Skip to content

Instantly share code, notes, and snippets.

View jameswnl's full-sized avatar

James Wong jameswnl

View GitHub Profile
#!/bin/sh
set -o errexit
set -o pipefail
######### postgres_ready #########
postgres_ready() {
python << END
import logging
import os
@jameswnl
jameswnl / port-forward.sh
Created July 10, 2020 20:58
script to port forwarding to the test-data-generator pod
#!/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
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]
@jameswnl
jameswnl / conversion_host_spec.rb
Last active February 8, 2019 21:16
spec stub method
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)
sudo xcode-select -s /Library/Developer/CommandLineTools && gem install ovirt-engine-sdk -v4.1.9 && sudo xcode-select -r
@jameswnl
jameswnl / vmware_metric_counters.rb
Created October 17, 2017 15:14
VMware metric counters
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 November 15, 2017 20:10
Describe pain points with possible enhancements of creating a new MIQ Provider

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 October 3, 2017 18:19
Set up 2nd MIQ appliance
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
{"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
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)