MCPcopy Create free account
hub / github.com/apache/cloudstack / VirtualMachine

Class VirtualMachine

tools/marvin/marvin/lib/base.py:371–1141  ·  view source on GitHub ↗

Manage virtual machine lifecycle

Source from the content-addressed store, hash-verified

369
370
371class VirtualMachine:
372 """Manage virtual machine lifecycle"""
373
374 '''Class level variables'''
375 # Variables denoting VM state - start
376 STOPPED = STOPPED
377 RUNNING = RUNNING
378 DESTROYED = DESTROYED
379 EXPUNGING = EXPUNGING
380 STOPPING = STOPPING
381 STARTING = STARTING
382
383 # Varibles denoting VM state - end
384
385 def __init__(self, items, services):
386 self.__dict__.update(items)
387 if "username" in services:
388 self.username = services["username"]
389 else:
390 self.username = 'root'
391
392 if "password" not in items:
393 if "password" in services:
394 self.password = services["password"]
395 else:
396 self.password = 'password'
397
398 if "ssh_port" in services:
399 self.ssh_port = services["ssh_port"]
400 else:
401 self.ssh_port = 22
402 self.ssh_client = None
403 # extract out the ipaddress
404 if self.nic:
405 self.ipaddress = self.nic[0].ipaddress
406
407 @classmethod
408 def ssh_access_group(cls, apiclient, cmd):
409 """
410 Programs the security group with SSH
411 access before deploying virtualmachine
412 @return:
413 """
414 zone_list = Zone.list(
415 apiclient,
416 id=cmd.zoneid if cmd.zoneid else None,
417 domainid=cmd.domainid if cmd.domainid else None
418 )
419 zone = zone_list[0]
420 # check if security groups settings is enabled for the zone
421 if zone.securitygroupsenabled:
422 list_security_groups = SecurityGroup.list(
423 apiclient,
424 account=cmd.account,
425 domainid=cmd.domainid,
426 listall=True,
427 securitygroupname="basic_sec_grp"
428 )

Callers 4

create_vm_customMethod · 0.90
createMethod · 0.70
createVMFromBackupMethod · 0.70

Implementers 2

VMEntityVOengine/schema/src/main/java/org/apache
VMInstanceVOengine/schema/src/main/java/com/cloud/

Calls

no outgoing calls

Tested by

no test coverage detected