Skip to content

Instantly share code, notes, and snippets.

View sneal's full-sized avatar

Shawn Neal sneal

View GitHub Profile
@sneal
sneal / main.go
Created January 11, 2024 19:58
CF apps running each diego cell
package main
import (
"context"
"fmt"
"github.com/cloudfoundry-community/go-cfclient/v3/client"
"github.com/cloudfoundry-community/go-cfclient/v3/config"
"github.com/cloudfoundry-community/go-cfclient/v3/resource"
"os"
)
@sneal
sneal / config.go
Last active December 6, 2023 18:39
go-cfclient config.New
func (c *Config) OAuth2HTTPClient(ctx context.Context) (*http.Client, error) {
// if explicitly configured with an oauth2 transport then use as-is
if _, ok := c.httpClient.Transport.(*oauth2.Transport); ok {
return c.httpClient, nil
}
// use our http.Client instance for token acquisition
oauthCtx := context.WithValue(ctx, oauth2.HTTPClient, c.httpClient)
var tokenSource oauth2.TokenSource
@sneal
sneal / README.md
Last active September 8, 2023 18:51
TAS External MySQL MIgration -> Internal TAS MySQL

Migration to TAS Internal MySQL

Migrating from an externally hosted MySQL DB server such as RDS or Oracle MySQL to the internally managed TAS HA cluster MySQL requires some extra steps to avoid application downtime. To avoid unnecessary downtime and churn we want to avoid having TAS system components ever see an empty MySQL database.

At a high level the overall procedure is:

  1. create single internal mysql instance
  2. bosh stop cloud_controller
This topic describes how to migrate your VMware Tanzu Operations Manager (Ops Manager) installation to a new vSphere datastore.
Prerequisites
Both the new and existing vSphere datastores must reside in the same data center.
To avoid service disruption, VMware recommends that you configure your overall Ops Manager deployment for high availability (HA). In addition, check for configurations necessary to achieve HA in each of your installed product tiles.
If your environment has any single points of failure, service might be disrupted as a result of the migration.
Before You Begin

This PowerCLI snippet can be used to find all the BOSH VMs connected to a specific datastore and then disconnect the CD-ROM to avoid vMotion or SDRS errors.

  1. Open a PowerCLI session and login to the appropriate vCenter using the Connect-VIServer command.
  2. Copy the below eject-iso.ps1 snippet locally
  3. Change the datastore name, from dsname to whatever your datastore name is.
  4. Execute the script

The final output table will contain all the VMs processed and list out the updated ISOPaths which should be empty at this point.

NOTE The script only modifies BOSH VMs, i.e. those with mounted env.iso files, however the output will display all VMs on the specified datastore and any other non-BOSH ISOs mounted.

@sneal
sneal / README.md
Created July 12, 2023 20:31
BOSH datastore cluster - datastore evacuation

This topic describes how to change your VMware Tanzu Operations Manager (Ops Manager) installation's underlying vSphere datastore clusters.

Before You Begin

The following sections describe the steps you can do prior to the migration.

Step 1: Back Up Your Environment

Ensure that your Ops Manager environment is fully backed up.

For more information about how to back up Ops Manager, see Backing Up Deployments.

@sneal
sneal / orderfiles.py
Created June 5, 2023 04:42
Script to rename all GoPro generated media in a directory to an ordinal number series (i.e. human understandable)
import sys, os
from pathlib import Path
from operator import itemgetter
p = ''.join(sys.argv[1:])
if len(p) == 0:
print('you must give a fully qualified directory path to process')
exit()
files = list(Path(p).glob('*.MP4'))
@sneal
sneal / README.md
Created May 11, 2023 20:51
vsphereVolume manual reattach

Using Pre-Existing Persistent Disks as PersistentVolumes

This explains how to create a PersistentVolume using existing (vsphereVolume) persistent disks populated with data, and how to use the PersistentVolume in a Pod.

Create Nginx Pod With PV

Create a storage class in the nginx namespace, here we're using the obsolete in-tree VCP provisioner:

apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: vcp-storage
@sneal
sneal / evc.patch
Last active May 13, 2023 14:53
Intel Sandy-Bridge EVC patch for BOSH
diff --git vsphere_cpi/lib/cloud/vsphere/resources/vm.rb vsphere_cpi/lib/cloud/vsphere/resources/vm.rb
index 69cb1a56..8e944a75 100644
--- vsphere_cpi/lib/cloud/vsphere/resources/vm.rb
+++ vsphere_cpi/lib/cloud/vsphere/resources/vm.rb
@@ -232,6 +232,10 @@ module VSphereCloud
@client.upgrade_vm_virtual_hardware(@mob)
end
+ def set_evc_mode
+ @client.apply_evc_mode(@mob)
@sneal
sneal / main.go
Created August 11, 2022 21:48
Set vSphere EVC mode on a VM using govmomi
package main
import (
"context"
"fmt"
"github.com/vmware/govmomi"
"github.com/vmware/govmomi/find"
"github.com/vmware/govmomi/object"
"github.com/vmware/govmomi/property"
"github.com/vmware/govmomi/session"