mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
CLOUDSTACK-6164: Added few changes for CLOUDSTACK-6164
This commit is contained in:
parent
23e059b1b9
commit
4a0e95cf5b
@ -104,6 +104,8 @@ class TestHosts(cloudstackTestCase):
|
||||
podid=self.pod.id,
|
||||
hypervisor=self.hypervisor
|
||||
)
|
||||
if host == FAILED:
|
||||
self.fail("Host Creation Failed")
|
||||
self.debug(
|
||||
"Created host (ID: %s) in cluster ID %s" %(
|
||||
host.id,
|
||||
|
||||
@ -22,6 +22,9 @@
|
||||
import marvin
|
||||
from utils import is_server_ssh_ready, random_gen
|
||||
from marvin.cloudstackAPI import *
|
||||
from marvin.codes import FAILED, PASS
|
||||
from marvin.cloudstackException import GetDetailExceptionInfo
|
||||
from marvin.lib.utils import validateList
|
||||
# Import System modules
|
||||
import time
|
||||
import hashlib
|
||||
@ -1782,8 +1785,12 @@ class Host:
|
||||
|
||||
@classmethod
|
||||
def create(cls, apiclient, cluster, services, zoneid=None, podid=None, hypervisor=None):
|
||||
"""Create Host in cluster"""
|
||||
|
||||
"""
|
||||
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
|
||||
"""
|
||||
try:
|
||||
cmd = addHost.addHostCmd()
|
||||
cmd.hypervisor = hypervisor
|
||||
cmd.url = services["url"]
|
||||
@ -1806,11 +1813,30 @@ class Host:
|
||||
if "password" in services:
|
||||
cmd.password = services["password"]
|
||||
|
||||
# Add host
|
||||
'''
|
||||
Adds a Host,
|
||||
If response is valid and host is up return
|
||||
an instance of Host.
|
||||
If response is invalid, returns FAILED.
|
||||
If host state is not up, verify through listHosts call
|
||||
till host status is up and return accordingly. Max 3 retries
|
||||
'''
|
||||
host = apiclient.addHost(cmd)
|
||||
|
||||
if isinstance(host, list):
|
||||
ret = validateList(host)
|
||||
if ret[0] == PASS:
|
||||
if str(host[0].state).lower() == 'up':
|
||||
return Host(host[0].__dict__)
|
||||
retries = 3
|
||||
while retries:
|
||||
lh_resp = apiclient.listHosts(host[0].id)
|
||||
ret = validateList(lh_resp)
|
||||
if (ret[0] == PASS) and (str(ret[1].state).lower() == 'up'):
|
||||
return Host(host[0].__dict__)
|
||||
retries += -1
|
||||
return FAILED
|
||||
except Exception, e:
|
||||
print "Exception Occurred Under Host.create : %s" % GetDetailExceptionInfo(e)
|
||||
return FAILED
|
||||
|
||||
def delete(self, apiclient):
|
||||
"""Delete Host"""
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user