OpenStack: Application credentials

Create applications credentials
openstack application credential create admin --role admin --expiration $(date -I -d '+1 month')T23:59:59 -c id -c secret #-f value

Configure clouds.yml
# ~/.config/openstack/clouds.yaml
clouds:
dev-app:
auth_type: "v3applicationcredential"
auth:
auth_url: https://keystone.example.com/v3
application_credential_id: "b9275fc5b3aadceeb407fbe941427425"
application_credential_secret: "HqfdfKk3q63xrnIZgdkizePfv1s27aYPBTrbiMKFNdrOU1JpdjfR0KSyomS4A01vSdxjkE9MzPuM4dVG7emWuA"

Open vSwitch (OVS)

Create
ovs-vsctl -- --may-exist add-port br-int o-hm0 -- \
set Interface o-hm0 type=internal -- \
set Interface o-hm0 external-ids:iface-status=active -- \
set Interface o-hm0 external-ids:attached-mac=${CTL_HOST_MAC} -- \
set Interface o-hm0 external-ids:iface-id=${PORT_ID} -- \
set Interface o-hm0 external-ids:skip_cleanup=true

Delete
ovs-vsctl -- del-port br-int o-hm0

Create port
openvswitch_vswitchd ovs-vsctl -- --may-exist add-port br-int my-port1 -- \
set Interface o-hm0 type=internal -- \

OpenStack: Glance (Image)

Deaktivate image
IMAGE_NAME="Ubuntu 14.04"
openstack image list --status active --name "${IMAGE_NAME}" -c ID -f value | xargs openstack image set --deactivate --private
openstack image list --status active

List the images
openstack image list

Delete all images
for IMAGE in $(openstack image list -c ID -f value); do
openstack image set --unprotected ${IMAGE}
openstack image delete ${IMAGE}
done

Delete image
IMAGE_NAME="Ubuntu 16.04"
openstack image set --unprotected ${IMAGE_NAME}

OpenStack: Live migrate VM to another OpenStack hypervisor

VM=foo-u1804

# list all vms on a hypervisor
openstack server list --all --status ACTIVE --host com1.example.com

# get current hypervisor
openstack server show ${VM} -c OS-EXT-SRV-ATTR:host -f value

# list avaiable hypervisors
openstack host list -c "Host Name" -c Service -f value | grep compute | cut -d" " -f1

# migrate VM
openstack server migrate ${VM} --live ${TARGET_COMPUTE_NODE} --wait

# get state
openstack server show ${VM} -c name -c OS-EXT-SRV-ATTR:host -c status -f value | paste - - -

# migrate all VMs
openstack server list --all --host ${OS_NODE}

Ansible Redfish module

# redfish_facts module
Documentation: https://docs.ansible.com/ansible/latest/modules/redfish_facts_module.html
Git: https://github.com/ansible/ansible/blob/devel/lib/ansible/modules/remote_management/redfish/redfish_facts.py
local: /usr/lib/python2.7/dist-packages/ansible/modules/remote_management/redfish/redfish_facts.py

# redfish_utils library
Git: https://github.com/ansible/ansible/blob/devel/lib/ansible/module_utils/redfish_utils.py
local: /usr/lib/python2.7/dist-packages/ansible/module_utils/redfish_utils.py

#!/usr/bin/env ansible-playbook

---
- hosts: localhost
vars:

Migrate LXC container to LXD (with ZFS storage)

CONTAINER_NAME=www

lxc-stop -n ${CONTAINER_NAME}
lxc init ubuntu:18.04 ${CONTAINER_NAME} -c security.privileged=true -c boot.autostart=true
#lxc stop ${CONTAINER_NAME}
#lxc config set ${CONTAINER_NAME} boot.autostart true
zfs mount tank/lxd/containers/${CONTAINER_NAME}
mv /var/lib/lxd/containers/${CONTAINER_NAME}/rootfs{,.org}
rsync -av --numeric-ids /var/lib/lxc/${CONTAINER_NAME}/rootfs /var/lib/lxd/containers/${CONTAINER_NAME}/
mv /var/lib/lxd/containers/${CONTAINER_NAME}/rootfs/dev{,.org}

OpenStack: Octavia LoadBalancer (LBaaS)

Create Amphora image
sudo apt install -y python-pip git qemu qemu-utils debootstrap kpartx
sudo pip install diskimage-builder
git clone https://review.openstack.org/p/openstack/octavia
cd octavia
sudo ./diskimage-create/diskimage-create.sh -d bionic -t raw
chmod a+r ./amphora-x64-haproxy.raw

Upload Amphora image
#openstack image create --container-format bare --disk-format qcow2 --private --file amphora-x64-haproxy.qcow2 --tag amphora amphora

iLO - IPMI on HP servers

Download Latest firmware
http://pingtool.org/latest-hp-ilo-firmwares/
https://support.hpe.com/hpesc/public/home/driverHome?sp4ts.oid=1009143853
# download "RECOMMENDED * Online ROM Flash Component for Linux - HPE Integrated Lights-Out"

Extract firmware
chmod +x /tmp/CP0*.scexe
/tmp/CP0*.scexe --unpack=/tmp

# flash iLo firmware (local)
yes | ./CP036949.scexe

# ipmitool -I lanplus -H www1-ipmi -U Administrator -P pass1234 hpm upgrade ilo4_261.bin

Flash iLo with SSH (not tested)