Skip to content

Instantly share code, notes, and snippets.

@mcornea
mcornea / reboot.py
Created March 21, 2023 14:07
redfish reboot
import openshift as oc
import redfish
import time
def bmc_hard_reboot(bmc_url, bmc_user, bmc_pass):
bmc_host = bmc_url.split('://')[-1].split('/')[0]
bmc_prefix = '/' + '/'.join(bmc_url.split('://')[-1].split('/')[1:])
headers = {'Content-Type': 'application/json'}
body = {'ResetType': 'ForceRestart'}
@mcornea
mcornea / test_du_deployment.yaml
Created October 22, 2021 09:24
test_du_deployment
---
apiVersion: v1
kind: Namespace
metadata:
name: testns
---
apiVersion: v1
kind: ConfigMap
metadata:
name: index-html-configmap
@mcornea
mcornea / test-deployment.yaml
Created September 29, 2021 13:21
test-deployment
---
apiVersion: v1
kind: Namespace
metadata:
name: testns
---
apiVersion: v1
kind: ConfigMap
metadata:
name: index-html-configmap
@mcornea
mcornea / httpd-pdb-anti-affinity.yaml
Last active November 10, 2020 18:46
httpd-pdb-anti-affinity
apiVersion: apps/v1
kind: Deployment
metadata:
name: httpd
namespace: test
spec:
replicas: 2
selector:
matchLabels:
app: httpd
@mcornea
mcornea / 00-worker-lb.yaml
Last active May 13, 2020 19:08
worker-lb role
apiVersion: machineconfiguration.openshift.io/v1
kind: MachineConfig
metadata:
annotations:
machineconfiguration.openshift.io/generated-by-controller-version: 910f22cb1550ad7bb02b82c5dc05062b1566ce5f
creationTimestamp: "2020-05-13T18:39:58Z"
generation: 1
labels:
machineconfiguration.openshift.io/role: worker-lb
name: 00-worker-lb
@mcornea
mcornea / add-machine-ips.sh
Last active February 27, 2020 19:00
BZ#1801238_workaround
#!/bin/bash
set -x
set -e
for node in $(oc --config $KUBECONFIG get nodes -o template --template='{{range .items}}{{.metadata.uid}}:{{.metadata.name}}{{"\n"}}{{end}}'); do
node_name=$(echo $node | cut -f2 -d':')
machine_name=$CLUSTER_NAME-$(echo $node_name | grep -oE "(master|worker)-[0-9]+")
if [[ "$machine_name" == *"worker"* ]]; then
echo "Skipping worker $machine_name because it should have inspection data to link automatically"
continue
@mcornea
mcornea / 02_configure_host.sh.diff
Created January 23, 2020 14:10
02_configure_host.sh
diff --git a/02_configure_host.sh b/02_configure_host.sh
index 7451bbc..687f8fe 100755
--- a/02_configure_host.sh
+++ b/02_configure_host.sh
@@ -104,9 +104,14 @@ if [ "$MANAGE_INT_BRIDGE" == "y" ]; then
# external access so we need to make sure we maintain dhcp config if its available
if [ "$INT_IF" ]; then
echo -e "DEVICE=$INT_IF\nTYPE=Ethernet\nONBOOT=yes\nNM_CONTROLLED=no\nBRIDGE=baremetal" | sudo dd of=/etc/sysconfig/network-scripts/ifcfg-$INT_IF
- if sudo nmap --script broadcast-dhcp-discover -e $INT_IF | grep "IP Offered" ; then
- grep -q BOOTPROTO /etc/sysconfig/network-scripts/ifcfg-baremetal || (echo -e "\nBOOTPROTO=dhcp\n" | sudo tee -a /etc/sysconfig/network-scripts/ifcfg-baremetal)
## Run the following commands on the hypervisor host. Any host used for InfraRed virt deployments should do the job.
## Download RHEL8 beta image
curl -o /var/lib/libvirt/images/rhel-guest-image-8.0-1690.x86_64.qcow2 http:///rhel-guest-image-8.0-1690.x86_64.qcow2
## Downloag libguestfs appliance to allow virt-customize on RHEL7 hypervirosr
curl -o /tmp/libguestfs_appliance.tar.gx http://download.libguestfs.org/binaries/appliance/appliance-1.40.1.tar.xz
tar -C /tmp/ -xvf /tmp/libguestfs_appliance.tar.gx
## Create the disk file to be used for the standalone VM
qemu-img create -f qcow2 /var/lib/libvirt/images/standalone.qcow2 100G
@mcornea
mcornea / expose_console.sh
Created September 24, 2019 00:23
expose console
pushd /home/rhhi-ci/jenkins/workspace/rhhi.next-virt-customized
source rhhi-qe-venv/bin/activate
ansible-playbook -i rhhi-qe-core/s2i/linchpin-provisioner/linchpin_workspace/inventories/rhhi.inventory rhhi-qe-core/s2i/linchpin-provisioner/linchpin_workspace/hooks/ansible/rhhi-setup/iptables_console.yaml -e @rhhi-qe-core/s2i/linchpin-provisioner/linchpin_workspace/hooks/ansible/rhhi-setup/extravars.yaml
@mcornea
mcornea / test
Last active September 19, 2019 13:31
test
diff --git a/OpenShift/assets/deploy/90_metal3_baremetalhost_crd.yaml b/OpenShift/assets/deploy/90_metal3_baremetalhost_crd.yaml
deleted file mode 100644
index 0c29c82..0000000
--- a/OpenShift/assets/deploy/90_metal3_baremetalhost_crd.yaml
+++ /dev/null
@@ -1,371 +0,0 @@
-apiVersion: apiextensions.k8s.io/v1beta1
-kind: CustomResourceDefinition
-metadata:
- name: baremetalhosts.metal3.io