Skip to content

Instantly share code, notes, and snippets.

Avatar

James Wong jameswnl

View GitHub Profile
@jameswnl
jameswnl / port-forward.sh
Created Jul 10, 2020
script to port forwarding to the test-data-generator pod
View port-forward.sh
#!/bin/sh
oc project tower-analytics-$1. # expect either ci or qa
if [ $? -eq 1 ]; then
echo "oc project tower-analytics-$0 failed. Abort"
exit 1
fi
for i in $(oc get pods -o name);
do
echo $i
View gist:b7fafa8396aef046148a6f688b7b0ff6
vagrant@minikf:~/kfv1$ kfctl generate all -V
INFO[0000] Ksonnet.Generate Name AppDir Platform filename="ksonnet/ksonnet.go:369"
INFO[0000] Creating environment "default" with namespace "default", pointing to "version:v1.13.2" cluster at address "https://10.10.10.10:8443" filename="env/create.go:77"
INFO[0003] Generating ksonnet-lib data at path 'ks_app/lib/ksonnet-lib/v1.13.2' filename="lib/lib.go:148"
INFO[0003] Successfully initialized the app . filename="ksonnet/ksonnet.go:505"
INFO[0003] App add registry kubeflow URI filename="ksonnet/ksonnet.go:621"
Error: couldn't generate KfApp: (kubeflow.error): Code 500 with message: kfApp Generate failed for ksonnet: (kubeflow.error): Code 400 with message: couldn't add registry kubeflow. Error: there was a problem adding registry kubeflow: initializing helm HTTP client: normalizing Helm repository URL: "" is an invalid scheme for Helm repository
Usage:
kfctl generate [all(=default)|k8s|platform] [flags]
View conversion_host_spec.rb
require "MiqSshUtil"
describe ConversionHost do
let(:apst) { FactoryBot.create(:service_template_ansible_playbook) }
let(:host) { FactoryBot.create(:host) }
let(:vm) { FactoryBot.create(:vm_or_template) }
before do
allow(vm).to receive(:supports_conversion_host?).and_return(true)
allow(host).to receive(:supports_conversion_host?).and_return(true)
View ovirt_engine_skd_problem.sh
sudo xcode-select -s /Library/Developer/CommandLineTools && gem install ovirt-engine-sdk -v4.1.9 && sudo xcode-select -r
View vmware_metric_counters.rb
counter_keys = ["net_usage_rate_average",
"mem_vmmemctl_absolute_average",
"net_usage_rate_average",
"cpu_ready_delta_summation",
"mem_swaptarget_absolute_average",
"net_usage_rate_average",
"net_usage_rate_average",
"cpu_ready_delta_summation",
"mem_vmmemctltarget_absolute_average",
"net_usage_rate_average",
@jameswnl
jameswnl / NewMiqProvider.md
Last active Nov 15, 2017
Describe pain points with possible enhancements of creating a new MIQ Provider
View NewMiqProvider.md

Based on using existing generator commnd: rails generate provider <AnyCloud>

Difficulties/Problems

  1. Variable not found error for the new cloud manager due to naming convention of class and folder.
  2. UI add-provider page: Validate button not enabled
  3. manageiq-ui-classic/app/views/layouts/angular-bootstrap/_auth_credentials_angular_bootstrap.html.haml
  4. manageiq-ui-classic/app/views/layouts/angular-bootstrap/_endpoints_angular.html.haml
@jameswnl
jameswnl / SecondMiqAppliance
Created Oct 3, 2017
Set up 2nd MIQ appliance
View SecondMiqAppliance
systemctl stop evmserverd && systemctl disable evmserverd
systemctl stop $APPLIANCE_PG_SERVICE && systemctl disable $APPLIANCE_PG_SERVICE
rm -rf $APPLIANCE_PG_DATA/*
vmdb && rm -f REGION config/database.yml
View dvswitch hash
{"MOR":"dvs-138", "config":{"uuid":"72 e1 2a 50 23 7a 6f 8c-2a 0d ed 82 3f 77 4a ab", "name":"DC1_DVS", "numStandalonePorts":"0", "numPorts":"384", "maxPorts":"2147483647", "uplinkPortPolicy":{"uplinkPortName":["uplink1", "uplink2", "uplink3", "uplink4"]}, "uplinkPortgroup":["dvportgroup-139"], "defaultPortConfig":{"blocked":{"inherited":"false", "value":"false"}, "vmDirectPathGen2Allowed":{"inherited":"false", "value":"false"}, "inShapingPolicy":{"inherited":"false", "enabled":{"inherited":"false", "value":"false"}, "averageBandwidth":{"inherited":"false", "value":"100000000"}, "peakBandwidth":{"inherited":"false", "value":"100000000"}, "burstSize":{"inherited":"false", "value":"104857600"}}, "outShapingPolicy":{"inherited":"false", "enabled":{"inherited":"false", "value":"false"}, "averageBandwidth":{"inherited":"false", "value":"100000000"}, "peakBandwidth":{"inherited":"false", "value":"100000000"}, "burstSize":{"inherited":"false", "value":"104857600"}}, "vendorSpecificConfig":{"inherited":"false"}, "net
View db_migration_plan_for_VDS
DB migration plan for VMware Distributed vSwitch support:
PR1:
1. update table switches.uid_ems = switches.host_id + "|" + switches.uid_ems
2. add index to switches on field uid_ems :uniquness => true
(VDS already has its uid_ems natural unique, this migration is to enforce that for local vSwitches)
PR2:
1. create a join table between hosts and switches, host_switches
2. populate (host_switches.host_id, host_switches.uid_ems) = (switches.host_id, switches.uid_ems)
View ec2-cloudwatch.py
#https://boto3.readthedocs.org/en/latest/reference/services/cloudwatch.html
import boto3
client = boto3.client('cloudwatch')
r2=client.get_metric_statistics(Namespace='AWS/EC2', MetricName='CPUUtilization',Statistics=['SampleCount'],StartTime=datetime(2015, 7, 19), EndTime=datetime(2015, 7, 20), Period=120, Dimensions=[{'Name': 'InstanceId', 'Value': 'i-6a469f90'}])
runs=[]
for status in ec2.meta.client.describe_instance_status()['InstanceStatuses']:
runs.append(status)