Skip to content

Instantly share code, notes, and snippets.

@arcolife
Last active August 16, 2017 10:13
Show Gist options
  • Save arcolife/c8cd4bf706a12248244e65004de360b4 to your computer and use it in GitHub Desktop.
Save arcolife/c8cd4bf706a12248244e65004de360b4 to your computer and use it in GitHub Desktop.
rhevm OCP node restart log

get OCP node vm names in RHVM


ovirt-shell --url https://<rhevm.url.com>/ovirt-engine/api -u admin@internal --insecure -E "list vms --query "name=vm*"  --show-all | egrep '^name |guest_info-ips-ip-address.*10'" > ips

egrep ' 10\.' -B 1 ips  | sed s/--//g > ocp_ips
# egrep ' 10\.' -B 1 ips  | sed s/--//g | sed '/^\s*$/d' > refined_ocp_ips

# cat ~/.psql_history | grep 'update vm_dynamic set' | awk '{ print $(NF)}' | sed -e s/\'//g  -e 's/;//g' -e 's/)//g' > ocp_nodes
less ocp_ips  | grep name | awk '{print $NF}' | sort > ocp_nodes_all
sort ocp_nodes > ocp_nodes_few
comm -12 ocp_nodes_all ocp_nodes_few > ocp_nodes_common
awk 'NR==FNR{a[$0]=1;next}!a[$0]' ocp_nodes_common  ocp_nodes_few >> ocp_nodes_common 
awk 'NR==FNR{a[$0]=1;next}!a[$0]' ocp_nodes_common  ocp_nodes_all >> ocp_nodes_common
sort ocp_nodes_common  > ocp_nodes

Python ovirt SDK to start all vms

from ovirtsdk.api import API 
from ovirtsdk.xml import params   

url = "https://<rhevm.url.com>/ovirt-engine/api"
password = ""

try:
    api = API (url=url,
               username="admin@internal",
               password=password,
               #ca_file="ca.crt")
               insecure=True)

    
    for vm_name in open('ocp_nodes').read().splitlines():

        vm = api.vms.get(name=vm_name)

        try:
            vm.start()
            print "Started '%s'." % vm.get_name()
        except Exception as ex:
            # print "Unable to start '%s': %s" % (vm.get_name(), ex)
            print "Exception for VM: {}\n{}".format(vm_name, ex)
            
    api.disconnect()

except Exception as ex:
    print "Unexpected error: %s" % ex

executing the VM start script

[root@rhevm ~]# python ./rhvm_start_vm.py 
Exception for VM: OCP_medium_master

status: 409
reason: Conflict
detail: Cannot run VM because the VM is in Up status.
Exception for VM: vm1_0
'NoneType' object has no attribute 'start'
Exception for VM: vm100_0

status: 409
reason: Conflict
detail: Cannot run VM because the VM is in Up status.
Exception for VM: vm101_0

status: 409
reason: Conflict
detail: Cannot run VM because the VM is in Up status.
Exception for VM: vm102_0

status: 409
reason: Conflict
detail: Cannot run VM because the VM is in Up status.
Exception for VM: vm103_0

status: 409
reason: Conflict
detail: Cannot run VM. There is no host that satisfies current scheduling constraints. See below for details:, The host smerf06a3 did not satisfy internal filter Memory because its available memory is too low (0.000000 MB) to run the VM.
Exception for VM: vm104_0

status: 409
reason: Conflict
detail: Cannot run VM. There is no host that satisfies current scheduling constraints. See below for details:, The host smerf06a3 did not satisfy internal filter Memory because its available memory is too low (0.000000 MB) to run the VM.
Exception for VM: vm105_0

status: 409
reason: Conflict
detail: Cannot run VM. There is no host that satisfies current scheduling constraints. See below for details:, The host smerf06a3 did not satisfy internal filter Memory because its available memory is too low (0.000000 MB) to run the VM.
Exception for VM: vm2_0

status: 409
reason: Conflict
detail: Cannot run VM because the VM is in Up status.
Exception for VM: vm200_0

