Example #1
0
File: esx.py Project: mennis/oTTo
 def rescan_hba(self):
     """
         Rescans the AOE HBA
     """
     cmd = mkcmdstr('esxcfg-scsidevs -a | grep -i coraid')
     result = self.run_and_check(cmd)
     hba_details = result.message.split(' ')
     hba_name = hba_details[0]
     logger.info(hba_name)
     cmd = mkcmdstr('esxcfg-rescan', hba_name)
     result = self.run_and_check(cmd, expectation=False)
     return result
Example #2
0
 def rescan_hba(self):
     """
         Rescans the AOE HBA
     """
     cmd = mkcmdstr('esxcfg-scsidevs -a | grep -i coraid')
     result = self.run_and_check(cmd)
     hba_details = result.message.split(' ')
     hba_name = hba_details[0]
     logger.info(hba_name)
     cmd = mkcmdstr('esxcfg-rescan', hba_name)
     result = self.run_and_check(cmd, expectation=False)
     return result
Example #3
0
File: esx.py Project: mennis/oTTo
    def power_on_vm(self, vm_list):
        """
            Power on the VM(s)
        """
        result = ReturnCode(False, message="empty vm_list")
        for vm in vm_list:
            cmd = mkcmdstr('vim-cmd vmsvc/power.getstate', vm)
            result = self.run_and_check(cmd)
            if result.message.find('Powered off') != -1:
                cmd = mkcmdstr('vim-cmd vmsvc/power.on', vm)
                result = self.run_and_check(cmd)
        logger.info("All vms are powered on")

        return result
Example #4
0
    def power_on_vm(self, vm_list):
        """
            Power on the VM(s)
        """
        result = ReturnCode(False, message="empty vm_list")
        for vm in vm_list:
            cmd = mkcmdstr('vim-cmd vmsvc/power.getstate', vm)
            result = self.run_and_check(cmd)
            if result.message.find('Powered off') != -1:
                cmd = mkcmdstr('vim-cmd vmsvc/power.on', vm)
                result = self.run_and_check(cmd)
        logger.info("All vms are powered on")

        return result
Example #5
0
File: esx.py Project: mennis/oTTo
    def shut_down_vm(self, vm_list):
        """
            Shut down/power off the VM(s)
        """
        errmsg = 'Cannot complete operation because VMware Tools is not running in this virtual machine'
        result = ReturnCode(False, message="empty vm_list")

        for vm in vm_list:
            cmd = mkcmdstr('vim-cmd vmsvc/power.getstate', vm)
            result = self.run_and_check(cmd)
            if result.message.find('Powered on') != -1:
                cmd = mkcmdstr('vim-cmd vmsvc/power.shutdown', vm)
                result = self.run_and_check(cmd)
                if result.message.find(errmsg) != -1:
                    cmd = mkcmdstr('vim-cmd vmsvc/power.off', vm)
                    result = self.run_and_check(cmd)

                else:
                    logger.info("VM is already powered off")
        return result
Example #6
0
File: esx.py Project: mennis/oTTo
 def claim_targets(self, target_list):
     """
     Claim the luns
     """
     lun_list = target_list.split(' ')
     result = ReturnCode(False, message="empty target list")
     for lun in lun_list:
         cmd = mkcmdstr('esxcli ethdrv claim -t', lun)
         logger.info(lun)
         result = self.run_and_check(cmd)
     return result
Example #7
0
    def shut_down_vm(self, vm_list):
        """
            Shut down/power off the VM(s)
        """
        errmsg = 'Cannot complete operation because VMware Tools is not running in this virtual machine'
        result = ReturnCode(False, message="empty vm_list")

        for vm in vm_list:
            cmd = mkcmdstr('vim-cmd vmsvc/power.getstate', vm)
            result = self.run_and_check(cmd)
            if result.message.find('Powered on') != -1:
                cmd = mkcmdstr('vim-cmd vmsvc/power.shutdown', vm)
                result = self.run_and_check(cmd)
                if result.message.find(errmsg) != -1:
                    cmd = mkcmdstr('vim-cmd vmsvc/power.off', vm)
                    result = self.run_and_check(cmd)

                else:
                    logger.info("VM is already powered off")
        return result
Example #8
0
 def claim_targets(self, target_list):
     """
     Claim the luns
     """
     lun_list = target_list.split(' ')
     result = ReturnCode(False, message="empty target list")
     for lun in lun_list:
         cmd = mkcmdstr('esxcli ethdrv claim -t', lun)
         logger.info(lun)
         result = self.run_and_check(cmd)
     return result
Example #9
0
File: esx.py Project: mennis/oTTo
 def hba_driver_install(self, path):
     """
       Install the specified HBA driver
     """
     cmd = mkcmdstr('esxcli software vib install -d', path)
     # logger.info( cmd )
     result = self.run_and_check(cmd)
     if result.message.find('Reboot Required: true') != -1:
         logger.info("Driver is installed. The system needs to be rebooted")
     else:
         logger.info("Driver is installed. System need not be rebooted")
     return result
Example #10
0
 def hba_driver_install(self, path):
     """
       Install the specified HBA driver
     """
     cmd = mkcmdstr('esxcli software vib install -d', path)
     # logger.info( cmd )
     result = self.run_and_check(cmd)
     if result.message.find('Reboot Required: true') != -1:
         logger.info("Driver is installed. The system needs to be rebooted")
     else:
         logger.info("Driver is installed. System need not be rebooted")
     return result
Example #11
0
File: esx.py Project: mennis/oTTo
 def get_vm_list(self):
     """
     Get the list of the VMs on the ESX
     """
     cmd = mkcmdstr('vim-cmd vmsvc/getallvms')
     result = self.run_and_check(cmd)
     lines = result.message.split('\n')
     vmids = []
     for l in lines:
         vmid = l.split(' ')
         if vmid[0] != 'Vmid':
             vmids.append(vmid[0])
         return vmids
Example #12
0
 def get_vm_list(self):
     """
     Get the list of the VMs on the ESX
     """
     cmd = mkcmdstr('vim-cmd vmsvc/getallvms')
     result = self.run_and_check(cmd)
     lines = result.message.split('\n')
     vmids = []
     for l in lines:
         vmid = l.split(' ')
         if vmid[0] != 'Vmid':
             vmids.append(vmid[0])
         return vmids
Example #13
0
File: esx.py Project: mennis/oTTo
    def check_vm_status(self, vm_list):
        """
            Checks if the VM(s) status is green/normal
        """
        result = ReturnCode(False, message="empty vm_list")

        for vm in vm_list:
            cmd = mkcmdstr('vim-cmd vmsvc/get.summary', vm)
            result = self.run_and_check(cmd)
            if result.message.find('overallStatus = \"green\"') != -1:
                logger.info("VM is in normal state")
            else:
                logger.info("VM is not in normal state")
        return result
Example #14
0
    def check_vm_status(self, vm_list):
        """
            Checks if the VM(s) status is green/normal
        """
        result = ReturnCode(False, message="empty vm_list")

        for vm in vm_list:
            cmd = mkcmdstr('vim-cmd vmsvc/get.summary', vm)
            result = self.run_and_check(cmd)
            if result.message.find('overallStatus = \"green\"') != -1:
                logger.info("VM is in normal state")
            else:
                logger.info("VM is not in normal state")
        return result