This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export DB_APP=$(juju 2>/dev/null status --format=json|jq 2>/dev/null -r '.applications | to_entries[] |"\(select((.value."charm-name"|startswith("perc")) or .value."charm-name" == "mysql").key)"') | |
export MYSQL_PW=$(juju 2>/dev/null run --unit ${DB_APP}/0 leader-get |awk 2>/dev/null '/mysql.passwd/{print $2}') | |
#Create array of Hypervisors with hostnames, virt type and IP | |
declare -ag OS_COMPUTE_NODES=($(juju ssh mysql/0 "mysql 2>/dev/null -u root -p${MYSQL_PW} -s -N -D nova -e 'SELECT hypervisor_hostname,hypervisor_type,host_ip FROM compute_nodes;'" 2>/dev/null|sed 's/\t/,/g'|sort -uV)) | |
# Print list of hypervisors from above array | |
for N in ${!OS_COMPUTE_NODES[@]};do printf "\e[2G$(($N+1))\e[0m) ${OS_COMPUTE_NODES[$N]//,/\\t}\n"; done|column -next |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#These commands should go directly under the maas command in the late_commands section in /etc/maas/preseeds/curtin_userdatas | |
#Spacing matters, copy as is. | |
nvidia_00_cmd: ["sh", "-c", "echo Blacklist Nouveau and Adding Cuda Drivers."] | |
nvidia_01_cmd: ["curtin", "in-target", "--", "sh", "-c", "echo", "-en", "blacklist nouveau\noptions nouveau modeset=0\n >> /etc/modeprobe.d/blacklist-nouveau.conf"] | |
nvidia_02_cmd: ["curtin", "in-target", "--", "sh", "-c", "wget -qO- http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/7fa2af80.pub|apt-key add -"] | |
nvidia_03_add: ["curtin", "in-target", "--", "add-apt-repository", "-y", "deb http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64 /"] | |
nvidia_04_cmd: ["curtin", "in-target", "--", "sh", "-c", "apt update"] | |
nvidia_05_cmd: ["curtin", "in-target", "--", "sh", "-c", "DEBIAN_FRONTEND=noninteractive apt install cuda -yq"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
maas ${MAAS_PROFILE} tags create name=pod-host \ | |
definition='//node[@id="memory" and @class="memory"]/size >= "17179860388" and | |
//node[@id="cpu" and @class="processor"]/configuration/setting/id="cores" >= 2 and | |
.//node[@id="cpu"]/capabilities/capability[@id="vmx"] and | |
.//node[@id="cpu"]/capabilities/capability[@id="aes"] and | |
.//node[@id="cpu"]/capabilities/capability[@id="ept"] and | |
.//node[@id="cpu"]/capabilities/capability[@id="vpid"] and | |
.//node[@id="cpu"]/capabilities/capability[@id="tpr_shadow"] and | |
.//node[@id="cpu"]/capabilities/capability[@id="flexpriority"] and | |
.//node[@id="cpu"]/capabilities/capability[@id="vnmi"]' \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#Script to configure openstack on Orangebox | |
[[ ${HOSTNAME,,} =~ orangebox ]] && export OB_NUM=$((10#${HOSTNAME:9})) || OB_NUM=20 | |
#Networking Variables - External will be provider, Int will be tenant | |
export NEUTRON_DNS1="172.27.$((${OB_NUM})).1" | |
export NEUTRON_DNS2="172.27.$((${OB_NUM}+2)).1" | |
export NEUTRON_DNS3="172.27.$((${OB_NUM}+3)).254" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
maas admin dnsresources create name=livepatch domain=canonical.com ip_addresses="162.213.33.130 162.213.33.177" | |
maas admin dnsresources create name=ntp domain=ubuntu.com ip_addresses="91.189.89.199 91.189.94.4 91.189.91.157 91.189.89.198" | |
maas admin dnsresources create name=landscape domain=canonical.com ip_addresses="91.189.89.90 91.189.89.173" | |
maas admin dnsresources create name=usn domain=ubuntu.com ip_addresses="162.213.33.205 162.213.33.20 162.213.33.141" | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
random-ipv6-range() { | |
local DESC="\e[1m${FUNCNAME}: Create a sequential range of IP addresses\e[0m\n" | |
[[ $1 = '--desc' ]] && { printf "${DESC}";return; } | |
random-ipv6-range_usage() { | |
printf "\n${DESC}\n" | |
printf "\e[2GUsage: ${FUNCNAME%%_*} [OPTIONS]\n\n" | |
printf "\e[2GOptions:\n" | |
printf "\e[4G -c, --count \e[24GNumber of IPv6 addresses to include in the range\n" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
increment-mac() { | |
local DESC="\e[1m${FUNCNAME}: Prints incrementing MAC address numbers\e[0m\n" | |
[[ $1 = '--desc' ]] && { printf "${DESC}";return; } | |
increment-mac_usage() { | |
printf "\n${DESC}\n" | |
printf "\e[2GUsage: ${FUNCNAME%%_*} [OPTIONS]\n\n" | |
printf "\e[2GOptions:\n" | |
printf "\e[4G -c, --count \e[20GNumber of MAC address to print\n" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
juju-upgrade-openstack() { | |
export SERIES=xenial | |
export RELEASE=pike | |
export CURRENT_MODEL=$(juju models|awk '/*/{gsub(/*/,"");print $1}') | |
printf "\e[2GGetting list of applications from juju model \"${CURRENT_MODEL}\" \n" | |
declare -ag JUJU_APPS=($(juju 2>/dev/null status --format=json|jq 2>/dev/null -r '.applications | to_entries[].key')) | |
printf "%s\n" ${JUJU_APPS[@]} | |
printf "\e[2GGetting list of openstack applications from juju model \"${CURRENT_MODEL}\" \n" | |
declare -ag UPGRADE_APPS=($(for APP in ${JUJU_APPS[@]};do [[ -n $(juju 2>/dev/null config ${APP} action-managed-upgrade) ]] && echo ${APP};done)) | |
printf "%s\n" ${UPGRADE_APPS[@]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#If populating MAAS DNS with domains, all domains get added to the search order. | |
#Resolv.conf only supports 6, so if you have more 6 domains entered, nothing after the 6th gets resolved | |
#Also, juju for some reason is doing an alpha sort on domain, which in most cases (and in the case of http://launchpad.net/opm) puts | |
#the MAAS domain near the end, which is past the 6th domain. | |
#This function will go through all machines and containers in a model and set a given search order, or | |
#if used without arguments will set the maas domain as the only entry in dns-search | |
fix-deployed-dns-search() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#If you are using a monospace font, this will be a waste of time | |
unicode-space-test() { | |
declare -ag SPACE_ARRAY=( | |
'\u0020|SPACE|Typically 1/4 EM; Adjusted depending on font.' | |
'\u00A0|NO-BREAK SPACE|As a space; Often not adjusted.' | |
'\u1680|OGHAM SPACE MARK|Usually not really a space but a dash.' | |
'\u180E|MONGOLIAN VOWEL SEPARATOR|No width space.' | |
'\u2000|EN QUAD|1 EN; Fixed-width.' | |
'\u2001|EM QUAD|1 EM (nominally; the height of the font); Fixed-width.' | |
'\u2002|EN SPACE|1 EN; Fixed-width.' |