status: 409
reason: Conflict
detail: Cannot run VM because the VM is in Up status.
Exception for VM: vm201_0

status: 409
reason: Conflict
detail: Cannot run VM because the VM is in Up status.
Exception for VM: vm202_0

status: 409
reason: Conflict
detail: Cannot run VM because the VM is in Up status.
Exception for VM: vm203_0

status: 409
reason: Conflict
detail: Cannot run VM because the VM is in Up status.
Exception for VM: vm204_0

status: 409
reason: Conflict
detail: Cannot run VM. There is no host that satisfies current scheduling constraints. See below for details:, The host smerf06a4 did not satisfy internal filter Memory because its available memory is too low (4033.000000 MB) to run the VM.
Exception for VM: vm205_0

status: 409
reason: Conflict
detail: Cannot run VM. There is no host that satisfies current scheduling constraints. See below for details:, The host smerf06a4 did not satisfy internal filter Memory because its available memory is too low (4033.000000 MB) to run the VM.
Exception for VM: vm250_0

status: 409
reason: Conflict
detail: Cannot run VM because the VM is in Up status.
Exception for VM: vm251_0

status: 409
reason: Conflict
detail: Cannot run VM because the VM is in Up status.
Exception for VM: vm252_0

status: 409
reason: Conflict
detail: Cannot run VM because the VM is in Up status.
Exception for VM: vm253_0

status: 409
reason: Conflict
detail: Cannot run VM because the VM is in Up status.
Exception for VM: vm254_0

status: 409
reason: Conflict
detail: Cannot run VM because the VM is in Up status.
Exception for VM: vm255_0

status: 409
reason: Conflict
detail: Cannot run VM because the VM is in Up status.
Exception for VM: vm300_0

status: 409
reason: Conflict
detail: Cannot run VM because the VM is in Up status.
Exception for VM: vm301_0

status: 409
reason: Conflict
detail: Cannot run VM because the VM is in Up status.
Exception for VM: vm302_0

status: 409
reason: Conflict
detail: Cannot run VM because the VM is in Up status.
Exception for VM: vm303_0

status: 409
reason: Conflict
detail: Cannot run VM because the VM is in Up status.
Exception for VM: vm304_0

status: 409
reason: Conflict
detail: Cannot run VM because the VM is in Up status.
Exception for VM: vm305_0

status: 409
reason: Conflict
detail: Cannot run VM because the VM is in Up status.
Exception for VM: vm4_0

status: 409
reason: Conflict
detail: Cannot run VM because the VM is in Up status.
Started 'vm400_0'.
Started 'vm401_0'.
Started 'vm402_0'.
Started 'vm403_0'.
Started 'vm404_0'.
Started 'vm405_0'.
Started 'vm5_0'.
Started 'vm500_0'.
Started 'vm501_0'.
Started 'vm502_0'.
Started 'vm503_0'.
Started 'vm504_0'.
Started 'vm505_0'.
Started 'vm550_0'.
Started 'vm551_0'.
Started 'vm552_0'.
Started 'vm553_0'.
Started 'vm554_0'.
Started 'vm555_0'.
Started 'vm6_0'.
Started 'vm600_0'.
Started 'vm601_0'.
Started 'vm602_0'.
^[[AStarted 'vm603_0'.
Started 'vm604_0'.
Started 'vm605_0'.
Exception for VM: vm700_0

status: 409
reason: Conflict
detail: Cannot run VM because the VM is in Up status.
Exception for VM: vm701_0

status: 409
reason: Conflict
detail: Cannot run VM because the VM is in Up status.
Exception for VM: vm702_0

status: 409
reason: Conflict
detail: Cannot run VM because the VM is in Up status.
Exception for VM: vm703_0

status: 409
reason: Conflict
detail: Cannot run VM because the VM is in Up status.
Exception for VM: vm704_0

status: 409
reason: Conflict
detail: Cannot run VM because the VM is in Up status.
Exception for VM: vm705_0

status: 409
...
...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment