def api_vm_change_description(HOST, USER, PASSW, VM, DESCRIPTION): prlsdkapi.init_server_sdk() server = prlsdkapi.Server() server.login(HOST, USER, PASSW, '', 0, 0, consts.PSL_NORMAL_SECURITY).wait() vm = api_get_vm(server, VM) vm.begin_edit().wait() vm.set_description(DESCRIPTION.encode("utf_8")) vm.commit().wait() server.logoff() prlsdkapi.deinit_sdk()
def api_get_vm_desc(HOST, USER, PASSW, VM): prlsdkapi.init_server_sdk() server = prlsdkapi.Server() server.login(HOST, USER, PASSW, '', 0, 0, consts.PSL_NORMAL_SECURITY).wait() vm = api_get_vm(server, VM) vm_config = vm.get_config() st = str(vm_config.get_description()) server.logoff() prlsdkapi.deinit_sdk() return st
def main(vmname, username, password): debug("Synchronizing host entries for {0} as {1}:{2}".format(vmname, username, password)) # Init Parallels SDK lib prlsdkapi.init_desktop_sdk() # For Win/Linux, this script will take a little tweaking # but to start with, you'll need to uncomment the following # prlsdkapi.init_desktop_wl_sdk() # Create server object and login server = prlsdkapi.Server() login(server) debug("Logged in to Parallels.") # Find vm vm = get_vm(server, vmname) if vm: debug("Successfully fetched VM with name %s" % vmname) # Get guest object guest = get_guest(vm, username, password) # Get guest network info network_info = get_guest_netinfo(guest) debug("Acquired the following network information:", network_info) # Extract the guest IP address m = re.search("^([\d]{1,3}\.[\d]{1,3}\.[\d]{1,3}\.[\d]{1,3})", network_info[0]["ip"]) ip = m.group(0) debug("Selected %s as the new host IP address." % ip) # Update hosts file update_hosts(ip) # If flag is set, update dnsmasq.conf if UPDATE_DNSMASQ_ENTRIES: dnsmasq_found = False debug("Searching for dnsmasq.conf...") if path_exists("/etc/dnsmasq.conf"): debug("Found dnsmasq.conf in /etc") dnsmasq_found = True update_dnsmasq_conf("/etc/dnsmasq.conf", ip) if path_exists("/usr/local/etc/dnsmasq.conf"): debug("Found dnsmasq.conf in /usr/local/etc/dnsmasq.conf") dnsmasq_found = True update_dnsmasq_conf("/usr/local/etc/dnsmasq.conf", ip) if dnsmasq_found is False: debug("No dnsmasq.conf file found.") # Logoff of guest guest.logout() debug("Logged off of VM guest") print "Host file entries for *.local and local.* have been updated!" print "New address is: " + ip else: print "Could not find a VM by the name '%s'" % vmname server.logoff() prlsdkapi.deinit_sdk() debug("Successfully logged out of Parallels and unloaded SDK.")
def main(): logging.basicConfig(format='%(asctime)s %(levelname)s: %(message)s', filename="checklist.log",filemode='w', level=logging.DEBUG) prlsdkapi.init_server_sdk() # Initialize the library. server = prlsdkapi.Server() # Create a Server object login_server(server, host_slicer(source_node)[2], host_slicer(source_node)[0], host_slicer(source_node)[1], consts.PSL_NORMAL_SECURITY); # get_vm_list(server) print bcolors.HEADER + '\nCreating containers...' + bcolors.ENDC for r in xrange(1,5): create_ct(server) logging.debug(CT) print bcolors.HEADER + '\nCreating content...' + bcolors.ENDC create_bigfile() print bcolors.OKGREEN + 'Done.' + bcolors.ENDC logging.debug('[VE] %s' %CT_MD5_list.items()) #create snapshot CT#2 # print bcolors.HEADER + '\nTaking snapshot' + bcolors.ENDC # try: # CT[CT.keys()[1]].create_snapshot('testfile') # print bcolors.OKGREEN + "Snapshot created" + bcolors.ENDC # logging.info('Snapshot for CT %s created' %CT.keys()[1]) # except: # print bcolors.FAIL + "Snapshot creation failure" + bcolors.ENDC # logging.error('Snapshot creation for CT %s FAILED' %CT.keys()[1]) print '\nBase checks:' scope1(CT[CT.keys()[0]]) print '' print bcolors.HEADER + '\nCreate CLONE and check MD5 for test content...' + bcolors.ENDC clone(CT[CT.keys()[2]]) if dest_node!="": print bcolors.HEADER + "\nMigrating..." + bcolors.ENDC try: migrate(CT[CT.keys()[3]]) print bcolors.OKGREEN + 'Migrated, let\'s check MD5 inside..' + bcolors.ENDC logging.info('CT %s migrated' %CT.keys()[3]) #raw_input() mig_md5_check(CT.keys()[3]) except: print bcolors.FAIL + "Migration FAILED" + bcolors.ENDC else: print bcolors.BOLD + '\nNo slave node provided, migration test skiped' + bcolors.ENDC # print CT[CT.keys()[1]].get_uuid() # job=CT[CT.keys()[1]].get_snapshots_tree() # job.wait() # result=job.get_result() # print CT.keys()[1] # print result.get_param_as_string() cleanup() server.logoff() #log off prlsdkapi.deinit_sdk() # deinitialize the library.
def main(): logging.basicConfig(format='%(asctime)s %(levelname)s: %(message)s', filename="checklist.log", filemode='w', level=logging.DEBUG) prlsdkapi.init_server_sdk() # Initialize the library. server = prlsdkapi.Server() # Create a Server object login_server(server, host_slicer(source_node)[2], host_slicer(source_node)[0], host_slicer(source_node)[1], consts.PSL_NORMAL_SECURITY) # get_vm_list(server) print bcolors.HEADER + '\nCreating containers...' + bcolors.ENDC for r in xrange(1, 5): create_ct(server) logging.debug(CT) print bcolors.HEADER + '\nCreating content...' + bcolors.ENDC create_bigfile() print bcolors.OKGREEN + 'Done.' + bcolors.ENDC logging.debug('[VE] %s' % CT_MD5_list.items()) #create snapshot CT#2 # print bcolors.HEADER + '\nTaking snapshot' + bcolors.ENDC # try: # CT[CT.keys()[1]].create_snapshot('testfile') # print bcolors.OKGREEN + "Snapshot created" + bcolors.ENDC # logging.info('Snapshot for CT %s created' %CT.keys()[1]) # except: # print bcolors.FAIL + "Snapshot creation failure" + bcolors.ENDC # logging.error('Snapshot creation for CT %s FAILED' %CT.keys()[1]) print '\nBase checks:' scope1(CT[CT.keys()[0]]) print '' print bcolors.HEADER + '\nCreate CLONE and check MD5 for test content...' + bcolors.ENDC clone(CT[CT.keys()[2]]) if dest_node != "": print bcolors.HEADER + "\nMigrating..." + bcolors.ENDC try: migrate(CT[CT.keys()[3]]) print bcolors.OKGREEN + 'Migrated, let\'s check MD5 inside..' + bcolors.ENDC logging.info('CT %s migrated' % CT.keys()[3]) #raw_input() mig_md5_check(CT.keys()[3]) except: print bcolors.FAIL + "Migration FAILED" + bcolors.ENDC else: print bcolors.BOLD + '\nNo slave node provided, migration test skiped' + bcolors.ENDC # print CT[CT.keys()[1]].get_uuid() # job=CT[CT.keys()[1]].get_snapshots_tree() # job.wait() # result=job.get_result() # print CT.keys()[1] # print result.get_param_as_string() cleanup() server.logoff() #log off prlsdkapi.deinit_sdk() # deinitialize the library.
def __del__(self): # Log off and deinitialize the prlsdkapi library. self.server.logoff() prlsdkapi.deinit_sdk()
def __exit__(self, exception_type, exception_value, traceback): prlsdkapi.deinit_sdk()