def run(Server, Port, Provider, ProviderServer, ProviderUser, ProviderPassword, ProviderTenant, VirtualMachineId, BootTimeoutSeconds, BootCheckSeconds): """command run method returns True/False""" logger = PLLogger.GetLogger('spirent.vds') credentials = make_credentials(Provider, ProviderServer, ProviderUser, ProviderPassword, ProviderTenant) try: vm_info = vcmlib.virtualmachinereboot(Server, Port, credentials, VirtualMachineId, BootTimeoutSeconds, BootCheckSeconds) logger.LogInfo('virtualMachineRunning ' + str(vm_info['virtualmachine_running'])) cmd = get_this_cmd() cmd.Set('VirtualMachineRunning', str(vm_info['virtualmachine_running'])) except Exception as ex: if len(ex.message): msg = str(ex.message) else: msg = str(ex) stack_trace = traceback.format_exc() logger.LogError('Reboot Exception Caught: ' + msg + ' ' + stack_trace) return False return True
def run(Server, Port, Provider, ProviderServer, ProviderUser, ProviderPassword, ProviderTenant, VirtualMachineId): """command run method returns True/False""" logger = PLLogger.GetLogger('spirent.vds') credentials = make_credentials(Provider, ProviderServer, ProviderUser, ProviderPassword, ProviderTenant) try: vm_info = vcmlib.virtualmachineinfo(Server, Port, credentials, VirtualMachineId) ip_list = [] net_list = [] network_list = vm_info['virtualmachine_ips'] for net_dict in network_list: ip_list.append(str(net_dict['ip_address'])) net_list.append(str(net_dict['network_name'])) logger.LogInfo('virtualMachineFound ' + str(vm_info['virtualmachine_found'])) logger.LogInfo(str(ip_list)) logger.LogInfo(str(net_list)) cmd = get_this_cmd() cmd.Set('VirtualMachineFound', str(vm_info['virtualmachine_found'])) cmd.SetCollection('AddrList', ip_list) cmd.SetCollection('NetworkList', net_list) except Exception as ex: if len(ex.message): msg = str(ex.message) else: msg = str(ex) stack_trace = traceback.format_exc() logger.LogError('VM Info Exception Caught: ' + msg + ' ' + stack_trace) return False return True
def run(Server, Port, Provider, ProviderServer, ProviderUser, ProviderPassword, ProviderTenant): """command run method returns True/False""" logger = PLLogger.GetLogger('spirent.vds') credentials = make_credentials(Provider, ProviderServer, ProviderUser, ProviderPassword, ProviderTenant) try: vm_info = vcmlib.listvirtualmachines(Server, Port, credentials) id_list = [] name_list = [] info = vm_info['virtualmachines'] for vm_dict in info: id_list.append(str(vm_dict['id'])) name_list.append(str(vm_dict['name'])) logger.LogInfo(str(id_list)) logger.LogInfo(str(name_list)) cmd = get_this_cmd() cmd.SetCollection('VmIdList', id_list) cmd.SetCollection('VmNameList', name_list) except Exception as ex: if len(ex.message): msg = str(ex.message) else: msg = str(ex) stack_trace = traceback.format_exc() logger.LogError('List VMs Exception Caught: ' + msg + ' ' + stack_trace) return False return True
def run(Server, Port, Provider, ProviderServer, ProviderUser, ProviderPassword, ProviderTenant, VirtualMachineName, SizeName, ImageName, LicenseServer, NtpServer, PortSpeed, Driver, IpAddr, Netmask, Gateway, Telnet, NetworkList, BootTimeoutSeconds, BootCheckSeconds, HostName, DatacenterName, DatastoreName, ResourcePoolName, Count): """command run method returns True/False""" if NetworkList == '': NetworkList = [] logger = PLLogger.GetLogger('spirent.vds') credentials = make_credentials(Provider, ProviderServer, ProviderUser, ProviderPassword, ProviderTenant) try: vm_info = vcmlib.virtualmachinecreate(Server, Port, credentials, VirtualMachineName, SizeName, ImageName, LicenseServer, NtpServer, PortSpeed, Driver, IpAddr, Netmask, Gateway, Telnet, NetworkList, BootTimeoutSeconds, BootCheckSeconds, HostName, DatacenterName, DatastoreName, ResourcePoolName, Count) running_list = vm_info['virtualmachine_running'] running_list = [str(elem) for elem in running_list] id_list = vm_info['id'] id_list = [str(elem) for elem in id_list] url_list = vm_info['url'] url_list = [str(elem) for elem in url_list] logger.LogInfo(str(running_list)) logger.LogInfo(str(id_list)) logger.LogInfo(str(url_list)) cmd = get_this_cmd() cmd.SetCollection('VirtualMachineRunning', running_list) cmd.SetCollection('VirtualMachineId', id_list) cmd.SetCollection('Url', url_list) except Exception as ex: if len(ex.message): msg = str(ex.message) else: msg = str(ex) stack_trace = traceback.format_exc() logger.LogError('Create VM Exception Caught: ' + msg + ' ' + stack_trace) return False return True
def run(Server, Port, Provider, ProviderServer, ProviderUser, ProviderPassword, ProviderTenant, VirtualMachineId): """command run method returns True/False""" logger = PLLogger.GetLogger("spirent.vds") credentials = make_credentials(Provider, ProviderServer, ProviderUser, ProviderPassword, ProviderTenant) try: vm_info = vcmlib.virtualmachinedestroy(Server, Port, credentials, VirtualMachineId) logger.LogInfo("virtualMachinePresent " + str(vm_info["virtualmachine_present"])) cmd = get_this_cmd() cmd.Set("VirtualMachinePresent", str(vm_info["virtualmachine_present"])) except Exception as ex: if len(ex.message): msg = str(ex.message) else: msg = str(ex) stack_trace = traceback.format_exc() logger.LogError("Destroy VM Exception Caught: " + msg + " " + stack_trace) return False return True
def run(Server, Port, Provider, ProviderServer, ProviderUser, ProviderPassword, ProviderTenant): """command run method returns True/False""" logger = PLLogger.GetLogger('spirent.vds') credentials = make_credentials(Provider, ProviderServer, ProviderUser, ProviderPassword, ProviderTenant) try: size_info = vcmlib.listsizes(Server, Port, credentials) id_list = [] name_list = [] ram_list = [] disk_list = [] vcpus_list = [] info = size_info['sizes'] for size_dict in info: id_list.append(str(size_dict['id'])) name_list.append(str(size_dict['name'])) ram_list.append(str(size_dict['ram'])) disk_list.append(str(size_dict['disk'])) vcpus_list.append(str(size_dict['vcpus'])) logger.LogInfo(str(id_list)) logger.LogInfo(str(name_list)) logger.LogInfo(str(ram_list)) logger.LogInfo(str(disk_list)) logger.LogInfo(str(vcpus_list)) cmd = get_this_cmd() cmd.SetCollection('SizeIdList', id_list) cmd.SetCollection('SizeNameList', name_list) cmd.SetCollection('RamList', ram_list) cmd.SetCollection('DiskList', disk_list) cmd.SetCollection('VcpusList', vcpus_list) except Exception as ex: if len(ex.message): msg = str(ex.message) else: msg = str(ex) stack_trace = traceback.format_exc() logger.LogError('List Sizes Exception Caught: ' + msg + ' ' + stack_trace) return False return True