def main(): # Creating Object for VMwareLib Class logging.info("Program Started") obj = VmwareLib() logging.info("Object created for VmwareLib") logging.debug(obj) vcenter_ip = "183.82.41.58" username = "******" password = "******" # Connecting to Vcenter si = obj.connect(vcenter_ip, username, password) logging.debug(si) if si: logging.info("connection object created") loggin.debug(si) #Reboot operation host_name = "192.168.50.16" try: VMreboot(si, host_name, obj) except VMRebootException as vmerror: logging.exception(vmerror) logging.info("VMreboot exception") # Disconnecting to Vcenter obj.disconnect(si) logging.info("Program Ended")
def main(): # Creating Object for VMwareLib Class obj = VmwareLib() vcenter_ip = "183.82.41.58" username = "******" password = "******" # Connecting to Vcenter si = obj.connect(vcenter_ip, username, password) name("avinash", obj) obj.disconnect(si)
def main(): # Creating Object for VMwareLib Class logging.info("Program Started") vcenter_ip = "183.82.41.58" username = "******" password = "******" # Creating Object for VMware Class obj = VmwareLib() logging.info("Object created for VmwareLib") logging.debug(obj) # Connecting to Vcenter si = obj.connect(vcenter_ip, username, password) if si: logging.info("connection object created") logging.debug(si) #Disk Increasing Operation #step1: (Getting the Target VM) vm_name = "ubuntu16.04" vm = get_vm(si, vm_name, obj) if vm: logging.info("The given Vm Found successfully") #Step2: Checking the powersgtatus of the VM , If power is ON , it will Power off the VM power_off_vm(vm, obj) #Step3: checking the initial disk space diskspace_initial = initial_diskspace(vm, obj) print "The actual capacity of the disk is :" + str( diskspace_initial / (1024 * 1024)) logging.info("The actual capacity of the disk is :" + str(diskspace_initial / (1024 * 1024))) new_size = raw_input("Enter the new capacity in GB: ") while not new_size: new_size = raw_input("Enter the new capacity in GB: ") try: new_size = int(new_size) new_size = new_size * (1024 * 1024) datacenter_name = "Nexiilabs" increase_disk(si, vm, obj, new_size, diskspace_initial, datacenter_name) # Disconnecting to Vcenter except ValueError: print "Please Enter Number only" except Exception as err: print err else: raise VmNotFoundException("Vm Not Found Error") obj.disconnect(si) logging.info("Program Ended")
def main(): # Creating Object for VMwareLib Class logging.info("Program Started") obj = VmwareLib() vcenter_ip = "183.82.41.58" username = "******" password = "******" # Connecting to Vcenter si = obj.connect(vcenter_ip, username, password) if si: logging.info("Object created for VmwareLib") logging.debug(obj) #Vmotion operation vm_name = "fancy" host_name = "192.168.50.14" vmotion(vm_name, host_name, obj, si) # Disconnecting to Vcenter obj.disconnect(si) logging.info("Program Ended")
def main(): # Creating Object for VMwareLib Class obj = VmwareLib() vcenter_ip = "183.82.41.58" username = "******" password = "******" # Connecting to Vcenter si = obj.connect(vcenter_ip, username, password) #Getting Vm if si: vm_name = raw_input("Enter VM name: ") vm = get_vm(si, vm_name, obj) if vm: print "plese select any one of the follwing options" n = input( "1.Power ON VM 2.Power OFF VM 3.Power state of VM: ") if n == 1: obj.power_on_vm(vm) elif n == 2: obj.power_off_vm(vm) elif n == 3: obj.power_state_vm(vm) else: print "please select valid option" obj.disconnect(si)
''' from vmware import VmwareLib def maintanencemode(si, host_name, obj): host = obj.get_host_by_name(si, host_name) timeout = 3000 # 3000 secends # This will put the given Esxi host in maintanence mode if host: obj.exit_maintanence_mode(host, timeout) if __name__ == "__main__": # Creating Object for VMwareLib Class obj = VmwareLib() vcenter_ip = "183.82.41.58" username = "******" password = "******" # Connecting to Vcenter si = obj.connect(vcenter_ip, username, password) #Reboot operation host_name = "192.168.50.16" maintanencemode(si, host_name, obj) # Disconnecting to Vcenter obj.disconnect(si)