You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by gi...@apache.org on 2014/02/26 12:33:37 UTC
git commit: updated refs/heads/marvin to 4a0e95c
Repository: cloudstack
Updated Branches:
refs/heads/marvin 23e059b1b -> 4a0e95cf5
CLOUDSTACK-6164: Added few changes for CLOUDSTACK-6164
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/4a0e95cf
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/4a0e95cf
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/4a0e95cf
Branch: refs/heads/marvin
Commit: 4a0e95cf5b72456a9e67cc58d89717d8ec4f1ded
Parents: 23e059b
Author: Santhosh Edukulla <Sa...@citrix.com>
Authored: Wed Feb 26 17:03:22 2014 +0530
Committer: Girish Shilamkar <gi...@clogeny.com>
Committed: Wed Feb 26 17:03:22 2014 +0530
----------------------------------------------------------------------
test/integration/smoke/test_hosts.py | 2 +
tools/marvin/marvin/lib/base.py | 80 ++++++++++++++++++++-----------
2 files changed, 55 insertions(+), 27 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4a0e95cf/test/integration/smoke/test_hosts.py
----------------------------------------------------------------------
diff --git a/test/integration/smoke/test_hosts.py b/test/integration/smoke/test_hosts.py
index 65e6d45..1b39b07 100644
--- a/test/integration/smoke/test_hosts.py
+++ b/test/integration/smoke/test_hosts.py
@@ -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,
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4a0e95cf/tools/marvin/marvin/lib/base.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/lib/base.py b/tools/marvin/marvin/lib/base.py
index c0c6f13..a2f9a8b 100755
--- a/tools/marvin/marvin/lib/base.py
+++ b/tools/marvin/marvin/lib/base.py
@@ -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,35 +1785,58 @@ class Host:
@classmethod
def create(cls, apiclient, cluster, services, zoneid=None, podid=None, hypervisor=None):
- """Create Host in cluster"""
-
- cmd = addHost.addHostCmd()
- cmd.hypervisor = hypervisor
- cmd.url = services["url"]
- cmd.clusterid = cluster.id
-
- if zoneid:
- cmd.zoneid = zoneid
- else:
- cmd.zoneid = services["zoneid"]
-
- if podid:
- cmd.podid = podid
- else:
- cmd.podid = services["podid"]
-
- if "clustertype" in services:
- cmd.clustertype = services["clustertype"]
- if "username" in services:
- cmd.username = services["username"]
- if "password" in services:
- cmd.password = services["password"]
+ """
+ 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"]
+ cmd.clusterid = cluster.id
- # Add host
- host = apiclient.addHost(cmd)
+ if zoneid:
+ cmd.zoneid = zoneid
+ else:
+ cmd.zoneid = services["zoneid"]
- if isinstance(host, list):
- return Host(host[0].__dict__)
+ if podid:
+ cmd.podid = podid
+ else:
+ cmd.podid = services["podid"]
+
+ if "clustertype" in services:
+ cmd.clustertype = services["clustertype"]
+ if "username" in services:
+ cmd.username = services["username"]
+ if "password" in services:
+ cmd.password = services["password"]
+
+ '''
+ 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)
+ 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"""