本文整理汇总了Python中pysphere.VIServer.get_clusters方法的典型用法代码示例。如果您正苦于以下问题:Python VIServer.get_clusters方法的具体用法?Python VIServer.get_clusters怎么用?Python VIServer.get_clusters使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pysphere.VIServer
的用法示例。
在下文中一共展示了VIServer.get_clusters方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from pysphere import VIServer [as 别名]
# 或者: from pysphere.VIServer import get_clusters [as 别名]
def main():
"""Sets up the module parameters, validates them and perform the change"""
module = AnsibleModule(
argument_spec=dict(
vcenter_hostname=dict(required=True),
username=dict(required=True),
password=dict(required=True),
guest=dict(required=True),
resource_pool=dict(required=True),
cluster=dict(required=True),
sync=dict(required=False, type='bool', default=True)
),
supports_check_mode=True
)
server = VIServer()
server.connect(
module.params['vcenter_hostname'],
module.params['username'],
module.params['password'])
virtualmachine = server.get_vm_by_name(module.params['guest'])
old_name = virtualmachine.get_resource_pool_name()
new_name = module.params['resource_pool']
# find the clusters ManagedObjectReference
cluster = None
clusters = server.get_clusters()
for mor, name in clusters.iteritems():
if name == module.params['cluster']:
cluster = mor
break
if cluster is None:
module.fail_json(msg='Cluster %s not found on server %s' %
(module.params['cluster'], module.params['vcenter_hostname']))
# find the new resource pools Managed Object Reference and migrate the VM
rps = server.get_resource_pools(from_mor=cluster)
for mor, path in rps.iteritems():
if re.match('.*%s$' % new_name, path):
if not re.match('.*%s$' % old_name, path):
if not module.check_mode:
virtualmachine.migrate(
resource_pool=mor,
host=virtualmachine.get_property('hostname'),
sync_run=module.params['sync'])
module.exit_json(changed=True, changes=module.params)
module.exit_json(changed=False, changes=module.params)
module.fail_json(msg='Resource pool %s not found' %
module.params['resource_pool'])
示例2: VMWareSystem
# 需要导入模块: from pysphere import VIServer [as 别名]
# 或者: from pysphere.VIServer import get_clusters [as 别名]
#.........这里部分代码省略.........
return True
else:
vm.power_off()
ack = vm.get_status()
if ack == 'POWERED OFF':
return True
return False
def delete_vm(self, vm_name):
vm = self._get_vm(vm_name)
if vm.is_powered_on():
self.stop_vm(vm_name)
# When pysphere moves up to 0.1.8, we can just do:
# vm.destroy()
request = VI.Destroy_TaskRequestMsg()
_this = request.new__this(vm._mor)
_this.set_attribute_type(vm._mor.get_attribute_type())
request.set_element__this(_this)
rtn = self.api._proxy.Destroy_Task(request)._returnval
task = VITask(rtn, self.api)
status = task.wait_for_state([task.STATE_SUCCESS, task.STATE_ERROR])
if status == task.STATE_SUCCESS:
return True
else:
return False
def create_vm(self, vm_name):
raise NotImplementedError('This function has not yet been implemented.')
def restart_vm(self, vm_name):
if not self.stop_vm(vm_name):
return False
else:
return self.start_vm(vm_name)
def list_vm(self):
return self._get_list_vms()
def list_template(self):
return self._get_list_vms(get_template=True)
def list_flavor(self):
raise NotImplementedError('This function is not supported on this platform.')
def list_host(self):
return self.api.get_hosts()
def list_datastore(self):
return self.api.get_datastores()
def list_cluster(self):
return self.api.get_clusters()
def info(self):
return '%s %s' % (self.api.get_server_type(), self.api.get_api_version())
def disconnect(self):
self.api.disconnect()
def vm_status(self, vm_name):
state = self._get_vm(vm_name).get_status()
print "vm " + vm_name + " status is " + state
return state
def is_vm_running(self, vm_name):
state = self.vm_status(vm_name)
return "POWERED ON" == state
def is_vm_stopped(self, vm_name):
state = self.vm_status(vm_name)
return "POWERED OFF" == state
def is_vm_suspended(self, vm_name):
state = self.vm_status(vm_name)
return "SUSPENDED" == state
def suspend_vm(self, vm_name):
vm = self._get_vm(vm_name)
if vm.is_powered_off():
raise Exception('Could not suspend %s because it\'s not running.' % vm_name)
else:
vm.suspend()
return self.is_vm_suspended(vm_name)
def clone_vm(self):
raise NotImplementedError('clone_vm not implemented.')
def deploy_template(self, template, *args, **kwargs):
if 'resourcepool' not in kwargs:
kwargs['resourcepool'] = None
vm = self._get_vm(template)
if vm:
vm.clone(kwargs['vm_name'], sync_run=True,
resourcepool=self._get_resource_pool(kwargs['resourcepool']))
return kwargs['vm_name']
else:
raise Exception('Could not clone %s' % template)
示例3: Exception
# 需要导入模块: from pysphere import VIServer [as 别名]
# 或者: from pysphere.VIServer import get_clusters [as 别名]
if(cur_region != region):
vcip = None
if(region == 'TOKYO'):
vcip = '10.1.1.50'
else:
vcip = '10.1.8.50'
logger.debug("Trying to connect %s" % vcip)
vc.connect(vcip,'sbgcf\\svc_report','VMwar3!!')
cur_region = region
try:
host_d = {}
vm_d = {}
for c_mor, c_name in vc.get_clusters().items():
if(not c_name in clstrname_d): continue
logger.debug("Fetching cluster '%s'",c_name)
for h_mor,h_name in vc.get_hosts(from_mor=c_mor).items():
logger.debug("Fetching host %s",h_name)
host_d[h_name] = c_name
for v_mor, v_name in vc._get_managed_objects(MORTypes.VirtualMachine, from_mor=h_mor).items():
vm_d[v_name] = h_name
except:
raise Exception("Failed to query VM list from vCenter %s" % vcip)
is_replica = re.match('.+REPLICA',appid)
if(not vm in vm_d):
if(is_replica):
ERROR(ErrorCode.E_MISSING_REPLICA,appid," (%s)" % vm)
示例4: get_stats
# 需要导入模块: from pysphere import VIServer [as 别名]
# 或者: from pysphere.VIServer import get_clusters [as 别名]
def get_stats():
stats = dict()
v = VCENTERLIST.split()
for vcenter in v:
logger('verb', "get_stats calls vcenter %s user %s" % (vcenter, USERNAME))
server = VIServer()
try:
server.connect(vcenter, USERNAME, PASSWORD)
except Exception:
logger('warn', "failed to connect to %s" % (vcenter))
continue
# get datastores
for ds, dsname in server.get_datastores().items():
DatastoreCapacity = 0
DatastoreFreespace = 0
DatastoreUsagePercent = 0
try:
logger('verb', "get_stats calls Datastore metrics query on vcenter: %s for datastore: %s" % (vcenter, dsname))
props = server._retrieve_properties_traversal(property_names=['name', 'summary.capacity', 'summary.freeSpace'], from_node=ds, obj_type="Datastore")
for prop_set in props:
# mor = prop_set.Obj #in case you need it
for prop in prop_set.PropSet:
if prop.Name == "summary.capacity":
DatastoreCapacity = (prop.Val / 1048576)
elif prop.Name == "summary.freeSpace":
DatastoreFreespace = (prop.Val / 1048576)
except Exception:
logger('warn', "failed to get Datastore metrics value on vcenter: %s for datastore: %s" % (vcenter, dsname))
DatastoreUsagePercent = (((DatastoreCapacity - DatastoreFreespace) * 100) / DatastoreCapacity)
metricnameZoneDatastoreCapacity = METRIC_DELIM.join([vcenter.lower(), "datastores", dsname.lower(), 'datastorecapacity'])
metricnameZoneDatastoreFreespace = METRIC_DELIM.join([vcenter.lower(), "datastores", dsname.lower(), 'datastorefreespace'])
metricnameZoneDatastoreUsagePercent = METRIC_DELIM.join([vcenter.lower(), "datastores", dsname.lower(), 'datastoreusagepercent'])
try:
stats[metricnameZoneDatastoreCapacity] = DatastoreCapacity
stats[metricnameZoneDatastoreFreespace] = DatastoreFreespace
stats[metricnameZoneDatastoreUsagePercent] = DatastoreUsagePercent
except (TypeError, ValueError):
pass
ZoneDatacentersCount = 0
ZoneClustersCount = 0
ZoneHostsCount = 0
ZoneRunningVMS = 0
ZoneStoppedVMS = 0
ZoneTotalVMS = 0
ZoneMemoryUsage = 0
ZoneCpuUsage = 0
ZoneTotalMemory = 0
ZoneCpuTotal = 0
logger('verb', "get_stats calls get_datacenters query on vcenter: %s" % (vcenter))
datacenters = server.get_datacenters()
logger('verb', "get_stats completed get_datacenters query on vcenter: %s" % (vcenter))
ZoneDatacentersCount = len(datacenters)
for d, dname in server.get_datacenters().items():
if "." in dname:
dname = dname.split(".")[0]
DatacenterRunningVMS = 0
DatacenterStoppedVMS = 0
DatacenterTotalVMS = 0
DatacenterClustersCount = 0
DatacenterHostsCount = 0
DatacenterMemoryUsage = 0
DatacenterCpuUsage = 0
DatacenterTotalMemory = 0
DatacenterCpuTotal = 0
logger('verb', "get_stats calls get_clusters query on vcenter: %s for datacenter: %s" % (vcenter, dname))
clusters = server.get_clusters(d)
logger('verb', "get_stats completed get_clusters query on vcenter: %s for datacenter: %s" % (vcenter, dname))
DatacenterClustersCount = len(clusters)
ZoneClustersCount = ZoneClustersCount + DatacenterClustersCount
for c, cname in server.get_clusters(d).items():
if "." in cname:
cname = cname.split(".")[0]
ClusterMemoryUsage = 0
ClusterCpuUsage = 0
ClusterTotalMemory = 0
ClusterCpuTotal = 0
ClusterRunningVMS = 0
ClusterStoppedVMS = 0
ClusterTotalVMS = 0
#.........这里部分代码省略.........
示例5: VIServer
# 需要导入模块: from pysphere import VIServer [as 别名]
# 或者: from pysphere.VIServer import get_clusters [as 别名]
pip install pysphere
"""
from pysphere import VIServer
server = VIServer()
server.connect("serverip","adminuser","pass")
#Get server characteristics
print server.get_server_type()
print server.get_api_version()
print server.get_clusters()
print server._get_resource_pools
#Get all the hosts
print server.get_hosts()
#Get VM`s in Prod resource pool which are in poweredon state
vmachines = server.get_registered_vms()
vmachines = server.get_registered_vms(resource_pool='Prod', status='poweredOn')
#Get virtual machine status
vm1 = server.get_vm_by_name('rhel5.3_prod')
print vm1.get_status()
示例6: VIServer
# 需要导入模块: from pysphere import VIServer [as 别名]
# 或者: from pysphere.VIServer import get_clusters [as 别名]
print "Invalid username or password"
sys.exit(1)
##if:Do we have a host?
if sThisCluster != "":
##stmt:Yes, connect to vCenter
server = VIServer()
server.connect(sThisEsxiHost, sThisUser, sThisPasswd)
##stmt:Get datacenter object
oDataCenter = server.get_datacenters()
##loop:Get each datacenter
for dc_mor, dc_name in oDataCenter.items():
##stmt:Get clusters in the datacenter
oClusters = server.get_clusters(from_mor=dc_mor)
##loop:Get each cluster
for c_mor, c_name in oClusters.items():
##stmt:Get next cluster
##if:Is this the cluster we are looking for?
if sThisCluster == c_name:
##stmt:Yes, get hosts
oHosts = server.get_hosts(from_mor=c_mor)
##loop:Get each host from cluster
for h_mor, h_name in oHosts.items():
##stmt:Get next host
print h_name
bFound = True
示例7: connect
# 需要导入模块: from pysphere import VIServer [as 别名]
# 或者: from pysphere.VIServer import get_clusters [as 别名]
class basicOps:
server=None
def connect(self):
configuration=Config()
server = configuration._config_value("general", "server")
if server is None:
raise ValueError("server must be supplied on command line"+"or in configuration file.")
username = configuration._config_value("general", "username")
if username is None:
raise ValueError("username must be supplied on command line"
" or in configuration file.")
password = configuration._config_value("general", "password")
if password is None:
raise ValueError("password must be supplied on command line"
" or in configuration file.")
self.server=VIServer()
self.server.connect(server,username,password)
def startVm(self,vmname):
vm=self.server.get_vm_by_name(vmname)
status=vm.get_status()
if status=="POWERED OFF":
task=vm.power_on(run_sync=False)
return task
def stopVm(self, vmname):
vm=self.server.get_vm_by_name(vmname)
status=vm.get_status()
if status=="POWERED ON":
task=vm.power_off(run_sync=False)
return task
def stopGuest(self,vmname):
vm=self.server.get_vm_by_name(vmname)
task=vm.shutdown_guest(run_sync=False)
return task
def rebootGuest(self,vmname):
vm=self.server.get_vm_by_name(vmname)
task=vm.reboot_guest(run_sync=False)
return task
def getDataCenters(self):
return self.server.get_datacenters()
def clone(self,templateName,cloneName="Template Clone"):
vm=self.server.get_vm_by_name(templateName)
resourcePool=self.getResourcePool()
print resourcePool
task=vm.clone(cloneName,resourcepool=resourcePool,sync_run=False)
try:
status=task.get_state()
print(status)
print "Creating machine from template:Job Status:" + status
if status!="error":
while (status!="success" or status !="error"):
status=task.get_state()
if status=="success":
break;
print "Creating machine from template: Job Status:" + status
#vm_new=self.server.get_vm_by_name(cloneName)
#return vm_new
except:
print("Error Occured:")
def getResourcePool(self):
configuration=Config()
datacenter = configuration._config_value("vmware", "datacenter")
if datacenter is None:
raise ValueError("server must be supplied"+"in configuration file.")
cluster = configuration._config_value("vmware", "cluster")
if cluster is None:
raise ValueError("cluster name must be supplied in configuration file.")
resourcePool = configuration._config_value("vmware", "resourcePool")
if resourcePool is None:
raise ValueError("Resource Pool name must be supplied in configuration file")
clusters=self.server.get_clusters()
#print clusters
keycluster=self.find_key(clusters,cluster)
# print(keycluster)
resource_pools=self.server.get_resource_pools(keycluster)
# print(resource_pools)
resourcePool=self.find_key(resource_pools,resourcePool,True)
# print (resourcePool)
return resourcePool
# resource_pools=self.server.get_resource_pools()
def find_key(self,dic, val, partial=False):
retval=None
if partial==False:
retval=[k for k, v in dic.iteritems() if v == val][0]
else:
retval =[k for k, v in dic.iteritems() if (v.find(val)>0)][0]
return retval
#.........这里部分代码省略.........
示例8:
# 需要导入模块: from pysphere import VIServer [as 别名]
# 或者: from pysphere.VIServer import get_clusters [as 别名]
# Setting up vars
datacenters = None
clusters = None
hosts = None
datastores = None
vms = None
try:
# Getting datacenters
logger.debug('Getting datastores')
datacenters = con.get_datacenters().values()
# Getting clusters
logger.debug('Getting clusters')
clusters = con.get_clusters().values()
# Getting Hosts
logger.debug('Getting Hosts')
hosts = con.get_hosts().values()
# Getting Datastores
logger.debug('Getting Datastores')
datastores = con.get_datastores().values()
# Getting Registered VMs
logger.debug('Getting VMs')
vms = con.get_registered_vms()
# Disconnecting from server
con.disconnect()
示例9: __init__
# 需要导入模块: from pysphere import VIServer [as 别名]
# 或者: from pysphere.VIServer import get_clusters [as 别名]
class ESXi_Server:
server_ip = ''
user_name = ''
password = ''
connect_flag = False
server = None
#vm_list = []
#def __init__(self):
#Use the given args to connect the esxi server you want
#@ip[string]: ESXi server's IP address
#@name[string]: the username used to login the ESXi server
#@pwd[string]: the password used to login the ESXi server
def connect_server(self, ip, name, pwd):
self.server_ip = ip
self.user_name = name
self.password = pwd
self.server = VIServer()
self.server.connect(self.server_ip, self.user_name, self.password)
self.connect_flag = self.server.is_connected()
if self.connect_flag:
return True
return False
#To get all the definition registered vms from the connected server
#@param[string]: can be set as ALL, POWER_ON, POWER_OFF, SUSPENDED
#According to the param, returns a list of VM Paths. You might also filter by datacenter,
#cluster, or resource pool by providing their name or MORs.
#if cluster is set, datacenter is ignored, and if resource pool is set
#both, datacenter and cluster are ignored.
def get_registered_vms(self, param, status=None, datacenter=None, cluster=None,
resource_pool=None):
if param not in ['ALL', 'POWER_ON', 'POWER_OFF', 'SUSPENDED']:
print "Get VMs error: param can only be set as ALL, POWER_ON, POWER_OFF, or SUSPENDED."
return None
if self.connect_flag == False:
print "Get VMs error: Server not connected."
return None
if param == 'ALL':
return self.server.get_registered_vms(datacenter, cluster, resource_pool)
elif param == 'POWER_ON':
return self.server.get_registered_vms(datacenter, cluster, resource_pool, status='poweredOn')
elif param == 'POWER_OFF':
return self.server.get_registered_vms(datacenter, cluster, resource_pool, status='poweredOff')
elif param == 'SUSPENDED':
return self.server.get_registered_vms(datacenter, cluster, resource_pool, status='suspended')
else:
return None
#Disconnect to the Server
def disconnect(self):
if self.connect_flag == True:
self.server = self.server.disconnect()
self.connect_flag == False
#To keep session alive
def keep_session_alive(self):
assert self.server.keep_session_alive()
#To get the server type
def get_server_type(self):
return self.server.get_server_type()
#To get performance manager
def get_performance_manager(self):
return self.server.get_performance_manager()
#To get the all the server's hosts
def get_all_hosts(self):
"""
Returns a dictionary of the existing hosts keys are their names
and values their ManagedObjectReference object.
"""
return self.server.get_hosts()
#To get all datastores
def get_all_datastores(self):
"""
Returns a dictionary of the existing datastores. Keys are
ManagedObjectReference and values datastore names.
"""
return self.server.get_datastores()
#To get all clusters
def get_all_clusters(self):
"""
Returns a dictionary of the existing clusters. Keys are their
ManagedObjectReference objects and values their names.
"""
return self.server.get_clusters()
#To get all datacenters
def get_all_datacenters(self):
"""
Returns a dictionary of the existing datacenters. keys are their
ManagedObjectReference objects and values their names.
"""
return self.server.get_datacenters()
#.........这里部分代码省略.........
示例10: main
# 需要导入模块: from pysphere import VIServer [as 别名]
# 或者: from pysphere.VIServer import get_clusters [as 别名]
def main(options):
global host_vms
LOGGER.debug("Options: {0}".format(options))
LOGGER.debug("Args: {0}".format(args))
#check for senseful inputs
if not options.vcServer or not options.satServer:
LOGGER.error("You need to specify at least Satellite and vCenter hostnames!")
exit(1)
#get Satellite and vCenter credentials
if options.dryrun: LOGGER.info("I'm only doing a simulation, I promise!")
(satUsername, satPassword) = get_credentials("Satellite", options.satAuthfile)
(vcUsername, vcPassword) = get_credentials("Virtualization", options.vcAuthfile)
#connect to vCenter
myVC = VIServer()
myVC.connect(options.vcServer, vcUsername, vcPassword)
#connect to Satellite
satellite_url = "http://{0}/rpc/api".format(options.satServer)
mySat = xmlrpclib.Server(satellite_url, verbose=options.debug)
key = mySat.auth.login(satUsername, satPassword)
check_if_api_is_supported(mySat)
#print information about host
LOGGER.info("Connected to " + options.vcServer + " (" + myVC.get_server_type() + "), version " + myVC.get_api_version() + ".")
#get list of all ESXi hosts by datacenter
LOGGER.info("Searching for ESXi hosts by datacenter...")
esxiHosts = myVC.get_hosts()
datacenters = myVC.get_datacenters()
for dc in datacenters:
tempHosts = myVC.get_hosts(from_mor=dc).values()
hosts_by_dc[datacenters.get(dc)] = (tempHosts)
LOGGER.debug("Hosts by DC: " + str(hosts_by_dc))
#get list of all ESXi hosts by cluster
LOGGER.info("Searching for ESXi hosts by cluster...")
clusters = myVC.get_clusters()
for cluster in clusters:
tempHosts = myVC.get_hosts(from_mor=cluster).values()
hosts_by_cluster[clusters.get(cluster)] = (tempHosts)
LOGGER.debug("Hosts by cluster: " + str(hosts_by_cluster))
#get list of all VMs by ESXi host
for dc in datacenters:
for host in hosts_by_dc[datacenters.get(dc)]:
LOGGER.debug("Found ESXi host '" + host + "'")
host_vms[host]=[]
LOGGER.debug("Added hosts to dict: " + str(host_vms))
#get list of all Linux VMs managed by Satellite
satlist = mySat.system.listSystems(key)
target_vms=[]
LOGGER.info("Digging through list of systems managed by Satellite...")
for system in satlist:
LOGGER.debug("Found system '" + system["name"] + "'")
#get custom keys
thisKeys = mySat.system.getCustomValues(key, system["id"])
#add virt_vmname if given
if "SYSTEM_VIRT_VMNAME" in thisKeys and thisKeys["SYSTEM_VIRT_VMNAME"] != "":
target_vms.append(thisKeys["SYSTEM_VIRT_VMNAME"])
else: target_vms.append(system)
LOGGER.debug("VM names: " + str(target_vms))
#get list of all VMs and assign to host dicts
LOGGER.info("Getting list of all VMs and assign them to host arrays - grab some coffee.")
vmlist = myVC.get_registered_vms()
counter=0
hit=0
for vm in vmlist:
#get VM and its properties
thisVM = myVC.get_vm_by_path(vm)
#only add if in target_vms
if thisVM.properties.name in target_vms:
LOGGER.debug("Found VM managed by Satellite: '" + thisVM.properties.name + "'")
host_vms[thisVM.properties.runtime.host.name].append(thisVM.properties.name)
else: LOGGER.debug("'" + thisVM.properties.name + "' dropped as it is not managed by Satellite")
LOGGER.debug("Current array for host '" + thisVM.properties.runtime.host.name + "': " + str(host_vms[thisVM.properties.runtime.host.name]))
#show progress
if hit == 9:
LOGGER.info("Checked " + str(counter+1) + " of " + str(len(vmlist)) + " VMs so far...")
hit=0
else: hit=(hit+1)
counter=(counter+1)
LOGGER.debug("Added VMs to host dicts: " + str(host_vms))
#get list of all Linux VMs managed by Satellite
satlist = mySat.system.listSystems(key)
LOGGER.info("Updating relevant system custom info keys...")
for system in satlist:
LOGGER.debug("Found system '" + system["name"] + "'")
#get custom keys
thisKeys = mySat.system.getCustomValues(key, system["id"])
#update key if exists
if "SYSTEM_VIRT_HOST" in thisKeys and thisKeys["SYSTEM_VIRT_HOST"] != "":
#get ESXi host running VM
if "SYSTEM_VIRT_VMNAME" in thisKeys and thisKeys["SYSTEM_VIRT_VMNAME"] != "":
#.........这里部分代码省略.........
示例11: raw_input
# 需要导入模块: from pysphere import VIServer [as 别名]
# 或者: from pysphere.VIServer import get_clusters [as 别名]
try:
options.vm_path
except NameError:
options.vm_path = raw_input("Enter the Template/VM to convert: ")
# Make the vcenter connection
server = VIServer()
server.connect(options.vcenter, options.username, options.password)
# Set the host, cluster and resource pool to "deploy" it into
# We get teh "mor" which is a number to identify with vCenter
hosts = server.get_hosts()
host = [k for k,v in hosts.items() if v=="esxhost.local"][0]
vm = server.get_vm_by_name(options.vm_path)
cluster_name = "DevTest_Cluster"
resource_pool = "/Resources"
cluster = [k for k,v in server.get_clusters().items() if v==cluster_name][0]
rpmor = [k for k,v in server.get_resource_pools(from_mor=cluster).items() if v==resource_pool][0]
# This is the request message we send off to make the change, setting the
# vm, host, and resource pool.
request = VI.MarkAsVirtualMachineRequestMsg()
_this = request.new__this(vm._mor)
_this.set_attribute_type(vm._mor.get_attribute_type())
request.set_element__this(_this)
request.set_element_pool(rpmor)
request.set_element_host(host)
server._proxy.MarkAsVirtualMachine(request)
server.disconnect()