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

Method create

tools/marvin/marvin/lib/base.py:3309–3363  ·  view source on GitHub ↗

1. Creates the host based upon the information provided. 2. Verifies the output of the adding host and its state post addition Returns FAILED in case of an issue, else an instance of Host

(cls, apiclient, cluster, services, zoneid=None, podid=None, hypervisor=None)

Source from the content-addressed store, hash-verified

3307
3308 @classmethod
3309 def create(cls, apiclient, cluster, services, zoneid=None, podid=None, hypervisor=None):
3310 """
3311 1. Creates the host based upon the information provided.
3312 2. Verifies the output of the adding host and its state post addition
3313 Returns FAILED in case of an issue, else an instance of Host
3314 """
3315 try:
3316 cmd = addHost.addHostCmd()
3317 cmd.hypervisor = hypervisor
3318 cmd.url = services["url"]
3319 cmd.clusterid = cluster.id
3320
3321 if zoneid:
3322 cmd.zoneid = zoneid
3323 else:
3324 cmd.zoneid = services["zoneid"]
3325
3326 if podid:
3327 cmd.podid = podid
3328 else:
3329 cmd.podid = services["podid"]
3330
3331 if "clustertype" in services:
3332 cmd.clustertype = services["clustertype"]
3333 if "username" in services:
3334 cmd.username = services["username"]
3335 if "password" in services:
3336 cmd.password = services["password"]
3337
3338 '''
3339 Adds a Host,
3340 If response is valid and host is up return
3341 an instance of Host.
3342 If response is invalid, returns FAILED.
3343 If host state is not up, verify through listHosts call
3344 till host status is up and return accordingly. Max 3 retries
3345 '''
3346 host = apiclient.addHost(cmd)
3347 ret = validateList(host)
3348 if ret[0] == PASS:
3349 if str(host[0].state).lower() == 'up':
3350 return Host(host[0].__dict__)
3351 retries = 3
3352 while retries:
3353 lh_resp = apiclient.listHosts(host[0].id)
3354 ret = validateList(lh_resp)
3355 if (ret[0] == PASS) and \
3356 (str(ret[1].state).lower() == 'up'):
3357 return Host(host[0].__dict__)
3358 retries += -1
3359 return FAILED
3360 except Exception as e:
3361 print("Exception Occurred Under Host.create : %s" % \
3362 GetDetailExceptionInfo(e))
3363 return FAILED
3364
3365 @staticmethod
3366 def _check_resource_state(apiclient, hostid, resourcestate):

Callers

nothing calls this directly

Implementers 1

HostVOengine/schema/src/main/java/com/cloud/

Calls 5

validateListFunction · 0.90
GetDetailExceptionInfoFunction · 0.90
HostClass · 0.70
addHostMethod · 0.65
listHostsMethod · 0.65

Tested by

no test coverage detected