You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by da...@apache.org on 2014/07/28 17:41:18 UTC
[01/18] Marvin + test changes from master Signed-off-by:
SrikanteswaraRao Talluri
Repository: cloudstack
Updated Branches:
refs/heads/4.4 8fb89cdc8 -> 798a6aa2e
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/tools/marvin/marvin/marvinPlugin.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/marvinPlugin.py b/tools/marvin/marvin/marvinPlugin.py
index df7d7a3..4200a65 100644
--- a/tools/marvin/marvin/marvinPlugin.py
+++ b/tools/marvin/marvin/marvinPlugin.py
@@ -14,25 +14,24 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
-
import marvin
-import sys
+from sys import stdout, exit
import logging
+import time
+import os
import nose.core
from marvin.cloudstackTestCase import cloudstackTestCase
from marvin.marvinInit import MarvinInit
from nose.plugins.base import Plugin
from marvin.codes import (SUCCESS,
FAILED,
- EXCEPTION,
- UNKNOWN_ERROR
- )
-import traceback
-import time
-import os
+ EXCEPTION)
+from marvin.lib.utils import random_gen
+from marvin.cloudstackException import GetDetailExceptionInfo
class MarvinPlugin(Plugin):
+
"""
Custom plugin for the cloudstackTestCases to be run using nose
"""
@@ -40,18 +39,35 @@ class MarvinPlugin(Plugin):
name = "marvin"
def __init__(self):
- self.identifier = None
- self.testClient = None
- self.parsedConfig = None
- self.configFile = None
- self.loadFlag = None
+ self.__identifier = None
+ self.__testClient = None
+ self.__logFolderPath = None
+ self.__parsedConfig = None
+ '''
+ Contains Config File
+ '''
+ self.__configFile = None
+ '''
+ Signifies the Zone against which all tests will be Run
+ '''
+ self.__zoneForTests = None
+ '''
+ Signifies the flag whether to deploy the New DC or Not
+ '''
+ self.__deployDcFlag = None
self.conf = None
- self.debugStream = sys.stdout
- self.testRunner = None
- self.testResult = SUCCESS
- self.startTime = None
- self.testName = None
- self.tcRunLogger = None
+ self.__resultStream = stdout
+ self.__testRunner = None
+ self.__testResult = SUCCESS
+ self.__startTime = None
+ self.__testName = None
+ self.__tcRunLogger = None
+ self.__testModName = ''
+ self.__hypervisorType = None
+ '''
+ The Log Path provided by user where all logs are routed to
+ '''
+ self.__userLogPath = None
Plugin.__init__(self)
def configure(self, options, conf):
@@ -60,20 +76,20 @@ class MarvinPlugin(Plugin):
self.enabled (True|False) determines whether marvin's tests will run.
By default non-default plugins like marvin will be disabled
"""
+ self.enabled = True
if hasattr(options, self.enableOpt):
if not getattr(options, self.enableOpt):
self.enabled = False
return
- else:
- self.enabled = True
- self.configFile = options.config_file
- self.loadFlag = options.load
- self.logFolderPath = options.log_folder_path
+ self.__configFile = options.configFile
+ self.__deployDcFlag = options.deployDc
+ self.__zoneForTests = options.zone
+ self.__hypervisorType = options.hypervisor_type
+ self.__userLogPath = options.logFolder
self.conf = conf
- '''
- Initializes the marvin with required settings
- '''
- self.startMarvin()
+ if self.startMarvin() == FAILED:
+ print "\nStarting Marvin Failed, exiting. Please Check"
+ exit(1)
def options(self, parser, env):
"""
@@ -82,20 +98,31 @@ class MarvinPlugin(Plugin):
parser.add_option("--marvin-config", action="store",
default=env.get('MARVIN_CONFIG',
'./datacenter.cfg'),
- dest="config_file",
- help="Marvin's configuration file where the " +
- "datacenter information is specified" +
- " [MARVIN_CONFIG]")
- parser.add_option("--load", action="store_true",
+ dest="configFile",
+ help="Marvin's configuration file is required."
+ "The config file containing the datacenter and "
+ "other management server "
+ "information is specified")
+ parser.add_option("--deploy", action="store_true",
default=False,
- dest="load",
- help="Only load the deployment configuration given")
- parser.add_option("--log-folder-path",
- action="store",
+ dest="deployDc",
+ help="Deploys the DC with Given Configuration."
+ "Requires only when DC needs to be deployed")
+ parser.add_option("--zone", action="store",
+ default=None,
+ dest="zone",
+ help="Runs all tests against this specified zone")
+ parser.add_option("--hypervisor", action="store",
+ default=None,
+ dest="hypervisor_type",
+ help="Runs all tests against the specified "
+ "zone and hypervisor Type")
+ parser.add_option("--log-folder-path", action="store",
default=None,
- dest="log_folder_path",
- help="Path to the folder "
- "where log files will be stored")
+ dest="logFolder",
+ help="Collects all logs under the user specified"
+ "folder"
+ )
Plugin.options(self, parser, env)
def wantClass(self, cls):
@@ -105,93 +132,124 @@ class MarvinPlugin(Plugin):
return True
return None
- def wantFile(self, filename):
+ def __checkImport(self, filename):
'''
- Only python files will be used as test modules
+ @Name : __checkImport
+ @Desc : Verifies to run the available test module for any Import
+ Errors before running and check
+ whether if it is importable.
+ This will check for test modules which has some issues to be
+ getting imported.
+ Returns False or True based upon the result.
'''
- parts = filename.split(os.path.sep)
- base, ext = os.path.splitext(parts[-1])
- if ext == '.py':
- return True
- else:
+ try:
+ if os.path.isfile(filename):
+ ret = os.path.splitext(filename)
+ if ret[1] == ".py":
+ os.system("python " + filename)
+ return True
+ return False
+ except ImportError as e:
+ print "FileName :%s : Error : %s" % \
+ (filename, GetDetailExceptionInfo(e))
return False
+ def wantFile(self, filename):
+ '''
+ @Desc : Only python files will be used as test modules
+ '''
+ return self.__checkImport(filename)
+
def loadTestsFromTestCase(self, cls):
if cls.__name__ != 'cloudstackTestCase':
- self.identifier = cls.__name__
+ self.__identifier = cls.__name__
self._injectClients(cls)
def beforeTest(self, test):
- self.testName = test.__str__().split()[0]
- self.testClient.identifier = '-'.join([self.identifier, self.testName])
- self.tcRunLogger.name = test.__str__()
-
- def prepareTestRunner(self, runner):
- return self.testRunner
+ self.__testModName = test.__str__()
+ self.__testName = test.__str__().split()[0]
+ self.__testClient.identifier = '-'.\
+ join([self.__identifier, self.__testName])
+ if self.__tcRunLogger:
+ self.__tcRunLogger.name = test.__str__()
def startTest(self, test):
"""
Currently used to record start time for tests
Dump Start Msg of TestCase to Log
"""
- self.tcRunLogger.debug("::::::::::::STARTED : TC: " +
- str(self.testName) + " :::::::::::")
- self.startTime = time.time()
+ if self.__tcRunLogger:
+ self.__tcRunLogger.debug("\n\n::::::::::::STARTED : TC: " +
+ str(self.__testName) + " :::::::::::")
+ self.__startTime = time.time()
+
+ def printMsg(self, status, tname, err):
+ if status in [FAILED, EXCEPTION] and self.__tcRunLogger:
+ self.__tcRunLogger.\
+ fatal("%s: %s: %s" % (status,
+ tname,
+ GetDetailExceptionInfo(err)))
+ write_str = "=== TestName: %s | Status : %s ===\n" % (tname, status)
+ self.__resultStream.write(write_str)
+ print write_str
- def getErrorInfo(self, err):
+ def addSuccess(self, test, capt):
'''
- Extracts and returns the sanitized error message
+ Adds the Success Messages to logs
'''
- if err is not None:
- return str(traceback.format_exc())
- else:
- return UNKNOWN_ERROR
+ self.printMsg(SUCCESS, self.__testName, "Test Case Passed")
+ self.__testresult = SUCCESS
def handleError(self, test, err):
'''
Adds Exception throwing test cases and information to log.
'''
- err_msg = self.getErrorInfo(err)
- self.tcRunLogger.fatal("%s: %s: %s" %
- (EXCEPTION, self.testName, err_msg))
- self.testResult = EXCEPTION
+ self.printMsg(EXCEPTION, self.__testName, GetDetailExceptionInfo(err))
+ self.__testResult = EXCEPTION
+
+ def prepareTestRunner(self, runner):
+ if self.__testRunner:
+ return self.__testRunner
def handleFailure(self, test, err):
'''
Adds Failing test cases and information to log.
'''
- err_msg = self.getErrorInfo(err)
- self.tcRunLogger.fatal("%s: %s: %s" %
- (FAILED, self.testName, err_msg))
- self.testResult = FAILED
+ self.printMsg(FAILED, self.__testName, GetDetailExceptionInfo(err))
+ self.__testResult = FAILED
def startMarvin(self):
'''
- Initializes the Marvin
- creates the test Client
- creates the runlogger for logging
- Parses the config and creates a parsedconfig
- Creates a debugstream for tc debug log
+ @Name : startMarvin
+ @Desc : Initializes the Marvin
+ creates the test Client
+ creates the runlogger for logging
+ Parses the config and creates a parsedconfig
+ Creates a debugstream for tc debug log
'''
try:
- obj_marvininit = MarvinInit(self.configFile,
- self.loadFlag,
- self.logFolderPath)
- if obj_marvininit.init() == SUCCESS:
- self.testClient = obj_marvininit.getTestClient()
- self.tcRunLogger = obj_marvininit.getLogger()
- self.parsedConfig = obj_marvininit.getParsedConfig()
- self.debugStream = obj_marvininit.getDebugFile()
- self.testRunner = nose.core.TextTestRunner(stream=
- self.debugStream,
- descriptions=True,
- verbosity=2,
- config=self.conf)
+ obj_marvininit = MarvinInit(self.__configFile,
+ self.__deployDcFlag,
+ None,
+ self.__zoneForTests,
+ self.__hypervisorType,
+ self.__userLogPath)
+ if obj_marvininit and obj_marvininit.init() == SUCCESS:
+ self.__testClient = obj_marvininit.getTestClient()
+ self.__tcRunLogger = obj_marvininit.getLogger()
+ self.__parsedConfig = obj_marvininit.getParsedConfig()
+ self.__resultStream = obj_marvininit.getResultFile()
+ self.__logFolderPath = obj_marvininit.getLogFolderPath()
+ self.__testRunner = nose.core.\
+ TextTestRunner(stream=self.__resultStream,
+ descriptions=True,
+ verbosity=2,
+ config=self.conf)
return SUCCESS
- else:
- return FAILED
- except Exception, e:
- print "Exception Occurred under startMarvin: %s" % str(e)
+ return FAILED
+ except Exception as e:
+ print "Exception Occurred under startMarvin: %s" % \
+ GetDetailExceptionInfo(e)
return FAILED
def stopTest(self, test):
@@ -199,27 +257,51 @@ class MarvinPlugin(Plugin):
Currently used to record end time for tests
"""
endTime = time.time()
- if self.startTime is not None:
- totTime = int(endTime - self.startTime)
- self.tcRunLogger.debug("TestCaseName: %s; Time Taken: "
- "%s Seconds; "
- "StartTime: %s; EndTime: %s; Result: %s"
- % (self.testName, str(totTime),
- str(time.ctime(self.startTime)),
- str(time.ctime(endTime)),
- self.testResult))
+ if self.__startTime:
+ totTime = int(endTime - self.__startTime)
+ if self.__tcRunLogger:
+ self.__tcRunLogger.\
+ debug("TestCaseName: %s; "
+ "Time Taken: %s Seconds; StartTime: %s; "
+ "EndTime: %s; Result: %s" %
+ (self.__testName, str(totTime),
+ str(time.ctime(self.__startTime)),
+ str(time.ctime(endTime)),
+ self.__testResult))
def _injectClients(self, test):
- setattr(test, "debug", self.tcRunLogger.debug)
- setattr(test, "info", self.tcRunLogger.info)
- setattr(test, "warn", self.tcRunLogger.warning)
- setattr(test, "error", self.tcRunLogger.error)
- setattr(test, "testClient", self.testClient)
- setattr(test, "config", self.parsedConfig)
- if self.testClient.identifier is None:
- self.testClient.identifier = self.identifier
- setattr(test, "clstestclient", self.testClient)
+ setattr(test, "debug", self.__tcRunLogger.debug)
+ setattr(test, "info", self.__tcRunLogger.info)
+ setattr(test, "warn", self.__tcRunLogger.warning)
+ setattr(test, "error", self.__tcRunLogger.error)
+ setattr(test, "testClient", self.__testClient)
+ setattr(test, "config", self.__parsedConfig)
+ if self.__testClient.identifier is None:
+ self.__testClient.identifier = self.__identifier
+ setattr(test, "clstestclient", self.__testClient)
if hasattr(test, "user"):
# when the class-level attr applied. all test runs as 'user'
- self.testClient.createUserApiClient(test.UserName, test.DomainName,
- test.AcctType)
+ self.__testClient.getUserApiClient(test.UserName,
+ test.DomainName,
+ test.AcctType)
+
+ def finalize(self, result):
+ try:
+ if not self.__userLogPath:
+ src = self.__logFolderPath
+ log_cfg = self.__parsedConfig.logger
+ tmp = log_cfg.__dict__.get('LogFolderPath') + "/MarvinLogs"
+ dst = tmp + "//" + random_gen()
+ mod_name = "test_suite"
+ if self.__testModName:
+ mod_name = self.__testModName.split(".")
+ if len(mod_name) > 2:
+ mod_name = mod_name[-2]
+ if mod_name:
+ dst = tmp + "/" + mod_name + "_" + random_gen()
+ cmd = "mv " + src + " " + dst
+ os.system(cmd)
+ print "===final results are now copied to: %s===" % str(dst)
+ except Exception, e:
+ print "=== Exception occurred under finalize :%s ===" % \
+ str(GetDetailExceptionInfo(e))
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/tools/marvin/marvin/src/__init__.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/src/__init__.py b/tools/marvin/marvin/src/__init__.py
new file mode 100644
index 0000000..13a8339
--- /dev/null
+++ b/tools/marvin/marvin/src/__init__.py
@@ -0,0 +1,16 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/tools/marvin/marvin/sshClient.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/sshClient.py b/tools/marvin/marvin/sshClient.py
index fd8726c..611c8b5 100644
--- a/tools/marvin/marvin/sshClient.py
+++ b/tools/marvin/marvin/sshClient.py
@@ -16,29 +16,49 @@
# under the License.
import paramiko
+from paramiko import (BadHostKeyException,
+ AuthenticationException,
+ SSHException,
+ SSHClient,
+ AutoAddPolicy,
+ Transport,
+ SFTPClient)
+import socket
import time
-import cloudstackException
+from marvin.cloudstackException import (
+ internalError,
+ GetDetailExceptionInfo
+)
import contextlib
import logging
from marvin.codes import (
- SUCCESS, FAIL, INVALID_INPUT, EXCEPTION_OCCURRED
- )
+ SUCCESS, FAILED, INVALID_INPUT, EXCEPTION_OCCURRED
+)
from contextlib import closing
class SshClient(object):
+
'''
- Added timeout flag for ssh connect calls.Default to 3.0 seconds
+ @Desc : SSH Library for Marvin.
+ Facilitates SSH,SCP services to marvin users
+ @Input: host: Host to connect
+ port: port on host to connect
+ user: Username to be used for connecting
+ passwd: Password for connection
+ retries and delay applies for establishing connection
+ timeout : Applies while executing command
'''
- def __init__(self, host, port, user, passwd, retries=20, delay=30,
- log_lvl=logging.INFO, keyPairFiles=None, timeout=10.0):
+
+ def __init__(self, host, port, user, passwd, retries=60, delay=10,
+ log_lvl=logging.DEBUG, keyPairFiles=None, timeout=10.0):
self.host = None
self.port = 22
self.user = user
self.passwd = passwd
self.keyPairFiles = keyPairFiles
- self.ssh = paramiko.SSHClient()
- self.ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
+ self.ssh = SSHClient()
+ self.ssh.set_missing_host_key_policy(AutoAddPolicy())
self.logger = logging.getLogger('sshClient')
self.retryCnt = 0
self.delay = 0
@@ -47,8 +67,8 @@ class SshClient(object):
ch.setLevel(log_lvl)
self.logger.addHandler(ch)
- #Check invalid host value and raise exception
- #Atleast host is required for connection
+ # Check invalid host value and raise exception
+ # Atleast host is required for connection
if host is not None and host != '':
self.host = host
if retries is not None and retries > 0:
@@ -57,11 +77,10 @@ class SshClient(object):
self.delay = delay
if timeout is not None and timeout > 0:
self.timeout = timeout
- if port is not None or port >= 0:
+ if port is not None and port >= 0:
self.port = port
- if self.createConnection() == FAIL:
- raise cloudstackException.\
- internalError("Connection Failed")
+ if self.createConnection() == FAILED:
+ raise internalError("SSH Connection Failed")
def execute(self, command):
stdin, stdout, stderr = self.ssh.exec_command(command)
@@ -86,15 +105,16 @@ class SshClient(object):
@Desc: Creates an ssh connection for
retries mentioned,along with sleep mentioned
@Output: SUCCESS on successful connection
- FAIL If connection through ssh failed
+ FAILED If connection through ssh failed
'''
- ret = FAIL
+ ret = FAILED
+ except_msg = ''
while self.retryCnt >= 0:
try:
- self.logger.debug("SSH Connection: Host:%s User:%s\
- Port:%s" %
- (self.host, self.user, str(self.port)
- ))
+ self.logger.debug("====Trying SSH Connection: Host:%s User:%s\
+ Port:%s RetryCnt:%s===" %
+ (self.host, self.user, str(self.port),
+ str(self.retryCnt)))
if self.keyPairFiles is None:
self.ssh.connect(hostname=self.host,
port=self.port,
@@ -102,22 +122,39 @@ class SshClient(object):
password=self.passwd,
timeout=self.timeout)
else:
+ self.ssh.load_host_keys(self.keyPairFiles)
self.ssh.connect(hostname=self.host,
port=self.port,
username=self.user,
password=self.passwd,
key_filename=self.keyPairFiles,
timeout=self.timeout,
- look_for_keys=False
+ look_for_keys=True
)
+ self.logger.debug("===SSH to Host %s port : %s SUCCESSFUL==="
+ % (str(self.host), str(self.port)))
ret = SUCCESS
break
- except Exception as se:
- self.retryCnt = self.retryCnt - 1
- if self.retryCnt == 0:
+ except BadHostKeyException as e:
+ except_msg = GetDetailExceptionInfo(e)
+ except AuthenticationException as e:
+ except_msg = GetDetailExceptionInfo(e)
+ except SSHException as e:
+ except_msg = GetDetailExceptionInfo(e)
+ except socket.error as e:
+ except_msg = GetDetailExceptionInfo(e)
+ except Exception as e:
+ except_msg = GetDetailExceptionInfo(e)
+ finally:
+ if self.retryCnt == 0 or ret == SUCCESS:
break
+ if except_msg != '':
+ self.logger.\
+ exception("SshClient: Exception under "
+ "createConnection: %s" % except_msg)
+ self.retryCnt = self.retryCnt - 1
time.sleep(self.delay)
- return ret
+ return ret
def runCommand(self, command):
'''
@@ -126,57 +163,54 @@ class SshClient(object):
returns the result along with status code
@Input: command to execute
@Output: 1: status of command executed.
- Default to None
SUCCESS : If command execution is successful
- FAIL : If command execution has failed
- EXCEPTION_OCCURRED: Exception occurred while executing
- command
- INVALID_INPUT : If invalid value for command is passed
+ FAILED : If command execution has failed
2: stdin,stdout,stderr values of command output
'''
- excep_msg = ''
- ret = {"status": None, "stdin": None, "stdout": None, "stderr": None}
+ ret = {"status": FAILED, "stdin": None, "stdout": None,
+ "stderr": INVALID_INPUT}
if command is None or command == '':
- ret["status"] = INVALID_INPUT
return ret
try:
status_check = 1
- stdin, stdout, stderr = self.ssh.exec_command(command)
- output = stdout.readlines()
- errors = stderr.readlines()
- inp = stdin.readlines()
- ret["stdin"] = inp
- ret["stdout"] = output
- ret["stderr"] = errors
+ stdin, stdout, stderr = self.ssh.\
+ exec_command(command, timeout=self.timeout)
if stdout is not None:
status_check = stdout.channel.recv_exit_status()
- if status_check == 0:
- ret["status"] = SUCCESS
- else:
- ret["status"] = FAIL
+ if status_check == 0:
+ ret["status"] = SUCCESS
+ ret["stdout"] = stdout.readlines()
+ if stderr is not None:
+ ret["stderr"] = stderr.readlines()
except Exception as e:
- excep_msg = str(e)
- ret["status"] = EXCEPTION_OCCURRED
+ ret["stderr"] = GetDetailExceptionInfo(e)
+ self.logger.exception("SshClient: Exception under runCommand :%s" %
+ GetDetailExceptionInfo(e))
finally:
- self.logger.debug(" Host: %s Cmd: %s Output:%s Exception: %s" %
- (self.host, command, str(ret), excep_msg))
+ self.logger.debug(" Host: %s Cmd: %s Output:%s" %
+ (self.host, command, str(ret)))
return ret
def scp(self, srcFile, destPath):
- transport = paramiko.Transport((self.host, int(self.port)))
+ transport = Transport((self.host, int(self.port)))
transport.connect(username=self.user, password=self.passwd)
- sftp = paramiko.SFTPClient.from_transport(transport)
+ sftp = SFTPClient.from_transport(transport)
try:
sftp.put(srcFile, destPath)
- except IOError, e:
+ except IOError as e:
raise e
+ def __del__(self):
+ self.close()
+
def close(self):
if self.ssh is not None:
self.ssh.close()
+ self.ssh = None
if __name__ == "__main__":
- with contextlib.closing(SshClient("10.223.75.10", 22, "root",
- "password")) as ssh:
- print ssh.execute("ls -l")
+ with contextlib.closing(SshClient("127.0.0.1", 22, "root",
+ "asdf!@34")) as ssh:
+ ret = ssh.runCommand("ls -l")
+ print ret
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/tools/marvin/marvin/tcExecuteEngine.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/tcExecuteEngine.py b/tools/marvin/marvin/tcExecuteEngine.py
index f959e7e..e2f4d11 100644
--- a/tools/marvin/marvin/tcExecuteEngine.py
+++ b/tools/marvin/marvin/tcExecuteEngine.py
@@ -23,6 +23,7 @@ from functools import partial
class TestCaseExecuteEngine(object):
+
def __init__(self, testclient, config, tc_logger=None, debug_stream=None):
"""
Initialize the testcase execution engine, just the basics here
@@ -53,7 +54,7 @@ class TestCaseExecuteEngine(object):
if isinstance(test, unittest.BaseTestSuite):
self.injectTestCase(test)
else:
- #inject testclient and logger into each unittest
+ # inject testclient and logger into each unittest
self.tcRunLogger.name = test.__str__()
setattr(test, "testClient", self.testclient)
setattr(test, "config", self.config)
@@ -61,9 +62,10 @@ class TestCaseExecuteEngine(object):
setattr(test.__class__, "clstestclient", self.testclient)
if hasattr(test, "user"):
# attribute when test is entirely executed as user
- self.testclient.createUserApiClient(test.UserName,
- test.DomainName,
- test.AcctType)
+ self.testclient.\
+ getUserApiClient(test.UserName,
+ test.DomainName,
+ test.AcctType)
def run(self):
if self.suite:
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/tools/marvin/marvin/testSetupSuccess.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/testSetupSuccess.py b/tools/marvin/marvin/testSetupSuccess.py
index 1701626..8b000f9 100644
--- a/tools/marvin/marvin/testSetupSuccess.py
+++ b/tools/marvin/marvin/testSetupSuccess.py
@@ -23,6 +23,7 @@ from time import sleep as delay
class TestSetupSuccess(cloudstackTestCase):
+
"""
Test to verify if the cloudstack is ready to launch tests upon
1. Verify that system VMs are up and running in all zones
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/tools/marvin/setup.py
----------------------------------------------------------------------
diff --git a/tools/marvin/setup.py b/tools/marvin/setup.py
index 9ce3951..4c775ad 100644
--- a/tools/marvin/setup.py
+++ b/tools/marvin/setup.py
@@ -6,9 +6,9 @@
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
-#
+#
# http://www.apache.org/licenses/LICENSE-2.0
-#
+#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -30,33 +30,37 @@ except ImportError:
VERSION = '0.1.0'
import os
+
+
def read(fname):
return open(os.path.join(os.path.dirname(__file__), fname)).read().strip()
setup(name="Marvin",
- version=VERSION,
- description="Marvin - Python client for Apache CloudStack",
- author="Edison Su",
- author_email="Edison.Su@citrix.com",
- maintainer="Prasanna Santhanam",
- maintainer_email="tsp@apache.org",
- long_description="Marvin is the Apache CloudStack python client written around the unittest framework",
- platforms=("Any",),
- url="https://builds.apache.org/job/cloudstack-marvin/",
- packages=["marvin", "marvin.cloudstackAPI", "marvin.integration",
- "marvin.integration.lib", "marvin.sandbox",
- "marvin.sandbox.advanced", "marvin.sandbox.advancedsg", "marvin.sandbox.basic"],
- license="LICENSE.txt",
- install_requires=[
- "mysql-connector-python",
- "requests",
- "paramiko",
- "nose",
- "ddt >= 0.4.0"
- ],
- py_modules=['marvin.marvinPlugin'],
- zip_safe=False,
- entry_points={
- 'nose.plugins': ['marvinPlugin = marvin.marvinPlugin:MarvinPlugin']
- },
-)
+ version=VERSION,
+ description="Marvin - Python client for Apache CloudStack",
+ author="Edison Su",
+ author_email="Edison.Su@citrix.com",
+ maintainer="Prasanna Santhanam",
+ maintainer_email="tsp@apache.org",
+ long_description="Marvin is the Apache CloudStack python "
+ "client written around the unittest framework",
+ platforms=("Any",),
+ url="https://builds.apache.org/job/cloudstack-marvin/",
+ packages=["marvin", "marvin.cloudstackAPI",
+ "marvin.lib", "marvin.config", "marvin.sandbox",
+ "marvin.sandbox.advanced", "marvin.sandbox.advancedsg",
+ "marvin.sandbox.basic"],
+ license="LICENSE.txt",
+ install_requires=[
+ "mysql-connector-python",
+ "requests",
+ "paramiko",
+ "nose",
+ "ddt >= 0.4.0"
+ ],
+ py_modules=['marvin.marvinPlugin'],
+ zip_safe=False,
+ entry_points={
+ 'nose.plugins': ['marvinPlugin = marvin.marvinPlugin:MarvinPlugin']
+ },
+ )
[11/18] Marvin + test changes from master Signed-off-by:
SrikanteswaraRao Talluri
Posted by da...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/smoke/test_disk_offerings.py
----------------------------------------------------------------------
diff --git a/test/integration/smoke/test_disk_offerings.py b/test/integration/smoke/test_disk_offerings.py
index 4c8a34c..780c154 100644
--- a/test/integration/smoke/test_disk_offerings.py
+++ b/test/integration/smoke/test_disk_offerings.py
@@ -20,30 +20,17 @@
import marvin
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
from nose.plugins.attrib import attr
_multiprocess_shared_ = True
-class Services:
- """Test Disk offerings Services
- """
-
- def __init__(self):
- self.services = {
- "off": {
- "name": "Disk offering",
- "displaytext": "Disk offering",
- "disksize": 1 # in GB
- },
- }
-
class TestCreateDiskOffering(cloudstackTestCase):
def setUp(self):
- self.services = Services().services
+ self.services = self.testClient.getParsedTestDataConfig()
self.apiclient = self.testClient.getApiClient()
self.dbclient = self.testClient.getDbConnection()
self.cleanup = []
@@ -68,7 +55,7 @@ class TestCreateDiskOffering(cloudstackTestCase):
"""
disk_offering = DiskOffering.create(
self.apiclient,
- self.services["off"]
+ self.services["disk_offering"]
)
self.cleanup.append(disk_offering)
@@ -92,16 +79,96 @@ class TestCreateDiskOffering(cloudstackTestCase):
self.assertEqual(
disk_response.displaytext,
- self.services["off"]["displaytext"],
+ self.services["disk_offering"]["displaytext"],
"Check server id in createServiceOffering"
)
self.assertEqual(
disk_response.name,
- self.services["off"]["name"],
+ self.services["disk_offering"]["name"],
"Check name in createServiceOffering"
)
return
+ @attr(hypervisor="kvm")
+ @attr(tags = ["advanced", "basic", "eip", "sg", "advancedns", "simulator", "smoke"])
+ def test_02_create_sparse_type_disk_offering(self):
+ """Test to create a sparse type disk offering"""
+
+ # Validate the following:
+ # 1. createDiskOfferings should return valid info for new offering
+ # 2. The Cloud Database contains the valid information
+
+ disk_offering = DiskOffering.create(
+ self.apiclient,
+ self.services["sparse"]
+ )
+ self.cleanup.append(disk_offering)
+
+ self.debug("Created Disk offering with ID: %s" % disk_offering.id)
+
+ list_disk_response = list_disk_offering(
+ self.apiclient,
+ id=disk_offering.id
+ )
+ self.assertEqual(
+ isinstance(list_disk_response, list),
+ True,
+ "Check list response returns a valid list"
+ )
+ self.assertNotEqual(
+ len(list_disk_response),
+ 0,
+ "Check Disk offering is created"
+ )
+ disk_response = list_disk_response[0]
+
+ self.assertEqual(
+ disk_response.provisioningtype,
+ self.services["sparse"]["provisioningtype"],
+ "Check provisionig type in createServiceOffering"
+ )
+ return
+
+
+ @attr(hypervisor="kvm")
+ @attr(tags = ["advanced", "basic", "eip", "sg", "advancedns", "simulator", "smoke"])
+ def test_04_create_fat_type_disk_offering(self):
+ """Test to create a sparse type disk offering"""
+
+ # Validate the following:
+ # 1. createDiskOfferings should return valid info for new offering
+ # 2. The Cloud Database contains the valid information
+
+ disk_offering = DiskOffering.create(
+ self.apiclient,
+ self.services["fat"]
+ )
+ self.cleanup.append(disk_offering)
+
+ self.debug("Created Disk offering with ID: %s" % disk_offering.id)
+
+ list_disk_response = list_disk_offering(
+ self.apiclient,
+ id=disk_offering.id
+ )
+ self.assertEqual(
+ isinstance(list_disk_response, list),
+ True,
+ "Check list response returns a valid list"
+ )
+ self.assertNotEqual(
+ len(list_disk_response),
+ 0,
+ "Check Disk offering is created"
+ )
+ disk_response = list_disk_response[0]
+
+ self.assertEqual(
+ disk_response.provisioningtype,
+ self.services["fat"]["provisioningtype"],
+ "Check provisionig type in createServiceOffering"
+ )
+ return
class TestDiskOfferings(cloudstackTestCase):
@@ -122,15 +189,17 @@ class TestDiskOfferings(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.services = Services().services
- cls.api_client = super(TestDiskOfferings, cls).getClsTestClient().getApiClient()
+ testClient = super(TestDiskOfferings, cls).getClsTestClient()
+ cls.apiclient = cls.testClient.getApiClient()
+ cls.services = cls.testClient.getParsedTestDataConfig()
+
cls.disk_offering_1 = DiskOffering.create(
- cls.api_client,
- cls.services["off"]
+ cls.apiclient,
+ cls.services["disk_offering"]
)
cls.disk_offering_2 = DiskOffering.create(
- cls.api_client,
- cls.services["off"]
+ cls.apiclient,
+ cls.services["disk_offering"]
)
cls._cleanup = [cls.disk_offering_1]
return
@@ -138,8 +207,8 @@ class TestDiskOfferings(cloudstackTestCase):
@classmethod
def tearDownClass(cls):
try:
- cls.api_client = super(TestDiskOfferings, cls).getClsTestClient().getApiClient()
- cleanup_resources(cls.api_client, cls._cleanup)
+ cls.apiclient = super(TestDiskOfferings, cls).getClsTestClient().getApiClient()
+ cleanup_resources(cls.apiclient, cls._cleanup)
except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e)
return
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/smoke/test_global_settings.py
----------------------------------------------------------------------
diff --git a/test/integration/smoke/test_global_settings.py b/test/integration/smoke/test_global_settings.py
index f94cf94..ace2db3 100644
--- a/test/integration/smoke/test_global_settings.py
+++ b/test/integration/smoke/test_global_settings.py
@@ -19,9 +19,9 @@
#Import Local Modules
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
from nose.plugins.attrib import attr
#Import System modules
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/smoke/test_guest_vlan_range.py
----------------------------------------------------------------------
diff --git a/test/integration/smoke/test_guest_vlan_range.py b/test/integration/smoke/test_guest_vlan_range.py
index 27225a5..bfef4a8 100644
--- a/test/integration/smoke/test_guest_vlan_range.py
+++ b/test/integration/smoke/test_guest_vlan_range.py
@@ -21,43 +21,22 @@ import marvin
from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
import datetime
-
-class Services:
- """Test Dedicating Guest Vlan Ranges
- """
-
- def __init__(self):
- self.services = {
- "domain": {
- "name": "Domain",
- },
- "account": {
- "email": "test@test.com",
- "firstname": "Test",
- "lastname": "User",
- "username": "test",
- "password": "password",
- },
- "name": "testphysicalnetwork",
-
- "vlan": "2118-2120",
- }
-
-
class TestDedicateGuestVlanRange(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.apiclient = super(TestDedicateGuestVlanRange, cls).getClsTestClient().getApiClient()
- cls.services = Services().services
+ testClient = super(TestDedicateGuestVlanRange, cls).getClsTestClient()
+ cls.apiclient = testClient.getApiClient()
+ cls.services = testClient.getParsedTestDataConfig()
+
# Get Zone, Domain
- cls.domain = get_domain(cls.apiclient, cls.services)
- cls.zone = get_zone(cls.apiclient, cls.services)
+ cls.domain = get_domain(cls.apiclient)
+ cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests())
# Create Account
cls.account = Account.create(
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/smoke/test_hosts.py
----------------------------------------------------------------------
diff --git a/test/integration/smoke/test_hosts.py b/test/integration/smoke/test_hosts.py
index 0810bac..52827aa 100644
--- a/test/integration/smoke/test_hosts.py
+++ b/test/integration/smoke/test_hosts.py
@@ -20,9 +20,9 @@
import marvin
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
from nose.plugins.attrib import attr
#Import System modules
@@ -30,81 +30,15 @@ import time
_multiprocess_shared_ = True
-class Services:
- """Test Hosts & Clusters Services
- """
-
- def __init__(self):
- self.services = {
- "clusters": {
- 0: {
- "clustername": "Xen Cluster",
- "clustertype": "CloudManaged",
- # CloudManaged or ExternalManaged"
- "hypervisor": "XenServer",
- # Hypervisor type
- },
- 1: {
- "clustername": "KVM Cluster",
- "clustertype": "CloudManaged",
- # CloudManaged or ExternalManaged"
- "hypervisor": "KVM",
- # Hypervisor type
- },
- 2: {
- "hypervisor": 'VMware',
- # Hypervisor type
- "clustertype": 'ExternalManaged',
- # CloudManaged or ExternalManaged"
- "username": 'administrator',
- "password": 'fr3sca',
- "url": 'http://192.168.100.17/CloudStack-Clogeny-Pune/Pune-1',
- # Format:http://vCenter Host/Datacenter/Cluster
- "clustername": 'VMWare Cluster',
- },
- },
- "hosts": {
- "xenserver": {
- # Must be name of corresponding Hypervisor type
- # in cluster in small letters
- "hypervisor": 'XenServer',
- # Hypervisor type
- "clustertype": 'CloudManaged',
- # CloudManaged or ExternalManaged"
- "url": 'http://192.168.100.211',
- "username": "root",
- "password": "fr3sca",
- },
- "kvm": {
- "hypervisor": 'KVM',
- # Hypervisor type
- "clustertype": 'CloudManaged',
- # CloudManaged or ExternalManaged"
- "url": 'http://192.168.100.212',
- "username": "root",
- "password": "fr3sca",
- },
- "vmware": {
- "hypervisor": 'VMware',
- # Hypervisor type
- "clustertype": 'ExternalManaged',
- # CloudManaged or ExternalManaged"
- "url": 'http://192.168.100.203',
- "username": "administrator",
- "password": "fr3sca",
- },
- },
- }
-
class TestHosts(cloudstackTestCase):
def setUp(self):
-
self.apiclient = self.testClient.getApiClient()
+ self.hypervisor = self.testClient.getHypervisorInfo()
self.dbclient = self.testClient.getDbConnection()
- self.services = Services().services
- self.zone = get_zone(self.apiclient, self.services)
- self.pod = get_pod(self.apiclient, self.zone.id, self.services)
+ self.services = self.testClient.getParsedTestDataConfig()
+ self.zone = get_zone(self.apiclient, self.testClient.getZoneForTests())
+ self.pod = get_pod(self.apiclient, self.zone.id)
self.cleanup = []
return
@@ -136,7 +70,8 @@ class TestHosts(cloudstackTestCase):
self.apiclient,
v,
zoneid=self.zone.id,
- podid=self.pod.id
+ podid=self.pod.id,
+ hypervisor=self.hypervisor
)
self.debug(
"Created Cluster for hypervisor type %s & ID: %s" %(
@@ -167,8 +102,11 @@ class TestHosts(cloudstackTestCase):
cluster,
self.services["hosts"][hypervisor_type],
zoneid=self.zone.id,
- podid=self.pod.id
+ 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/798a6aa2/test/integration/smoke/test_internal_lb.py
----------------------------------------------------------------------
diff --git a/test/integration/smoke/test_internal_lb.py b/test/integration/smoke/test_internal_lb.py
index 875df04..d6f3477 100644
--- a/test/integration/smoke/test_internal_lb.py
+++ b/test/integration/smoke/test_internal_lb.py
@@ -17,80 +17,29 @@
""" Tests for configuring Internal Load Balancing Rules.
"""
#Import Local Modules
+from marvin.codes import FAILED
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
from nose.plugins.attrib import attr
-
-class Services:
- def __init__(self):
- self.services = {
- "account": {
- "email": "test@test.com",
- "firstname": "Test",
- "lastname": "User",
- "username": "test",
- "password": "password",
- },
- "virtual_machine": {
- "displayname": "Test VM",
- "username": "root",
- "password": "password",
- "ssh_port": 22,
- "hypervisor": 'XenServer',
- "privateport": 22,
- "publicport": 22,
- "protocol": 'TCP',
- },
- "ostype": 'CentOS 5.3 (64-bit)',
- "service_offering": {
- "name": "Tiny Instance",
- "displaytext": "Tiny Instance",
- "cpunumber": 1,
- "cpuspeed": 100,
- "memory": 256,
- },
- "network_offering": {
- "name": "Network offering for internal lb service",
- "displaytext": "Network offering for internal lb service",
- "guestiptype": "Isolated",
- "traffictype": "Guest",
- "supportedservices": "Vpn,Dhcp,Dns,Lb,UserData,SourceNat,StaticNat,PortForwarding,NetworkACL",
- "serviceProviderList": {
- "Dhcp": "VpcVirtualRouter",
- "Dns": "VpcVirtualRouter",
- "Vpn": "VpcVirtualRouter",
- "UserData": "VpcVirtualRouter",
- "Lb": "InternalLbVM",
- "SourceNat": "VpcVirtualRouter",
- "StaticNat": "VpcVirtualRouter",
- "PortForwarding": "VpcVirtualRouter",
- "NetworkACL": "VpcVirtualRouter",
- },
- "serviceCapabilityList": {
- "SourceNat": {"SupportedSourceNatTypes": "peraccount"},
- "Lb": {"lbSchemes": "internal", "SupportedLbIsolation": "dedicated"}
- }
- }
- }
-
-
class TestInternalLb(cloudstackTestCase):
"""Test Internal LB
"""
@classmethod
def setUpClass(cls):
- cls.apiclient = super(TestInternalLb, cls).getClsTestClient().getApiClient()
- cls.services = Services().services
- cls.zone = get_zone(cls.apiclient, cls.services)
+ testClient = super(TestInternalLb, cls).getClsTestClient()
+ cls.apiclient = testClient.getApiClient()
+ cls.services = testClient.getParsedTestDataConfig()
+
+ cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests())
cls.domain = get_domain(cls.apiclient)
cls.service_offering = ServiceOffering.create(
cls.apiclient,
- cls.services["service_offering"]
+ cls.services["service_offerings"]
)
cls.account = Account.create(cls.apiclient, services=cls.services["account"])
cls.template = get_template(
@@ -98,6 +47,10 @@ class TestInternalLb(cloudstackTestCase):
cls.zone.id,
cls.services["ostype"]
)
+
+ if cls.template == FAILED:
+ assert False, "get_template() failed to return template with description %s" % cls.services["ostype"]
+
cls.debug("Successfully created account: %s, id: \
%s" % (cls.account.name,\
cls.account.id))
@@ -106,10 +59,10 @@ class TestInternalLb(cloudstackTestCase):
@attr(tags=["smoke", "advanced", "provisioning"])
def test_internallb(self):
"""Test create, delete, assign, remove of internal loadbalancer
+ """
#1) Create and enable network offering with Internal Lb vm service
- """
+ self.networkOffering = NetworkOffering.create(self.apiclient, self.services["network_offering_internal_lb"], conservemode=False)
#TODO: SIMENH:modify this test to verify lb rules by sending request from another tier
- self.networkOffering = NetworkOffering.create(self.apiclient, self.services["network_offering"], conservemode=False)
self.networkOffering.update(self.apiclient, state="Enabled")
#2) Create VPC and network in it
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/smoke/test_iso.py
----------------------------------------------------------------------
diff --git a/test/integration/smoke/test_iso.py b/test/integration/smoke/test_iso.py
index 01ce2fd..4a22850 100644
--- a/test/integration/smoke/test_iso.py
+++ b/test/integration/smoke/test_iso.py
@@ -20,9 +20,9 @@
import marvin
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
from nose.plugins.attrib import attr
import urllib
from random import random
@@ -31,70 +31,19 @@ import time
_multiprocess_shared_ = True
-class Services:
- """Test ISO Services
- """
-
- def __init__(self):
- self.services = {
- "account": {
- "email": "test@test.com",
- "firstname": "Test",
- "lastname": "User",
- "username": "test",
- # Random characters are appended in create account to
- # ensure unique username generated each time
- "password": "password",
- },
- "iso_1":
- {
- "displaytext": "Test ISO 1",
- "name": "ISO 1",
- "url": "http://people.apache.org/~tsp/dummy.iso",
- # Source URL where ISO is located
- "isextractable": True,
- "isfeatured": True,
- "ispublic": True,
- "ostype": "CentOS 5.3 (64-bit)",
- },
- "iso_2":
- {
- "displaytext": "Test ISO 2",
- "name": "ISO 2",
- "url": "http://people.apache.org/~tsp/dummy.iso",
- # Source URL where ISO is located
- "isextractable": True,
- "isfeatured": True,
- "ispublic": True,
- "ostype": "CentOS 5.3 (64-bit)",
- "mode": 'HTTP_DOWNLOAD',
- # Used in Extract template, value must be HTTP_DOWNLOAD
- },
- "isfeatured": True,
- "ispublic": True,
- "isextractable": True,
- "bootable": True, # For edit template
- "passwordenabled": True,
- "sleep": 60,
- "timeout": 10,
- "ostype": "CentOS 5.3 (64-bit)",
- # CentOS 5.3 (64 bit)
- }
-
-
class TestCreateIso(cloudstackTestCase):
#TODO: SIMENH: check the existence of registered of ISO in secondary deploy a VM with registered ISO. can be added \
# as another test
def setUp(self):
- self.services = Services().services
+ self.services = self.testClient.getParsedTestDataConfig()
self.apiclient = self.testClient.getApiClient()
self.dbclient = self.testClient.getDbConnection()
# Get Zone, Domain and templates
- self.domain = get_domain(self.apiclient, self.services)
- self.zone = get_zone(self.apiclient, self.services)
+ self.domain = get_domain(self.apiclient)
+ self.zone = get_zone(self.apiclient, self.testClient.getZoneForTests())
self.services['mode'] = self.zone.networktype
self.services["domainid"] = self.domain.id
- self.services["iso_2"]["zoneid"] = self.zone.id
+ self.services["iso2"]["zoneid"] = self.zone.id
self.account = Account.create(
self.apiclient,
@@ -109,8 +58,8 @@ class TestCreateIso(cloudstackTestCase):
if not isinstance(ostypes, list):
raise unittest.SkipTest("OSTypeId for given description not found")
- self.services["iso_1"]["ostypeid"] = ostypes[0].id
- self.services["iso_2"]["ostypeid"] = ostypes[0].id
+ self.services["iso1"]["ostypeid"] = ostypes[0].id
+ self.services["iso2"]["ostypeid"] = ostypes[0].id
self.services["ostypeid"] = ostypes[0].id
self.cleanup = [self.account]
@@ -139,7 +88,7 @@ class TestCreateIso(cloudstackTestCase):
iso = Iso.create(
self.apiclient,
- self.services["iso_2"],
+ self.services["iso2"],
account=self.account.name,
domainid=self.account.domainid
)
@@ -170,17 +119,17 @@ class TestCreateIso(cloudstackTestCase):
self.assertEqual(
iso_response.displaytext,
- self.services["iso_2"]["displaytext"],
+ self.services["iso2"]["displaytext"],
"Check display text of newly created ISO"
)
self.assertEqual(
iso_response.name,
- self.services["iso_2"]["name"],
+ self.services["iso2"]["name"],
"Check name of newly created ISO"
)
self.assertEqual(
iso_response.zoneid,
- self.services["iso_2"]["zoneid"],
+ self.services["iso2"]["zoneid"],
"Check zone ID of newly created ISO"
)
return
@@ -191,62 +140,62 @@ class TestISO(cloudstackTestCase):
@classmethod
@attr(BugId="CLOUDSTACK-6769, CLOUDSTACK-6774")
def setUpClass(cls):
- cls.services = Services().services
- cls.api_client = super(TestISO, cls).getClsTestClient().getApiClient()
+ testClient = super(TestISO, cls).getClsTestClient()
+ cls.apiclient = testClient.getApiClient()
+ cls.services = testClient.getParsedTestDataConfig()
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.apiclient)
+ cls.zone = get_zone(cls.apiclient, cls.testClient.getZoneForTests())
cls.services["domainid"] = cls.domain.id
- cls.services["iso_1"]["zoneid"] = cls.zone.id
- cls.services["iso_2"]["zoneid"] = cls.zone.id
+ cls.services["iso1"]["zoneid"] = cls.zone.id
+ cls.services["iso2"]["zoneid"] = cls.zone.id
cls.services["sourcezoneid"] = cls.zone.id
#populate second zone id for iso copy
cmd = listZones.listZonesCmd()
- cls.zones = cls.api_client.listZones(cmd)
+ cls.zones = cls.apiclient.listZones(cmd)
if not isinstance(cls.zones, list):
raise Exception("Failed to find zones.")
#Create an account, ISOs etc.
cls.account = Account.create(
- cls.api_client,
+ cls.apiclient,
cls.services["account"],
domainid=cls.domain.id
)
- cls.services["account"] = cls.account.name
# Finding the OsTypeId from Ostype
ostypes = list_os_types(
- cls.api_client,
+ cls.apiclient,
description=cls.services["ostype"]
)
if not isinstance(ostypes, list):
raise unittest.SkipTest("OSTypeId for given description not found")
- cls.services["iso_1"]["ostypeid"] = ostypes[0].id
- cls.services["iso_2"]["ostypeid"] = ostypes[0].id
+ cls.services["iso1"]["ostypeid"] = ostypes[0].id
+ cls.services["iso2"]["ostypeid"] = ostypes[0].id
cls.services["ostypeid"] = ostypes[0].id
cls.iso_1 = Iso.create(
- cls.api_client,
- cls.services["iso_1"],
+ cls.apiclient,
+ cls.services["iso1"],
account=cls.account.name,
domainid=cls.account.domainid
)
try:
- cls.iso_1.download(cls.api_client)
+ cls.iso_1.download(cls.apiclient)
except Exception as e:
raise Exception("Exception while downloading ISO %s: %s"\
% (cls.iso_1.id, e))
cls.iso_2 = Iso.create(
- cls.api_client,
- cls.services["iso_2"],
+ cls.apiclient,
+ cls.services["iso2"],
account=cls.account.name,
domainid=cls.account.domainid
)
try:
- cls.iso_2.download(cls.api_client)
+ cls.iso_2.download(cls.apiclient)
except Exception as e:
raise Exception("Exception while downloading ISO %s: %s"\
% (cls.iso_2.id, e))
@@ -257,9 +206,9 @@ class TestISO(cloudstackTestCase):
@classmethod
def tearDownClass(cls):
try:
- cls.api_client = super(TestISO, cls).getClsTestClient().getApiClient()
+ cls.apiclient = super(TestISO, cls).getClsTestClient().getApiClient()
#Clean up, terminate the created templates
- cleanup_resources(cls.api_client, cls._cleanup)
+ cleanup_resources(cls.apiclient, cls._cleanup)
except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e)
@@ -388,8 +337,8 @@ class TestISO(cloudstackTestCase):
cmd = extractIso.extractIsoCmd()
cmd.id = self.iso_2.id
- cmd.mode = self.services["iso_2"]["mode"]
- cmd.zoneid = self.services["iso_2"]["zoneid"]
+ cmd.mode = self.services["iso2"]["mode"]
+ cmd.zoneid = self.services["iso2"]["zoneid"]
list_extract_response = self.apiclient.extractIso(cmd)
try:
@@ -410,12 +359,12 @@ class TestISO(cloudstackTestCase):
)
self.assertEqual(
list_extract_response.extractMode,
- self.services["iso_2"]["mode"],
+ self.services["iso2"]["mode"],
"Check mode of extraction"
)
self.assertEqual(
list_extract_response.zoneid,
- self.services["iso_2"]["zoneid"],
+ self.services["iso2"]["zoneid"],
"Check zone ID of extraction"
)
self.assertEqual(
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/smoke/test_loadbalance.py
----------------------------------------------------------------------
diff --git a/test/integration/smoke/test_loadbalance.py b/test/integration/smoke/test_loadbalance.py
index 46eb7d4..daa5fee 100644
--- a/test/integration/smoke/test_loadbalance.py
+++ b/test/integration/smoke/test_loadbalance.py
@@ -15,154 +15,86 @@
# specific language governing permissions and limitations
# under the License.
+from marvin.codes import FAILED
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
from marvin.sshClient import SshClient
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
from nose.plugins.attrib import attr
#Import System modules
import time
_multiprocess_shared_ = True
-class Services:
- """Test Network Services
- """
-
- def __init__(self):
- self.services = {
- "ostype": "CentOS 5.3 (64-bit)",
- # Cent OS 5.3 (64 bit)
- "lb_switch_wait": 10,
- # Time interval after which LB switches the requests
- "sleep": 60,
- "timeout":10,
- "network_offering": {
- "name": 'Test Network offering',
- "displaytext": 'Test Network offering',
- "guestiptype": 'Isolated',
- "supportedservices": 'Dhcp,Dns,SourceNat,PortForwarding',
- "traffictype": 'GUEST',
- "availability": 'Optional',
- "serviceProviderList" : {
- "Dhcp": 'VirtualRouter',
- "Dns": 'VirtualRouter',
- "SourceNat": 'VirtualRouter',
- "PortForwarding": 'VirtualRouter',
- },
- },
- "network": {
- "name": "Test Network",
- "displaytext": "Test Network",
- },
- "service_offering": {
- "name": "Tiny Instance",
- "displaytext": "Tiny Instance",
- "cpunumber": 1,
- "cpuspeed": 100,
- # in MHz
- "memory": 256,
- # In MBs
- },
- "account": {
- "email": "test@test.com",
- "firstname": "Test",
- "lastname": "User",
- "username": "test",
- "password": "password",
- },
- "server":
- {
- "displayname": "Small Instance",
- "username": "root",
- "password": "password",
- "hypervisor": 'XenServer',
- "privateport": 22,
- "publicport": 22,
- "ssh_port": 22,
- "protocol": 'TCP',
- },
- "natrule":
- {
- "privateport": 22,
- "publicport": 2222,
- "protocol": "TCP"
- },
- "lbrule":
- {
- "name": "SSH",
- "alg": "roundrobin",
- # Algorithm used for load balancing
- "privateport": 22,
- "publicport": 2222,
- "protocol": 'TCP'
- }
- }
-
class TestLoadBalance(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(TestLoadBalance, cls).getClsTestClient().getApiClient()
- cls.services = Services().services
+ testClient = super(TestLoadBalance, cls).getClsTestClient()
+ cls.apiclient = testClient.getApiClient()
+ cls.services = testClient.getParsedTestDataConfig()
+
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.apiclient)
+ cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests())
template = get_template(
- cls.api_client,
+ cls.apiclient,
cls.zone.id,
cls.services["ostype"]
)
- cls.services["server"]["zoneid"] = cls.zone.id
+ if template == FAILED:
+ assert False, "get_template() failed to return template with description %s" % cls.services["ostype"]
+
+ cls.services["virtual_machine"]["zoneid"] = cls.zone.id
#Create an account, network, VM and IP addresses
cls.account = Account.create(
- cls.api_client,
+ cls.apiclient,
cls.services["account"],
admin=True,
domainid=cls.domain.id
)
cls.service_offering = ServiceOffering.create(
- cls.api_client,
- cls.services["service_offering"]
+ cls.apiclient,
+ cls.services["service_offerings"]
)
cls.vm_1 = VirtualMachine.create(
- cls.api_client,
- cls.services["server"],
+ cls.apiclient,
+ cls.services["virtual_machine"],
templateid=template.id,
accountid=cls.account.name,
domainid=cls.account.domainid,
serviceofferingid=cls.service_offering.id
)
cls.vm_2 = VirtualMachine.create(
- cls.api_client,
- cls.services["server"],
+ cls.apiclient,
+ cls.services["virtual_machine"],
templateid=template.id,
accountid=cls.account.name,
domainid=cls.account.domainid,
serviceofferingid=cls.service_offering.id
)
cls.vm_3 = VirtualMachine.create(
- cls.api_client,
- cls.services["server"],
+ cls.apiclient,
+ cls.services["virtual_machine"],
templateid=template.id,
accountid=cls.account.name,
domainid=cls.account.domainid,
serviceofferingid=cls.service_offering.id
)
cls.non_src_nat_ip = PublicIPAddress.create(
- cls.api_client,
+ cls.apiclient,
cls.account.name,
cls.zone.id,
cls.account.domainid,
- cls.services["server"]
+ cls.services["virtual_machine"]
)
# Open up firewall port for SSH
cls.fw_rule = FireWallRule.create(
- cls.api_client,
+ cls.apiclient,
ipaddressid=cls.non_src_nat_ip.ipaddress.id,
protocol=cls.services["lbrule"]["protocol"],
cidrlist=['0.0.0.0/0'],
@@ -185,7 +117,7 @@ class TestLoadBalance(cloudstackTestCase):
@classmethod
def tearDownClass(cls):
- cleanup_resources(cls.api_client, cls._cleanup)
+ cleanup_resources(cls.apiclient, cls._cleanup)
return
def try_ssh(self, ip_addr, hostnames):
@@ -208,7 +140,7 @@ class TestLoadBalance(cloudstackTestCase):
except Exception as e:
self.fail("%s: SSH failed for VM with IP Address: %s" %
(e, ip_addr))
- time.sleep(self.services["lb_switch_wait"])
+ time.sleep(10)
return
@attr(tags = ["advanced", "advancedns", "smoke", "provisioning"])
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/smoke/test_multipleips_per_nic.py
----------------------------------------------------------------------
diff --git a/test/integration/smoke/test_multipleips_per_nic.py b/test/integration/smoke/test_multipleips_per_nic.py
index 0c6c02a..ad3a3cf 100644
--- a/test/integration/smoke/test_multipleips_per_nic.py
+++ b/test/integration/smoke/test_multipleips_per_nic.py
@@ -16,6 +16,7 @@
# under the License.
#Test from the Marvin - Testing in Python wiki
+from marvin.codes import FAILED
#All tests inherit from cloudstackTestCase
from marvin.cloudstackTestCase import cloudstackTestCase
@@ -23,13 +24,13 @@ from marvin.cloudstackTestCase import cloudstackTestCase
#Import Integration Libraries
#base - contains all resources as entities and defines create, delete, list operations on them
-from marvin.integration.lib.base import Account, VirtualMachine, ServiceOffering
+from marvin.lib.base import Account, VirtualMachine, ServiceOffering
#utils - utility classes for common cleanup, external library wrappers etc
-from marvin.integration.lib.utils import cleanup_resources
+from marvin.lib.utils import cleanup_resources
#common - commonly used methods for all tests are listed here
-from marvin.integration.lib.common import get_zone, get_domain, get_template
+from marvin.lib.common import get_zone, get_domain, get_template
from marvin.cloudstackAPI.addIpToNic import addIpToNicCmd
from marvin.cloudstackAPI.removeIpFromNic import removeIpFromNicCmd
@@ -38,52 +39,23 @@ from marvin.cloudstackAPI.listNics import listNicsCmd
from nose.plugins.attrib import attr
-class TestData(object):
- """Test data object that is required to create resources
- """
- def __init__(self):
- self.testdata = {
- #data to create an account
- "account": {
- "email": "test@test.com",
- "firstname": "Test",
- "lastname": "User",
- "username": "test",
- "password": "password",
- },
- #data reqd for virtual machine creation
- "virtual_machine" : {
- "name" : "testvm",
- "displayname" : "Test VM",
- },
- #small service offering
- "service_offering": {
- "small": {
- "name": "Small Instance",
- "displaytext": "Small Instance",
- "cpunumber": 1,
- "cpuspeed": 100,
- "memory": 256,
- },
- },
- "ostype": 'CentOS 5.3 (64-bit)',
- }
-
-
class TestDeployVM(cloudstackTestCase):
"""Test deploy a VM into a user account
"""
def setUp(self):
- self.testdata = TestData().testdata
+ self.testdata = self.testClient.getParsedTestDataConfig()
self.apiclient = self.testClient.getApiClient()
# Get Zone, Domain and Default Built-in template
- self.domain = get_domain(self.apiclient, self.testdata)
- self.zone = get_zone(self.apiclient, self.testdata)
+ self.domain = get_domain(self.apiclient)
+ self.zone = get_zone(self.apiclient, self.testClient.getZoneForTests())
self.testdata["mode"] = self.zone.networktype
self.template = get_template(self.apiclient, self.zone.id, self.testdata["ostype"])
+ if self.template == FAILED:
+ assert False, "get_template() failed to return template with description %s" % self.testdata["ostype"]
+
#create a user account
self.account = Account.create(
self.apiclient,
@@ -93,7 +65,7 @@ class TestDeployVM(cloudstackTestCase):
#create a service offering
self.service_offering = ServiceOffering.create(
self.apiclient,
- self.testdata["service_offering"]["small"]
+ self.testdata["service_offerings"]["small"]
)
#build cleanup list
self.cleanup = [
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/smoke/test_network.py
----------------------------------------------------------------------
diff --git a/test/integration/smoke/test_network.py b/test/integration/smoke/test_network.py
index 2cdcfa2..a9e0c25 100644
--- a/test/integration/smoke/test_network.py
+++ b/test/integration/smoke/test_network.py
@@ -18,139 +18,67 @@
"""
#Import Local Modules
import marvin
-from marvin.cloudstackException import cloudstackAPIException
+from marvin.codes import FAILED
+from marvin.cloudstackException import CloudstackAPIException
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
from marvin.sshClient import SshClient
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
from nose.plugins.attrib import attr
#Import System modules
import time
_multiprocess_shared_ = True
-class Services:
- """Test Network Services
- """
-
- def __init__(self):
- self.services = {
- "ostype": "CentOS 5.3 (64-bit)",
- # Cent OS 5.3 (64 bit)
- "lb_switch_wait": 10,
- # Time interval after which LB switches the requests
- "sleep": 60,
- "timeout":10,
- "network_offering": {
- "name": 'Test Network offering',
- "displaytext": 'Test Network offering',
- "guestiptype": 'Isolated',
- "supportedservices": 'Dhcp,Dns,SourceNat,PortForwarding',
- "traffictype": 'GUEST',
- "availability": 'Optional',
- "serviceProviderList" : {
- "Dhcp": 'VirtualRouter',
- "Dns": 'VirtualRouter',
- "SourceNat": 'VirtualRouter',
- "PortForwarding": 'VirtualRouter',
- },
- },
- "network": {
- "name": "Test Network",
- "displaytext": "Test Network",
- },
- "service_offering": {
- "name": "Tiny Instance",
- "displaytext": "Tiny Instance",
- "cpunumber": 1,
- "cpuspeed": 100,
- # in MHz
- "memory": 256,
- # In MBs
- },
- "account": {
- "email": "test@test.com",
- "firstname": "Test",
- "lastname": "User",
- "username": "test",
- "password": "password",
- },
- "server":
- {
- "displayname": "Small Instance",
- "username": "root",
- "password": "password",
- "hypervisor": 'XenServer',
- "privateport": 22,
- "publicport": 22,
- "ssh_port": 22,
- "protocol": 'TCP',
- },
- "natrule":
- {
- "privateport": 22,
- "publicport": 22,
- "protocol": "TCP"
- },
- "lbrule":
- {
- "name": "SSH",
- "alg": "roundrobin",
- # Algorithm used for load balancing
- "privateport": 22,
- "publicport": 2222,
- "protocol": 'TCP'
- }
- }
-
class TestPublicIP(cloudstackTestCase):
def setUp(self):
self.apiclient = self.testClient.getApiClient()
- self.services = Services().services
@classmethod
def setUpClass(cls):
- cls.api_client = super(TestPublicIP, cls).getClsTestClient().getApiClient()
- cls.services = Services().services
+ testClient = super(TestPublicIP, cls).getClsTestClient()
+ cls.apiclient = testClient.getApiClient()
+ cls.services = testClient.getParsedTestDataConfig()
+
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.apiclient)
+ cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests())
cls.services['mode'] = cls.zone.networktype
# Create Accounts & networks
cls.account = Account.create(
- cls.api_client,
+ cls.apiclient,
cls.services["account"],
admin=True,
domainid=cls.domain.id
)
cls.user = Account.create(
- cls.api_client,
+ cls.apiclient,
cls.services["account"],
domainid=cls.domain.id
)
cls.services["network"]["zoneid"] = cls.zone.id
cls.network_offering = NetworkOffering.create(
- cls.api_client,
+ cls.apiclient,
cls.services["network_offering"],
)
# Enable Network offering
- cls.network_offering.update(cls.api_client, state='Enabled')
+ cls.network_offering.update(cls.apiclient, state='Enabled')
cls.services["network"]["networkoffering"] = cls.network_offering.id
cls.account_network = Network.create(
- cls.api_client,
+ cls.apiclient,
cls.services["network"],
cls.account.name,
cls.account.domainid
)
cls.user_network = Network.create(
- cls.api_client,
+ cls.apiclient,
cls.services["network"],
cls.user.name,
cls.user.domainid
@@ -158,13 +86,13 @@ class TestPublicIP(cloudstackTestCase):
# Create Source NAT IP addresses
account_src_nat_ip = PublicIPAddress.create(
- cls.api_client,
+ cls.apiclient,
cls.account.name,
cls.zone.id,
cls.account.domainid
)
user_src_nat_ip = PublicIPAddress.create(
- cls.api_client,
+ cls.apiclient,
cls.user.name,
cls.zone.id,
cls.user.domainid
@@ -182,7 +110,7 @@ class TestPublicIP(cloudstackTestCase):
def tearDownClass(cls):
try:
#Cleanup resources used
- cleanup_resources(cls.api_client, cls._cleanup)
+ cleanup_resources(cls.apiclient, cls._cleanup)
except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e)
return
@@ -223,6 +151,7 @@ class TestPublicIP(cloudstackTestCase):
)
ip_address.delete(self.apiclient)
+ time.sleep(30)
# Validate the following:
# 1.listPublicIpAddresses should no more return the released address
@@ -231,10 +160,15 @@ class TestPublicIP(cloudstackTestCase):
id=ip_address.ipaddress.id
)
self.assertEqual(
- list_pub_ip_addr_resp,
- None,
- "Check if disassociated IP Address is no longer available"
- )
+ isinstance(list_pub_ip_addr_resp, list),
+ True,
+ "Check list response returns a valid list"
+ )
+ self.assertEqual(
+ len(list_pub_ip_addr_resp),
+ 0,
+ "Check if the list public ip api response is not zero"
+ )
return
@attr(tags = ["advanced", "advancedns", "smoke", "selfservice"])
@@ -293,32 +227,35 @@ class TestPortForwarding(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(TestPortForwarding, cls).getClsTestClient().getApiClient()
- cls.services = Services().services
-
+ testClient = super(TestPortForwarding, cls).getClsTestClient()
+ cls.apiclient = testClient.getApiClient()
+ cls.services = testClient.getParsedTestDataConfig()
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.apiclient)
+ cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests())
template = get_template(
- cls.api_client,
+ cls.apiclient,
cls.zone.id,
cls.services["ostype"]
)
+ if template == FAILED:
+ assert False, "get_template() failed to return template with description %s" % cls.services["ostype"]
+
#Create an account, network, VM and IP addresses
cls.account = Account.create(
- cls.api_client,
+ cls.apiclient,
cls.services["account"],
admin=True,
domainid=cls.domain.id
)
- cls.services["server"]["zoneid"] = cls.zone.id
+ cls.services["virtual_machine"]["zoneid"] = cls.zone.id
cls.service_offering = ServiceOffering.create(
- cls.api_client,
- cls.services["service_offering"]
+ cls.apiclient,
+ cls.services["service_offerings"]
)
cls.virtual_machine = VirtualMachine.create(
- cls.api_client,
- cls.services["server"],
+ cls.apiclient,
+ cls.services["virtual_machine"],
templateid=template.id,
accountid=cls.account.name,
domainid=cls.account.domainid,
@@ -338,8 +275,8 @@ class TestPortForwarding(cloudstackTestCase):
@classmethod
def tearDownClass(cls):
try:
- cls.api_client = super(TestPortForwarding, cls).getClsTestClient().getApiClient()
- cleanup_resources(cls.api_client, cls._cleanup)
+ cls.apiclient = super(TestPortForwarding, cls).getClsTestClient().getApiClient()
+ cleanup_resources(cls.apiclient, cls._cleanup)
except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e)
@@ -437,22 +374,27 @@ class TestPortForwarding(cloudstackTestCase):
))
self.virtual_machine.get_ssh_client(src_nat_ip_addr.ipaddress)
-
+ vm_response = VirtualMachine.list(
+ self.apiclient,
+ id=self.virtual_machine.id
+ )
+ if vm_response[0].state != 'Running':
+ self.fail("State of VM : %s is not found to be Running" % str(self.virtual_machine.ipaddress))
+
except Exception as e:
self.fail(
"SSH Access failed for %s: %s" % \
(self.virtual_machine.ipaddress, e)
)
- nat_rule.delete(self.apiclient)
-
try:
+ nat_rule.delete(self.apiclient)
list_nat_rule_response = list_nat_rules(
self.apiclient,
id=nat_rule.id
)
- except cloudstackAPIException:
- self.debug("Nat Rule is deleted")
+ except CloudstackAPIException:
+ self.fail("Nat Rule Deletion or Listing Failed")
# Check if the Public SSH port is inaccessible
with self.assertRaises(Exception):
@@ -464,9 +406,7 @@ class TestPortForwarding(cloudstackTestCase):
src_nat_ip_addr.ipaddress,
self.virtual_machine.ssh_port,
self.virtual_machine.username,
- self.virtual_machine.password,
- retries=2,
- delay=0
+ self.virtual_machine.password
)
return
@@ -483,7 +423,7 @@ class TestPortForwarding(cloudstackTestCase):
self.account.name,
self.zone.id,
self.account.domainid,
- self.services["server"]
+ self.services["virtual_machine"]
)
self.cleanup.append(ip_address)
@@ -569,7 +509,7 @@ class TestPortForwarding(cloudstackTestCase):
self.apiclient,
id=nat_rule.id
)
- except cloudstackAPIException:
+ except CloudstackAPIException:
self.debug("Nat Rule is deleted")
# Check if the Public SSH port is inaccessible
@@ -596,17 +536,19 @@ class TestRebootRouter(cloudstackTestCase):
def setUp(self):
self.apiclient = self.testClient.getApiClient()
- self.services = Services().services
+ self.services = self.testClient.getParsedTestDataConfig()
# Get Zone, Domain and templates
- self.domain = get_domain(self.apiclient, self.services)
- self.zone = get_zone(self.apiclient, self.services)
+ self.domain = get_domain(self.apiclient)
+ self.zone = get_zone(self.apiclient, self.testClient.getZoneForTests())
template = get_template(
self.apiclient,
self.zone.id,
self.services["ostype"]
)
- self.services["server"]["zoneid"] = self.zone.id
+ if template == FAILED:
+ self.fail("get_template() failed to return template with description %s" % self.services["ostype"])
+ self.services["virtual_machine"]["zoneid"] = self.zone.id
#Create an account, network, VM and IP addresses
self.account = Account.create(
@@ -617,11 +559,11 @@ class TestRebootRouter(cloudstackTestCase):
)
self.service_offering = ServiceOffering.create(
self.apiclient,
- self.services["service_offering"]
+ self.services["service_offerings"]
)
self.vm_1 = VirtualMachine.create(
self.apiclient,
- self.services["server"],
+ self.services["virtual_machine"],
templateid=template.id,
accountid=self.account.name,
domainid=self.account.domainid,
@@ -646,7 +588,7 @@ class TestRebootRouter(cloudstackTestCase):
self.vm_1.account,
self.vm_1.zoneid,
self.vm_1.domainid,
- self.services["server"]
+ self.services["virtual_machine"]
)
#Open up firewall port for SSH
fw_rule = FireWallRule.create(
@@ -762,17 +704,17 @@ class TestReleaseIP(cloudstackTestCase):
def setUp(self):
self.apiclient = self.testClient.getApiClient()
- self.services = Services().services
+ self.services = self.testClient.getParsedTestDataConfig()
# Get Zone, Domain and templates
- self.domain = get_domain(self.apiclient, self.services)
- self.zone = get_zone(self.apiclient, self.services)
+ self.domain = get_domain(self.apiclient)
+ self.zone = get_zone(self.apiclient, self.testClient.getZoneForTests())
template = get_template(
self.apiclient,
self.zone.id,
self.services["ostype"]
)
- self.services["server"]["zoneid"] = self.zone.id
+ self.services["virtual_machine"]["zoneid"] = self.zone.id
#Create an account, network, VM, Port forwarding rule, LB rules
self.account = Account.create(
@@ -784,12 +726,12 @@ class TestReleaseIP(cloudstackTestCase):
self.service_offering = ServiceOffering.create(
self.apiclient,
- self.services["service_offering"]
+ self.services["service_offerings"]
)
self.virtual_machine = VirtualMachine.create(
self.apiclient,
- self.services["server"],
+ self.services["virtual_machine"],
templateid=template.id,
accountid=self.account.name,
domainid=self.account.domainid,
@@ -867,7 +809,7 @@ class TestReleaseIP(cloudstackTestCase):
id=self.nat_rule.id
)
self.debug("List NAT Rule response" + str(list_nat_rule))
- except cloudstackAPIException:
+ except CloudstackAPIException:
self.debug("Port Forwarding Rule is deleted")
# listLoadBalancerRules should not list
@@ -878,7 +820,7 @@ class TestReleaseIP(cloudstackTestCase):
id=self.lb_rule.id
)
self.debug("List LB Rule response" + str(list_lb_rule))
- except cloudstackAPIException:
+ except CloudstackAPIException:
self.debug("Port Forwarding Rule is deleted")
# SSH Attempt though public IP should fail
@@ -899,17 +841,17 @@ class TestDeleteAccount(cloudstackTestCase):
def setUp(self):
self.apiclient = self.testClient.getApiClient()
- self.services = Services().services
+ self.services = self.testClient.getParsedTestDataConfig()
# Get Zone, Domain and templates
- self.domain = get_domain(self.apiclient, self.services)
- self.zone = get_zone(self.apiclient, self.services)
+ self.domain = get_domain(self.apiclient)
+ self.zone = get_zone(self.apiclient, self.testClient.getZoneForTests())
template = get_template(
self.apiclient,
self.zone.id,
self.services["ostype"]
)
- self.services["server"]["zoneid"] = self.zone.id
+ self.services["virtual_machine"]["zoneid"] = self.zone.id
#Create an account, network, VM and IP addresses
self.account = Account.create(
@@ -920,11 +862,11 @@ class TestDeleteAccount(cloudstackTestCase):
)
self.service_offering = ServiceOffering.create(
self.apiclient,
- self.services["service_offering"]
+ self.services["service_offerings"]
)
self.vm_1 = VirtualMachine.create(
self.apiclient,
- self.services["server"],
+ self.services["virtual_machine"],
templateid=template.id,
accountid=self.account.name,
domainid=self.account.domainid,
@@ -993,7 +935,7 @@ class TestDeleteAccount(cloudstackTestCase):
account=self.account.name,
domainid=self.account.domainid
)
- except cloudstackAPIException:
+ except CloudstackAPIException:
self.debug("Port Forwarding Rule is deleted")
# ListPortForwardingRules should not
@@ -1004,7 +946,7 @@ class TestDeleteAccount(cloudstackTestCase):
account=self.account.name,
domainid=self.account.domainid
)
- except cloudstackAPIException:
+ except CloudstackAPIException:
self.debug("NATRule is deleted")
#Retrieve router for the user account
@@ -1019,7 +961,7 @@ class TestDeleteAccount(cloudstackTestCase):
None,
"Check routers are properly deleted."
)
- except cloudstackAPIException:
+ except CloudstackAPIException:
self.debug("Router is deleted")
except Exception as e:
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/smoke/test_network_acl.py
----------------------------------------------------------------------
diff --git a/test/integration/smoke/test_network_acl.py b/test/integration/smoke/test_network_acl.py
index 69134e5..68e5067 100644
--- a/test/integration/smoke/test_network_acl.py
+++ b/test/integration/smoke/test_network_acl.py
@@ -17,77 +17,27 @@
""" Tests for Network ACLs in VPC
"""
#Import Local Modules
+from marvin.codes import FAILED
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
from nose.plugins.attrib import attr
-class Services:
- def __init__(self):
- self.services = {
- "account": {
- "email": "test@test.com",
- "firstname": "Test",
- "lastname": "User",
- "username": "test",
- "password": "password",
- },
- "virtual_machine": {
- "displayname": "Test VM",
- "username": "root",
- "password": "password",
- "ssh_port": 22,
- "hypervisor": 'XenServer',
- "privateport": 22,
- "publicport": 22,
- "protocol": 'TCP',
- },
- "ostype": 'CentOS 5.3 (64-bit)',
- "service_offering": {
- "name": "Tiny Instance",
- "displaytext": "Tiny Instance",
- "cpunumber": 1,
- "cpuspeed": 100,
- "memory": 256,
- },
- "network_offering": {
- "name": "Network offering for internal lb service",
- "displaytext": "Network offering for internal lb service",
- "guestiptype": "Isolated",
- "traffictype": "Guest",
- "supportedservices": "Vpn,Dhcp,Dns,Lb,UserData,SourceNat,StaticNat,PortForwarding,NetworkACL",
- "serviceProviderList": {
- "Dhcp": "VpcVirtualRouter",
- "Dns": "VpcVirtualRouter",
- "Vpn": "VpcVirtualRouter",
- "UserData": "VpcVirtualRouter",
- "Lb": "InternalLbVM",
- "SourceNat": "VpcVirtualRouter",
- "StaticNat": "VpcVirtualRouter",
- "PortForwarding": "VpcVirtualRouter",
- "NetworkACL": "VpcVirtualRouter",
- },
- "serviceCapabilityList": {
- "SourceNat": {"SupportedSourceNatTypes": "peraccount"},
- "Lb": {"lbSchemes": "internal", "SupportedLbIsolation": "dedicated"}
- }
- }
- }
-
-
class TestNetworkACL(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.apiclient = super(TestNetworkACL, cls).getClsTestClient().getApiClient()
- cls.services = Services().services
- cls.zone = get_zone(cls.apiclient, cls.services)
+ testClient = super(TestNetworkACL, cls).getClsTestClient()
+ cls.apiclient = testClient.getApiClient()
+ cls.services = testClient.getParsedTestDataConfig()
+
+ cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests())
cls.domain = get_domain(cls.apiclient)
cls.service_offering = ServiceOffering.create(
cls.apiclient,
- cls.services["service_offering"]
+ cls.services["service_offerings"]
)
cls.account = Account.create(cls.apiclient, services=cls.services["account"])
cls.template = get_template(
@@ -95,6 +45,10 @@ class TestNetworkACL(cloudstackTestCase):
cls.zone.id,
cls.services["ostype"]
)
+
+ if cls.template == FAILED:
+ assert False, "get_template() failed to return template with description %s" % cls.services["ostype"]
+
cls.debug("Successfully created account: %s, id: \
%s" % (cls.account.name,\
cls.account.id))
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/smoke/test_nic.py
----------------------------------------------------------------------
diff --git a/test/integration/smoke/test_nic.py b/test/integration/smoke/test_nic.py
index 9b29403..e12bb33 100644
--- a/test/integration/smoke/test_nic.py
+++ b/test/integration/smoke/test_nic.py
@@ -16,119 +16,19 @@
# under the License.
""" NIC tests for VM """
import marvin
+from marvin.codes import FAILED
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
from marvin.sshClient import SshClient
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
from nose.plugins.attrib import attr
import signal
import sys
import time
-class Services:
- def __init__(self):
- self.services = {
- "disk_offering":{
- "displaytext": "Small",
- "name": "Small",
- "disksize": 1
- },
- "account": {
- "email": "test@test.com",
- "firstname": "Test",
- "lastname": "User",
- "username": "test",
- # Random characters are appended in create account to
- # ensure unique username generated each time
- "password": "password",
- },
- # Create a small virtual machine instance with disk offering
- "small": {
- "displayname": "testserver",
- "username": "root", # VM creds for SSH
- "password": "password",
- "ssh_port": 22,
- "hypervisor": 'XenServer',
- "privateport": 22,
- "publicport": 22,
- "protocol": 'TCP',
- },
- "service_offerings": {
- "tiny": {
- "name": "Tiny Instance",
- "displaytext": "Tiny Instance",
- "cpunumber": 1,
- "cpuspeed": 100, # in MHz
- "memory": 128, # In MBs
- },
- },
- "network_offering": {
- "name": 'Test Network offering',
- "displaytext": 'Test Network offering',
- "guestiptype": 'Isolated',
- "supportedservices": 'Dhcp,Dns,SourceNat,PortForwarding',
- "traffictype": 'GUEST',
- "availability": 'Optional',
- "serviceProviderList" : {
- "Dhcp": 'VirtualRouter',
- "Dns": 'VirtualRouter',
- "SourceNat": 'VirtualRouter',
- "PortForwarding": 'VirtualRouter',
- },
- },
- "network_offering_shared": {
- "name": 'Test Network offering shared',
- "displaytext": 'Test Network offering Shared',
- "guestiptype": 'Shared',
- "supportedservices": 'Dhcp,Dns,UserData',
- "traffictype": 'GUEST',
- "specifyVlan" : "True",
- "specifyIpRanges" : "True",
- "serviceProviderList" : {
- "Dhcp": 'VirtualRouter',
- "Dns": 'VirtualRouter',
- "UserData": 'VirtualRouter',
- },
- },
- "network": {
- "name": "Test Network",
- "displaytext": "Test Network",
- "acltype": "Account",
- },
- "network2": {
- "name": "Test Network Shared",
- "displaytext": "Test Network Shared",
- "vlan" :1201,
- "gateway" :"172.16.15.1",
- "netmask" :"255.255.255.0",
- "startip" :"172.16.15.21",
- "endip" :"172.16.15.41",
- "acltype": "Account",
- },
- # ISO settings for Attach/Detach ISO tests
- "iso": {
- "displaytext": "Test ISO",
- "name": "testISO",
- "url": "http://people.apache.org/~tsp/dummy.iso",
- # Source URL where ISO is located
- "ostype": 'CentOS 5.3 (64-bit)',
- "mode": 'HTTP_DOWNLOAD', # Downloading existing ISO
- },
- "template": {
- "displaytext": "Cent OS Template",
- "name": "Cent OS Template",
- "passwordenabled": True,
- },
- "sleep": 60,
- "timeout": 10,
- #Migrate VM to hostid
- "ostype": 'CentOS 5.3 (64-bit)',
- # CentOS 5.3 (64-bit)
- }
-
class TestNic(cloudstackTestCase):
def setUp(self):
@@ -143,11 +43,11 @@ class TestNic(cloudstackTestCase):
try:
self.apiclient = self.testClient.getApiClient()
self.dbclient = self.testClient.getDbConnection()
- self.services = Services().services
+ self.services = self.testClient.getParsedTestDataConfig()
# Get Zone, Domain and templates
- domain = get_domain(self.apiclient, self.services)
- zone = get_zone(self.apiclient, self.services)
+ domain = get_domain(self.apiclient)
+ zone = get_zone(self.apiclient, self.testClient.getZoneForTests())
self.services['mode'] = zone.networktype
#if local storage is enabled, alter the offerings to use localstorage
@@ -164,7 +64,7 @@ class TestNic(cloudstackTestCase):
self.services["small"]["zoneid"] = zone.id
self.services["small"]["template"] = template.id
- self.services["iso"]["zoneid"] = zone.id
+ self.services["iso1"]["zoneid"] = zone.id
self.services["network"]["zoneid"] = zone.id
# Create Account, VMs, NAT Rules etc
@@ -219,7 +119,7 @@ class TestNic(cloudstackTestCase):
except Exception as ex:
self.debug("Exception during NIC test SETUP!: " + str(ex))
- @attr(tags = ["devcloud", "advanced", "advancedns", "smoke", "basic", "sg", "provisioning"])
+ @attr(tags = ["devcloud", "smoke", "basic", "sg", "provisioning"])
def test_01_nic(self):
#TODO: SIMENH: add validation
"""Test to add and update added nic to a virtual machine"""
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/smoke/test_non_contigiousvlan.py
----------------------------------------------------------------------
diff --git a/test/integration/smoke/test_non_contigiousvlan.py b/test/integration/smoke/test_non_contigiousvlan.py
index d21391e..90235ec 100644
--- a/test/integration/smoke/test_non_contigiousvlan.py
+++ b/test/integration/smoke/test_non_contigiousvlan.py
@@ -18,8 +18,8 @@
from marvin import cloudstackTestCase
from marvin.cloudstackAPI import *
from marvin.cloudstackTestCase import cloudstackTestCase
-from marvin.integration.lib.base import Account
-from marvin.integration.lib.base import PhysicalNetwork
+from marvin.lib.base import Account
+from marvin.lib.base import PhysicalNetwork
from nose.plugins.attrib import attr
class Services():
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/smoke/test_over_provisioning.py
----------------------------------------------------------------------
diff --git a/test/integration/smoke/test_over_provisioning.py b/test/integration/smoke/test_over_provisioning.py
index 7d10fc7..1c5d8a5 100644
--- a/test/integration/smoke/test_over_provisioning.py
+++ b/test/integration/smoke/test_over_provisioning.py
@@ -19,9 +19,9 @@
#Import Local Modules
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
from nose.plugins.attrib import attr
#Import System modules
@@ -67,7 +67,11 @@ class TestUpdateOverProvision(cloudstackTestCase):
self.poolId = pool.id
""" list overprovisioning factor for storage pool """
- factorOld = float(pool.overprovisionfactor)
+ failed = 0
+ if pool.overprovisionfactor is None:
+ failed = 1
+ self.assertNotEqual(failed,1,"pool.overprovisionfactor is none")
+ factorOld = float(str(pool.overprovisionfactor))
factorNew = str(factorOld + 1.0)
""" update setting for the pool"""
@@ -85,7 +89,11 @@ class TestUpdateOverProvision(cloudstackTestCase):
id = self.poolId
)
pool = storage_pools[0]
- factorNew = float(pool.overprovisionfactor)
+ failed = 0
+ if pool.overprovisionfactor is None:
+ failed = 1
+ self.assertNotEqual(failed,1,"pool.overprovisionfactor is none")
+ factorNew = float(str(pool.overprovisionfactor))
self.assertNotEqual(int(factorNew), int(factorOld)," Check if overprovision factor of storage pool has changed")
self.assertEqual(int(factorNew), int(factorOld + 1.0)," Check if overprovision factor of storage pool has increased by 1")
@@ -100,8 +108,11 @@ class TestUpdateOverProvision(cloudstackTestCase):
pool = storage_pools[0]
updateConfigurationCmd = updateConfiguration.updateConfigurationCmd()
updateConfigurationCmd.name = "storage.overprovisioning.factor"
- factorOld = float(pool.overprovisionfactor)
+ factorOld = 0
+ if pool.overprovisionfactor is not None:
+ factorOld = float(str(pool.overprovisionfactor))
factorNew = str(factorOld - 1.0)
- updateConfigurationCmd.value = factorNew
- updateConfigurationCmd.storageid = pool.id
- updateConfigurationResponse = self.apiClient.updateConfiguration(updateConfigurationCmd)
+ if factorNew > 0:
+ updateConfigurationCmd.value = factorNew
+ updateConfigurationCmd.storageid = pool.id
+ updateConfigurationResponse = self.apiClient.updateConfiguration(updateConfigurationCmd)
[13/18] Marvin + test changes from master Signed-off-by:
SrikanteswaraRao Talluri
Posted by da...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/component/test_redundant_router_upgrades.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_redundant_router_upgrades.py b/test/integration/component/test_redundant_router_upgrades.py
index bd38c14..6c177ef 100644
--- a/test/integration/component/test_redundant_router_upgrades.py
+++ b/test/integration/component/test_redundant_router_upgrades.py
@@ -17,9 +17,9 @@
from nose.plugins.attrib import attr
-from marvin.integration.lib.base import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.common import *
+from marvin.lib.base import *
+from marvin.lib.utils import *
+from marvin.lib.common import *
#Import Local Modules
from marvin.cloudstackTestCase import cloudstackTestCase
@@ -137,14 +137,13 @@ class TestRvRUpgradeDowngrade(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(
- TestRvRUpgradeDowngrade,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestRvRUpgradeDowngrade, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.template = get_template(
cls.api_client,
cls.zone.id,
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/component/test_region_vpc.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_region_vpc.py b/test/integration/component/test_region_vpc.py
index 2cd9de9..e348065 100644
--- a/test/integration/component/test_region_vpc.py
+++ b/test/integration/component/test_region_vpc.py
@@ -23,9 +23,9 @@ import marvin
from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
from marvin.sshClient import SshClient
import datetime
@@ -159,24 +159,30 @@ class TestRegionVpcOffering(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(
- TestRegionVpcOffering,
- cls
- ).getClsTestClient().getApiClient()
- cls.services = Services().services
+ testClient = super(TestRegionVpcOffering, cls).getClsTestClient()
+ cls.apiclient = testClient.getApiClient()
+ cls.services = testClient.getParsedTestDataConfig()
+
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.apiclient)
+ cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests())
+ cls.services['mode'] = cls.zone.networktype
+
+
cls.template = get_template(
- cls.api_client,
- cls.zone.id,
- cls.services["ostype"]
- )
+ cls.apiclient,
+ cls.zone.id,
+ cls.services["ostype"]
+ )
+ if cls.template == FAILED:
+ assert False, "get_template() failed to return template with description %s" % cls.services["ostype"]
+
+
cls.services["virtual_machine"]["zoneid"] = cls.zone.id
cls.services["virtual_machine"]["template"] = cls.template.id
cls.service_offering = ServiceOffering.create(
- cls.api_client,
+ cls.apiclient,
cls.services["service_offering"]
)
cls._cleanup = [
@@ -188,7 +194,7 @@ class TestRegionVpcOffering(cloudstackTestCase):
def tearDownClass(cls):
try:
#Cleanup resources used
- cleanup_resources(cls.api_client, cls._cleanup)
+ cleanup_resources(cls.apiclient, cls._cleanup)
except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e)
return
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/component/test_regions.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_regions.py b/test/integration/component/test_regions.py
index 2a84943..40e65cf 100644
--- a/test/integration/component/test_regions.py
+++ b/test/integration/component/test_regions.py
@@ -17,9 +17,9 @@
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
from nose.plugins.attrib import attr
from random import choice
@@ -41,7 +41,7 @@ class TestRegions(cloudstackTestCase):
def setUpClass(cls):
cls.api_client = super(TestRegions, cls).getClsTestClient().getApiClient()
cls.services = Services().services
- cls.domain = get_domain(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
cls.cleanup = []
return
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/component/test_regions_accounts.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_regions_accounts.py b/test/integration/component/test_regions_accounts.py
index 51620e5..a554893 100644
--- a/test/integration/component/test_regions_accounts.py
+++ b/test/integration/component/test_regions_accounts.py
@@ -17,9 +17,9 @@
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
from nose.plugins.attrib import attr
class Services:
@@ -57,7 +57,7 @@ class TestRegionsAccounts(cloudstackTestCase):
def setUpClass(cls):
cls.api_client = super(TestRegionsAccounts, cls).getClsTestClient().getApiClient()
cls.services = Services().services
- cls.domain = get_domain(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
cls.cleanup = []
return
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/component/test_reset_ssh_keypair.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_reset_ssh_keypair.py b/test/integration/component/test_reset_ssh_keypair.py
index ded2529..307e8dc 100644
--- a/test/integration/component/test_reset_ssh_keypair.py
+++ b/test/integration/component/test_reset_ssh_keypair.py
@@ -19,18 +19,18 @@
"""
#Import Local Modules
-from marvin.integration.lib.base import (VirtualMachine,
+from marvin.lib.base import (VirtualMachine,
SSHKeyPair,
Account,
Template,
ServiceOffering,
EgressFireWallRule)
-from marvin.integration.lib.common import (get_domain,
+from marvin.lib.common import (get_domain,
get_zone,
get_template,
list_virtual_machines,
list_volumes)
-from marvin.integration.lib.utils import (cleanup_resources,
+from marvin.lib.utils import (cleanup_resources,
random_gen,
validateList)
from marvin.cloudstackTestCase import cloudstackTestCase, unittest
@@ -114,14 +114,13 @@ class TestResetSSHKeypair(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(
- TestResetSSHKeypair,
- cls).getClsTestClient().getApiClient()
+ cls.testClient = super(TestResetSSHKeypair, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
cls.services = Services().services
# Get Zone, Domain and templates
- domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.services['mode'] = cls.zone.networktype
# Set Zones and disk offerings
@@ -955,14 +954,13 @@ class TestResetSSHKeyUserRights(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(
- TestResetSSHKeyUserRights,
- cls).getClsTestClient().getApiClient()
+ cls.testClient = super(TestResetSSHKeyUserRights, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.services['mode'] = cls.zone.networktype
# Set Zones and disk offerings
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/component/test_resource_limits.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_resource_limits.py b/test/integration/component/test_resource_limits.py
index 9f99161..09d9658 100644
--- a/test/integration/component/test_resource_limits.py
+++ b/test/integration/component/test_resource_limits.py
@@ -19,7 +19,7 @@
#Import Local Modules
from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import cloudstackTestCase
-from marvin.integration.lib.base import (VirtualMachine,
+from marvin.lib.base import (VirtualMachine,
Snapshot,
Template,
PublicIPAddress,
@@ -31,14 +31,14 @@ from marvin.integration.lib.base import (VirtualMachine,
NetworkOffering,
ServiceOffering,
Configurations)
-from marvin.integration.lib.common import (list_volumes,
+from marvin.lib.common import (list_volumes,
get_domain,
get_zone,
get_template,
update_resource_limit,
list_configurations,
wait_for_cleanup)
-from marvin.integration.lib.utils import cleanup_resources
+from marvin.lib.utils import cleanup_resources
import time
@@ -127,11 +127,13 @@ class TestResourceLimitsAccount(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(TestResourceLimitsAccount, cls).getClsTestClient().getApiClient()
+ cls.testClient = super(TestResourceLimitsAccount, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.services['mode'] = cls.zone.networktype
cls.template = get_template(
@@ -897,10 +899,11 @@ class TestResourceLimitsDomain(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(TestResourceLimitsDomain, cls).getClsTestClient().getApiClient()
+ cls.testClient = super(TestResourceLimitsDomain, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
- # Get Zone, Domain and templates
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.services['mode'] = cls.zone.networktype
cls.template = get_template(
@@ -1354,14 +1357,12 @@ class TestMaxAccountNetworks(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(
- TestMaxAccountNetworks,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestMaxAccountNetworks, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
- # Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
+ cls.domain = get_domain(cls.api_client)
cls.services['mode'] = cls.zone.networktype
cls.template = get_template(
cls.api_client,
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/component/test_routers.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_routers.py b/test/integration/component/test_routers.py
index 29e2e9f..d729a07 100644
--- a/test/integration/component/test_routers.py
+++ b/test/integration/component/test_routers.py
@@ -21,9 +21,9 @@ import marvin
from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
#Import System modules
import time
@@ -98,11 +98,13 @@ class TestRouterServices(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(TestRouterServices, cls).getClsTestClient().getApiClient()
+ cls.testClient = super(TestRouterServices, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.services['mode'] = cls.zone.networktype
cls.template = get_template(
cls.api_client,
@@ -641,11 +643,13 @@ class TestRouterStopCreatePF(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(TestRouterStopCreatePF, cls).getClsTestClient().getApiClient()
+ cls.testClient = super(TestRouterStopCreatePF, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.services['mode'] = cls.zone.networktype
template = get_template(
cls.api_client,
@@ -853,11 +857,13 @@ class TestRouterStopCreateLB(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(TestRouterStopCreateLB, cls).getClsTestClient().getApiClient()
+ cls.testClient = super(TestRouterStopCreateLB, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.services['mode'] = cls.zone.networktype
template = get_template(
cls.api_client,
@@ -1065,11 +1071,13 @@ class TestRouterStopCreateFW(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(TestRouterStopCreateFW, cls).getClsTestClient().getApiClient()
+ cls.testClient = super(TestRouterStopCreateFW, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.services['mode'] = cls.zone.networktype
template = get_template(
cls.api_client,
@@ -1122,6 +1130,7 @@ class TestRouterStopCreateFW(cloudstackTestCase):
def setUp(self):
self.apiclient = self.testClient.getApiClient()
+ self.hypervisor = self.testClient.getHypervisorInfo()
self.cleanup = []
return
@@ -1255,8 +1264,8 @@ class TestRouterStopCreateFW(cloudstackTestCase):
"Check end port of firewall rule"
)
# For DNS and DHCP check 'dnsmasq' process status
- if (self.apiclient.hypervisor.lower() == 'vmware'
- or self.apiclient.hypervisor.lower() == 'hyperv'):
+ if (self.hypervisor.lower() == 'vmware'
+ or self.hypervisor.lower() == 'hyperv'):
result = get_process_status(
self.apiclient.connection.mgtSvr,
22,
@@ -1264,7 +1273,7 @@ class TestRouterStopCreateFW(cloudstackTestCase):
self.apiclient.connection.passwd,
router.linklocalip,
'iptables -t nat -L',
- hypervisor=self.apiclient.hypervisor
+ hypervisor=self.hypervisor
)
else:
hosts = list_hosts(
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/component/test_security_groups.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_security_groups.py b/test/integration/component/test_security_groups.py
index 8e07396..f5c4727 100644
--- a/test/integration/component/test_security_groups.py
+++ b/test/integration/component/test_security_groups.py
@@ -22,9 +22,9 @@ import marvin
from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
from marvin.sshClient import SshClient
#Import System modules
@@ -117,12 +117,13 @@ class TestDefaultSecurityGroup(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.services = Services().services
- cls.api_client = super(TestDefaultSecurityGroup, cls).getClsTestClient().getApiClient()
+ cls.testClient = super(TestDefaultSecurityGroup, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+ cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.services['mode'] = cls.zone.networktype
template = get_template(
@@ -390,12 +391,13 @@ class TestAuthorizeIngressRule(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.services = Services().services
- cls.api_client = super(TestAuthorizeIngressRule, cls).getClsTestClient().getApiClient()
+ cls.testClient = super(TestAuthorizeIngressRule, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+ cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.services['mode'] = cls.zone.networktype
template = get_template(
@@ -526,12 +528,13 @@ class TestRevokeIngressRule(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.services = Services().services
- cls.api_client = super(TestRevokeIngressRule, cls).getClsTestClient().getApiClient()
+ cls.testClient = super(TestRevokeIngressRule, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+ cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.services['mode'] = cls.zone.networktype
template = get_template(
@@ -684,12 +687,13 @@ class TestDhcpOnlyRouter(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.services = Services().services
- cls.api_client = super(TestDhcpOnlyRouter, cls).getClsTestClient().getApiClient()
+ cls.testClient = super(TestDhcpOnlyRouter, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+ cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.services['mode'] = cls.zone.networktype
template = get_template(
@@ -821,12 +825,13 @@ class TestdeployVMWithUserData(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.services = Services().services
- cls.api_client = super(TestdeployVMWithUserData, cls).getClsTestClient().getApiClient()
+ cls.testClient = super(TestdeployVMWithUserData, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+ cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.services['mode'] = cls.zone.networktype
template = get_template(
@@ -985,8 +990,8 @@ class TestDeleteSecurityGroup(cloudstackTestCase):
self.services = Services().services
# Get Zone, Domain and templates
- self.domain = get_domain(self.apiclient, self.services)
- self.zone = get_zone(self.apiclient, self.services)
+ self.domain = get_domain(self.apiclient)
+ self.zone = get_zone(self.apiclient, self.testClient.getZoneForTests())
self.services['mode'] = self.zone.networktype
template = get_template(
@@ -1232,8 +1237,8 @@ class TestIngressRule(cloudstackTestCase):
self.services = Services().services
# Get Zone, Domain and templates
- self.domain = get_domain(self.apiclient, self.services)
- self.zone = get_zone(self.apiclient, self.services)
+ self.domain = get_domain(self.apiclient)
+ self.zone = get_zone(self.apiclient, self.testClient.getZoneForTests())
self.services['mode'] = self.zone.networktype
template = get_template(
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/component/test_shared_networks.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_shared_networks.py b/test/integration/component/test_shared_networks.py
index 9d96fd6..f99bfbf 100644
--- a/test/integration/component/test_shared_networks.py
+++ b/test/integration/component/test_shared_networks.py
@@ -20,7 +20,7 @@
#Import Local Modules
from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import cloudstackTestCase, unittest
-from marvin.integration.lib.base import (Account,
+from marvin.lib.base import (Account,
Network,
NetworkOffering,
VirtualMachine,
@@ -31,9 +31,9 @@ from marvin.integration.lib.base import (Account,
FireWallRule,
ServiceOffering,
PublicIPAddress)
-from marvin.integration.lib.utils import (cleanup_resources,
+from marvin.lib.utils import (cleanup_resources,
xsplit)
-from marvin.integration.lib.common import (get_domain,
+from marvin.lib.common import (get_domain,
get_zone,
get_template,
wait_for_cleanup,
@@ -154,16 +154,13 @@ class TestSharedNetworks(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(
- TestSharedNetworks,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestSharedNetworks, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
cls.services = Services().services
-
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.template = get_template(
cls.api_client,
cls.zone.id,
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/component/test_snapshot_gc.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_snapshot_gc.py b/test/integration/component/test_snapshot_gc.py
index 6858670..42c361c 100644
--- a/test/integration/component/test_snapshot_gc.py
+++ b/test/integration/component/test_snapshot_gc.py
@@ -18,10 +18,10 @@
from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
-from marvin.integration.lib.utils import is_snapshot_on_nfs
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
+from marvin.lib.utils import is_snapshot_on_nfs
class Services:
@@ -122,11 +122,13 @@ class TestAccountSnapshotClean(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(TestAccountSnapshotClean, cls).getClsTestClient().getApiClient()
+ cls.testClient = super(TestAccountSnapshotClean, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.services['mode'] = cls.zone.networktype
template = get_template(
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/component/test_snapshot_limits.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_snapshot_limits.py b/test/integration/component/test_snapshot_limits.py
index e204f4c..95c6432 100644
--- a/test/integration/component/test_snapshot_limits.py
+++ b/test/integration/component/test_snapshot_limits.py
@@ -18,10 +18,10 @@
from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
-from marvin.integration.lib.utils import is_snapshot_on_nfs
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
+from marvin.lib.utils import is_snapshot_on_nfs
import os
@@ -123,11 +123,13 @@ class TestSnapshotLimit(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(TestSnapshotLimit, cls).getClsTestClient().getApiClient()
+ cls.testClient = super(TestSnapshotLimit, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.services['mode'] = cls.zone.networktype
cls._cleanup = []
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/component/test_snapshots.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_snapshots.py b/test/integration/component/test_snapshots.py
index 034af9c..f874bd3 100644
--- a/test/integration/component/test_snapshots.py
+++ b/test/integration/component/test_snapshots.py
@@ -20,7 +20,7 @@
from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import cloudstackTestCase, unittest
-from marvin.integration.lib.base import (Snapshot,
+from marvin.lib.base import (Snapshot,
Template,
VirtualMachine,
Account,
@@ -28,7 +28,7 @@ from marvin.integration.lib.base import (Snapshot,
DiskOffering,
Volume)
-from marvin.integration.lib.common import (get_domain,
+from marvin.lib.common import (get_domain,
get_zone,
get_template,
list_events,
@@ -38,7 +38,7 @@ from marvin.integration.lib.common import (get_domain,
list_virtual_machines,
)
-from marvin.integration.lib.utils import (cleanup_resources,
+from marvin.lib.utils import (cleanup_resources,
format_volume_to_ext3,
random_gen,
is_snapshot_on_nfs,
@@ -158,11 +158,13 @@ class TestSnapshots(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(TestSnapshots, cls).getClsTestClient().getApiClient()
+ cls.testClient = super(TestSnapshots, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.services['mode'] = cls.zone.networktype
cls.disk_offering = DiskOffering.create(
cls.api_client,
@@ -229,6 +231,7 @@ class TestSnapshots(cloudstackTestCase):
def setUp(self):
self.apiclient = self.testClient.getApiClient()
+ self.hypervisor = self.testClient.getHypervisorInfo()
self.dbclient = self.testClient.getDbConnection()
self.cleanup = []
return
@@ -910,11 +913,13 @@ class TestCreateVMSnapshotTemplate(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(TestCreateVMSnapshotTemplate, cls).getClsTestClient().getApiClient()
+ cls.testClient = super(TestCreateVMSnapshotTemplate, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.services['mode'] = cls.zone.networktype
cls.template = get_template(
@@ -956,6 +961,7 @@ class TestCreateVMSnapshotTemplate(cloudstackTestCase):
def setUp(self):
self.apiclient = self.testClient.getApiClient()
+ self.hypervisor = self.testClient.getHypervisorInfo()
self.dbclient = self.testClient.getDbConnection()
self.cleanup = []
return
@@ -1108,11 +1114,14 @@ class TestSnapshotEvents(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(TestSnapshotEvents, cls).getClsTestClient().getApiClient()
+ cls.testClient = super(TestSnapshotEvents, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.services['mode'] = cls.zone.networktype
template = get_template(
@@ -1163,6 +1172,7 @@ class TestSnapshotEvents(cloudstackTestCase):
def setUp(self):
self.apiclient = self.testClient.getApiClient()
+ self.hypervisor = self.testClient.getHypervisorInfo()
self.dbclient = self.testClient.getDbConnection()
self.cleanup = []
return
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/component/test_snapshots_improvement.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_snapshots_improvement.py b/test/integration/component/test_snapshots_improvement.py
index 52979c4..b2b0a54 100644
--- a/test/integration/component/test_snapshots_improvement.py
+++ b/test/integration/component/test_snapshots_improvement.py
@@ -20,10 +20,10 @@
# Import Local Modules
from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import cloudstackTestCase, unittest
-from marvin.integration.lib.utils import (random_gen,
+from marvin.lib.utils import (random_gen,
is_snapshot_on_nfs,
cleanup_resources)
-from marvin.integration.lib.base import (
+from marvin.lib.base import (
Account,
ServiceOffering,
VirtualMachine,
@@ -32,7 +32,7 @@ from marvin.integration.lib.base import (
Volume,
DiskOffering
)
-from marvin.integration.lib.common import (get_domain,
+from marvin.lib.common import (get_domain,
get_zone,
get_template,
list_snapshots
@@ -126,11 +126,13 @@ class TestSnapshotOnRootVolume(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(TestSnapshotOnRootVolume,
- cls).getClsTestClient().getApiClient()
+ cls.testClient = super(TestSnapshotOnRootVolume, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ # Get Zone, Domain and templates
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.template = get_template(
cls.api_client,
cls.zone.id,
@@ -299,13 +301,13 @@ class TestCreateSnapshot(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(
- TestCreateSnapshot,
- cls).getClsTestClient().getApiClient()
+ cls.testClient = super(TestCreateSnapshot, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.template = get_template(
cls.api_client,
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/component/test_stopped_vm.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_stopped_vm.py b/test/integration/component/test_stopped_vm.py
index 53ad7e2..6c77679 100644
--- a/test/integration/component/test_stopped_vm.py
+++ b/test/integration/component/test_stopped_vm.py
@@ -22,9 +22,9 @@ import marvin
from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
#Import System modules
import time
@@ -108,14 +108,13 @@ class TestDeployVM(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(
- TestDeployVM,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestDeployVM, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.template = get_template(
cls.api_client,
@@ -962,14 +961,13 @@ class TestDeployHaEnabledVM(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(
- TestDeployHaEnabledVM,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestDeployHaEnabledVM, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.template = get_template(
cls.api_client,
@@ -1194,14 +1192,13 @@ class TestRouterStateAfterDeploy(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(
- TestRouterStateAfterDeploy,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestRouterStateAfterDeploy, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.template = get_template(
cls.api_client,
@@ -1409,14 +1406,13 @@ class TestDeployVMBasicZone(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(
- TestDeployVMBasicZone,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestDeployVMBasicZone, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.template = get_template(
cls.api_client,
@@ -1477,14 +1473,13 @@ class TestDeployVMFromTemplate(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(
- TestDeployVMFromTemplate,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestDeployVMFromTemplate, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
# Create service, disk offerings etc
cls.service_offering = ServiceOffering.create(
@@ -1511,8 +1506,8 @@ class TestDeployVMFromTemplate(cloudstackTestCase):
raise Exception("Warning: Exception during cleanup : %s" % e)
def setUp(self):
-
self.apiclient = self.testClient.getApiClient()
+ self.hypervisor = self.testClient.getHypervisorInfo()
self.dbclient = self.testClient.getDbConnection()
self.services = Services().services
self.services["virtual_machine"]["zoneid"] = self.zone.id
@@ -1533,7 +1528,8 @@ class TestDeployVMFromTemplate(cloudstackTestCase):
self.services["template"],
zoneid=self.zone.id,
account=self.account.name,
- domainid=self.account.domainid
+ domainid=self.account.domainid,
+ hypervisor=self.hypervisor
)
self.debug(
"Registered a template of format: %s with ID: %s" % (
@@ -1638,14 +1634,13 @@ class TestVMAccountLimit(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(
- TestVMAccountLimit,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestVMAccountLimit, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.template = get_template(
cls.api_client,
@@ -1754,14 +1749,13 @@ class TestUploadAttachVolume(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(
- TestUploadAttachVolume,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestUploadAttachVolume, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.template = get_template(
cls.api_client,
@@ -1864,14 +1858,13 @@ class TestDeployOnSpecificHost(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(
- TestDeployOnSpecificHost,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestDeployOnSpecificHost, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.template = get_template(
cls.api_client,
cls.zone.id,
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/component/test_storage_motion.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_storage_motion.py b/test/integration/component/test_storage_motion.py
index e1fd40f..5b9086b 100644
--- a/test/integration/component/test_storage_motion.py
+++ b/test/integration/component/test_storage_motion.py
@@ -20,9 +20,9 @@
import marvin
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
from nose.plugins.attrib import attr
#Import System modules
import time
@@ -89,12 +89,13 @@ class TestStorageMotion(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(TestStorageMotion, cls).getClsTestClient().getApiClient()
- cls.services = Services().services
+ cls.testClient = super(TestStorageMotion, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+ cls.services = Services().services
# Get Zone, Domain and templates
- domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.services['mode'] = cls.zone.networktype
template = get_template(
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/component/test_tags.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_tags.py b/test/integration/component/test_tags.py
index 1e8667d..d6b43d9 100644
--- a/test/integration/component/test_tags.py
+++ b/test/integration/component/test_tags.py
@@ -21,9 +21,9 @@ import marvin
from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
import datetime
@@ -174,30 +174,28 @@ class TestResourceTags(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(
- TestResourceTags,
- cls
- ).getClsTestClient().getApiClient()
- cls.services = Services().services
- # Get Zone
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.testClient = super(TestResourceTags, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
- # Create domains, account etc.
- cls.domain = get_domain(cls.api_client, cls.services)
+ cls.services = Services().services
- cls.account = Account.create(
- cls.api_client,
- cls.services["account"],
- admin=True,
- )
- cls.zone = get_zone(cls.api_client, cls.services)
+ # Get Zone, Domain and templates
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
+ cls.domain = get_domain(cls.api_client)
cls.template = get_template(
cls.api_client,
cls.zone.id,
cls.services["ostype"]
)
+ if cls.template == FAILED:
+ assert False, "get_template() failed to return template with description %s" % cls.services["ostype"]
+ cls.account = Account.create(
+ cls.api_client,
+ cls.services["account"],
+ admin=True,
+ )
# Create service offerings, disk offerings etc
cls.service_offering = ServiceOffering.create(
cls.api_client,
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/component/test_templates.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_templates.py b/test/integration/component/test_templates.py
index 1e612c2..98b1cbc 100644
--- a/test/integration/component/test_templates.py
+++ b/test/integration/component/test_templates.py
@@ -21,9 +21,9 @@ import marvin
from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
import urllib
from random import random
#Import System modules
@@ -101,8 +101,8 @@ class Services:
class TestCreateTemplate(cloudstackTestCase):
def setUp(self):
-
self.apiclient = self.testClient.getApiClient()
+ self.hypervisor = self.testClient.getHypervisorInfo()
self.dbclient = self.testClient.getDbConnection()
self.cleanup = []
return
@@ -118,12 +118,13 @@ class TestCreateTemplate(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.services = Services().services
- cls.api_client = super(TestCreateTemplate, cls).getClsTestClient().getApiClient()
+ cls.testClient = super(TestCreateTemplate, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+ cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.services['mode'] = cls.zone.networktype
cls.services["virtual_machine"]["zoneid"] = cls.zone.id
@@ -184,7 +185,8 @@ class TestCreateTemplate(cloudstackTestCase):
self.services["templates"][0],
zoneid=self.zone.id,
account=self.account.name,
- domainid=self.account.domainid
+ domainid=self.account.domainid,
+ hypervisor=self.hypervisor
)
self.debug(
"Registered a template of format: %s with ID: %s" % (
@@ -276,12 +278,13 @@ class TestTemplates(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.services = Services().services
- cls.api_client = super(TestTemplates, cls).getClsTestClient().getApiClient()
+ cls.testClient = super(TestTemplates, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
- # Get Zone, templates etc
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.services = Services().services
+ # Get Zone, Domain and templates
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.services['mode'] = cls.zone.networktype
#populate second zone id for iso copy
cmd = listZones.listZonesCmd()
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/component/test_update_vm.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_update_vm.py b/test/integration/component/test_update_vm.py
index 6d84708..1c5c236 100644
--- a/test/integration/component/test_update_vm.py
+++ b/test/integration/component/test_update_vm.py
@@ -17,9 +17,9 @@
from marvin.cloudstackTestCase import cloudstackTestCase
-from marvin.integration.lib.base import Account, VirtualMachine, ServiceOffering
-from marvin.integration.lib.utils import cleanup_resources
-from marvin.integration.lib.common import get_zone, get_domain, get_template
+from marvin.lib.base import Account, VirtualMachine, ServiceOffering
+from marvin.lib.utils import cleanup_resources
+from marvin.lib.common import get_zone, get_domain, get_template
from nose.plugins.attrib import attr
class TestData(object):
@@ -61,8 +61,8 @@ class TestUpdateVirtualMachine(cloudstackTestCase):
self.apiclient = self.testClient.getApiClient()
# Get Zone, Domain and Default Built-in template
- self.domain = get_domain(self.apiclient, self.testdata)
- self.zone = get_zone(self.apiclient, self.testdata)
+ self.domain = get_domain(self.apiclient)
+ self.zone = get_zone(self.apiclient, self.testClient.getZoneForTests())
self.testdata["mode"] = self.zone.networktype
self.template = get_template(self.apiclient, self.zone.id, self.testdata["ostype"])
@@ -156,4 +156,4 @@ class TestUpdateVirtualMachine(cloudstackTestCase):
try:
cleanup_resources(self.apiclient, self.cleanup)
except Exception as e:
- self.debug("Warning! Exception in tearDown: %s" % e)
\ No newline at end of file
+ self.debug("Warning! Exception in tearDown: %s" % e)
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/component/test_usage.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_usage.py b/test/integration/component/test_usage.py
index d18d2ea..eb92011 100644
--- a/test/integration/component/test_usage.py
+++ b/test/integration/component/test_usage.py
@@ -21,9 +21,9 @@ import marvin
from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
from marvin.sshClient import SshClient
import datetime
@@ -112,11 +112,13 @@ class TestVmUsage(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(TestVmUsage, cls).getClsTestClient().getApiClient()
+ cls.testClient = super(TestVmUsage, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.services['mode'] = cls.zone.networktype
template = get_template(
@@ -296,11 +298,13 @@ class TestPublicIPUsage(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(TestPublicIPUsage, cls).getClsTestClient().getApiClient()
+ cls.testClient = super(TestPublicIPUsage, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.services['mode'] = cls.zone.networktype
template = get_template(
@@ -448,11 +452,13 @@ class TestVolumeUsage(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(TestVolumeUsage, cls).getClsTestClient().getApiClient()
+ cls.testClient = super(TestVolumeUsage, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.services['mode'] = cls.zone.networktype
cls.disk_offering = DiskOffering.create(
cls.api_client,
@@ -622,11 +628,13 @@ class TestTemplateUsage(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(TestTemplateUsage, cls).getClsTestClient().getApiClient()
+ cls.testClient = super(TestTemplateUsage, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.services['mode'] = cls.zone.networktype
cls.services["server"]["zoneid"] = cls.zone.id
template = get_template(
@@ -787,11 +795,13 @@ class TestISOUsage(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(TestISOUsage, cls).getClsTestClient().getApiClient()
+ cls.testClient = super(TestISOUsage, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.services['mode'] = cls.zone.networktype
cls.services["server"]["zoneid"] = cls.zone.id
cls.services["iso"]["zoneid"] = cls.zone.id
@@ -924,11 +934,13 @@ class TestLBRuleUsage(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(TestLBRuleUsage, cls).getClsTestClient().getApiClient()
+ cls.testClient = super(TestLBRuleUsage, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.services['mode'] = cls.zone.networktype
template = get_template(
cls.api_client,
@@ -1086,11 +1098,13 @@ class TestSnapshotUsage(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(TestSnapshotUsage, cls).getClsTestClient().getApiClient()
+ cls.testClient = super(TestSnapshotUsage, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.services['mode'] = cls.zone.networktype
template = get_template(
@@ -1253,11 +1267,13 @@ class TestNatRuleUsage(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(TestNatRuleUsage, cls).getClsTestClient().getApiClient()
+ cls.testClient = super(TestNatRuleUsage, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.services['mode'] = cls.zone.networktype
template = get_template(
cls.api_client,
@@ -1415,11 +1431,13 @@ class TestVpnUsage(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(TestVpnUsage, cls).getClsTestClient().getApiClient()
+ cls.testClient = super(TestVpnUsage, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.services['mode'] = cls.zone.networktype
template = get_template(
cls.api_client,
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/component/test_vm_passwdenabled.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_vm_passwdenabled.py b/test/integration/component/test_vm_passwdenabled.py
index 5cfa525..2f68257 100644
--- a/test/integration/component/test_vm_passwdenabled.py
+++ b/test/integration/component/test_vm_passwdenabled.py
@@ -18,9 +18,9 @@ import marvin
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
from marvin.sshClient import SshClient
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
from nose.plugins.attrib import attr
@@ -92,15 +92,13 @@ class TestVMPasswordEnabled(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(
- TestVMPasswordEnabled,
- cls
- ).getClsTestClient().getApiClient()
- cls.services = Services().services
+ cls.testClient = super(TestVMPasswordEnabled, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+ cls.services = Services().services
# Get Zone, Domain and templates
- domain = get_domain(cls.api_client, cls.services)
- zone = get_zone(cls.api_client, cls.services)
+ domain = get_domain(cls.api_client)
+ zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.services['mode'] = zone.networktype
template = get_template(
cls.api_client,
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/component/test_vmware_drs.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_vmware_drs.py b/test/integration/component/test_vmware_drs.py
index 9a07d91..7d3ab7f 100644
--- a/test/integration/component/test_vmware_drs.py
+++ b/test/integration/component/test_vmware_drs.py
@@ -23,19 +23,19 @@ from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import cloudstackTestCase, unittest
-from marvin.integration.lib.base import (Account,
+from marvin.lib.base import (Account,
AffinityGroup,
Host,
VirtualMachine,
ServiceOffering)
-from marvin.integration.lib.common import (get_zone,
+from marvin.lib.common import (get_zone,
get_template,
get_domain,
get_pod
)
-from marvin.integration.lib.utils import (validateList,
+from marvin.lib.utils import (validateList,
cleanup_resources,
random_gen)
@@ -111,25 +111,16 @@ class TestVMPlacement(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(
- TestVMPlacement,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestVMPlacement, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(
- cls.api_client,
- cls.services
- )
- cls.zone = get_zone(
- cls.api_client,
- cls.services
- )
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.pod = get_pod(
cls.api_client,
- zoneid=cls.zone.id,
- services=cls.services
- )
+ zone_id=cls.zone.id)
cls.template = get_template(
cls.api_client,
cls.zone.id,
@@ -280,20 +271,13 @@ class TestAntiAffinityRules(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(
- TestAntiAffinityRules,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestAntiAffinityRules, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(
- cls.api_client,
- cls.services
- )
- cls.zone = get_zone(
- cls.api_client,
- cls.services
- )
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.template = get_template(
cls.api_client,
cls.zone.id,
@@ -515,20 +499,13 @@ class TestAffinityRules(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(
- TestAffinityRules,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestAffinityRules, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(
- cls.api_client,
- cls.services
- )
- cls.zone = get_zone(
- cls.api_client,
- cls.services
- )
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.template = get_template(
cls.api_client,
cls.zone.id,
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/component/test_volumes.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_volumes.py b/test/integration/component/test_volumes.py
index bcf552a..a310472 100644
--- a/test/integration/component/test_volumes.py
+++ b/test/integration/component/test_volumes.py
@@ -20,9 +20,9 @@
from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
#Import System modules
import time
@@ -88,13 +88,14 @@ class TestAttachVolume(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(TestAttachVolume, cls).getClsTestClient().getApiClient()
- cls.services = Services().services
+ cls.testClient = super(TestAttachVolume, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+ cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
- cls.pod = get_pod(cls.api_client, cls.zone.id, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
+ cls.pod = get_pod(cls.api_client, cls.zone.id)
cls.services['mode'] = cls.zone.networktype
cls.disk_offering = DiskOffering.create(
cls.api_client,
@@ -378,13 +379,14 @@ class TestAttachDetachVolume(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(TestAttachDetachVolume, cls).getClsTestClient().getApiClient()
- cls.services = Services().services
+ cls.testClient = super(TestAttachDetachVolume, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+ cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
- cls.pod = get_pod(cls.api_client, cls.zone.id, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
+ cls.pod = get_pod(cls.api_client, cls.zone.id)
cls.services['mode'] = cls.zone.networktype
cls.disk_offering = DiskOffering.create(
cls.api_client,
@@ -641,13 +643,14 @@ class TestAttachVolumeISO(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(TestAttachVolumeISO, cls).getClsTestClient().getApiClient()
- cls.services = Services().services
+ cls.testClient = super(TestAttachVolumeISO, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+ cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
- cls.pod = get_pod(cls.api_client, cls.zone.id, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
+ cls.pod = get_pod(cls.api_client, cls.zone.id)
cls.services['mode'] = cls.zone.networktype
cls.disk_offering = DiskOffering.create(
cls.api_client,
@@ -852,11 +855,13 @@ class TestVolumes(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(TestVolumes, cls).getClsTestClient().getApiClient()
+ cls.testClient = super(TestVolumes, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.services['mode'] = cls.zone.networktype
cls.disk_offering = DiskOffering.create(
cls.api_client,
@@ -1105,7 +1110,7 @@ class TestVolumes(cloudstackTestCase):
)
self.assertTrue(domuser is not None)
- domapiclient = self.testClient.getUserApiClient(account=domuser.name, domain=dom.name)
+ domapiclient = self.testClient.getUserApiClient(UserName=domuser.name, DomainName=dom.name)
diskoffering = DiskOffering.list(self.apiclient)
self.assertTrue(isinstance(diskoffering, list), msg="DiskOffering list is not a list?")
@@ -1133,15 +1138,12 @@ class TestDeployVmWithCustomDisk(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(
- TestDeployVmWithCustomDisk,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestDeployVmWithCustomDisk, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
cls.services = Services().services
-
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.services['mode'] = cls.zone.networktype
cls.disk_offering = DiskOffering.create(
cls.api_client,
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/component/test_vpc.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_vpc.py b/test/integration/component/test_vpc.py
index 5c55cb6..e9d396e8 100644
--- a/test/integration/component/test_vpc.py
+++ b/test/integration/component/test_vpc.py
@@ -20,11 +20,11 @@
#Import Local Modules
from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import *
-from marvin.cloudstackException import cloudstackAPIException
+from marvin.cloudstackException import CloudstackAPIException
from marvin.cloudstackAPI import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
class Services:
@@ -175,14 +175,13 @@ class TestVPC(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(
- TestVPC,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestVPC, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.template = get_template(
cls.api_client,
cls.zone.id,
@@ -1934,10 +1933,10 @@ class TestVPC(cloudstackTestCase):
self.debug("creating a VPC network in the account: %s" %
user.name)
- userapiclient = self.testClient.createUserApiClient(
+ userapiclient = self.testClient.getUserApiClient(
UserName=user.name,
DomainName=user.domain,
- acctType=0)
+ type=0)
vpc = VPC.create(
@@ -2017,8 +2016,8 @@ class TestVPC(cloudstackTestCase):
#0 - User, 1 - Root Admin, 2 - Domain Admin
userapiclient = self.testClient.getUserApiClient(
- account=user.name,
- domain=self.services["domain"]["name"],
+ UserName=user.name,
+ DomainName=self.services["domain"]["name"],
type=2)
vpc = VPC.create(
@@ -2092,8 +2091,8 @@ class TestVPC(cloudstackTestCase):
user.name)
userapiclient = self.testClient.getUserApiClient(
- account=user.name,
- domain=user.domain,
+ UserName=user.name,
+ DomainName=user.domain,
type=0)
vpc = VPC.create(
@@ -2171,8 +2170,8 @@ class TestVPC(cloudstackTestCase):
self.debug("Created account: %s" % domain_admin.name)
self.cleanup.append(domain_admin)
da_apiclient = self.testClient.getUserApiClient(
- account=domain_admin.name,
- domain=domain_admin.domain,
+ UserName=domain_admin.name,
+ DomainName=domain_admin.domain,
type=2)
user = Account.create(
@@ -2188,11 +2187,11 @@ class TestVPC(cloudstackTestCase):
#0 - User, 1 - Root Admin, 2 - Domain Admin
userapiclient = self.testClient.getUserApiClient(
- account=user.name,
- domain=user.domain,
+ UserName=user.name,
+ DomainName=user.domain,
type=0)
- with self.assertRaises(cloudstackAPIException):
+ with self.assertRaises(CloudstackAPIException):
vpc = VPC.create(
da_apiclient,
self.services["vpc"],
@@ -2222,8 +2221,8 @@ class TestVPC(cloudstackTestCase):
self.debug("Created account: %s" % domain_admin.name)
self.cleanup.append(domain_admin)
da_apiclient = self.testClient.getUserApiClient(
- account=domain_admin.name,
- domain=self.services["domain"]["name"],
+ UserName=domain_admin.name,
+ DomainName=self.services["domain"]["name"],
type=2)
user = Account.create(
@@ -2239,8 +2238,8 @@ class TestVPC(cloudstackTestCase):
#0 - User, 1 - Root Admin, 2 - Domain Admin
userapiclient = self.testClient.getUserApiClient(
- account=user.name,
- domain=user.domain,
+ UserName=user.name,
+ DomainName=user.domain,
type=0)
vpc = VPC.create(
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/component/test_vpc_distributed_routing_offering.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_vpc_distributed_routing_offering.py b/test/integration/component/test_vpc_distributed_routing_offering.py
index 0fa7de7..cc9a191 100644
--- a/test/integration/component/test_vpc_distributed_routing_offering.py
+++ b/test/integration/component/test_vpc_distributed_routing_offering.py
@@ -23,9 +23,9 @@ import marvin
from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
from marvin.sshClient import SshClient
import datetime
@@ -154,24 +154,27 @@ class TestVPCDistributedRouterOffering(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(
- TestVPCDistributedRouterOffering,
- cls
- ).getClsTestClient().getApiClient()
- cls.services = Services().services
+ testClient = super(TestVPCDistributedRouterOffering, cls).getClsTestClient()
+ cls.apiclient = testClient.getApiClient()
+ cls.services = testClient.getParsedTestDataConfig()
+
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.apiclient)
+ cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests())
+ cls.services['mode'] = cls.zone.networktype
+
cls.template = get_template(
- cls.api_client,
- cls.zone.id,
- cls.services["ostype"]
- )
+ cls.apiclient,
+ cls.zone.id,
+ cls.services["ostype"]
+ )
+ if cls.template == FAILED:
+ assert False, "get_template() failed to return template with description %s" % cls.services["ostype"]
cls.services["virtual_machine"]["zoneid"] = cls.zone.id
cls.services["virtual_machine"]["template"] = cls.template.id
cls.service_offering = ServiceOffering.create(
- cls.api_client,
+ cls.apiclient,
cls.services["service_offering"]
)
cls._cleanup = [
@@ -183,7 +186,7 @@ class TestVPCDistributedRouterOffering(cloudstackTestCase):
def tearDownClass(cls):
try:
#Cleanup resources used
- cleanup_resources(cls.api_client, cls._cleanup)
+ cleanup_resources(cls.apiclient, cls._cleanup)
except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e)
return
[07/18] Marvin + test changes from master Signed-off-by:
SrikanteswaraRao Talluri
Posted by da...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/tools/marvin/marvin/config/test_data.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/config/test_data.py b/tools/marvin/marvin/config/test_data.py
new file mode 100644
index 0000000..1a29ed9
--- /dev/null
+++ b/tools/marvin/marvin/config/test_data.py
@@ -0,0 +1,629 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+test_data = {
+ "region": {
+ "regionid": "2",
+ "regionname": "Region2",
+ "regionendpoint": "http://region2:8080/client"
+ },
+ "zone": "NA",
+ "hypervisor": "XenServer",
+ "deleteDC": True,
+ "vdomain": {
+ "name": "domain"
+ },
+ "email": "test@test.com",
+ "gateway": "172.1.1.1",
+ "netmask": "255.255.255.0",
+ "startip": "172.1.1.10",
+ "endip": "172.1.1.20",
+ "regionid": "1",
+ "vlan": "10",
+ "isportable": "true",
+
+ "project": {
+ "name": "Project",
+ "displaytext": "Test project"
+ },
+ "account": {
+ "email": "test-account@test.com",
+ "firstname": "test",
+ "lastname": "test",
+ "username": "test-account",
+ "password": "password"
+ },
+ "small": {
+ "displayname": "testserver",
+ "username": "root",
+ "password": "password",
+ "ssh_port": 22,
+ "hypervisor": "XenServer",
+ "privateport": 22,
+ "publicport": 22,
+ "protocol": 'TCP',
+ },
+ "medium": {
+ "displayname": "testserver",
+ "username": "root",
+ "password": "password",
+ "ssh_port": 22,
+ "hypervisor": 'XenServer',
+ "privateport": 22,
+ "publicport": 22,
+ "protocol": 'TCP',
+ },
+ "service_offering": {
+ "name": "Tiny Instance",
+ "displaytext": "Tiny Instance",
+ "cpunumber": 1,
+ "cpuspeed": 100, # in MHz
+ "memory": 128, # In MBs
+ },
+ "service_offerings": {
+ "name": "Tiny Instance",
+ "displaytext": "Tiny Instance",
+ "cpunumber": 1,
+ "cpuspeed": 100,
+ "memory": 128,
+
+ "tiny": {
+ "name": "Tiny Instance",
+ "displaytext": "Tiny Instance",
+ "cpunumber": 1,
+ "cpuspeed": 100,
+ "memory": 128,
+ },
+ "small": {
+ "name": "Small Instance",
+ "displaytext": "Small Instance",
+ "cpunumber": 1,
+ "cpuspeed": 100,
+ "memory": 256
+ },
+ "medium": {
+ "name": "Medium Instance",
+ "displaytext": "Medium Instance",
+ "cpunumber": 1,
+ "cpuspeed": 100,
+ "memory": 256,
+ },
+ "big": {
+ "name": "BigInstance",
+ "displaytext": "BigInstance",
+ "cpunumber": 1,
+ "cpuspeed": 100,
+ "memory": 512,
+ }
+ },
+ "disk_offering": {
+ "name": "Disk offering",
+ "displaytext": "Disk offering",
+ "disksize": 1
+ },
+ 'resized_disk_offering': {
+ "displaytext": "Resized",
+ "name": "Resized",
+ "disksize": 3
+ },
+ "network": {
+ "name": "Test Network",
+ "displaytext": "Test Network",
+ "acltype": "Account",
+ },
+ "network2": {
+ "name": "Test Network Shared",
+ "displaytext": "Test Network Shared",
+ "vlan": 1201,
+ "gateway": "172.16.15.1",
+ "netmask": "255.255.255.0",
+ "startip": "172.16.15.21",
+ "endip": "172.16.15.41",
+ "acltype": "Account",
+ },
+ "network_offering": {
+ "name": 'Test Network offering',
+ "displaytext": 'Test Network offering',
+ "guestiptype": 'Isolated',
+ "supportedservices": 'Dhcp,Dns,SourceNat,PortForwarding',
+ "traffictype": 'GUEST',
+ "availability": 'Optional',
+ "serviceProviderList": {
+ "Dhcp": 'VirtualRouter',
+ "Dns": 'VirtualRouter',
+ "SourceNat": 'VirtualRouter',
+ "PortForwarding": 'VirtualRouter',
+ },
+ },
+ "nw_off_isolated_persistent": {
+ "name": 'Test Nw off isolated persistent',
+ "displaytext": 'Test Nw off isolated persistent',
+ "guestiptype": 'Isolated',
+ "supportedservices": 'Dhcp,Dns,SourceNat,PortForwarding',
+ "traffictype": 'GUEST',
+ "isPersistent": 'True',
+ "availability": 'Optional',
+ "serviceProviderList": {
+ "Dhcp": 'VirtualRouter',
+ "Dns": 'VirtualRouter',
+ "SourceNat": 'VirtualRouter',
+ "PortForwarding": 'VirtualRouter',
+ },
+ },
+ "isolated_network_offering": {
+ "name": "Network offering-DA services",
+ "displaytext": "Network offering-DA services",
+ "guestiptype": "Isolated",
+ "supportedservices":
+ "Dhcp,Dns,SourceNat,PortForwarding,Vpn,Firewall,Lb,UserData,StaticNat",
+ "traffictype": "GUEST",
+ "availability": "Optional'",
+ "serviceProviderList": {
+ "Dhcp": "VirtualRouter",
+ "Dns": "VirtualRouter",
+ "SourceNat": "VirtualRouter",
+ "PortForwarding": "VirtualRouter",
+ "Vpn": "VirtualRouter",
+ "Firewall": "VirtualRouter",
+ "Lb": "VirtualRouter",
+ "UserData": "VirtualRouter",
+ "StaticNat": "VirtualRouter"
+ }
+ },
+ "isolated_network": {
+ "name": "Isolated Network",
+ "displaytext": "Isolated Network"
+ },
+ "virtual_machine": {
+ "displayname": "Test VM",
+ "username": "root",
+ "password": "password",
+ "ssh_port": 22,
+ "privateport": 22,
+ "publicport": 22,
+ "protocol": "TCP",
+ "affinity": {
+ "name": "webvms",
+ "type": "host anti-affinity",
+ },
+ },
+ "virtual_machine2": {
+ "name": "testvm2",
+ "displayname": "Test VM2",
+ },
+ "virtual_machine3": {
+ "name": "testvm3",
+ "displayname": "Test VM3",
+ },
+ "server_without_disk": {
+ "displayname": "Test VM-No Disk",
+ "username": "root",
+ "password": "password",
+ "ssh_port": 22,
+ "hypervisor": 'XenServer',
+ "privateport": 22,
+ "publicport": 22,
+ "protocol": 'TCP',
+ },
+ "shared_network": {
+ "name": "MySharedNetwork - Test",
+ "displaytext": "MySharedNetwork",
+ "vlan": "",
+ "gateway": "",
+ "netmask": "",
+ "startip": "",
+ "endip": "",
+ "acltype": "Domain",
+ "scope": "all"
+ },
+ "shared_network_offering_sg": {
+ "name": "MySharedOffering-sg",
+ "displaytext": "MySharedOffering-sg",
+ "guestiptype": "Shared",
+ "supportedservices": "Dhcp,Dns,UserData,SecurityGroup",
+ "specifyVlan": "False",
+ "specifyIpRanges": "False",
+ "traffictype": "GUEST",
+ "serviceProviderList": {
+ "Dhcp": "VirtualRouter",
+ "Dns": "VirtualRouter",
+ "UserData": "VirtualRouter",
+ "SecurityGroup": "SecurityGroupProvider"
+ }
+ },
+ "shared_network_sg": {
+ "name": "Shared-Network-SG-Test",
+ "displaytext": "Shared-Network_SG-Test",
+ "networkofferingid": "1",
+ "vlan": "",
+ "gateway": "",
+ "netmask": "255.255.255.0",
+ "startip": "",
+ "endip": "",
+ "acltype": "Domain",
+ "scope": "all"
+ },
+ "vpc_offering": {
+ "name": "VPC off",
+ "displaytext": "VPC off",
+ "supportedservices":
+ "Dhcp,Dns,SourceNat,PortForwarding,Vpn,Lb,UserData,StaticNat,NetworkACL"
+ },
+ "vpc": {
+ "name": "TestVPC",
+ "displaytext": "TestVPC",
+ "cidr": "10.0.0.1/24"
+ },
+ "clusters": {
+ 0: {
+ "clustername": "Xen Cluster",
+ "clustertype": "CloudManaged",
+ "hypervisor": "XenServer",
+ },
+ 1: {
+ "clustername": "KVM Cluster",
+ "clustertype": "CloudManaged",
+ "hypervisor": "KVM",
+ },
+ 2: {
+ "hypervisor": 'VMware',
+ "clustertype": 'ExternalManaged',
+ "username": 'administrator',
+ "password": 'fr3sca',
+ "url": 'http://192.168.100.17/CloudStack-Clogeny-Pune/Pune-1',
+ "clustername": 'VMWare Cluster',
+ },
+ },
+ "hosts": {
+ "xenserver": {
+ "hypervisor": 'XenServer',
+ "clustertype": 'CloudManaged',
+ "url": 'http://192.168.100.211',
+ "username": "root",
+ "password": "fr3sca",
+ },
+ "kvm": {
+ "hypervisor": 'KVM',
+ "clustertype": 'CloudManaged',
+ "url": 'http://192.168.100.212',
+ "username": "root",
+ "password": "fr3sca",
+ },
+ "vmware": {
+ "hypervisor": 'VMware',
+ "clustertype": 'ExternalManaged',
+ "url": 'http://192.168.100.203',
+ "username": "administrator",
+ "password": "fr3sca",
+ },
+ },
+ "network_offering_shared": {
+ "name": 'Test Network offering shared',
+ "displaytext": 'Test Network offering Shared',
+ "guestiptype": 'Shared',
+ "supportedservices": 'Dhcp,Dns,UserData',
+ "traffictype": 'GUEST',
+ "specifyVlan": "True",
+ "specifyIpRanges": "True",
+ "serviceProviderList": {
+ "Dhcp": 'VirtualRouter',
+ "Dns": 'VirtualRouter',
+ "UserData": 'VirtualRouter',
+ },
+ },
+ "nw_off_persistent_RVR": {
+ "name": 'Network offering-RVR services',
+ "displaytext": 'Network off-RVR services',
+ "guestiptype": 'Isolated',
+ "supportedservices":
+ 'Vpn,Dhcp,Dns,SourceNat,PortForwarding,Firewall,Lb,UserData,StaticNat',
+ "traffictype": 'GUEST',
+ "isPersistent": 'True',
+ "availability": 'Optional',
+ "serviceProviderList": {
+ "Vpn": 'VirtualRouter',
+ "Dhcp": 'VirtualRouter',
+ "Dns": 'VirtualRouter',
+ "SourceNat": 'VirtualRouter',
+ "PortForwarding": 'VirtualRouter',
+ "Firewall": 'VirtualRouter',
+ "Lb": 'VirtualRouter',
+ "UserData": 'VirtualRouter',
+ "StaticNat": 'VirtualRouter',
+ },
+ "serviceCapabilityList": {
+ "SourceNat": {
+ "SupportedSourceNatTypes": "peraccount",
+ "RedundantRouter": "true",
+ },
+ "lb": {
+ "SupportedLbIsolation": "dedicated"
+ },
+ },
+ },
+ "nw_off_isolated_persistent_netscaler": {
+ "name": 'Netscaler',
+ "displaytext": 'Netscaler',
+ "guestiptype": 'Isolated',
+ "supportedservices":
+ 'Dhcp,Dns,SourceNat,PortForwarding,Vpn,Firewall,Lb,UserData,StaticNat',
+ "traffictype": 'GUEST',
+ "isPersistent": 'True',
+ "availability": 'Optional',
+ "serviceProviderList": {
+ "Dhcp": 'VirtualRouter',
+ "Dns": 'VirtualRouter',
+ "SourceNat": 'VirtualRouter',
+ "PortForwarding": 'VirtualRouter',
+ "Vpn": 'VirtualRouter',
+ "Firewall": 'VirtualRouter',
+ "Lb": 'Netscaler',
+ "UserData": 'VirtualRouter',
+ "StaticNat": 'VirtualRouter',
+ },
+
+ },
+ "nw_off_persistent_VPCVR_NoLB": {
+ "name": 'VPC Network offering',
+ "displaytext": 'VPC Network off',
+ "guestiptype": 'Isolated',
+ "supportedservices":
+ 'Vpn,Dhcp,Dns,SourceNat,PortForwarding,UserData,StaticNat,NetworkACL',
+ "traffictype": 'GUEST',
+ "availability": 'Optional',
+ "isPersistent": 'True',
+ "useVpc": 'on',
+ "serviceProviderList": {
+ "Vpn": 'VpcVirtualRouter',
+ "Dhcp": 'VpcVirtualRouter',
+ "Dns": 'VpcVirtualRouter',
+ "SourceNat": 'VpcVirtualRouter',
+ "PortForwarding": 'VpcVirtualRouter',
+ "UserData": 'VpcVirtualRouter',
+ "StaticNat": 'VpcVirtualRouter',
+ "NetworkACL": 'VpcVirtualRouter'
+ },
+
+ },
+ "network_offering_internal_lb": {
+ "name": "Network offering for internal lb service",
+ "displaytext": "Network offering for internal lb service",
+ "guestiptype": "Isolated",
+ "traffictype": "Guest",
+ "supportedservices":
+ "Vpn,Dhcp,Dns,Lb,UserData,SourceNat,StaticNat,PortForwarding,NetworkACL",
+ "serviceProviderList": {
+ "Dhcp": "VpcVirtualRouter",
+ "Dns": "VpcVirtualRouter",
+ "Vpn": "VpcVirtualRouter",
+ "UserData": "VpcVirtualRouter",
+ "Lb": "InternalLbVM",
+ "SourceNat": "VpcVirtualRouter",
+ "StaticNat": "VpcVirtualRouter",
+ "PortForwarding": "VpcVirtualRouter",
+ "NetworkACL": "VpcVirtualRouter",
+ },
+ "serviceCapabilityList": {
+ "SourceNat": {"SupportedSourceNatTypes": "peraccount"},
+ "Lb": {"lbSchemes": "internal", "SupportedLbIsolation": "dedicated"}
+ }
+ },
+ "natrule": {
+ "privateport": 22,
+ "publicport": 2222,
+ "protocol": "TCP"
+ },
+ "lbrule": {
+ "name": "SSH",
+ "alg": "roundrobin",
+ "privateport": 22,
+ "publicport": 2222,
+ "protocol": 'TCP'
+ },
+ "iso": {
+ "displaytext": "Test ISO",
+ "name": "ISO",
+ "url": "http://people.apache.org/~tsp/dummy.iso",
+ "bootable": False,
+ "ispublic": False,
+ "ostype": "CentOS 5.6 (64-bit)",
+ },
+ "iso1": {
+ "displaytext": "Test ISO 1",
+ "name": "ISO 1",
+ "url": "http://people.apache.org/~tsp/dummy.iso",
+ "isextractable": True,
+ "isfeatured": True,
+ "ispublic": True,
+ "ostype": "CentOS 5.6 (64-bit)",
+ },
+ "iso2": {
+ "displaytext": "Test ISO 2",
+ "name": "ISO 2",
+ "url": "http://people.apache.org/~tsp/dummy.iso",
+ "isextractable": True,
+ "isfeatured": True,
+ "ispublic": True,
+ "ostype": "CentOS 5.6 (64-bit)",
+ "mode": 'HTTP_DOWNLOAD',
+ },
+ "isfeatured": True,
+ "ispublic": True,
+ "isextractable": True,
+ "bootable": True,
+ "passwordenabled": True,
+
+ "template": {
+ "displaytext": "xs",
+ "name": "xs",
+ "passwordenabled": False,
+ },
+ "template_2": {
+ "displaytext": "Public Template",
+ "name": "Public template",
+ "ostype": "CentOS 5.6 (64-bit)",
+ "isfeatured": True,
+ "ispublic": True,
+ "isextractable": True,
+ "mode": "HTTP_DOWNLOAD",
+ },
+ "templatefilter": 'self',
+
+ "templates": {
+ "displaytext": 'Template',
+ "name": 'Template',
+ "ostype": "CentOS 5.3 (64-bit)",
+ "templatefilter": 'self',
+ },
+ "security_group": {"name": "custom_Sec_Grp"},
+ "ingress_rule": {
+ "protocol": "TCP",
+ "startport": "22",
+ "endport": "22",
+ "cidrlist": "0.0.0.0/0"
+ },
+ "vpncustomergateway": {
+ "ipsecpsk": "secreatKey",
+ "ikepolicy": "aes128-sha1",
+ "ikelifetime": "86400",
+ "esppolicy": "aes128-sha1",
+ "epslifetime": "3600",
+ "dpd": "false"
+ },
+ "ostype": "CentOS 5.6 (64-bit)",
+ "sleep": 90,
+ "timeout": 10,
+ "page": 1,
+ "pagesize": 2,
+ "listall": 'true',
+ "advanced_sg": {
+ "zone": {
+ "name": "",
+ "dns1": "8.8.8.8",
+ "internaldns1": "192.168.100.1",
+ "networktype": "Advanced",
+ "securitygroupenabled": "true"
+ },
+ "securitygroupenabled": "true"
+ },
+ "vlan": "10",
+ "portableiprange_vlan": {
+ "part": ["4090-4091", "4092-4095"],
+ "full": "4090-4095"
+ },
+ "nfs": {
+ "url": "nfs://nfs/export/automation/1/testprimary",
+ "name": "Primary XEN"
+ },
+ "iscsi": {
+ "url":
+ "iscsi://192.168.100.21/iqn.2012-01.localdomain.clo-cstack-cos6:iser/1",
+ "name": "Primary iSCSI"
+ },
+ "volume": {"diskname": "Test Volume"},
+ "custom_volume": {
+ "customdisksize": 1,
+ "diskname": "Custom disk",
+ },
+ "upload_volume": {
+ "diskname": "UploadVol",
+ "format": "VHD",
+ "url":
+ "http://10.147.28.7/templates/393d3550-05ef-330f-9b8c-745b0e699759.vhd",
+ "checksum": "",
+ },
+ "recurring_snapshot": {
+ "maxsnaps": 2,
+ "timezone": "US/Arizona",
+ },
+ "volume_offerings": {
+ 0: {"diskname": "TestDiskServ"},
+ },
+ "diskdevice": ['/dev/vdc', '/dev/vdb', '/dev/hdb', '/dev/hdc',
+ '/dev/xvdd', '/dev/cdrom', '/dev/sr0', '/dev/cdrom1'],
+
+ # test_vpc_vpn.py
+ "vpn_user": {
+ "username": "test",
+ "password": "password",
+ },
+ "vpc": {
+ "name": "vpc_vpn",
+ "displaytext": "vpc-vpn",
+ "cidr": "10.1.1.0/24"
+ },
+ "ntwk": {
+ "name": "tier1",
+ "displaytext": "vpc-tier1",
+ "gateway": "10.1.1.1",
+ "netmask": "255.255.255.192"
+ },
+ "vpc2": {
+ "name": "vpc2_vpn",
+ "displaytext": "vpc2-vpn",
+ "cidr": "10.2.1.0/24"
+ },
+ "ntwk2": {
+ "name": "tier2",
+ "displaytext": "vpc-tier2",
+ "gateway": "10.2.1.1",
+ "netmask": "255.255.255.192"
+ },
+ "server": {
+ "displayname": "TestVM",
+ "username": "root",
+ "password": "password",
+ "ssh_port": 22,
+ "hypervisor": 'XenServer',
+ "privateport": 22,
+ "publicport": 22,
+ "protocol": 'TCP'
+ },
+ "privateport": 22,
+ "publicport": 22,
+ "protocol": 'TCP',
+ "forvirtualnetwork": "true",
+ "customdisksize": 1,
+ "diskname": "Test Volume",
+ "portableIpRange": {
+ "gateway": "10.223.252.195",
+ "netmask": "255.255.255.192",
+ "startip": "10.223.252.196",
+ "endip": "10.223.252.197",
+ "vlan": "1001"
+ },
+ "sparse": {
+ "name": "Sparse Type Disk offering",
+ "displaytext":
+ "Sparse Type Disk offering",
+ "disksize": 1, # in GB
+ "provisioningtype": "sparse"
+ },
+ "fat": {
+ "name": "Fat Type Disk offering",
+ "displaytext":
+ "Fat Type Disk offering",
+ "disksize": 1, # in GB
+ "provisioningtype": "fat"
+ },
+ "sparse_disk_offering": {
+ "displaytext": "Sparse",
+ "name": "Sparse",
+ "provisioningtype": "sparse",
+ "disksize": 1
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/tools/marvin/marvin/configGenerator.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/configGenerator.py b/tools/marvin/marvin/configGenerator.py
index 0b4a0a1..68ec24e 100644
--- a/tools/marvin/marvin/configGenerator.py
+++ b/tools/marvin/marvin/configGenerator.py
@@ -20,9 +20,12 @@ import os
from optparse import OptionParser
import jsonHelper
from marvin.codes import *
+from marvin.cloudstackException import GetDetailExceptionInfo
+from marvin.config.test_data import test_data
class managementServer(object):
+
def __init__(self):
self.mgtSvrIp = None
self.port = 8096
@@ -34,6 +37,7 @@ class managementServer(object):
class dbServer(object):
+
def __init__(self):
self.dbSvr = None
self.port = 3306
@@ -50,8 +54,7 @@ class configuration(object):
class logger(object):
def __init__(self):
- '''TestCase/TestClient'''
- self.logFolderPath = None
+ self.LogFolderPath = None
class cloudstackConfiguration(object):
@@ -61,6 +64,7 @@ class cloudstackConfiguration(object):
self.dbSvr = None
self.globalConfig = []
self.logger = None
+ self.TestData = None
class zone(object):
@@ -83,6 +87,7 @@ class zone(object):
class trafficType(object):
+
def __init__(self, typ, labeldict=None):
self.typ = typ # Guest/Management/Public
if labeldict:
@@ -95,6 +100,7 @@ class trafficType(object):
class pod(object):
+
def __init__(self):
self.gateway = None
self.name = None
@@ -109,6 +115,7 @@ class pod(object):
class VmwareDc(object):
+
def __init__(self):
self.zoneid = None
self.name = None
@@ -118,6 +125,7 @@ class VmwareDc(object):
class cluster(object):
+
def __init__(self):
self.clustername = None
self.clustertype = None
@@ -132,6 +140,7 @@ class cluster(object):
class host(object):
+
def __init__(self):
self.hypervisor = None
self.password = None
@@ -149,6 +158,7 @@ class host(object):
class physicalNetwork(object):
+
def __init__(self):
self.name = None
self.tags = []
@@ -163,6 +173,7 @@ class physicalNetwork(object):
class provider(object):
+
def __init__(self, name=None):
self.name = name
self.state = None
@@ -173,6 +184,7 @@ class provider(object):
class network(object):
+
def __init__(self):
self.displaytext = None
self.name = None
@@ -185,6 +197,7 @@ class network(object):
class iprange(object):
+
def __init__(self):
'''tagged/untagged'''
self.gateway = None
@@ -198,12 +211,14 @@ class iprange(object):
class primaryStorage(object):
+
def __init__(self):
self.name = None
self.url = None
class secondaryStorage(object):
+
def __init__(self):
self.url = None
self.provider = None
@@ -211,6 +226,7 @@ class secondaryStorage(object):
class cacheStorage(object):
+
def __init__(self):
self.url = None
self.provider = None
@@ -218,6 +234,7 @@ class cacheStorage(object):
class s3(object):
+
def __init__(self):
self.accesskey = None
self.secretkey = None
@@ -230,6 +247,7 @@ class s3(object):
class netscaler(object):
+
def __init__(self, hostname=None, username='nsroot', password='nsroot'):
self.hostname = hostname
self.username = username
@@ -246,11 +264,12 @@ class netscaler(object):
def __repr__(self):
req = zip(self.__dict__.keys(), self.__dict__.values())
- return self.hostname+"?" + "&".join(["=".join([r[0], r[1]])
- for r in req])
+ return self.hostname + "?" + "&".join(["=".join([r[0], r[1]])
+ for r in req])
class srx(object):
+
def __init__(self, hostname=None, username='root', password='admin'):
self.hostname = hostname
self.username = username
@@ -269,11 +288,12 @@ class srx(object):
def __repr__(self):
req = zip(self.__dict__.keys(), self.__dict__.values())
- return self.hostname+"?" + "&".join(["=".join([r[0], r[1]])
- for r in req])
+ return self.hostname + "?" + "&".join(["=".join([r[0], r[1]])
+ for r in req])
class bigip(object):
+
def __init__(self, hostname=None, username='root', password='default'):
self.hostname = hostname
self.username = username
@@ -290,14 +310,14 @@ class bigip(object):
def __repr__(self):
req = zip(self.__dict__.keys(), self.__dict__.values())
- return self.hostname+"?" + "&".join(["=".join([r[0], r[1]])
- for r in req])
+ return self.hostname + "?" + "&".join(["=".join([r[0], r[1]])
+ for r in req])
class ConfigManager(object):
'''
- @Name: configManager
+ @Name: ConfigManager
@Desc: 1. It provides the basic configuration facilities to marvin.
2. User can just add configuration files for his tests, deployment
etc, under one config folder before running their tests.
@@ -328,16 +348,21 @@ class ConfigManager(object):
"getConfig" API,once configObj is returned.
'''
- def __init__(self):
- # Joining path with current directory will avoid relative path issue
- # It will take correct path irrespective of from where the test case is run
- dirPath = os.path.dirname(__file__)
- self.filePath = os.path.join(dirPath, 'config/config.cfg')
- self.parsedDict = None
- if self.__verifyFile(self.filePath) is not False:
- self.parsedDict = self.__parseConfig(self.filePath)
-
- def __parseConfig(self, file):
+ def __init__(self, cfg_file=None):
+ self.__filePath = cfg_file
+ self.__parsedCfgDict = None
+ '''
+ Set the Configuration
+ '''
+ self.__setConfig()
+
+ def __setConfig(self):
+ if not self.__verifyFile():
+ dirPath = os.path.dirname(__file__)
+ self.__filePath = str(os.path.join(dirPath, "config/test_data.py"))
+ self.__parsedCfgDict = self.__parseConfig()
+
+ def __parseConfig(self):
'''
@Name : __parseConfig
@Description: Parses the Input configuration Json file
@@ -348,36 +373,38 @@ class ConfigManager(object):
'''
config_dict = None
try:
- configlines = []
- with open(file, 'r') as fp:
- for line in fp:
- if len(line) != 0:
+ if self.__filePath.endswith(".py"):
+ config_dict = test_data
+ else:
+ configLines = []
+ with open(file, 'r') as fp:
+ for line in fp:
ws = line.strip()
- if ws[0] not in ["#"]:
- configlines.append(ws)
- config_dict = json.loads("\n".join(configlines))
- except Exception, e:
- #Will replace with log once we have logging done
- print "\n Exception occurred under __parseConfig", e
+ if not ws.startswith("#"):
+ configLines.append(ws)
+ config = json.loads("\n".join(configLines))
+ config_dict = config
+ except Exception as e:
+ # Will replace with log once we have logging done
+ print "\n Exception occurred under ConfigManager:__parseConfig" \
+ " :%s", GetDetailExceptionInfo(e)
finally:
return config_dict
- def __verifyFile(self, file):
+ def __verifyFile(self):
'''
@Name : __parseConfig
@Description: Parses the Input configuration Json file
and returns a dictionary from the file.
- @Input : file NA
+ @Input : NA
@Output : True or False based upon file input validity
and availability
'''
- if file is None or file == '':
+ if self.__filePath is None or self.__filePath == '':
return False
- if os.path.exists(file) is False:
- return False
- return True
+ return os.path.exists(self.__filePath)
- def __getSectionData(self, return_dict, section=None):
+ def getSectionData(self, section=None):
'''
@Name: getSectionData
@Desc: Gets the Section data of a particular section
@@ -386,43 +413,29 @@ class ConfigManager(object):
section to be returned from this dict
@Output:Section matching inside the parsed data
'''
- if return_dict is not None:
- inp = return_dict
- elif self.parsedDict is None:
+ if self.__parsedCfgDict is None or section is None:
+ print "\nEither Parsed Dictionary is None or Section is None"
return INVALID_INPUT
- else:
- inp = self.parsedDict
-
if section is not None:
- return inp.get(section)
- else:
- return inp
+ return self.__parsedCfgDict.get(section)
- def getConfig(self, file_path=None, section=None):
+ def getConfig(self):
'''
- @Name: getConfig
- @Desc : Parses and converts the given configuration file to dictionary
- @Input : file_path: path where the configuration needs to be passed
- section: specific section inside the file
- @Output: INVALID_INPUT: This value is returned if the input
- is invalid or not able to be parsed
- Parsed configuration dictionary from json file
+ @Name : getConfig
+ @Desc : Returns the Parsed Dictionary of Config Provided
+ @Input : NA
+ @Output: ParsedDict if successful if cfg file provided is valid
+ None if cfg file is invalid or not able to be parsed
'''
- ret = None
- if file not in [None, '']:
- if self.__verifyFile(file_path) is False:
- return INVALID_INPUT
- else:
- ret = self.__parseConfig(file_path)
- return self.__getSectionData(ret, section)
+ return self.__parsedCfgDict
def getDeviceUrl(obj):
req = zip(obj.__dict__.keys(), obj.__dict__.values())
if obj.hostname:
- return "http://" + obj.hostname+"?" + "&".join(["=".join([r[0],
- r[1]])
- for r in req])
+ return "http://" + obj.hostname + "?" + "&".join(["=".join([r[0],
+ r[1]])
+ for r in req])
else:
return None
@@ -437,11 +450,11 @@ def descSetupInBasicMode():
z.dns2 = "8.8.4.4"
z.internaldns1 = "192.168.110.254"
z.internaldns2 = "192.168.110.253"
- z.name = "test"+str(l)
+ z.name = "test" + str(l)
z.networktype = 'Basic'
z.securitygroupenabled = 'True'
- #If security groups are reqd
+ # If security groups are reqd
sgprovider = provider()
sgprovider.broadcastdomainrange = 'Pod'
sgprovider.name = 'SecurityGroupProvider'
@@ -467,15 +480,15 @@ def descSetupInBasicMode():
ip = iprange()
ip.gateway = p.gateway
ip.netmask = p.netmask
- ip.startip = "192.168.%d.%d" % (i, j*20)
- ip.endip = "192.168.%d.%d" % (i, j*20+10)
+ ip.startip = "192.168.%d.%d" % (i, j * 20)
+ ip.endip = "192.168.%d.%d" % (i, j * 20 + 10)
p.guestIpRanges.append(ip)
'''add 10 clusters'''
for j in range(2):
c = cluster()
- c.clustername = "test"+str(l)+str(i) + str(j)
+ c.clustername = "test" + str(l) + str(i) + str(j)
c.clustertype = "CloudManaged"
c.hypervisor = "Simulator"
@@ -484,15 +497,16 @@ def descSetupInBasicMode():
h = host()
h.username = "root"
h.password = "password"
- memory = 8*1024*1024*1024
- localstorage = 1*1024*1024*1024*1024
+ memory = 8 * 1024 * 1024 * 1024
+ localstorage = 1 * 1024 * 1024 * 1024 * 1024
h.url = "http://sim/%d%d%d%d" % (l, i, j, k)
c.hosts.append(h)
'''add 2 primary storages'''
for m in range(2):
primary = primaryStorage()
- primary.name = "primary"+str(l) + str(i) + str(j) + str(m)
+ primary.name = "primary" + \
+ str(l) + str(i) + str(j) + str(m)
primary.url = "nfs://localhost/path%s" % (str(l) + str(i) +
str(j) + str(m))
c.primaryStorages.append(primary)
@@ -504,7 +518,7 @@ def descSetupInBasicMode():
'''add two secondary'''
for i in range(5):
secondary = secondaryStorage()
- secondary.url = "nfs://localhost/path"+str(l) + str(i)
+ secondary.url = "nfs://localhost/path" + str(l) + str(i)
z.secondaryStorages.append(secondary)
zs.zones.append(z)
@@ -546,7 +560,7 @@ def descSetupInEipMode():
z.dns2 = "8.8.4.4"
z.internaldns1 = "192.168.110.254"
z.internaldns2 = "192.168.110.253"
- z.name = "test"+str(l)
+ z.name = "test" + str(l)
z.networktype = 'Basic'
ips = iprange()
@@ -557,7 +571,7 @@ def descSetupInEipMode():
ips.netmask = "255.255.255.0"
z.ipranges.append(ips)
- #If security groups are reqd
+ # If security groups are reqd
sgprovider = provider()
sgprovider.broadcastdomainrange = 'Pod'
sgprovider.name = 'SecurityGroupProvider'
@@ -591,15 +605,15 @@ def descSetupInEipMode():
ip = iprange()
ip.gateway = p.gateway
ip.netmask = p.netmask
- ip.startip = "192.168.%d.%d" % (i, j*20)
- ip.endip = "192.168.%d.%d" % (i, j*20+10)
+ ip.startip = "192.168.%d.%d" % (i, j * 20)
+ ip.endip = "192.168.%d.%d" % (i, j * 20 + 10)
p.guestIpRanges.append(ip)
'''add 10 clusters'''
for j in range(2):
c = cluster()
- c.clustername = "test"+str(l)+str(i) + str(j)
+ c.clustername = "test" + str(l) + str(i) + str(j)
c.clustertype = "CloudManaged"
c.hypervisor = "Simulator"
@@ -614,7 +628,8 @@ def descSetupInEipMode():
'''add 2 primary storages'''
for m in range(2):
primary = primaryStorage()
- primary.name = "primary"+str(l) + str(i) + str(j) + str(m)
+ primary.name = "primary" + \
+ str(l) + str(i) + str(j) + str(m)
primary.url = "nfs://localhost/path%s" % (str(l) + str(i)
+ str(j)
+ str(m))
@@ -627,7 +642,7 @@ def descSetupInEipMode():
'''add two secondary'''
for i in range(5):
secondary = secondaryStorage()
- secondary.url = "nfs://localhost/path"+str(l) + str(i)
+ secondary.url = "nfs://localhost/path" + str(l) + str(i)
z.secondaryStorages.append(secondary)
zs.zones.append(z)
@@ -667,7 +682,7 @@ def descSetupInAdvancedMode():
z.dns2 = "8.8.4.4"
z.internaldns1 = "192.168.110.254"
z.internaldns2 = "192.168.110.253"
- z.name = "test"+str(l)
+ z.name = "test" + str(l)
z.networktype = 'Advanced'
z.guestcidraddress = "10.1.1.0/24"
z.vlan = "100-2000"
@@ -703,7 +718,7 @@ def descSetupInAdvancedMode():
'''add 10 clusters'''
for j in range(2):
c = cluster()
- c.clustername = "test"+str(l)+str(i) + str(j)
+ c.clustername = "test" + str(l) + str(i) + str(j)
c.clustertype = "CloudManaged"
c.hypervisor = "Simulator"
@@ -714,7 +729,7 @@ def descSetupInAdvancedMode():
h.password = "password"
memory = 8 * 1024 * 1024 * 1024
localstorage = 1 * 1024 * 1024 * 1024 * 1024
- #h.url = "http://sim/%d%d%d%d/cpucore=1&cpuspeed=8000&\
+ # h.url = "http://sim/%d%d%d%d/cpucore=1&cpuspeed=8000&\
# memory=%d&localstorage=%d"%(l, i, j, k, memory,
# localstorage)
h.url = "http://sim/%d%d%d%d" % (l, i, j, k)
@@ -723,8 +738,9 @@ def descSetupInAdvancedMode():
'''add 2 primary storages'''
for m in range(2):
primary = primaryStorage()
- primary.name = "primary"+str(l) + str(i) + str(j) + str(m)
- #primary.url = "nfs://localhost/path%s/size=%d" %
+ primary.name = "primary" + \
+ str(l) + str(i) + str(j) + str(m)
+ # primary.url = "nfs://localhost/path%s/size=%d" %
# (str(l) + str(i) + str(j) + str(m), size)
primary.url = "nfs://localhost/path%s" % (str(l) + str(i)
+ str(j)
@@ -738,7 +754,7 @@ def descSetupInAdvancedMode():
'''add two secondary'''
for i in range(5):
secondary = secondaryStorage()
- secondary.url = "nfs://localhost/path"+str(l) + str(i)
+ secondary.url = "nfs://localhost/path" + str(l) + str(i)
z.secondaryStorages.append(secondary)
'''add default public network'''
@@ -788,7 +804,7 @@ def descSetupInAdvancedsgMode():
z.dns2 = "8.8.4.4"
z.internaldns1 = "192.168.110.254"
z.internaldns2 = "192.168.110.253"
- z.name = "test"+str(l)
+ z.name = "test" + str(l)
z.networktype = 'Advanced'
z.vlan = "100-2000"
z.securitygroupenabled = "true"
@@ -797,7 +813,7 @@ def descSetupInAdvancedsgMode():
pn.name = "test-network"
pn.traffictypes = [trafficType("Guest"), trafficType("Management")]
- #If security groups are reqd
+ # If security groups are reqd
sgprovider = provider()
sgprovider.broadcastdomainrange = 'ZONE'
sgprovider.name = 'SecurityGroupProvider'
@@ -817,7 +833,7 @@ def descSetupInAdvancedsgMode():
'''add 10 clusters'''
for j in range(2):
c = cluster()
- c.clustername = "test"+str(l)+str(i) + str(j)
+ c.clustername = "test" + str(l) + str(i) + str(j)
c.clustertype = "CloudManaged"
c.hypervisor = "Simulator"
@@ -828,17 +844,18 @@ def descSetupInAdvancedsgMode():
h.password = "password"
memory = 8 * 1024 * 1024 * 1024
localstorage = 1 * 1024 * 1024 * 1024 * 1024
- #h.url = "http://sim/%d%d%d%d/cpucore=1&cpuspeed=8000&\
- #memory=%d&localstorage=%d" % (l, i, j, k, memory,
- #localstorage)
+ # h.url = "http://sim/%d%d%d%d/cpucore=1&cpuspeed=8000&\
+ # memory=%d&localstorage=%d" % (l, i, j, k, memory,
+ # localstorage)
h.url = "http://sim/%d%d%d%d" % (l, i, j, k)
c.hosts.append(h)
'''add 2 primary storages'''
for m in range(2):
primary = primaryStorage()
- primary.name = "primary"+str(l) + str(i) + str(j) + str(m)
- #primary.url = "nfs://localhost/path%s/size=%d" % \
+ primary.name = "primary" + \
+ str(l) + str(i) + str(j) + str(m)
+ # primary.url = "nfs://localhost/path%s/size=%d" % \
#(str(l) + str(i) + str(j) + str(m), size)
primary.url = "nfs://localhost/path%s" % \
(str(l) + str(i) + str(j) + str(m))
@@ -851,7 +868,7 @@ def descSetupInAdvancedsgMode():
'''add two secondary'''
for i in range(5):
secondary = secondaryStorage()
- secondary.url = "nfs://localhost/path"+str(l) + str(i)
+ secondary.url = "nfs://localhost/path" + str(l) + str(i)
z.secondaryStorages.append(secondary)
'''add default guest network'''
@@ -901,18 +918,19 @@ def generate_setup_config(config, file=None):
def getSetupConfig(file):
- if not os.path.exists(file):
- raise IOError("config file %s not found. \
- please specify a valid config file" % file)
- config = cloudstackConfiguration()
- configLines = []
- with open(file, 'r') as fp:
- for line in fp:
- ws = line.strip()
- if not ws.startswith("#"):
- configLines.append(ws)
- config = json.loads("\n".join(configLines))
- return jsonHelper.jsonLoader(config)
+ try:
+ config = cloudstackConfiguration()
+ configLines = []
+ with open(file, 'r') as fp:
+ for line in fp:
+ ws = line.strip()
+ if not ws.startswith("#"):
+ configLines.append(ws)
+ config = json.loads("\n".join(configLines))
+ return jsonHelper.jsonLoader(config)
+ except Exception as e:
+ print "\nException Occurred under getSetupConfig %s" % \
+ GetDetailExceptionInfo(e)
if __name__ == "__main__":
parser = OptionParser()
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/tools/marvin/marvin/dbConnection.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/dbConnection.py b/tools/marvin/marvin/dbConnection.py
index 99014ab..66c6cb1 100644
--- a/tools/marvin/marvin/dbConnection.py
+++ b/tools/marvin/marvin/dbConnection.py
@@ -20,12 +20,13 @@ import contextlib
from mysql import connector
from mysql.connector import errors
from contextlib import closing
-import cloudstackException
+from marvin import cloudstackException
import sys
import os
-class dbConnection(object):
+class DbConnection(object):
+
def __init__(self, host="localhost", port=3306, user='cloud',
passwd='cloud', db='cloud'):
self.host = host
@@ -51,7 +52,7 @@ class dbConnection(object):
try:
resultRow = cursor.fetchall()
except errors.InterfaceError:
- #Raised on empty result - DML
+ # Raised on empty result - DML
resultRow = []
return resultRow
@@ -68,7 +69,7 @@ class dbConnection(object):
return self.execute(sqls)
if __name__ == "__main__":
- db = dbConnection()
+ db = DbConnection()
'''
try:
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/tools/marvin/marvin/deployAndRun.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/deployAndRun.py b/tools/marvin/marvin/deployAndRun.py
index 56747a7..d3b6b86 100644
--- a/tools/marvin/marvin/deployAndRun.py
+++ b/tools/marvin/marvin/deployAndRun.py
@@ -15,13 +15,13 @@
# specific language governing permissions and limitations
# under the License.
-from tcExecuteEngine import TestCaseExecuteEngine
+from .tcExecuteEngine import TestCaseExecuteEngine
import sys
import os
import traceback
import time
from argparse import ArgumentParser
-from marvinInit import MarvinInit
+from .marvinInit import MarvinInit
from marvin.codes import (SUCCESS,
FAILED,
EXCEPTION,
@@ -96,7 +96,7 @@ def startMarvin(cfg_file, load_flag):
else:
print "\nMarvin Initialization Failed"
exit(1)
- except Exception, e:
+ except Exception as e:
print "\n Exception occurred while starting Marvin %s" % str(e)
exit(1)
[15/18] Marvin + test changes from master Signed-off-by:
SrikanteswaraRao Talluri
Posted by da...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/component/test_explicit_dedication.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_explicit_dedication.py b/test/integration/component/test_explicit_dedication.py
index c589c6a..4ce5c15 100644
--- a/test/integration/component/test_explicit_dedication.py
+++ b/test/integration/component/test_explicit_dedication.py
@@ -21,9 +21,9 @@ import marvin
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
from marvin.sshClient import SshClient
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
from nose.plugins.attrib import attr
#Import System modules
import time
@@ -96,12 +96,13 @@ class TestExplicitDedication(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(TestExplicitDedication, cls).getClsTestClient().getApiClient()
- cls.services = Services().services
+ cls.testClient = super(TestExplicitDedication, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+ cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.services['mode'] = cls.zone.networktype
cls.template = get_template(
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/component/test_haproxy.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_haproxy.py b/test/integration/component/test_haproxy.py
index ceea50b..e3b45b5 100644
--- a/test/integration/component/test_haproxy.py
+++ b/test/integration/component/test_haproxy.py
@@ -19,7 +19,7 @@
# Import Local Modules
from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import cloudstackTestCase
-from marvin.integration.lib.base import (
+from marvin.lib.base import (
Account,
ServiceOffering,
VirtualMachine,
@@ -31,11 +31,11 @@ from marvin.integration.lib.base import (
Vpn,
NATRule
)
-from marvin.integration.lib.common import (get_domain,
+from marvin.lib.common import (get_domain,
get_zone,
get_template
)
-from marvin.integration.lib.utils import (cleanup_resources,
+from marvin.lib.utils import (cleanup_resources,
random_gen)
from marvin.cloudstackAPI import createLBStickinessPolicy
from marvin.sshClient import SshClient
@@ -118,12 +118,13 @@ class TestHAProxyStickyness(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(TestHAProxyStickyness,
- cls).getClsTestClient().getApiClient()
+ cls.testClient = super(TestHAProxyStickyness, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.template = get_template(
cls.api_client,
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/component/test_implicit_planner.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_implicit_planner.py b/test/integration/component/test_implicit_planner.py
index 5124e70..9cbd73c 100644
--- a/test/integration/component/test_implicit_planner.py
+++ b/test/integration/component/test_implicit_planner.py
@@ -21,9 +21,9 @@ import marvin
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
from marvin.sshClient import SshClient
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
from nose.plugins.attrib import attr
#Import System modules
import time
@@ -91,12 +91,13 @@ class TestImplicitPlanner(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(TestImplicitPlanner, cls).getClsTestClient().getApiClient()
- cls.services = Services().services
+ cls.testClient = super(TestImplicitPlanner, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+ cls.services = Services().services
# Get Zone, Domain and templates
- domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.services['mode'] = cls.zone.networktype
template = get_template(
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/component/test_ip_reservation.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_ip_reservation.py b/test/integration/component/test_ip_reservation.py
index 46b4edb..dea26ab 100644
--- a/test/integration/component/test_ip_reservation.py
+++ b/test/integration/component/test_ip_reservation.py
@@ -23,31 +23,10 @@
Feature Specifications: https://cwiki.apache.org/confluence/display/CLOUDSTACK/FS+-+IP+Range+Reservation+within+a+Network
"""
from marvin.cloudstackTestCase import cloudstackTestCase, unittest
-from marvin.integration.lib.utils import (cleanup_resources,
- validateList,
- verifyRouterState)
-from marvin.integration.lib.base import (Network,
- Account,
- ServiceOffering,
- VirtualMachine,
- Router,
- NetworkOffering,
- VpcOffering,
- VPC)
-from marvin.integration.lib.common import (get_domain,
- get_zone,
- get_template,
- createEnabledNetworkOffering,
- get_free_vlan,
- wait_for_cleanup,
- createNetworkRulesForVM)
-from marvin.codes import (PASS,
- NAT_RULE,
- STATIC_NAT_RULE,
- FAIL,
- UNKNOWN,
- FAULT,
- MASTER)
+from marvin.cloudstackException import CloudstackAPIException
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
import netaddr
import random
@@ -101,18 +80,22 @@ class TestIpReservation(cloudstackTestCase):
"""
@classmethod
def setUpClass(cls):
- cloudstackTestClient = super(TestIpReservation, cls).getClsTestClient()
- cls.api_client = cloudstackTestClient.getApiClient()
- # Fill test data from the external config file
- cls.testData = cloudstackTestClient.getConfigParser().parsedDict
+ cls.testClient = super(TestIpReservation, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
+ # Fill services from the external config file
+ cls.testData = cls.testClient.getParsedTestDataConfig()
+
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.testData)
- cls.zone = get_zone(cls.api_client, cls.testData)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.template = get_template(
cls.api_client,
cls.zone.id,
cls.testData["ostype"]
)
+ if cls.template == FAILED:
+ assert False, "get_template() failed to return template with description %s" % cls.testData["ostype"]
cls.testData["domainid"] = cls.domain.id
cls.testData["zoneid"] = cls.zone.id
cls.testData["virtual_machine"]["zoneid"] = cls.zone.id
@@ -545,18 +528,22 @@ class TestRestartNetwork(cloudstackTestCase):
"""
@classmethod
def setUpClass(cls):
- cloudstackTestClient = super(TestRestartNetwork, cls).getClsTestClient()
- cls.api_client = cloudstackTestClient.getApiClient()
- # Fill test data from the external config file
- cls.testData = cloudstackTestClient.getConfigParser().parsedDict
+ cls.testClient = super(TestRestartNetwork, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
+ # Fill services from the external config file
+ cls.testData = cls.testClient.getParsedTestDataConfig()
+
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.testData)
- cls.zone = get_zone(cls.api_client, cls.testData)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.template = get_template(
cls.api_client,
cls.zone.id,
cls.testData["ostype"]
)
+ if cls.template == FAILED:
+ assert False, "get_template() failed to return template with description %s" % cls.testData["ostype"]
cls.testData["domainid"] = cls.domain.id
cls.testData["zoneid"] = cls.zone.id
cls.testData["virtual_machine"]["zoneid"] = cls.zone.id
@@ -666,18 +653,22 @@ class TestUpdateIPReservation(cloudstackTestCase):
"""
@classmethod
def setUpClass(cls):
- cloudstackTestClient = super(TestUpdateIPReservation, cls).getClsTestClient()
- cls.api_client = cloudstackTestClient.getApiClient()
- # Fill test data from the external config file
- cls.testData = cloudstackTestClient.getConfigParser().parsedDict
+ cls.testClient = super(TestUpdateIPReservation, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
+ # Fill services from the external config file
+ cls.testData = cls.testClient.getParsedTestDataConfig()
+
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.testData)
- cls.zone = get_zone(cls.api_client, cls.testData)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.template = get_template(
cls.api_client,
cls.zone.id,
cls.testData["ostype"]
)
+ if cls.template == FAILED:
+ assert False, "get_template() failed to return template with description %s" % cls.testData["ostype"]
cls.testData["domainid"] = cls.domain.id
cls.testData["zoneid"] = cls.zone.id
cls.testData["virtual_machine"]["zoneid"] = cls.zone.id
@@ -812,18 +803,22 @@ class TestRouterOperations(cloudstackTestCase):
"""
@classmethod
def setUpClass(cls):
- cloudstackTestClient = super(TestRouterOperations, cls).getClsTestClient()
- cls.api_client = cloudstackTestClient.getApiClient()
- # Fill test data from the external config file
- cls.testData = cloudstackTestClient.getConfigParser().parsedDict
+ cls.testClient = super(TestRouterOperations, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
+ # Fill services from the external config file
+ cls.testData = cls.testClient.getParsedTestDataConfig()
+
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.testData)
- cls.zone = get_zone(cls.api_client, cls.testData)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.template = get_template(
cls.api_client,
cls.zone.id,
cls.testData["ostype"]
)
+ if cls.template == FAILED:
+ assert False, "get_template() failed to return template with description %s" % cls.testData["ostype"]
cls.testData["domainid"] = cls.domain.id
cls.testData["zoneid"] = cls.zone.id
cls.testData["virtual_machine"]["zoneid"] = cls.zone.id
@@ -978,18 +973,22 @@ class TestFailureScnarios(cloudstackTestCase):
"""
@classmethod
def setUpClass(cls):
- cloudstackTestClient = super(TestFailureScnarios, cls).getClsTestClient()
- cls.api_client = cloudstackTestClient.getApiClient()
- # Fill test data from the external config file
- cls.testData = cloudstackTestClient.getConfigParser().parsedDict
+ cls.testClient = super(TestFailureScnarios, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
+ # Fill services from the external config file
+ cls.testData = cls.testClient.getParsedTestDataConfig()
+
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.testData)
- cls.zone = get_zone(cls.api_client, cls.testData)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.template = get_template(
cls.api_client,
cls.zone.id,
cls.testData["ostype"]
)
+ if cls.template == FAILED:
+ assert False, "get_template() failed to return template with description %s" % cls.testData["ostype"]
cls.testData["domainid"] = cls.domain.id
cls.testData["zoneid"] = cls.zone.id
cls.testData["virtual_machine"]["zoneid"] = cls.zone.id
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/component/test_ldap.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_ldap.py b/test/integration/component/test_ldap.py
index 965ff36..5dd9692 100644
--- a/test/integration/component/test_ldap.py
+++ b/test/integration/component/test_ldap.py
@@ -29,9 +29,9 @@ import hashlib
import random
from marvin.cloudstackAPI import *
from marvin.cloudstackAPI import login
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
from nose.plugins.attrib import attr
import urllib
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/component/test_memory_limits.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_memory_limits.py b/test/integration/component/test_memory_limits.py
index 020f89b..5dd3ba0 100644
--- a/test/integration/component/test_memory_limits.py
+++ b/test/integration/component/test_memory_limits.py
@@ -19,21 +19,21 @@
# Import Local Modules
from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import cloudstackTestCase, unittest
-from marvin.integration.lib.base import (
+from marvin.lib.base import (
Account,
ServiceOffering,
VirtualMachine,
Resources,
Domain
)
-from marvin.integration.lib.common import (get_domain,
+from marvin.lib.common import (get_domain,
get_zone,
get_template,
wait_for_cleanup,
findSuitableHostForMigration,
get_resource_type
)
-from marvin.integration.lib.utils import cleanup_resources
+from marvin.lib.utils import cleanup_resources
from marvin.codes import ERROR_NO_HOST_FOR_MIGRATION
class Services:
@@ -91,12 +91,13 @@ class TestMemoryLimits(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(TestMemoryLimits,
- cls).getClsTestClient().getApiClient()
+ cls.testClient = super(TestMemoryLimits, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.services["mode"] = cls.zone.networktype
@@ -370,12 +371,13 @@ class TestDomainMemoryLimitsConfiguration(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(TestDomainMemoryLimitsConfiguration,
- cls).getClsTestClient().getApiClient()
+ cls.testClient = super(TestDomainMemoryLimitsConfiguration, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.services["mode"] = cls.zone.networktype
cls.template = get_template(
@@ -498,7 +500,7 @@ class TestDomainMemoryLimitsConfiguration(cloudstackTestCase):
self.account = admin
self.domain = domain
- api_client = self.testClient.createUserApiClient(
+ api_client = self.testClient.getUserApiClient(
UserName=self.account.name,
DomainName=self.account.domain)
@@ -570,7 +572,7 @@ class TestDomainMemoryLimitsConfiguration(cloudstackTestCase):
self.account = admin
self.domain = domain
- api_client = self.testClient.createUserApiClient(
+ api_client = self.testClient.getUserApiClient(
UserName=self.account.name,
DomainName=self.account.domain)
@@ -630,7 +632,7 @@ class TestDomainMemoryLimitsConfiguration(cloudstackTestCase):
self.account = admin
self.domain = domain
- api_client = self.testClient.createUserApiClient(
+ api_client = self.testClient.getUserApiClient(
UserName=self.account.name,
DomainName=self.account.domain)
@@ -703,7 +705,7 @@ class TestDomainMemoryLimitsConfiguration(cloudstackTestCase):
if memory_account_gc[0].max != 8192:
self.skipTest("This test case requires configuration value max.account.memory to be 8192")
- api_client = self.testClient.createUserApiClient(
+ api_client = self.testClient.getUserApiClient(
UserName=self.account.name,
DomainName=self.account.domain)
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/component/test_mm_domain_limits.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_mm_domain_limits.py b/test/integration/component/test_mm_domain_limits.py
index 0a8e98b..bc8c9ea 100644
--- a/test/integration/component/test_mm_domain_limits.py
+++ b/test/integration/component/test_mm_domain_limits.py
@@ -19,14 +19,14 @@
# Import Local Modules
from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import cloudstackTestCase, unittest
-from marvin.integration.lib.base import (
+from marvin.lib.base import (
Account,
ServiceOffering,
VirtualMachine,
Resources,
Domain
)
-from marvin.integration.lib.common import (get_domain,
+from marvin.lib.common import (get_domain,
get_zone,
get_template,
wait_for_cleanup,
@@ -34,7 +34,7 @@ from marvin.integration.lib.common import (get_domain,
get_resource_type,
update_resource_count
)
-from marvin.integration.lib.utils import cleanup_resources
+from marvin.lib.utils import cleanup_resources
from marvin.codes import ERROR_NO_HOST_FOR_MIGRATION
class Services:
@@ -92,12 +92,13 @@ class TestDomainMemoryLimits(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(TestDomainMemoryLimits,
- cls).getClsTestClient().getApiClient()
+ cls.testClient = super(TestDomainMemoryLimits, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.services["mode"] = cls.zone.networktype
cls.template = get_template(
@@ -234,7 +235,7 @@ class TestDomainMemoryLimits(cloudstackTestCase):
self.debug("Creating an instance with service offering: %s" %
self.service_offering.name)
- api_client = self.testClient.createUserApiClient(
+ api_client = self.testClient.getUserApiClient(
UserName=self.account.name,
DomainName=self.account.domain)
@@ -371,7 +372,7 @@ class TestDomainMemoryLimits(cloudstackTestCase):
self.debug("Creating an instance with service offering: %s" %
self.service_offering.name)
- api_client = self.testClient.createUserApiClient(
+ api_client = self.testClient.getUserApiClient(
UserName=self.account.name,
DomainName=self.account.domain)
@@ -432,7 +433,7 @@ class TestDomainMemoryLimits(cloudstackTestCase):
self.debug("Creating an instance with service offering: %s" %
self.service_offering.name)
- api_client = self.testClient.createUserApiClient(
+ api_client = self.testClient.getUserApiClient(
UserName=self.account.name,
DomainName=self.account.domain)
@@ -492,7 +493,7 @@ class TestDomainMemoryLimits(cloudstackTestCase):
self.debug("Creating an instance with service offering: %s" %
self.service_offering.name)
- api_client = self.testClient.createUserApiClient(
+ api_client = self.testClient.getUserApiClient(
UserName=self.account.name,
DomainName=self.account.domain)
@@ -524,12 +525,13 @@ class TestMultipleChildDomainsMemory(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(TestMultipleChildDomainsMemory,
- cls).getClsTestClient().getApiClient()
+ cls.testClient = super(TestMultipleChildDomainsMemory, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.services["mode"] = cls.zone.networktype
cls.template = get_template(
@@ -709,11 +711,11 @@ class TestMultipleChildDomainsMemory(cloudstackTestCase):
self.debug("Setting up account and domain hierarchy")
self.setupAccounts()
- api_client_cadmin_1 = self.testClient.createUserApiClient(
+ api_client_cadmin_1 = self.testClient.getUserApiClient(
UserName=self.cadmin_1.name,
DomainName=self.cadmin_1.domain)
- api_client_cadmin_2 = self.testClient.createUserApiClient(
+ api_client_cadmin_2 = self.testClient.getUserApiClient(
UserName=self.cadmin_2.name,
DomainName=self.cadmin_2.domain)
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/component/test_mm_max_limits.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_mm_max_limits.py b/test/integration/component/test_mm_max_limits.py
index 52ff98e..34d4147 100644
--- a/test/integration/component/test_mm_max_limits.py
+++ b/test/integration/component/test_mm_max_limits.py
@@ -19,7 +19,7 @@
# Import Local Modules
from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import cloudstackTestCase, unittest
-from marvin.integration.lib.base import (
+from marvin.lib.base import (
Account,
ServiceOffering,
VirtualMachine,
@@ -27,11 +27,11 @@ from marvin.integration.lib.base import (
Domain,
Project
)
-from marvin.integration.lib.common import (get_domain,
+from marvin.lib.common import (get_domain,
get_zone,
get_template
)
-from marvin.integration.lib.utils import cleanup_resources
+from marvin.lib.utils import cleanup_resources
class Services:
"""Test memory resource limit services
@@ -88,12 +88,13 @@ class TestMaxMemoryLimits(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(TestMaxMemoryLimits,
- cls).getClsTestClient().getApiClient()
+ cls.testClient = super(TestMaxMemoryLimits, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.services["mode"] = cls.zone.networktype
cls.template = get_template(
@@ -253,7 +254,7 @@ class TestMaxMemoryLimits(cloudstackTestCase):
self.debug("Setting up account and domain hierarchy")
self.setupAccounts(account_limit=8, domain_limit=4)
- api_client = self.testClient.createUserApiClient(
+ api_client = self.testClient.getUserApiClient(
UserName=self.child_do_admin.name,
DomainName=self.child_do_admin.domain)
@@ -280,7 +281,7 @@ class TestMaxMemoryLimits(cloudstackTestCase):
self.debug("Setting up account and domain hierarchy")
self.setupAccounts(account_limit=7, domain_limit=14)
- api_client = self.testClient.createUserApiClient(
+ api_client = self.testClient.getUserApiClient(
UserName=self.child_do_admin.name,
DomainName=self.child_do_admin.domain)
@@ -310,7 +311,7 @@ class TestMaxMemoryLimits(cloudstackTestCase):
self.debug("Setting up account and domain hierarchy")
self.setupAccounts(account_limit=8,domain_limit=8, project_limit=4)
- api_client = self.testClient.createUserApiClient(
+ api_client = self.testClient.getUserApiClient(
UserName=self.child_do_admin.name,
DomainName=self.child_do_admin.domain)
@@ -334,7 +335,7 @@ class TestMaxMemoryLimits(cloudstackTestCase):
self.debug("Setting up account and domain hierarchy")
self.setupAccounts(account_limit=6, project_limit=12, domain_limit=12)
- api_client = self.testClient.createUserApiClient(
+ api_client = self.testClient.getUserApiClient(
UserName=self.child_do_admin.name,
DomainName=self.child_do_admin.domain)
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/component/test_mm_project_limits.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_mm_project_limits.py b/test/integration/component/test_mm_project_limits.py
index 00c0ab4..593b2b6 100644
--- a/test/integration/component/test_mm_project_limits.py
+++ b/test/integration/component/test_mm_project_limits.py
@@ -19,21 +19,21 @@
# Import Local Modules
from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import cloudstackTestCase, unittest
-from marvin.integration.lib.base import (
+from marvin.lib.base import (
Account,
ServiceOffering,
VirtualMachine,
Domain,
Project
)
-from marvin.integration.lib.common import (get_domain,
+from marvin.lib.common import (get_domain,
get_zone,
get_template,
wait_for_cleanup,
findSuitableHostForMigration,
get_resource_type
)
-from marvin.integration.lib.utils import cleanup_resources
+from marvin.lib.utils import cleanup_resources
from marvin.codes import ERROR_NO_HOST_FOR_MIGRATION
class Services:
@@ -91,12 +91,13 @@ class TestProjectsMemoryLimits(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(TestProjectsMemoryLimits,
- cls).getClsTestClient().getApiClient()
+ cls.testClient = super(TestProjectsMemoryLimits, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.services["mode"] = cls.zone.networktype
cls.template = get_template(
@@ -137,7 +138,7 @@ class TestProjectsMemoryLimits(cloudstackTestCase):
self.debug("Setting up account and domain hierarchy")
self.setupProjectAccounts()
- api_client = self.testClient.createUserApiClient(
+ api_client = self.testClient.getUserApiClient(
UserName=self.admin.name,
DomainName=self.admin.domain)
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/component/test_multiple_ip_ranges.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_multiple_ip_ranges.py b/test/integration/component/test_multiple_ip_ranges.py
index aae90c4..32c39f7 100644
--- a/test/integration/component/test_multiple_ip_ranges.py
+++ b/test/integration/component/test_multiple_ip_ranges.py
@@ -18,10 +18,10 @@
"""
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
-from marvin.cloudstackException import cloudstackAPIException
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.cloudstackException import CloudstackAPIException
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
from netaddr import *
from nose.plugins.attrib import attr
@@ -78,12 +78,14 @@ class TestMultipleIpRanges(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(TestMultipleIpRanges, cls).getClsTestClient().getApiClient()
+ cls.testClient = super(TestMultipleIpRanges, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
- cls.pod = get_pod(cls.api_client, cls.zone.id, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
+ cls.pod = get_pod(cls.api_client, cls.zone.id)
cls.services['mode'] = cls.zone.networktype
cls.services["domainid"] = cls.domain.id
cls.services["zoneid"] = cls.zone.id
@@ -296,7 +298,7 @@ class TestMultipleIpRanges(cloudstackTestCase):
#listing vlan ip ranges with the id should through exception , if not mark the test case as failed
try:
new_vlan.list(self.apiclient, id=new_vlan.vlan.id)
- except cloudstackAPIException as cs:
+ except CloudstackAPIException as cs:
self.debug(cs.errorMsg)
self.assertTrue(cs.errorMsg.find("entity does not exist")>0, msg="Failed to delete IP range")
return
@@ -387,7 +389,7 @@ class TestMultipleIpRanges(cloudstackTestCase):
self.debug("Adding overlapped ip range")
try:
new_vlan2 = PublicIpRange.create(self.apiclient, self.services["vlan_ip_range"])
- except cloudstackAPIException as cs:
+ except CloudstackAPIException as cs:
self.debug(cs.errorMsg)
self.assertTrue(cs.errorMsg.find("already has IPs that overlap with the new range")>0, msg="Fail:CS allowed adding overlapped ip ranges in guest cidr")
return
@@ -443,7 +445,7 @@ class TestMultipleIpRanges(cloudstackTestCase):
self.debug("Adding ip range overlapped with two cidrs")
try:
new_vlan3 = PublicIpRange.create(self.apiclient, self.services["vlan_ip_range"])
- except cloudstackAPIException as cs:
+ except CloudstackAPIException as cs:
self.debug(cs.errorMsg)
self.assertTrue(cs.errorMsg.find("already has IPs that overlap with the new range")>0, msg="Fail:CS allowed adding overlapped ip ranges in guest cidr")
return
@@ -496,7 +498,7 @@ class TestMultipleIpRanges(cloudstackTestCase):
self.debug("Adding IP range super set to existing CIDR")
try:
new_vlan2 = PublicIpRange.create(self.apiclient, self.services["vlan_ip_range"])
- except cloudstackAPIException as cs:
+ except CloudstackAPIException as cs:
self.debug(cs.errorMsg)
self.assertTrue(cs.errorMsg.find("superset")>0, msg="Fail: CS allowed adding ip range superset to existing CIDR")
return
@@ -549,7 +551,7 @@ class TestMultipleIpRanges(cloudstackTestCase):
self.debug("Adding ip range subset to existing cidr")
try:
new_vlan2 = PublicIpRange.create(self.apiclient, self.services["vlan_ip_range"])
- except cloudstackAPIException as cs:
+ except CloudstackAPIException as cs:
self.debug(cs.errorMsg)
self.assertTrue(cs.errorMsg.find("subset")>0, msg="Fail: CS allowed adding ip range subset to existing CIDR")
return
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/component/test_multiple_ips_per_nic.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_multiple_ips_per_nic.py b/test/integration/component/test_multiple_ips_per_nic.py
index dcbb453..2739637 100644
--- a/test/integration/component/test_multiple_ips_per_nic.py
+++ b/test/integration/component/test_multiple_ips_per_nic.py
@@ -23,32 +23,14 @@
Design Document: https://cwiki.apache.org/confluence/display/CLOUDSTACK/Multiple+IP+address+per+NIC
"""
from marvin.cloudstackTestCase import cloudstackTestCase
-from marvin.integration.lib.utils import (cleanup_resources,
- validateList,
- random_gen)
-from marvin.integration.lib.base import (Account,
- ServiceOffering,
- Network,
- VirtualMachine,
- VpcOffering,
- VPC,
- NIC,
- Domain,
- PublicIPAddress,
- StaticNATRule,
- FireWallRule,
- NATRule)
-from marvin.integration.lib.common import (get_domain,
- get_zone,
- get_template,
- get_free_vlan,
- setSharedNetworkParams,
- createEnabledNetworkOffering,
- shouldTestBeSkipped)
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
from nose.plugins.attrib import attr
from marvin.codes import PASS, ISOLATED_NETWORK, VPC_NETWORK, SHARED_NETWORK, FAIL
from ddt import ddt, data
+import time
def createNetwork(self, networkType):
"""Create a network of given type (isolated/shared/isolated in VPC)"""
@@ -137,21 +119,23 @@ class TestBasicOperations(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cloudstackTestClient = super(TestBasicOperations,cls).getClsTestClient()
- cls.api_client = cloudstackTestClient.getApiClient()
+ cls.testClient = super(TestBasicOperations, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
# Fill services from the external config file
- cls.services = cloudstackTestClient.getConfigParser().parsedDict
+ cls.services = cls.testClient.getParsedTestDataConfig()
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
- cls.mode = str(cls.zone.networktype).lower()
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.template = get_template(
cls.api_client,
cls.zone.id,
cls.services["ostype"]
)
+ if cls.template == FAILED:
+ assert False, "get_template() failed to return template with description %s" % cls.services["ostype"]
+
cls.services["virtual_machine"]["zoneid"] = cls.zone.id
cls.services["virtual_machine"]["template"] = cls.template.id
cls.service_offering = ServiceOffering.create(
@@ -486,21 +470,23 @@ class TestNetworkRules(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cloudstackTestClient = super(TestNetworkRules,cls).getClsTestClient()
- cls.api_client = cloudstackTestClient.getApiClient()
+ cls.testClient = super(TestNetworkRules, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
# Fill services from the external config file
- cls.services = cloudstackTestClient.getConfigParser().parsedDict
+ cls.services = cls.testClient.getParsedTestDataConfig()
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
- cls.mode = str(cls.zone.networktype).lower()
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.template = get_template(
cls.api_client,
cls.zone.id,
cls.services["ostype"]
)
+ if cls.template == FAILED:
+ assert False, "get_template() failed to return template with description %s" % cls.services["ostype"]
+
cls.services["virtual_machine"]["zoneid"] = cls.zone.id
cls.services["virtual_machine"]["template"] = cls.template.id
cls.service_offering = ServiceOffering.create(
@@ -851,3 +837,439 @@ class TestNetworkRules(cloudstackTestCase):
public_ip.delete(self.apiclient)
return
+
+@ddt
+class TestVmNetworkOperations(cloudstackTestCase):
+ """Test VM and Network operations with network rules created on secondary IP
+ """
+
+ @classmethod
+ def setUpClass(cls):
+ cls.testClient = super(TestVmNetworkOperations, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
+ # Fill services from the external config file
+ cls.services = cls.testClient.getParsedTestDataConfig()
+
+ # Get Zone, Domain and templates
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
+ cls.template = get_template(
+ cls.api_client,
+ cls.zone.id,
+ cls.services["ostype"]
+ )
+ if cls.template == FAILED:
+ assert False, "get_template() failed to return template with description %s" % cls.services["ostype"]
+ cls.services["virtual_machine"]["zoneid"] = cls.zone.id
+ cls.services["virtual_machine"]["template"] = cls.template.id
+ cls.service_offering = ServiceOffering.create(
+ cls.api_client,
+ cls.services["service_offering"]
+ )
+ cls._cleanup = [cls.service_offering]
+ cls.services["shared_network_offering"]["specifyVlan"] = "True"
+ cls.services["shared_network_offering"]["specifyIpRanges"] = "True"
+
+ cls.shared_network_offering = CreateEnabledNetworkOffering(cls.api_client, cls.services["shared_network_offering"])
+ cls._cleanup.append(cls.shared_network_offering)
+
+ if cls.mode == "advanced":
+ cls.isolated_network_offering = CreateEnabledNetworkOffering(cls.api_client, cls.services["isolated_network_offering"])
+ cls._cleanup.append(cls.isolated_network_offering)
+ cls.isolated_network_offering_vpc = CreateEnabledNetworkOffering(cls.api_client, cls.services["nw_offering_isolated_vpc"])
+ cls._cleanup.append(cls.isolated_network_offering_vpc)
+ cls.vpc_off = VpcOffering.create(cls.api_client, cls.services["vpc_offering"])
+ cls.vpc_off.update(cls.api_client, state='Enabled')
+ cls._cleanup.append(cls.vpc_off)
+ return
+
+ @classmethod
+ def tearDownClass(cls):
+ try:
+ # Cleanup resources used
+ cleanup_resources(cls.api_client, cls._cleanup)
+ except Exception as e:
+ raise Exception("Warning: Exception during cleanup : %s" % e)
+ return
+
+ def setUp(self):
+ self.apiclient = self.testClient.getApiClient()
+ self.dbclient = self.testClient.getDbConnection()
+ self.cleanup = [ ]
+ return
+
+ def tearDown(self):
+ try:
+ # Clean up, terminate the resources created
+ cleanup_resources(self.apiclient, self.cleanup)
+ except Exception as e:
+ raise Exception("Warning: Exception during cleanup : %s" % e)
+ return
+
+ def VerifyStaticNatForPublicIp(self, ipaddressid, natrulestatus):
+ """ List public IP and verify that NAT rule status for the IP is as desired """
+
+ publiciplist = PublicIPAddress.list(self.apiclient, id=ipaddressid, listall=True)
+ self.assertEqual(validateList(publiciplist)[0], PASS, "Public IP list validation failed")
+ self.assertEqual(publiciplist[0].isstaticnat, natrulestatus, "isstaticnat should be %s, it is %s" %
+ (natrulestatus, publiciplist[0].isstaticnat))
+
+ return
+
+ @data(ISOLATED_NETWORK, SHARED_NETWORK, VPC_NETWORK)
+ @attr(tags=["advanced"])
+ def test_delete_vm(self, value):
+ """ Test delete VM and verify network rules are cleaned up"""
+
+ # Steps:
+ # 1. Create Account and create network in it (isoalted/ shared/ vpc)
+ # 2. Deploy a VM in this network and account
+ # 3. Add 2 secondary IPs to the default nic of VM
+ # 4. Acquire 2 public IPs in the network
+ # 5. For 1st public IP create nat rule to 1st private IP, for 2nd public IP, create
+ # static nat rule to 2nd private IP
+ # 6. Destroy the virtual machine
+ # 7. Verify that nat rule does not exist and static nat is not enabled for
+ # secondary IP
+
+ self.account = Account.create(self.apiclient,self.services["account"],domainid=self.domain.id)
+ self.cleanup.append(self.account)
+
+ network = createNetwork(self, value)
+
+ try:
+ virtual_machine = VirtualMachine.create(self.apiclient,self.services["virtual_machine"],
+ networkids=[network.id],serviceofferingid=self.service_offering.id,
+ accountid=self.account.name,domainid=self.account.domainid)
+ except Exception as e:
+ self.fail("vm creation failed: %s" % e)
+
+ # Add secondary IPs to default NIC of VM
+ try:
+ ipaddress_1 = NIC.addIp(self.apiclient, id=virtual_machine.nic[0].id)
+ ipaddress_2 = NIC.addIp(self.apiclient, id=virtual_machine.nic[0].id)
+ except Exception as e:
+ self.fail("Failed while adding secondary IP to NIC of vm %s" % virtual_machine.id)
+
+ # Acquire public IP addresses in the network
+ try:
+ public_ip_1 = PublicIPAddress.create(self.api_client,accountid=self.account.name,
+ zoneid=self.zone.id,domainid=self.account.domainid,
+ networkid=network.id, vpcid = network.vpcid if value == VPC_NETWORK else None)
+
+ public_ip_2 = PublicIPAddress.create(self.api_client,accountid=self.account.name,
+ zoneid=self.zone.id,domainid=self.account.domainid,
+ networkid=network.id, vpcid = network.vpcid if value == VPC_NETWORK else None)
+ except Exception as e:
+ self.fail("Exception while acquiring public ip address: %s" % e)
+
+ # Create Firewall and natrule for 1st IP and static nat rule for 2nd IP
+ if value != VPC_NETWORK:
+ FireWallRule.create(self.apiclient,ipaddressid=public_ip_1.ipaddress.id,
+ protocol='TCP', cidrlist=[self.services["fwrule"]["cidr"]],
+ startport=self.services["fwrule"]["startport"],endport=self.services["fwrule"]["endport"])
+
+ natrule = NATRule.create(self.api_client, virtual_machine,
+ self.services["natrule"],ipaddressid=public_ip_1.ipaddress.id,
+ networkid=network.id, vmguestip = ipaddress_1.ipaddress)
+
+ StaticNATRule.enable(self.apiclient, public_ip_2.ipaddress.id, virtual_machine.id,
+ network.id, vmguestip=ipaddress_2.ipaddress)
+
+ # Delete VM
+ virtual_machine.delete(self.apiclient)
+
+ # Wait for VMs to expunge
+ wait_for_cleanup(self.api_client, ["expunge.delay", "expunge.interval"])
+
+ # Make sure the VM is expunged
+ retriesCount = 20
+ while True:
+ vms = VirtualMachine.list(self.apiclient, id=virtual_machine.id)
+ if vms is None:
+ break
+ elif retriesCount == 0:
+ self.fail("Failed to expunge vm even after 20 minutes")
+ time.sleep(60)
+ retriesCount -= 1
+
+ # Try to list nat rule
+ with self.assertRaises(Exception):
+ NATRule.list(self.apiclient, id=natrule.id, listall=True)
+
+ # Verify static nat rule is no longer enabled
+ self.VerifyStaticNatForPublicIp(public_ip_2.ipaddress.id, False)
+ return
+
+ @data(ISOLATED_NETWORK, SHARED_NETWORK, VPC_NETWORK)
+ @attr(tags=["advanced"])
+ def test_recover_vm(self, value):
+ """ Test recover VM operation with VM having secondary IPs"""
+
+ # Steps:
+ # 1. Create Account and create network in it (isoalted/ shared/ vpc)
+ # 2. Deploy a VM in this network and account
+ # 3. Add 2 secondary IPs to the default nic of VM
+ # 4. Acquire 2 public IPs in the network
+ # 5. For 1st public IP create nat rule to 1st private IP, for 2nd public IP, create
+ # static nat rule to 2nd private IP
+ # 6. Destroy the virtual machine and recover it
+ # 7. Verify that nat and static nat rules exist
+
+ self.account = Account.create(self.apiclient,self.services["account"],domainid=self.domain.id)
+ self.cleanup.append(self.account)
+
+ network = createNetwork(self, value)
+
+ try:
+ virtual_machine = VirtualMachine.create(self.apiclient,self.services["virtual_machine"],
+ networkids=[network.id],serviceofferingid=self.service_offering.id,
+ accountid=self.account.name,domainid=self.account.domainid)
+ except Exception as e:
+ self.fail("vm creation failed: %s" % e)
+
+ try:
+ ipaddress_1 = NIC.addIp(self.apiclient, id=virtual_machine.nic[0].id)
+ ipaddress_2 = NIC.addIp(self.apiclient, id=virtual_machine.nic[0].id)
+ except Exception as e:
+ self.fail("Failed while adding secondary IP to NIC of vm %s" % virtual_machine.id)
+
+ try:
+ public_ip_1 = PublicIPAddress.create(self.api_client,accountid=self.account.name,
+ zoneid=self.zone.id,domainid=self.account.domainid,
+ networkid=network.id, vpcid = network.vpcid if value == VPC_NETWORK else None)
+
+ public_ip_2 = PublicIPAddress.create(self.api_client,accountid=self.account.name,
+ zoneid=self.zone.id,domainid=self.account.domainid,
+ networkid=network.id, vpcid = network.vpcid if value == VPC_NETWORK else None)
+ except Exception as e:
+ self.fail("Exception while acquiring public ip address: %s" % e)
+
+ if value != VPC_NETWORK:
+ FireWallRule.create(self.apiclient,ipaddressid=public_ip_1.ipaddress.id,
+ protocol='TCP', cidrlist=[self.services["fwrule"]["cidr"]],
+ startport=self.services["fwrule"]["startport"],endport=self.services["fwrule"]["endport"])
+
+ natrule = NATRule.create(self.api_client, virtual_machine,
+ self.services["natrule"],ipaddressid=public_ip_1.ipaddress.id,
+ networkid=network.id, vmguestip = ipaddress_1.ipaddress)
+
+ StaticNATRule.enable(self.apiclient, public_ip_2.ipaddress.id, virtual_machine.id,
+ network.id, vmguestip=ipaddress_2.ipaddress)
+
+ virtual_machine.delete(self.apiclient)
+ virtual_machine.recover(self.apiclient)
+
+ retriesCount = 10
+ while True:
+ vms = VirtualMachine.list(self.apiclient, id=virtual_machine.id)
+ self.assertEqual(validateList(vms)[0], PASS, "vms list validation failed")
+ if str(vms[0].state).lower() == "stopped":
+ break
+ elif retriesCount == 0:
+ self.fail("Failed to recover vm even after 10 mins")
+ time.sleep(60)
+ retriesCount -= 1
+
+ natrules = NATRule.list(self.apiclient, id=natrule.id, listall=True)
+ self.assertEqual(validateList(natrules)[0], PASS, "nat rules validation failed")
+
+ self.VerifyStaticNatForPublicIp(public_ip_2.ipaddress.id, True)
+
+ return
+
+ @data(ISOLATED_NETWORK, SHARED_NETWORK, VPC_NETWORK)
+ @attr(tags=["advanced"])
+ def test_network_restart_cleanup_true(self, value):
+ """Test network restart (cleanup True) with VM having secondary IPs and related network rules"""
+
+ # Steps:
+ # 1. Create Account and create network in it (isoalted/ shared/ vpc)
+ # 2. Deploy a VM in this network and account
+ # 3. Add 2 secondary IPs to the default nic of VM
+ # 4. Acquire 2 public IPs in the network
+ # 5. For 1st public IP create nat rule to 1st private IP, for 2nd public IP, create
+ # static nat rule to 2nd private IP
+ # 6. Restart the network with cleanup option True
+ # 7. Verify that nat and static nat rules exist after network restart
+
+ self.account = Account.create(self.apiclient,self.services["account"],domainid=self.domain.id)
+ self.cleanup.append(self.account)
+
+ network = createNetwork(self, value)
+
+ try:
+ virtual_machine = VirtualMachine.create(self.apiclient,self.services["virtual_machine"],
+ networkids=[network.id],serviceofferingid=self.service_offering.id,
+ accountid=self.account.name,domainid=self.account.domainid)
+ except Exception as e:
+ self.fail("vm creation failed: %s" % e)
+
+ try:
+ ipaddress_1 = NIC.addIp(self.apiclient, id=virtual_machine.nic[0].id)
+ ipaddress_2 = NIC.addIp(self.apiclient, id=virtual_machine.nic[0].id)
+ except Exception as e:
+ self.fail("Failed while adding secondary IP to NIC of vm %s" % virtual_machine.id)
+
+ try:
+ public_ip_1 = PublicIPAddress.create(self.api_client,accountid=self.account.name,
+ zoneid=self.zone.id,domainid=self.account.domainid,
+ networkid=network.id, vpcid = network.vpcid if value == VPC_NETWORK else None)
+
+ public_ip_2 = PublicIPAddress.create(self.api_client,accountid=self.account.name,
+ zoneid=self.zone.id,domainid=self.account.domainid,
+ networkid=network.id, vpcid = network.vpcid if value == VPC_NETWORK else None)
+ except Exception as e:
+ self.fail("Exception while acquiring public ip address: %s" % e)
+
+ if value != VPC_NETWORK:
+ FireWallRule.create(self.apiclient,ipaddressid=public_ip_1.ipaddress.id,
+ protocol='TCP', cidrlist=[self.services["fwrule"]["cidr"]],
+ startport=self.services["fwrule"]["startport"],endport=self.services["fwrule"]["endport"])
+
+ natrule = NATRule.create(self.api_client, virtual_machine,
+ self.services["natrule"],ipaddressid=public_ip_1.ipaddress.id,
+ networkid=network.id, vmguestip = ipaddress_1.ipaddress)
+
+ StaticNATRule.enable(self.apiclient, public_ip_2.ipaddress.id, virtual_machine.id,
+ network.id, vmguestip=ipaddress_2.ipaddress)
+
+ network.restart(self.apiclient, cleanup=True)
+
+ natrulelist = NATRule.list(self.apiclient, id=natrule.id, listall=True)
+ self.assertEqual(validateList(natrulelist)[0], PASS, "nat rules list validation failed")
+
+ self.VerifyStaticNatForPublicIp(public_ip_2.ipaddress.id, True)
+ return
+
+ @data(ISOLATED_NETWORK, SHARED_NETWORK, VPC_NETWORK)
+ @attr(tags=["advanced"])
+ def test_network_restart_cleanup_false(self, value):
+ """Test network restart (cleanup True) with VM having secondary IPs and related network rules"""
+
+ # Steps:
+ # 1. Create Account and create network in it (isoalted/ shared/ vpc)
+ # 2. Deploy a VM in this network and account
+ # 3. Add 2 secondary IPs to the default nic of VM
+ # 4. Acquire 2 public IPs in the network
+ # 5. For 1st public IP create nat rule to 1st private IP, for 2nd public IP, create
+ # static nat rule to 2nd private IP
+ # 6. Restart the network with cleanup option False
+ # 7. Verify that nat and static nat rules exist after network restart
+
+ self.account = Account.create(self.apiclient,self.services["account"],domainid=self.domain.id)
+ self.cleanup.append(self.account)
+
+ network = createNetwork(self, value)
+
+ try:
+ virtual_machine = VirtualMachine.create(self.apiclient,self.services["virtual_machine"],
+ networkids=[network.id],serviceofferingid=self.service_offering.id,
+ accountid=self.account.name,domainid=self.account.domainid)
+ except Exception as e:
+ self.fail("vm creation failed: %s" % e)
+
+ try:
+ ipaddress_1 = NIC.addIp(self.apiclient, id=virtual_machine.nic[0].id)
+ ipaddress_2 = NIC.addIp(self.apiclient, id=virtual_machine.nic[0].id)
+ except Exception as e:
+ self.fail("Failed while adding secondary IP to NIC of vm %s" % virtual_machine.id)
+
+ try:
+ public_ip_1 = PublicIPAddress.create(self.api_client,accountid=self.account.name,
+ zoneid=self.zone.id,domainid=self.account.domainid,
+ networkid=network.id, vpcid = network.vpcid if value == VPC_NETWORK else None)
+
+ public_ip_2 = PublicIPAddress.create(self.api_client,accountid=self.account.name,
+ zoneid=self.zone.id,domainid=self.account.domainid,
+ networkid=network.id, vpcid = network.vpcid if value == VPC_NETWORK else None)
+ except Exception as e:
+ self.fail("Exception while acquiring public ip address: %s" % e)
+
+ if value != VPC_NETWORK:
+ FireWallRule.create(self.apiclient,ipaddressid=public_ip_1.ipaddress.id,
+ protocol='TCP', cidrlist=[self.services["fwrule"]["cidr"]],
+ startport=self.services["fwrule"]["startport"],endport=self.services["fwrule"]["endport"])
+
+ natrule = NATRule.create(self.api_client, virtual_machine,
+ self.services["natrule"],ipaddressid=public_ip_1.ipaddress.id,
+ networkid=network.id, vmguestip = ipaddress_1.ipaddress)
+
+ StaticNATRule.enable(self.apiclient, public_ip_2.ipaddress.id, virtual_machine.id,
+ network.id, vmguestip=ipaddress_2.ipaddress)
+
+ network.restart(self.apiclient, cleanup=False)
+
+ natrulelist = NATRule.list(self.apiclient, id=natrule.id, listall=True)
+ self.assertEqual(validateList(natrulelist)[0], PASS, "nat rules list validation failed")
+
+ self.VerifyStaticNatForPublicIp(public_ip_2.ipaddress.id, True)
+ return
+
+ @data(ISOLATED_NETWORK, SHARED_NETWORK, VPC_NETWORK)
+ @attr(tags=["advanced"])
+ def test_reboot_router_VM(self, value):
+ """ Test reboot router and persistence of network rules"""
+
+ # Steps:
+ # 1. Create Account and create network in it (isoalted/ shared/ vpc)
+ # 2. Deploy a VM in this network and account
+ # 3. Add 2 secondary IPs to the default nic of VM
+ # 4. Acquire 2 public IPs in the network
+ # 5. For 1st public IP create nat rule to 1st private IP, for 2nd public IP, create
+ # static nat rule to 2nd private IP
+ # 6. Reboot router VM
+ # 7. Verify that nat and static nat rules exist after router restart
+
+ self.account = Account.create(self.apiclient,self.services["account"],domainid=self.domain.id)
+ self.cleanup.append(self.account)
+
+ network = createNetwork(self, value)
+
+ try:
+ virtual_machine = VirtualMachine.create(self.apiclient,self.services["virtual_machine"],
+ networkids=[network.id],serviceofferingid=self.service_offering.id,
+ accountid=self.account.name,domainid=self.account.domainid)
+ except Exception as e:
+ self.fail("vm creation failed: %s" % e)
+
+ try:
+ ipaddress_1 = NIC.addIp(self.apiclient, id=virtual_machine.nic[0].id)
+ ipaddress_2 = NIC.addIp(self.apiclient, id=virtual_machine.nic[0].id)
+ except Exception as e:
+ self.fail("Failed while adding secondary IP to NIC of vm %s" % virtual_machine.id)
+
+ try:
+ public_ip_1 = PublicIPAddress.create(self.api_client,accountid=self.account.name,
+ zoneid=self.zone.id,domainid=self.account.domainid,
+ networkid=network.id, vpcid = network.vpcid if value == VPC_NETWORK else None)
+
+ public_ip_2 = PublicIPAddress.create(self.api_client,accountid=self.account.name,
+ zoneid=self.zone.id,domainid=self.account.domainid,
+ networkid=network.id, vpcid = network.vpcid if value == VPC_NETWORK else None)
+ except Exception as e:
+ self.fail("Exception while acquiring public ip address: %s" % e)
+
+ if value != VPC_NETWORK:
+ FireWallRule.create(self.apiclient,ipaddressid=public_ip_1.ipaddress.id,
+ protocol='TCP', cidrlist=[self.services["fwrule"]["cidr"]],
+ startport=self.services["fwrule"]["startport"],endport=self.services["fwrule"]["endport"])
+
+ natrule = NATRule.create(self.api_client, virtual_machine,
+ self.services["natrule"],ipaddressid=public_ip_1.ipaddress.id,
+ networkid=network.id, vmguestip = ipaddress_1.ipaddress)
+
+ StaticNATRule.enable(self.apiclient, public_ip_2.ipaddress.id, virtual_machine.id,
+ network.id, vmguestip=ipaddress_2.ipaddress)
+
+ routers = Router.list(self.apiclient, networkid=network.id, listall=True)
+ self.assertEqual(validateList(routers)[0], PASS, "routers list validation failed")
+
+ Router.reboot(self.apiclient, id=routers[0].id)
+
+ natrulelist = NATRule.list(self.apiclient, id=natrule.id, listall=True)
+ self.assertEqual(validateList(natrulelist)[0], PASS, "nat rules list validation failed")
+
+ self.VerifyStaticNatForPublicIp(public_ip_2.ipaddress.id, True)
+ return
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/component/test_netscaler_configs.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_netscaler_configs.py b/test/integration/component/test_netscaler_configs.py
index 98613fe..592b351 100644
--- a/test/integration/component/test_netscaler_configs.py
+++ b/test/integration/component/test_netscaler_configs.py
@@ -22,9 +22,9 @@ import marvin
from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
from marvin.sshClient import SshClient
import datetime
@@ -156,14 +156,13 @@ class TestAddNetScaler(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(
- TestAddNetScaler,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestAddNetScaler, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls._cleanup = []
return
@@ -282,14 +281,13 @@ class TestInvalidParametersNetscaler(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(
- TestInvalidParametersNetscaler,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestInvalidParametersNetscaler, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls._cleanup = []
return
@@ -526,14 +524,13 @@ class TestNetScalerDedicated(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(
- TestNetScalerDedicated,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestNetScalerDedicated, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.template = get_template(
cls.api_client,
cls.zone.id,
@@ -749,14 +746,13 @@ class TestNetScalerShared(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(
- TestNetScalerShared,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestNetScalerShared, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.template = get_template(
cls.api_client,
cls.zone.id,
@@ -992,14 +988,13 @@ class TestNetScalerCustomCapacity(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(
- TestNetScalerCustomCapacity,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestNetScalerCustomCapacity, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.template = get_template(
cls.api_client,
cls.zone.id,
@@ -1265,14 +1260,13 @@ class TestNetScalerNoCapacity(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(
- TestNetScalerNoCapacity,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestNetScalerNoCapacity, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.template = get_template(
cls.api_client,
cls.zone.id,
@@ -1539,14 +1533,13 @@ class TestGuestNetworkWithNetScaler(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(
- TestGuestNetworkWithNetScaler,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestGuestNetworkWithNetScaler, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.template = get_template(
cls.api_client,
cls.zone.id,
@@ -2096,14 +2089,13 @@ class TestGuestNetworkShutDown(cloudstackTestCase):
@classmethod
def setUpClass(cls):
cls._cleanup = []
- cls.api_client = super(
- TestGuestNetworkShutDown,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestGuestNetworkShutDown, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.template = get_template(
cls.api_client,
cls.zone.id,
@@ -2502,14 +2494,13 @@ class TestServiceProvider(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(
- TestServiceProvider,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestServiceProvider, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.template = get_template(
cls.api_client,
cls.zone.id,
@@ -2817,14 +2808,13 @@ class TestDeleteNetscaler(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(
- TestDeleteNetscaler,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestDeleteNetscaler, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.template = get_template(
cls.api_client,
cls.zone.id,
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/component/test_netscaler_lb.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_netscaler_lb.py b/test/integration/component/test_netscaler_lb.py
index 26df545..732f0f9 100644
--- a/test/integration/component/test_netscaler_lb.py
+++ b/test/integration/component/test_netscaler_lb.py
@@ -22,9 +22,9 @@ import marvin
from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
from marvin.sshClient import SshClient
import datetime
@@ -150,14 +150,13 @@ class TestLbSourceNat(cloudstackTestCase):
@classmethod
def setUpClass(cls):
cls._cleanup = []
- cls.api_client = super(
- TestLbSourceNat,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestLbSourceNat, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.template = get_template(
cls.api_client,
cls.zone.id,
@@ -359,14 +358,13 @@ class TestLbOnIpWithPf(cloudstackTestCase):
@classmethod
def setUpClass(cls):
cls._cleanup = []
- cls.api_client = super(
- TestLbOnIpWithPf,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestLbOnIpWithPf, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.template = get_template(
cls.api_client,
cls.zone.id,
@@ -572,14 +570,13 @@ class TestPfOnIpWithLb(cloudstackTestCase):
@classmethod
def setUpClass(cls):
cls._cleanup = []
- cls.api_client = super(
- TestPfOnIpWithLb,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestPfOnIpWithLb, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.template = get_template(
cls.api_client,
cls.zone.id,
@@ -786,14 +783,13 @@ class TestLbOnNonSourceNat(cloudstackTestCase):
@classmethod
def setUpClass(cls):
cls._cleanup = []
- cls.api_client = super(
- TestLbOnNonSourceNat,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestLbOnNonSourceNat, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.template = get_template(
cls.api_client,
cls.zone.id,
@@ -1003,14 +999,13 @@ class TestAddMultipleVmsLb(cloudstackTestCase):
@classmethod
def setUpClass(cls):
cls._cleanup = []
- cls.api_client = super(
- TestAddMultipleVmsLb,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestAddMultipleVmsLb, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.template = get_template(
cls.api_client,
cls.zone.id,
@@ -1282,14 +1277,13 @@ class TestMultipleLbRules(cloudstackTestCase):
@classmethod
def setUpClass(cls):
cls._cleanup = []
- cls.api_client = super(
- TestMultipleLbRules,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestMultipleLbRules, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.template = get_template(
cls.api_client,
cls.zone.id,
@@ -1601,14 +1595,13 @@ class TestMultipleLbRulesSameIp(cloudstackTestCase):
@classmethod
def setUpClass(cls):
cls._cleanup = []
- cls.api_client = super(
- TestMultipleLbRulesSameIp,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestMultipleLbRulesSameIp, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.template = get_template(
cls.api_client,
cls.zone.id,
@@ -1926,14 +1919,13 @@ class TestLoadBalancingRule(cloudstackTestCase):
@classmethod
def setUpClass(cls):
cls._cleanup = []
- cls.api_client = super(
- TestLoadBalancingRule,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestLoadBalancingRule, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.template = get_template(
cls.api_client,
cls.zone.id,
@@ -2140,14 +2132,13 @@ class TestDeleteCreateLBRule(cloudstackTestCase):
@classmethod
def setUpClass(cls):
cls._cleanup = []
- cls.api_client = super(
- TestDeleteCreateLBRule,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestDeleteCreateLBRule, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.template = get_template(
cls.api_client,
cls.zone.id,
@@ -2269,14 +2260,13 @@ class TestVmWithLb(cloudstackTestCase):
@classmethod
def setUpClass(cls):
cls._cleanup = []
- cls.api_client = super(
- TestVmWithLb,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestVmWithLb, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.template = get_template(
cls.api_client,
cls.zone.id,
[10/18] Marvin + test changes from master Signed-off-by:
SrikanteswaraRao Talluri
Posted by da...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/smoke/test_portable_publicip.py
----------------------------------------------------------------------
diff --git a/test/integration/smoke/test_portable_publicip.py b/test/integration/smoke/test_portable_publicip.py
index efbd483..2d02a71 100644
--- a/test/integration/smoke/test_portable_publicip.py
+++ b/test/integration/smoke/test_portable_publicip.py
@@ -18,73 +18,11 @@
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
from nose.plugins.attrib import attr
-class Services:
- """Test Data
- """
-
- def __init__(self):
- self.services = {
- "domain": {
- "name": "Domain",
- },
- "account": {
- "email": "test@test.com",
- "firstname": "Test",
- "lastname": "User",
- "username": "test",
- # Random characters are appended for unique
- # username
- "password": "password",
- },
- "service_offering": {
- "name": "Tiny Instance",
- "displaytext": "Tiny Instance",
- "cpunumber": 1,
- "cpuspeed": 100,
- # in MHz
- "memory": 128,
- # In MBs
- },
- "network_offering": {
- "name": 'Test Network offering',
- "displaytext": 'Test Network offering',
- "guestiptype": 'Isolated',
- "supportedservices": 'Dhcp,Dns,SourceNat,PortForwarding',
- "traffictype": 'GUEST',
- "availability": 'Optional',
- "serviceProviderList" : {
- "Dhcp": 'VirtualRouter',
- "Dns": 'VirtualRouter',
- "SourceNat": 'VirtualRouter',
- "PortForwarding": 'VirtualRouter',
- },
- },
- "network": {
- "name": "Test Network",
- "displaytext": "Test Network",
- },
- "ostype": 'CentOS 5.3 (64-bit)',
- "gateway" : "172.1.1.1",
- "netmask" : "255.255.255.0",
- "startip" : "172.1.1.10",
- "endip" : "172.1.1.20",
- "regionid" : "1",
- "vlan" :"10",
- "isportable" : "true",
- "virtual_machine" : {
- "affinity": {
- "name": "webvms",
- "type": "host anti-affinity",
- },
- "hypervisor" : "XenServer",
- }
- }
-
class TestPortablePublicIPRange(cloudstackTestCase):
"""
@@ -95,15 +33,17 @@ class TestPortablePublicIPRange(cloudstackTestCase):
"""
@classmethod
def setUpClass(cls):
- cls.api_client = super(TestPortablePublicIPRange, cls).getClsTestClient().getApiClient()
- cls.services = Services().services
+ testClient = super(TestPortablePublicIPRange, cls).getClsTestClient()
+ cls.apiclient = testClient.getApiClient()
+ cls.services = testClient.getParsedTestDataConfig()
+
# Get Zone, Domain
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.apiclient)
+ cls.zone = get_zone(cls.apiclient, cls.testClient.getZoneForTests())
# Create Account
cls.account = Account.create(
- cls.api_client,
+ cls.apiclient,
cls.services["account"],
domainid=cls.domain.id
)
@@ -116,7 +56,7 @@ class TestPortablePublicIPRange(cloudstackTestCase):
def tearDownClass(cls):
try:
# Cleanup resources used
- cleanup_resources(cls.api_client, cls._cleanup)
+ cleanup_resources(cls.apiclient, cls._cleanup)
except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e)
return
@@ -141,7 +81,7 @@ class TestPortablePublicIPRange(cloudstackTestCase):
"""
self.debug("attempting to create a portable Public IP range")
self.portable_ip_range = PortablePublicIpRange.create(
- self.api_client,
+ self.apiclient,
self.services
)
self.debug("attempting to verify portable Public IP range is created")
@@ -161,29 +101,31 @@ class TestPortablePublicIPAcquire(cloudstackTestCase):
"""
@classmethod
def setUpClass(cls):
- cls.api_client = super(TestPortablePublicIPAcquire, cls).getClsTestClient().getApiClient()
- cls.services = Services().services
+ testClient = super(TestPortablePublicIPAcquire, cls).getClsTestClient()
+ cls.apiclient = testClient.getApiClient()
+ cls.services = testClient.getParsedTestDataConfig()
+
# Get Zone, Domain
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.apiclient)
+ cls.zone = get_zone(cls.apiclient, cls.testClient.getZoneForTests())
# Create Account
cls.account = Account.create(
- cls.api_client,
+ cls.apiclient,
cls.services["account"],
domainid=cls.domain.id
)
cls.services["network"]["zoneid"] = cls.zone.id
cls.network_offering = NetworkOffering.create(
- cls.api_client,
+ cls.apiclient,
cls.services["network_offering"],
)
# Enable Network offering
- cls.network_offering.update(cls.api_client, state='Enabled')
+ cls.network_offering.update(cls.apiclient, state='Enabled')
cls.services["network"]["networkoffering"] = cls.network_offering.id
cls.account_network = Network.create(
- cls.api_client,
+ cls.apiclient,
cls.services["network"],
cls.account.name,
cls.account.domainid
@@ -200,7 +142,7 @@ class TestPortablePublicIPAcquire(cloudstackTestCase):
def tearDownClass(cls):
try:
# Cleanup resources used
- cleanup_resources(cls.api_client, cls._cleanup)
+ cleanup_resources(cls.apiclient, cls._cleanup)
except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e)
return
@@ -225,13 +167,13 @@ class TestPortablePublicIPAcquire(cloudstackTestCase):
"""
self.debug("attempting to create a portable Public IP range")
self.portable_ip_range = PortablePublicIpRange.create(
- self.api_client,
+ self.apiclient,
self.services
)
- ip_address = PublicIPAddress.create(self.api_client, self.account.name,
+ ip_address = PublicIPAddress.create(self.apiclient, self.account.name,
self.zone.id, self.account.domainid, isportable=True)
- ip_address.delete(self.api_client)
+ ip_address.delete(self.apiclient)
self.portable_ip_range.delete(self.apiclient)
return
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/smoke/test_primary_storage.py
----------------------------------------------------------------------
diff --git a/test/integration/smoke/test_primary_storage.py b/test/integration/smoke/test_primary_storage.py
index f102078..3c1aa62 100644
--- a/test/integration/smoke/test_primary_storage.py
+++ b/test/integration/smoke/test_primary_storage.py
@@ -20,43 +20,24 @@
import marvin
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
from nose.plugins.attrib import attr
#Import System modules
import time
_multiprocess_shared_ = True
-class Services:
- """Test Primary storage Services
- """
-
- def __init__(self):
- self.services = {
- "nfs":
- {
- "url": "nfs://10.147.28.7/export/home/talluri/testprimary",
- # Format: File_System_Type/Location/Path
- "name": "Primary XEN"
- },
- "iscsi": {
- "url": "iscsi://192.168.100.21/iqn.2012-01.localdomain.clo-cstack-cos6:iser/1",
- # Format : iscsi://IP Address/IQN number/LUN#
- "name": "Primary iSCSI"
- }
- }
-
class TestPrimaryStorageServices(cloudstackTestCase):
def setUp(self):
self.apiclient = self.testClient.getApiClient()
- self.services = Services().services
+ self.services = self.testClient.getParsedTestDataConfig()
self.cleanup = []
# Get Zone and pod
- self.zone = get_zone(self.apiclient, self.services)
+ self.zone = get_zone(self.apiclient, self.testClient.getZoneForTests())
self.pod = get_pod(self.apiclient, self.zone.id)
return
@@ -218,7 +199,7 @@ class TestPrimaryStorageServices(cloudstackTestCase):
self.assertEqual(
storage.type,
- 'NetworkFilesystem',
+ 'IscsiLUN',
"Check storage pool type "
)
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/smoke/test_privategw_acl.py
----------------------------------------------------------------------
diff --git a/test/integration/smoke/test_privategw_acl.py b/test/integration/smoke/test_privategw_acl.py
index ec5ef8b..8d20770 100644
--- a/test/integration/smoke/test_privategw_acl.py
+++ b/test/integration/smoke/test_privategw_acl.py
@@ -19,9 +19,9 @@
#Import Local Modules
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
from nose.plugins.attrib import attr
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/smoke/test_public_ip_range.py
----------------------------------------------------------------------
diff --git a/test/integration/smoke/test_public_ip_range.py b/test/integration/smoke/test_public_ip_range.py
index 759e107..b961dc3 100644
--- a/test/integration/smoke/test_public_ip_range.py
+++ b/test/integration/smoke/test_public_ip_range.py
@@ -21,50 +21,26 @@ import marvin
from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
import datetime
-class Services:
- """Test Dedicating Public IP addresses
- """
-
- def __init__(self):
- self.services = {
- "domain": {
- "name": "Domain",
- },
- "account": {
- "email": "test@test.com",
- "firstname": "Test",
- "lastname": "User",
- "username": "test",
- "password": "password",
- },
- "gateway": "10.102.197.1",
- "netmask": "255.255.255.0",
- "forvirtualnetwork": "true",
- "startip": "10.102.197.70",
- "endip": "10.102.197.73",
- "zoneid": "1",
- "podid": "",
- "vlan": "4444",
- }
-
class TestDedicatePublicIPRange(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(TestDedicatePublicIPRange, cls).getClsTestClient().getApiClient()
- cls.services = Services().services
+ cls.testClient = super(TestDedicatePublicIPRange, cls).getClsTestClient()
+ cls.apiclient = cls.testClient.getApiClient()
+ cls.services = cls.testClient.getParsedTestDataConfig()
# Get Zone, Domain
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
-
+ cls.domain = get_domain(cls.apiclient)
+ cls.zone = get_zone(cls.apiclient, cls.testClient.getZoneForTests())
+ cls.services["zoneid"] = cls.zone.id
+ cls.pod = get_pod(cls.apiclient, cls.zone.id)
# Create Account
cls.account = Account.create(
- cls.api_client,
+ cls.apiclient,
cls.services["account"],
domainid=cls.domain.id
)
@@ -77,7 +53,7 @@ class TestDedicatePublicIPRange(cloudstackTestCase):
def tearDownClass(cls):
try:
# Cleanup resources used
- cleanup_resources(cls.api_client, cls._cleanup)
+ cleanup_resources(cls.apiclient, cls._cleanup)
except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e)
return
@@ -112,7 +88,7 @@ class TestDedicatePublicIPRange(cloudstackTestCase):
self.debug("Creating Public IP range")
self.public_ip_range = PublicIpRange.create(
- self.api_client,
+ self.apiclient,
self.services
)
list_public_ip_range_response = PublicIpRange.list(
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/smoke/test_pvlan.py
----------------------------------------------------------------------
diff --git a/test/integration/smoke/test_pvlan.py b/test/integration/smoke/test_pvlan.py
index 38afd41..a1c146b 100644
--- a/test/integration/smoke/test_pvlan.py
+++ b/test/integration/smoke/test_pvlan.py
@@ -21,9 +21,9 @@ import marvin
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
from marvin.sshClient import SshClient
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
from nose.plugins.attrib import attr
import telnetlib
@@ -80,12 +80,6 @@ class TestPVLAN(cloudstackTestCase):
createNetworkCmd.ip6cidr="fc00:1234::/64"
createNetworkCmd.startipv6="fc00:1234::10"
createNetworkCmd.endipv6="fc00:1234::20"
- err = 0;
- try:
- createNetworkResponse = self.apiClient.createNetwork(createNetworkCmd)
- except Exception as e:
- err = 1;
- self.debug("Try alloc with ipv6, got:%s" % e)
- self.assertEqual(err, 1, "Shouldn't allow create PVLAN network with IPv6");
-
-
+ err = 0
+ createNetworkResponse = self.apiClient.createNetwork(createNetworkCmd)
+ self.assertEqual(createNetworkResponse, FAILED, "Creating PVLAN with IPv6 should fail")
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/smoke/test_regions.py
----------------------------------------------------------------------
diff --git a/test/integration/smoke/test_regions.py b/test/integration/smoke/test_regions.py
index 71900b4..389f878 100644
--- a/test/integration/smoke/test_regions.py
+++ b/test/integration/smoke/test_regions.py
@@ -17,42 +17,33 @@
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
from nose.plugins.attrib import attr
-class Services:
- def __init__(self):
- self.services = {
- "region": {
- "regionid": "2",
- "regionname": "Region2",
- "regionendpoint": "http://region2:8080/client"
- }
- }
-
-
class TestRegions(cloudstackTestCase):
"""Test Regions - basic region creation
"""
@classmethod
def setUpClass(cls):
- cls.api_client = super(TestRegions, cls).getClsTestClient().getApiClient()
- cls.services = Services().services
- cls.domain = get_domain(cls.api_client, cls.services)
+ testClient = super(TestRegions, cls).getClsTestClient()
+ cls.apiclient = testClient.getApiClient()
+ cls.services = testClient.getParsedTestDataConfig()
+
+ cls.domain = get_domain(cls.apiclient)
cls.cleanup = []
@attr(tags=["simulator", "basic", "advanced", "selfservice"])
def test_createRegion(self):
""" Test for create region
"""
- region = Region.create(self.api_client,
+ region = Region.create(self.apiclient,
self.services["region"]
)
- list_region = Region.list(self.api_client,
+ list_region = Region.list(self.apiclient,
id=self.services["region"]["regionid"]
)
@@ -86,8 +77,8 @@ class TestRegions(cloudstackTestCase):
def tearDownClass(cls):
try:
#Clean up
- cleanup_resources(cls.api_client, cls.cleanup)
- list_region = Region.list(cls.api_client, id=cls.services["region"]["regionid"])
+ cleanup_resources(cls.apiclient, cls.cleanup)
+ list_region = Region.list(cls.apiclient, id=cls.services["region"]["regionid"])
assert list_region is None, "Region deletion fails"
except Exception as e:
- raise Exception("Warning: Region cleanup/delete fails with : %s" % e)
\ No newline at end of file
+ raise Exception("Warning: Region cleanup/delete fails with : %s" % e)
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/smoke/test_reset_vm_on_reboot.py
----------------------------------------------------------------------
diff --git a/test/integration/smoke/test_reset_vm_on_reboot.py b/test/integration/smoke/test_reset_vm_on_reboot.py
index 6cb63e3..4709df4 100644
--- a/test/integration/smoke/test_reset_vm_on_reboot.py
+++ b/test/integration/smoke/test_reset_vm_on_reboot.py
@@ -18,106 +18,56 @@
"""
#Import Local Modules
import marvin
+from marvin.codes import FAILED
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
from nose.plugins.attrib import attr
_multiprocess_shared_ = True
-class Services:
- """Test VM Life Cycle Services
- """
-
- def __init__(self):
- self.services = {
-
- "account": {
- "email": "test@test.com",
- "firstname": "Test",
- "lastname": "User",
- "username": "test",
- # Random characters are appended in create account to
- # ensure unique username generated each time
- "password": "password",
- },
- "small":
- # Create a small virtual machine instance with disk offering
- {
- "displayname": "testserver",
- "username": "root", # VM creds for SSH
- "password": "password",
- "ssh_port": 22,
- "hypervisor": 'XenServer',
- "privateport": 22,
- "publicport": 22,
- "protocol": 'TCP',
- },
- "service_offerings":
- {
- "small":
- {
- # Small service offering ID to for change VM
- # service offering from medium to small
- "name": "SmallInstance_volatile",
- "displaytext": "SmallInstance_volatile",
- "cpunumber": 1,
- "cpuspeed": 100,
- "memory": 256,
- },
- },
- #Change this
- "template": {
- "displaytext": "xs",
- "name": "xs",
- "passwordenabled": False,
- },
- "sleep": 60,
- "timeout": 10,
- #Migrate VM to hostid
- "ostype": 'CentOS 5.3 (64-bit)',
- # CentOS 5.3 (64-bit)
- }
-
-
class TestResetVmOnReboot(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(TestResetVmOnReboot, cls).getClsTestClient().getApiClient()
- cls.services = Services().services
+ testClient = super(TestResetVmOnReboot, cls).getClsTestClient()
+ cls.apiclient = testClient.getApiClient()
+ cls.services = testClient.getParsedTestDataConfig()
# Get Zone, Domain and templates
- domain = get_domain(cls.api_client, cls.services)
- zone = get_zone(cls.api_client, cls.services)
+ domain = get_domain(cls.apiclient)
+ zone = get_zone(cls.apiclient, testClient.getZoneForTests())
cls.services['mode'] = zone.networktype
template = get_template(
- cls.api_client,
+ cls.apiclient,
zone.id,
cls.services["ostype"]
)
+ if template == FAILED:
+ assert False, "get_template() failed to return template with description %s" % cls.services["ostype"]
+
# Set Zones and disk offerings ??
cls.services["small"]["zoneid"] = zone.id
cls.services["small"]["template"] = template.id
# Create account, service offerings, vm.
cls.account = Account.create(
- cls.api_client,
+ cls.apiclient,
cls.services["account"],
domainid=domain.id
)
cls.small_offering = ServiceOffering.create(
- cls.api_client,
+ cls.apiclient,
cls.services["service_offerings"]["small"],
isvolatile="true"
)
#create a virtual machine
cls.virtual_machine = VirtualMachine.create(
- cls.api_client,
+ cls.apiclient,
cls.services["small"],
accountid=cls.account.name,
domainid=cls.account.domainid,
@@ -131,8 +81,8 @@ class TestResetVmOnReboot(cloudstackTestCase):
@classmethod
def tearDownClass(cls):
- cls.api_client = super(TestResetVmOnReboot, cls).getClsTestClient().getApiClient()
- cleanup_resources(cls.api_client, cls._cleanup)
+ cls.apiclient = super(TestResetVmOnReboot, cls).getClsTestClient().getApiClient()
+ cleanup_resources(cls.apiclient, cls._cleanup)
return
def setUp(self):
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/smoke/test_resource_detail.py
----------------------------------------------------------------------
diff --git a/test/integration/smoke/test_resource_detail.py b/test/integration/smoke/test_resource_detail.py
index a0cac9b..7f4a6e7 100644
--- a/test/integration/smoke/test_resource_detail.py
+++ b/test/integration/smoke/test_resource_detail.py
@@ -21,113 +21,46 @@ import marvin
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
from marvin.sshClient import SshClient
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
from nose.plugins.attrib import attr
#Import System modules
import time
_multiprocess_shared_ = True
-class Services:
- """Test VM Life Cycle Services
- """
-
- def __init__(self):
- self.services = {
-
- "account": {
- "email": "test@test.com",
- "firstname": "Test",
- "lastname": "User",
- "username": "test",
- # Random characters are appended in create account to
- # ensure unique username generated each time
- "password": "password",
- },
- "small":
- # Create a small virtual machine instance with disk offering
- {
- "displayname": "testserver",
- "username": "root", # VM creds for SSH
- "password": "password",
- "ssh_port": 22,
- "hypervisor": 'XenServer',
- "privateport": 22,
- "publicport": 22,
- "protocol": 'TCP',
- },
- "disk_offering": {
- "displaytext": "Small",
- "name": "Small",
- "storagetype": "shared",
- "disksize": 1
- },
- "service_offerings":
- {
- "small":
- {
- # Small service offering ID to for change VM
- # service offering from medium to small
- "name": "SmallInstance",
- "displaytext": "SmallInstance",
- "cpunumber": 1,
- "cpuspeed": 100,
- "memory": 256,
- },
- "big":
- {
- # Big service offering ID to for change VM
- "name": "BigInstance",
- "displaytext": "BigInstance",
- "cpunumber": 1,
- "cpuspeed": 100,
- "memory": 512,
- }
- },
- #Change this
- "template": {
- "displaytext": "xs",
- "name": "xs",
- "passwordenabled": False,
- },
- "sleep": 60,
- "timeout": 10,
- #Migrate VM to hostid
- "ostype": 'CentOS 5.6 (64-bit)',
- # CentOS 5.3 (64-bit)
- }
class TestResourceDetail(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(TestResourceDetail, cls).getClsTestClient().getApiClient()
- cls.services = Services().services
+ testClient = super(TestResourceDetail, cls).getClsTestClient()
+ cls.apiclient = testClient.getApiClient()
+ cls.services = testClient.getParsedTestDataConfig()
# Get Zone, Domain and templates
- domain = get_domain(cls.api_client, cls.services)
- zone = get_zone(cls.api_client, cls.services)
+ domain = get_domain(cls.apiclient)
+ zone = get_zone(cls.apiclient, testClient.getZoneForTests())
cls.services['mode'] = zone.networktype
# Set Zones and disk offerings ??
# Create account, service offerings, vm.
cls.account = Account.create(
- cls.api_client,
+ cls.apiclient,
cls.services["account"],
domainid=domain.id
)
cls.disk_offering = DiskOffering.create(
- cls.api_client,
+ cls.apiclient,
cls.services["disk_offering"]
)
#create a volume
cls.volume = Volume.create(
- cls.api_client,
+ cls.apiclient,
{ "diskname" : "ndm"},
zoneid=zone.id,
account=cls.account.name,
@@ -142,8 +75,8 @@ class TestResourceDetail(cloudstackTestCase):
@classmethod
def tearDownClass(cls):
- cls.api_client = super(TestResourceDetail, cls).getClsTestClient().getApiClient()
- cleanup_resources(cls.api_client, cls._cleanup)
+ cls.apiclient = super(TestResourceDetail, cls).getClsTestClient().getApiClient()
+ cleanup_resources(cls.apiclient, cls._cleanup)
return
def setUp(self):
@@ -175,7 +108,7 @@ class TestResourceDetail(cloudstackTestCase):
listResourceDetailCmd = listResourceDetails.listResourceDetailsCmd()
listResourceDetailCmd.resourceid = self.volume.id
listResourceDetailCmd.resourcetype = "Volume"
- listResourceDetailResponse = self.api_client.listResourceDetails(listResourceDetailCmd)
+ listResourceDetailResponse = self.apiclient.listResourceDetails(listResourceDetailCmd)
self.assertEqual(listResourceDetailResponse, None, "Check if the list API \
returns an empty response")
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/smoke/test_routers.py
----------------------------------------------------------------------
diff --git a/test/integration/smoke/test_routers.py b/test/integration/smoke/test_routers.py
index 2bd1d5e..2aa83c3 100644
--- a/test/integration/smoke/test_routers.py
+++ b/test/integration/smoke/test_routers.py
@@ -18,88 +18,55 @@
"""
#Import Local Modules
import marvin
+from marvin.codes import FAILED
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
from marvin.sshClient import SshClient
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
from nose.plugins.attrib import attr
#Import System modules
import time
_multiprocess_shared_ = True
-class Services:
- """Test router Services
- """
-
- def __init__(self):
- self.services = {
- "service_offering": {
- "name": "Tiny Instance",
- "displaytext": "Tiny Instance",
- "cpunumber": 1,
- "cpuspeed": 100, # in MHz
- "memory": 128, # In MBs
- },
- "virtual_machine":
- {
- "displayname": "Test VM",
- "username": "root",
- "password": "password",
- "ssh_port": 22,
- "hypervisor": 'XenServer',
- "privateport": 22,
- "publicport": 22,
- "protocol": 'TCP',
- },
- "account": {
- "email": "test@test.com",
- "firstname": "Test",
- "lastname": "User",
- "username": "testuser",
- "password": "password",
- },
- "ostype": "CentOS 5.3 (64-bit)",
- "sleep": 60,
- "timeout": 10,
- }
-
class TestRouterServices(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(
- TestRouterServices,
- cls
- ).getClsTestClient().getApiClient()
- cls.services = Services().services
+ testClient = super(TestRouterServices, cls).getClsTestClient()
+ cls.apiclient = testClient.getApiClient()
+ cls.services = testClient.getParsedTestDataConfig()
+
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.apiclient)
+ cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests())
cls.services['mode'] = cls.zone.networktype
template = get_template(
- cls.api_client,
+ cls.apiclient,
cls.zone.id,
cls.services["ostype"]
)
+ if template == FAILED:
+ cls.fail("get_template() failed to return template with description %s" % cls.services["ostype"])
+
cls.services["virtual_machine"]["zoneid"] = cls.zone.id
#Create an account, network, VM and IP addresses
cls.account = Account.create(
- cls.api_client,
+ cls.apiclient,
cls.services["account"],
domainid=cls.domain.id
)
cls.service_offering = ServiceOffering.create(
- cls.api_client,
- cls.services["service_offering"]
+ cls.apiclient,
+ cls.services["service_offerings"]
)
cls.vm_1 = VirtualMachine.create(
- cls.api_client,
+ cls.apiclient,
cls.services["virtual_machine"],
templateid=template.id,
accountid=cls.account.name,
@@ -115,12 +82,12 @@ class TestRouterServices(cloudstackTestCase):
@classmethod
def tearDownClass(cls):
try:
- cls.api_client = super(
+ cls.apiclient = super(
TestRouterServices,
cls
).getClsTestClient().getApiClient()
#Clean up, terminate the created templates
- cleanup_resources(cls.api_client, cls.cleanup)
+ cleanup_resources(cls.apiclient, cls.cleanup)
except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e)
@@ -128,6 +95,7 @@ class TestRouterServices(cloudstackTestCase):
def setUp(self):
self.apiclient = self.testClient.getApiClient()
+ self.hypervisor = self.testClient.getHypervisorInfo()
return
@attr(tags = ["advanced", "basic", "sg", "smoke", "provisioning"])
@@ -180,7 +148,7 @@ class TestRouterServices(cloudstackTestCase):
"Check list router response for router state"
)
- if self.apiclient.hypervisor.lower() == 'vmware':
+ if self.hypervisor.lower() == 'vmware':
result = get_process_status(
self.apiclient.connection.mgtSvr,
22,
@@ -188,7 +156,7 @@ class TestRouterServices(cloudstackTestCase):
self.apiclient.connection.passwd,
router.linklocalip,
"service dnsmasq status",
- hypervisor=self.apiclient.hypervisor
+ hypervisor=self.hypervisor
)
else:
try:
@@ -262,7 +230,7 @@ class TestRouterServices(cloudstackTestCase):
"Check list router response for router state"
)
- if self.apiclient.hypervisor.lower() == 'vmware':
+ if self.hypervisor.lower() == 'vmware':
result = get_process_status(
self.apiclient.connection.mgtSvr,
22,
@@ -270,7 +238,7 @@ class TestRouterServices(cloudstackTestCase):
self.apiclient.connection.passwd,
router.linklocalip,
"service dnsmasq status",
- hypervisor=self.apiclient.hypervisor
+ hypervisor=self.hypervisor
)
else:
try:
@@ -294,7 +262,7 @@ class TestRouterServices(cloudstackTestCase):
"Check dnsmasq service is running or not"
)
- if self.apiclient.hypervisor.lower() == 'vmware':
+ if self.hypervisor.lower() == 'vmware':
result = get_process_status(
self.apiclient.connection.mgtSvr,
22,
@@ -302,7 +270,7 @@ class TestRouterServices(cloudstackTestCase):
self.apiclient.connection.passwd,
router.linklocalip,
"service haproxy status",
- hypervisor=self.apiclient.hypervisor
+ hypervisor=self.hypervisor
)
else:
try:
@@ -473,7 +441,7 @@ class TestRouterServices(cloudstackTestCase):
)
host = hosts[0]
- if self.apiclient.hypervisor.lower() == 'vmware':
+ if self.hypervisor.lower() == 'vmware':
res = get_process_status(
self.apiclient.connection.mgtSvr,
22,
@@ -481,7 +449,7 @@ class TestRouterServices(cloudstackTestCase):
self.apiclient.connection.passwd,
router.linklocalip,
"uptime",
- hypervisor=self.apiclient.hypervisor
+ hypervisor=self.hypervisor
)
else:
try:
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/smoke/test_scale_vm.py
----------------------------------------------------------------------
diff --git a/test/integration/smoke/test_scale_vm.py b/test/integration/smoke/test_scale_vm.py
index 026ac13..03d2e87 100644
--- a/test/integration/smoke/test_scale_vm.py
+++ b/test/integration/smoke/test_scale_vm.py
@@ -18,119 +18,60 @@
"""
#Import Local Modules
import marvin
+from marvin.codes import FAILED
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
from nose.plugins.attrib import attr
_multiprocess_shared_ = True
-class Services:
- """Test VM Life Cycle Services
- """
-
- def __init__(self):
- self.services = {
-
- "account": {
- "email": "test@test.com",
- "firstname": "Test",
- "lastname": "User",
- "username": "test",
- # Random characters are appended in create account to
- # ensure unique username generated each time
- "password": "password",
- },
- "small":
- # Create a small virtual machine instance with disk offering
- {
- "displayname": "testserver",
- "username": "root", # VM creds for SSH
- "password": "password",
- "ssh_port": 22,
- "hypervisor": 'XenServer',
- "privateport": 22,
- "publicport": 22,
- "protocol": 'TCP',
- },
- "service_offerings":
- {
- "small":
- {
- # Small service offering ID to for change VM
- # service offering from medium to small
- "name": "SmallInstance",
- "displaytext": "SmallInstance",
- "cpunumber": 1,
- "cpuspeed": 100,
- "memory": 256,
- },
- "big":
- {
- # Big service offering ID to for change VM
- "name": "BigInstance",
- "displaytext": "BigInstance",
- "cpunumber": 1,
- "cpuspeed": 100,
- "memory": 512,
- }
- },
- #Change this
- "template": {
- "displaytext": "xs",
- "name": "xs",
- "passwordenabled": False,
- },
- "sleep": 60,
- "timeout": 10,
- #Migrate VM to hostid
- "ostype": 'CentOS 5.3 (64-bit)',
- # CentOS 5.3 (64-bit)
- }
-
-
class TestScaleVm(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(TestScaleVm, cls).getClsTestClient().getApiClient()
- cls.services = Services().services
+ testClient = super(TestScaleVm, cls).getClsTestClient()
+ cls.apiclient = testClient.getApiClient()
+ cls.services = testClient.getParsedTestDataConfig()
# Get Zone, Domain and templates
- domain = get_domain(cls.api_client, cls.services)
- zone = get_zone(cls.api_client, cls.services)
+ domain = get_domain(cls.apiclient)
+ zone = get_zone(cls.apiclient, testClient.getZoneForTests())
cls.services['mode'] = zone.networktype
template = get_template(
- cls.api_client,
+ cls.apiclient,
zone.id,
cls.services["ostype"]
)
+ if template == FAILED:
+ assert False, "get_template() failed to return template with description %s" % cls.services["ostype"]
+
# Set Zones and disk offerings ??
cls.services["small"]["zoneid"] = zone.id
cls.services["small"]["template"] = template.id
# Create account, service offerings, vm.
cls.account = Account.create(
- cls.api_client,
+ cls.apiclient,
cls.services["account"],
domainid=domain.id
)
cls.small_offering = ServiceOffering.create(
- cls.api_client,
+ cls.apiclient,
cls.services["service_offerings"]["small"]
)
cls.big_offering = ServiceOffering.create(
- cls.api_client,
+ cls.apiclient,
cls.services["service_offerings"]["big"]
)
#create a virtual machine
cls.virtual_machine = VirtualMachine.create(
- cls.api_client,
+ cls.apiclient,
cls.services["small"],
accountid=cls.account.name,
domainid=cls.account.domainid,
@@ -144,8 +85,8 @@ class TestScaleVm(cloudstackTestCase):
@classmethod
def tearDownClass(cls):
- cls.api_client = super(TestScaleVm, cls).getClsTestClient().getApiClient()
- cleanup_resources(cls.api_client, cls._cleanup)
+ cls.apiclient = super(TestScaleVm, cls).getClsTestClient().getApiClient()
+ cleanup_resources(cls.apiclient, cls._cleanup)
return
def setUp(self):
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/smoke/test_secondary_storage.py
----------------------------------------------------------------------
diff --git a/test/integration/smoke/test_secondary_storage.py b/test/integration/smoke/test_secondary_storage.py
index 240f54f..ac80956 100644
--- a/test/integration/smoke/test_secondary_storage.py
+++ b/test/integration/smoke/test_secondary_storage.py
@@ -20,9 +20,9 @@
import marvin
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
from nose.plugins.attrib import attr
#Import System modules
@@ -33,7 +33,7 @@ class TestSecStorageServices(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(TestSecStorageServices, cls).getClsTestClient().getApiClient()
+ cls.apiclient = super(TestSecStorageServices, cls).getClsTestClient().getApiClient()
cls._cleanup = []
return
@@ -41,7 +41,7 @@ class TestSecStorageServices(cloudstackTestCase):
def tearDownClass(cls):
try:
#Cleanup resources used
- cleanup_resources(cls.api_client, cls._cleanup)
+ cleanup_resources(cls.apiclient, cls._cleanup)
except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e)
return
@@ -187,6 +187,8 @@ class TestSecStorageServices(cloudstackTestCase):
listall=True,
account='system'
)
+ self.assertEqual(validateList(list_template_response)[0], PASS,\
+ "templates list validation failed")
# Ensure all BUILTIN templates are downloaded
templateid = None
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/smoke/test_service_offerings.py
----------------------------------------------------------------------
diff --git a/test/integration/smoke/test_service_offerings.py b/test/integration/smoke/test_service_offerings.py
index 70865b4..3c91859 100644
--- a/test/integration/smoke/test_service_offerings.py
+++ b/test/integration/smoke/test_service_offerings.py
@@ -17,15 +17,16 @@
""" BVT tests for Service offerings"""
#Import Local Modules
+from marvin.codes import FAILED
from marvin.cloudstackTestCase import cloudstackTestCase
from marvin.cloudstackAPI import changeServiceForVirtualMachine,updateServiceOffering
-from marvin.integration.lib.utils import (isAlmostEqual,
+from marvin.lib.utils import (isAlmostEqual,
cleanup_resources,
random_gen)
-from marvin.integration.lib.base import (ServiceOffering,
+from marvin.lib.base import (ServiceOffering,
Account,
VirtualMachine)
-from marvin.integration.lib.common import (list_service_offering,
+from marvin.lib.common import (list_service_offering,
list_virtual_machines,
get_domain,
get_zone,
@@ -35,93 +36,13 @@ from nose.plugins.attrib import attr
_multiprocess_shared_ = True
-class Services:
- """Test Service offerings Services
- """
-
- def __init__(self):
- self.services = {
- "account": {
- "email": "test@test.com",
- "firstname": "Test",
- "lastname": "User",
- "username": "test",
- # Random characters are appended in create account to
- # ensure unique username generated each time
- "password": "password",
- },
- "off":
- {
- "name": "Service Offering",
- "displaytext": "Service Offering",
- "cpunumber": 1,
- "cpuspeed": 100, # MHz
- "memory": 128, # in MBs
- },
- "small":
- # Create a small virtual machine instance with disk offering
- {
- "displayname": "testserver",
- "username": "root", # VM creds for SSH
- "password": "password",
- "ssh_port": 22,
- "hypervisor": 'XenServer',
- "privateport": 22,
- "publicport": 22,
- "protocol": 'TCP',
- },
- "medium": # Create a medium virtual machine instance
- {
- "displayname": "testserver",
- "username": "root",
- "password": "password",
- "ssh_port": 22,
- "hypervisor": 'XenServer',
- "privateport": 22,
- "publicport": 22,
- "protocol": 'TCP',
- },
- "service_offerings":
- {
- "tiny":
- {
- "name": "Tiny Instance",
- "displaytext": "Tiny Instance",
- "cpunumber": 1,
- "cpuspeed": 100, # in MHz
- "memory": 128, # In MBs
- },
- "small":
- {
- # Small service offering ID to for change VM
- # service offering from medium to small
- "name": "Small Instance",
- "displaytext": "Small Instance",
- "cpunumber": 1,
- "cpuspeed": 100,
- "memory": 128,
- },
- "medium":
- {
- # Medium service offering ID to for
- # change VM service offering from small to medium
- "name": "Medium Instance",
- "displaytext": "Medium Instance",
- "cpunumber": 1,
- "cpuspeed": 100,
- "memory": 256,
- }
- },
- "ostype": 'CentOS 5.3 (64-bit)',
- }
-
class TestCreateServiceOffering(cloudstackTestCase):
def setUp(self):
self.apiclient = self.testClient.getApiClient()
self.dbclient = self.testClient.getDbConnection()
self.cleanup = []
- self.services = Services().services
+ self.services = self.testClient.getParsedTestDataConfig()
def tearDown(self):
try:
@@ -143,7 +64,7 @@ class TestCreateServiceOffering(cloudstackTestCase):
service_offering = ServiceOffering.create(
self.apiclient,
- self.services["off"]
+ self.services["service_offerings"]
)
self.cleanup.append(service_offering)
@@ -168,27 +89,27 @@ class TestCreateServiceOffering(cloudstackTestCase):
self.assertEqual(
list_service_response[0].cpunumber,
- self.services["off"]["cpunumber"],
+ self.services["service_offerings"]["cpunumber"],
"Check server id in createServiceOffering"
)
self.assertEqual(
list_service_response[0].cpuspeed,
- self.services["off"]["cpuspeed"],
+ self.services["service_offerings"]["cpuspeed"],
"Check cpuspeed in createServiceOffering"
)
self.assertEqual(
list_service_response[0].displaytext,
- self.services["off"]["displaytext"],
+ self.services["service_offerings"]["displaytext"],
"Check server displaytext in createServiceOfferings"
)
self.assertEqual(
list_service_response[0].memory,
- self.services["off"]["memory"],
+ self.services["service_offerings"]["memory"],
"Check memory in createServiceOffering"
)
self.assertEqual(
list_service_response[0].name,
- self.services["off"]["name"],
+ self.services["service_offerings"]["name"],
"Check name in createServiceOffering"
)
return
@@ -212,25 +133,30 @@ class TestServiceOfferings(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(TestServiceOfferings, cls).getClsTestClient().getApiClient()
- cls.services = Services().services
- domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ testClient = super(TestServiceOfferings, cls).getClsTestClient()
+ cls.apiclient = testClient.getApiClient()
+ cls.services = testClient.getParsedTestDataConfig()
+
+ domain = get_domain(cls.apiclient)
+ cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests())
cls.services['mode'] = cls.zone.networktype
cls.service_offering_1 = ServiceOffering.create(
- cls.api_client,
- cls.services["off"]
+ cls.apiclient,
+ cls.services["service_offerings"]
)
cls.service_offering_2 = ServiceOffering.create(
- cls.api_client,
- cls.services["off"]
+ cls.apiclient,
+ cls.services["service_offerings"]
)
template = get_template(
- cls.api_client,
+ cls.apiclient,
cls.zone.id,
cls.services["ostype"]
)
+ if template == FAILED:
+ assert False, "get_template() failed to return template with description %s" % cls.services["ostype"]
+
# Set Zones and disk offerings
cls.services["small"]["zoneid"] = cls.zone.id
cls.services["small"]["template"] = template.id
@@ -240,22 +166,22 @@ class TestServiceOfferings(cloudstackTestCase):
# Create VMs, NAT Rules etc
cls.account = Account.create(
- cls.api_client,
+ cls.apiclient,
cls.services["account"],
domainid=domain.id
)
cls.small_offering = ServiceOffering.create(
- cls.api_client,
+ cls.apiclient,
cls.services["service_offerings"]["small"]
)
cls.medium_offering = ServiceOffering.create(
- cls.api_client,
+ cls.apiclient,
cls.services["service_offerings"]["medium"]
)
cls.medium_virtual_machine = VirtualMachine.create(
- cls.api_client,
+ cls.apiclient,
cls.services["medium"],
accountid=cls.account.name,
domainid=cls.account.domainid,
@@ -272,9 +198,9 @@ class TestServiceOfferings(cloudstackTestCase):
@classmethod
def tearDownClass(cls):
try:
- cls.api_client = super(TestServiceOfferings, cls).getClsTestClient().getApiClient()
+ cls.apiclient = super(TestServiceOfferings, cls).getClsTestClient().getApiClient()
#Clean up, terminate the created templates
- cleanup_resources(cls.api_client, cls._cleanup)
+ cleanup_resources(cls.apiclient, cls._cleanup)
except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e)
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/smoke/test_snapshots.py
----------------------------------------------------------------------
diff --git a/test/integration/smoke/test_snapshots.py b/test/integration/smoke/test_snapshots.py
index e3bd186..a9be4e2 100644
--- a/test/integration/smoke/test_snapshots.py
+++ b/test/integration/smoke/test_snapshots.py
@@ -15,129 +15,35 @@
# specific language governing permissions and limitations
# under the License.
+from marvin.codes import FAILED
from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
-
-class Services:
- """Test Snapshots Services
- """
-
- def __init__(self):
- self.services = {
- "account": {
- "email": "test@test.com",
- "firstname": "Test",
- "lastname": "User",
- "username": "test",
- # Random characters are appended for unique
- # username
- "password": "password",
- },
- "service_offering": {
- "name": "Tiny Instance",
- "displaytext": "Tiny Instance",
- "cpunumber": 1,
- "cpuspeed": 200, # in MHz
- "memory": 256, # In MBs
- },
- "disk_offering": {
- "displaytext": "Small Disk",
- "name": "Small Disk",
- "disksize": 1
- },
- "server_with_disk":
- {
- "displayname": "Test VM -With Disk",
- "username": "root",
- "password": "password",
- "ssh_port": 22,
- "hypervisor": 'XenServer',
- "privateport": 22,
- "publicport": 22,
- "protocol": 'TCP',
- },
-
- "server_without_disk":
- {
- "displayname": "Test VM-No Disk",
- "username": "root",
- "password": "password",
- "ssh_port": 22,
- "hypervisor": 'XenServer',
- "privateport": 22,
- # For NAT rule creation
- "publicport": 22,
- "protocol": 'TCP',
- },
- "server": {
- "displayname": "TestVM",
- "username": "root",
- "password": "password",
- "ssh_port": 22,
- "hypervisor": 'XenServer',
- "privateport": 22,
- "publicport": 22,
- "protocol": 'TCP',
- },
- "mgmt_server": {
- "ipaddress": '192.168.100.21',
- "username": "root",
- "password": "password",
- "port": 22,
- },
- "recurring_snapshot": {
- "intervaltype": 'HOURLY',
- # Frequency of snapshots
- "maxsnaps": 1, # Should be min 2
- "schedule": 1,
- "timezone": 'US/Arizona',
- # Timezone Formats - http://cloud.mindtouch.us/CloudStack_Documentation/Developer's_Guide%3A_CloudStack
- },
- "templates": {
- "displaytext": 'Template',
- "name": 'Template',
- "ostype": "CentOS 5.3 (64-bit)",
- "templatefilter": 'self',
- },
- "volume": {
- "diskname": "APP Data Volume",
- "size": 1, # in GBs
- "diskdevice": ['/dev/xvdb', '/dev/sdb', '/dev/hdb', '/dev/vdb' ], # Data Disk
- },
- "paths": {
- "mount_dir": "/mnt/tmp",
- "sub_dir": "test",
- "sub_lvl_dir1": "test1",
- "sub_lvl_dir2": "test2",
- "random_data": "random.data",
- },
- "ostype": "CentOS 5.3 (64-bit)",
- # Cent OS 5.3 (64 bit)
- "sleep": 60,
- "timeout": 10,
- }
-
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
class TestSnapshotRootDisk(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(TestSnapshotRootDisk, cls).getClsTestClient().getApiClient()
- cls.services = Services().services
+ testClient = super(TestSnapshotRootDisk, cls).getClsTestClient()
+ cls.apiclient = testClient.getApiClient()
+ cls.services = testClient.getParsedTestDataConfig()
+
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.apiclient)
+ cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests())
cls.services['mode'] = cls.zone.networktype
template = get_template(
- cls.api_client,
+ cls.apiclient,
cls.zone.id,
cls.services["ostype"]
)
+ if template == FAILED:
+ assert False, "get_template() failed to return template with description %s" % cls.services["ostype"]
+
cls.services["domainid"] = cls.domain.id
cls.services["server_without_disk"]["zoneid"] = cls.zone.id
cls.services["templates"]["ostypeid"] = template.ostypeid
@@ -145,20 +51,17 @@ class TestSnapshotRootDisk(cloudstackTestCase):
# Create VMs, NAT Rules etc
cls.account = Account.create(
- cls.api_client,
+ cls.apiclient,
cls.services["account"],
domainid=cls.domain.id
)
-
- cls.services["account"] = cls.account.name
-
cls.service_offering = ServiceOffering.create(
- cls.api_client,
- cls.services["service_offering"]
+ cls.apiclient,
+ cls.services["service_offerings"]
)
cls.virtual_machine = cls.virtual_machine_with_disk = \
VirtualMachine.create(
- cls.api_client,
+ cls.apiclient,
cls.services["server_without_disk"],
templateid=template.id,
accountid=cls.account.name,
@@ -176,7 +79,7 @@ class TestSnapshotRootDisk(cloudstackTestCase):
def tearDownClass(cls):
try:
#Cleanup resources used
- cleanup_resources(cls.api_client, cls._cleanup)
+ cleanup_resources(cls.apiclient, cls._cleanup)
except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e)
return
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/smoke/test_ssvm.py
----------------------------------------------------------------------
diff --git a/test/integration/smoke/test_ssvm.py b/test/integration/smoke/test_ssvm.py
index cf40907..ffa620b 100644
--- a/test/integration/smoke/test_ssvm.py
+++ b/test/integration/smoke/test_ssvm.py
@@ -21,9 +21,9 @@ import marvin
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
from marvin.sshClient import SshClient
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
from nose.plugins.attrib import attr
import telnetlib
@@ -31,24 +31,14 @@ import telnetlib
import time
_multiprocess_shared_ = True
-class Services:
- """Test SSVM Services
- """
-
- def __init__(self):
- self.services = {
- "sleep": 60,
- "timeout": 10,
- }
-
class TestSSVMs(cloudstackTestCase):
def setUp(self):
-
self.apiclient = self.testClient.getApiClient()
+ self.hypervisor = self.testClient.getHypervisorInfo()
self.cleanup = []
- self.services = Services().services
- self.zone = get_zone(self.apiclient, self.services)
+ self.services = self.testClient.getParsedTestDataConfig()
+ self.zone = get_zone(self.apiclient, self.testClient.getZoneForTests())
return
def tearDown(self):
@@ -329,7 +319,7 @@ class TestSSVMs(cloudstackTestCase):
self.debug("Running SSVM check script")
- if self.apiclient.hypervisor.lower() == 'vmware':
+ if self.hypervisor.lower() == 'vmware':
#SSH into SSVMs is done via management server for Vmware
result = get_process_status(
self.apiclient.connection.mgtSvr,
@@ -338,7 +328,7 @@ class TestSSVMs(cloudstackTestCase):
self.apiclient.connection.passwd,
ssvm.privateip,
"/usr/local/cloud/systemvm/ssvm-check.sh |grep -e ERROR -e WARNING -e FAIL",
- hypervisor=self.apiclient.hypervisor
+ hypervisor=self.hypervisor
)
else:
try:
@@ -369,7 +359,7 @@ class TestSSVMs(cloudstackTestCase):
)
#Check status of cloud service
- if self.apiclient.hypervisor.lower() == 'vmware':
+ if self.hypervisor.lower() == 'vmware':
#SSH into SSVMs is done via management server for Vmware
result = get_process_status(
self.apiclient.connection.mgtSvr,
@@ -378,7 +368,7 @@ class TestSSVMs(cloudstackTestCase):
self.apiclient.connection.passwd,
ssvm.privateip,
"service cloud status",
- hypervisor=self.apiclient.hypervisor
+ hypervisor=self.hypervisor
)
else:
try:
@@ -453,7 +443,7 @@ class TestSSVMs(cloudstackTestCase):
self.debug("Checking cloud process status")
- if self.apiclient.hypervisor.lower() == 'vmware':
+ if self.hypervisor.lower() == 'vmware':
#SSH into SSVMs is done via management server for vmware
result = get_process_status(
self.apiclient.connection.mgtSvr,
@@ -462,7 +452,7 @@ class TestSSVMs(cloudstackTestCase):
self.apiclient.connection.passwd,
cpvm.privateip,
"service cloud status",
- hypervisor=self.apiclient.hypervisor
+ hypervisor=self.hypervisor
)
else:
try:
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/smoke/test_templates.py
----------------------------------------------------------------------
diff --git a/test/integration/smoke/test_templates.py b/test/integration/smoke/test_templates.py
index 32b3696..4865ee3 100644
--- a/test/integration/smoke/test_templates.py
+++ b/test/integration/smoke/test_templates.py
@@ -18,12 +18,13 @@
"""
#Import Local Modules
import marvin
+from marvin.codes import FAILED
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
from marvin.sshClient import SshClient
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
from nose.plugins.attrib import attr
import urllib
from random import random
@@ -32,72 +33,6 @@ import datetime
_multiprocess_shared_ = True
-class Services:
- """Test Templates Services
- """
-
- def __init__(self):
- self.services = {
- "account": {
- "email": "test@test.com",
- "firstname": "Test",
- "lastname": "User",
- "username": "test",
- # Random characters are appended for unique
- # username
- "password": "password",
- },
- "service_offering": {
- "name": "Tiny Instance",
- "displaytext": "Tiny Instance",
- "cpunumber": 1,
- "cpuspeed": 100, # in MHz
- "memory": 128, # In MBs
- },
- "disk_offering": {
- "displaytext": "Small",
- "name": "Small",
- "disksize": 1
- },
- "virtual_machine": {
- "displayname": "testVM",
- "hypervisor": 'XenServer',
- "protocol": 'TCP',
- "ssh_port": 22,
- "username": "root",
- "password": "password",
- "privateport": 22,
- "publicport": 22,
- },
- "volume": {
- "diskname": "Test Volume",
- },
- "template_1": {
- "displaytext": "Cent OS Template",
- "name": "Cent OS Template",
- "ostype": "CentOS 5.3 (64-bit)",
- },
- "template_2": {
- "displaytext": "Public Template",
- "name": "Public template",
- "ostype": "CentOS 5.3 (64-bit)",
- "isfeatured": True,
- "ispublic": True,
- "isextractable": True,
- "mode": "HTTP_DOWNLOAD",
- },
- "templatefilter": 'self',
- "isfeatured": True,
- "ispublic": True,
- "isextractable": False,
- "bootable": True,
- "passwordenabled": True,
- "ostype": "CentOS 5.3 (64-bit)",
- "sleep": 30,
- "timeout": 10,
- }
-
-
class TestCreateTemplate(cloudstackTestCase):
def setUp(self):
@@ -118,23 +53,28 @@ class TestCreateTemplate(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.services = Services().services
- cls.api_client = super(TestCreateTemplate, cls).getClsTestClient().getApiClient()
+
+ testClient = super(TestCreateTemplate, cls).getClsTestClient()
+ cls.apiclient = testClient.getApiClient()
+ cls.services = testClient.getParsedTestDataConfig()
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.apiclient)
+ cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests())
cls.services['mode'] = cls.zone.networktype
cls.disk_offering = DiskOffering.create(
- cls.api_client,
+ cls.apiclient,
cls.services["disk_offering"]
)
template = get_template(
- cls.api_client,
+ cls.apiclient,
cls.zone.id,
cls.services["ostype"]
)
- cls.services["template_1"]["ostypeid"] = template.ostypeid
+ if template == FAILED:
+ assert False, "get_template() failed to return template with description %s" % cls.services["ostype"]
+
+ cls.services["template"]["ostypeid"] = template.ostypeid
cls.services["template_2"]["ostypeid"] = template.ostypeid
cls.services["ostypeid"] = template.ostypeid
@@ -144,19 +84,17 @@ class TestCreateTemplate(cloudstackTestCase):
cls.services["sourcezoneid"] = cls.zone.id
cls.account = Account.create(
- cls.api_client,
+ cls.apiclient,
cls.services["account"],
domainid=cls.domain.id
)
- cls.services["account"] = cls.account.name
-
cls.service_offering = ServiceOffering.create(
- cls.api_client,
- cls.services["service_offering"]
+ cls.apiclient,
+ cls.services["service_offerings"]
)
#create virtual machine
cls.virtual_machine = VirtualMachine.create(
- cls.api_client,
+ cls.apiclient,
cls.services["virtual_machine"],
templateid=template.id,
accountid=cls.account.name,
@@ -166,7 +104,7 @@ class TestCreateTemplate(cloudstackTestCase):
)
#Stop virtual machine
- cls.virtual_machine.stop(cls.api_client)
+ cls.virtual_machine.stop(cls.apiclient)
# Poll listVM to ensure VM is stopped properly
timeout = cls.services["timeout"]
@@ -175,7 +113,7 @@ class TestCreateTemplate(cloudstackTestCase):
# Ensure that VM is in stopped state
list_vm_response = list_virtual_machines(
- cls.api_client,
+ cls.apiclient,
id=cls.virtual_machine.id
)
@@ -193,7 +131,7 @@ class TestCreateTemplate(cloudstackTestCase):
timeout = timeout - 1
list_volume = list_volumes(
- cls.api_client,
+ cls.apiclient,
virtualmachineid=cls.virtual_machine.id,
type='ROOT',
listall=True
@@ -210,9 +148,9 @@ class TestCreateTemplate(cloudstackTestCase):
@classmethod
def tearDownClass(cls):
try:
- cls.api_client = super(TestCreateTemplate, cls).getClsTestClient().getApiClient()
+ cls.apiclient = super(TestCreateTemplate, cls).getClsTestClient().getApiClient()
#Cleanup resources used
- cleanup_resources(cls.api_client, cls._cleanup)
+ cleanup_resources(cls.apiclient, cls._cleanup)
except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e)
@@ -233,7 +171,7 @@ class TestCreateTemplate(cloudstackTestCase):
#Create template from Virtual machine and Volume ID
template = Template.create(
self.apiclient,
- self.services["template_1"],
+ self.services["template"],
self.volume.id,
account=self.account.name,
domainid=self.account.domainid
@@ -264,18 +202,18 @@ class TestCreateTemplate(cloudstackTestCase):
self.assertEqual(
template_response.displaytext,
- self.services["template_1"]["displaytext"],
+ self.services["template"]["displaytext"],
"Check display text of newly created template"
)
name = template_response.name
self.assertEqual(
- name.count(self.services["template_1"]["name"]),
+ name.count(self.services["template"]["name"]),
1,
"Check name of newly created template"
)
self.assertEqual(
template_response.ostypeid,
- self.services["template_1"]["ostypeid"],
+ self.services["template"]["ostypeid"],
"Check osTypeID of newly created template"
)
return
@@ -286,60 +224,61 @@ class TestTemplates(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.services = Services().services
- cls.api_client = super(TestTemplates, cls).getClsTestClient().getApiClient()
+ testClient = super(TestTemplates, cls).getClsTestClient()
+ cls.apiclient = testClient.getApiClient()
+ cls.services = testClient.getParsedTestDataConfig()
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.apiclient)
+ cls.zone = get_zone(cls.apiclient, cls.testClient.getZoneForTests())
cls.services['mode'] = cls.zone.networktype
#populate second zone id for iso copy
cmd = listZones.listZonesCmd()
- cls.zones = cls.api_client.listZones(cmd)
+ cls.zones = cls.apiclient.listZones(cmd)
if not isinstance(cls.zones, list):
raise Exception("Failed to find zones.")
cls.disk_offering = DiskOffering.create(
- cls.api_client,
+ cls.apiclient,
cls.services["disk_offering"]
)
template = get_template(
- cls.api_client,
+ cls.apiclient,
cls.zone.id,
cls.services["ostype"]
)
+ if template == FAILED:
+ assert False, "get_template() failed to return template with description %s" % cls.services["ostype"]
+
cls.services["virtual_machine"]["zoneid"] = cls.zone.id
cls.services["volume"]["diskoffering"] = cls.disk_offering.id
cls.services["volume"]["zoneid"] = cls.zone.id
cls.services["template_2"]["zoneid"] = cls.zone.id
cls.services["sourcezoneid"] = cls.zone.id
- cls.services["template_1"]["ostypeid"] = template.ostypeid
+ cls.services["template"]["ostypeid"] = template.ostypeid
cls.services["template_2"]["ostypeid"] = template.ostypeid
cls.services["ostypeid"] = template.ostypeid
-
+ print "Before:",cls.services
cls.account = Account.create(
- cls.api_client,
+ cls.apiclient,
cls.services["account"],
admin=True,
domainid=cls.domain.id
)
-
+ print "After:",cls.services
cls.user = Account.create(
- cls.api_client,
+ cls.apiclient,
cls.services["account"],
domainid=cls.domain.id
)
-
- cls.services["account"] = cls.account.name
-
cls.service_offering = ServiceOffering.create(
- cls.api_client,
- cls.services["service_offering"]
+ cls.apiclient,
+ cls.services["service_offerings"]
)
#create virtual machine
cls.virtual_machine = VirtualMachine.create(
- cls.api_client,
+ cls.apiclient,
cls.services["virtual_machine"],
templateid=template.id,
accountid=cls.account.name,
@@ -348,7 +287,7 @@ class TestTemplates(cloudstackTestCase):
mode=cls.services["mode"]
)
#Stop virtual machine
- cls.virtual_machine.stop(cls.api_client)
+ cls.virtual_machine.stop(cls.apiclient)
# Poll listVM to ensure VM is stopped properly
timeout = cls.services["timeout"]
@@ -357,7 +296,7 @@ class TestTemplates(cloudstackTestCase):
# Ensure that VM is in stopped state
list_vm_response = list_virtual_machines(
- cls.api_client,
+ cls.apiclient,
id=cls.virtual_machine.id
)
@@ -375,7 +314,7 @@ class TestTemplates(cloudstackTestCase):
timeout = timeout - 1
list_volume = list_volumes(
- cls.api_client,
+ cls.apiclient,
virtualmachineid=cls.virtual_machine.id,
type='ROOT',
listall=True
@@ -389,14 +328,14 @@ class TestTemplates(cloudstackTestCase):
#Create templates for Edit, Delete & update permissions testcases
cls.template_1 = Template.create(
- cls.api_client,
- cls.services["template_1"],
+ cls.apiclient,
+ cls.services["template"],
cls.volume.id,
account=cls.account.name,
domainid=cls.account.domainid
)
cls.template_2 = Template.create(
- cls.api_client,
+ cls.apiclient,
cls.services["template_2"],
cls.volume.id,
account=cls.account.name,
@@ -412,9 +351,9 @@ class TestTemplates(cloudstackTestCase):
@classmethod
def tearDownClass(cls):
try:
- cls.api_client = super(TestTemplates, cls).getClsTestClient().getApiClient()
+ cls.apiclient = super(TestTemplates, cls).getClsTestClient().getApiClient()
#Cleanup created resources such as templates and VMs
- cleanup_resources(cls.api_client, cls._cleanup)
+ cleanup_resources(cls.apiclient, cls._cleanup)
except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e)
@@ -438,7 +377,7 @@ class TestTemplates(cloudstackTestCase):
return
- @attr(tags = ["advanced", "advancedns", "smoke", "basic", "sg", "selfservice"])
+ @attr(tags = ["advanced", "advancedns", "smoke", "basic", "sg", "selfservice", "test"])
def test_02_edit_template(self):
"""Test Edit template
"""
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/smoke/test_vm_ha.py
----------------------------------------------------------------------
diff --git a/test/integration/smoke/test_vm_ha.py b/test/integration/smoke/test_vm_ha.py
index 2dd514d..f549243 100644
--- a/test/integration/smoke/test_vm_ha.py
+++ b/test/integration/smoke/test_vm_ha.py
@@ -25,13 +25,13 @@ from marvin.cloudstackTestCase import cloudstackTestCase
#Import Integration Libraries
#base - contains all resources as entities and defines create, delete, list operations on them
-from marvin.integration.lib.base import Account, VirtualMachine, Cluster, Host, ServiceOffering, Configurations, SimulatorMock
+from marvin.lib.base import Account, VirtualMachine, Cluster, Host, ServiceOffering, Configurations, SimulatorMock
#utils - utility classes for common cleanup, external library wrappers etc
-from marvin.integration.lib.utils import cleanup_resources
+from marvin.lib.utils import cleanup_resources
#common - commonly used methods for all tests are listed here
-from marvin.integration.lib.common import get_zone, get_domain, get_template
+from marvin.lib.common import get_zone, get_domain, get_template
from nose.plugins.attrib import attr
[18/18] git commit: updated refs/heads/4.4 to 798a6aa
Posted by da...@apache.org.
Marvin + test changes from master Signed-off-by: SrikanteswaraRao Talluri <ta...@apache.org>
Signed-off-by: SrikanteswaraRao Talluri <ta...@apache.org>
(cherry picked from commit 404ac549bfd84e97c756009f214e74cdb73548de)
Conflicts:
test/integration/smoke/test_vm_iam.py
tools/marvin/marvin/deployDataCenter.py
tools/marvin/marvin/lib/base.py
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/798a6aa2
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/798a6aa2
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/798a6aa2
Branch: refs/heads/4.4
Commit: 798a6aa2e3fd47368b6ba94483f42e9658ad9835
Parents: 8fb89cd
Author: SrikanteswaraRao Talluri <ta...@apache.org>
Authored: Mon Apr 28 14:55:11 2014 +0530
Committer: Daan Hoogland <da...@onecht.net>
Committed: Mon Jul 28 17:40:56 2014 +0200
----------------------------------------------------------------------
.../maint/test_egress_rules_host_maintenance.py | 20 +-
.../component/maint/test_high_availability.py | 26 +-
.../maint/test_host_high_availability.py | 36 +-
.../component/maint/test_multiple_ip_ranges.py | 20 +-
.../component/maint/test_redundant_router.py | 70 +-
...test_redundant_router_deployment_planning.py | 17 +-
.../test_redundant_router_network_rules.py | 17 +-
.../maint/test_vpc_host_maintenance.py | 21 +-
.../maint/test_vpc_on_host_maintenance.py | 17 +-
.../component/test_VirtualRouter_alerts.py | 22 +-
test/integration/component/test_accounts.py | 141 +-
.../component/test_add_remove_network.py | 118 +-
.../component/test_advancedsg_networks.py | 71 +-
.../component/test_affinity_groups.py | 115 +-
.../component/test_allocation_states.py | 39 +-
test/integration/component/test_asa1000v_fw.py | 18 +-
test/integration/component/test_assign_vm.py | 39 +-
test/integration/component/test_baremetal.py | 28 +-
.../component/test_base_image_updation.py | 22 +-
test/integration/component/test_blocker_bugs.py | 74 +-
.../component/test_cpu_domain_limits.py | 38 +-
test/integration/component/test_cpu_limits.py | 35 +-
.../component/test_cpu_max_limits.py | 25 +-
.../component/test_cpu_project_limits.py | 17 +-
.../component/test_custom_hostname.py | 44 +-
.../component/test_deploy_vm_userdata_reg.py | 19 +-
.../component/test_dynamic_compute_offering.py | 44 +-
.../component/test_egress_fw_rules.py | 19 +-
test/integration/component/test_egress_rules.py | 126 +-
test/integration/component/test_eip_elb.py | 22 +-
test/integration/component/test_escalations.py | 8230 ++++++++++++++++++
.../component/test_explicit_dedication.py | 15 +-
test/integration/component/test_haproxy.py | 15 +-
.../component/test_implicit_planner.py | 15 +-
.../component/test_ip_reservation.py | 109 +-
test/integration/component/test_ldap.py | 6 +-
.../integration/component/test_memory_limits.py | 32 +-
.../component/test_mm_domain_limits.py | 36 +-
.../integration/component/test_mm_max_limits.py | 23 +-
.../component/test_mm_project_limits.py | 17 +-
.../component/test_multiple_ip_ranges.py | 28 +-
.../component/test_multiple_ips_per_nic.py | 490 +-
.../component/test_netscaler_configs.py | 116 +-
test/integration/component/test_netscaler_lb.py | 116 +-
.../component/test_netscaler_lb_algo.py | 106 +-
.../component/test_netscaler_lb_sticky.py | 17 +-
.../component/test_netscaler_nw_off.py | 82 +-
.../component/test_network_offering.py | 39 +-
.../component/test_non_contiguous_vlan.py | 22 +-
.../component/test_persistent_networks.py | 112 +-
test/integration/component/test_portable_ip.py | 142 +-
.../component/test_project_configs.py | 62 +-
.../component/test_project_limits.py | 35 +-
.../component/test_project_resources.py | 69 +-
.../integration/component/test_project_usage.py | 102 +-
test/integration/component/test_projects.py | 109 +-
.../component/test_recurring_snapshots.py | 16 +-
.../component/test_redundant_router_cleanups.py | 17 +-
.../component/test_redundant_router_services.py | 17 +-
.../component/test_redundant_router_upgrades.py | 17 +-
test/integration/component/test_region_vpc.py | 38 +-
test/integration/component/test_regions.py | 8 +-
.../component/test_regions_accounts.py | 8 +-
.../component/test_reset_ssh_keypair.py | 24 +-
.../component/test_resource_limits.py | 33 +-
test/integration/component/test_routers.py | 45 +-
.../component/test_security_groups.py | 59 +-
.../component/test_shared_networks.py | 17 +-
test/integration/component/test_snapshot_gc.py | 16 +-
.../component/test_snapshot_limits.py | 16 +-
test/integration/component/test_snapshots.py | 34 +-
.../component/test_snapshots_improvement.py | 26 +-
test/integration/component/test_stopped_vm.py | 99 +-
.../component/test_storage_motion.py | 15 +-
test/integration/component/test_tags.py | 34 +-
test/integration/component/test_templates.py | 31 +-
test/integration/component/test_update_vm.py | 12 +-
test/integration/component/test_usage.py | 78 +-
.../component/test_vm_passwdenabled.py | 18 +-
test/integration/component/test_vmware_drs.py | 61 +-
test/integration/component/test_volumes.py | 60 +-
test/integration/component/test_vpc.py | 49 +-
.../test_vpc_distributed_routing_offering.py | 35 +-
test/integration/component/test_vpc_network.py | 54 +-
.../component/test_vpc_network_lbrules.py | 17 +-
.../component/test_vpc_network_pfrules.py | 17 +-
.../component/test_vpc_network_staticnatrule.py | 17 +-
.../integration/component/test_vpc_offerings.py | 17 +-
test/integration/component/test_vpc_routers.py | 200 +-
.../component/test_vpc_vm_life_cycle.py | 61 +-
.../component/test_vpc_vms_deployment.py | 17 +-
test/integration/component/test_vpn_users.py | 23 +-
test/integration/smoke/test_affinity_groups.py | 85 +-
.../smoke/test_deploy_vgpu_enabled_vm.py | 18 +-
test/integration/smoke/test_deploy_vm.py | 60 +-
.../smoke/test_deploy_vm_root_resize.py | 29 +-
.../smoke/test_deploy_vm_with_userdata.py | 60 +-
...deploy_vms_with_varied_deploymentplanners.py | 56 +-
test/integration/smoke/test_disk_offerings.py | 125 +-
test/integration/smoke/test_global_settings.py | 6 +-
test/integration/smoke/test_guest_vlan_range.py | 39 +-
test/integration/smoke/test_hosts.py | 88 +-
test/integration/smoke/test_internal_lb.py | 79 +-
test/integration/smoke/test_iso.py | 125 +-
test/integration/smoke/test_loadbalance.py | 126 +-
.../smoke/test_multipleips_per_nic.py | 50 +-
test/integration/smoke/test_network.py | 230 +-
test/integration/smoke/test_network_acl.py | 74 +-
test/integration/smoke/test_nic.py | 118 +-
.../smoke/test_non_contigiousvlan.py | 4 +-
.../integration/smoke/test_over_provisioning.py | 29 +-
.../integration/smoke/test_portable_publicip.py | 110 +-
test/integration/smoke/test_primary_storage.py | 31 +-
test/integration/smoke/test_privategw_acl.py | 6 +-
test/integration/smoke/test_public_ip_range.py | 50 +-
test/integration/smoke/test_pvlan.py | 18 +-
test/integration/smoke/test_regions.py | 35 +-
.../smoke/test_reset_vm_on_reboot.py | 86 +-
test/integration/smoke/test_resource_detail.py | 95 +-
test/integration/smoke/test_routers.py | 90 +-
test/integration/smoke/test_scale_vm.py | 97 +-
.../integration/smoke/test_secondary_storage.py | 12 +-
.../integration/smoke/test_service_offerings.py | 136 +-
test/integration/smoke/test_snapshots.py | 135 +-
test/integration/smoke/test_ssvm.py | 34 +-
test/integration/smoke/test_templates.py | 175 +-
test/integration/smoke/test_vm_ha.py | 6 +-
test/integration/smoke/test_vm_iam.py | 719 ++
test/integration/smoke/test_vm_life_cycle.py | 186 +-
test/integration/smoke/test_vm_snapshots.py | 106 +-
test/integration/smoke/test_volumes.py | 177 +-
test/integration/smoke/test_vpc_vpn.py | 112 +-
tools/marvin/marvin/__init__.py | 2 +-
tools/marvin/marvin/asyncJobMgr.py | 12 +-
tools/marvin/marvin/cloudstackConnection.py | 476 +-
tools/marvin/marvin/cloudstackException.py | 19 +-
tools/marvin/marvin/cloudstackTestCase.py | 6 +-
tools/marvin/marvin/cloudstackTestClient.py | 550 +-
tools/marvin/marvin/codegenerator.py | 15 +-
tools/marvin/marvin/codes.py | 21 +-
tools/marvin/marvin/config/__init__.py | 16 +
tools/marvin/marvin/config/config.cfg | 38 +-
tools/marvin/marvin/config/test_data.cfg | 427 +
tools/marvin/marvin/config/test_data.py | 629 ++
tools/marvin/marvin/configGenerator.py | 230 +-
tools/marvin/marvin/dbConnection.py | 9 +-
tools/marvin/marvin/deployAndRun.py | 6 +-
tools/marvin/marvin/deployDataCenter.py | 1530 ++--
tools/marvin/marvin/integration/__init__.py | 18 -
tools/marvin/marvin/integration/lib/__init__.py | 16 -
tools/marvin/marvin/integration/lib/base.py | 3890 ---------
tools/marvin/marvin/integration/lib/common.py | 1036 ---
tools/marvin/marvin/integration/lib/utils.py | 453 -
tools/marvin/marvin/jsonHelper.py | 9 +-
tools/marvin/marvin/lib/__init__.py | 16 +
tools/marvin/marvin/lib/base.py | 4086 +++++++++
tools/marvin/marvin/lib/common.py | 1062 +++
tools/marvin/marvin/lib/utils.py | 498 ++
tools/marvin/marvin/marvinInit.py | 250 +-
tools/marvin/marvin/marvinLog.py | 141 +-
tools/marvin/marvin/marvinPlugin.py | 308 +-
tools/marvin/marvin/src/__init__.py | 16 +
tools/marvin/marvin/sshClient.py | 142 +-
tools/marvin/marvin/tcExecuteEngine.py | 10 +-
tools/marvin/marvin/testSetupSuccess.py | 1 +
tools/marvin/setup.py | 60 +-
166 files changed, 21569 insertions(+), 11017 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/component/maint/test_egress_rules_host_maintenance.py
----------------------------------------------------------------------
diff --git a/test/integration/component/maint/test_egress_rules_host_maintenance.py b/test/integration/component/maint/test_egress_rules_host_maintenance.py
index 2b81787..a27ada3 100644
--- a/test/integration/component/maint/test_egress_rules_host_maintenance.py
+++ b/test/integration/component/maint/test_egress_rules_host_maintenance.py
@@ -23,9 +23,9 @@ from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
from marvin.sshClient import SshClient
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
#Import System modules
import time
@@ -100,19 +100,17 @@ class TestEgressAfterHostMaintenance(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.services = Services().services
- cls.api_client = super(
- TestEgressAfterHostMaintenance,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestEgressAfterHostMaintenance, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+ cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.services['mode'] = cls.zone.networktype
cls.pod = get_pod(
cls.api_client,
- zoneid=cls.zone.id
+ zone_id=cls.zone.id
)
template = get_template(
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/component/maint/test_high_availability.py
----------------------------------------------------------------------
diff --git a/test/integration/component/maint/test_high_availability.py b/test/integration/component/maint/test_high_availability.py
index 6ada659..cc687f8 100644
--- a/test/integration/component/maint/test_high_availability.py
+++ b/test/integration/component/maint/test_high_availability.py
@@ -23,9 +23,9 @@ import marvin
from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
from marvin.sshClient import SshClient
import datetime
@@ -107,24 +107,16 @@ class TestHighAvailability(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(
- TestHighAvailability,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestHighAvailability, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(
- cls.api_client,
- cls.services
- )
- cls.zone = get_zone(
- cls.api_client,
- cls.services
- )
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.pod = get_pod(
cls.api_client,
- zoneid=cls.zone.id,
- services=cls.services
+ zone_id=cls.zone.id
)
cls.template = get_template(
cls.api_client,
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/component/maint/test_host_high_availability.py
----------------------------------------------------------------------
diff --git a/test/integration/component/maint/test_host_high_availability.py b/test/integration/component/maint/test_host_high_availability.py
index b4c50c7..4cd7fd8 100644
--- a/test/integration/component/maint/test_host_high_availability.py
+++ b/test/integration/component/maint/test_host_high_availability.py
@@ -21,9 +21,10 @@
from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
+import time
class Services:
@@ -76,20 +77,13 @@ class TestHostHighAvailability(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(
- TestHostHighAvailability,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestHostHighAvailability, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(
- cls.api_client,
- cls.services
- )
- cls.zone = get_zone(
- cls.api_client,
- cls.services
- )
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.template = get_template(
cls.api_client,
@@ -626,11 +620,7 @@ class TestHostHighAvailability(cloudstackTestCase):
#verify the VM live migration happened to another running host
self.debug("Waiting for VM to come up")
- wait_for_vm(
- self.apiclient,
- virtualmachineid=vm_with_ha_enabled.id,
- interval=timeout
- )
+ time.sleep(timeout)
vms = VirtualMachine.list(
self.apiclient,
@@ -758,11 +748,7 @@ class TestHostHighAvailability(cloudstackTestCase):
#verify the VM live migration happened to another running host
self.debug("Waiting for VM to come up")
- wait_for_vm(
- self.apiclient,
- virtualmachineid=vm_with_ha_disabled.id,
- interval=timeout
- )
+ time.sleep(timeout)
vms = VirtualMachine.list(
self.apiclient,
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/component/maint/test_multiple_ip_ranges.py
----------------------------------------------------------------------
diff --git a/test/integration/component/maint/test_multiple_ip_ranges.py b/test/integration/component/maint/test_multiple_ip_ranges.py
index dc8021b..982dd7c 100644
--- a/test/integration/component/maint/test_multiple_ip_ranges.py
+++ b/test/integration/component/maint/test_multiple_ip_ranges.py
@@ -18,10 +18,10 @@
"""
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
-from marvin.cloudstackException import cloudstackAPIException
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.cloudstackException import CloudstackAPIException
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
# from netaddr import *
import netaddr
from nose.plugins.attrib import attr
@@ -87,13 +87,15 @@ class TestMultipleIpRanges(cloudstackTestCase):
"""
@classmethod
def setUpClass(cls):
- cls.api_client = super(TestMultipleIpRanges, cls).getClsTestClient().getApiClient()
- cls.dbclient = super(TestMultipleIpRanges, cls).getClsTestClient().getDbConnection()
+ cls.testClient = super(TestEgressAfterHostMaintenance, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+ cls.dbclient = cls.testClient.getDbConnection()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
- cls.pod = get_pod(cls.api_client, cls.zone.id, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
+ cls.pod = get_pod(cls.api_client, cls.zone.id)
cls.services['mode'] = cls.zone.networktype
cls.services["domainid"] = cls.domain.id
cls.services["zoneid"] = cls.zone.id
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/component/maint/test_redundant_router.py
----------------------------------------------------------------------
diff --git a/test/integration/component/maint/test_redundant_router.py b/test/integration/component/maint/test_redundant_router.py
index 617a546..66bb477 100644
--- a/test/integration/component/maint/test_redundant_router.py
+++ b/test/integration/component/maint/test_redundant_router.py
@@ -16,9 +16,9 @@
# under the License.
from nose.plugins.attrib import attr
-from marvin.integration.lib.base import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.common import *
+from marvin.lib.base import *
+from marvin.lib.utils import *
+from marvin.lib.common import *
#Import Local Modules
from marvin.cloudstackTestCase import cloudstackTestCase
@@ -137,14 +137,13 @@ class TestCreateRvRNetworkOffering(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(
- TestCreateRvRNetworkOffering,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestCreateRvRNetworkOffering, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls._cleanup = []
return
@@ -231,14 +230,13 @@ class TestCreateRvRNetwork(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(
- TestCreateRvRNetwork,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestCreateRvRNetwork, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.template = get_template(
cls.api_client,
cls.zone.id,
@@ -433,14 +431,13 @@ class TestCreateRvRNetworkNonDefaultGuestCidr(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(
- TestCreateRvRNetworkNonDefaultGuestCidr,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestCreateRvRNetworkNonDefaultGuestCidr, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.template = get_template(
cls.api_client,
cls.zone.id,
@@ -642,14 +639,13 @@ class TestRVRInternals(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(
- TestRVRInternals,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestRVRInternals, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.template = get_template(
cls.api_client,
cls.zone.id,
@@ -685,6 +681,7 @@ class TestRVRInternals(cloudstackTestCase):
def setUp(self):
self.apiclient = self.testClient.getApiClient()
+ self.hypervisor = self.testClient.getHypervisorInfo()
self.dbclient = self.testClient.getDbConnection()
self.account = Account.create(
self.apiclient,
@@ -846,7 +843,7 @@ class TestRVRInternals(cloudstackTestCase):
self.debug(master_router.linklocalip)
# Check eth2 port for master router
- if self.apiclient.hypervisor.lower() == 'vmware':
+ if self.hypervisor.lower() == 'vmware':
result = get_process_status(
self.apiclient.connection.mgtSvr,
22,
@@ -854,7 +851,7 @@ class TestRVRInternals(cloudstackTestCase):
self.apiclient.connection.passwd,
master_router.linklocalip,
'ip addr show eth2',
- hypervisor=self.apiclient.hypervisor
+ hypervisor=self.hypervisor
)
else:
result = get_process_status(
@@ -882,7 +879,7 @@ class TestRVRInternals(cloudstackTestCase):
)
# Check eth2 port for backup router
- if self.apiclient.hypervisor.lower() == 'vmware':
+ if self.hypervisor.lower() == 'vmware':
result = get_process_status(
self.apiclient.connection.mgtSvr,
22,
@@ -890,7 +887,7 @@ class TestRVRInternals(cloudstackTestCase):
self.apiclient.connction.passwd,
backup_router.linklocalip,
'ip addr show eth2',
- hypervisor=self.apiclient.hypervisor
+ hypervisor=self.hypervisor
)
else:
result = get_process_status(
@@ -945,14 +942,13 @@ class TestRvRRedundancy(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(
- TestRvRRedundancy,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestRvRRedundancy, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.template = get_template(
cls.api_client,
cls.zone.id,
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/component/maint/test_redundant_router_deployment_planning.py
----------------------------------------------------------------------
diff --git a/test/integration/component/maint/test_redundant_router_deployment_planning.py b/test/integration/component/maint/test_redundant_router_deployment_planning.py
index 879a4da..b63cda9 100644
--- a/test/integration/component/maint/test_redundant_router_deployment_planning.py
+++ b/test/integration/component/maint/test_redundant_router_deployment_planning.py
@@ -16,9 +16,9 @@
# under the License.
from nose.plugins.attrib import attr
-from marvin.integration.lib.base import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.common import *
+from marvin.lib.base import *
+from marvin.lib.utils import *
+from marvin.lib.common import *
#Import Local Modules
from marvin.cloudstackTestCase import cloudstackTestCase
@@ -136,14 +136,13 @@ class TestRvRDeploymentPlanning(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(
- TestRvRDeploymentPlanning,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestRvRDeploymentPlanning, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.template = get_template(
cls.api_client,
cls.zone.id,
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/component/maint/test_redundant_router_network_rules.py
----------------------------------------------------------------------
diff --git a/test/integration/component/maint/test_redundant_router_network_rules.py b/test/integration/component/maint/test_redundant_router_network_rules.py
index 010aaaa..12c4d2c 100644
--- a/test/integration/component/maint/test_redundant_router_network_rules.py
+++ b/test/integration/component/maint/test_redundant_router_network_rules.py
@@ -16,9 +16,9 @@
# under the License.
from nose.plugins.attrib import attr
-from marvin.integration.lib.base import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.common import *
+from marvin.lib.base import *
+from marvin.lib.utils import *
+from marvin.lib.common import *
#Import Local Modules
from marvin.cloudstackTestCase import cloudstackTestCase
@@ -137,14 +137,13 @@ class TestRedundantRouterRulesLifeCycle(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(
- TestRedundantRouterRulesLifeCycle,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestRedundantRouterRulesLifeCycle, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.template = get_template(
cls.api_client,
cls.zone.id,
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/component/maint/test_vpc_host_maintenance.py
----------------------------------------------------------------------
diff --git a/test/integration/component/maint/test_vpc_host_maintenance.py b/test/integration/component/maint/test_vpc_host_maintenance.py
index 57dfb4b..83ba271 100644
--- a/test/integration/component/maint/test_vpc_host_maintenance.py
+++ b/test/integration/component/maint/test_vpc_host_maintenance.py
@@ -22,11 +22,9 @@ import marvin
from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
-from marvin.sshClient import SshClient
-import datetime
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
class Services:
@@ -190,14 +188,13 @@ class TestVMLifeCycleHostmaintenance(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(
- TestVMLifeCycleHostmaintenance,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestVMLifeCycleHostmaintenance, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.template = get_template(
cls.api_client,
cls.zone.id,
@@ -554,4 +551,4 @@ class TestVMLifeCycleHostmaintenance(cloudstackTestCase):
"Router state should be running"
)
# TODO: Check for the network connectivity
- return
\ No newline at end of file
+ return
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/component/maint/test_vpc_on_host_maintenance.py
----------------------------------------------------------------------
diff --git a/test/integration/component/maint/test_vpc_on_host_maintenance.py b/test/integration/component/maint/test_vpc_on_host_maintenance.py
index 6630ee6..eb3360a 100644
--- a/test/integration/component/maint/test_vpc_on_host_maintenance.py
+++ b/test/integration/component/maint/test_vpc_on_host_maintenance.py
@@ -18,9 +18,9 @@
from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
class Services:
@@ -77,14 +77,13 @@ class TestVPCHostMaintenance(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(
- TestVPCHostMaintenance,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestVPCHostMaintenance, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.template = get_template(
cls.api_client,
cls.zone.id,
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/component/test_VirtualRouter_alerts.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_VirtualRouter_alerts.py b/test/integration/component/test_VirtualRouter_alerts.py
index 4b53e3f..e6f0a82 100644
--- a/test/integration/component/test_VirtualRouter_alerts.py
+++ b/test/integration/component/test_VirtualRouter_alerts.py
@@ -20,10 +20,11 @@
import marvin
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
from nose.plugins.attrib import attr
+from marvin.codes import FAILED
import time
@@ -96,12 +97,13 @@ class Services:
class TestVRServiceFailureAlerting(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(TestVRServiceFailureAlerting, cls).getClsTestClient().getApiClient()
+ cls.testClient = super(TestVRServiceFailureAlerting, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
cls.services = Services().services
# Get Zone, Domain and templates
- domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
+ domain = get_domain(cls.api_client)
cls.services['mode'] = cls.zone.networktype
template = get_template(
@@ -109,6 +111,9 @@ class TestVRServiceFailureAlerting(cloudstackTestCase):
cls.zone.id,
cls.services["ostype"]
)
+
+ if template == FAILED:
+ assert False, "get_template() failed to return template with description %s" % cls.services["ostype"]
# Set Zones and disk offerings ??
cls.services["small"]["zoneid"] = cls.zone.id
cls.services["small"]["template"] = template.id
@@ -148,6 +153,7 @@ class TestVRServiceFailureAlerting(cloudstackTestCase):
def setUp(self):
self.apiclient = self.testClient.getApiClient()
self.dbclient = self.testClient.getDbConnection()
+ self.hypervisor = self.testClient.getHypervisorInfo()
self.cleanup = []
def tearDown(self):
@@ -202,7 +208,7 @@ class TestVRServiceFailureAlerting(cloudstackTestCase):
alertSubject = "Monitoring Service on VR " + router.name
- if self.apiclient.hypervisor.lower() == 'vmware':
+ if self.hypervisor.lower() == 'vmware':
result = get_process_status(
self.apiclient.connection.mgtSvr,
22,
@@ -210,7 +216,7 @@ class TestVRServiceFailureAlerting(cloudstackTestCase):
self.apiclient.connection.passwd,
router.linklocalip,
"service dnsmasq status",
- hypervisor=self.apiclient.hypervisor
+ hypervisor=self.hypervisor
)
else:
try:
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/component/test_accounts.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_accounts.py b/test/integration/component/test_accounts.py
index bee17fb..cf5f2b6 100644
--- a/test/integration/component/test_accounts.py
+++ b/test/integration/component/test_accounts.py
@@ -17,14 +17,32 @@
""" P1 tests for Account
"""
#Import Local Modules
-from marvin.cloudstackTestCase import *
-from marvin.cloudstackAPI import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
-from marvin.sshClient import SshClient
+from marvin.cloudstackTestCase import cloudstackTestCase
+#from marvin.cloudstackAPI import *
+from marvin.lib.utils import (random_gen,
+ cleanup_resources)
+from marvin.lib.base import (Domain,
+ Account,
+ ServiceOffering,
+ VirtualMachine,
+ Network,
+ User,
+ NATRule,
+ Template,
+ PublicIPAddress)
+from marvin.lib.common import (get_domain,
+ get_zone,
+ get_template,
+ list_accounts,
+ list_virtual_machines,
+ list_service_offering,
+ list_templates,
+ list_users,
+ get_builtin_template_info,
+ wait_for_cleanup)
from nose.plugins.attrib import attr
-from marvin.cloudstackException import cloudstackAPIException
+from marvin.cloudstackException import CloudstackAPIException
+import time
class Services:
"""Test Account Services
@@ -102,13 +120,11 @@ class TestAccounts(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(
- TestAccounts,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestAccounts, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
- # Get Zone, Domain and templates
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.services['mode'] = cls.zone.networktype
cls.template = get_template(
cls.api_client,
@@ -232,13 +248,11 @@ class TestRemoveUserFromAccount(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(
- TestRemoveUserFromAccount,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestRemoveUserFromAccount, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
- # Get Zone, Domain and templates
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.services['mode'] = cls.zone.networktype
cls.template = get_template(
cls.api_client,
@@ -392,13 +406,11 @@ class TestNonRootAdminsPrivileges(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(
- TestNonRootAdminsPrivileges,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestNonRootAdminsPrivileges, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
- # Get Zone settings
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.services['mode'] = cls.zone.networktype
# Create an account, domain etc
cls.domain = Domain.create(
@@ -726,12 +738,12 @@ class TestTemplateHierarchy(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(
- TestTemplateHierarchy,
- cls).getClsTestClient().getApiClient()
+ cls.testClient = super(TestTemplateHierarchy, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+ cls.hypervisor = cls.testClient.getHypervisorInfo()
+
cls.services = Services().services
- # Get Zone settings
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.services['mode'] = cls.zone.networktype
# Create domains, accounts and template
@@ -772,7 +784,8 @@ class TestTemplateHierarchy(cloudstackTestCase):
cls.services["template"],
zoneid=cls.zone.id,
account=cls.account_1.name,
- domainid=cls.domain_1.id
+ domainid=cls.domain_1.id,
+ hypervisor=cls.hypervisor
)
# Wait for template to download
@@ -879,21 +892,12 @@ class TestAddVmToSubDomain(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(
- TestAddVmToSubDomain,
- cls
- ).getClsTestClient().getApiClient()
- cls.services = Services().services
+ cls.testClient = super(TestAddVmToSubDomain, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
- # Setup working Environment- Create domain, zone, pod cluster etc.
- cls.domain = get_domain(
- cls.api_client,
- cls.services
- )
- cls.zone = get_zone(
- cls.api_client,
- cls.services,
- )
+ cls.services = Services().services
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.services['mode'] = cls.zone.networktype
cls.sub_domain = Domain.create(
cls.api_client,
@@ -1031,14 +1035,12 @@ class TestUserDetails(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(
- TestUserDetails,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestUserDetails, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
- # Get Zone, Domain etc
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.services['mode'] = cls.zone.networktype
cls._cleanup = []
return
@@ -1331,14 +1333,12 @@ class TestUserLogin(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(
- TestUserLogin,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestUserLogin, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
- # Get Zone, Domain etc
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.services['mode'] = cls.zone.networktype
cls._cleanup = []
return
@@ -1482,21 +1482,12 @@ class TestDomainForceRemove(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(
- TestDomainForceRemove,
- cls
- ).getClsTestClient().getApiClient()
- cls.services = Services().services
+ cls.testClient = super(TestDomainForceRemove, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
- # Setup working Environment- Create domain, zone, pod cluster etc.
- cls.domain = get_domain(
- cls.api_client,
- cls.services
- )
- cls.zone = get_zone(
- cls.api_client,
- cls.services,
- )
+ cls.services = Services().services
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.services['mode'] = cls.zone.networktype
cls.template = get_template(
@@ -1681,7 +1672,7 @@ class TestDomainForceRemove(cloudstackTestCase):
" to cleanup any remaining resouces")
# Sleep 3*account.gc to ensure that all resources are deleted
wait_for_cleanup(self.apiclient, ["account.cleanup.interval"]*3)
- with self.assertRaises(cloudstackAPIException):
+ with self.assertRaises(CloudstackAPIException):
Domain.list(
self.apiclient,
id=domain.id,
@@ -1689,7 +1680,7 @@ class TestDomainForceRemove(cloudstackTestCase):
)
self.debug("Checking if the resources in domain are deleted")
- with self.assertRaises(cloudstackAPIException):
+ with self.assertRaises(CloudstackAPIException):
Account.list(
self.apiclient,
name=self.account_1.name,
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/component/test_add_remove_network.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_add_remove_network.py b/test/integration/component/test_add_remove_network.py
index b2b3594..2aadb5b 100644
--- a/test/integration/component/test_add_remove_network.py
+++ b/test/integration/component/test_add_remove_network.py
@@ -29,7 +29,7 @@
from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import cloudstackTestCase, unittest
from ddt import ddt, data
-from marvin.integration.lib.base import (
+from marvin.lib.base import (
Account,
Domain,
ServiceOffering,
@@ -39,7 +39,7 @@ from marvin.integration.lib.base import (
VpcOffering,
VPC
)
-from marvin.integration.lib.common import (get_domain,
+from marvin.lib.common import (get_domain,
get_zone,
get_template,
list_virtual_machines,
@@ -49,7 +49,7 @@ from marvin.integration.lib.common import (get_domain,
update_resource_limit
)
-from marvin.integration.lib.utils import (validateList,
+from marvin.lib.utils import (validateList,
random_gen,
get_hypervisor_type,
cleanup_resources)
@@ -60,6 +60,7 @@ from marvin.cloudstackAPI import (addNicToVirtualMachine,
from marvin.codes import PASS
import random
+import time
class Services:
"""Test Add Remove Network Services
@@ -67,7 +68,7 @@ class Services:
def __init__(self):
self.services = {
-
+ "sleep": 60,
"ostype": "CentOS 5.3 (64-bit)",
# Cent OS 5.3 (64 bit)
@@ -173,7 +174,10 @@ class TestAddNetworkToVirtualMachine(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(TestAddNetworkToVirtualMachine, cls).getClsTestClient().getApiClient()
+ cls.testClient = super(TestAddNetworkToVirtualMachine, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
+ cls.services = Services().services
hypervisor = get_hypervisor_type(cls.api_client)
if hypervisor.lower() not in ["xenserver","kvm"]:
@@ -181,8 +185,8 @@ class TestAddNetworkToVirtualMachine(cloudstackTestCase):
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
template = get_template(cls.api_client, cls.zone.id, cls.services["ostype"])
# Set Zones and disk offerings
@@ -394,8 +398,7 @@ class TestAddNetworkToVirtualMachine(cloudstackTestCase):
# Trying to add same network to vm for the second time
with self.assertRaises(Exception) as e:
self.addNetworkToVm(network, self.virtual_machine)
-
- self.debug("Adding same network again failed with exception: %s" % e.exception)
+ self.debug("Adding same network again failed with exception: %s" % e.exception)
return
@@ -517,7 +520,7 @@ class TestAddNetworkToVirtualMachine(cloudstackTestCase):
with self.assertRaises(Exception) as e:
self.addNetworkToVm(self.shared_network, self.virtual_machine,
ipaddress = ipaddress)
- self.debug("API failed with exception: %s" % e.exception)
+ self.debug("API failed with exception: %s" % e.exception)
return
@@ -554,9 +557,7 @@ class TestAddNetworkToVirtualMachine(cloudstackTestCase):
with self.assertRaises(Exception) as e:
self.virtual_machine.add_nic(self.apiclient, network.id)
- network.delete(self.apiclient)
-
- self.debug("Operation failed with exception %s" % e.exception)
+ self.debug("Operation failed with exception %s" % e.exception)
return
@@ -608,15 +609,13 @@ class TestAddNetworkToVirtualMachine(cloudstackTestCase):
domainid=self.child_do_admin_2.domainid, serviceofferingid=self.service_offering.id,
mode=self.zone.networktype)
+ time.sleep(self.services["sleep"])
self.debug("Trying to %s network in domain %s to a vm in domain %s, This should fail" %
(network.type, self.child_domain_1.name, self.child_domain_2.name))
with self.assertRaises(Exception) as e:
virtual_machine.add_nic(self.apiclient, network.id)
- self.debug("Operation failed with exception %s" % e.exception)
-
- network.delete(self.apiclient)
-
+ self.debug("Operation failed with exception %s" % e.exception)
return
@attr(tags = ["advanced"])
@@ -688,7 +687,7 @@ class TestAddNetworkToVirtualMachine(cloudstackTestCase):
with self.assertRaises(Exception) as e:
virtual_machine.add_nic(self.apiclient, network_2.id)
- self.debug("Operation failed with exception %s" % e.exception)
+ self.debug("Operation failed with exception %s" % e.exception)
return
@@ -696,16 +695,18 @@ class TestRemoveNetworkFromVirtualMachine(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(TestRemoveNetworkFromVirtualMachine, cls).getClsTestClient().getApiClient()
+ cls.testClient = super(TestRemoveNetworkFromVirtualMachine, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
+ cls.services = Services().services
hypervisor = get_hypervisor_type(cls.api_client)
if hypervisor.lower() not in ["xenserver","kvm"]:
raise unittest.SkipTest("This feature is supported only on XenServer and KVM")
- cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
template = get_template(cls.api_client,cls.zone.id,cls.services["ostype"])
# Set Zones and disk offerings
@@ -838,7 +839,7 @@ class TestRemoveNetworkFromVirtualMachine(cloudstackTestCase):
self.virtual_machine.id)
with self.assertRaises(Exception):
self.virtual_machine.remove_nic(self.apiclient, vm_list[0].nic[0].id)
- self.debug("Removing default nic of vm failed")
+ self.debug("Removing default nic of vm failed")
return
@attr(tags = ["advanced"])
@@ -869,23 +870,25 @@ class TestRemoveNetworkFromVirtualMachine(cloudstackTestCase):
operation should fail")
with self.assertRaises(Exception) as e:
self.virtual_machine.remove_nic(self.apiclient, virtual_machine.nic[0].id)
- self.debug("Operation failed with exception: %s" % e.exception)
+ self.debug("Operation failed with exception: %s" % e.exception)
return
class TestUpdateVirtualMachineNIC(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(TestUpdateVirtualMachineNIC, cls).getClsTestClient().getApiClient()
+ cls.testClient = super(TestUpdateVirtualMachineNIC, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
+ cls.services = Services().services
hypervisor = get_hypervisor_type(cls.api_client)
if hypervisor.lower() not in ["xenserver","kvm"]:
raise unittest.SkipTest("This feature is supported only on XenServer and KVM")
- cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
template = get_template(cls.api_client,cls.zone.id,cls.services["ostype"])
# Set Zones and disk offerings
@@ -1047,7 +1050,7 @@ class TestUpdateVirtualMachineNIC(cloudstackTestCase):
self.debug("Trying to set default nic again as default nic, This should fail")
with self.assertRaises(Exception) as e:
self.virtual_machine.update_default_nic(self.apiclient, nicId = defaultNicId)
- self.debug("updateDefaultNic operation failed as expected with exception: %s" %
+ self.debug("updateDefaultNic operation failed as expected with exception: %s" %
e.exception)
return
@@ -1072,15 +1075,16 @@ class TestUpdateVirtualMachineNIC(cloudstackTestCase):
virtual_machine = VirtualMachine.create(self.apiclient,self.services["virtual_machine"],
accountid=account.name,domainid=account.domainid,
serviceofferingid=self.service_offering.id,mode=self.zone.networktype)
+ time.sleep(self.services["sleep"])
self.debug("Deployed virtual machine: %s" % virtual_machine.id)
-
+
foreignNicId = virtual_machine.nic[0].id
self.debug("Trying to set nic of new virtual machine as default nic of existing virtual machine, This \
operation should fail")
with self.assertRaises(Exception) as e:
self.virtual_machine.update_default_nic(self.apiclient, nicId = foreignNicId)
- self.debug("updateDefaultNic operation failed as expected with exception: %s" %
+ self.debug("updateDefaultNic operation failed as expected with exception: %s" %
e.exception)
return
@@ -1089,16 +1093,18 @@ class TestFailureScenariosAddNetworkToVM(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(TestFailureScenariosAddNetworkToVM, cls).getClsTestClient().getApiClient()
+ cls.testClient = super(TestFailureScenariosAddNetworkToVM, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
+ cls.services = Services().services
hypervisor = get_hypervisor_type(cls.api_client)
if hypervisor.lower() not in ["xenserver","kvm"]:
raise unittest.SkipTest("This feature is supported only on XenServer and KVM")
- cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
template = get_template(cls.api_client,cls.zone.id,cls.services["ostype"])
# Set Zones and disk offerings
cls.services["virtual_machine"]["zoneid"] = cls.zone.id
@@ -1226,6 +1232,7 @@ class TestFailureScenariosAddNetworkToVM(cloudstackTestCase):
cmd.networkid = isolated_network.id
with self.assertRaises(Exception) as e:
+ time.sleep(5)
self.apiclient.addNicToVirtualMachine(cmd)
self.debug("addNicToVirtualMachine API failed with exception: %s" % e.exception)
@@ -1267,6 +1274,7 @@ class TestFailureScenariosAddNetworkToVM(cloudstackTestCase):
virtual_machine = VirtualMachine.create(self.apiclient,self.services["virtual_machine"],
serviceofferingid=self.service_offering.id,
mode=basicZone.networktype)
+ time.sleep(self.services["sleep"])
self.debug("Deployed virtual machine %s: " % virtual_machine.id)
cmd = addNicToVirtualMachine.addNicToVirtualMachineCmd()
@@ -1276,6 +1284,7 @@ class TestFailureScenariosAddNetworkToVM(cloudstackTestCase):
self.dedbug("Trying to add isolated network to VM (both in basic zone,\
this operation should fail")
with self.assertRaises(Exception) as e:
+ time.sleep(5)
self.apiclient.addNicToVirtualMachine(cmd)
self.debug("addNicToVirtualMachine API failed with exception: %s" % e.exception)
@@ -1302,12 +1311,13 @@ class TestFailureScenariosAddNetworkToVM(cloudstackTestCase):
self.debug("Created account %s" % account.name)
self.debug("creating user api client for account: %s" % account.name)
- api_client = self.testClient.createUserApiClient(UserName=account.name, DomainName=self.account.domain)
+ api_client = self.testClient.getUserApiClient(UserName=account.name, DomainName=self.account.domain)
self.debug("Trying to add network to vm with this api client, this should fail due to \
insufficient permission")
with self.assertRaises(Exception) as e:
+ time.sleep(5)
api_client.addNicToVirtualMachine(cmd)
self.debug("addNicToVirtualMachine API failed with exception: %s" % e.exception)
@@ -1317,16 +1327,18 @@ class TestFailureScenariosRemoveNicFromVM(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(TestFailureScenariosRemoveNicFromVM, cls).getClsTestClient().getApiClient()
+ cls.testClient = super(TestFailureScenariosRemoveNicFromVM, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
+ cls.services = Services().services
hypervisor = get_hypervisor_type(cls.api_client)
if hypervisor.lower() not in ["xenserver","kvm"]:
raise unittest.SkipTest("This feature is supported only on XenServer and KVM")
- cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
template = get_template(cls.api_client,cls.zone.id,cls.services["ostype"])
# Set Zones and disk offerings
@@ -1374,7 +1386,7 @@ class TestFailureScenariosRemoveNicFromVM(cloudstackTestCase):
def tearDownClass(cls):
try:
# Disable Network Offerings
- #cls.isolated_network_offering.update(cls.api_client, state='Disabled')
+ cls.isolated_network_offering.update(cls.api_client, state='Disabled')
# Cleanup resources used
cleanup_resources(cls.api_client, cls._cleanup)
@@ -1480,7 +1492,7 @@ class TestFailureScenariosRemoveNicFromVM(cloudstackTestCase):
self.debug("Created account %s" % account.name)
self.debug("creating user api client for account: %s" % account.name)
- api_client = self.testClient.createUserApiClient(UserName=account.name, DomainName=self.account.domain)
+ api_client = self.testClient.getUserApiClient(UserName=account.name, DomainName=self.account.domain)
self.debug("Trying to add network to vm with this api client, this should fail due to \
insufficient permission")
@@ -1495,16 +1507,18 @@ class TestFailureScenariosUpdateVirtualMachineNIC(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(TestFailureScenariosUpdateVirtualMachineNIC, cls).getClsTestClient().getApiClient()
+ cls.testClient = super(TestFailureScenariosUpdateVirtualMachineNIC, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
+ cls.services = Services().services
hypervisor = get_hypervisor_type(cls.api_client)
if hypervisor.lower() not in ["xenserver","kvm"]:
raise unittest.SkipTest("This feature is supported only on XenServer and KVM")
- cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
template = get_template(cls.api_client, cls.zone.id, cls.services["ostype"])
# Set Zones and disk offerings
@@ -1603,7 +1617,7 @@ class TestFailureScenariosUpdateVirtualMachineNIC(cloudstackTestCase):
with self.assertRaises(Exception) as e:
self.apiclient.updateDefaultNicForVirtualMachine(cmd)
- self.debug("updateDefaultNicForVirtualMachine API failed with exception: %s" %
+ self.debug("updateDefaultNicForVirtualMachine API failed with exception: %s" %
e.exception)
return
@@ -1649,7 +1663,7 @@ class TestFailureScenariosUpdateVirtualMachineNIC(cloudstackTestCase):
with self.assertRaises(Exception) as e:
self.apiclient.updateDefaultNicForVirtualMachine(cmd)
- self.debug("updateDefaultNicForVirtualMachine API failed with exception: %s" %
+ self.debug("updateDefaultNicForVirtualMachine API failed with exception: %s" %
e.exception)
return
@@ -1678,7 +1692,7 @@ class TestFailureScenariosUpdateVirtualMachineNIC(cloudstackTestCase):
accountid=account.name,domainid=account.domainid,
serviceofferingid=self.service_offering.id,
mode=self.zone.networktype)
-
+ time.sleep(self.services["sleep"])
self.debug("Created virtual machine %s" % virtual_machine.id)
self.debug("Creating isolated network in account %s" % account.name)
@@ -1731,7 +1745,7 @@ class TestFailureScenariosUpdateVirtualMachineNIC(cloudstackTestCase):
with self.assertRaises(Exception) as e:
self.apiclient.updateDefaultNicForVirtualMachine(cmd)
- self.debug("updateDefaultNicForVirtualMachine API failed with exception: %s" %
+ self.debug("updateDefaultNicForVirtualMachine API failed with exception: %s" %
e.exception)
return
@@ -1751,7 +1765,7 @@ class TestFailureScenariosUpdateVirtualMachineNIC(cloudstackTestCase):
self.debug("Created account %s" % account.name)
self.debug("creating user api client for account: %s" % account.name)
- api_client = self.testClient.createUserApiClient(UserName=account.name, DomainName=self.account.domain)
+ api_client = self.testClient.getUserApiClient(UserName=account.name, DomainName=self.account.domain)
self.debug("Listing virtual machine so that to retrive the list of non-default and default nic")
vm_list = list_virtual_machines(self.apiclient, id=self.virtual_machine.id)
@@ -1781,7 +1795,7 @@ class TestFailureScenariosUpdateVirtualMachineNIC(cloudstackTestCase):
with self.assertRaises(Exception) as e:
api_client.updateDefaultNicForVirtualMachine(cmd)
- self.debug("updateDefaultNicForVirtualMachine API failed with exception: %s" %
+ self.debug("updateDefaultNicForVirtualMachine API failed with exception: %s" %
e.exception)
return
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/component/test_advancedsg_networks.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_advancedsg_networks.py b/test/integration/component/test_advancedsg_networks.py
index 207659f..f9155ed 100644
--- a/test/integration/component/test_advancedsg_networks.py
+++ b/test/integration/component/test_advancedsg_networks.py
@@ -19,7 +19,7 @@
"""
from marvin.cloudstackTestCase import cloudstackTestCase, unittest
from ddt import ddt, data
-from marvin.integration.lib.base import (Zone,
+from marvin.lib.base import (Zone,
ServiceOffering,
Account,
NetworkOffering,
@@ -31,14 +31,14 @@ from marvin.integration.lib.base import (Zone,
SecurityGroup,
Host)
-from marvin.integration.lib.common import (get_domain,
+from marvin.lib.common import (get_domain,
get_zone,
get_template,
get_free_vlan,
list_virtual_machines,
wait_for_cleanup)
-from marvin.integration.lib.utils import (cleanup_resources,
+from marvin.lib.utils import (cleanup_resources,
random_gen,
validateList)
from marvin.cloudstackAPI import (authorizeSecurityGroupIngress,
@@ -54,14 +54,12 @@ class TestCreateZoneSG(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cloudstackTestClient = super(TestCreateZoneSG,cls).getClsTestClient()
- cls.api_client = cloudstackTestClient.getApiClient()
-
- # Fill services from the external config file
- cls.services = cloudstackTestClient.getConfigParser().parsedDict
+ cls.testClient = super(TestCreateZoneSG, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+ cls.services = cls.testClient.getParsedTestDataConfig()
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
cls._cleanup = []
return
@@ -154,14 +152,13 @@ class TestNetworksInAdvancedSG(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cloudstackTestClient = super(TestNetworksInAdvancedSG,cls).getClsTestClient()
- cls.api_client = cloudstackTestClient.getApiClient()
-
- cls.services = cloudstackTestClient.getConfigParser().parsedDict
+ cls.testClient = super(TestNetworksInAdvancedSG, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+ cls.services = cls.testClient.getParsedTestDataConfig()
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.template = get_template(cls.api_client, cls.zone.id,
cls.services["ostype"])
@@ -1102,14 +1099,13 @@ class TestNetworksInAdvancedSG_VmOperations(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cloudstackTestClient = super(TestNetworksInAdvancedSG_VmOperations,cls).getClsTestClient()
- cls.api_client = cloudstackTestClient.getApiClient()
-
- cls.services = cloudstackTestClient.getConfigParser().parsedDict
+ cls.testClient = super(TestNetworksInAdvancedSG_VmOperations, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+ cls.services = cls.testClient.getParsedTestDataConfig()
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.template = get_template(cls.api_client,cls.zone.id,cls.services["ostype"])
cls.services["virtual_machine"]["zoneid"] = cls.zone.id
@@ -2086,14 +2082,13 @@ class TestSecurityGroups_BasicSanity(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cloudstackTestClient = super(TestSecurityGroups_BasicSanity,cls).getClsTestClient()
- cls.api_client = cloudstackTestClient.getApiClient()
-
- cls.services = cloudstackTestClient.getConfigParser().parsedDict
+ cls.testClient = super(TestSecurityGroups_BasicSanity, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+ cls.services = cls.testClient.getParsedTestDataConfig()
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.template = get_template(cls.api_client,cls.zone.id,cls.services["ostype"])
cls.services["virtual_machine"]["zoneid"] = cls.zone.id
@@ -2548,14 +2543,13 @@ class TestSharedNetworkOperations(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cloudstackTestClient = super(TestSharedNetworkOperations,cls).getClsTestClient()
- cls.api_client = cloudstackTestClient.getApiClient()
-
- cls.services = cloudstackTestClient.getConfigParser().parsedDict
+ cls.testClient = super(TestSharedNetworkOperations, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+ cls.services = cls.testClient.getParsedTestDataConfig()
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.template = get_template(cls.api_client,cls.zone.id,cls.services["ostype"])
cls.services["virtual_machine"]["zoneid"] = cls.zone.id
@@ -2815,14 +2809,13 @@ class TestAccountBasedIngressRules(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cloudstackTestClient = super(TestAccountBasedIngressRules,cls).getClsTestClient()
- cls.api_client = cloudstackTestClient.getApiClient()
-
- cls.services = cloudstackTestClient.getConfigParser().parsedDict
+ cls.testClient = super(TestAccountBasedIngressRules, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+ cls.services = cls.testClient.getParsedTestDataConfig()
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.template = get_template(cls.api_client,cls.zone.id,cls.services["ostype"])
cls.services["virtual_machine"]["zoneid"] = cls.zone.id
[02/18] Marvin + test changes from master Signed-off-by:
SrikanteswaraRao Talluri
Posted by da...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/tools/marvin/marvin/lib/common.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/lib/common.py b/tools/marvin/marvin/lib/common.py
new file mode 100644
index 0000000..8868d2d
--- /dev/null
+++ b/tools/marvin/marvin/lib/common.py
@@ -0,0 +1,1062 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+"""Common functions
+"""
+
+# Import Local Modules
+from marvin.cloudstackAPI import (listConfigurations,
+ listPhysicalNetworks,
+ listRegions,
+ addNetworkServiceProvider,
+ updateNetworkServiceProvider,
+ listDomains,
+ listZones,
+ listPods,
+ listOsTypes,
+ listTemplates,
+ updateResourceLimit,
+ listRouters,
+ listNetworks,
+ listClusters,
+ listSystemVms,
+ listStoragePools,
+ listVirtualMachines,
+ listLoadBalancerRuleInstances,
+ listFirewallRules,
+ listVolumes,
+ listIsos,
+ listAccounts,
+ listSnapshotPolicies,
+ listDiskOfferings,
+ listVlanIpRanges,
+ listUsageRecords,
+ listNetworkServiceProviders,
+ listHosts,
+ listPublicIpAddresses,
+ listPortForwardingRules,
+ listLoadBalancerRules,
+ listSnapshots,
+ listUsers,
+ listEvents,
+ listServiceOfferings,
+ listVirtualRouterElements,
+ listNetworkOfferings,
+ listResourceLimits,
+ listVPCOfferings)
+
+
+
+
+from marvin.sshClient import SshClient
+from marvin.codes import (PASS, ISOLATED_NETWORK, VPC_NETWORK,
+ BASIC_ZONE, FAIL, NAT_RULE, STATIC_NAT_RULE)
+import random
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.codes import PASS
+
+
+# Import System modules
+import time
+
+
+def is_config_suitable(apiclient, name, value):
+ """
+ Ensure if the deployment has the expected `value` for the global setting `name'
+ @return: true if value is set, else false
+ """
+ configs = Configurations.list(apiclient, name=name)
+ assert(
+ configs is not None and isinstance(
+ configs,
+ list) and len(
+ configs) > 0)
+ return configs[0].value == value
+
+
+def wait_for_cleanup(apiclient, configs=None):
+ """Sleeps till the cleanup configs passed"""
+
+ # Configs list consists of the list of global configs
+ if not isinstance(configs, list):
+ return
+ for config in configs:
+ cmd = listConfigurations.listConfigurationsCmd()
+ cmd.name = config
+ cmd.listall = True
+ try:
+ config_descs = apiclient.listConfigurations(cmd)
+ except Exception as e:
+ raise Exception("Failed to fetch configurations: %s" % e)
+
+ if not isinstance(config_descs, list):
+ raise Exception("List configs didn't returned a valid data")
+
+ config_desc = config_descs[0]
+ # Sleep for the config_desc.value time
+ time.sleep(int(config_desc.value))
+ return
+
+
+def add_netscaler(apiclient, zoneid, NSservice):
+ """ Adds Netscaler device and enables NS provider"""
+
+ cmd = listPhysicalNetworks.listPhysicalNetworksCmd()
+ cmd.zoneid = zoneid
+ physical_networks = apiclient.listPhysicalNetworks(cmd)
+ if isinstance(physical_networks, list):
+ physical_network = physical_networks[0]
+
+ cmd = listNetworkServiceProviders.listNetworkServiceProvidersCmd()
+ cmd.name = 'Netscaler'
+ cmd.physicalnetworkid = physical_network.id
+ nw_service_providers = apiclient.listNetworkServiceProviders(cmd)
+
+ if isinstance(nw_service_providers, list):
+ netscaler_provider = nw_service_providers[0]
+ else:
+ cmd1 = addNetworkServiceProvider.addNetworkServiceProviderCmd()
+ cmd1.name = 'Netscaler'
+ cmd1.physicalnetworkid = physical_network.id
+ netscaler_provider = apiclient.addNetworkServiceProvider(cmd1)
+
+ netscaler = NetScaler.add(
+ apiclient,
+ NSservice,
+ physicalnetworkid=physical_network.id
+ )
+ if netscaler_provider.state != 'Enabled':
+ cmd = updateNetworkServiceProvider.updateNetworkServiceProviderCmd()
+ cmd.id = netscaler_provider.id
+ cmd.state = 'Enabled'
+ apiclient.updateNetworkServiceProvider(cmd)
+
+ return netscaler
+
+
+def get_region(apiclient, region_id=None, region_name=None):
+ '''
+ @name : get_region
+ @Desc : Returns the Region Information for a given region id or region name
+ @Input : region_name: Name of the Region
+ region_id : Id of the region
+ @Output : 1. Region Information for the passed inputs else first Region
+ 2. FAILED In case the cmd failed
+ '''
+ cmd = listRegions.listRegionsCmd()
+ if region_name is not None:
+ cmd.name = region_name
+ if region_id is not None:
+ cmd.id = region_id
+ cmd_out = apiclient.listRegions(cmd)
+ return FAILED if validateList(cmd_out)[0] != PASS else cmd_out[0]
+
+
+def get_domain(apiclient, domain_id=None, domain_name=None):
+ '''
+ @name : get_domain
+ @Desc : Returns the Domain Information for a given domain id or domain name
+ @Input : domain id : Id of the Domain
+ domain_name : Name of the Domain
+ @Output : 1. Domain Information for the passed inputs else first Domain
+ 2. FAILED In case the cmd failed
+ '''
+ cmd = listDomains.listDomainsCmd()
+
+ if domain_name is not None:
+ cmd.name = domain_name
+ if domain_id is not None:
+ cmd.id = domain_id
+ cmd_out = apiclient.listDomains(cmd)
+ if validateList(cmd_out)[0] != PASS:
+ return FAILED
+ return cmd_out[0]
+
+
+def get_zone(apiclient, zone_name=None, zone_id=None):
+ '''
+ @name : get_zone
+ @Desc :Returns the Zone Information for a given zone id or Zone Name
+ @Input : zone_name: Name of the Zone
+ zone_id : Id of the zone
+ @Output : 1. Zone Information for the passed inputs else first zone
+ 2. FAILED In case the cmd failed
+ '''
+ cmd = listZones.listZonesCmd()
+ if zone_name is not None:
+ cmd.name = zone_name
+ if zone_id is not None:
+ cmd.id = zone_id
+
+ cmd_out = apiclient.listZones(cmd)
+
+ if validateList(cmd_out)[0] != PASS:
+ return FAILED
+ '''
+ Check if input zone name and zone id is None,
+ then return first element of List Zones command
+ '''
+ return cmd_out[0]
+
+
+def get_pod(apiclient, zone_id=None, pod_id=None, pod_name=None):
+ '''
+ @name : get_pod
+ @Desc : Returns the Pod Information for a given zone id or Zone Name
+ @Input : zone_id: Id of the Zone
+ pod_name : Name of the Pod
+ pod_id : Id of the Pod
+ @Output : 1. Pod Information for the pod
+ 2. FAILED In case the cmd failed
+ '''
+ cmd = listPods.listPodsCmd()
+
+ if pod_name is not None:
+ cmd.name = pod_name
+ if pod_id is not None:
+ cmd.id = pod_id
+ if zone_id is not None:
+ cmd.zoneid = zone_id
+
+ cmd_out = apiclient.listPods(cmd)
+
+ if validateList(cmd_out)[0] != PASS:
+ return FAILED
+ return cmd_out[0]
+def get_template(
+ apiclient, zone_id=None, ostype_desc=None, template_filter="featured", template_type='BUILTIN',
+ template_id=None, template_name=None, account=None, domain_id=None, project_id=None,
+ hypervisor=None):
+ '''
+ @Name : get_template
+ @Desc : Retrieves the template Information based upon inputs provided
+ Template is retrieved based upon either of the inputs matched
+ condition
+ @Input : returns a template"
+ @Output : FAILED in case of any failure
+ template Information matching the inputs
+ '''
+ cmd = listTemplates.listTemplatesCmd()
+ cmd.templatefilter = template_filter
+ if domain_id is not None:
+ cmd.domainid = domain_id
+ if zone_id is not None:
+ cmd.zoneid = zone_id
+ if template_id is not None:
+ cmd.id = template_id
+ if template_name is not None:
+ cmd.name = template_name
+ if hypervisor is not None:
+ cmd.hypervisor = hypervisor
+ if project_id is not None:
+ cmd.projectid = project_id
+ if account is not None:
+ cmd.account = account
+
+ '''
+ Get the Templates pertaining to the inputs provided
+ '''
+ list_templatesout = apiclient.listTemplates(cmd)
+ if validateList(list_templatesout)[0] != PASS:
+ return FAILED
+
+ for template in list_templatesout:
+ if template.isready and template.templatetype == template_type:
+ return template
+ '''
+ Return default first template, if no template matched
+ '''
+ return list_templatesout[0]
+
+
+def download_systemplates_sec_storage(server, services):
+ """Download System templates on sec storage"""
+
+ try:
+ # Login to management server
+ ssh = SshClient(
+ server["ipaddress"],
+ server["port"],
+ server["username"],
+ server["password"]
+ )
+ except Exception:
+ raise Exception("SSH access failed for server with IP address: %s" %
+ server["ipaddess"])
+ # Mount Secondary Storage on Management Server
+ cmds = [
+ "mkdir -p %s" % services["mnt_dir"],
+ "mount -t nfs %s:/%s %s" % (
+ services["sec_storage"],
+ services["path"],
+ services["mnt_dir"]
+ ),
+ "%s -m %s -u %s -h %s -F" % (
+ services["command"],
+ services["mnt_dir"],
+ services["download_url"],
+ services["hypervisor"]
+ )
+ ]
+ for c in cmds:
+ result = ssh.execute(c)
+
+ res = str(result)
+
+ # Unmount the Secondary storage
+ ssh.execute("umount %s" % (services["mnt_dir"]))
+
+ if res.count("Successfully installed system VM template") == 1:
+ return
+ else:
+ raise Exception("Failed to download System Templates on Sec Storage")
+ return
+
+
+def wait_for_ssvms(apiclient, zoneid, podid, interval=60):
+ """After setup wait for SSVMs to come Up"""
+
+ time.sleep(interval)
+ timeout = 40
+ while True:
+ list_ssvm_response = list_ssvms(
+ apiclient,
+ systemvmtype='secondarystoragevm',
+ zoneid=zoneid,
+ podid=podid
+ )
+ ssvm = list_ssvm_response[0]
+ if ssvm.state != 'Running':
+ # Sleep to ensure SSVMs are Up and Running
+ time.sleep(interval)
+ timeout = timeout - 1
+ elif ssvm.state == 'Running':
+ break
+ elif timeout == 0:
+ raise Exception("SSVM failed to come up")
+ break
+
+ timeout = 40
+ while True:
+ list_ssvm_response = list_ssvms(
+ apiclient,
+ systemvmtype='consoleproxy',
+ zoneid=zoneid,
+ podid=podid
+ )
+ cpvm = list_ssvm_response[0]
+ if cpvm.state != 'Running':
+ # Sleep to ensure SSVMs are Up and Running
+ time.sleep(interval)
+ timeout = timeout - 1
+ elif cpvm.state == 'Running':
+ break
+ elif timeout == 0:
+ raise Exception("CPVM failed to come up")
+ break
+ return
+
+
+def get_builtin_template_info(apiclient, zoneid):
+ """Returns hypervisor specific infor for templates"""
+
+ list_template_response = Template.list(
+ apiclient,
+ templatefilter='featured',
+ zoneid=zoneid,
+ )
+
+ for b_template in list_template_response:
+ if b_template.templatetype == 'BUILTIN':
+ break
+
+ extract_response = Template.extract(apiclient,
+ b_template.id,
+ 'HTTP_DOWNLOAD',
+ zoneid)
+
+ return extract_response.url, b_template.hypervisor, b_template.format
+
+
+def download_builtin_templates(apiclient, zoneid, hypervisor, host,
+ linklocalip, interval=60):
+ """After setup wait till builtin templates are downloaded"""
+
+ # Change IPTABLES Rules
+ get_process_status(
+ host["ipaddress"],
+ host["port"],
+ host["username"],
+ host["password"],
+ linklocalip,
+ "iptables -P INPUT ACCEPT"
+ )
+ time.sleep(interval)
+ # Find the BUILTIN Templates for given Zone, Hypervisor
+ list_template_response = list_templates(
+ apiclient,
+ hypervisor=hypervisor,
+ zoneid=zoneid,
+ templatefilter='self'
+ )
+
+ if not isinstance(list_template_response, list):
+ raise Exception("Failed to download BUILTIN templates")
+
+ # Ensure all BUILTIN templates are downloaded
+ templateid = None
+ for template in list_template_response:
+ if template.templatetype == "BUILTIN":
+ templateid = template.id
+
+ # Sleep to ensure that template is in downloading state after adding
+ # Sec storage
+ time.sleep(interval)
+ while True:
+ template_response = list_templates(
+ apiclient,
+ id=templateid,
+ zoneid=zoneid,
+ templatefilter='self'
+ )
+ template = template_response[0]
+ # If template is ready,
+ # template.status = Download Complete
+ # Downloading - x% Downloaded
+ # Error - Any other string
+ if template.status == 'Download Complete':
+ break
+
+ elif 'Downloaded' in template.status:
+ time.sleep(interval)
+
+ elif 'Installing' not in template.status:
+ raise Exception("ErrorInDownload")
+
+ return
+
+
+def update_resource_limit(apiclient, resourcetype, account=None,
+ domainid=None, max=None, projectid=None):
+ """Updates the resource limit to 'max' for given account"""
+
+ cmd = updateResourceLimit.updateResourceLimitCmd()
+ cmd.resourcetype = resourcetype
+ if account:
+ cmd.account = account
+ if domainid:
+ cmd.domainid = domainid
+ if max:
+ cmd.max = max
+ if projectid:
+ cmd.projectid = projectid
+ apiclient.updateResourceLimit(cmd)
+ return
+
+
+def list_os_types(apiclient, **kwargs):
+ """List all os types matching criteria"""
+
+ cmd = listOsTypes.listOsTypesCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listOsTypes(cmd))
+
+
+def list_routers(apiclient, **kwargs):
+ """List all Routers matching criteria"""
+
+ cmd = listRouters.listRoutersCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listRouters(cmd))
+
+
+def list_zones(apiclient, **kwargs):
+ """List all Zones matching criteria"""
+
+ cmd = listZones.listZonesCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listZones(cmd))
+
+
+def list_networks(apiclient, **kwargs):
+ """List all Networks matching criteria"""
+
+ cmd = listNetworks.listNetworksCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listNetworks(cmd))
+
+
+def list_clusters(apiclient, **kwargs):
+ """List all Clusters matching criteria"""
+
+ cmd = listClusters.listClustersCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listClusters(cmd))
+
+
+def list_ssvms(apiclient, **kwargs):
+ """List all SSVMs matching criteria"""
+
+ cmd = listSystemVms.listSystemVmsCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listSystemVms(cmd))
+
+
+def list_storage_pools(apiclient, **kwargs):
+ """List all storage pools matching criteria"""
+
+ cmd = listStoragePools.listStoragePoolsCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listStoragePools(cmd))
+
+
+def list_virtual_machines(apiclient, **kwargs):
+ """List all VMs matching criteria"""
+
+ cmd = listVirtualMachines.listVirtualMachinesCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listVirtualMachines(cmd))
+
+
+def list_hosts(apiclient, **kwargs):
+ """List all Hosts matching criteria"""
+
+ cmd = listHosts.listHostsCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listHosts(cmd))
+
+
+def list_configurations(apiclient, **kwargs):
+ """List configuration with specified name"""
+
+ cmd = listConfigurations.listConfigurationsCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listConfigurations(cmd))
+
+
+def list_publicIP(apiclient, **kwargs):
+ """List all Public IPs matching criteria"""
+
+ cmd = listPublicIpAddresses.listPublicIpAddressesCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listPublicIpAddresses(cmd))
+
+
+def list_nat_rules(apiclient, **kwargs):
+ """List all NAT rules matching criteria"""
+
+ cmd = listPortForwardingRules.listPortForwardingRulesCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listPortForwardingRules(cmd))
+
+
+def list_lb_rules(apiclient, **kwargs):
+ """List all Load balancing rules matching criteria"""
+
+ cmd = listLoadBalancerRules.listLoadBalancerRulesCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listLoadBalancerRules(cmd))
+
+
+def list_lb_instances(apiclient, **kwargs):
+ """List all Load balancing instances matching criteria"""
+
+ cmd = listLoadBalancerRuleInstances.listLoadBalancerRuleInstancesCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listLoadBalancerRuleInstances(cmd))
+
+
+def list_firewall_rules(apiclient, **kwargs):
+ """List all Firewall Rules matching criteria"""
+
+ cmd = listFirewallRules.listFirewallRulesCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listFirewallRules(cmd))
+
+
+def list_volumes(apiclient, **kwargs):
+ """List all volumes matching criteria"""
+
+ cmd = listVolumes.listVolumesCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listVolumes(cmd))
+
+
+def list_isos(apiclient, **kwargs):
+ """Lists all available ISO files."""
+
+ cmd = listIsos.listIsosCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listIsos(cmd))
+
+
+def list_snapshots(apiclient, **kwargs):
+ """List all snapshots matching criteria"""
+
+ cmd = listSnapshots.listSnapshotsCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listSnapshots(cmd))
+
+
+def list_templates(apiclient, **kwargs):
+ """List all templates matching criteria"""
+
+ cmd = listTemplates.listTemplatesCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listTemplates(cmd))
+
+
+def list_domains(apiclient, **kwargs):
+ """Lists domains"""
+
+ cmd = listDomains.listDomainsCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listDomains(cmd))
+
+
+def list_accounts(apiclient, **kwargs):
+ """Lists accounts and provides detailed account information for
+ listed accounts"""
+
+ cmd = listAccounts.listAccountsCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listAccounts(cmd))
+
+
+def list_users(apiclient, **kwargs):
+ """Lists users and provides detailed account information for
+ listed users"""
+
+ cmd = listUsers.listUsersCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listUsers(cmd))
+
+
+def list_snapshot_policy(apiclient, **kwargs):
+ """Lists snapshot policies."""
+
+ cmd = listSnapshotPolicies.listSnapshotPoliciesCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listSnapshotPolicies(cmd))
+
+
+def list_events(apiclient, **kwargs):
+ """Lists events"""
+
+ cmd = listEvents.listEventsCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listEvents(cmd))
+
+
+def list_disk_offering(apiclient, **kwargs):
+ """Lists all available disk offerings."""
+
+ cmd = listDiskOfferings.listDiskOfferingsCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listDiskOfferings(cmd))
+
+
+def list_service_offering(apiclient, **kwargs):
+ """Lists all available service offerings."""
+
+ cmd = listServiceOfferings.listServiceOfferingsCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listServiceOfferings(cmd))
+
+
+def list_vlan_ipranges(apiclient, **kwargs):
+ """Lists all VLAN IP ranges."""
+
+ cmd = listVlanIpRanges.listVlanIpRangesCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listVlanIpRanges(cmd))
+
+
+def list_usage_records(apiclient, **kwargs):
+ """Lists usage records for accounts"""
+
+ cmd = listUsageRecords.listUsageRecordsCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listUsageRecords(cmd))
+
+
+def list_nw_service_prividers(apiclient, **kwargs):
+ """Lists Network service providers"""
+
+ cmd = listNetworkServiceProviders.listNetworkServiceProvidersCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listNetworkServiceProviders(cmd))
+
+
+def list_virtual_router_elements(apiclient, **kwargs):
+ """Lists Virtual Router elements"""
+
+ cmd = listVirtualRouterElements.listVirtualRouterElementsCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listVirtualRouterElements(cmd))
+
+
+def list_network_offerings(apiclient, **kwargs):
+ """Lists network offerings"""
+
+ cmd = listNetworkOfferings.listNetworkOfferingsCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listNetworkOfferings(cmd))
+
+
+def list_resource_limits(apiclient, **kwargs):
+ """Lists resource limits"""
+
+ cmd = listResourceLimits.listResourceLimitsCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listResourceLimits(cmd))
+
+
+def list_vpc_offerings(apiclient, **kwargs):
+ """ Lists VPC offerings """
+
+ cmd = listVPCOfferings.listVPCOfferingsCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listVPCOfferings(cmd))
+
+
+def update_resource_count(apiclient, domainid, accountid=None,
+ projectid=None, rtype=None):
+ """updates the resource count
+ 0 - VM
+ 1 - Public IP
+ 2 - Volume
+ 3 - Snapshot
+ 4 - Template
+ 5 - Projects
+ 6 - Network
+ 7 - VPC
+ 8 - CPUs
+ 9 - RAM
+ 10 - Primary (shared) storage (Volumes)
+ 11 - Secondary storage (Snapshots, Templates & ISOs)
+ """
+
+ Resources.updateCount(apiclient,
+ domainid=domainid,
+ account=accountid if accountid else None,
+ projectid=projectid if projectid else None,
+ resourcetype=rtype if rtype else None
+ )
+ return
+
+def findSuitableHostForMigration(apiclient, vmid):
+ """Returns a suitable host for VM migration"""
+ suitableHost = None
+ try:
+ hosts = Host.listForMigration(apiclient, virtualmachineid=vmid,
+ )
+ except Exception as e:
+ raise Exception("Exception while getting hosts list suitable for migration: %s" % e)
+
+ suitablehosts = []
+ if isinstance(hosts, list) and len(hosts) > 0:
+ suitablehosts = [host for host in hosts if (str(host.resourcestate).lower() == "enabled"\
+ and str(host.state).lower() == "up")]
+ if len(suitablehosts)>0:
+ suitableHost = suitablehosts[0]
+
+ return suitableHost
+
+
+def get_resource_type(resource_id):
+ """Returns resource type"""
+
+ lookup = {0: "VM",
+ 1: "Public IP",
+ 2: "Volume",
+ 3: "Snapshot",
+ 4: "Template",
+ 5: "Projects",
+ 6: "Network",
+ 7: "VPC",
+ 8: "CPUs",
+ 9: "RAM",
+ 10: "Primary (shared) storage (Volumes)",
+ 11: "Secondary storage (Snapshots, Templates & ISOs)"
+ }
+
+ return lookup[resource_id]
+
+
+
+def get_free_vlan(apiclient, zoneid):
+ """
+ Find an unallocated VLAN outside the range allocated to the physical network.
+
+ @note: This does not guarantee that the VLAN is available for use in
+ the deployment's network gear
+ @return: physical_network, shared_vlan_tag
+ """
+ list_physical_networks_response = PhysicalNetwork.list(
+ apiclient,
+ zoneid=zoneid
+ )
+ assert isinstance(list_physical_networks_response, list)
+ assert len(
+ list_physical_networks_response) > 0, "No physical networks found in zone %s" % zoneid
+
+ physical_network = list_physical_networks_response[0]
+
+ networks = list_networks(apiclient, zoneid=zoneid, type='Shared')
+ usedVlanIds = []
+
+ if isinstance(networks, list) and len(networks) > 0:
+ usedVlanIds = [int(nw.vlan)
+ for nw in networks if nw.vlan != "untagged"]
+
+ if hasattr(physical_network, "vlan") is False:
+ while True:
+ shared_ntwk_vlan = random.randrange(1, 4095)
+ if shared_ntwk_vlan in usedVlanIds:
+ continue
+ else:
+ break
+ else:
+ vlans = xsplit(physical_network.vlan, ['-', ','])
+
+ assert len(vlans) > 0
+ assert int(vlans[0]) < int(
+ vlans[-1]), "VLAN range %s was improperly split" % physical_network.vlan
+
+ # Assuming random function will give different integer each time
+ retriesCount = 20
+
+ shared_ntwk_vlan = None
+
+ while True:
+
+ if retriesCount == 0:
+ break
+
+ free_vlan = int(vlans[-1]) + random.randrange(1, 20)
+
+ if free_vlan > 4095:
+ free_vlan = int(vlans[0]) - random.randrange(1, 20)
+ if free_vlan < 0 or (free_vlan in usedVlanIds):
+ retriesCount -= 1
+ continue
+ else:
+ shared_ntwk_vlan = free_vlan
+ break
+
+ return physical_network, shared_ntwk_vlan
+
+
+def setNonContiguousVlanIds(apiclient, zoneid):
+ """
+ Form the non contiguous ranges based on currently assigned range in physical network
+ """
+
+ NonContigVlanIdsAcquired = False
+
+ list_physical_networks_response = PhysicalNetwork.list(
+ apiclient,
+ zoneid=zoneid
+ )
+ assert isinstance(list_physical_networks_response, list)
+ assert len(
+ list_physical_networks_response) > 0, "No physical networks found in zone %s" % zoneid
+
+ for physical_network in list_physical_networks_response:
+
+ vlans = xsplit(physical_network.vlan, ['-', ','])
+
+ assert len(vlans) > 0
+ assert int(vlans[0]) < int(
+ vlans[-1]), "VLAN range %s was improperly split" % physical_network.vlan
+
+ # Keep some gap between existing vlan and the new vlans which we are going to add
+ # So that they are non contiguous
+
+ non_contig_end_vlan_id = int(vlans[-1]) + 6
+ non_contig_start_vlan_id = int(vlans[0]) - 6
+
+ # Form ranges which are consecutive to existing ranges but not immediately contiguous
+ # There should be gap in between existing range and new non contiguous
+ # ranage
+
+ # If you can't add range after existing range, because it's crossing 4095, then
+ # select VLAN ids before the existing range such that they are greater than 0, and
+ # then add this non contiguoud range
+ vlan = {"partial_range": ["", ""], "full_range": ""}
+
+ if non_contig_end_vlan_id < 4095:
+ vlan["partial_range"][0] = str(
+ non_contig_end_vlan_id - 4) + '-' + str(non_contig_end_vlan_id - 3)
+ vlan["partial_range"][1] = str(
+ non_contig_end_vlan_id - 1) + '-' + str(non_contig_end_vlan_id)
+ vlan["full_range"] = str(
+ non_contig_end_vlan_id - 4) + '-' + str(non_contig_end_vlan_id)
+ NonContigVlanIdsAcquired = True
+
+ elif non_contig_start_vlan_id > 0:
+ vlan["partial_range"][0] = str(
+ non_contig_start_vlan_id) + '-' + str(non_contig_start_vlan_id + 1)
+ vlan["partial_range"][1] = str(
+ non_contig_start_vlan_id + 3) + '-' + str(non_contig_start_vlan_id + 4)
+ vlan["full_range"] = str(
+ non_contig_start_vlan_id) + '-' + str(non_contig_start_vlan_id + 4)
+ NonContigVlanIdsAcquired = True
+
+ else:
+ NonContigVlanIdsAcquired = False
+
+ # If failed to get relevant vlan ids, continue to next physical network
+ # else break from loop as we have hot the non contiguous vlan ids for
+ # the test purpose
+
+ if not NonContigVlanIdsAcquired:
+ continue
+ else:
+ break
+
+ # If even through looping from all existing physical networks, failed to get relevant non
+ # contiguous vlan ids, then fail the test case
+
+ if not NonContigVlanIdsAcquired:
+ return None, None
+
+ return physical_network, vlan
+
+def is_public_ip_in_correct_state(apiclient, ipaddressid, state):
+ """ Check if the given IP is in the correct state (given)
+ and return True/False accordingly"""
+ retriesCount = 10
+ while True:
+ portableips = PublicIPAddress.list(apiclient, id=ipaddressid)
+ assert validateList(portableips)[0] == PASS, "IPs list validation failed"
+ if str(portableips[0].state).lower() == state:
+ break
+ elif retriesCount == 0:
+ return False
+ else:
+ retriesCount -= 1
+ time.sleep(60)
+ continue
+ return True
+
+def setSharedNetworkParams(networkServices, range=20):
+ """Fill up the services dictionary for shared network using random subnet"""
+
+ # @range: range decides the endip. Pass the range as "x" if you want the difference between the startip
+ # and endip as "x"
+ # Set the subnet number of shared networks randomly prior to execution
+ # of each test case to avoid overlapping of ip addresses
+ shared_network_subnet_number = random.randrange(1,254)
+
+ networkServices["gateway"] = "172.16."+str(shared_network_subnet_number)+".1"
+ networkServices["startip"] = "172.16."+str(shared_network_subnet_number)+".2"
+ networkServices["endip"] = "172.16."+str(shared_network_subnet_number)+"."+str(range+1)
+ networkServices["netmask"] = "255.255.255.0"
+ return networkServices
+
+def createEnabledNetworkOffering(apiclient, networkServices):
+ """Create and enable network offering according to the type
+
+ @output: List, containing [ Result,Network Offering,Reason ]
+ Ist Argument('Result') : FAIL : If exception or assertion error occurs
+ PASS : If network offering
+ is created and enabled successfully
+ IInd Argument(Net Off) : Enabled network offering
+ In case of exception or
+ assertion error, it will be None
+ IIIrd Argument(Reason) : Reason for failure,
+ default to None
+ """
+ try:
+ resultSet = [FAIL, None, None]
+ # Create network offering
+ network_offering = NetworkOffering.create(apiclient, networkServices, conservemode=False)
+
+ # Update network offering state from disabled to enabled.
+ NetworkOffering.update(network_offering, apiclient, id=network_offering.id,
+ state="enabled")
+ except Exception as e:
+ resultSet[2] = e
+ return resultSet
+ return [PASS, network_offering, None]
+
+def shouldTestBeSkipped(networkType, zoneType):
+ """Decide which test to skip, according to type of network and zone type"""
+
+ # If network type is isolated or vpc and zone type is basic, then test should be skipped
+ skipIt = False
+ if ((networkType.lower() == str(ISOLATED_NETWORK).lower() or networkType.lower() == str(VPC_NETWORK).lower())
+ and (zoneType.lower() == BASIC_ZONE)):
+ skipIt = True
+ return skipIt
+
+def verifyNetworkState(apiclient, networkid, state):
+ """List networks and check if the network state matches the given state"""
+ try:
+ networks = Network.list(apiclient, id=networkid)
+ except Exception as e:
+ raise Exception("Failed while fetching network list with error: %s" % e)
+ assert validateList(networks)[0] == PASS, "Networks list validation failed, list is %s" % networks
+ assert str(networks[0].state).lower() == state, "network state should be %s, it is %s" % (state, networks[0].state)
+ return
+
+def verifyComputeOfferingCreation(apiclient, computeofferingid):
+ """List Compute offerings by ID and verify that the offering exists"""
+
+ cmd = listServiceOfferings.listServiceOfferingsCmd()
+ cmd.id = computeofferingid
+ serviceOfferings = None
+ try:
+ serviceOfferings = apiclient.listServiceOfferings(cmd)
+ except Exception:
+ return FAIL
+ if not (isinstance(serviceOfferings, list) and len(serviceOfferings) > 0):
+ return FAIL
+ return PASS
+
+def createNetworkRulesForVM(apiclient, virtualmachine, ruletype,
+ account, networkruledata):
+ """Acquire IP, create Firewall and NAT/StaticNAT rule
+ (associating it with given vm) for that IP"""
+
+ try:
+ public_ip = PublicIPAddress.create(
+ apiclient,accountid=account.name,
+ zoneid=virtualmachine.zoneid,domainid=account.domainid,
+ networkid=virtualmachine.nic[0].networkid)
+
+ FireWallRule.create(
+ apiclient,ipaddressid=public_ip.ipaddress.id,
+ protocol='TCP', cidrlist=[networkruledata["fwrule"]["cidr"]],
+ startport=networkruledata["fwrule"]["startport"],
+ endport=networkruledata["fwrule"]["endport"]
+ )
+
+ if ruletype == NAT_RULE:
+ # Create NAT rule
+ NATRule.create(apiclient, virtualmachine,
+ networkruledata["natrule"],ipaddressid=public_ip.ipaddress.id,
+ networkid=virtualmachine.nic[0].networkid)
+ elif ruletype == STATIC_NAT_RULE:
+ # Enable Static NAT for VM
+ StaticNATRule.enable(apiclient,public_ip.ipaddress.id,
+ virtualmachine.id, networkid=virtualmachine.nic[0].networkid)
+ except Exception as e:
+ [FAIL, e]
+ return [PASS, public_ip]
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/tools/marvin/marvin/lib/utils.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/lib/utils.py b/tools/marvin/marvin/lib/utils.py
new file mode 100644
index 0000000..cb5dcfb
--- /dev/null
+++ b/tools/marvin/marvin/lib/utils.py
@@ -0,0 +1,498 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+"""Utilities functions
+"""
+
+import marvin
+import os
+import time
+import logging
+import string
+import random
+import imaplib
+import email
+import socket
+import urlparse
+import datetime
+from marvin.cloudstackAPI import cloudstackAPIClient, listHosts, listRouters
+from platform import system
+from marvin.cloudstackException import GetDetailExceptionInfo
+from marvin.sshClient import SshClient
+from marvin.codes import (
+ SUCCESS,
+ FAIL,
+ PASS,
+ MATCH_NOT_FOUND,
+ INVALID_INPUT,
+ EMPTY_LIST,
+ FAILED)
+
+def restart_mgmt_server(server):
+ """Restarts the management server"""
+
+ try:
+ # Get the SSH client
+ ssh = is_server_ssh_ready(
+ server["ipaddress"],
+ server["port"],
+ server["username"],
+ server["password"],
+ )
+ result = ssh.execute("/etc/init.d/cloud-management restart")
+ res = str(result)
+ # Server Stop - OK
+ # Server Start - OK
+ if res.count("OK") != 2:
+ raise ("ErrorInReboot!")
+ except Exception as e:
+ raise e
+ return
+
+
+def fetch_latest_mail(services, from_mail):
+ """Fetch mail"""
+
+ # Login to mail server to verify email
+ mail = imaplib.IMAP4_SSL(services["server"])
+ mail.login(
+ services["email"],
+ services["password"]
+ )
+ mail.list()
+ mail.select(services["folder"])
+ date = (datetime.date.today() - datetime.timedelta(1)).strftime("%d-%b-%Y")
+
+ result, data = mail.uid(
+ 'search',
+ None,
+ '(SENTSINCE {date} HEADER FROM "{mail}")'.format(
+ date=date,
+ mail=from_mail
+ )
+ )
+ # Return False if email is not present
+ if data == []:
+ return False
+
+ latest_email_uid = data[0].split()[-1]
+ result, data = mail.uid('fetch', latest_email_uid, '(RFC822)')
+ raw_email = data[0][1]
+ email_message = email.message_from_string(raw_email)
+ result = get_first_text_block(email_message)
+ return result
+
+
+def get_first_text_block(email_message_instance):
+ """fetches first text block from the mail"""
+ maintype = email_message_instance.get_content_maintype()
+ if maintype == 'multipart':
+ for part in email_message_instance.get_payload():
+ if part.get_content_maintype() == 'text':
+ return part.get_payload()
+ elif maintype == 'text':
+ return email_message_instance.get_payload()
+
+
+def random_gen(id=None, size=6, chars=string.ascii_uppercase + string.digits):
+ """Generate Random Strings of variable length"""
+ randomstr = ''.join(random.choice(chars) for x in range(size))
+ if id:
+ return ''.join([id, '-', randomstr])
+ return randomstr
+
+
+def cleanup_resources(api_client, resources):
+ """Delete resources"""
+ for obj in resources:
+ obj.delete(api_client)
+
+
+def is_server_ssh_ready(ipaddress, port, username, password, retries=20, retryinterv=30, timeout=10.0, keyPairFileLocation=None):
+ '''
+ @Name: is_server_ssh_ready
+ @Input: timeout: tcp connection timeout flag,
+ others information need to be added
+ @Output:object for SshClient
+ Name of the function is little misnomer and is not
+ verifying anything as such mentioned
+ '''
+
+ try:
+ ssh = SshClient(
+ host=ipaddress,
+ port=port,
+ user=username,
+ passwd=password,
+ keyPairFiles=keyPairFileLocation,
+ retries=retries,
+ delay=retryinterv,
+ timeout=timeout)
+ except Exception, e:
+ raise Exception("SSH connection has Failed. Waited %ss. Error is %s" % (retries * retryinterv, str(e)))
+ else:
+ return ssh
+
+
+def format_volume_to_ext3(ssh_client, device="/dev/sda"):
+ """Format attached storage to ext3 fs"""
+ cmds = [
+ "echo -e 'n\np\n1\n\n\nw' | fdisk %s" % device,
+ "mkfs.ext3 %s1" % device,
+ ]
+ for c in cmds:
+ ssh_client.execute(c)
+
+
+def fetch_api_client(config_file='datacenterCfg'):
+ """Fetch the Cloudstack API Client"""
+ config = marvin.configGenerator.get_setup_config(config_file)
+ mgt = config.mgtSvr[0]
+ testClientLogger = logging.getLogger("testClient")
+ asyncTimeout = 3600
+ return cloudstackAPIClient.CloudStackAPIClient(
+ marvin.cloudstackConnection.cloudConnection(
+ mgt,
+ asyncTimeout,
+ testClientLogger
+ )
+ )
+
+def get_host_credentials(config, hostip):
+ """Get login information for a host `hostip` (ipv4) from marvin's `config`
+
+ @return the tuple username, password for the host else raise keyerror"""
+ for zone in config.zones:
+ for pod in zone.pods:
+ for cluster in pod.clusters:
+ for host in cluster.hosts:
+ if str(host.url).startswith('http'):
+ hostname = urlparse.urlsplit(str(host.url)).netloc
+ else:
+ hostname = str(host.url)
+ try:
+ if socket.getfqdn(hostip) == socket.getfqdn(hostname):
+ return host.username, host.password
+ except socket.error, e:
+ raise Exception("Unresolvable host %s error is %s" % (hostip, e))
+ raise KeyError("Please provide the marvin configuration file with credentials to your hosts")
+
+
+def get_process_status(hostip, port, username, password, linklocalip, process, hypervisor=None):
+ """Double hop and returns a process status"""
+
+ #SSH to the machine
+ ssh = SshClient(hostip, port, username, password)
+ if (str(hypervisor).lower() == 'vmware'
+ or str(hypervisor).lower() == 'hyperv'):
+ ssh_command = "ssh -i /var/cloudstack/management/.ssh/id_rsa -ostricthostkeychecking=no "
+ else:
+ ssh_command = "ssh -i ~/.ssh/id_rsa.cloud -ostricthostkeychecking=no "
+
+ ssh_command = ssh_command +\
+ "-oUserKnownHostsFile=/dev/null -p 3922 %s %s" % (
+ linklocalip,
+ process)
+
+ # Double hop into router
+ timeout = 5
+ # Ensure the SSH login is successful
+ while True:
+ res = ssh.execute(ssh_command)
+
+ if res[0] != "Host key verification failed.":
+ break
+ elif timeout == 0:
+ break
+
+ time.sleep(5)
+ timeout = timeout - 1
+ return res
+
+
+def isAlmostEqual(first_digit, second_digit, range=0):
+ digits_equal_within_range = False
+
+ try:
+ if ((first_digit - range) < second_digit < (first_digit + range)):
+ digits_equal_within_range = True
+ except Exception as e:
+ raise e
+ return digits_equal_within_range
+
+
+def xsplit(txt, seps):
+ """
+ Split a string in `txt` by list of delimiters in `seps`
+ @param txt: string to split
+ @param seps: list of separators
+ @return: list of split units
+ """
+ default_sep = seps[0]
+ for sep in seps[1:]: # we skip seps[0] because that's the default separator
+ txt = txt.replace(sep, default_sep)
+ return [i.strip() for i in txt.split(default_sep)]
+
+def get_hypervisor_type(apiclient):
+
+ """Return the hypervisor type of the hosts in setup"""
+
+ cmd = listHosts.listHostsCmd()
+ cmd.type = 'Routing'
+ cmd.listall = True
+ hosts = apiclient.listHosts(cmd)
+ hosts_list_validation_result = validateList(hosts)
+ assert hosts_list_validation_result[0] == PASS, "host list validation failed"
+ return hosts_list_validation_result[1].hypervisor
+
+def is_snapshot_on_nfs(apiclient, dbconn, config, zoneid, snapshotid):
+ """
+ Checks whether a snapshot with id (not UUID) `snapshotid` is present on the nfs storage
+
+ @param apiclient: api client connection
+ @param @dbconn: connection to the cloudstack db
+ @param config: marvin configuration file
+ @param zoneid: uuid of the zone on which the secondary nfs storage pool is mounted
+ @param snapshotid: uuid of the snapshot
+ @return: True if snapshot is found, False otherwise
+ """
+ # snapshot extension to be appended to the snapshot path obtained from db
+ snapshot_extensions = {"vmware": ".ovf",
+ "kvm": "",
+ "xenserver": ".vhd",
+ "simulator":""}
+
+ qresultset = dbconn.execute(
+ "select id from snapshots where uuid = '%s';" \
+ % str(snapshotid)
+ )
+ if len(qresultset) == 0:
+ raise Exception(
+ "No snapshot found in cloudstack with id %s" % snapshotid)
+
+
+ snapshotid = qresultset[0][0]
+ qresultset = dbconn.execute(
+ "select install_path,store_id from snapshot_store_ref where snapshot_id='%s' and store_role='Image';" % snapshotid
+ )
+
+ assert isinstance(qresultset, list), "Invalid db query response for snapshot %s" % snapshotid
+
+ if len(qresultset) == 0:
+ #Snapshot does not exist
+ return False
+
+ from base import ImageStore
+ #pass store_id to get the exact storage pool where snapshot is stored
+ secondaryStores = ImageStore.list(apiclient, zoneid=zoneid, id=int(qresultset[0][1]))
+
+ assert isinstance(secondaryStores, list), "Not a valid response for listImageStores"
+ assert len(secondaryStores) != 0, "No image stores found in zone %s" % zoneid
+
+ secondaryStore = secondaryStores[0]
+
+ if str(secondaryStore.providername).lower() != "nfs":
+ raise Exception(
+ "is_snapshot_on_nfs works only against nfs secondary storage. found %s" % str(secondaryStore.providername))
+
+ hypervisor = get_hypervisor_type(apiclient)
+ # append snapshot extension based on hypervisor, to the snapshot path
+ snapshotPath = str(qresultset[0][0]) + snapshot_extensions[str(hypervisor).lower()]
+
+ nfsurl = secondaryStore.url
+ from urllib2 import urlparse
+ parse_url = urlparse.urlsplit(nfsurl, scheme='nfs')
+ host, path = parse_url.netloc, parse_url.path
+
+ if not config.mgtSvr:
+ raise Exception("Your marvin configuration does not contain mgmt server credentials")
+ mgtSvr, user, passwd = config.mgtSvr[0].mgtSvrIp, config.mgtSvr[0].user, config.mgtSvr[0].passwd
+
+ try:
+ ssh_client = SshClient(
+ mgtSvr,
+ 22,
+ user,
+ passwd
+ )
+ cmds = [
+ "mkdir -p %s /mnt/tmp",
+ "mount -t %s %s%s /mnt/tmp" % (
+ 'nfs',
+ host,
+ path,
+ ),
+ "test -f %s && echo 'snapshot exists'" % (
+ os.path.join("/mnt/tmp", snapshotPath)
+ ),
+ ]
+
+ for c in cmds:
+ result = ssh_client.execute(c)
+
+ # Unmount the Sec Storage
+ cmds = [
+ "cd",
+ "umount /mnt/tmp",
+ ]
+ for c in cmds:
+ ssh_client.execute(c)
+ except Exception as e:
+ raise Exception("SSH failed for management server: %s - %s" %
+ (config.mgtSvr[0].mgtSvrIp, e))
+ return 'snapshot exists' in result
+
+def validateList(inp):
+ """
+ @name: validateList
+ @Description: 1. A utility function to validate
+ whether the input passed is a list
+ 2. The list is empty or not
+ 3. If it is list and not empty, return PASS and first element
+ 4. If not reason for FAIL
+ @Input: Input to be validated
+ @output: List, containing [ Result,FirstElement,Reason ]
+ Ist Argument('Result') : FAIL : If it is not a list
+ If it is list but empty
+ PASS : If it is list and not empty
+ IInd Argument('FirstElement'): If it is list and not empty,
+ then first element
+ in it, default to None
+ IIIrd Argument( 'Reason' ): Reason for failure ( FAIL ),
+ default to None.
+ INVALID_INPUT
+ EMPTY_LIST
+ """
+ ret = [FAIL, None, None]
+ if inp is None:
+ ret[2] = INVALID_INPUT
+ return ret
+ if not isinstance(inp, list):
+ ret[2] = INVALID_INPUT
+ return ret
+ if len(inp) == 0:
+ ret[2] = EMPTY_LIST
+ return ret
+ return [PASS, inp[0], None]
+
+def verifyElementInList(inp, toverify, responsevar=None, pos=0):
+ '''
+ @name: verifyElementInList
+ @Description:
+ 1. A utility function to validate
+ whether the input passed is a list.
+ The list is empty or not.
+ If it is list and not empty, verify
+ whether a given element is there in that list or not
+ at a given pos
+ @Input:
+ I : Input to be verified whether its a list or not
+ II : Element to verify whether it exists in the list
+ III : variable name in response object to verify
+ default to None, if None, we will verify for the complete
+ first element EX: state of response object object
+ IV : Position in the list at which the input element to verify
+ default to 0
+ @output: List, containing [ Result,Reason ]
+ Ist Argument('Result') : FAIL : If it is not a list
+ If it is list but empty
+ PASS : If it is list and not empty
+ and matching element was found
+ IIrd Argument( 'Reason' ): Reason for failure ( FAIL ),
+ default to None.
+ INVALID_INPUT
+ EMPTY_LIST
+ MATCH_NOT_FOUND
+ '''
+ if toverify is None or toverify == '' \
+ or pos is None or pos < -1 or pos == '':
+ return [FAIL, INVALID_INPUT]
+ out = validateList(inp)
+ if out[0] == FAIL:
+ return [FAIL, out[2]]
+ if len(inp) > pos:
+ if responsevar is None:
+ if inp[pos] == toverify:
+ return [PASS, None]
+ else:
+ if responsevar in inp[pos].__dict__ and getattr(inp[pos], responsevar) == toverify:
+ return [PASS, None]
+ else:
+ return [FAIL, MATCH_NOT_FOUND]
+ else:
+ return [FAIL, MATCH_NOT_FOUND]
+
+def checkVolumeSize(ssh_handle=None,
+ volume_name="/dev/sda",
+ cmd_inp="/sbin/fdisk -l | grep Disk",
+ size_to_verify=0):
+ '''
+ @Name : getDiskUsage
+ @Desc : provides facility to verify the volume size against the size to verify
+ @Input: 1. ssh_handle : machine against which to execute the disk size cmd
+ 2. volume_name : The name of the volume against which to verify the size
+ 3. cmd_inp : Input command used to veify the size
+ 4. size_to_verify: size against which to compare.
+ @Output: Returns FAILED in case of an issue, else SUCCESS
+ '''
+ try:
+ if ssh_handle is None or cmd_inp is None or volume_name is None:
+ return INVALID_INPUT
+
+ cmd = cmd_inp
+ '''
+ Retrieve the cmd output
+ '''
+ if system().lower() != "windows":
+ fdisk_output = ssh_handle.runCommand(cmd_inp)
+ if fdisk_output["status"] != SUCCESS:
+ return FAILED
+ temp_out = fdisk_output["stdout"]
+ for line in temp_out.split("\n"):
+ if volume_name in line:
+ parts = line.split()
+ if str(parts[-2]) == str(size_to_verify):
+ return [SUCCESS,str(parts[-2])]
+ return [FAILED,"Volume Not Found"]
+ except Exception, e:
+ print "\n Exception Occurred under getDiskUsage: " \
+ "%s" %GetDetailExceptionInfo(e)
+ return [FAILED,GetDetailExceptionInfo(e)]
+
+
+def verifyRouterState(apiclient, routerid, allowedstates):
+ """List the router and verify that its state is in allowed states
+ @output: List, containing [Result, Reason]
+ Ist Argument ('Result'): FAIL: If router state is not
+ in allowed states
+ PASS: If router state is in
+ allowed states"""
+
+ try:
+ cmd = listRouters.listRoutersCmd()
+ cmd.id = routerid
+ cmd.listall = True
+ routers = apiclient.listRouters(cmd)
+ except Exception as e:
+ return [FAIL, e]
+ listvalidationresult = validateList(routers)
+ if listvalidationresult[0] == FAIL:
+ return [FAIL, listvalidationresult[2]]
+ if routers[0].redundantstate not in allowedstates:
+ return [FAIL, "Redundant state of the router should be in %s but is %s" %
+ (allowedstates, routers[0].redundantstate)]
+ return [PASS, None]
+
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/tools/marvin/marvin/marvinInit.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/marvinInit.py b/tools/marvin/marvin/marvinInit.py
index f722058..c35fec6 100644
--- a/tools/marvin/marvin/marvinInit.py
+++ b/tools/marvin/marvin/marvinInit.py
@@ -15,56 +15,67 @@
# specific language governing permissions and limitations
# under the License.
'''
-@Desc: Initializes the marvin and does required prerequisites
+Initializes the marvin and does required prerequisites
for starting it.
-1. Parses the configuration file passed to marvin and creates a
- parsed config
+ 1. Parses the configuration file passed to marvin and creates a
+ parsed config.
2. Initializes the logging required for marvin.All logs are
now made available under a single timestamped folder.
- 3. Deploys the Data Center based upon input
+ 3. Deploys the Data Center based upon input.
'''
-
-from marvin import configGenerator
-from marvin import cloudstackException
+from marvin.configGenerator import getSetupConfig
from marvin.marvinLog import MarvinLog
-from marvin.deployDataCenter import deployDataCenters
+from marvin.deployDataCenter import DeployDataCenters
+from marvin.cloudstackTestClient import CSTestClient
+from marvin.cloudstackException import GetDetailExceptionInfo
from marvin.codes import(
- YES,
- NO,
+ XEN_SERVER,
SUCCESS,
FAILED
- )
-import sys
-import time
+)
import os
-import logging
-import string
-import random
class MarvinInit:
- def __init__(self, config_file, load_flag, log_folder_path=None):
+
+ def __init__(self, config_file,
+ deploy_dc_flag=None,
+ test_mod_name="deploydc",
+ zone=None,
+ hypervisor_type=None,
+ user_logfolder_path=None):
self.__configFile = config_file
- self.__loadFlag = load_flag
- self.__parsedConfig = None
- self.__logFolderPath = log_folder_path
+ self.__deployFlag = deploy_dc_flag
+ self.__logFolderPath = None
self.__tcRunLogger = None
+ self.__testModName = test_mod_name
self.__testClient = None
- self.__tcRunDebugFile = None
+ self.__tcResultFile = None
+ self.__testDataFilePath = None
+ self.__zoneForTests = zone
+ self.__parsedConfig = None
+ self.__hypervisorType = hypervisor_type
+ self.__userLogFolderPath = user_logfolder_path
def __parseConfig(self):
'''
+ @Name: __parseConfig
@Desc : Parses the configuration file passed and assigns
the parsed configuration
+ @Output : SUCCESS or FAILED
'''
try:
- self.__parsedConfig = configGenerator.\
- getSetupConfig(self.__configFile)
+ if not os.path.isfile(self.__configFile):
+ print "\n=== Marvin Parse Config Init Failed ==="
+ return FAILED
+ self.__parsedConfig = getSetupConfig(self.__configFile)
+ print "\n=== Marvin Parse Config Successful ==="
return SUCCESS
- except Exception, e:
- print "\n Exception Occurred Under __parseConfig : %s" % str(e)
- return None
+ except Exception as e:
+ print "\nException Occurred Under __parseConfig : " \
+ "%s" % GetDetailExceptionInfo(e)
+ return FAILED
def getParsedConfig(self):
return self.__parsedConfig
@@ -78,33 +89,67 @@ class MarvinInit:
def getLogger(self):
return self.__tcRunLogger
- def getDebugFile(self):
- return self.__tcRunDebugFile
+ def getResultFile(self):
+ '''
+ @Name : getDebugFile
+ @Desc : Creates the result file at a given path.
+ @Output : Returns the Result file to be used for writing
+ test outputs
+ '''
+ if self.__logFolderPath is not None:
+ self.__tcResultFile = open(self.__logFolderPath +
+ "/results.txt", "w")
+ return self.__tcResultFile
+
+ def __setHypervisorAndZoneInfo(self):
+ '''
+ @Name : __setHypervisorAndZoneInfo
+ @Desc: Set the HyperVisor and Zone details;
+ default to XenServer
+ '''
+ try:
+ if not self.__hypervisorType:
+ self.__hypervisorType = XEN_SERVER
+ if not self.__zoneForTests:
+ if self.__parsedConfig:
+ for zone in self.__parsedConfig.zones:
+ self.__zoneForTests = zone.name
+ break
+ return SUCCESS
+ except Exception as e:
+ print "\n Exception Occurred Under init " \
+ "%s" % GetDetailExceptionInfo(e)
+ return FAILED
def init(self):
'''
+ @Name : init
@Desc :Initializes the marvin by
1. Parsing the configuration and creating a parsed config
structure
2. Creates a timestamped log folder and provides all logs
to be dumped there
3. Creates the DataCenter based upon configuration provided
+ @Output : SUCCESS or FAILED
'''
try:
- if ((self.__parseConfig() is not None) and
- (self.__initLogging() is not None) and
- (self.__deployDC() is not None)):
+ if ((self.__parseConfig() != FAILED) and
+ (self.__setHypervisorAndZoneInfo())and
+ (self.__setTestDataPath() != FAILED) and
+ (self.__initLogging() != FAILED) and
+ (self.__createTestClient() != FAILED) and
+ (self.__deployDC() != FAILED)):
return SUCCESS
- else:
- return FAILED
- except Exception, e:
- print "\n Exception Occurred Under init %s" % str(e)
+ return FAILED
+ except Exception as e:
+ print "\n Exception Occurred Under init " \
+ "%s" % GetDetailExceptionInfo(e)
return FAILED
def __initLogging(self):
- try:
- '''
- @Desc : 1. Initializes the logging for marvin and so provides
+ '''
+ @Name : __initLogging
+ @Desc : 1. Initializes the logging for marvin and so provides
various log features for automation run.
2. Initializes all logs to be available under
given Folder Path,where all test run logs
@@ -112,58 +157,87 @@ class MarvinInit:
3. All logging like exception log,results, run info etc
for a given test run are available under a given
timestamped folder
- '''
- temp_path = "".join(str(time.time()).split("."))
- if self.__logFolderPath is None:
- log_config = self.__parsedConfig.logger
- if log_config is not None:
- if log_config.LogFolderPath is not None:
- self.logFolderPath = log_config.LogFolderPath + '/' \
- + temp_path
- else:
- self.logFolderPath = temp_path
- else:
- self.logFolderPath = temp_path
- else:
- self.logFolderPath = self.__logFolderPath + '/' + temp_path
- if os.path.exists(self.logFolderPath):
- self.logFolderPath += ''.join(random.choice(
- string.ascii_uppercase +
- string.digits for x in range(3)))
- os.makedirs(self.logFolderPath)
- '''
- Log File Paths
- '''
- tc_failed_exceptionlog = self.logFolderPath + "/failed_" \
- "plus_" \
- "exceptions.txt"
- tc_run_log = self.logFolderPath + "/runinfo.txt"
- self.__tcRunDebugFile = open(self.logFolderPath +
- "/results.txt", "w")
-
+ @Output : SUCCESS or FAILED
+ '''
+ try:
log_obj = MarvinLog("CSLog")
- self.__tcRunLogger = log_obj.setLogHandler(tc_run_log)
- log_obj.setLogHandler(tc_failed_exceptionlog,
- log_level=logging.FATAL)
+ if log_obj:
+ ret = log_obj.\
+ createLogs(self.__testModName,
+ self.__parsedConfig.logger,
+ self.__userLogFolderPath)
+ if ret != FAILED:
+ self.__logFolderPath = log_obj.getLogFolderPath()
+ self.__tcRunLogger = log_obj.getLogger()
+ print "\n=== Marvin Init Logging Successful==="
+ return SUCCESS
+ return FAILED
+ except Exception as e:
+ print "\n Exception Occurred Under __initLogging " \
+ ":%s" % GetDetailExceptionInfo(e)
+ return FAILED
+
+ def __createTestClient(self):
+ '''
+ @Name : __createTestClient
+ @Desc : Creates the TestClient during init
+ based upon the parameters provided
+ @Output: Returns SUCCESS or FAILED
+ '''
+ try:
+ mgt_details = self.__parsedConfig.mgtSvr[0]
+ dbsvr_details = self.__parsedConfig.dbSvr
+ self.__testClient = CSTestClient(mgt_details, dbsvr_details,
+ logger=self.__tcRunLogger,
+ test_data_filepath=
+ self.__testDataFilePath,
+ zone=self.__zoneForTests,
+ hypervisor_type=
+ self.__hypervisorType)
+ if self.__testClient:
+ return self.__testClient.createTestClient()
+ return FAILED
+ except Exception as e:
+ print "\n Exception Occurred Under __createTestClient : %s" % \
+ GetDetailExceptionInfo(e)
+ return FAILED
+
+ def __setTestDataPath(self):
+ '''
+ @Name : __setTestDataPath
+ @Desc : Sets the TestData Path for tests to run
+ @Output:Returns SUCCESS or FAILED
+ '''
+ try:
+ if ((self.__parsedConfig.TestData is not None) and
+ (self.__parsedConfig.TestData.Path is not None)):
+ self.__testDataFilePath = self.__parsedConfig.TestData.Path
+ print "\n=== Marvin Setting TestData Successful==="
return SUCCESS
- except Exception, e:
- print "\n Exception Occurred Under __initLogging :%s" % str(e)
- return None
+ except Exception as e:
+ print "\nException Occurred Under __setTestDataPath : %s" % \
+ GetDetailExceptionInfo(e)
+ return FAILED
def __deployDC(self):
+ '''
+ @Name : __deployDC
+ @Desc : Deploy the DataCenter and returns accordingly.
+ @Output: SUCCESS or FAILED
+ '''
try:
- '''
- Deploy the DataCenter and retrieves test client.
- '''
- deploy_obj = deployDataCenters(self.__parsedConfig,
- self.__tcRunLogger)
- if self.__loadFlag:
- deploy_obj.loadCfg()
- else:
- deploy_obj.deploy()
-
- self.__testClient = deploy_obj.testClient
- return SUCCESS
- except Exception, e:
- print "\n Exception Occurred Under __deployDC : %s" % str(e)
- return None
+ ret = SUCCESS
+ if self.__deployFlag:
+ deploy_obj = DeployDataCenters(self.__testClient,
+ self.__parsedConfig,
+ self.__tcRunLogger)
+ ret = deploy_obj.deploy()
+ if ret == SUCCESS:
+ print "Deploy DC Successful"
+ else:
+ print "Deploy DC Failed"
+ return ret
+ except Exception as e:
+ print "\n Exception Occurred Under __deployDC : %s" % \
+ GetDetailExceptionInfo(e)
+ return FAILED
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/tools/marvin/marvin/marvinLog.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/marvinLog.py b/tools/marvin/marvin/marvinLog.py
index 76de185..65687aa 100644
--- a/tools/marvin/marvin/marvinLog.py
+++ b/tools/marvin/marvin/marvinLog.py
@@ -20,17 +20,22 @@
import logging
import sys
import time
-from marvin.codes import (NO,
- YES
+import os
+from marvin.codes import (SUCCESS,
+ FAILED
)
+from marvin.cloudstackException import GetDetailExceptionInfo
+from marvin.lib.utils import random_gen
class MarvinLog:
+
'''
+ @Name : MarvinLog
@Desc : provides interface for logging to marvin
@Input : logger_name : name for logger
'''
- logFormat = logging.Formatter("%(asctime)s - %(levelname)s - %(name)s - %(message)s")
+ logFormat = logging.Formatter("%(asctime)s - %(levelname)s - %(message)s")
_instance = None
def __new__(cls, logger_name):
@@ -39,21 +44,39 @@ class MarvinLog:
return cls._instance
def __init__(self, logger_name):
- self.loggerName = logger_name
- self.logger = None
+ '''
+ @Name: __init__
+ @Input: logger_name for logger
+ '''
+ self.__loggerName = logger_name
+ '''
+ Logger for Logging Info
+ '''
+ self.__logger = None
+ '''
+ Log Folder Directory
+ '''
+ self.__logFolderDir = None
self.__setLogger()
def __setLogger(self):
- self.logger = logging.getLogger(self.loggerName)
- self.logger.setLevel(logging.DEBUG)
+ '''
+ @Name : __setLogger
+ @Desc : Sets the Logger and Level
+ '''
+ self.__logger = logging.getLogger(self.__loggerName)
+ self.__logger.setLevel(logging.DEBUG)
- def setLogHandler(self, log_file_path, log_format=None,
- log_level=logging.DEBUG):
+ def __setLogHandler(self, log_file_path,
+ log_format=None,
+ log_level=logging.DEBUG):
'''
+ @Name : __setLogHandler
@Desc: Adds the given Log handler to the current logger
@Input: log_file_path: Log File Path as where to store the logs
log_format : Format of log messages to be dumped
log_level : Determines the level of logging for this logger
+ @Output: SUCCESS if no issues else FAILED
'''
try:
if log_file_path is not None:
@@ -66,8 +89,98 @@ class MarvinLog:
else:
stream.setFormatter(self.__class__.logFormat)
stream.setLevel(log_level)
- self.logger.addHandler(stream)
- except Exception, e:
- print "\n Exception Occurred Under setLogHandler %s" % str(e)
- finally:
- return self.logger
+ self.__logger.addHandler(stream)
+ return SUCCESS
+ except Exception as e:
+ print "\nException Occurred Under " \
+ "__setLogHandler %s" % GetDetailExceptionInfo(e)
+ return FAILED
+
+ def __cleanPreviousLogs(self, logfolder_to_remove):
+ '''
+ @Name : __cleanPreviousLogs
+ @Desc : Removes the Previous Logs
+ @Return: N\A
+ @Input: logfolder_to_remove: Path of Log to remove
+ '''
+ try:
+ if os.path.isdir(logfolder_to_remove):
+ os.rmdir(logfolder_to_remove)
+ except Exception as e:
+ print "\n Exception Occurred Under __cleanPreviousLogs :%s" % \
+ GetDetailExceptionInfo(e)
+ return FAILED
+
+ def getLogger(self):
+ '''
+ @Name:getLogger
+ @Desc : Returns the Logger
+ '''
+ return self.__logger
+
+ def getLogFolderPath(self):
+ '''
+ @Name : getLogFolderPath
+ @Desc : Returns the final log directory path for marvin run
+ '''
+ return self.__logFolderDir
+
+ def createLogs(self,
+ test_module_name=None,
+ log_cfg=None,
+ user_provided_logpath=None):
+ '''
+ @Name : createLogs
+ @Desc : Gets the Logger with file paths initialized and created
+ @Inputs :test_module_name: Test Module Name to use for logs while
+ creating log folder path
+ log_cfg: Log Configuration provided inside of
+ Configuration
+ user_provided_logpath:LogPath provided by user
+ If user provided log path
+ is available, then one in cfg
+ will not be picked up.
+ @Output : SUCCESS\FAILED
+ '''
+ try:
+ temp_ts = time.strftime("%b_%d_%Y_%H_%M_%S",
+ time.localtime())
+ if test_module_name is None:
+ temp_path = temp_ts + "_" + random_gen()
+ else:
+ temp_path = str(test_module_name) + \
+ "__" + str(temp_ts) + "_" + random_gen()
+
+ if user_provided_logpath:
+ temp_dir = user_provided_logpath
+ elif ((log_cfg is not None) and
+ ('LogFolderPath' in log_cfg.__dict__.keys()) and
+ (log_cfg.__dict__.get('LogFolderPath') is not None)):
+ temp_dir = \
+ log_cfg.__dict__.get('LogFolderPath') + "/MarvinLogs"
+
+ self.__logFolderDir = temp_dir + "//" + temp_path
+ print "\n==== Log Folder Path: %s. " \
+ "All logs will be available here ====" \
+ % str(self.__logFolderDir)
+ os.makedirs(self.__logFolderDir)
+
+ '''
+ Log File Paths
+ 1. FailedExceptionLog
+ 2. RunLog contains the complete Run Information for Test Run
+ 3. ResultFile contains the TC result information for Test Run
+ '''
+ tc_failed_exception_log = \
+ self.__logFolderDir + "/failed_plus_exceptions.txt"
+ tc_run_log = self.__logFolderDir + "/runinfo.txt"
+ if self.__setLogHandler(tc_run_log,
+ log_level=logging.DEBUG) != FAILED:
+ self.__setLogHandler(tc_failed_exception_log,
+ log_level=logging.FATAL)
+ return SUCCESS
+ return FAILED
+ except Exception as e:
+ print "\n Exception Occurred Under createLogs :%s" % \
+ GetDetailExceptionInfo(e)
+ return FAILED
[05/18] Marvin + test changes from master Signed-off-by:
SrikanteswaraRao Talluri
Posted by da...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/tools/marvin/marvin/integration/lib/base.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/integration/lib/base.py b/tools/marvin/marvin/integration/lib/base.py
deleted file mode 100755
index c23ea8a..0000000
--- a/tools/marvin/marvin/integration/lib/base.py
+++ /dev/null
@@ -1,3890 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-""" Base class for all Cloudstack resources
- -Virtual machine, Volume, Snapshot etc
-"""
-
-import marvin
-from utils import is_server_ssh_ready, random_gen
-from marvin.cloudstackAPI import *
-# Import System modules
-import time
-import hashlib
-import base64
-
-
-class Domain:
- """ Domain Life Cycle """
- def __init__(self, items):
- self.__dict__.update(items)
-
- @classmethod
- def create(cls, apiclient, services, name=None, networkdomain=None,
- parentdomainid=None):
- """Creates an domain"""
-
- cmd = createDomain.createDomainCmd()
-
- if "domainUUID" in services:
- cmd.domainid = "-".join([services["domainUUID"], random_gen()])
-
- if name:
- cmd.name = "-".join([name, random_gen()])
- elif "name" in services:
- cmd.name = "-".join([services["name"], random_gen()])
-
- if networkdomain:
- cmd.networkdomain = networkdomain
- elif "networkdomain" in services:
- cmd.networkdomain = services["networkdomain"]
-
- if parentdomainid:
- cmd.parentdomainid = parentdomainid
- elif "parentdomainid" in services:
- cmd.parentdomainid = services["parentdomainid"]
- try:
- domain = apiclient.createDomain(cmd)
- if domain is not None:
- return Domain(domain.__dict__)
- except Exception as e:
- raise e
-
- def delete(self, apiclient, cleanup=None):
- """Delete an domain"""
- cmd = deleteDomain.deleteDomainCmd()
- cmd.id = self.id
- if cleanup:
- cmd.cleanup = cleanup
- apiclient.deleteDomain(cmd)
-
- @classmethod
- def list(cls, apiclient, **kwargs):
- """Lists domains"""
- cmd = listDomains.listDomainsCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listDomains(cmd))
-
-
-class Account:
- """ Account Life Cycle """
- def __init__(self, items):
- self.__dict__.update(items)
-
- @classmethod
- def create(cls, apiclient, services, admin=False, domainid=None):
- """Creates an account"""
- cmd = createAccount.createAccountCmd()
-
- # 0 - User, 1 - Root Admin, 2 - Domain Admin
- cmd.accounttype = 2 if (admin and domainid) else int(admin)
-
- cmd.email = services["email"]
- cmd.firstname = services["firstname"]
- cmd.lastname = services["lastname"]
-
- cmd.password = services["password"]
-
- username = "-".join([services["username"], random_gen(id=apiclient.id)])
- # Trim username to 99 characters to prevent failure
- cmd.username = username[:99] if len(username) > 99 else username
-
- if "accountUUID" in services:
- cmd.accountid = "-".join([services["accountUUID"],random_gen()])
-
- if "userUUID" in services:
- cmd.userid = "-".join([services["userUUID"],random_gen()])
-
-
- if domainid:
- cmd.domainid = domainid
- account = apiclient.createAccount(cmd)
-
- return Account(account.__dict__)
-
- def delete(self, apiclient):
- """Delete an account"""
- cmd = deleteAccount.deleteAccountCmd()
- cmd.id = self.id
- apiclient.deleteAccount(cmd)
-
- @classmethod
- def list(cls, apiclient, **kwargs):
- """Lists accounts and provides detailed account information for
- listed accounts"""
-
- cmd = listAccounts.listAccountsCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listAccounts(cmd))
-
- def disable(self, apiclient, lock=False):
- """Disable an account"""
- cmd = disableAccount.disableAccountCmd()
- cmd.id = self.id
- cmd.lock = lock
- apiclient.disableAccount(cmd)
-
-
-class User:
- """ User Life Cycle """
- def __init__(self, items):
- self.__dict__.update(items)
-
- @classmethod
- def create(cls, apiclient, services, account, domainid):
- cmd = createUser.createUserCmd()
- """Creates an user"""
-
- cmd.account = account
- cmd.domainid = domainid
- cmd.email = services["email"]
- cmd.firstname = services["firstname"]
- cmd.lastname = services["lastname"]
-
- if "userUUID" in services:
- cmd.userid = "-".join([services["userUUID"],random_gen()])
-
- cmd.password = services["password"]
- cmd.username = "-".join([services["username"], random_gen()])
- user = apiclient.createUser(cmd)
-
- return User(user.__dict__)
-
- def delete(self, apiclient):
- """Delete an account"""
- cmd = deleteUser.deleteUserCmd()
- cmd.id = self.id
- apiclient.deleteUser(cmd)
-
- @classmethod
- def list(cls, apiclient, **kwargs):
- """Lists users and provides detailed account information for
- listed users"""
-
- cmd = listUsers.listUsersCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listUsers(cmd))
-
- @classmethod
- def registerUserKeys(cls, apiclient, userid):
- cmd = registerUserKeys.registerUserKeysCmd()
- cmd.id = userid
- return apiclient.registerUserKeys(cmd)
-
- def update(self, apiclient, **kwargs):
- """Updates the user details"""
-
- cmd = updateUser.updateUserCmd()
- cmd.id = self.id
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return (apiclient.updateUser(cmd))
-
- @classmethod
- def update(cls, apiclient, id, **kwargs):
- """Updates the user details (class method)"""
-
- cmd = updateUser.updateUserCmd()
- cmd.id = id
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return (apiclient.updateUser(cmd))
-
- @classmethod
- def login(cls, apiclient, username, password, domain=None, domainid=None):
- """Logins to the CloudStack"""
-
- cmd = login.loginCmd()
- cmd.username = username
- cmd.password = password
- if domain:
- cmd.domain = domain
- if domainid:
- cmd.domainId = domainid
- return apiclient.login(cmd)
-
-
-class VirtualMachine:
- """Manage virtual machine lifecycle"""
-
- def __init__(self, items, services):
- self.__dict__.update(items)
- if "username" in services:
- self.username = services["username"]
- else:
- self.username = 'root'
- if "password" in services:
- self.password = services["password"]
- else:
- self.password = 'password'
- if "ssh_port" in services:
- self.ssh_port = services["ssh_port"]
- else:
- self.ssh_port = 22
- self.ssh_client = None
- # extract out the ipaddress
- self.ipaddress = self.nic[0].ipaddress
-
- @classmethod
- def ssh_access_group(cls, apiclient, cmd):
- """
- Programs the security group with SSH access before deploying virtualmachine
- @return:
- """
- zone_list = Zone.list(
- apiclient,
- id=cmd.zoneid if cmd.zoneid else None,
- domainid=cmd.domainid if cmd.domainid else None
- )
- zone = zone_list[0]
- #check if security groups settings is enabled for the zone
- if zone.securitygroupsenabled:
- list_security_groups = SecurityGroup.list(
- apiclient,
- account=cmd.account,
- domainid=cmd.domainid,
- listall=True,
- securitygroupname="basic_sec_grp"
- )
-
- if not isinstance(list_security_groups, list):
- basic_mode_security_group = SecurityGroup.create(
- apiclient,
- {"name": "basic_sec_grp"},
- cmd.account,
- cmd.domainid,
- )
- sec_grp_services = {
- "protocol": "TCP",
- "startport": 22,
- "endport": 22,
- "cidrlist": "0.0.0.0/0"
- }
- #Authorize security group for above ingress rule
- basic_mode_security_group.authorize(apiclient, sec_grp_services, account=cmd.account,
- domainid=cmd.domainid)
- else:
- basic_mode_security_group = list_security_groups[0]
-
- if isinstance(cmd.securitygroupids, list):
- cmd.securitygroupids.append(basic_mode_security_group.id)
- else:
- cmd.securitygroupids = [basic_mode_security_group.id]
-
- @classmethod
- def access_ssh_over_nat(cls, apiclient, services, virtual_machine, allow_egress=False):
- """
- Program NAT and PF rules to open up ssh access to deployed guest
- @return:
- """
- public_ip = PublicIPAddress.create(
- apiclient=apiclient,
- accountid=virtual_machine.account,
- zoneid=virtual_machine.zoneid,
- domainid=virtual_machine.domainid,
- services=services
- )
- FireWallRule.create(
- apiclient=apiclient,
- ipaddressid=public_ip.ipaddress.id,
- protocol='TCP',
- cidrlist=['0.0.0.0/0'],
- startport=22,
- endport=22
- )
- nat_rule = NATRule.create(
- apiclient=apiclient,
- virtual_machine=virtual_machine,
- services=services,
- ipaddressid=public_ip.ipaddress.id
- )
- if allow_egress:
- EgressFireWallRule.create(
- apiclient=apiclient,
- networkid=virtual_machine.nic[0].networkid,
- protocol='All',
- cidrlist='0.0.0.0/0'
- )
- virtual_machine.ssh_ip = nat_rule.ipaddress
- virtual_machine.public_ip = nat_rule.ipaddress
-
- @classmethod
- def create(cls, apiclient, services, templateid=None, accountid=None,
- domainid=None, zoneid=None, networkids=None, serviceofferingid=None,
- securitygroupids=None, projectid=None, startvm=None,
- diskofferingid=None, affinitygroupnames=None, affinitygroupids=None, group=None,
- hostid=None, keypair=None, ipaddress=None, mode='default', method='GET',
- customcpunumber=None, customcpuspeed=None, custommemory=None, rootdisksize=None):
- """Create the instance"""
-
- cmd = deployVirtualMachine.deployVirtualMachineCmd()
-
- if serviceofferingid:
- cmd.serviceofferingid = serviceofferingid
- elif "serviceoffering" in services:
- cmd.serviceofferingid = services["serviceoffering"]
-
- if zoneid:
- cmd.zoneid = zoneid
- elif "zoneid" in services:
- cmd.zoneid = services["zoneid"]
- cmd.hypervisor = apiclient.hypervisor
-
- if "displayname" in services:
- cmd.displayname = services["displayname"]
-
- if "name" in services:
- cmd.name = services["name"]
-
- if accountid:
- cmd.account = accountid
- elif "account" in services:
- cmd.account = services["account"]
-
- if domainid:
- cmd.domainid = domainid
- elif "domainid" in services:
- cmd.domainid = services["domainid"]
-
- if networkids:
- cmd.networkids = networkids
- allow_egress = False
- elif "networkids" in services:
- cmd.networkids = services["networkids"]
- allow_egress = False
- else:
- # When no networkids are passed, network
- # is created using the "defaultOfferingWithSourceNAT"
- # which has an egress policy of DENY. But guests in tests
- # need access to test network connectivity
- allow_egress = True
-
- if templateid:
- cmd.templateid = templateid
- elif "template" in services:
- cmd.templateid = services["template"]
-
- if diskofferingid:
- cmd.diskofferingid = diskofferingid
- elif "diskoffering" in services:
- cmd.diskofferingid = services["diskoffering"]
-
- if keypair:
- cmd.keypair = keypair
- elif "keypair" in services:
- cmd.keypair = services["keypair"]
-
- if ipaddress:
- cmd.ipaddress = ipaddress
- elif ipaddress in services:
- cmd.ipaddress = services["ipaddress"]
-
- if securitygroupids:
- cmd.securitygroupids = [str(sg_id) for sg_id in securitygroupids]
-
- if "affinitygroupnames" in services:
- cmd.affinitygroupnames = services["affinitygroupnames"]
- elif affinitygroupnames:
- cmd.affinitygroupnames = affinitygroupnames
-
- if affinitygroupids:
- cmd.affinitygroupids = affinitygroupids
-
- if projectid:
- cmd.projectid = projectid
-
- if startvm is not None:
- cmd.startvm = startvm
-
- if hostid:
- cmd.hostid = hostid
-
- if "userdata" in services:
- cmd.userdata = base64.urlsafe_b64encode(services["userdata"])
-
- cmd.details = [{}]
-
- if customcpunumber:
- cmd.details[0]["cpuNumber"] = customcpunumber
-
- if customcpuspeed:
- cmd.details[0]["cpuSpeed"] = customcpuspeed
-
- if custommemory:
- cmd.details[0]["memory"] = custommemory
-
- if rootdisksize >= 0:
- cmd.details[0]["rootdisksize"] = rootdisksize
-
- if group:
- cmd.group = group
-
- #program default access to ssh
- if mode.lower() == 'basic':
- cls.ssh_access_group(apiclient, cmd)
-
- virtual_machine = apiclient.deployVirtualMachine(cmd, method=method)
-
- virtual_machine.ssh_ip = virtual_machine.nic[0].ipaddress
- if startvm == False:
- virtual_machine.public_ip = virtual_machine.nic[0].ipaddress
- return VirtualMachine(virtual_machine.__dict__, services)
-
- #program ssh access over NAT via PF
- if mode.lower() == 'advanced':
- cls.access_ssh_over_nat(apiclient, services, virtual_machine, allow_egress=allow_egress)
- elif mode.lower() == 'basic':
- if virtual_machine.publicip is not None:
- vm_ssh_ip = virtual_machine.publicip #EIP/ELB (netscaler) enabled zone
- else:
- vm_ssh_ip = virtual_machine.nic[0].ipaddress #regular basic zone with security group
- virtual_machine.ssh_ip = vm_ssh_ip
- virtual_machine.public_ip = vm_ssh_ip
-
- return VirtualMachine(virtual_machine.__dict__, services)
-
- def start(self, apiclient):
- """Start the instance"""
- cmd = startVirtualMachine.startVirtualMachineCmd()
- cmd.id = self.id
- apiclient.startVirtualMachine(cmd)
-
- def stop(self, apiclient):
- """Stop the instance"""
- cmd = stopVirtualMachine.stopVirtualMachineCmd()
- cmd.id = self.id
- apiclient.stopVirtualMachine(cmd)
-
- def reboot(self, apiclient):
- """Reboot the instance"""
- cmd = rebootVirtualMachine.rebootVirtualMachineCmd()
- cmd.id = self.id
- apiclient.rebootVirtualMachine(cmd)
-
- def recover(self, apiclient):
- """Recover the instance"""
- cmd = recoverVirtualMachine.recoverVirtualMachineCmd()
- cmd.id = self.id
- apiclient.recoverVirtualMachine(cmd)
-
- def restore(self, apiclient, templateid=None):
- """Restore the instance"""
- cmd = restoreVirtualMachine.restoreVirtualMachineCmd()
- cmd.virtualmachineid = self.id
- if templateid:
- cmd.templateid = templateid
- return apiclient.restoreVirtualMachine(cmd)
-
- def get_ssh_client(self, ipaddress=None, reconnect=False, port=None, keyPairFileLocation=None):
- """Get SSH object of VM"""
-
- # If NAT Rules are not created while VM deployment in Advanced mode
- # then, IP address must be passed
- if ipaddress != None:
- self.ssh_ip = ipaddress
- if port:
- self.ssh_port = port
-
- if keyPairFileLocation is not None:
- self.password = None
-
- if reconnect:
- self.ssh_client = is_server_ssh_ready(
- self.ssh_ip,
- self.ssh_port,
- self.username,
- self.password,
- keyPairFileLocation=keyPairFileLocation
- )
- self.ssh_client = self.ssh_client or is_server_ssh_ready(
- self.ssh_ip,
- self.ssh_port,
- self.username,
- self.password,
- keyPairFileLocation=keyPairFileLocation
- )
- return self.ssh_client
-
- def resetSshKey(self, apiclient, **kwargs):
- """Resets SSH key"""
-
- cmd = resetSSHKeyForVirtualMachine.resetSSHKeyForVirtualMachineCmd()
- cmd.id = self.id
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.resetSSHKeyForVirtualMachine(cmd))
-
- def update(self, apiclient, **kwargs):
- """Updates the VM data"""
-
- cmd = updateVirtualMachine.updateVirtualMachineCmd()
- cmd.id = self.id
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.updateVirtualMachine(cmd))
-
- def delete(self, apiclient):
- """Destroy an Instance"""
- cmd = destroyVirtualMachine.destroyVirtualMachineCmd()
- cmd.id = self.id
- apiclient.destroyVirtualMachine(cmd)
-
- def migrate(self, apiclient, hostid=None):
- """migrate an Instance"""
- cmd = migrateVirtualMachine.migrateVirtualMachineCmd()
- cmd.virtualmachineid = self.id
- if hostid:
- cmd.hostid = hostid
- apiclient.migrateVirtualMachine(cmd)
-
- def attach_volume(self, apiclient, volume):
- """Attach volume to instance"""
- cmd = attachVolume.attachVolumeCmd()
- cmd.id = volume.id
- cmd.virtualmachineid = self.id
- return apiclient.attachVolume(cmd)
-
- def detach_volume(self, apiclient, volume):
- """Detach volume to instance"""
- cmd = detachVolume.detachVolumeCmd()
- cmd.id = volume.id
- return apiclient.detachVolume(cmd)
-
- def add_nic(self, apiclient, networkId, ipaddress=None):
- """Add a NIC to a VM"""
- cmd = addNicToVirtualMachine.addNicToVirtualMachineCmd()
- cmd.virtualmachineid = self.id
- cmd.networkid = networkId
-
- if ipaddress:
- cmd.ipaddress = ipaddress
-
- return apiclient.addNicToVirtualMachine(cmd)
-
- def remove_nic(self, apiclient, nicId):
- """Remove a NIC to a VM"""
- cmd = removeNicFromVirtualMachine.removeNicFromVirtualMachineCmd()
- cmd.nicid = nicId
- cmd.virtualmachineid = self.id
- return apiclient.removeNicFromVirtualMachine(cmd)
-
- def update_default_nic(self, apiclient, nicId):
- """Set a NIC to be the default network adapter for a VM"""
- cmd = updateDefaultNicForVirtualMachine.updateDefaultNicForVirtualMachineCmd()
- cmd.nicid = nicId
- cmd.virtualmachineid = self.id
- return apiclient.updateDefaultNicForVirtualMachine(cmd)
-
- def attach_iso(self, apiclient, iso):
- """Attach ISO to instance"""
- cmd = attachIso.attachIsoCmd()
- cmd.id = iso.id
- cmd.virtualmachineid = self.id
- return apiclient.attachIso(cmd)
-
- def detach_iso(self, apiclient):
- """Detach ISO to instance"""
- cmd = detachIso.detachIsoCmd()
- cmd.id = self.id
- return apiclient.detachIso(cmd)
-
- def change_service_offering(self, apiclient, serviceOfferingId):
- """Change service offering of the instance"""
- cmd = changeServiceForVirtualMachine.changeServiceForVirtualMachineCmd()
- cmd.id = self.id
- cmd.serviceofferingid = serviceOfferingId
- return apiclient.changeServiceForVirtualMachine(cmd)
-
- @classmethod
- def list(cls, apiclient, **kwargs):
- """List all VMs matching criteria"""
-
- cmd = listVirtualMachines.listVirtualMachinesCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listVirtualMachines(cmd))
-
- def resetPassword(self, apiclient):
- """Resets VM password if VM created using password enabled template"""
-
- cmd = resetPasswordForVirtualMachine.resetPasswordForVirtualMachineCmd()
- cmd.id = self.id
- try:
- response = apiclient.resetPasswordForVirtualMachine(cmd)
- except Exception as e:
- raise Exception("Reset Password failed! - %s" % e)
- if response is not None:
- return response.password
-
- def assign_virtual_machine(self, apiclient, account, domainid):
- """Move a user VM to another user under same domain."""
-
- cmd = assignVirtualMachine.assignVirtualMachineCmd()
- cmd.virtualmachineid = self.id
- cmd.account = account
- cmd.domainid = domainid
- try:
- response = apiclient.assignVirtualMachine(cmd)
- return response
- except Exception as e:
- raise Exception("assignVirtualMachine failed - %s" %e)
-
- def update_affinity_group(self, apiclient, affinitygroupids=None,
- affinitygroupnames=None):
- """Update affinity group of a VM"""
- cmd = updateVMAffinityGroup.updateVMAffinityGroupCmd()
- cmd.id = self.id
-
- if affinitygroupids:
- cmd.affinitygroupids = affinitygroupids
-
- if affinitygroupnames:
- cmd.affinitygroupnames = affinitygroupnames
-
- return apiclient.updateVMAffinityGroup(cmd)
-
- def scale(self, apiclient, serviceOfferingId,
- customcpunumber=None, customcpuspeed=None, custommemory=None):
- """Change service offering of the instance"""
- cmd = scaleVirtualMachine.scaleVirtualMachineCmd()
- cmd.id = self.id
- cmd.serviceofferingid = serviceOfferingId
- cmd.details = [{"cpuNumber": "","cpuSpeed":"","memory":""}]
- if customcpunumber:
- cmd.details[0]["cpuNumber"] = customcpunumber
- if customcpuspeed:
- cmd.details[0]["cpuSpeed"] = customcpuspeed
- if custommemory:
- cmd.details[0]["memory"] = custommemory
- return apiclient.scaleVirtualMachine(cmd)
-
-
-class Volume:
- """Manage Volume Life cycle
- """
- def __init__(self, items):
- self.__dict__.update(items)
-
- @classmethod
- def create(cls, apiclient, services, zoneid=None, account=None,
- domainid=None, diskofferingid=None, projectid=None):
- """Create Volume"""
- cmd = createVolume.createVolumeCmd()
- cmd.name = services["diskname"]
-
- if diskofferingid:
- cmd.diskofferingid = diskofferingid
- elif "diskofferingid" in services:
- cmd.diskofferingid = services["diskofferingid"]
-
- if zoneid:
- cmd.zoneid = zoneid
- elif "zoneid" in services:
- cmd.zoneid = services["zoneid"]
-
- if account:
- cmd.account = account
- elif "account" in services:
- cmd.account = services["account"]
-
- if domainid:
- cmd.domainid = domainid
- elif "domainid" in services:
- cmd.domainid = services["domainid"]
-
- if projectid:
- cmd.projectid = projectid
- return Volume(apiclient.createVolume(cmd).__dict__)
-
- @classmethod
- def create_custom_disk(cls, apiclient, services, account=None,
- domainid=None, diskofferingid=None):
- """Create Volume from Custom disk offering"""
- cmd = createVolume.createVolumeCmd()
- cmd.name = services["diskname"]
-
- if diskofferingid:
- cmd.diskofferingid = diskofferingid
- elif "customdiskofferingid" in services:
- cmd.diskofferingid = services["customdiskofferingid"]
-
- cmd.size = services["customdisksize"]
- cmd.zoneid = services["zoneid"]
-
- if account:
- cmd.account = account
- else:
- cmd.account = services["account"]
-
- if domainid:
- cmd.domainid = domainid
- else:
- cmd.domainid = services["domainid"]
-
- return Volume(apiclient.createVolume(cmd).__dict__)
-
- @classmethod
- def create_from_snapshot(cls, apiclient, snapshot_id, services,
- account=None, domainid=None):
- """Create Volume from snapshot"""
- cmd = createVolume.createVolumeCmd()
- cmd.name = "-".join([services["diskname"], random_gen()])
- cmd.snapshotid = snapshot_id
- cmd.zoneid = services["zoneid"]
- cmd.size = services["size"]
- if account:
- cmd.account = account
- else:
- cmd.account = services["account"]
- if domainid:
- cmd.domainid = domainid
- else:
- cmd.domainid = services["domainid"]
- return Volume(apiclient.createVolume(cmd).__dict__)
-
- def delete(self, apiclient):
- """Delete Volume"""
- cmd = deleteVolume.deleteVolumeCmd()
- cmd.id = self.id
- apiclient.deleteVolume(cmd)
-
- @classmethod
- def list(cls, apiclient, **kwargs):
- """List all volumes matching criteria"""
-
- cmd = listVolumes.listVolumesCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listVolumes(cmd))
-
- def resize(self, apiclient, **kwargs):
- """Resize a volume"""
- cmd = resizeVolume.resizeVolumeCmd()
- cmd.id = self.id
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.resizeVolume(cmd))
-
- @classmethod
- def upload(cls, apiclient, services, zoneid=None, account=None, domainid=None, url=None):
- """Uploads the volume to specified account"""
-
- cmd = uploadVolume.uploadVolumeCmd()
- if zoneid:
- cmd.zoneid = zoneid
- if account:
- cmd.account = account
- if domainid:
- cmd.domainid = domainid
- cmd.format = services["format"]
- cmd.name = services["diskname"]
- if url:
- cmd.url = url
- else:
- cmd.url = services["url"]
- return Volume(apiclient.uploadVolume(cmd).__dict__)
-
- def wait_for_upload(self, apiclient, timeout=10, interval=60):
- """Wait for upload"""
- # Sleep to ensure template is in proper state before download
- time.sleep(interval)
-
- while True:
- volume_response = Volume.list(
- apiclient,
- id=self.id,
- zoneid=self.zoneid,
- )
- if isinstance(volume_response, list):
-
- volume = volume_response[0]
- # If volume is ready,
- # volume.state = Allocated
- if volume.state == 'Uploaded':
- break
-
- elif 'Uploading' in volume.state:
- time.sleep(interval)
-
- elif 'Installing' not in volume.state:
- raise Exception(
- "Error in uploading volume: status - %s" %
- volume.state)
- elif timeout == 0:
- break
-
- else:
- time.sleep(interval)
- timeout = timeout - 1
- return
-
- @classmethod
- def migrate(cls, apiclient, **kwargs):
- """Migrate a volume"""
- cmd = migrateVolume.migrateVolumeCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.migrateVolume(cmd))
-
-class Snapshot:
- """Manage Snapshot Lifecycle
- """
- def __init__(self, items):
- self.__dict__.update(items)
-
- @classmethod
- def create(cls, apiclient, volume_id, account=None,
- domainid=None, projectid=None):
- """Create Snapshot"""
- cmd = createSnapshot.createSnapshotCmd()
- cmd.volumeid = volume_id
- if account:
- cmd.account = account
- if domainid:
- cmd.domainid = domainid
- if projectid:
- cmd.projectid = projectid
- return Snapshot(apiclient.createSnapshot(cmd).__dict__)
-
- def delete(self, apiclient):
- """Delete Snapshot"""
- cmd = deleteSnapshot.deleteSnapshotCmd()
- cmd.id = self.id
- apiclient.deleteSnapshot(cmd)
-
- @classmethod
- def list(cls, apiclient, **kwargs):
- """List all snapshots matching criteria"""
-
- cmd = listSnapshots.listSnapshotsCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listSnapshots(cmd))
-
-
-class Template:
- """Manage template life cycle"""
-
- def __init__(self, items):
- self.__dict__.update(items)
-
- @classmethod
- def create(cls, apiclient, services, volumeid=None,
- account=None, domainid=None, projectid=None):
- """Create template from Volume"""
- # Create template from Virtual machine and Volume ID
- cmd = createTemplate.createTemplateCmd()
- cmd.displaytext = services["displaytext"]
- cmd.name = "-".join([services["name"], random_gen()])
- if "ostypeid" in services:
- cmd.ostypeid = services["ostypeid"]
- elif "ostype" in services:
- # Find OSTypeId from Os type
- sub_cmd = listOsTypes.listOsTypesCmd()
- sub_cmd.description = services["ostype"]
- ostypes = apiclient.listOsTypes(sub_cmd)
-
- if not isinstance(ostypes, list):
- raise Exception(
- "Unable to find Ostype id with desc: %s" %
- services["ostype"])
- cmd.ostypeid = ostypes[0].id
- else:
- raise Exception(
- "Unable to find Ostype is required for creating template")
-
- cmd.isfeatured = services["isfeatured"] if "isfeatured" in services else False
- cmd.ispublic = services["ispublic"] if "ispublic" in services else False
- cmd.isextractable = services["isextractable"] if "isextractable" in services else False
- cmd.passwordenabled = services["passwordenabled"] if "passwordenabled" in services else False
-
- if volumeid:
- cmd.volumeid = volumeid
-
- if account:
- cmd.account = account
-
- if domainid:
- cmd.domainid = domainid
-
- if projectid:
- cmd.projectid = projectid
- return Template(apiclient.createTemplate(cmd).__dict__)
-
- @classmethod
- def register(cls, apiclient, services, zoneid=None,
- account=None, domainid=None):
- """Create template from URL"""
-
- # Create template from Virtual machine and Volume ID
- cmd = registerTemplate.registerTemplateCmd()
- cmd.displaytext = services["displaytext"]
- cmd.name = "-".join([services["name"], random_gen()])
- cmd.format = services["format"]
- cmd.hypervisor = apiclient.hypervisor
-
- if "ostypeid" in services:
- cmd.ostypeid = services["ostypeid"]
- elif "ostype" in services:
- # Find OSTypeId from Os type
- sub_cmd = listOsTypes.listOsTypesCmd()
- sub_cmd.description = services["ostype"]
- ostypes = apiclient.listOsTypes(sub_cmd)
-
- if not isinstance(ostypes, list):
- raise Exception(
- "Unable to find Ostype id with desc: %s" %
- services["ostype"])
- cmd.ostypeid = ostypes[0].id
- else:
- raise Exception(
- "Unable to find Ostype is required for registering template")
-
- cmd.url = services["url"]
-
- if zoneid:
- cmd.zoneid = zoneid
- else:
- cmd.zoneid = services["zoneid"]
-
- cmd.isfeatured = services["isfeatured"] if "isfeatured" in services else False
- cmd.ispublic = services["ispublic"] if "ispublic" in services else False
- cmd.isextractable = services["isextractable"] if "isextractable" in services else False
- cmd.passwordenabled = services["passwordenabled"] if "passwordenabled" in services else False
-
- if account:
- cmd.account = account
-
- if domainid:
- cmd.domainid = domainid
-
- # Register Template
- template = apiclient.registerTemplate(cmd)
-
- if isinstance(template, list):
- return Template(template[0].__dict__)
-
- @classmethod
- def extract(cls, apiclient, id, mode, zoneid=None):
- "Extract template "
-
- cmd = extractTemplate.extractTemplateCmd()
- cmd.id = id
- cmd.mode = mode
- cmd.zoneid = zoneid
-
- return apiclient.extractTemplate(cmd)
-
- @classmethod
- def create_from_snapshot(cls, apiclient, snapshot, services,
- random_name=True):
- """Create Template from snapshot"""
- # Create template from Virtual machine and Snapshot ID
- cmd = createTemplate.createTemplateCmd()
- cmd.displaytext = services["displaytext"]
- cmd.name = "-".join([
- services["name"],
- random_gen()
- ]) if random_name else services["name"]
-
- if "ostypeid" in services:
- cmd.ostypeid = services["ostypeid"]
- elif "ostype" in services:
- # Find OSTypeId from Os type
- sub_cmd = listOsTypes.listOsTypesCmd()
- sub_cmd.description = services["ostype"]
- ostypes = apiclient.listOsTypes(sub_cmd)
-
- if not isinstance(ostypes, list):
- raise Exception(
- "Unable to find Ostype id with desc: %s" %
- services["ostype"])
- cmd.ostypeid = ostypes[0].id
- else:
- raise Exception(
- "Unable to find Ostype is required for creating template")
-
- cmd.snapshotid = snapshot.id
- return Template(apiclient.createTemplate(cmd).__dict__)
-
- def delete(self, apiclient):
- """Delete Template"""
-
- cmd = deleteTemplate.deleteTemplateCmd()
- cmd.id = self.id
- apiclient.deleteTemplate(cmd)
-
- def download(self, apiclient, timeout=5, interval=60):
- """Download Template"""
- # Sleep to ensure template is in proper state before download
- time.sleep(interval)
-
- while True:
- template_response = Template.list(
- apiclient,
- id=self.id,
- zoneid=self.zoneid,
- templatefilter='self'
- )
- if isinstance(template_response, list):
-
- template = template_response[0]
- # If template is ready,
- # template.status = Download Complete
- # Downloading - x% Downloaded
- # Error - Any other string
- if template.status == 'Download Complete':
- break
-
- elif 'Downloaded' in template.status:
- time.sleep(interval)
-
- elif 'Installing' not in template.status:
- raise Exception(
- "Error in downloading template: status - %s" %
- template.status)
-
- elif timeout == 0:
- break
-
- else:
- time.sleep(interval)
- timeout = timeout - 1
- return
-
- def updatePermissions(self, apiclient, **kwargs):
- """Updates the template permissions"""
-
- cmd = updateTemplatePermissions.updateTemplatePermissionsCmd()
- cmd.id = self.id
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.updateTemplatePermissions(cmd))
-
- @classmethod
- def list(cls, apiclient, **kwargs):
- """List all templates matching criteria"""
-
- cmd = listTemplates.listTemplatesCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listTemplates(cmd))
-
-
-class Iso:
- """Manage ISO life cycle"""
-
- def __init__(self, items):
- self.__dict__.update(items)
-
- @classmethod
- def create(cls, apiclient, services, account=None, domainid=None,
- projectid=None):
- """Create an ISO"""
- # Create ISO from URL
- cmd = registerIso.registerIsoCmd()
- cmd.displaytext = services["displaytext"]
- cmd.name = services["name"]
- if "ostypeid" in services:
- cmd.ostypeid = services["ostypeid"]
- elif "ostype" in services:
- # Find OSTypeId from Os type
- sub_cmd = listOsTypes.listOsTypesCmd()
- sub_cmd.description = services["ostype"]
- ostypes = apiclient.listOsTypes(sub_cmd)
-
- if not isinstance(ostypes, list):
- raise Exception(
- "Unable to find Ostype id with desc: %s" %
- services["ostype"])
- cmd.ostypeid = ostypes[0].id
- else:
- raise Exception(
- "Unable to find Ostype is required for creating ISO")
-
- cmd.url = services["url"]
- cmd.zoneid = services["zoneid"]
-
- if "isextractable" in services:
- cmd.isextractable = services["isextractable"]
- if "isfeatured" in services:
- cmd.isfeatured = services["isfeatured"]
- if "ispublic" in services:
- cmd.ispublic = services["ispublic"]
-
- if account:
- cmd.account = account
- if domainid:
- cmd.domainid = domainid
- if projectid:
- cmd.projectid = projectid
- # Register ISO
- iso = apiclient.registerIso(cmd)
-
- if iso:
- return Iso(iso[0].__dict__)
-
- def delete(self, apiclient):
- """Delete an ISO"""
- cmd = deleteIso.deleteIsoCmd()
- cmd.id = self.id
- apiclient.deleteIso(cmd)
- return
-
- def download(self, apiclient, timeout=5, interval=60):
- """Download an ISO"""
- # Ensuring ISO is successfully downloaded
- while True:
- time.sleep(interval)
-
- cmd = listIsos.listIsosCmd()
- cmd.id = self.id
- iso_response = apiclient.listIsos(cmd)
-
- if isinstance(iso_response, list):
- response = iso_response[0]
- # Again initialize timeout to avoid listISO failure
- timeout = 5
- # Check whether download is in progress(for Ex:10% Downloaded)
- # or ISO is 'Successfully Installed'
- if response.status == 'Successfully Installed':
- return
- elif 'Downloaded' not in response.status and \
- 'Installing' not in response.status:
- raise Exception(
- "Error In Downloading ISO: ISO Status - %s" %
- response.status)
-
- elif timeout == 0:
- raise Exception("ISO download Timeout Exception")
- else:
- timeout = timeout - 1
- return
-
- @classmethod
- def list(cls, apiclient, **kwargs):
- """Lists all available ISO files."""
-
- cmd = listIsos.listIsosCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listIsos(cmd))
-
-
-class PublicIPAddress:
- """Manage Public IP Addresses"""
-
- def __init__(self, items):
- self.__dict__.update(items)
-
- @classmethod
- def create(cls, apiclient, accountid=None, zoneid=None, domainid=None, services=None,
- networkid=None, projectid=None, vpcid=None, isportable=False):
- """Associate Public IP address"""
- cmd = associateIpAddress.associateIpAddressCmd()
-
- if accountid:
- cmd.account = accountid
- elif "account" in services:
- cmd.account = services["account"]
-
- if zoneid:
- cmd.zoneid = zoneid
- elif "zoneid" in services:
- cmd.zoneid = services["zoneid"]
-
- if domainid:
- cmd.domainid = domainid
- elif "domainid" in services:
- cmd.domainid = services["domainid"]
-
- if isportable:
- cmd.isportable = isportable
-
- if networkid:
- cmd.networkid = networkid
-
- if projectid:
- cmd.projectid = projectid
-
- if vpcid:
- cmd.vpcid = vpcid
- return PublicIPAddress(apiclient.associateIpAddress(cmd).__dict__)
-
- def delete(self, apiclient):
- """Dissociate Public IP address"""
- cmd = disassociateIpAddress.disassociateIpAddressCmd()
- cmd.id = self.ipaddress.id
- apiclient.disassociateIpAddress(cmd)
- return
-
- @classmethod
- def list(cls, apiclient, **kwargs):
- """List all Public IPs matching criteria"""
-
- cmd = listPublicIpAddresses.listPublicIpAddressesCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listPublicIpAddresses(cmd))
-
-
-class NATRule:
- """Manage port forwarding rule"""
-
- def __init__(self, items):
- self.__dict__.update(items)
-
- @classmethod
- def create(cls, apiclient, virtual_machine, services, ipaddressid=None,
- projectid=None, openfirewall=False, networkid=None, vpcid=None):
- """Create Port forwarding rule"""
- cmd = createPortForwardingRule.createPortForwardingRuleCmd()
-
- if ipaddressid:
- cmd.ipaddressid = ipaddressid
- elif "ipaddressid" in services:
- cmd.ipaddressid = services["ipaddressid"]
-
- cmd.privateport = services["privateport"]
- cmd.publicport = services["publicport"]
- if "privateendport" in services:
- cmd.privateendport = services["privateendport"]
- if "publicendport" in services:
- cmd.publicendport = services["publicendport"]
- cmd.protocol = services["protocol"]
- cmd.virtualmachineid = virtual_machine.id
-
- if projectid:
- cmd.projectid = projectid
-
- if openfirewall:
- cmd.openfirewall = True
-
- if networkid:
- cmd.networkid = networkid
-
- if vpcid:
- cmd.vpcid = vpcid
- return NATRule(apiclient.createPortForwardingRule(cmd).__dict__)
-
- def delete(self, apiclient):
- """Delete port forwarding"""
- cmd = deletePortForwardingRule.deletePortForwardingRuleCmd()
- cmd.id = self.id
- apiclient.deletePortForwardingRule(cmd)
- return
-
- @classmethod
- def list(cls, apiclient, **kwargs):
- """List all NAT rules matching criteria"""
-
- cmd = listPortForwardingRules.listPortForwardingRulesCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listPortForwardingRules(cmd))
-
-
-class StaticNATRule:
- """Manage Static NAT rule"""
-
- def __init__(self, items):
- self.__dict__.update(items)
-
- @classmethod
- def create(cls, apiclient, services, ipaddressid=None, networkid=None, vpcid=None):
- """Creates static ip forwarding rule"""
-
- cmd = createFirewallRule.createFirewallRuleCmd()
- cmd.protocol = services["protocol"]
- cmd.startport = services["startport"]
-
- if "endport" in services:
- cmd.endport = services["endport"]
-
- if "cidrlist" in services:
- cmd.cidrlist = services["cidrlist"]
-
- if ipaddressid:
- cmd.ipaddressid = ipaddressid
- elif "ipaddressid" in services:
- cmd.ipaddressid = services["ipaddressid"]
-
- if networkid:
- cmd.networkid = networkid
-
- if vpcid:
- cmd.vpcid = vpcid
- return StaticNATRule(apiclient.createFirewallRule(cmd).__dict__)
-
- def delete(self, apiclient):
- """Delete IP forwarding rule"""
- cmd = deleteIpForwardingRule.deleteIpForwardingRuleCmd()
- cmd.id = self.id
- apiclient.deleteIpForwardingRule(cmd)
- return
-
- @classmethod
- def list(cls, apiclient, **kwargs):
- """List all IP forwarding rules matching criteria"""
-
- cmd = listIpForwardingRules.listIpForwardingRulesCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listIpForwardingRules(cmd))
-
- @classmethod
- def enable(cls, apiclient, ipaddressid, virtualmachineid, networkid=None):
- """Enables Static NAT rule"""
-
- cmd = enableStaticNat.enableStaticNatCmd()
- cmd.ipaddressid = ipaddressid
- cmd.virtualmachineid = virtualmachineid
- if networkid:
- cmd.networkid = networkid
- apiclient.enableStaticNat(cmd)
- return
-
- @classmethod
- def disable(cls, apiclient, ipaddressid, virtualmachineid):
- """Disables Static NAT rule"""
-
- cmd = disableStaticNat.disableStaticNatCmd()
- cmd.ipaddressid = ipaddressid
- apiclient.disableStaticNat(cmd)
- return
-
-
-class EgressFireWallRule:
- """Manage Egress Firewall rule"""
-
- def __init__(self, items):
- self.__dict__.update(items)
-
- @classmethod
- def create(cls, apiclient, networkid, protocol, cidrlist=None,
- startport=None, endport=None):
- """Create Egress Firewall Rule"""
- cmd = createEgressFirewallRule.createEgressFirewallRuleCmd()
- cmd.networkid = networkid
- cmd.protocol = protocol
- if cidrlist:
- cmd.cidrlist = cidrlist
- if startport:
- cmd.startport = startport
- if endport:
- cmd.endport = endport
-
- return EgressFireWallRule(apiclient.createEgressFirewallRule(cmd).__dict__)
-
- def delete(self, apiclient):
- """Delete Egress Firewall rule"""
- cmd = deleteEgressFirewallRule.deleteEgressFirewallRuleCmd()
- cmd.id = self.id
- apiclient.deleteEgressFirewallRule(cmd)
- return
-
- @classmethod
- def list(cls, apiclient, **kwargs):
- """List all Egress Firewall Rules matching criteria"""
-
- cmd = listEgressFirewallRules.listEgressFirewallRulesCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listEgressFirewallRules(cmd))
-
-
-
-class FireWallRule:
- """Manage Firewall rule"""
-
- def __init__(self, items):
- self.__dict__.update(items)
-
- @classmethod
- def create(cls, apiclient, ipaddressid, protocol, cidrlist=None,
- startport=None, endport=None, projectid=None, vpcid=None):
- """Create Firewall Rule"""
- cmd = createFirewallRule.createFirewallRuleCmd()
- cmd.ipaddressid = ipaddressid
- cmd.protocol = protocol
- if cidrlist:
- cmd.cidrlist = cidrlist
- if startport:
- cmd.startport = startport
- if endport:
- cmd.endport = endport
-
- if projectid:
- cmd.projectid = projectid
-
- if vpcid:
- cmd.vpcid = vpcid
-
- return FireWallRule(apiclient.createFirewallRule(cmd).__dict__)
-
- def delete(self, apiclient):
- """Delete Firewall rule"""
- cmd = deleteFirewallRule.deleteFirewallRuleCmd()
- cmd.id = self.id
- apiclient.deleteFirewallRule(cmd)
- return
-
- @classmethod
- def list(cls, apiclient, **kwargs):
- """List all Firewall Rules matching criteria"""
-
- cmd = listFirewallRules.listFirewallRulesCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listFirewallRules(cmd))
-
-
-class ServiceOffering:
- """Manage service offerings cycle"""
-
- def __init__(self, items):
- self.__dict__.update(items)
-
- @classmethod
- def create(cls, apiclient, services, domainid=None, **kwargs):
- """Create Service offering"""
- cmd = createServiceOffering.createServiceOfferingCmd()
- cmd.cpunumber = services["cpunumber"]
- cmd.cpuspeed = services["cpuspeed"]
- cmd.displaytext = services["displaytext"]
- cmd.memory = services["memory"]
- cmd.name = services["name"]
- if "storagetype" in services:
- cmd.storagetype = services["storagetype"]
-
- if "systemvmtype" in services:
- cmd.systemvmtype = services['systemvmtype']
-
- if "issystem" in services:
- cmd.issystem = services['issystem']
-
- if "tags" in services:
- cmd.tags = services["tags"]
-
- if "hosttags" in services:
- cmd.hosttags = services["hosttags"]
-
- if "deploymentplanner" in services:
- cmd.deploymentplanner = services["deploymentplanner"]
-
- if "serviceofferingdetails" in services:
- cmd.serviceofferingdetails.append({services['serviceofferingdetails']})
-
- if "isvolatile" in services:
- cmd.isvolatile = services["isvolatile"]
-
- if "offerha" in services:
- cmd.offerha = services["offerha"]
-
- # Service Offering private to that domain
- if domainid:
- cmd.domainid = domainid
-
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return ServiceOffering(apiclient.createServiceOffering(cmd).__dict__)
-
- def delete(self, apiclient):
- """Delete Service offering"""
- cmd = deleteServiceOffering.deleteServiceOfferingCmd()
- cmd.id = self.id
- apiclient.deleteServiceOffering(cmd)
- return
-
- @classmethod
- def list(cls, apiclient, **kwargs):
- """Lists all available service offerings."""
-
- cmd = listServiceOfferings.listServiceOfferingsCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listServiceOfferings(cmd))
-
-
-class DiskOffering:
- """Manage disk offerings cycle"""
-
- def __init__(self, items):
- self.__dict__.update(items)
-
- @classmethod
- def create(cls, apiclient, services, custom=False, domainid=None):
- """Create Disk offering"""
- cmd = createDiskOffering.createDiskOfferingCmd()
- cmd.displaytext = services["displaytext"]
- cmd.name = services["name"]
- if custom:
- cmd.customized = True
- else:
- cmd.disksize = services["disksize"]
-
- if domainid:
- cmd.domainid = domainid
-
- if "storagetype" in services:
- cmd.storagetype = services["storagetype"]
-
- return DiskOffering(apiclient.createDiskOffering(cmd).__dict__)
-
- def delete(self, apiclient):
- """Delete Disk offering"""
- cmd = deleteDiskOffering.deleteDiskOfferingCmd()
- cmd.id = self.id
- apiclient.deleteDiskOffering(cmd)
- return
-
- @classmethod
- def list(cls, apiclient, **kwargs):
- """Lists all available disk offerings."""
-
- cmd = listDiskOfferings.listDiskOfferingsCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listDiskOfferings(cmd))
-
-
-class NetworkOffering:
- """Manage network offerings cycle"""
-
- def __init__(self, items):
- self.__dict__.update(items)
-
- @classmethod
- def create(cls, apiclient, services, **kwargs):
- """Create network offering"""
-
- cmd = createNetworkOffering.createNetworkOfferingCmd()
- cmd.displaytext = "-".join([services["displaytext"], random_gen()])
- cmd.name = "-".join([services["name"], random_gen()])
- cmd.guestiptype = services["guestiptype"]
- cmd.supportedservices = ''
- if "supportedservices" in services:
- cmd.supportedservices = services["supportedservices"]
- cmd.traffictype = services["traffictype"]
-
- if "useVpc" in services:
- cmd.useVpc = services["useVpc"]
- cmd.serviceproviderlist = []
- if "serviceProviderList" in services:
- for service, provider in services["serviceProviderList"].items():
- cmd.serviceproviderlist.append({
- 'service': service,
- 'provider': provider
- })
- if "serviceCapabilityList" in services:
- cmd.servicecapabilitylist = []
- for service, capability in services["serviceCapabilityList"].items():
- for ctype, value in capability.items():
- cmd.servicecapabilitylist.append({
- 'service': service,
- 'capabilitytype': ctype,
- 'capabilityvalue': value
- })
- if "specifyVlan" in services:
- cmd.specifyVlan = services["specifyVlan"]
- if "specifyIpRanges" in services:
- cmd.specifyIpRanges = services["specifyIpRanges"]
- if "ispersistent" in services:
- cmd.ispersistent = services["ispersistent"]
- if "egress_policy" in services:
- cmd.egressdefaultpolicy = services["egress_policy"]
-
- cmd.availability = 'Optional'
-
- [setattr(cmd, k, v) for k, v in kwargs.items()]
-
- return NetworkOffering(apiclient.createNetworkOffering(cmd).__dict__)
-
- def delete(self, apiclient):
- """Delete network offering"""
- cmd = deleteNetworkOffering.deleteNetworkOfferingCmd()
- cmd.id = self.id
- apiclient.deleteNetworkOffering(cmd)
- return
-
- def update(self, apiclient, **kwargs):
- """Lists all available network offerings."""
-
- cmd = updateNetworkOffering.updateNetworkOfferingCmd()
- cmd.id = self.id
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.updateNetworkOffering(cmd))
-
- @classmethod
- def list(cls, apiclient, **kwargs):
- """Lists all available network offerings."""
-
- cmd = listNetworkOfferings.listNetworkOfferingsCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listNetworkOfferings(cmd))
-
-
-class SnapshotPolicy:
- """Manage snapshot policies"""
-
- def __init__(self, items):
- self.__dict__.update(items)
-
- @classmethod
- def create(cls, apiclient, volumeid, services):
- """Create Snapshot policy"""
- cmd = createSnapshotPolicy.createSnapshotPolicyCmd()
- cmd.intervaltype = services["intervaltype"]
- cmd.maxsnaps = services["maxsnaps"]
- cmd.schedule = services["schedule"]
- cmd.timezone = services["timezone"]
- cmd.volumeid = volumeid
- return SnapshotPolicy(apiclient.createSnapshotPolicy(cmd).__dict__)
-
- def delete(self, apiclient):
- """Delete Snapshot policy"""
- cmd = deleteSnapshotPolicies.deleteSnapshotPoliciesCmd()
- cmd.id = self.id
- apiclient.deleteSnapshotPolicies(cmd)
- return
-
- @classmethod
- def list(cls, apiclient, **kwargs):
- """Lists snapshot policies."""
-
- cmd = listSnapshotPolicies.listSnapshotPoliciesCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listSnapshotPolicies(cmd))
-
-
-class LoadBalancerRule:
- """Manage Load Balancer rule"""
-
- def __init__(self, items):
- self.__dict__.update(items)
-
- @classmethod
- def create(cls, apiclient, services, ipaddressid=None, accountid=None,
- networkid=None, vpcid=None, projectid=None, domainid=None):
- """Create Load balancing Rule"""
-
- cmd = createLoadBalancerRule.createLoadBalancerRuleCmd()
-
- if ipaddressid:
- cmd.publicipid = ipaddressid
- elif "ipaddressid" in services:
- cmd.publicipid = services["ipaddressid"]
-
- if accountid:
- cmd.account = accountid
- elif "account" in services:
- cmd.account = services["account"]
-
- if domainid:
- cmd.domainid = domainid
-
- if vpcid:
- cmd.vpcid = vpcid
- cmd.name = services["name"]
- cmd.algorithm = services["alg"]
- cmd.privateport = services["privateport"]
- cmd.publicport = services["publicport"]
-
- if "openfirewall" in services:
- cmd.openfirewall = services["openfirewall"]
-
- if projectid:
- cmd.projectid = projectid
-
- if networkid:
- cmd.networkid = networkid
- return LoadBalancerRule(apiclient.createLoadBalancerRule(cmd).__dict__)
-
- def delete(self, apiclient):
- """Delete load balancing rule"""
- cmd = deleteLoadBalancerRule.deleteLoadBalancerRuleCmd()
- cmd.id = self.id
- apiclient.deleteLoadBalancerRule(cmd)
- return
-
- def assign(self, apiclient, vms):
- """Assign virtual machines to load balancing rule"""
- cmd = assignToLoadBalancerRule.assignToLoadBalancerRuleCmd()
- cmd.id = self.id
- cmd.virtualmachineids = [str(vm.id) for vm in vms]
- apiclient.assignToLoadBalancerRule(cmd)
- return
-
- def remove(self, apiclient, vms):
- """Remove virtual machines from load balancing rule"""
- cmd = removeFromLoadBalancerRule.removeFromLoadBalancerRuleCmd()
- cmd.id = self.id
- cmd.virtualmachineids = [str(vm.id) for vm in vms]
- apiclient.removeFromLoadBalancerRule(cmd)
- return
-
- def update(self, apiclient, algorithm=None, description=None, name=None, **kwargs):
- """Updates the load balancing rule"""
- cmd = updateLoadBalancerRule.updateLoadBalancerRuleCmd()
- cmd.id = self.id
- if algorithm:
- cmd.algorithm = algorithm
- if description:
- cmd.description = description
- if name:
- cmd.name = name
-
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return apiclient.updateLoadBalancerRule(cmd)
-
- def createSticky(self, apiclient, methodname, name, description=None, param=None):
- """Creates a sticky policy for the LB rule"""
-
- cmd = createLBStickinessPolicy.createLBStickinessPolicyCmd()
- cmd.lbruleid = self.id
- cmd.methodname = methodname
- cmd.name = name
- if description:
- cmd.description = description
- if param:
- cmd.param = []
- for name, value in param.items():
- cmd.param.append({'name': name, 'value': value})
- return apiclient.createLBStickinessPolicy(cmd)
-
- def deleteSticky(self, apiclient, id):
- """Deletes stickyness policy"""
-
- cmd = deleteLBStickinessPolicy.deleteLBStickinessPolicyCmd()
- cmd.id = id
- return apiclient.deleteLBStickinessPolicy(cmd)
-
- @classmethod
- def listStickyPolicies(cls, apiclient, lbruleid, **kwargs):
- """Lists stickiness policies for load balancing rule"""
-
- cmd = listLBStickinessPolicies.listLBStickinessPoliciesCmd()
- cmd.lbruleid = lbruleid
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return apiclient.listLBStickinessPolicies(cmd)
-
- @classmethod
- def list(cls, apiclient, **kwargs):
- """List all Load balancing rules matching criteria"""
-
- cmd = listLoadBalancerRules.listLoadBalancerRulesCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listLoadBalancerRules(cmd))
-
-
-class Cluster:
- """Manage Cluster life cycle"""
-
- def __init__(self, items):
- self.__dict__.update(items)
-
- @classmethod
- def create(cls, apiclient, services, zoneid=None, podid=None):
- """Create Cluster"""
- cmd = addCluster.addClusterCmd()
- cmd.clustertype = services["clustertype"]
- cmd.hypervisor = apiclient.hypervisor
-
- if zoneid:
- cmd.zoneid = zoneid
- else:
- cmd.zoneid = services["zoneid"]
-
- if podid:
- cmd.podid = podid
- else:
- cmd.podid = services["podid"]
-
- if "username" in services:
- cmd.username = services["username"]
- if "password" in services:
- cmd.password = services["password"]
- if "url" in services:
- cmd.url = services["url"]
- if "clustername" in services:
- cmd.clustername = services["clustername"]
-
- return Cluster(apiclient.addCluster(cmd)[0].__dict__)
-
- def delete(self, apiclient):
- """Delete Cluster"""
- cmd = deleteCluster.deleteClusterCmd()
- cmd.id = self.id
- apiclient.deleteCluster(cmd)
- return
-
- @classmethod
- def list(cls, apiclient, **kwargs):
- """List all Clusters matching criteria"""
-
- cmd = listClusters.listClustersCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listClusters(cmd))
-
-
-class Host:
- """Manage Host life cycle"""
-
- def __init__(self, items):
- self.__dict__.update(items)
-
- @classmethod
- def create(cls, apiclient, cluster, services, zoneid=None, podid=None):
- """Create Host in cluster"""
-
- cmd = addHost.addHostCmd()
- cmd.hypervisor = apiclient.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"]
-
- # Add host
- host = apiclient.addHost(cmd)
-
- if isinstance(host, list):
- return Host(host[0].__dict__)
-
- def delete(self, apiclient):
- """Delete Host"""
- # Host must be in maintenance mode before deletion
- cmd = prepareHostForMaintenance.prepareHostForMaintenanceCmd()
- cmd.id = self.id
- apiclient.prepareHostForMaintenance(cmd)
- time.sleep(30)
-
- cmd = deleteHost.deleteHostCmd()
- cmd.id = self.id
- apiclient.deleteHost(cmd)
- return
-
- def enableMaintenance(self, apiclient):
- """enables maintenance mode Host"""
-
- cmd = prepareHostForMaintenance.prepareHostForMaintenanceCmd()
- cmd.id = self.id
- return apiclient.prepareHostForMaintenance(cmd)
-
- @classmethod
- def enableMaintenance(cls, apiclient, id):
- """enables maintenance mode Host"""
-
- cmd = prepareHostForMaintenance.prepareHostForMaintenanceCmd()
- cmd.id = id
- return apiclient.prepareHostForMaintenance(cmd)
-
- def cancelMaintenance(self, apiclient):
- """Cancels maintenance mode Host"""
-
- cmd = cancelHostMaintenance.cancelHostMaintenanceCmd()
- cmd.id = self.id
- return apiclient.cancelHostMaintenance(cmd)
-
- @classmethod
- def cancelMaintenance(cls, apiclient, id):
- """Cancels maintenance mode Host"""
-
- cmd = cancelHostMaintenance.cancelHostMaintenanceCmd()
- cmd.id = id
- return apiclient.cancelHostMaintenance(cmd)
-
- @classmethod
- def list(cls, apiclient, **kwargs):
- """List all Hosts matching criteria"""
-
- cmd = listHosts.listHostsCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listHosts(cmd))
-
- @classmethod
- def listForMigration(cls, apiclient, **kwargs):
- """List all Hosts for migration matching criteria"""
-
- cmd = findHostsForMigration.findHostsForMigrationCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.findHostsForMigration(cmd))
-
- @classmethod
- def update(cls, apiclient, **kwargs):
- """Update host information"""
-
- cmd = updateHost.updateHostCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.updateHost(cmd))
-
-
-class StoragePool:
- """Manage Storage pools (Primary Storage)"""
-
- def __init__(self, items):
- self.__dict__.update(items)
-
- @classmethod
- def create(cls, apiclient, services, clusterid=None,
- zoneid=None, podid=None):
- """Create Storage pool (Primary Storage)"""
-
- cmd = createStoragePool.createStoragePoolCmd()
- cmd.name = services["name"]
-
- if podid:
- cmd.podid = podid
- else:
- cmd.podid = services["podid"]
-
- cmd.url = services["url"]
- if clusterid:
- cmd.clusterid = clusterid
- elif "clusterid" in services:
- cmd.clusterid = services["clusterid"]
-
- if zoneid:
- cmd.zoneid = zoneid
- else:
- cmd.zoneid = services["zoneid"]
-
- return StoragePool(apiclient.createStoragePool(cmd).__dict__)
-
- def delete(self, apiclient):
- """Delete Storage pool (Primary Storage)"""
-
- # Storage pool must be in maintenance mode before deletion
- cmd = enableStorageMaintenance.enableStorageMaintenanceCmd()
- cmd.id = self.id
- apiclient.enableStorageMaintenance(cmd)
- time.sleep(30)
- cmd = deleteStoragePool.deleteStoragePoolCmd()
- cmd.id = self.id
- apiclient.deleteStoragePool(cmd)
- return
-
- def enableMaintenance(self, apiclient):
- """enables maintenance mode Storage pool"""
-
- cmd = enableStorageMaintenance.enableStorageMaintenanceCmd()
- cmd.id = self.id
- return apiclient.enableStorageMaintenance(cmd)
-
- @classmethod
- def list(cls, apiclient, **kwargs):
- """List all storage pools matching criteria"""
-
- cmd = listStoragePools.listStoragePoolsCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listStoragePools(cmd))
-
- @classmethod
- def listForMigration(cls, apiclient, **kwargs):
- """List all storage pools for migration matching criteria"""
-
- cmd = findStoragePoolsForMigration.findStoragePoolsForMigrationCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.findStoragePoolsForMigration(cmd))
-
-class Network:
- """Manage Network pools"""
-
- def __init__(self, items):
- self.__dict__.update(items)
-
- @classmethod
- def create(cls, apiclient, services, accountid=None, domainid=None,
- networkofferingid=None, projectid=None,
- subdomainaccess=None, zoneid=None,
- gateway=None, netmask=None, vpcid=None, aclid=None):
- """Create Network for account"""
- cmd = createNetwork.createNetworkCmd()
- cmd.name = services["name"]
- cmd.displaytext = services["displaytext"]
-
- if networkofferingid:
- cmd.networkofferingid = networkofferingid
- elif "networkoffering" in services:
- cmd.networkofferingid = services["networkoffering"]
-
- if zoneid:
- cmd.zoneid = zoneid
- elif "zoneid" in services:
- cmd.zoneid = services["zoneid"]
-
- if subdomainaccess is not None:
- cmd.subdomainaccess = subdomainaccess
-
- if gateway:
- cmd.gateway = gateway
- elif "gateway" in services:
- cmd.gateway = services["gateway"]
- if netmask:
- cmd.netmask = netmask
- elif "netmask" in services:
- cmd.netmask = services["netmask"]
- if "startip" in services:
- cmd.startip = services["startip"]
- if "endip" in services:
- cmd.endip = services["endip"]
- if "vlan" in services:
- cmd.vlan = services["vlan"]
- if "acltype" in services:
- cmd.acltype = services["acltype"]
-
- if accountid:
- cmd.account = accountid
- if domainid:
- cmd.domainid = domainid
- if projectid:
- cmd.projectid = projectid
- if vpcid:
- cmd.vpcid = vpcid
- if aclid:
- cmd.aclid = aclid
- return Network(apiclient.createNetwork(cmd).__dict__)
-
- def delete(self, apiclient):
- """Delete Account"""
-
- cmd = deleteNetwork.deleteNetworkCmd()
- cmd.id = self.id
- apiclient.deleteNetwork(cmd)
-
- def update(self, apiclient, **kwargs):
- """Updates network with parameters passed"""
-
- cmd = updateNetwork.updateNetworkCmd()
- cmd.id = self.id
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.updateNetwork(cmd))
-
- def restart(self, apiclient, cleanup=None):
- """Restarts the network"""
-
- cmd = restartNetwork.restartNetworkCmd()
- cmd.id = self.id
- if cleanup:
- cmd.cleanup = cleanup
- return(apiclient.restartNetwork(cmd))
-
- @classmethod
- def list(cls, apiclient, **kwargs):
- """List all Networks matching criteria"""
-
- cmd = listNetworks.listNetworksCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listNetworks(cmd))
-
-
-class NetworkACL:
- """Manage Network ACL lifecycle"""
-
- def __init__(self, items):
- self.__dict__.update(items)
-
- @classmethod
- def create(cls, apiclient, services, networkid=None, protocol=None,
- number=None, aclid=None, action='Allow', traffictype=None, cidrlist=[]):
- """Create network ACL rules(Ingress/Egress)"""
-
- cmd = createNetworkACL.createNetworkACLCmd()
- if "networkid" in services:
- cmd.networkid = services["networkid"]
- elif networkid:
- cmd.networkid = networkid
-
- if "protocol" in services:
- cmd.protocol = services["protocol"]
- if services["protocol"] == 'ICMP':
- cmd.icmptype = -1
- cmd.icmpcode = -1
- elif protocol:
- cmd.protocol = protocol
-
- if "startport" in services:
- cmd.startport = services["startport"]
- if "endport" in services:
- cmd.endport = services["endport"]
-
- if "cidrlist" in services:
- cmd.cidrlist = services["cidrlist"]
- elif cidrlist:
- cmd.cidrlist = cidrlist
-
- if "traffictype" in services:
- cmd.traffictype = services["traffictype"]
- elif traffictype:
- cmd.traffictype = traffictype
-
- if "action" in services:
- cmd.action = services["action"]
- elif action:
- cmd.action = action
-
- if "number" in services:
- cmd.number = services["number"]
- elif number:
- cmd.number = number
-
- if "aclid" in services:
- cmd.aclid = services["aclid"]
- elif aclid:
- cmd.aclid = aclid
-
- # Defaulted to Ingress
- return NetworkACL(apiclient.createNetworkACL(cmd).__dict__)
-
- def delete(self, apiclient):
- """Delete network acl"""
-
- cmd = deleteNetworkACL.deleteNetworkACLCmd()
- cmd.id = self.id
- return apiclient.deleteNetworkACL(cmd)
-
- @classmethod
- def list(cls, apiclient, **kwargs):
- """List Network ACLs"""
-
- cmd = listNetworkACLs.listNetworkACLsCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listNetworkACLs(cmd))
-
-
-class NetworkACLList:
- """Manage Network ACL lists lifecycle"""
-
- def __init__(self, items):
- self.__dict__.update(items)
-
- @classmethod
- def create(cls, apiclient, services, name=None, description=None, vpcid=None):
- """Create network ACL container list"""
-
- cmd = createNetworkACLList.createNetworkACLListCmd()
- if "name" in services:
- cmd.name = services["name"]
- elif name:
- cmd.name = name
-
- if "description" in services:
- cmd.description = services["description"]
- elif description:
- cmd.description = description
-
- if "vpcid" in services:
- cmd.vpcid = services["vpcid"]
- elif vpcid:
- cmd.vpcid = vpcid
-
- return NetworkACLList(apiclient.createNetworkACLList(cmd).__dict__)
-
- def delete(self, apiclient):
- """Delete network acl list"""
-
- cmd = deleteNetworkACLList.deleteNetworkACLListCmd()
- cmd.id = self.id
- return apiclient.deleteNetworkACLList(cmd)
-
- @classmethod
- def list(cls, apiclient, **kwargs):
- """List Network ACL lists"""
-
- cmd = listNetworkACLLists.listNetworkACLListsCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listNetworkACLLists(cmd))
-
-
-class Vpn:
- """Manage VPN life cycle"""
-
- def __init__(self, items):
- self.__dict__.update(items)
-
- @classmethod
- def create(cls, apiclient, publicipid, account=None, domainid=None,
- projectid=None, networkid=None, vpcid=None):
- """Create VPN for Public IP address"""
- cmd = createRemoteAccessVpn.createRemoteAccessVpnCmd()
- cmd.publicipid = publicipid
- if account:
- cmd.account = account
- if domainid:
- cmd.domainid = domainid
- if projectid:
- cmd.projectid = projectid
- if networkid:
- cmd.networkid = networkid
- if vpcid:
- cmd.vpcid = vpcid
- return Vpn(apiclient.createRemoteAccessVpn(cmd).__dict__)
-
- def delete(self, apiclient):
- """Delete remote VPN access"""
-
- cmd = deleteRemoteAccessVpn.deleteRemoteAccessVpnCmd()
- cmd.publicipid = self.publicipid
- apiclient.deleteRemoteAccessVpn(cmd)
-
- @classmethod
- def list(cls, apiclient, **kwargs):
- """List all VPN matching criteria"""
-
- cmd = listRemoteAccessVpns.listRemoteAccessVpnsCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listRemoteAccessVpns(cmd))
-
-
-class VpnUser:
- """Manage VPN user"""
-
- def __init__(self, items):
- self.__dict__.update(items)
-
- @classmethod
- def create(cls, apiclient, username, password, account=None, domainid=None,
- projectid=None, rand_name=True):
- """Create VPN user"""
- cmd = addVpnUser.addVpnUserCmd()
- cmd.username = "-".join([username,
- random_gen()]) if rand_name else username
- cmd.password = password
-
- if account:
- cmd.account = account
- if domainid:
- cmd.domainid = domainid
- if projectid:
- cmd.projectid = projectid
- return VpnUser(apiclient.addVpnUser(cmd).__dict__)
-
- def delete(self, apiclient, projectid=None):
- """Remove VPN user"""
-
- cmd = removeVpnUser.removeVpnUserCmd()
- cmd.username = self.username
- if projectid:
- cmd.projectid = projectid
- else:
- cmd.account = self.account
- cmd.domainid = self.domainid
- apiclient.removeVpnUser(cmd)
-
- @classmethod
- def list(cls, apiclient, **kwargs):
- """List all VPN Users matching criteria"""
-
- cmd = listVpnUsers.listVpnUsersCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listVpnUsers(cmd))
-
-
-class Zone:
- """Manage Zone"""
-
- def __init__(self, items):
- self.__dict__.update(items)
-
- @classmethod
- def create(cls, apiclient, services, domainid=None):
- """Create zone"""
- cmd = createZone.createZoneCmd()
- cmd.dns1 = services["dns1"]
- cmd.internaldns1 = services["internaldns1"]
- cmd.name = services["name"]
- cmd.networktype = services["networktype"]
-
- if "dns2" in services:
- cmd.dns2 = services["dns2"]
- if "internaldns2" in services:
- cmd.internaldns2 = services["internaldns2"]
- if domainid:
- cmd.domainid = domainid
- if "securitygroupenabled" in services:
- cmd.securitygroupenabled = services["securitygroupenabled"]
-
- return Zone(apiclient.createZone(cmd).__dict__)
-
- def delete(self, apiclient):
- """Delete Zone"""
-
- cmd = deleteZone.deleteZoneCmd()
- cmd.id = self.id
- apiclient.deleteZone(cmd)
-
- def update(self, apiclient, **kwargs):
- """Update the zone"""
-
- cmd = updateZone.updateZoneCmd()
- cmd.id = self.id
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return apiclient.updateZone(cmd)
-
- @classmethod
- def list(cls, apiclient, **kwargs):
- """List all Zones matching criteria"""
-
- cmd = listZones.listZonesCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listZones(cmd))
-
-
-class Pod:
- """Manage Pod"""
-
- def __init__(self, items):
- self.__dict__.update(items)
-
- @classmethod
- def create(cls, apiclient, services):
- """Create Pod"""
- cmd = createPod.createPodCmd()
- cmd.gateway = services["gateway"]
- cmd.netmask = services["netmask"]
- cmd.name = services["name"]
- cmd.startip = services["startip"]
- cmd.endip = services["endip"]
- cmd.zoneid = services["zoneid"]
-
- return Pod(apiclient.createPod(cmd).__dict__)
-
- def delete(self, apiclient):
- """Delete Pod"""
-
- cmd = deletePod.deletePodCmd()
- cmd.id = self.id
- apiclient.deletePod(cmd)
-
- @classmethod
- def list(cls, apiclient, **kwargs):
- "Returns a default pod for specified zone"
-
- cmd = listPods.listPodsCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return apiclient.listPods(cmd)
-
-
-class PublicIpRange:
- """Manage VlanIpRange"""
-
- def __init__(self, items):
- self.__dict__.update(items)
-
- @classmethod
- def create(cls, apiclient, services):
- """Create VlanIpRange"""
-
- cmd = createVlanIpRange.createVlanIpRangeCmd()
- cmd.gateway = services["gateway"]
- cmd.netmask = services["netmask"]
- cmd.forvirtualnetwork = services["forvirtualnetwork"]
- cmd.startip = services["startip"]
- cmd.endip = services["endip"]
- cmd.zoneid = services["zoneid"]
- cmd.podid = services["podid"]
- cmd.vlan = services["vlan"]
-
- return PublicIpRange(apiclient.createVlanIpRange(cmd).__dict__)
-
- def delete(self, apiclient):
- """Delete VlanIpRange"""
-
- cmd = deleteVlanIpRange.deleteVlanIpRangeCmd()
- cmd.id = self.vlan.id
- apiclient.deleteVlanIpRange(cmd)
-
- @classmethod
- def list(cls, apiclient, **kwargs):
- """Lists all VLAN IP ranges."""
-
- cmd = listVlanIpRanges.listVlanIpRangesCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listVlanIpRanges(cmd))
-
- @classmethod
- def dedicate(cls, apiclient, id, account=None, domainid=None, projectid=None):
- """Dedicate VLAN IP range"""
-
- cmd = dedicatePublicIpRange.dedicatePublicIpRangeCmd()
- cmd.id = id
- cmd.account = account
- cmd.domainid = domainid
- cmd.projectid = projectid
- return PublicIpRange(apiclient.dedicatePublicIpRange(cmd).__dict__)
-
- def release(self, apiclient):
- """Release VLAN IP range"""
-
- cmd = releasePublicIpRange.releasePublicIpRangeCmd()
- cmd.id = self.vlan.id
- return apiclient.releasePublicIpRange(cmd)
-
-
-class PortablePublicIpRange:
- """Manage portable public Ip Range"""
-
- def __init__(self, items):
- self.__dict__.update(items)
-
- @classmethod
- def create(cls, apiclient, services):
- """Create portable public Ip Range"""
-
- cmd = createPortableIpRange.createPortableIpRangeCmd()
- cmd.gateway = services["gateway"]
- cmd.netmask = services["netmask"]
- cmd.startip = services["startip"]
- cmd.endip = services["endip"]
- cmd.regionid = services["regionid"]
-
- if "vlan" in services:
- cmd.vlan = services["vlan"]
-
- return PortablePublicIpRange(apiclient.createPortableIpRange(cmd).__dict__)
-
- def delete(self, apiclient):
- """Delete portable IpRange"""
-
- cmd = deletePortableIpRange.deletePortableIpRangeCmd()
- cmd.id = self.id
- apiclient.deletePortableIpRange(cmd)
-
- @classmethod
- def list(cls, apiclient, **kwargs):
- """Lists all portable public IP ranges."""
-
- cmd = listPortableIpRanges.listPortableIpRangesCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listPortableIpRanges(cmd))
-
-class SecondaryStagingStore:
- """Manage Staging Store"""
-
- def __init__(self, items):
- self.__dict__.update(items)
-
- @classmethod
- def create(cls, apiclient, url, provider, services=None):
- """Create Staging Storage"""
- cmd = createSecondaryStagingStore.createSecondaryStagingStoreCmd()
- cmd.url = url
- cmd.provider = provider
- if services:
- if "zoneid" in services:
- cmd.zoneid = services["zoneid"]
- if "details" in services:
- cmd.details = services["details"]
- if "scope" in services:
- cmd.scope = services["scope"]
-
- return SecondaryStagingStore(apiclient.createSecondaryStagingStore(cmd).__dict__)
-
- def delete(self, apiclient):
- """Delete Staging Storage"""
- cmd = deleteSecondaryStagingStore.deleteSecondaryStagingStoreCmd()
- cmd.id = self.id
- apiclient.deleteSecondaryStagingStore(cmd)
-
- @classmethod
- def list(cls, apiclient, **kwargs):
- cmd = listSecondaryStagingStores.listSecondaryStagingStoresCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listSecondaryStagingStores(cmd))
-
-
-class ImageStore:
- """Manage image stores"""
-
- def __init__(self, items):
- self.__dict__.update(items)
-
- @classmethod
- def create(cls, apiclient, url, provider, services=None):
- """Add Image Store"""
- cmd = addImageStore.addImageStoreCmd()
- cmd.url = url
- cmd.provider = provider
- if services:
- if "zoneid" in services:
- cmd.zoneid = services["zoneid"]
- if "details" in services:
- cmd.details = services["details"]
- if "scope" in services:
- cmd.scope = services["scope"]
-
- return ImageStore(apiclient.addImageStore(cmd).__dict__)
-
- def delete(self, apiclient):
- """Delete Image Store"""
- cmd = deleteImageStore.deleteImageStoreCmd()
- cmd.id = self.id
- apiclient.deleteImageStore(cmd)
-
- @classmethod
- def list(cls, apiclient, **kwargs):
- cmd = listImageStores.listImageStoresCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listImageStores(cmd))
-
-
-class PhysicalNetwork:
- """Manage physical network storage"""
-
- def __init__(self, items):
- self.__dict__.update(items)
-
- @classmethod
- def create(cls, apiclient, services, zoneid, domainid=None):
- """Create physical network"""
- cmd = createPhysicalNetwork.createPhysicalNetworkCmd()
-
- cmd.name = services["name"]
- cmd.zoneid = zoneid
- if domainid:
- cmd.domainid = domainid
- return PhysicalNetwork(apiclient.createPhysicalNetwork(cmd).__dict__)
-
- def delete(self, apiclient):
- """Delete Physical Network"""
-
- cmd = deletePhysicalNetwork.deletePhysicalNetworkCmd()
- cmd.id = self.id
- apiclient.deletePhysicalNetwork(cmd)
-
- def update(self, apiclient, **kwargs):
- """Update Physical network state"""
-
- cmd = updatePhysicalNetwork.updatePhysicalNetworkCmd()
- cmd.id = self.id
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return apiclient.updatePhysicalNetwork(cmd)
-
- def addTrafficType(self, apiclient, type):
- """Add Traffic type to Physical network"""
-
- cmd = addTrafficType.addTrafficTypeCmd()
- cmd.physicalnetworkid = self.id
- cmd.traffictype = type
- return apiclient.addTrafficType(cmd)
-
- @classmethod
- def dedicate(cls, apiclient, vlanrange, physicalnetworkid, account=None, domainid=None, projectid=None):
- """Dedicate guest vlan range"""
-
- cmd = dedicateGuestVlanRange.dedicateGuestVlanRangeCmd()
- cmd.vlanrange = vlanrange
- cmd.physicalnetworkid = physicalnetworkid
- cmd.account = account
- cmd.domainid = domainid
- cmd.projectid = projectid
- return PhysicalNetwork(apiclient.dedicateGuestVlanRange(cmd).__dict__)
-
- def release(self, apiclient):
- """Release guest vlan range"""
-
- cmd = releaseDedicatedGuestVlanRange.releaseDedicatedGuestVlanRangeCmd()
- cmd.id = self.id
- return apiclient.releaseDedicatedGuestVlanRange(cmd)
-
- @classmethod
- def listDedicated(cls, apiclient, **kwargs):
- """Lists all dedicated guest vlan ranges"""
-
- cmd = listDedicatedGuestVlanRanges.listDedicatedGuestVlanRangesCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return apiclient.listDedicatedGuestVlanRanges(cmd)
-
- @classmethod
- def list(cls, apiclient, **kwargs):
- """Lists all physical networks"""
-
- cmd = listPhysicalNetworks.listPhysicalNetworksCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return map(lambda pn : PhysicalNetwork(pn.__dict__), apiclient.listPhysicalNetworks(cmd))
-
-
-class SecurityGroup:
- """Manage Secur
<TRUNCATED>
[16/18] Marvin + test changes from master Signed-off-by:
SrikanteswaraRao Talluri
Posted by da...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/component/test_escalations.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_escalations.py b/test/integration/component/test_escalations.py
new file mode 100644
index 0000000..e994579
--- /dev/null
+++ b/test/integration/component/test_escalations.py
@@ -0,0 +1,8230 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+#Import Local Modules
+from marvin.cloudstackTestCase import *
+from marvin.cloudstackException import *
+from marvin.cloudstackAPI import *
+from marvin.sshClient import SshClient
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
+from marvin.lib.utils import checkVolumeSize
+from marvin.codes import SUCCESS
+from nose.plugins.attrib import attr
+from time import sleep
+
+class TestVolumes(cloudstackTestCase):
+
+ @classmethod
+ def setUpClass(cls):
+
+ cls.testClient = super(TestVolumes, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+ cls.services = cls.testClient.getParsedTestDataConfig()
+ # Get Domain, Zone, Template
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client)
+ cls.template = get_template(
+ cls.api_client,
+ cls.zone.id,
+ cls.services["ostype"]
+ )
+ if cls.zone.localstorageenabled:
+ cls.storagetype = 'local'
+ cls.services["service_offerings"]["tiny"]["storagetype"] = 'local'
+ cls.services["disk_offering"]["storagetype"] = 'local'
+ else:
+ cls.storagetype = 'shared'
+ cls.services["service_offerings"]["tiny"]["storagetype"] = 'shared'
+ cls.services["disk_offering"]["storagetype"] = 'shared'
+
+ cls.services['mode'] = cls.zone.networktype
+ cls.services["virtual_machine"]["hypervisor"] = 'XenServer'
+ cls.services["virtual_machine"]["zoneid"] = cls.zone.id
+ cls.services["virtual_machine"]["template"] = cls.template.id
+ cls.services["custom_volume"]["zoneid"] = cls.zone.id
+
+ # Creating Disk offering, Service Offering and Account
+ cls.disk_offering = DiskOffering.create(
+ cls.api_client,
+ cls.services["disk_offering"]
+ )
+ cls.service_offering = ServiceOffering.create(
+ cls.api_client,
+ cls.services["service_offerings"]["tiny"]
+ )
+ cls.account = Account.create(
+ cls.api_client,
+ cls.services["account"],
+ domainid=cls.domain.id
+ )
+
+ # Getting authentication for user in newly created Account
+ cls.user = cls.account.user[0]
+
+ cls.userapiclient = cls.testClient.getUserApiClient(cls.user.username, cls.domain.name)
+
+ # Creating Virtual Machine
+ cls.virtual_machine = VirtualMachine.create(
+ cls.userapiclient,
+ cls.services["virtual_machine"],
+ accountid=cls.account.name,
+ domainid=cls.account.domainid,
+ serviceofferingid=cls.service_offering.id,
+ )
+ cls._cleanup = [
+ cls.virtual_machine,
+ cls.disk_offering,
+ cls.service_offering,
+ cls.account
+ ]
+
+ def setUp(self):
+
+ self.apiClient = self.testClient.getApiClient()
+ self.cleanup = []
+
+ def tearDown(self):
+ #Clean up, terminate the created volumes
+ cleanup_resources(self.apiClient, self.cleanup)
+ return
+
+ @classmethod
+ def tearDownClass(cls):
+ try:
+ cls.apiclient = super(TestVolumes, cls).getClsTestClient().getApiClient()
+ cleanup_resources(cls.apiclient, cls._cleanup)
+ except Exception as e:
+ raise Exception("Warning: Exception during cleanup : %s" % e)
+
+
+ def __verify_values(self, expected_vals, actual_vals):
+ """
+ @summary: Function to verify expected and actual values
+ Step1: Initializing return flag to True
+ Step1: Verifying length of expected and actual dictionaries is matching.
+ If not matching returning false
+ Step2: Listing all the keys from expected dictionary
+ Step3: Looping through each key from step2 and verifying expected and actual dictionaries have same value
+ If not making return flag to False
+ Step4: returning the return flag after all the values are verified
+ """
+ return_flag = True
+
+ if len(expected_vals) != len(actual_vals):
+ return False
+
+ keys = expected_vals.keys()
+ for i in range(0, len(expected_vals)):
+ exp_val = expected_vals[keys[i]]
+ act_val = actual_vals[keys[i]]
+ if exp_val == act_val:
+ return_flag = return_flag and True
+ else:
+ return_flag = return_flag and False
+ self.debug("expected Value: %s, is not matching with actual value: %s" % (
+ exp_val,
+ act_val
+ ))
+ return return_flag
+
+ @attr(tags=["advanced", "basic", "provisioning"])
+ def test_01_list_volumes_pagination(self):
+ """
+ @summary: Test List Volumes pagination
+
+ Step1: Listing all the volumes for a user
+ Step2: Verifying listed volumes for account created at class level
+ Step3: If number of volumes is less than (page size + 1), then creating them
+ Step4: Listing all the volumes again after creation of volumes
+ Step5: Verifying the length of the volumes is (page size + 1)
+ Step6: Listing all the volumes in page1
+ Step7: Verifying that the length of the volumes in page 1 is (page size)
+ Step8: Listing all the volumes in page2
+ Step9: Verifying that the length of the volumes in page 2 is 1
+ Step10: Deleting the volume present in page 2
+ Step11: Listing for the volumes on page 2
+ Step12: Verifying that there are no volumes present in page 2
+ """
+ # Listing all the volumes for a user
+ list_volumes_before = Volume.list(self.userapiclient, listall=self.services["listall"])
+
+ # Verifying listed volumes for account created at class level
+ self.assertIsNotNone(
+ list_volumes_before,
+ "create volume from VM failed at class setup method"
+ )
+ self.assertEqual(
+ len(list_volumes_before),
+ 1,
+ "more than 1 volume created from VM at class level"
+ )
+
+ # If number of volumes is less than (pagesize + 1), then creating them
+ for i in range(0, (self.services["pagesize"])):
+ volume_created = Volume.create(
+ self.userapiclient,
+ self.services["volume"],
+ zoneid=self.zone.id,
+ diskofferingid=self.disk_offering.id
+ )
+ self.assertIsNotNone(
+ volume_created,
+ "Volume is not created"
+ )
+ if(i < (self.services["pagesize"] - 1)):
+ self.cleanup.append(volume_created)
+
+ self.assertEqual(
+ self.services["volume"]["diskname"],
+ volume_created.name,
+ "Newly created volume name and the test data volume name are not matching"
+ )
+
+ # Listing all the volumes again after creation of volumes
+ list_volumes_after = Volume.list(self.userapiclient, listall=self.services["listall"])
+
+ # Verifying the length of the volumes is (page size + 1)
+ self.assertEqual(
+ len(list_volumes_after),
+ (self.services["pagesize"] + 1),
+ "Number of volumes created is not matching expected"
+ )
+
+ # Listing all the volumes in page1
+ list_volumes_page1 = Volume.list(
+ self.userapiclient,
+ listall=self.services["listall"],
+ page=1,
+ pagesize=self.services["pagesize"]
+ )
+ self.assertIsNotNone(
+ list_volumes_page1,
+ "No volumes found in Page 1"
+ )
+ # Verifying that the length of the volumes in page 1 is (page size)
+ self.assertEqual(
+ len(list_volumes_page1),
+ self.services["pagesize"],
+ "List Volume response is not matching with the page size length for page 1"
+ )
+
+ # Listing all the volumes in page2
+ list_volumes_page2 = Volume.list(
+ self.userapiclient,
+ listall=self.services["listall"],
+ page=2,
+ pagesize=self.services["pagesize"]
+ )
+ self.assertIsNotNone(
+ list_volumes_page2,
+ "No volumes found in Page 2"
+ )
+ # Verifying that the length of the volumes in page 2 is 1
+ self.assertEqual(
+ len(list_volumes_page2),
+ 1,
+ "List Volume response is not matching with the page size length for page 2"
+ )
+ volume_page2 = list_volumes_page2[0]
+
+ # Verifying that the volume on page 2 is not present in page1
+ for i in range(0, len(list_volumes_page1)):
+ volume_page1 = list_volumes_page1[i]
+ self.assertNotEquals(
+ volume_page2.id,
+ volume_page1.id,
+ "Volume listed in page 2 is also listed in page 1"
+ )
+
+ # Deleting a single volume
+ Volume.delete(volume_created, self.userapiclient)
+
+ # Listing the volumes in page 2
+ list_volume_response = Volume.list(
+ self.userapiclient,
+ listall=self.services["listall"],
+ page=2,
+ pagesize=self.services["pagesize"]
+ )
+ # verifying that volume does not exists on page 2
+ self.assertEqual(
+ list_volume_response,
+ None,
+ "Volume was not deleted"
+ )
+ return
+
+ @attr(tags=["advanced", "basic", "provisioning"])
+ def test_02_list_volume_byid(self):
+ """
+ @summary: Test List Volumes with Id
+
+ Step1: Listing all the volumes for a user before creating a data volume
+ Step2: Verifying the length of the list as 1
+ Step3: Creating a data volume
+ Step4: Listing all the volumes for a user after creating a data volume
+ Step5: Verifying the list volume size is increased by 1
+ Step6: List the volumes by specifying root volume Id
+ Step7: Verifying the details of the root volume
+ Step8: List the volumes by specifying data volume Id
+ Step9: Verifying the details of the data volume
+ """
+ # Listing all the volumes for a user before creating a data volume
+ list_volumes_before = Volume.list(
+ self.userapiclient,
+ listall=self.services["listall"]
+ )
+ self.assertIsNotNone(
+ list_volumes_before,
+ "create volume from VM failed at class setup method")
+ # Verifying the length of the list as 1
+ self.assertEqual(
+ len(list_volumes_before),
+ 1,
+ "more than 1 volume created at class level"
+ )
+ root_volume = list_volumes_before[0]
+
+ # Creating a data volume
+ volume_created = Volume.create(
+ self.userapiclient,
+ self.services["volume"],
+ zoneid=self.zone.id,
+ diskofferingid=self.disk_offering.id
+ )
+ self.assertIsNotNone(
+ volume_created,
+ "Volume is not created"
+ )
+ self.cleanup.append(volume_created)
+
+ self.assertEqual(
+ self.services["volume"]["diskname"],
+ volume_created.name,
+ "Newly created volume name and the test data volume name are not matching"
+ )
+ # Listing all the volumes for a user after creating a data volume
+ list_volumes_after = Volume.list(
+ self.userapiclient,
+ listall=self.services["listall"]
+ )
+ self.assertIsNotNone(
+ list_volumes_after,
+ "Volume creation failed"
+ )
+ # Verifying the list volume size is increased by 1
+ self.assertEqual(
+ len(list_volumes_before) + 1,
+ len(list_volumes_after),
+ "list volume is not matching with Number of volumes created"
+ )
+
+ # Listing a Root Volume by Id and verifying the volume details
+ list_volumes_by_id = Volume.list(
+ self.userapiclient,
+ listall=self.services["listall"],
+ id=root_volume.id
+ )
+ self.assertIsNotNone(
+ list_volumes_by_id,
+ "Root volume is not listed"
+ )
+ self.assertEqual(
+ 1,
+ len(list_volumes_by_id),
+ "list volume is not matching with Number of volumes created"
+ )
+ obtained_volume = list_volumes_by_id[0]
+
+ #Creating expected and actual values dictionaries
+ expected_dict = {
+ "id":root_volume.id,
+ "name":root_volume.name,
+ "vmname":self.virtual_machine.name,
+ "state":"Ready",
+ "type":"ROOT",
+ "zoneid":self.zone.id,
+ "account":self.account.name,
+ "storagetype":self.storagetype,
+ "size":self.template.size
+ }
+ actual_dict = {
+ "id":obtained_volume.id,
+ "name":obtained_volume.name,
+ "vmname":obtained_volume.vmname,
+ "state":obtained_volume.state,
+ "type":obtained_volume.type,
+ "zoneid":obtained_volume.zoneid,
+ "account":obtained_volume.account,
+ "storagetype":obtained_volume.storagetype,
+ "size":obtained_volume.size,
+ }
+ root_volume_status = self.__verify_values(
+ expected_dict,
+ actual_dict
+ )
+ self.assertEqual(
+ True,
+ root_volume_status,
+ "Listed Root Volume details are not as expected"
+ )
+ # Listing a Data Volume by Id and verifying the volume details
+ list_volumes_by_id = Volume.list(
+ self.userapiclient,
+ listall=self.services["listall"],
+ id=volume_created.id
+ )
+ self.assertIsNotNone(
+ list_volumes_by_id,
+ "Data volume is not listed"
+ )
+ self.assertEqual(
+ len(list_volumes_by_id),
+ 1,
+ "list volume is not matching with Number of volumes created"
+ )
+ obtained_volume = list_volumes_by_id[0]
+
+ #Creating expected and actual values dictionaries
+ expected_dict = {
+ "id":volume_created.id,
+ "name":volume_created.name,
+ "state":"Allocated",
+ "type":"DATADISK",
+ "zoneid":self.zone.id,
+ "account":self.account.name,
+ "storagetype":self.storagetype,
+ "size":self.disk_offering.disksize
+ }
+ actual_dict = {
+ "id":obtained_volume.id,
+ "name":obtained_volume.name,
+ "state":obtained_volume.state,
+ "type":obtained_volume.type,
+ "zoneid":obtained_volume.zoneid,
+ "account":obtained_volume.account,
+ "storagetype":obtained_volume.storagetype,
+ "size":obtained_volume.size/(1024*1024*1024),
+ }
+ root_volume_status = self.__verify_values(
+ expected_dict,
+ actual_dict
+ )
+ self.assertEqual(
+ True,
+ root_volume_status,
+ "Listed Data Volume details are not as expected"
+ )
+ return
+
+ @attr(tags=["advanced", "basic", "provisioning"])
+ def test_03_data_volume_resize(self):
+ """
+ @summary: Test to verify creation and resize of data volume
+
+ Step1: Listing the volumes for a user before creating data volume
+ Step2: Creating a data volume
+ Step3: Listing the volumes for a user after creating data volume
+ Step4: Attaching and Detaching data volume created to Virtual Machine
+ Step5: Verifying if there exists a disk offering with higher size
+ If not present creating it
+ Step6: Resizing data volume
+ """
+ # Listing volumes for a user before creating a volume
+ list_volumes_before = Volume.list(self.userapiclient, listall=self.services["listall"])
+
+ # Creating a data volume
+ volume_created = Volume.create(
+ self.userapiclient,
+ self.services["volume"],
+ zoneid=self.zone.id,
+ diskofferingid=self.disk_offering.id
+ )
+ self.assertIsNotNone(volume_created, "Data volume creation failed")
+
+ self.cleanup.append(volume_created)
+
+ # Listing volumes for a user after creating data volume
+ list_volumes_after = Volume.list(self.userapiclient, listall=self.services["listall"])
+ self.assertEquals(
+ len(list_volumes_before) + 1,
+ len(list_volumes_after),
+ "Data volume creation failed"
+ )
+
+ # Attaching data volume created to Virtual Machine
+ self.virtual_machine.attach_volume(
+ self.userapiclient,
+ volume_created
+ )
+
+ list_volumes = Volume.list(
+ self.userapiclient,
+ listall=self.services["listall"],
+ id=volume_created.id
+ )
+ attached_volume = list_volumes[0]
+
+ self.assertIsNotNone(
+ attached_volume.vmname,
+ "VM is not attached to Volume"
+ )
+ self.assertEquals(
+ self.virtual_machine.name,
+ attached_volume.vmname,
+ "VM Name is not matching with attached vm"
+ )
+
+ # Detaching data volume from Virtual Machine
+ self.virtual_machine.detach_volume(
+ self.userapiclient,
+ volume_created
+ )
+ list_volumes = Volume.list(
+ self.userapiclient,
+ listall=self.services["listall"],
+ id=volume_created.id
+ )
+ detached_volume = list_volumes[0]
+ self.assertIsNone(
+ detached_volume.vmname,
+ "VM is not detached from volume"
+ )
+
+ # Verifying if there exists a disk offering with higher size. If not present creating it
+ list_disk_offerings = DiskOffering.list(self.apiClient)
+
+ large_disk_offering_exists = False
+ # Converting disk_size in bytes to GB
+ current_disk_size = volume_created.size/(1024*1024*1024)
+
+ for disk_offering in list_disk_offerings:
+ if ((disk_offering.disksize > current_disk_size) and (not disk_offering.iscustomized) and disk_offering.storagetype == self.storagetype):
+ new_disk_offering = disk_offering
+ large_disk_offering_exists = True
+ break
+
+ if large_disk_offering_exists == False:
+ new_size = (volume_created.size/(1024*1024*1024)) + 1
+ self.services["disk_offering"]["disksize"] = new_size
+ new_disk_offering = DiskOffering.create(
+ self.apiClient,
+ self.services["disk_offering"]
+ )
+ if new_disk_offering is not None:
+ self.cleanup.append(new_disk_offering)
+ else:
+ new_size = new_disk_offering.disksize
+
+ # Resizing data volume
+ resized_volume = volume_created.resize(
+ self.userapiclient,
+ diskofferingid=new_disk_offering.id,
+ shrinkok='false',
+ )
+ self.assertIsNotNone(resized_volume, "Resize Volume failed")
+ # Verifying data volume size is increased
+ self.assertEquals(
+ new_size,
+ (resized_volume.size/(1024*1024*1024)),
+ "volume not resized to expected value"
+ )
+ return
+
+ @attr(tags=["advanced", "basic", "provisioning"])
+ def test_04_custom_volume_resize(self):
+ """
+ @summary: Test to verify creation and resize of custom volume
+
+ Step1: Checking if Custom disk offering already exists.
+ If not present then creating custom Disk Offering
+ Step2: Listing the volumes for a user before creating custom volume
+ Step3: Creating a custom volume
+ Step4: Listing the volumes for a user after creating custom volume
+ Step5: Attaching and Detaching custom volume created to Virtual Machine
+ Step6: Resizing custom volume
+ """
+ # Listing all the disk offerings
+ list_disk_offerings = DiskOffering.list(self.apiClient)
+
+ custom_disk_offering_exists = False
+
+ # Verifying if a custom disk offering already exists
+ if list_disk_offerings is not None:
+ for disk_offering in list_disk_offerings:
+ if (disk_offering.iscustomized and disk_offering.storagetype == self.storagetype):
+ custom_disk_offering = disk_offering
+ custom_disk_offering_exists = True
+ break
+
+ # If a custom disk offering does not exists, then creating a custom disk offering
+ if custom_disk_offering_exists == False:
+ custom_disk_offering = DiskOffering.create(
+ self.apiClient,
+ self.services["disk_offering"],
+ custom=True
+ )
+ if custom_disk_offering is not None:
+ self.cleanup.append(custom_disk_offering)
+
+ # Listing the volumes for a user before creating custom volume
+ list_volumes_before = Volume.list(self.userapiclient, listall=self.services["listall"])
+
+ # Creating a custom volume
+ volume_created = Volume.create_custom_disk(
+ self.userapiclient,
+ self.services["custom_volume"],
+ account=self.account.name,
+ domainid=self.account.domainid,
+ diskofferingid=custom_disk_offering.id
+ )
+ self.assertIsNotNone(
+ volume_created,
+ "Custom volume did not get created"
+ )
+
+ self.cleanup.append(volume_created)
+
+ # Listing the volumes for a user after creating custom volume
+ list_volumes_after = Volume.list(self.userapiclient, listall=self.services["listall"])
+
+ # Verifyign that volume list is increased by 1 after creation of custion volume
+ self.assertEquals(
+ len(list_volumes_before) + 1,
+ len(list_volumes_after),
+ "Custom volume did not get created"
+ )
+
+ # Attaching custom volume created to Virtual Machine
+ self.virtual_machine.attach_volume(
+ self.userapiclient,
+ volume_created
+ )
+ list_volumes = Volume.list(
+ self.userapiclient,
+ listall=self.services["listall"],
+ id=volume_created.id
+ )
+ attached_volume = list_volumes[0]
+
+ self.assertIsNotNone(
+ attached_volume.vmname,
+ "VM is not attached to Volume"
+ )
+ self.assertEquals(
+ self.virtual_machine.name,
+ attached_volume.vmname,
+ "VM Name is not matching with attached vm"
+ )
+
+ # Detaching custom volume from Virtual Machine
+ self.virtual_machine.detach_volume(
+ self.userapiclient,
+ volume_created
+ )
+ list_volumes = Volume.list(
+ self.userapiclient,
+ listall=self.services["listall"],
+ id=volume_created.id
+ )
+ detached_volume = list_volumes[0]
+ self.assertIsNone(
+ detached_volume.vmname,
+ "VM is not detached from volume"
+ )
+
+ # Resizing custom volume
+ # Increasing custom disk size by 1
+ new_size = self.services["custom_volume"]["customdisksize"] + 1
+ resized_volume = volume_created.resize(
+ self.userapiclient,
+ diskofferingid=custom_disk_offering.id,
+ shrinkok='false',
+ size=new_size)
+ self.assertIsNotNone(resized_volume, "Resize Volume failed")
+ # Verifying that custom disk size is increased
+ self.assertEquals(
+ new_size,
+ (resized_volume.size/(1024*1024*1024)),
+ "volume not resized to expected value"
+ )
+ return
+
+ @attr(tags=["advanced", "basic", "provisioning"])
+ def test_05_volume_snapshot(self):
+ """
+ @summary: Test to verify creation of snapshot from volume and creation of template, volume from snapshot
+
+ Step1: Creating a volume
+ Step2: Attaching and Detaching custom volume created to Virtual Machine
+ Step3: Creating Snapshot from volume
+ Step4: Creating Volume from snapshot
+ Step5: Creating Template from Snapshot
+ """
+ list_volumes_before = Volume.list(self.userapiclient, listall=self.services["listall"])
+
+ volume_created = Volume.create(
+ self.userapiclient,
+ self.services["volume"],
+ zoneid=self.zone.id,
+ diskofferingid=self.disk_offering.id
+ )
+
+ self.assertIsNotNone(volume_created, "Volume not created")
+
+ if volume_created is not None:
+ self.cleanup.append(volume_created)
+
+ list_volumes_after = Volume.list(self.userapiclient, listall=self.services["listall"])
+
+ self.assertEquals(
+ len(list_volumes_before) + 1,
+ len(list_volumes_after),
+ "Volume not created"
+ )
+ # Attaching and Detaching custom volume created to Virtual Machine
+ self.virtual_machine.attach_volume(
+ self.userapiclient,
+ volume_created
+ )
+
+ list_volumes = Volume.list(
+ self.userapiclient,
+ listall=self.services["listall"],
+ id=volume_created.id
+ )
+ attached_volume = list_volumes[0]
+
+ self.assertIsNotNone(
+ attached_volume.vmname,
+ "VM is not attached to Volume"
+ )
+ self.assertEquals(
+ self.virtual_machine.name,
+ attached_volume.vmname,
+ "VM Name is not matching with attached vm"
+ )
+ self.virtual_machine.detach_volume(
+ self.userapiclient,
+ volume_created
+ )
+ list_volumes = Volume.list(
+ self.userapiclient,
+ listall=self.services["listall"],
+ id=volume_created.id
+ )
+ detached_volume = list_volumes[0]
+ self.assertIsNone(
+ detached_volume.vmname,
+ "VM is not detached from volume"
+ )
+ # Creating Snapshot from volume
+ snapshot_created = Snapshot.create(
+ self.userapiclient,
+ volume_created.id,
+ )
+
+ self.assertIsNotNone(snapshot_created, "Snapshot not created")
+
+ self.cleanup.append(snapshot_created)
+
+ #Creating expected and actual values dictionaries
+ expected_dict = {
+ "id":volume_created.id,
+ "intervaltype":"MANUAL",
+ "snapshottype":"MANUAL",
+ "volumetype":volume_created.type,
+ "domain":self.domain.id
+ }
+ actual_dict = {
+ "id":snapshot_created.volumeid,
+ "intervaltype":snapshot_created.intervaltype,
+ "snapshottype":snapshot_created.snapshottype,
+ "volumetype":snapshot_created.volumetype,
+ "domain":snapshot_created.domainid,
+ }
+ status = self.__verify_values(
+ expected_dict,
+ actual_dict
+ )
+ self.assertEqual(
+ True,
+ status,
+ "Snapshot created from Volume details are not as expected"
+ )
+ # Creating Volume from snapshot
+ cmd = createVolume.createVolumeCmd()
+ cmd.name = "-".join([self.services["volume"]["diskname"], random_gen()])
+ cmd.snapshotid = snapshot_created.id
+
+ volume_from_snapshot = Volume(self.userapiclient.createVolume(cmd).__dict__)
+
+ self.assertIsNotNone(
+ volume_from_snapshot,
+ "Volume creation failed from snapshot"
+ )
+ self.cleanup.append(volume_from_snapshot)
+
+ #Creating expected and actual values dictionaries
+ expected_dict = {
+ "snapshotid":snapshot_created.id,
+ "volumetype":snapshot_created.volumetype,
+ "size":self.disk_offering.disksize,
+ "accounr":self.account.name,
+ "domain":self.domain.id,
+ "storagetype":self.storagetype,
+ "zone":self.zone.id
+ }
+ actual_dict = {
+ "snapshotid":volume_from_snapshot.snapshotid,
+ "volumetype":volume_from_snapshot.type,
+ "size":volume_from_snapshot.size/(1024*1024*1024),
+ "accounr":volume_from_snapshot.account,
+ "domain":volume_from_snapshot.domainid,
+ "storagetype":volume_from_snapshot.storagetype,
+ "zone":volume_from_snapshot.zoneid,
+ }
+ status = self.__verify_values(
+ expected_dict,
+ actual_dict
+ )
+ self.assertEqual(
+ True,
+ status,
+ "Volume created from Snapshot details are not as expected"
+ )
+ # Creating Template from Snapshot
+ list_templates_before = Template.list(self.userapiclient, templatefilter='self')
+
+ if list_templates_before is None:
+ templates_before_size = 0
+ else:
+ templates_before_size = len(list_templates_before)
+
+ cmd = createTemplate.createTemplateCmd()
+ cmd.name = self.services["ostype"]
+ cmd.displaytext = self.services["ostype"]
+ cmd.ostypeid = self.template.ostypeid
+ cmd.snapshotid = snapshot_created.id
+ cmd.ispublic = False
+ cmd.passwordenabled = False
+
+ template_from_snapshot = Template(self.userapiclient.createTemplate(cmd).__dict__)
+
+ self.assertIsNotNone(
+ template_from_snapshot,
+ "Template creation failed from snapshot"
+ )
+
+ self.cleanup.append(template_from_snapshot)
+
+ #Creating expected and actual values dictionaries
+ expected_dict = {
+ "name":self.services["ostype"],
+ "ostypeid":self.template.ostypeid,
+ "type":"USER",
+ "zone":self.zone.id,
+ "domain":self.domain.id,
+ "account":self.account.name,
+ "passwordenabled":False,
+ "ispublic":False,
+ "size":self.disk_offering.disksize
+ }
+ actual_dict = {
+ "name":template_from_snapshot.name,
+ "ostypeid":template_from_snapshot.ostypeid,
+ "type":template_from_snapshot.templatetype,
+ "zone":template_from_snapshot.zoneid,
+ "domain":template_from_snapshot.domainid,
+ "account":template_from_snapshot.account,
+ "passwordenabled":template_from_snapshot.passwordenabled,
+ "ispublic":template_from_snapshot.ispublic,
+ "size":template_from_snapshot.size/(1024*1024*1024)
+ }
+ status = self.__verify_values(
+ expected_dict,
+ actual_dict
+ )
+ self.assertEqual(
+ True,
+ status,
+ "Template created from Snapshot details are not as expected"
+ )
+
+ list_templates_after = Template.list(self.userapiclient, templatefilter='self')
+
+ self.assertEquals(
+ templates_before_size + 1,
+ len(list_templates_after),
+ "Template creation failed from snapshot"
+ )
+ return
+
+ @attr(tags=["advanced", "basic", "provisioning"])
+ def test_06_volume_snapshot_policy_hourly(self):
+ """
+ @summary: Test to verify creation of Hourly Snapshot policies from volume
+
+ Step1: Creating a Volume.
+ Step2: Attaching volume created in Step2 to virtual machine
+ Step3: Detaching the volume created in step2 from virtual machine
+ Step4: Listing snapshot policies for a volume created in step1
+ Step5: Creating Hourly snapshot policy
+ Step6: Listing snapshot policies for a volume created in step1 again
+ Step7: Verifyign that the list snapshot policy length is increased by 1
+ """
+ list_volumes_before = Volume.list(self.userapiclient, listall=self.services["listall"])
+
+ volume_created = Volume.create(
+ self.userapiclient,
+ self.services["volume"],
+ zoneid=self.zone.id,
+ diskofferingid=self.disk_offering.id
+ )
+
+ self.assertIsNotNone(volume_created, "Volume not created")
+ self.cleanup.append(volume_created)
+
+ list_volumes_after = Volume.list(self.userapiclient, listall=self.services["listall"])
+
+ self.assertEquals(
+ len(list_volumes_before) + 1,
+ len(list_volumes_after),
+ "Volume not created"
+ )
+
+ # Attaching volume created to Virtual Machine
+ self.virtual_machine.attach_volume(
+ self.userapiclient,
+ volume_created
+ )
+
+ list_volumes = Volume.list(
+ self.userapiclient,
+ listall=self.services["listall"],
+ id=volume_created.id
+ )
+ attached_volume = list_volumes[0]
+
+ self.assertIsNotNone(
+ attached_volume.vmname,
+ "VM is not attached to Volume"
+ )
+ self.assertEquals(
+ self.virtual_machine.name,
+ attached_volume.vmname,
+ "VM Name is not matching with attached vm"
+ )
+ # Detaching volume created from Virtual Machine
+ self.virtual_machine.detach_volume(
+ self.userapiclient,
+ volume_created
+ )
+ list_volumes = Volume.list(
+ self.userapiclient,
+ listall=self.services["listall"],
+ id=volume_created.id
+ )
+ detached_volume = list_volumes[0]
+ self.assertIsNone(
+ detached_volume.vmname,
+ "VM is not detached from volume"
+ )
+ # Creating Hourly Snapshot Policy from volume
+ self.services["recurring_snapshot"]["intervaltype"] = 'hourly'
+ self.services["recurring_snapshot"]["schedule"] = '1'
+
+ list_snapshot_policy_before = SnapshotPolicy.list(self.userapiclient, volumeid=volume_created.id)
+
+ snapshot_policy_before_size = 0
+
+ if list_snapshot_policy_before is not None:
+ snapshot_policy_before_size = len(list_snapshot_policy_before)
+
+ snapshot_policy_hourly = SnapshotPolicy.create(
+ self.userapiclient,
+ volume_created.id,
+ self.services["recurring_snapshot"]
+ )
+ self.assertIsNotNone(
+ snapshot_policy_hourly,
+ "Hourly Snapshot policy creation failed"
+ )
+ #Creating expected and actual values dictionaries
+ expected_dict = {
+ "schedule":self.services["recurring_snapshot"]["schedule"],
+ "intervaltype":0,
+ "volumeid":volume_created.id
+ }
+ actual_dict = {
+ "schedule":snapshot_policy_hourly.schedule,
+ "intervaltype":snapshot_policy_hourly.intervaltype,
+ "volumeid":snapshot_policy_hourly.volumeid
+ }
+ status = self.__verify_values(
+ expected_dict,
+ actual_dict
+ )
+ self.assertEqual(
+ True,
+ status,
+ "Hourly Snapshot Policy details are not as expected"
+ )
+
+ list_snapshot_policy_after = SnapshotPolicy.list(self.userapiclient, volumeid=volume_created.id)
+
+ self.assertIsNotNone(
+ list_snapshot_policy_after,
+ "Hourly Snapshot policy creation failed"
+ )
+ self.assertEquals(
+ snapshot_policy_before_size + 1,
+ len(list_snapshot_policy_after),
+ "Hourly Snapshot policy creation failed"
+ )
+ return
+
+ @attr(tags=["advanced", "basic", "provisioning"])
+ def test_07_volume_snapshot_policy_daily(self):
+ """
+ @summary: Test to verify creation of Daily Snapshot policies from volume
+
+ Step1: Creating a Volume.
+ Step2: Attaching volume created in Step2 to virtual machine
+ Step3: Detaching the volume created in step2 from virtual machine
+ Step4: Listing snapshot policies for a volume created in step1
+ Step5: Creating Daily snapshot policy
+ Step6: Listing snapshot policies for a volume created in step1 again
+ Step7: Verifyign that the list snapshot policy length is increased by 1
+ """
+ list_volumes_before = Volume.list(self.userapiclient, listall=self.services["listall"])
+
+ volume_created = Volume.create(
+ self.userapiclient,
+ self.services["volume"],
+ zoneid=self.zone.id,
+ diskofferingid=self.disk_offering.id
+ )
+
+ self.assertIsNotNone(volume_created, "Volume not created")
+ self.cleanup.append(volume_created)
+
+ list_volumes_after = Volume.list(self.userapiclient, listall=self.services["listall"])
+
+ self.assertEquals(
+ len(list_volumes_before) + 1,
+ len(list_volumes_after),
+ "Volume not created"
+ )
+ # Attaching volume created to Virtual Machine
+ self.virtual_machine.attach_volume(
+ self.userapiclient,
+ volume_created
+ )
+
+ list_volumes = Volume.list(
+ self.userapiclient,
+ listall=self.services["listall"],
+ id=volume_created.id
+ )
+ attached_volume = list_volumes[0]
+
+ self.assertIsNotNone(
+ attached_volume.vmname,
+ "VM is not attached to Volume"
+ )
+ self.assertEquals(
+ self.virtual_machine.name,
+ attached_volume.vmname,
+ "VM Name is not matching with attached vm"
+ )
+ # Detaching volume created from Virtual Machine
+ self.virtual_machine.detach_volume(
+ self.userapiclient,
+ volume_created
+ )
+ list_volumes = Volume.list(
+ self.userapiclient,
+ listall=self.services["listall"],
+ id=volume_created.id
+ )
+ detached_volume = list_volumes[0]
+ self.assertIsNone(
+ detached_volume.vmname,
+ "VM is not detached from volume"
+ )
+ # Creating Daily Snapshot Policy from volume
+ self.services["recurring_snapshot"]["intervaltype"] = 'daily'
+ self.services["recurring_snapshot"]["schedule"] = '00:00'
+
+ list_snapshot_policy_before = SnapshotPolicy.list(self.userapiclient, volumeid=volume_created.id)
+
+ snapshot_policy_before_size = 0
+
+ if list_snapshot_policy_before is not None:
+ snapshot_policy_before_size = len(list_snapshot_policy_before)
+
+ snapshot_policy_daily = SnapshotPolicy.create(
+ self.userapiclient,
+ volume_created.id,
+ self.services["recurring_snapshot"]
+ )
+ self.assertIsNotNone(
+ snapshot_policy_daily,
+ "Daily Snapshot policy creation failed"
+ )
+ #Creating expected and actual values dictionaries
+ expected_dict = {
+ "schedule":self.services["recurring_snapshot"]["schedule"],
+ "intervaltype":1,
+ "volumeid":volume_created.id
+ }
+ actual_dict = {
+ "schedule":snapshot_policy_daily.schedule,
+ "intervaltype":snapshot_policy_daily.intervaltype,
+ "volumeid":snapshot_policy_daily.volumeid
+ }
+ status = self.__verify_values(
+ expected_dict,
+ actual_dict
+ )
+ self.assertEqual(
+ True,
+ status,
+ "Daily Snapshot Policy details are not as expected"
+ )
+
+ list_snapshot_policy_after = SnapshotPolicy.list(self.userapiclient, volumeid=volume_created.id)
+
+ self.assertIsNotNone(
+ list_snapshot_policy_after,
+ "Daily Snapshot policy creation failed"
+ )
+ self.assertEquals(
+ snapshot_policy_before_size + 1,
+ len(list_snapshot_policy_after),
+ "Daily Snapshot policy creation failed"
+ )
+ return
+
+ @attr(tags=["advanced", "basic", "provisioning"])
+ def test_08_volume_snapshot_policy_weekly(self):
+ """
+ @summary: Test to verify creation of Weekly Snapshot policies from volume
+
+ Step1: Creating a Volume.
+ Step2: Attaching volume created in Step2 to virtual machine
+ Step3: Detaching the volume created in step2 from virtual machine
+ Step4: Listing snapshot policies for a volume created in step1
+ Step5: Creating Weekly snapshot policy
+ Step6: Listing snapshot policies for a volume created in step1 again
+ Step7: Verifyign that the list snapshot policy length is increased by 1
+ """
+ list_volumes_before = Volume.list(self.userapiclient, listall=self.services["listall"])
+
+ volume_created = Volume.create(
+ self.userapiclient,
+ self.services["volume"],
+ zoneid=self.zone.id,
+ diskofferingid=self.disk_offering.id
+ )
+
+ self.assertIsNotNone(volume_created, "Volume not created")
+ self.cleanup.append(volume_created)
+
+ list_volumes_after = Volume.list(self.userapiclient, listall=self.services["listall"])
+
+ self.assertEquals(
+ len(list_volumes_before) + 1,
+ len(list_volumes_after),
+ "Volume not created"
+ )
+
+ # Attaching volume created to Virtual Machine
+ self.virtual_machine.attach_volume(
+ self.userapiclient,
+ volume_created
+ )
+ list_volumes = Volume.list(
+ self.userapiclient,
+ listall=self.services["listall"],
+ id=volume_created.id
+ )
+ attached_volume = list_volumes[0]
+
+ self.assertIsNotNone(
+ attached_volume.vmname,
+ "VM is not attached to Volume"
+ )
+ self.assertEquals(
+ self.virtual_machine.name,
+ attached_volume.vmname,
+ "VM Name is not matching with attached vm"
+ )
+ # Detaching volume created to Virtual Machine
+ self.virtual_machine.detach_volume(
+ self.userapiclient,
+ volume_created
+ )
+ list_volumes = Volume.list(
+ self.userapiclient,
+ listall=self.services["listall"],
+ id=volume_created.id
+ )
+ detached_volume = list_volumes[0]
+ self.assertIsNone(
+ detached_volume.vmname,
+ "VM is not detached from volume"
+ )
+ # Creating Weekly Snapshot Policy from volume
+ self.services["recurring_snapshot"]["intervaltype"] = 'weekly'
+ self.services["recurring_snapshot"]["schedule"] = '00:00:1'
+
+ list_snapshot_policy_before = SnapshotPolicy.list(self.userapiclient, volumeid=volume_created.id)
+
+ snapshot_policy_before_size = 0
+
+ if list_snapshot_policy_before is not None:
+ snapshot_policy_before_size = len(list_snapshot_policy_before)
+
+ snapshot_policy_weekly = SnapshotPolicy.create(
+ self.userapiclient,
+ volume_created.id,
+ self.services["recurring_snapshot"]
+ )
+ self.assertIsNotNone(
+ snapshot_policy_weekly,
+ "Weekly Snapshot policy creation failed"
+ )
+ #Creating expected and actual values dictionaries
+ expected_dict = {
+ "schedule":self.services["recurring_snapshot"]["schedule"],
+ "intervaltype":2,
+ "volumeid":volume_created.id
+ }
+ actual_dict = {
+ "schedule":snapshot_policy_weekly.schedule,
+ "intervaltype":snapshot_policy_weekly.intervaltype,
+ "volumeid":snapshot_policy_weekly.volumeid
+ }
+ status = self.__verify_values(
+ expected_dict,
+ actual_dict
+ )
+ self.assertEqual(
+ True,
+ status,
+ "Weekly Snapshot Policy details are not as expected"
+ )
+
+ list_snapshot_policy_after = SnapshotPolicy.list(self.userapiclient, volumeid=volume_created.id)
+
+ self.assertIsNotNone(
+ list_snapshot_policy_after,
+ "Weekly Snapshot policy creation failed"
+ )
+ self.assertEquals(
+ snapshot_policy_before_size + 1,
+ len(list_snapshot_policy_after),
+ "Weekly Snapshot policy creation failed"
+ )
+ return
+
+ @attr(tags=["advanced", "basic", "provisioning"])
+ def test_09_volume_snapshot_policy_monthly(self):
+ """
+ @summary: Test to verify creation of Monthly Snapshot policies from volume
+
+ Step1: Creating a Volume.
+ Step2: Attaching volume created in Step2 to virtual machine
+ Step3: Detaching the volume created in step2 from virtual machine
+ Step4: Listing snapshot policies for a volume created in step1
+ Step5: Creating Monthly snapshot policy
+ Step6: Listing snapshot policies for a volume created in step1 again
+ Step7: Verifyign that the list snapshot policy length is increased by 1
+ Step8: Deleting monthly snapshot policy created in step5
+ Step9: List snapshot policies for a volume again
+ Step10: Verifying that the list snapshot policy length is decreased by 1
+ """
+ list_volumes_before = Volume.list(self.userapiclient, listall=self.services["listall"])
+
+ volume_created = Volume.create(
+ self.userapiclient,
+ self.services["volume"],
+ zoneid=self.zone.id,
+ diskofferingid=self.disk_offering.id
+ )
+ self.assertIsNotNone(volume_created, "Volume not created")
+ self.cleanup.append(volume_created)
+
+ list_volumes_after = Volume.list(self.userapiclient, listall=self.services["listall"])
+
+ self.assertEquals(
+ len(list_volumes_before) + 1,
+ len(list_volumes_after),
+ "Volume not created"
+ )
+ # Attaching and Detaching custom volume created to Virtual Machine
+ self.virtual_machine.attach_volume(
+ self.userapiclient,
+ volume_created
+ )
+ list_volumes = Volume.list(
+ self.userapiclient,
+ listall=self.services["listall"],
+ id=volume_created.id
+ )
+ attached_volume = list_volumes[0]
+
+ self.assertIsNotNone(
+ attached_volume.vmname,
+ "VM is not attached to Volume"
+ )
+ self.assertEquals(
+ self.virtual_machine.name,
+ attached_volume.vmname,
+ "VM Name is not matching with attached vm"
+ )
+ self.virtual_machine.detach_volume(
+ self.userapiclient,
+ volume_created
+ )
+ list_volumes = Volume.list(
+ self.userapiclient,
+ listall=self.services["listall"],
+ id=volume_created.id
+ )
+ detached_volume = list_volumes[0]
+ self.assertIsNone(
+ detached_volume.vmname,
+ "VM is not detached from volume"
+ )
+ # Creating Monthly Snapshot Policy from volume
+ self.services["recurring_snapshot"]["intervaltype"] = 'monthly'
+ self.services["recurring_snapshot"]["schedule"] = '00:00:1'
+
+ list_snapshot_policy_before = SnapshotPolicy.list(self.userapiclient, volumeid=volume_created.id)
+
+ snapshot_policy_before_size = 0
+
+ if list_snapshot_policy_before is not None:
+ snapshot_policy_before_size = len(list_snapshot_policy_before)
+
+ snapshot_policy_monthly = SnapshotPolicy.create(
+ self.userapiclient,
+ volume_created.id,
+ self.services["recurring_snapshot"])
+ self.assertIsNotNone(
+ snapshot_policy_monthly,
+ "Monthly Snapshot policy creation failed"
+ )
+ #Creating expected and actual values dictionaries
+ expected_dict = {
+ "schedule":self.services["recurring_snapshot"]["schedule"],
+ "intervaltype":3,
+ "volumeid":volume_created.id
+ }
+ actual_dict = {
+ "schedule":snapshot_policy_monthly.schedule,
+ "intervaltype":snapshot_policy_monthly.intervaltype,
+ "volumeid":snapshot_policy_monthly.volumeid
+ }
+ status = self.__verify_values(
+ expected_dict,
+ actual_dict
+ )
+ self.assertEqual(
+ True,
+ status,
+ "Monthly Snapshot Policy details are not as expected"
+ )
+
+ list_snapshot_policy_after = SnapshotPolicy.list(self.userapiclient, volumeid=volume_created.id)
+
+ self.assertIsNotNone(
+ list_snapshot_policy_after,
+ "Monthly Snapshot policy creation failed"
+ )
+ self.assertEquals(
+ snapshot_policy_before_size + 1,
+ len(list_snapshot_policy_after),
+ "Monthly Snapshot policy creation failed"
+ )
+ # Deleting monthly snapshot policy
+ SnapshotPolicy.delete(snapshot_policy_monthly, self.userapiclient)
+
+ list_snapshot_policies = SnapshotPolicy.list(self.userapiclient, volumeid=volume_created.id)
+
+ self.assertIsNone(
+ list_snapshot_policies,
+ "Deletion of Monthly Snapshot policy failed"
+ )
+ return
+
+ @attr(tags=["advanced", "basic", "provisioning"])
+ def test_10_volume_snapshots_pagination(self):
+ """
+ @summary: Test to verify pagination of snapshots for Volume
+
+ Step1: Creating a Volume.
+ Step2: Attaching volume created in Step2 to virtual machine
+ Step3: Detaching the volume created in step2 from virtual machine
+ Step4: Listing all the snapshots for a volume
+ Step5: Creating Pagesize + 1 number of snapshots for a volume
+ Step6: Listing all the snapshots for a volume
+ Step7: Verifying that there are pagesize + 1 number of snapshots listsed
+ Step8: Listing all the snapshots in page 1
+ Step9: Listing all the snapshots in page 2
+ Step10: Deleting the snapshot present in page 2
+ Step11: Listign the snapshots from page 2 again and verifyign that list returns none
+ """
+ list_volumes_before = Volume.list(self.userapiclient, listall=self.services["listall"])
+
+ # Creating a Volume
+ volume_created = Volume.create(
+ self.userapiclient,
+ self.services["volume"],
+ zoneid=self.zone.id,
+ diskofferingid=self.disk_offering.id
+ )
+ self.assertIsNotNone(volume_created, "Volume not created")
+ self.cleanup.append(volume_created)
+
+ list_volumes_after = Volume.list(self.userapiclient, listall=self.services["listall"])
+
+ self.assertEquals(
+ len(list_volumes_before) + 1,
+ len(list_volumes_after),
+ "Volume not created"
+ )
+ #Attaching volume to virtual machine
+ self.virtual_machine.attach_volume(
+ self.userapiclient,
+ volume_created
+ )
+ list_volumes = Volume.list(
+ self.userapiclient,
+ listall=self.services["listall"],
+ id=volume_created.id
+ )
+ attached_volume = list_volumes[0]
+
+ self.assertIsNotNone(
+ attached_volume.vmname,
+ "VM is not attached to Volume"
+ )
+ self.assertEquals(
+ self.virtual_machine.name,
+ attached_volume.vmname,
+ "VM Name is not matching with attached vm"
+ )
+ #Detaching volume from virtual machine
+ self.virtual_machine.detach_volume(
+ self.userapiclient,
+ volume_created
+ )
+ list_volumes = Volume.list(
+ self.userapiclient,
+ listall=self.services["listall"],
+ id=volume_created.id
+ )
+ detached_volume = list_volumes[0]
+ self.assertIsNone(
+ detached_volume.vmname,
+ "VM is not detached from volume"
+ )
+
+ #Creating 3 Snapshots from volume
+ list_snapshot_before = Snapshot.list(
+ self.userapiclient,
+ volumeid=volume_created.id,
+ listall=self.services["listall"]
+ )
+ self.assertIsNone(
+ list_snapshot_before,
+ "Newly created volume is already having snapshots"
+ )
+
+ list_snapshot_before_size = 0
+ for i in range(0, 3):
+ snapshot_created = Snapshot.create(
+ self.userapiclient,
+ volume_created.id,
+ )
+ self.assertIsNotNone(snapshot_created, "Snapshot not created")
+ self.cleanup.append(snapshot_created)
+
+ self.assertEquals(
+ volume_created.id,
+ snapshot_created.volumeid,
+ "Snapshot not created for given volume"
+ )
+
+ list_snapshot_after = Snapshot.list(
+ self.userapiclient,
+ volumeid=volume_created.id,
+ listall=self.services["listall"]
+ )
+ self.assertEqual(
+ list_snapshot_before_size+3,
+ len(list_snapshot_after),
+ "Number of snapshots created is not matching expected"
+ )
+ #Listing all the snapshots in page1
+ list_snapshots_page1 = Snapshot.list(
+ self.userapiclient,
+ volumeid=volume_created.id,
+ listall=self.services["listall"],
+ page=1,
+ pagesize=2
+ )
+ self.assertEqual(
+ 2,
+ len(list_snapshots_page1),
+ "List snapshots response is not matching with the page size length for page 1"
+ )
+
+ #Listing all the snapshots in page2 and ensuring only 1 snapshot is present
+ list_snapshots_page2 = Snapshot.list(
+ self.userapiclient,
+ volumeid=volume_created.id,
+ listall=self.services["listall"],
+ page=2,
+ pagesize=2
+ )
+ self.assertEqual(
+ len(list_snapshots_page2),
+ 1,
+ "List snapshots response is not matching with the page size length for page 2"
+ )
+ snapshot_page2 = list_snapshots_page2[0]
+
+ # Verifying that the snapshot on page 2 is not present in page1
+ for i in range(0, len(list_snapshots_page1)):
+ snapshot_page1 = list_snapshots_page1[i]
+ self.assertNotEquals(
+ snapshot_page2.id,
+ snapshot_page1.id,
+ "Snapshot listed in page 2 is also listed in page 1"
+ )
+ # Deleting a single snapshot and verifying that snapshot does not exists on page 2
+ Snapshot.delete(snapshot_created, self.userapiclient)
+
+ list_snapshot_page2 = Snapshot.list(
+ self.userapiclient,
+ volumeid=volume_created.id,
+ listall=self.services["listall"],
+ page=2,
+ pagesize=2
+ )
+ self.assertEqual(
+ None,
+ list_snapshot_page2,
+ "Snapshot was not deleted"
+ )
+ list_snapshot_page1 = Snapshot.list(
+ self.userapiclient,
+ volumeid=volume_created.id,
+ listall=self.services["listall"],
+ page=1,
+ pagesize=2
+ )
+ self.assertEqual(
+ 2,
+ len(list_snapshot_page1),
+ "Snapshots on page 1 are not matching"
+ )
+ return
+
+ @attr(tags=["advanced", "basic", "provisioning"])
+ def test_11_volume_extract(self):
+ """
+ @summary: Test to verify extract/download a Volume
+
+ Step1: Listing Volumes before creating a Volume
+ Step2: Creating a Volume.
+ Step3: Verifying that created volume is not none and adding to clean up
+ Step4: Listing the volumes after creation
+ Step5: Verifying that the list volume size is increased by 1
+ Step6: Attaching volume created in Step2 to virtual machine
+ Step7: Detaching the volume created in step2 from virtual machine
+ Step8: Extracting/Downloadign the volume
+ Step9: Verifyign that a download URL is created for volume download
+ """
+ list_volumes_before = Volume.list(self.userapiclient, listall=self.services["listall"])
+
+ self.assertIsNotNone(
+ list_volumes_before,
+ "volume not created for the vm launched at class level"
+ )
+ volume_created = Volume.create(
+ self.userapiclient,
+ self.services["volume"],
+ zoneid=self.zone.id,
+ diskofferingid=self.disk_offering.id
+ )
+
+ self.assertIsNotNone(volume_created, "Volume not created")
+ self.cleanup.append(volume_created)
+
+ list_volumes_after = Volume.list(self.userapiclient, listall=self.services["listall"])
+
+ self.assertIsNotNone(
+ list_volumes_after,
+ "volume creation failed"
+ )
+ self.assertEquals(
+ len(list_volumes_before) + 1,
+ len(list_volumes_after),
+ "Volume not created"
+ )
+ #Attaching and Detaching volume created to Virtual Machine
+ self.virtual_machine.attach_volume(
+ self.userapiclient,
+ volume_created
+ )
+ list_volumes = Volume.list(
+ self.userapiclient,
+ listall=self.services["listall"],
+ id=volume_created.id
+ )
+ attached_volume = list_volumes[0]
+
+ self.assertIsNotNone(
+ attached_volume.vmname,
+ "VM is not attached to Volume"
+ )
+ self.assertEquals(
+ self.virtual_machine.name,
+ attached_volume.vmname,
+ "VM Name is not matching with attached vm"
+ )
+ self.virtual_machine.detach_volume(
+ self.userapiclient,
+ volume_created
+ )
+ list_volumes = Volume.list(
+ self.userapiclient,
+ listall=self.services["listall"],
+ id=volume_created.id
+ )
+ detached_volume = list_volumes[0]
+ self.assertIsNone(
+ detached_volume.vmname,
+ "VM is not detached from volume"
+ )
+ #Extract/Download the volume
+ self.services["mode"] = "HTTP_DOWNLOAD"
+
+ extract_volume_response = Volume.extract(
+ self.userapiclient,
+ volume_created.id,
+ self.zone.id,
+ self.services["mode"]
+ )
+ self.assertIsNotNone(extract_volume_response, "Extract/Download volume failed")
+
+ self.assertEquals(
+ "DOWNLOAD_URL_CREATED",
+ extract_volume_response.state,
+ "Failed to create Download URL"
+ )
+ self.assertIsNotNone(
+ extract_volume_response.url,
+ "Extract/Download volume URL is NULL"
+ )
+ self.assertTrue(
+ (extract_volume_response.url.find("https://")!=-1),
+ "Extract/Download volume URL doesnot contain https://"
+ )
+ self.assertEquals(
+ volume_created.id,
+ extract_volume_response.id,
+ "Extracted/Downloaded volume is not matching with original volume"
+ )
+ return
+
+ @attr(tags=["advanced", "basic", "provisioning"])
+ def test_12_volume_upload(self):
+ """
+ @summary: Test to verify upload volume
+
+ Step1: Listing the volumes for a user before uploading volume
+ Step2: Uploading a volume
+ Step3: Listing the volumes for a user after uploading data volume
+ Step4: Verifying that the list volume length after upload is increased by 1
+ """
+ list_volumes_before = Volume.list(self.userapiclient, listall=self.services["listall"])
+
+ self.assertIsNotNone(
+ list_volumes_before,
+ "volume not created for the vm launched at class level"
+ )
+ #Uploading a Volume
+ volume_uploaded = Volume.upload(
+ self.userapiclient,
+ self.services["upload_volume"],
+ self.zone.id
+ )
+ self.assertIsNotNone(volume_uploaded, "volume uploading failed")
+
+ self.assertEquals(
+ self.services["upload_volume"]["diskname"],
+ volume_uploaded.name,
+ "Uploaded volume name is not matching with name provided while uploading")
+
+ #Listing the volumes for a user after uploading data volume
+ list_volumes_after = Volume.list(self.userapiclient, listall=self.services["listall"])
+
+ self.assertIsNotNone(
+ list_volumes_after,
+ "volume not created for the vm launched at class level"
+ )
+ #Asserting that the list volume length after upload is increased by 1
+ self.assertEquals(
+ len(list_volumes_before) + 1,
+ len(list_volumes_after),
+ "upload volume failed"
+ )
+ return
+
+class TestListInstances(cloudstackTestCase):
+
+ @classmethod
+ def setUpClass(cls):
+ try:
+ cls._cleanup = []
+ cls.testClient = super(TestListInstances, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+ cls.services = cls.testClient.getParsedTestDataConfig()
+
+ # Get Domain, Zone, Template
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client)
+ cls.template = get_template(
+ cls.api_client,
+ cls.zone.id,
+ cls.services["ostype"]
+ )
+ if cls.zone.localstorageenabled:
+ cls.storagetype = 'local'
+ cls.services["service_offerings"]["tiny"]["storagetype"] = 'local'
+ cls.services["disk_offering"]["storagetype"] = 'local'
+ else:
+ cls.storagetype = 'shared'
+ cls.services["service_offerings"]["tiny"]["storagetype"] = 'shared'
+ cls.services["disk_offering"]["storagetype"] = 'shared'
+
+ cls.services['mode'] = cls.zone.networktype
+ cls.services["virtual_machine"]["hypervisor"] = cls.testClient.getHypervisorInfo()
+ cls.services["virtual_machine"]["zoneid"] = cls.zone.id
+ cls.services["virtual_machine"]["template"] = cls.template.id
+ cls.services["custom_volume"]["zoneid"] = cls.zone.id
+
+ # Creating Disk offering, Service Offering and Account
+ cls.disk_offering = DiskOffering.create(
+ cls.api_client,
+ cls.services["disk_offering"]
+ )
+ cls._cleanup.append(cls.disk_offering)
+ cls.service_offering = ServiceOffering.create(
+ cls.api_client,
+ cls.services["service_offerings"]["tiny"]
+ )
+ cls._cleanup.append(cls.service_offering)
+ cls.account = Account.create(
+ cls.api_client,
+ cls.services["account"],
+ domainid=cls.domain.id
+ )
+ # Getting authentication for user in newly created Account
+ cls.user = cls.account.user[0]
+ cls.userapiclient = cls.testClient.getUserApiClient(cls.user.username, cls.domain.name)
+ # Updating resource Limits
+ for i in range(0,12):
+ Resources.updateLimit(
+ cls.api_client,
+ account=cls.account.name,
+ domainid=cls.domain.id,
+ max=-1,
+ resourcetype=i
+ )
+
+ cls._cleanup.append(cls.account)
+ except Exception as e:
+ cls.tearDownClass()
+ raise Exception("Warning: Exception in setup : %s" % e)
+ return
+
+ def setUp(self):
+
+ self.apiClient = self.testClient.getApiClient()
+ self.cleanup = []
+
+ def tearDown(self):
+ #Clean up, terminate the created resources
+ cleanup_resources(self.apiClient, self.cleanup)
+ return
+
+ @classmethod
+ def tearDownClass(cls):
+ try:
+ cleanup_resources(cls.api_client, cls._cleanup)
+ except Exception as e:
+ raise Exception("Warning: Exception during cleanup : %s" % e)
+
+ return
+
+ def __verify_values(self, expected_vals, actual_vals):
+ """
+ @Desc: Function to verify expected and actual values
+ @Steps:
+ Step1: Initializing return flag to True
+ Step1: Verifying length of expected and actual dictionaries is matching.
+ If not matching returning false
+ Step2: Listing all the keys from expected dictionary
+ Step3: Looping through each key from step2 and verifying expected and actual dictionaries have same value
+ If not making return flag to False
+ Step4: returning the return flag after all the values are verified
+ """
+ return_flag = True
+
+ if len(expected_vals) != len(actual_vals):
+ return False
+
+ keys = expected_vals.keys()
+ for i in range(0, len(expected_vals)):
+ exp_val = expected_vals[keys[i]]
+ act_val = actual_vals[keys[i]]
+ if exp_val == act_val:
+ return_flag = return_flag and True
+ else:
+ return_flag = return_flag and False
+ self.debug("expected Value: %s, is not matching with actual value: %s" % (
+ exp_val,
+ act_val
+ ))
+ return return_flag
+
+ @attr(tags=["advanced", "basic", "selfservice"])
+ def test_01_list_instances_pagination(self):
+ """
+ @Desc: Test List Instances pagination
+ @Steps:
+ Step1: Listing all the Instances for a user
+ Step2: Verifying listed Instances for account created at class level
+ Step3: If number of volumes is less than (page size + 1), then creating them
+ Step4: Listing all the volumes again after creation of volumes
+ Step5: Verifying the length of the volumes is (page size + 1)
+ Step6: Listing all the volumes in page1
+ Step7: Verifying that the length of the volumes in page 1 is (page size)
+ Step8: Listing all the volumes in page2
+ Step9: Verifying that the length of the volumes in page 2 is 1
+ Step10: Deleting the volume present in page 2
+ Step11: Listing for the volumes on page 2
+ Step12: Verifying that there are no volumes present in page 2
+ """
+ # Listing all the instances for a user
+ list_instances_before = VirtualMachine.list(self.userapiclient, listall=self.services["listall"])
+
+ # Verifying listed instances for account created at class level
+ self.assertIsNone(
+ list_instances_before,
+ "Virtual Machine already exists for newly created user"
+ )
+ # If number of instances are less than (pagesize + 1), then creating them
+ for i in range(0, (self.services["pagesize"] + 1)):
+ vm_created = VirtualMachine.create(
+ self.userapiclient,
+ self.services["virtual_machine"],
+ accountid=self.account.name,
+ domainid=self.account.domainid,
+ serviceofferingid=self.service_offering.id,
+ )
+ self.assertIsNotNone(
+ vm_created,
+ "VM creation failed"
+ )
+ if(i < (self.services["pagesize"])):
+ self.cleanup.append(vm_created)
+
+ self.assertEqual(
+ self.services["virtual_machine"]["displayname"],
+ vm_created.displayname,
+ "Newly created VM name and the test data VM name are not matching"
+ )
+
+ # Listing all the instances again after creating VM's
+ list_instances_after = VirtualMachine.list(self.userapiclient, listall=self.services["listall"])
+ status = validateList(list_instances_after)
+ self.assertEqua
<TRUNCATED>
[12/18] Marvin + test changes from master Signed-off-by:
SrikanteswaraRao Talluri
Posted by da...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/component/test_vpc_network.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_vpc_network.py b/test/integration/component/test_vpc_network.py
index 6f280b8..2924b72 100644
--- a/test/integration/component/test_vpc_network.py
+++ b/test/integration/component/test_vpc_network.py
@@ -21,8 +21,8 @@
from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import cloudstackTestCase, unittest
from marvin.cloudstackAPI import startVirtualMachine, stopVirtualMachine
-from marvin.integration.lib.utils import cleanup_resources, validateList
-from marvin.integration.lib.base import (VirtualMachine,
+from marvin.lib.utils import cleanup_resources, validateList
+from marvin.lib.base import (VirtualMachine,
ServiceOffering,
Account,
NATRule,
@@ -35,7 +35,7 @@ from marvin.integration.lib.base import (VirtualMachine,
StaticNATRule,
NetworkACL,
PublicIPAddress)
-from marvin.integration.lib.common import (get_zone,
+from marvin.lib.common import (get_zone,
get_domain,
get_template,
wait_for_cleanup,
@@ -239,17 +239,17 @@ class TestVPCNetwork(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(
- TestVPCNetwork,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestVPCNetwork, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
+
# Added an attribute to track if Netscaler addition was successful.
# Value is checked in tests and if not configured, Netscaler tests will be skipped
cls.ns_configured = False
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.template = get_template(
cls.api_client,
cls.zone.id,
@@ -1003,17 +1003,17 @@ class TestVPCNetworkRanges(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(
- TestVPCNetworkRanges,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestVPCNetworkRanges, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
+
# Added an attribute to track if Netscaler addition was successful.
# Value is checked in tests and if not configured, Netscaler tests will be skipped
cls.ns_configured = False
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.template = get_template(
cls.api_client,
cls.zone.id,
@@ -1541,14 +1541,14 @@ class TestVPCNetworkUpgrade(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(
- TestVPCNetworkUpgrade,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestVPCNetworkUpgrade, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
+
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.template = get_template(
cls.api_client,
cls.zone.id,
@@ -2123,14 +2123,14 @@ class TestVPCNetworkGc(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(
- TestVPCNetworkGc,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestVPCNetworkGc, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
+
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.template = get_template(
cls.api_client,
cls.zone.id,
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/component/test_vpc_network_lbrules.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_vpc_network_lbrules.py b/test/integration/component/test_vpc_network_lbrules.py
index 9d75550..a5625e7 100644
--- a/test/integration/component/test_vpc_network_lbrules.py
+++ b/test/integration/component/test_vpc_network_lbrules.py
@@ -20,7 +20,7 @@
#Import Local Modules
from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import cloudstackTestCase, unittest
-from marvin.integration.lib.base import (stopRouter,
+from marvin.lib.base import (stopRouter,
startRouter,
Account,
VpcOffering,
@@ -34,11 +34,11 @@ from marvin.integration.lib.base import (stopRouter,
VirtualMachine,
LoadBalancerRule,
StaticNATRule)
-from marvin.integration.lib.common import (get_domain,
+from marvin.lib.common import (get_domain,
get_zone,
get_template,
list_routers)
-from marvin.integration.lib.utils import cleanup_resources
+from marvin.lib.utils import cleanup_resources
import socket
import time
@@ -181,14 +181,13 @@ class TestVPCNetworkLBRules(cloudstackTestCase):
# We want to fail quicker if it's failure
socket.setdefaulttimeout(60)
- cls.api_client = super(
- TestVPCNetworkLBRules,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestVPCNetworkLBRules, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.template = get_template(
cls.api_client,
cls.zone.id,
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/component/test_vpc_network_pfrules.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_vpc_network_pfrules.py b/test/integration/component/test_vpc_network_pfrules.py
index e5bb158..31e7320 100644
--- a/test/integration/component/test_vpc_network_pfrules.py
+++ b/test/integration/component/test_vpc_network_pfrules.py
@@ -19,7 +19,7 @@
"""
from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import cloudstackTestCase, unittest
-from marvin.integration.lib.base import (stopRouter,
+from marvin.lib.base import (stopRouter,
startRouter,
Account,
VpcOffering,
@@ -32,11 +32,11 @@ from marvin.integration.lib.base import (stopRouter,
Network,
VirtualMachine,
LoadBalancerRule)
-from marvin.integration.lib.common import (get_domain,
+from marvin.lib.common import (get_domain,
get_zone,
get_template,
list_routers)
-from marvin.integration.lib.utils import cleanup_resources
+from marvin.lib.utils import cleanup_resources
import socket
import time
@@ -182,14 +182,13 @@ class TestVPCNetworkPFRules(cloudstackTestCase):
# We want to fail quicker if it's failure
socket.setdefaulttimeout(60)
- cls.api_client = super(
- TestVPCNetworkPFRules,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestVPCNetworkPFRules, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.template = get_template(
cls.api_client,
cls.zone.id,
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/component/test_vpc_network_staticnatrule.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_vpc_network_staticnatrule.py b/test/integration/component/test_vpc_network_staticnatrule.py
index ddc3c4c..65cb044 100644
--- a/test/integration/component/test_vpc_network_staticnatrule.py
+++ b/test/integration/component/test_vpc_network_staticnatrule.py
@@ -19,7 +19,7 @@
"""
from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import cloudstackTestCase, unittest
-from marvin.integration.lib.base import (Account,
+from marvin.lib.base import (Account,
VpcOffering,
VPC,
ServiceOffering,
@@ -32,11 +32,11 @@ from marvin.integration.lib.base import (Account,
StaticNATRule)
from marvin.cloudstackAPI import (stopRouter,
startRouter)
-from marvin.integration.lib.common import (get_domain,
+from marvin.lib.common import (get_domain,
get_zone,
get_template,
list_routers)
-from marvin.integration.lib.utils import cleanup_resources
+from marvin.lib.utils import cleanup_resources
import socket
import time
@@ -182,14 +182,13 @@ class TestVPCNetworkPFRules(cloudstackTestCase):
# We want to fail quicker if it's failure
socket.setdefaulttimeout(60)
- cls.api_client = super(
- TestVPCNetworkPFRules,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestVPCNetworkPFRules, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.template = get_template(
cls.api_client,
cls.zone.id,
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/component/test_vpc_offerings.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_vpc_offerings.py b/test/integration/component/test_vpc_offerings.py
index 9e3064b..f190773 100644
--- a/test/integration/component/test_vpc_offerings.py
+++ b/test/integration/component/test_vpc_offerings.py
@@ -23,9 +23,9 @@ import marvin
from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
from marvin.sshClient import SshClient
import datetime
@@ -137,14 +137,13 @@ class TestVPCOffering(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(
- TestVPCOffering,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestVPCOffering, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.template = get_template(
cls.api_client,
cls.zone.id,
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/component/test_vpc_routers.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_vpc_routers.py b/test/integration/component/test_vpc_routers.py
index fb5aed5..3cf537a 100644
--- a/test/integration/component/test_vpc_routers.py
+++ b/test/integration/component/test_vpc_routers.py
@@ -22,9 +22,9 @@ import marvin
from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
import datetime
@@ -169,16 +169,15 @@ class TestVPCRoutersBasic(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.apiclient = super(
- TestVPCRoutersBasic,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestVPCRoutersBasic, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.apiclient, cls.services)
- cls.zone = get_zone(cls.apiclient, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.template = get_template(
- cls.apiclient,
+ cls.api_client,
cls.zone.id,
cls.services["ostype"]
)
@@ -186,16 +185,16 @@ class TestVPCRoutersBasic(cloudstackTestCase):
cls.services["virtual_machine"]["template"] = cls.template.id
cls.service_offering = ServiceOffering.create(
- cls.apiclient,
+ cls.api_client,
cls.services["service_offering"]
)
cls.vpc_off = VpcOffering.create(
- cls.apiclient,
+ cls.api_client,
cls.services["vpc_offering"]
)
- cls.vpc_off.update(cls.apiclient, state='Enabled')
+ cls.vpc_off.update(cls.api_client, state='Enabled')
cls.account = Account.create(
- cls.apiclient,
+ cls.api_client,
cls.services["account"],
admin=True,
domainid=cls.domain.id
@@ -203,13 +202,13 @@ class TestVPCRoutersBasic(cloudstackTestCase):
cls._cleanup = [cls.account]
cls._cleanup.append(cls.vpc_off)
#cls.debug("Enabling the VPC offering created")
- cls.vpc_off.update(cls.apiclient, state='Enabled')
+ cls.vpc_off.update(cls.api_client, state='Enabled')
#cls.debug("creating a VPC network in the account: %s" %
# cls.account.name)
cls.services["vpc"]["cidr"] = '10.1.1.1/16'
cls.vpc = VPC.create(
- cls.apiclient,
+ cls.api_client,
cls.services["vpc"],
vpcofferingid=cls.vpc_off.id,
zoneid=cls.zone.id,
@@ -224,13 +223,13 @@ class TestVPCRoutersBasic(cloudstackTestCase):
def tearDownClass(cls):
try:
#Cleanup resources used
- cleanup_resources(cls.apiclient, cls._cleanup)
+ cleanup_resources(cls.api_client, cls._cleanup)
except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e)
return
def setUp(self):
- self.apiclient = self.testClient.getApiClient()
+ self.api_client = self.testClient.getApiClient()
return
@@ -242,7 +241,7 @@ class TestVPCRoutersBasic(cloudstackTestCase):
self.debug("Check if the VPC offering is created successfully?")
vpc_offs = VpcOffering.list(
- self.apiclient,
+ self.api_client,
id=vpc_offering.id
)
self.assertEqual(
@@ -265,7 +264,7 @@ class TestVPCRoutersBasic(cloudstackTestCase):
self.debug("Check if the VPC network is created successfully?")
vpc_networks = VPC.list(
- self.apiclient,
+ self.api_client,
id=network.id
)
self.assertEqual(
@@ -291,7 +290,7 @@ class TestVPCRoutersBasic(cloudstackTestCase):
""" Migrate the router """
self.debug("Checking if the host is available for migration?")
- hosts = Host.list(self.apiclient, zoneid=self.zone.id, type='Routing')
+ hosts = Host.list(self.api_client, zoneid=self.zone.id, type='Routing')
self.assertEqual(
isinstance(hosts, list),
@@ -319,7 +318,7 @@ class TestVPCRoutersBasic(cloudstackTestCase):
cmd.isAsync = "false"
cmd.hostid = host.id
cmd.virtualmachineid = router.id
- self.apiclient.migrateSystemVm(cmd)
+ self.api_client.migrateSystemVm(cmd)
except Exception as e:
self.fail("Failed to migrate instance, %s" % e)
@@ -329,7 +328,7 @@ class TestVPCRoutersBasic(cloudstackTestCase):
#List routers to check state of router
router_response = list_routers(
- self.apiclient,
+ self.api_client,
id=router.id
)
self.assertEqual(
@@ -358,7 +357,7 @@ class TestVPCRoutersBasic(cloudstackTestCase):
# Stop the VPC Router
routers = Router.list(
- self.apiclient,
+ self.api_client,
account=self.account.name,
domainid=self.account.domainid,
listall=True
@@ -374,11 +373,11 @@ class TestVPCRoutersBasic(cloudstackTestCase):
#Stop the router
cmd = stopRouter.stopRouterCmd()
cmd.id = router.id
- self.apiclient.stopRouter(cmd)
+ self.api_client.stopRouter(cmd)
#List routers to check state of router
router_response = list_routers(
- self.apiclient,
+ self.api_client,
id=router.id
)
self.assertEqual(
@@ -399,11 +398,11 @@ class TestVPCRoutersBasic(cloudstackTestCase):
self.debug("Starting the router with ID: %s" % router.id)
cmd = startRouter.startRouterCmd()
cmd.id = router.id
- self.apiclient.startRouter(cmd)
+ self.api_client.startRouter(cmd)
#List routers to check state of router
router_response = list_routers(
- self.apiclient,
+ self.api_client,
id=router.id
)
self.assertEqual(
@@ -433,7 +432,7 @@ class TestVPCRoutersBasic(cloudstackTestCase):
self.validate_vpc_offering(self.vpc_off)
self.validate_vpc_network(self.vpc)
routers = Router.list(
- self.apiclient,
+ self.api_client,
account=self.account.name,
domainid=self.account.domainid,
listall=True
@@ -449,11 +448,11 @@ class TestVPCRoutersBasic(cloudstackTestCase):
#Reboot the router
cmd = rebootRouter.rebootRouterCmd()
cmd.id = router.id
- self.apiclient.rebootRouter(cmd)
+ self.api_client.rebootRouter(cmd)
#List routers to check state of router
router_response = list_routers(
- self.apiclient,
+ self.api_client,
id=router.id
)
self.assertEqual(
@@ -478,7 +477,7 @@ class TestVPCRoutersBasic(cloudstackTestCase):
self.validate_vpc_network(self.vpc)
routers = Router.list(
- self.apiclient,
+ self.api_client,
account=self.account.name,
domainid=self.account.domainid,
listall=True
@@ -505,7 +504,7 @@ class TestVPCRoutersBasic(cloudstackTestCase):
self.validate_vpc_network(self.vpc)
routers = Router.list(
- self.apiclient,
+ self.api_client,
account=self.account.name,
domainid=self.account.domainid,
listall=True
@@ -521,15 +520,15 @@ class TestVPCRoutersBasic(cloudstackTestCase):
self.debug("Stopping the router with ID: %s" % router.id)
cmd = stopRouter.stopRouterCmd()
cmd.id = router.id
- self.apiclient.stopRouter(cmd)
+ self.api_client.stopRouter(cmd)
service_offering = ServiceOffering.create(
- self.apiclient,
+ self.api_client,
self.services["service_offering_new"]
)
self.debug("Changing service offering for the Router %s" % router.id)
try:
- router = Router.change_service_offering(self.apiclient,
+ router = Router.change_service_offering(self.api_client,
router.id,
service_offering.id
)
@@ -538,7 +537,7 @@ class TestVPCRoutersBasic(cloudstackTestCase):
self.debug("Router %s" % router)
routers = Router.list(
- self.apiclient,
+ self.api_client,
account=self.account.name,
domainid=self.account.domainid,
listall=True
@@ -562,7 +561,7 @@ class TestVPCRoutersBasic(cloudstackTestCase):
self.validate_vpc_offering(self.vpc_off)
self.validate_vpc_network(self.vpc)
routers = Router.list(
- self.apiclient,
+ self.api_client,
account=self.account.name,
domainid=self.account.domainid,
listall=True
@@ -573,12 +572,12 @@ class TestVPCRoutersBasic(cloudstackTestCase):
"List Routers should return a valid list"
)
- Router.destroy( self.apiclient,
+ Router.destroy( self.api_client,
id=routers[0].id
)
routers = Router.list(
- self.apiclient,
+ self.api_client,
account=self.account.name,
domainid=self.account.domainid,
listall=True
@@ -594,17 +593,16 @@ class TestVPCRouterOneNetwork(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.apiclient = super(
- TestVPCRouterOneNetwork,
- cls
- ).getClsTestClient().getApiClient()
cls._cleanup = []
+ cls.testClient = super(TestVPCRouterOneNetwork, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.apiclient, cls.services)
- cls.zone = get_zone(cls.apiclient, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.template = get_template(
- cls.apiclient,
+ cls.api_client,
cls.zone.id,
cls.services["ostype"]
)
@@ -612,19 +610,19 @@ class TestVPCRouterOneNetwork(cloudstackTestCase):
cls.services["virtual_machine"]["template"] = cls.template.id
cls.service_offering = ServiceOffering.create(
- cls.apiclient,
+ cls.api_client,
cls.services["service_offering"]
)
cls._cleanup.append(cls.service_offering)
cls.vpc_off = VpcOffering.create(
- cls.apiclient,
+ cls.api_client,
cls.services["vpc_offering"]
)
- cls.vpc_off.update(cls.apiclient, state='Enabled')
+ cls.vpc_off.update(cls.api_client, state='Enabled')
cls._cleanup.append(cls.vpc_off)
cls.account = Account.create(
- cls.apiclient,
+ cls.api_client,
cls.services["account"],
admin=True,
domainid=cls.domain.id
@@ -633,7 +631,7 @@ class TestVPCRouterOneNetwork(cloudstackTestCase):
cls.services["vpc"]["cidr"] = '10.1.1.1/16'
cls.vpc = VPC.create(
- cls.apiclient,
+ cls.api_client,
cls.services["vpc"],
vpcofferingid=cls.vpc_off.id,
zoneid=cls.zone.id,
@@ -642,7 +640,7 @@ class TestVPCRouterOneNetwork(cloudstackTestCase):
)
private_gateway = PrivateGateway.create(
- cls.apiclient,
+ cls.api_client,
gateway='10.1.3.1',
ipaddress='10.1.3.100',
netmask='255.255.255.0',
@@ -650,34 +648,34 @@ class TestVPCRouterOneNetwork(cloudstackTestCase):
vpcid=cls.vpc.id
)
cls.gateways = PrivateGateway.list(
- cls.apiclient,
+ cls.api_client,
id=private_gateway.id,
listall=True
)
static_route = StaticRoute.create(
- cls.apiclient,
+ cls.api_client,
cidr='11.1.1.1/24',
gatewayid=private_gateway.id
)
cls.static_routes = StaticRoute.list(
- cls.apiclient,
+ cls.api_client,
id=static_route.id,
listall=True
)
cls.nw_off = NetworkOffering.create(
- cls.apiclient,
+ cls.api_client,
cls.services["network_offering"],
conservemode=False
)
# Enable Network offering
- cls.nw_off.update(cls.apiclient, state='Enabled')
+ cls.nw_off.update(cls.api_client, state='Enabled')
cls._cleanup.append(cls.nw_off)
# Creating network using the network offering created
cls.network_1 = Network.create(
- cls.apiclient,
+ cls.api_client,
cls.services["network"],
accountid=cls.account.name,
domainid=cls.account.domainid,
@@ -689,7 +687,7 @@ class TestVPCRouterOneNetwork(cloudstackTestCase):
# Spawn an instance in that network
vm_1 = VirtualMachine.create(
- cls.apiclient,
+ cls.api_client,
cls.services["virtual_machine"],
accountid=cls.account.name,
domainid=cls.account.domainid,
@@ -697,7 +695,7 @@ class TestVPCRouterOneNetwork(cloudstackTestCase):
networkids=[str(cls.network_1.id)]
)
vm_2 = VirtualMachine.create(
- cls.apiclient,
+ cls.api_client,
cls.services["virtual_machine"],
accountid=cls.account.name,
domainid=cls.account.domainid,
@@ -707,7 +705,7 @@ class TestVPCRouterOneNetwork(cloudstackTestCase):
# Spawn an instance in that network
vm_3 = VirtualMachine.create(
- cls.apiclient,
+ cls.api_client,
cls.services["virtual_machine"],
accountid=cls.account.name,
domainid=cls.account.domainid,
@@ -716,14 +714,14 @@ class TestVPCRouterOneNetwork(cloudstackTestCase):
)
vms = VirtualMachine.list(
- cls.apiclient,
+ cls.api_client,
account=cls.account.name,
domainid=cls.account.domainid,
listall=True
)
public_ip_1 = PublicIPAddress.create(
- cls.apiclient,
+ cls.api_client,
accountid=cls.account.name,
zoneid=cls.zone.id,
domainid=cls.account.domainid,
@@ -732,7 +730,7 @@ class TestVPCRouterOneNetwork(cloudstackTestCase):
)
nat_rule = NATRule.create(
- cls.apiclient,
+ cls.api_client,
vm_1,
cls.services["natrule"],
ipaddressid=public_ip_1.ipaddress.id,
@@ -742,14 +740,14 @@ class TestVPCRouterOneNetwork(cloudstackTestCase):
)
nwacl_nat = NetworkACL.create(
- cls.apiclient,
+ cls.api_client,
networkid=cls.network_1.id,
services=cls.services["natrule"],
traffictype='Ingress'
)
public_ip_2 = PublicIPAddress.create(
- cls.apiclient,
+ cls.api_client,
accountid=cls.account.name,
zoneid=cls.zone.id,
domainid=cls.account.domainid,
@@ -758,7 +756,7 @@ class TestVPCRouterOneNetwork(cloudstackTestCase):
)
try:
StaticNATRule.enable(
- cls.apiclient,
+ cls.api_client,
ipaddressid=public_ip_2.ipaddress.id,
virtualmachineid=vm_2.id,
networkid=cls.network_1.id
@@ -768,7 +766,7 @@ class TestVPCRouterOneNetwork(cloudstackTestCase):
public_ip_2.ipaddress.ipaddress, e))
public_ips = PublicIPAddress.list(
- cls.apiclient,
+ cls.api_client,
networkid=cls.network_1.id,
listall=True,
isstaticnat=True,
@@ -776,7 +774,7 @@ class TestVPCRouterOneNetwork(cloudstackTestCase):
domainid=cls.account.domainid
)
public_ip_3 = PublicIPAddress.create(
- cls.apiclient,
+ cls.api_client,
accountid=cls.account.name,
zoneid=cls.zone.id,
domainid=cls.account.domainid,
@@ -785,7 +783,7 @@ class TestVPCRouterOneNetwork(cloudstackTestCase):
)
lb_rule = LoadBalancerRule.create(
- cls.apiclient,
+ cls.api_client,
cls.services["lbrule"],
ipaddressid=public_ip_3.ipaddress.id,
accountid=cls.account.name,
@@ -794,17 +792,17 @@ class TestVPCRouterOneNetwork(cloudstackTestCase):
domainid=cls.account.domainid
)
- lb_rule.assign(cls.apiclient, [vm_3])
+ lb_rule.assign(cls.api_client, [vm_3])
nwacl_lb = NetworkACL.create(
- cls.apiclient,
+ cls.api_client,
networkid=cls.network_1.id,
services=cls.services["lbrule"],
traffictype='Ingress'
)
nwacl_internet_1 = NetworkACL.create(
- cls.apiclient,
+ cls.api_client,
networkid=cls.network_1.id,
services=cls.services["http_rule"],
traffictype='Egress'
@@ -814,20 +812,20 @@ class TestVPCRouterOneNetwork(cloudstackTestCase):
def tearDownClass(cls):
try:
#Cleanup resources used
- cleanup_resources(cls.apiclient, cls._cleanup)
+ cleanup_resources(cls.api_client, cls._cleanup)
except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e)
return
def setUp(self):
- self.apiclient = self.testClient.getApiClient()
+ self.api_client = self.testClient.getApiClient()
self.cleanup = []
return
def tearDown(self):
try:
#Clean up, terminate the created network offerings
- cleanup_resources(self.apiclient, self.cleanup)
+ cleanup_resources(self.api_client, self.cleanup)
except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e)
@@ -838,7 +836,7 @@ class TestVPCRouterOneNetwork(cloudstackTestCase):
self.debug("Check if the VPC offering is created successfully?")
vpc_offs = VpcOffering.list(
- self.apiclient,
+ self.api_client,
id=vpc_offering.id
)
self.assertEqual(
@@ -861,7 +859,7 @@ class TestVPCRouterOneNetwork(cloudstackTestCase):
self.debug("Check if the VPC network is created successfully?")
vpc_networks = VPC.list(
- self.apiclient,
+ self.api_client,
id=network.id
)
self.assertEqual(
@@ -887,13 +885,13 @@ class TestVPCRouterOneNetwork(cloudstackTestCase):
""" Validate network rules
"""
vms = VirtualMachine.list(
- self.apiclient,
+ self.api_client,
account=self.account.name,
domainid=self.account.domainid,
listall=True
)
public_ips = PublicIPAddress.list(
- self.apiclient,
+ self.api_client,
account=self.account.name,
domainid=self.account.domainid,
listall=True
@@ -927,7 +925,7 @@ class TestVPCRouterOneNetwork(cloudstackTestCase):
""" Migrate the router """
self.debug("Checking if the host is available for migration?")
- hosts = Host.list(self.apiclient, zoneid=self.zone.id, type='Routing')
+ hosts = Host.list(self.api_client, zoneid=self.zone.id, type='Routing')
self.assertEqual(
isinstance(hosts, list),
@@ -955,7 +953,7 @@ class TestVPCRouterOneNetwork(cloudstackTestCase):
cmd.isAsync = "false"
cmd.hostid = host.id
cmd.virtualmachineid = router.id
- self.apiclient.migrateSystemVm(cmd)
+ self.api_client.migrateSystemVm(cmd)
except Exception as e:
self.fail("Failed to migrate instance, %s" % e)
@@ -965,7 +963,7 @@ class TestVPCRouterOneNetwork(cloudstackTestCase):
#List routers to check state of router
router_response = list_routers(
- self.apiclient,
+ self.api_client,
id=router.id
)
self.assertEqual(
@@ -1012,7 +1010,7 @@ class TestVPCRouterOneNetwork(cloudstackTestCase):
# Stop the VPC Router
routers = Router.list(
- self.apiclient,
+ self.api_client,
account=self.account.name,
domainid=self.account.domainid,
listall=True
@@ -1028,11 +1026,11 @@ class TestVPCRouterOneNetwork(cloudstackTestCase):
#Stop the router
cmd = stopRouter.stopRouterCmd()
cmd.id = router.id
- self.apiclient.stopRouter(cmd)
+ self.api_client.stopRouter(cmd)
#List routers to check state of router
router_response = list_routers(
- self.apiclient,
+ self.api_client,
id=router.id
)
self.assertEqual(
@@ -1053,11 +1051,11 @@ class TestVPCRouterOneNetwork(cloudstackTestCase):
self.debug("Starting the router with ID: %s" % router.id)
cmd = startRouter.startRouterCmd()
cmd.id = router.id
- self.apiclient.startRouter(cmd)
+ self.api_client.startRouter(cmd)
#List routers to check state of router
router_response = list_routers(
- self.apiclient,
+ self.api_client,
id=router.id
)
self.assertEqual(
@@ -1106,7 +1104,7 @@ class TestVPCRouterOneNetwork(cloudstackTestCase):
)
routers = Router.list(
- self.apiclient,
+ self.api_client,
account=self.account.name,
domainid=self.account.domainid,
listall=True
@@ -1122,11 +1120,11 @@ class TestVPCRouterOneNetwork(cloudstackTestCase):
#Reboot the router
cmd = rebootRouter.rebootRouterCmd()
cmd.id = router.id
- self.apiclient.rebootRouter(cmd)
+ self.api_client.rebootRouter(cmd)
#List routers to check state of router
router_response = list_routers(
- self.apiclient,
+ self.api_client,
id=router.id
)
self.assertEqual(
@@ -1172,7 +1170,7 @@ class TestVPCRouterOneNetwork(cloudstackTestCase):
"List static route should return a valid response"
)
routers = Router.list(
- self.apiclient,
+ self.api_client,
account=self.account.name,
domainid=self.account.domainid,
listall=True
@@ -1216,7 +1214,7 @@ class TestVPCRouterOneNetwork(cloudstackTestCase):
)
routers = Router.list(
- self.apiclient,
+ self.api_client,
account=self.account.name,
domainid=self.account.domainid,
listall=True
@@ -1232,15 +1230,15 @@ class TestVPCRouterOneNetwork(cloudstackTestCase):
self.debug("Stopping the router with ID: %s" % router.id)
cmd = stopRouter.stopRouterCmd()
cmd.id = router.id
- self.apiclient.stopRouter(cmd)
+ self.api_client.stopRouter(cmd)
service_offering = ServiceOffering.create(
- self.apiclient,
+ self.api_client,
self.services["service_offering_new"]
)
self.debug("Changing service offering for the Router %s" % router.id)
try:
- router = Router.change_service_offering(self.apiclient,
+ router = Router.change_service_offering(self.api_client,
router.id,
service_offering.id
)
@@ -1249,7 +1247,7 @@ class TestVPCRouterOneNetwork(cloudstackTestCase):
self.debug("Router %s" % router)
routers = Router.list(
- self.apiclient,
+ self.api_client,
account=self.account.name,
domainid=self.account.domainid,
listall=True
@@ -1294,7 +1292,7 @@ class TestVPCRouterOneNetwork(cloudstackTestCase):
)
routers = Router.list(
- self.apiclient,
+ self.api_client,
account=self.account.name,
domainid=self.account.domainid,
listall=True
@@ -1305,12 +1303,12 @@ class TestVPCRouterOneNetwork(cloudstackTestCase):
"List Routers should return a valid list"
)
- Router.destroy( self.apiclient,
+ Router.destroy( self.api_client,
id=routers[0].id
)
routers = Router.list(
- self.apiclient,
+ self.api_client,
account=self.account.name,
domainid=self.account.domainid,
listall=True
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/component/test_vpc_vm_life_cycle.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_vpc_vm_life_cycle.py b/test/integration/component/test_vpc_vm_life_cycle.py
index e40067e..95f46d0 100644
--- a/test/integration/component/test_vpc_vm_life_cycle.py
+++ b/test/integration/component/test_vpc_vm_life_cycle.py
@@ -20,8 +20,8 @@
#Import Local Modules
from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import cloudstackTestCase, unittest
-from marvin.integration.lib.utils import cleanup_resources, validateList
-from marvin.integration.lib.base import (VirtualMachine,
+from marvin.lib.utils import cleanup_resources, validateList
+from marvin.lib.base import (VirtualMachine,
NATRule,
LoadBalancerRule,
StaticNATRule,
@@ -35,7 +35,7 @@ from marvin.integration.lib.base import (VirtualMachine,
Account,
ServiceOffering,
Host)
-from marvin.integration.lib.common import (get_domain,
+from marvin.lib.common import (get_domain,
get_zone,
get_template,
get_free_vlan,
@@ -212,14 +212,13 @@ class TestVMLifeCycleVPC(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(
- TestVMLifeCycleVPC,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestVMLifeCycleVPC, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.template = get_template(
cls.api_client,
cls.zone.id,
@@ -873,14 +872,13 @@ class TestVMLifeCycleSharedNwVPC(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(
- TestVMLifeCycleSharedNwVPC,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestVMLifeCycleSharedNwVPC, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.template = get_template(
cls.api_client,
cls.zone.id,
@@ -1660,14 +1658,13 @@ class TestVMLifeCycleBothIsolated(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(
- TestVMLifeCycleBothIsolated,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestVMLifeCycleBothIsolated, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.template = get_template(
cls.api_client,
cls.zone.id,
@@ -1995,14 +1992,13 @@ class TestVMLifeCycleStoppedVPCVR(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(
- TestVMLifeCycleStoppedVPCVR,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestVMLifeCycleStoppedVPCVR, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.template = get_template(
cls.api_client,
cls.zone.id,
@@ -2681,14 +2677,13 @@ class TestVMLifeCycleDiffHosts(cloudstackTestCase):
def setUpClass(cls):
try:
- cls.api_client = super(
- TestVMLifeCycleDiffHosts,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestVMLifeCycleDiffHosts, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.template = get_template(
cls.api_client,
cls.zone.id,
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/component/test_vpc_vms_deployment.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_vpc_vms_deployment.py b/test/integration/component/test_vpc_vms_deployment.py
index 0ef51b4..1c1f93d 100644
--- a/test/integration/component/test_vpc_vms_deployment.py
+++ b/test/integration/component/test_vpc_vms_deployment.py
@@ -20,7 +20,7 @@
#Import Local Modules
from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import cloudstackTestCase, unittest
-from marvin.integration.lib.base import (VirtualMachine,
+from marvin.lib.base import (VirtualMachine,
NetworkOffering,
VpcOffering,
VPC,
@@ -36,13 +36,13 @@ from marvin.integration.lib.base import (VirtualMachine,
StaticNATRule,
Configurations)
-from marvin.integration.lib.common import (get_domain,
+from marvin.lib.common import (get_domain,
get_zone,
get_template,
wait_for_cleanup,
get_free_vlan)
-from marvin.integration.lib.utils import cleanup_resources
+from marvin.lib.utils import cleanup_resources
from marvin.cloudstackAPI import rebootRouter
@@ -166,14 +166,13 @@ class TestVMDeployVPC(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(
- TestVMDeployVPC,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestVMDeployVPC, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.template = get_template(
cls.api_client,
cls.zone.id,
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/component/test_vpn_users.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_vpn_users.py b/test/integration/component/test_vpn_users.py
index 710055a..c8b3a2d 100644
--- a/test/integration/component/test_vpn_users.py
+++ b/test/integration/component/test_vpn_users.py
@@ -19,9 +19,9 @@
"""
# Import Local Modules
from nose.plugins.attrib import attr
-from marvin.cloudstackException import cloudstackAPIException
+from marvin.cloudstackException import CloudstackAPIException
from marvin.cloudstackTestCase import cloudstackTestCase
-from marvin.integration.lib.base import (
+from marvin.lib.base import (
Account,
ServiceOffering,
VirtualMachine,
@@ -31,11 +31,11 @@ from marvin.integration.lib.base import (
Configurations,
NATRule
)
-from marvin.integration.lib.common import (get_domain,
+from marvin.lib.common import (get_domain,
get_zone,
get_template
)
-from marvin.integration.lib.utils import cleanup_resources
+from marvin.lib.utils import cleanup_resources
class Services:
@@ -94,12 +94,13 @@ class Services:
class TestVPNUsers(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(TestVPNUsers,
- cls).getClsTestClient().getApiClient()
+ cls.testClient = super(TestVPNUsers, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.services["mode"] = cls.zone.networktype
@@ -155,7 +156,7 @@ class TestVPNUsers(cloudstackTestCase):
services=self.services["virtual_machine"]
)
return
- except cloudstackAPIException as e:
+ except CloudstackAPIException as e:
self.tearDown()
raise e
@@ -396,7 +397,7 @@ class TestVPNUsers(cloudstackTestCase):
domainid=self.account.domainid)
self.cleanup.append(admin)
self.debug("Creating API client for newly created user")
- api_client = self.testClient.createUserApiClient(
+ api_client = self.testClient.getUserApiClient(
UserName=self.account.name,
DomainName=self.account.domain)
@@ -438,7 +439,7 @@ class TestVPNUsers(cloudstackTestCase):
domainid=self.account.domainid)
self.cleanup.append(admin)
self.debug("Creating API client for newly created user")
- api_client = self.testClient.createUserApiClient(
+ api_client = self.testClient.getUserApiClient(
UserName=self.account.name,
DomainName=self.account.domain)
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/smoke/test_affinity_groups.py
----------------------------------------------------------------------
diff --git a/test/integration/smoke/test_affinity_groups.py b/test/integration/smoke/test_affinity_groups.py
index b118364..4f3f9ec 100644
--- a/test/integration/smoke/test_affinity_groups.py
+++ b/test/integration/smoke/test_affinity_groups.py
@@ -16,52 +16,15 @@
# specific language governing permissions and limitations
# under the License.
+from marvin.codes import FAILED
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
from marvin.sshClient import SshClient
from nose.plugins.attrib import attr
-class Services:
- """Test Account Services
- """
-
- def __init__(self):
- self.services = {
- "domain": {
- "name": "Domain",
- },
- "account": {
- "email": "test@test.com",
- "firstname": "Test",
- "lastname": "User",
- "username": "test",
- # Random characters are appended for unique
- # username
- "password": "password",
- },
- "service_offering": {
- "name": "Tiny Instance",
- "displaytext": "Tiny Instance",
- "cpunumber": 1,
- "cpuspeed": 100,
- # in MHz
- "memory": 128,
- # In MBs
- },
- "ostype": 'CentOS 5.3 (64-bit)',
- "virtual_machine" : {
- "affinity": {
- "name": "webvms",
- "type": "host anti-affinity",
- },
- "hypervisor" : "XenServer",
- }
- }
-
-
class TestDeployVmWithAffinityGroup(cloudstackTestCase):
"""
This test deploys a virtual machine into a user account
@@ -70,36 +33,40 @@ class TestDeployVmWithAffinityGroup(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(TestDeployVmWithAffinityGroup, cls).getClsTestClient().getApiClient()
- cls.services = Services().services
+ cls.testClient = super(TestDeployVmWithAffinityGroup, cls).getClsTestClient()
+ zone_name = cls.testClient.getZoneForTests()
+ cls.apiclient = cls.testClient.getApiClient()
+ cls.domain = get_domain(cls.apiclient)
+ cls.services = cls.testClient.getParsedTestDataConfig()
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.zone = get_zone(cls.apiclient, cls.testClient.getZoneForTests())
+
cls.template = get_template(
- cls.api_client,
+ cls.apiclient,
cls.zone.id,
cls.services["ostype"]
)
+
+ if cls.template == FAILED:
+ assert False, "get_template() failed to return template with description %s" % cls.services["ostype"]
+
cls.services["virtual_machine"]["zoneid"] = cls.zone.id
cls.services["template"] = cls.template.id
cls.services["zoneid"] = cls.zone.id
cls.account = Account.create(
- cls.api_client,
+ cls.apiclient,
cls.services["account"],
domainid=cls.domain.id
)
-
- cls.services["account"] = cls.account.name
-
cls.service_offering = ServiceOffering.create(
- cls.api_client,
- cls.services["service_offering"]
+ cls.apiclient,
+ cls.services["service_offerings"]
)
- cls.ag = AffinityGroup.create(cls.api_client, cls.services["virtual_machine"]["affinity"],
- account=cls.services["account"], domainid=cls.domain.id)
+ cls.ag = AffinityGroup.create(cls.apiclient, cls.services["virtual_machine"]["affinity"],
+ account=cls.account.name, domainid=cls.domain.id)
cls._cleanup = [
cls.service_offering,
@@ -118,7 +85,7 @@ class TestDeployVmWithAffinityGroup(cloudstackTestCase):
"""
#deploy VM1 in affinity group created in setUp
vm1 = VirtualMachine.create(
- self.api_client,
+ self.apiclient,
self.services["virtual_machine"],
templateid=self.template.id,
accountid=self.account.name,
@@ -128,7 +95,7 @@ class TestDeployVmWithAffinityGroup(cloudstackTestCase):
)
list_vm1 = list_virtual_machines(
- self.api_client,
+ self.apiclient,
id=vm1.id
)
self.assertEqual(
@@ -151,7 +118,7 @@ class TestDeployVmWithAffinityGroup(cloudstackTestCase):
#deploy VM2 in affinity group created in setUp
vm2 = VirtualMachine.create(
- self.api_client,
+ self.apiclient,
self.services["virtual_machine"],
templateid=self.template.id,
accountid=self.account.name,
@@ -160,7 +127,7 @@ class TestDeployVmWithAffinityGroup(cloudstackTestCase):
affinitygroupnames=[self.ag.name]
)
list_vm2 = list_virtual_machines(
- self.api_client,
+ self.apiclient,
id=vm2.id
)
self.assertEqual(
@@ -189,6 +156,6 @@ class TestDeployVmWithAffinityGroup(cloudstackTestCase):
def tearDownClass(cls):
try:
#Clean up, terminate the created templates
- cleanup_resources(cls.api_client, cls._cleanup)
+ cleanup_resources(cls.apiclient, cls._cleanup)
except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e)
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/smoke/test_deploy_vgpu_enabled_vm.py
----------------------------------------------------------------------
diff --git a/test/integration/smoke/test_deploy_vgpu_enabled_vm.py b/test/integration/smoke/test_deploy_vgpu_enabled_vm.py
index 38c6d12..fa33bdc 100644
--- a/test/integration/smoke/test_deploy_vgpu_enabled_vm.py
+++ b/test/integration/smoke/test_deploy_vgpu_enabled_vm.py
@@ -23,16 +23,19 @@ from marvin.cloudstackTestCase import cloudstackTestCase
#Import Integration Libraries
#base - contains all resources as entities and defines create, delete, list operations on them
-from marvin.integration.lib.base import Account, VirtualMachine, ServiceOffering
+from marvin.lib.base import Account, VirtualMachine, ServiceOffering
#utils - utility classes for common cleanup, external library wrappers etc
-from marvin.integration.lib.utils import cleanup_resources
+from marvin.lib.utils import cleanup_resources
#common - commonly used methods for all tests are listed here
-from marvin.integration.lib.common import get_zone, get_domain, get_template
+from marvin.lib.common import get_zone, get_domain, get_template
+
+from marvin.codes import FAILED
from nose.plugins.attrib import attr
+
class Services:
"""Test VM Life Cycle Services
"""
@@ -116,12 +119,15 @@ class TestDeployvGPUenabledVM(cloudstackTestCase):
self.apiclient = self.testClient.getApiClient()
# Get Zone, Domain and Default Built-in template
- self.domain = get_domain(self.apiclient, self.services)
- self.zone = get_zone(self.apiclient, self.services)
+ self.domain = get_domain(self.apiclient)
+ self.zone = get_zone(self.apiclient, self.testClient.getZoneForTests())
self.services["mode"] = self.zone.networktype
# Before running this test, register a windows template with ostype as 'Windows 7 (32-bit)'
- self.template = get_template(self.apiclient, self.zone.id, self.services["ostype"], templatetype='USER')
+ self.services["ostype"] = 'Windows 7 (32-bit)'
+ self.template = get_template(self.apiclient, self.zone.id, self.services["ostype"])
+ if self.template == FAILED:
+ assert False, "get_template() failed to return template with description %s" % self.services["ostype"]
#create a user account
self.account = Account.create(
self.apiclient,
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/smoke/test_deploy_vm.py
----------------------------------------------------------------------
diff --git a/test/integration/smoke/test_deploy_vm.py b/test/integration/smoke/test_deploy_vm.py
index 6ff7346..ca4891d 100644
--- a/test/integration/smoke/test_deploy_vm.py
+++ b/test/integration/smoke/test_deploy_vm.py
@@ -22,72 +22,36 @@ from marvin.cloudstackTestCase import cloudstackTestCase
#Import Integration Libraries
+from marvin.codes import FAILED
#base - contains all resources as entities and defines create, delete, list operations on them
-from marvin.integration.lib.base import Account, VirtualMachine, ServiceOffering, SimulatorMock
+from marvin.lib.base import Account, VirtualMachine, ServiceOffering, SimulatorMock
#utils - utility classes for common cleanup, external library wrappers etc
-from marvin.integration.lib.utils import cleanup_resources
+from marvin.lib.utils import cleanup_resources
#common - commonly used methods for all tests are listed here
-from marvin.integration.lib.common import get_zone, get_domain, get_template
+from marvin.lib.common import get_zone, get_domain, get_template
from nose.plugins.attrib import attr
-class TestData(object):
- """Test data object that is required to create resources
- """
- def __init__(self):
- self.testdata = {
- #data to create an account
- "account": {
- "email": "test@test.com",
- "firstname": "Test",
- "lastname": "User",
- "username": "test",
- "password": "password",
- },
- #data reqd for virtual machine creation
- "virtual_machine" : {
- "name" : "testvm",
- "displayname" : "Test VM",
- },
- #data reqd for virtual machine creation
- "virtual_machine2" : {
- "name" : "testvm2",
- "displayname" : "Test VM2",
- },
- "virtual_machine3" : {
- "name" : "testvm3",
- "displayname" : "Test VM3",
- },
- #small service offering
- "service_offering": {
- "small": {
- "name": "Small Instance",
- "displaytext": "Small Instance",
- "cpunumber": 1,
- "cpuspeed": 100,
- "memory": 256,
- },
- },
- "ostype": 'CentOS 5.3 (64-bit)',
- }
-
-
class TestDeployVM(cloudstackTestCase):
"""Test deploy a VM into a user account
"""
def setUp(self):
- self.testdata = TestData().testdata
self.apiclient = self.testClient.getApiClient()
+ self.testdata = self.testClient.getParsedTestDataConfig()
+
# Get Zone, Domain and Default Built-in template
- self.domain = get_domain(self.apiclient, self.testdata)
- self.zone = get_zone(self.apiclient, self.testdata)
+ self.domain = get_domain(self.apiclient)
+ self.zone = get_zone(self.apiclient, self.testClient.getZoneForTests())
self.testdata["mode"] = self.zone.networktype
self.template = get_template(self.apiclient, self.zone.id, self.testdata["ostype"])
+ if self.template == FAILED:
+ self.fail("get_template() failed to return template with description %s" % self.testdata["ostype"])
+
#create a user account
self.account = Account.create(
self.apiclient,
@@ -97,7 +61,7 @@ class TestDeployVM(cloudstackTestCase):
#create a service offering
self.service_offering = ServiceOffering.create(
self.apiclient,
- self.testdata["service_offering"]["small"]
+ self.testdata["service_offerings"]["small"]
)
#build cleanup list
self.cleanup = [
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/smoke/test_deploy_vm_root_resize.py
----------------------------------------------------------------------
diff --git a/test/integration/smoke/test_deploy_vm_root_resize.py b/test/integration/smoke/test_deploy_vm_root_resize.py
index aa88beb..e758ffd 100644
--- a/test/integration/smoke/test_deploy_vm_root_resize.py
+++ b/test/integration/smoke/test_deploy_vm_root_resize.py
@@ -23,13 +23,15 @@ from marvin.cloudstackTestCase import cloudstackTestCase
#Import Integration Libraries
#base - contains all resources as entities and defines create, delete, list operations on them
-from marvin.integration.lib.base import Account, VirtualMachine, ServiceOffering
+from marvin.lib.base import Account, VirtualMachine, ServiceOffering
#utils - utility classes for common cleanup, external library wrappers etc
-from marvin.integration.lib.utils import cleanup_resources
+from marvin.lib.utils import cleanup_resources
#common - commonly used methods for all tests are listed here
-from marvin.integration.lib.common import get_zone, get_domain, get_template, list_volumes
+from marvin.lib.common import get_zone, get_domain, get_template, list_volumes
+
+from marvin.codes import FAILED
from nose.plugins.attrib import attr
@@ -71,12 +73,15 @@ class TestDeployVM(cloudstackTestCase):
def setUp(self):
self.testdata = TestData().testdata
self.apiclient = self.testClient.getApiClient()
+ self.hypervisor = self.testClient.getHypervisorInfo()
# Get Zone, Domain and Default Built-in template
- self.domain = get_domain(self.apiclient, self.testdata)
- self.zone = get_zone(self.apiclient, self.testdata)
+ self.domain = get_domain(self.apiclient)
+ self.zone = get_zone(self.apiclient, self.testClient.getZoneForTests())
self.testdata["mode"] = self.zone.networktype
self.template = get_template(self.apiclient, self.zone.id, self.testdata["ostype"])
+ if self.template == FAILED:
+ assert False, "get_template() failed to return template with description %s" % self.services["ostype"]
# for testing with specific template
# self.template = get_template(self.apiclient, self.zone.id, self.testdata["ostype"], templatetype='USER', services = {"template":'31f52a4d-5681-43f7-8651-ad4aaf823618'})
@@ -107,7 +112,7 @@ class TestDeployVM(cloudstackTestCase):
# 2. root disk has new size per listVolumes
# 3. Rejects non-supported hypervisor types
"""
- if(self.apiclient.hypervisor == 'kvm'):
+ if(self.hypervisor == 'kvm'):
newrootsize = (self.template.size >> 30) + 2
self.virtual_machine = VirtualMachine.create(
self.apiclient,
@@ -174,7 +179,7 @@ class TestDeployVM(cloudstackTestCase):
"Check if the root volume resized appropriately"
)
else:
- self.debug("hypervisor %s unsupported for test 00, verifying it errors properly" % self.apiclient.hypervisor)
+ self.debug("hypervisor %s unsupported for test 00, verifying it errors properly" % self.hypervisor)
newrootsize = (self.template.size >> 30) + 2
success = False
@@ -195,13 +200,13 @@ class TestDeployVM(cloudstackTestCase):
else:
self.debug("virtual machine create did not fail appropriately. Error was actually : " + str(ex));
- self.assertEqual(success, True, "Check if unsupported hypervisor %s fails appropriately" % self.apiclient.hypervisor)
+ self.assertEqual(success, True, "Check if unsupported hypervisor %s fails appropriately" % self.hypervisor)
@attr(tags = ['advanced', 'simulator', 'basic', 'sg', 'provisioning'])
def test_01_deploy_vm_root_resize(self):
"""Test proper failure to deploy virtual machine with rootdisksize of 0
"""
- if (self.apiclient.hypervisor == 'kvm'):
+ if (self.hypervisor == 'kvm'):
newrootsize = 0
success = False
try:
@@ -223,13 +228,13 @@ class TestDeployVM(cloudstackTestCase):
self.assertEqual(success, True, "Check if passing 0 as rootdisksize fails appropriately")
else:
- self.debug("test 01 does not support hypervisor type " + self.apiclient.hypervisor);
+ self.debug("test 01 does not support hypervisor type " + self.hypervisor);
@attr(tags = ['advanced', 'simulator', 'basic', 'sg', 'provisioning'])
def test_02_deploy_vm_root_resize(self):
"""Test proper failure to deploy virtual machine with rootdisksize less than template size
"""
- if (self.apiclient.hypervisor == 'kvm'):
+ if (self.hypervisor == 'kvm'):
newrootsize = (self.template.size >> 30) - 1
self.assertEqual(newrootsize > 0, True, "Provided template is less than 1G in size, cannot run test")
@@ -254,7 +259,7 @@ class TestDeployVM(cloudstackTestCase):
self.assertEqual(success, True, "Check if passing rootdisksize < templatesize fails appropriately")
else:
- self.debug("test 01 does not support hypervisor type " + self.apiclient.hypervisor);
+ self.debug("test 01 does not support hypervisor type " + self.hypervisor);
def tearDown(self):
try:
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/smoke/test_deploy_vm_with_userdata.py
----------------------------------------------------------------------
diff --git a/test/integration/smoke/test_deploy_vm_with_userdata.py b/test/integration/smoke/test_deploy_vm_with_userdata.py
index b8be83a..7616b82 100644
--- a/test/integration/smoke/test_deploy_vm_with_userdata.py
+++ b/test/integration/smoke/test_deploy_vm_with_userdata.py
@@ -16,62 +16,33 @@
# under the License.
from marvin.cloudstackTestCase import cloudstackTestCase
-from marvin.integration.lib.base import (ServiceOffering,
+from marvin.lib.base import (ServiceOffering,
VirtualMachine,
Account)
-from marvin.integration.lib.common import get_template, get_zone, list_virtual_machines
-from marvin.integration.lib.utils import cleanup_resources
+from marvin.lib.common import get_template, get_zone, list_virtual_machines
+from marvin.lib.utils import cleanup_resources
from nose.plugins.attrib import attr
-
+from marvin.codes import FAILED
import random
import string
-class Services:
- def __init__(self):
- self.services = {
- "account": {
- "email": "test@test.com",
- "firstname": "Test",
- "lastname": "User",
- "username": "test",
- "password": "password",
- },
- "virtual_machine": {
- "displayname": "Test VM",
- "username": "root",
- "password": "password",
- "ssh_port": 22,
- "hypervisor": 'XenServer',
- "privateport": 22,
- "publicport": 22,
- "protocol": 'TCP',
- },
- "ostype": 'CentOS 5.3 (64-bit)',
- "service_offering": {
- "name": "Tiny Instance",
- "displaytext": "Tiny Instance",
- "cpunumber": 1,
- "cpuspeed": 100,
- "memory": 256,
- },
- }
-
-
class TestDeployVmWithUserData(cloudstackTestCase):
"""Tests for UserData
"""
@classmethod
def setUpClass(cls):
- cls.apiClient = super(TestDeployVmWithUserData, cls).getClsTestClient().getApiClient()
- cls.services = Services().services
- cls.zone = get_zone(cls.apiClient, cls.services)
+ testClient = super(TestDeployVmWithUserData, cls).getClsTestClient()
+ cls.apiClient = testClient.getApiClient()
+ cls.services = testClient.getParsedTestDataConfig()
+
+ cls.zone = get_zone(cls.apiClient, testClient.getZoneForTests())
if cls.zone.localstorageenabled:
#For devcloud since localstroage is enabled
- cls.services["service_offering"]["storagetype"] = "local"
+ cls.services["service_offerings"]["storagetype"] = "local"
cls.service_offering = ServiceOffering.create(
cls.apiClient,
- cls.services["service_offering"]
+ cls.services["service_offerings"]
)
cls.account = Account.create(cls.apiClient, services=cls.services["account"])
cls.cleanup = [cls.account]
@@ -80,6 +51,10 @@ class TestDeployVmWithUserData(cloudstackTestCase):
cls.zone.id,
cls.services["ostype"]
)
+
+ if cls.template == FAILED:
+ assert False, "get_template() failed to return template with description %s" % cls.services["ostype"]
+
cls.debug("Successfully created account: %s, id: \
%s" % (cls.account.name,\
cls.account.id))
@@ -92,7 +67,10 @@ class TestDeployVmWithUserData(cloudstackTestCase):
user_data = ''.join(random.choice(string.ascii_uppercase + string.digits) for x in range(2500))
cls.services["virtual_machine"]["userdata"] = user_data
- @attr(tags=["simulator", "devcloud", "basic", "advanced", "provisioning"])
+ def setup(self):
+ self.hypervisor = self.testClient.getHypervisorInfo()
+
+ @attr(tags=["simulator", "devcloud", "basic", "advanced", "post", "provisioning"])
def test_deployvm_userdata_post(self):
"""Test userdata as POST, size > 2k
"""
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/smoke/test_deploy_vms_with_varied_deploymentplanners.py
----------------------------------------------------------------------
diff --git a/test/integration/smoke/test_deploy_vms_with_varied_deploymentplanners.py b/test/integration/smoke/test_deploy_vms_with_varied_deploymentplanners.py
index fc11549..420925e 100644
--- a/test/integration/smoke/test_deploy_vms_with_varied_deploymentplanners.py
+++ b/test/integration/smoke/test_deploy_vms_with_varied_deploymentplanners.py
@@ -15,40 +15,13 @@
# specific language governing permissions and limitations
# under the License.
+from marvin.codes import FAILED
from marvin.cloudstackTestCase import cloudstackTestCase
-from marvin.integration.lib.base import Account, VirtualMachine, ServiceOffering, Host, Cluster
-from marvin.integration.lib.common import get_zone, get_domain, get_template
-from marvin.integration.lib.utils import cleanup_resources
+from marvin.lib.base import Account, VirtualMachine, ServiceOffering, Host, Cluster
+from marvin.lib.common import get_zone, get_domain, get_template
+from marvin.lib.utils import cleanup_resources
from nose.plugins.attrib import attr
-class Services:
- def __init__(self):
- self.services = {
- "account": {
- "email": "test@test.com",
- "firstname": "Test",
- "lastname": "User",
- "username": "test",
- # Random characters are appended for unique
- # username
- "password": "password",
- },
- "service_offering": {
- "name": "Planner Service Offering",
- "displaytext": "Planner Service Offering",
- "cpunumber": 1,
- "cpuspeed": 100,
- # in MHz
- "memory": 128,
- # In MBs
- },
- "ostype": 'CentOS 5.3 (64-bit)',
- "virtual_machine": {
- "hypervisor": "XenServer",
- }
- }
-
-
class TestDeployVmWithVariedPlanners(cloudstackTestCase):
""" Test to create services offerings for deployment planners
- firstfit, userdispersing
@@ -56,16 +29,22 @@ class TestDeployVmWithVariedPlanners(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.apiclient = super(TestDeployVmWithVariedPlanners, cls).getClsTestClient().getApiClient()
- cls.services = Services().services
+ testClient = super(TestDeployVmWithVariedPlanners, cls).getClsTestClient()
+ cls.apiclient = testClient.getApiClient()
+ cls.services = testClient.getParsedTestDataConfig()
+
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.apiclient, cls.services)
- cls.zone = get_zone(cls.apiclient, cls.services)
+ cls.domain = get_domain(cls.apiclient)
+ cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests())
cls.template = get_template(
cls.apiclient,
cls.zone.id,
cls.services["ostype"]
)
+
+ if cls.template == FAILED:
+ assert false, "get_template() failed to return template with description %s" % cls.services["ostype"]
+
cls.services["virtual_machine"]["zoneid"] = cls.zone.id
cls.services["template"] = cls.template.id
cls.services["zoneid"] = cls.zone.id
@@ -75,7 +54,6 @@ class TestDeployVmWithVariedPlanners(cloudstackTestCase):
cls.services["account"],
domainid=cls.domain.id
)
- cls.services["account"] = cls.account.name
cls.hosts = Host.list(cls.apiclient, type='Routing')
cls.clusters = Cluster.list(cls.apiclient)
cls.cleanup = [
@@ -89,7 +67,7 @@ class TestDeployVmWithVariedPlanners(cloudstackTestCase):
#FIXME: How do we know that first fit actually happened?
self.service_offering_firstfit = ServiceOffering.create(
self.apiclient,
- self.services["service_offering"],
+ self.services["service_offerings"],
deploymentplanner='FirstFitPlanner'
)
@@ -132,7 +110,7 @@ class TestDeployVmWithVariedPlanners(cloudstackTestCase):
"""
self.service_offering_userdispersing = ServiceOffering.create(
self.apiclient,
- self.services["service_offering"],
+ self.services["service_offerings"],
deploymentplanner='UserDispersingPlanner'
)
@@ -191,7 +169,7 @@ class TestDeployVmWithVariedPlanners(cloudstackTestCase):
"""
self.service_offering_userconcentrated = ServiceOffering.create(
self.apiclient,
- self.services["service_offering"],
+ self.services["service_offerings"],
deploymentplanner='UserConcentratedPodPlanner'
)
[17/18] Marvin + test changes from master Signed-off-by:
SrikanteswaraRao Talluri
Posted by da...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/component/test_affinity_groups.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_affinity_groups.py b/test/integration/component/test_affinity_groups.py
index 68902f5..eb58777 100644
--- a/test/integration/component/test_affinity_groups.py
+++ b/test/integration/component/test_affinity_groups.py
@@ -15,12 +15,20 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
-from marvin.cloudstackTestCase import *
-from marvin.cloudstackAPI import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
-from marvin.sshClient import SshClient
+from marvin.cloudstackTestCase import cloudstackTestCase, unittest
+from marvin.cloudstackAPI import deleteAffinityGroup
+from marvin.lib.utils import (cleanup_resources,
+ random_gen)
+from marvin.lib.base import (Account,
+ ServiceOffering,
+ VirtualMachine,
+ AffinityGroup,
+ Domain)
+from marvin.lib.common import (get_zone,
+ get_domain,
+ get_template,
+ list_virtual_machines,
+ wait_for_cleanup)
from nose.plugins.attrib import attr
class Services:
@@ -89,12 +97,12 @@ class TestCreateAffinityGroup(cloudstackTestCase):
@classmethod
def setUpClass(cls):
-
- cls.api_client = super(TestCreateAffinityGroup, cls).getClsTestClient().getApiClient()
+ cls.testClient = super(TestCreateAffinityGroup, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.template = get_template(
cls.api_client,
cls.zone.id,
@@ -197,7 +205,7 @@ class TestCreateAffinityGroup(cloudstackTestCase):
self.cleanup.append(self.do_admin)
self.cleanup.append(self.new_domain)
- domainapiclient = self.testClient.createUserApiClient(self.do_admin.name, self.new_domain.name, 2)
+ domainapiclient = self.testClient.getUserApiClient(self.do_admin.name, self.new_domain.name, 2)
aff_grp = self.create_aff_grp(api_client=domainapiclient, aff_grp=self.services["host_anti_affinity"],
acc=self.do_admin.name, domainid=self.new_domain.id)
@@ -214,7 +222,7 @@ class TestCreateAffinityGroup(cloudstackTestCase):
self.user = Account.create(self.api_client, self.services["new_account"],
domainid=self.domain.id)
- userapiclient = self.testClient.createUserApiClient(self.user.name, self.domain.name)
+ userapiclient = self.testClient.getUserApiClient(self.user.name, self.domain.name)
self.cleanup.append(self.user)
aff_grp = self.create_aff_grp(api_client=userapiclient, aff_grp=self.services["host_anti_affinity"],
@@ -283,12 +291,14 @@ class TestListAffinityGroups(cloudstackTestCase):
@classmethod
def setUpClass(cls):
+ cls.testClient = super(TestListAffinityGroups, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
- cls.api_client = super(TestListAffinityGroups, cls).getClsTestClient().getApiClient()
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
+
cls.template = get_template(
cls.api_client,
cls.zone.id,
@@ -530,11 +540,14 @@ class TestDeleteAffinityGroups(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(TestDeleteAffinityGroups, cls).getClsTestClient().getApiClient()
+ cls.testClient = super(TestDeleteAffinityGroups, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
+
cls.template = get_template(
cls.api_client,
cls.zone.id,
@@ -704,10 +717,10 @@ class TestDeleteAffinityGroups(cloudstackTestCase):
self.user2 = Account.create(self.apiclient, self.services["new_account1"])
self.cleanup.append(self.user2)
- userapiclient = self.testClient.createUserApiClient(
+ userapiclient = self.testClient.getUserApiClient(
UserName=self.user2.name,
DomainName=self.user2.domain,
- acctType=0)
+ type=0)
aff_1 = self.create_aff_grp(api_client=userapiclient,
aff_grp=self.services["host_anti_affinity"])
@@ -740,10 +753,10 @@ class TestDeleteAffinityGroups(cloudstackTestCase):
self.user2 = Account.create(self.apiclient, self.services["new_account1"])
self.cleanup.append(self.user2)
- userapiclient = self.testClient.createUserApiClient(
+ userapiclient = self.testClient.getUserApiClient(
UserName=self.user2.name,
DomainName=self.user2.domain,
- acctType=0)
+ type=0)
aff_1 = self.create_aff_grp(api_client=userapiclient,
aff_grp=self.services["host_anti_affinity"])
@@ -781,10 +794,10 @@ class TestDeleteAffinityGroups(cloudstackTestCase):
self.services["new_account"])
self.cleanup.append(self.user1)
- user1apiclient = self.testClient.createUserApiClient(
+ user1apiclient = self.testClient.getUserApiClient(
UserName=self.user1.name,
DomainName=self.user1.domain,
- acctType=0)
+ type=0)
aff_grp = self.create_aff_grp(api_client=user1apiclient,
aff_grp=self.services["host_anti_affinity"])
@@ -800,11 +813,14 @@ class TestUpdateVMAffinityGroups(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(TestUpdateVMAffinityGroups, cls).getClsTestClient().getApiClient()
+ cls.testClient = super(TestUpdateVMAffinityGroups, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
+
cls.template = get_template(
cls.api_client,
cls.zone.id,
@@ -1084,11 +1100,14 @@ class TestDeployVMAffinityGroups(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(TestDeployVMAffinityGroups, cls).getClsTestClient().getApiClient()
+ cls.testClient = super(TestDeployVMAffinityGroups, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
+
cls.template = get_template(
cls.api_client,
cls.zone.id,
@@ -1294,10 +1313,10 @@ class TestDeployVMAffinityGroups(cloudstackTestCase):
self.user2 = Account.create(self.apiclient, self.services["new_account1"])
self.cleanup.append(self.user2)
- userapiclient = self.testClient.createUserApiClient(
+ userapiclient = self.testClient.getUserApiClient(
UserName=self.user2.name,
DomainName=self.user2.domain,
- acctType=0)
+ type=0)
self.create_aff_grp(api_client=userapiclient,
aff_grp=self.services["host_anti_affinity"])
@@ -1327,10 +1346,10 @@ class TestDeployVMAffinityGroups(cloudstackTestCase):
self.user2 = Account.create(self.apiclient, self.services["new_account1"])
self.cleanup.append(self.user2)
- userapiclient = self.testClient.createUserApiClient(
+ userapiclient = self.testClient.getUserApiClient(
UserName=self.user2.name,
DomainName=self.user2.domain,
- acctType=0)
+ type=0)
self.create_aff_grp(api_client=userapiclient,
aff_grp=self.services["host_anti_affinity"])
@@ -1432,11 +1451,13 @@ class TestAffinityGroupsAdminUser(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(TestAffinityGroupsAdminUser, cls).getClsTestClient().getApiClient()
+ cls.testClient = super(TestAffinityGroupsAdminUser, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.template = get_template(
cls.api_client,
cls.zone.id,
@@ -1549,10 +1570,10 @@ class TestAffinityGroupsAdminUser(cloudstackTestCase):
self.services["new_account"])
self.cleanup.append(self.user1)
- userapiclient = self.testClient.createUserApiClient(
+ userapiclient = self.testClient.getUserApiClient(
UserName=self.user1.name,
DomainName=self.user1.domain,
- acctType=0)
+ type=0)
aff_grp = self.create_aff_grp(api_client=userapiclient,
aff_grp=self.services["host_anti_affinity"])
@@ -1588,10 +1609,10 @@ class TestAffinityGroupsAdminUser(cloudstackTestCase):
self.services["new_account"])
self.cleanup.append(self.user1)
- userapiclient = self.testClient.createUserApiClient(
+ userapiclient = self.testClient.getUserApiClient(
UserName=self.user1.name,
DomainName=self.user1.domain,
- acctType=0)
+ type=0)
aff_grp = self.create_aff_grp(api_client=userapiclient,
aff_grp=self.services["host_anti_affinity"])
@@ -1638,10 +1659,10 @@ class TestAffinityGroupsAdminUser(cloudstackTestCase):
self.services["new_account"])
self.cleanup.append(self.user1)
- userapiclient = self.testClient.createUserApiClient(
+ userapiclient = self.testClient.getUserApiClient(
UserName=self.user1.name,
DomainName=self.user1.domain,
- acctType=0)
+ type=0)
aff_grp1 = self.create_aff_grp(api_client=userapiclient,
aff_grp=self.services["host_anti_affinity"])
@@ -1674,10 +1695,10 @@ class TestAffinityGroupsAdminUser(cloudstackTestCase):
self.services["new_account"])
self.cleanup.append(self.user1)
- userapiclient = self.testClient.createUserApiClient(
+ userapiclient = self.testClient.getUserApiClient(
UserName=self.user1.name,
DomainName=self.user1.domain,
- acctType=0)
+ type=0)
aff_grp = self.create_aff_grp(api_client=userapiclient,
aff_grp=self.services["host_anti_affinity"])
@@ -1706,10 +1727,10 @@ class TestAffinityGroupsAdminUser(cloudstackTestCase):
self.services["new_account"])
self.cleanup.append(self.user1)
- userapiclient = self.testClient.createUserApiClient(
+ userapiclient = self.testClient.getUserApiClient(
UserName=self.user1.name,
DomainName=self.user1.domain,
- acctType=0)
+ type=0)
aff_grp = self.create_aff_grp(api_client=userapiclient,
aff_grp=self.services["host_anti_affinity"])
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/component/test_allocation_states.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_allocation_states.py b/test/integration/component/test_allocation_states.py
index 1c0bce5..9ba246f 100644
--- a/test/integration/component/test_allocation_states.py
+++ b/test/integration/component/test_allocation_states.py
@@ -15,17 +15,16 @@
# specific language governing permissions and limitations
# under the License.
-import marvin
from nose.plugins.attrib import attr
-from marvin.cloudstackTestCase import *
-from marvin.cloudstackAPI import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
-from nose.plugins.attrib import attr
-import datetime
-
-
+from marvin.cloudstackTestCase import cloudstackTestCase
+from marvin.lib.utils import cleanup_resources
+from marvin.lib.base import (Host,
+ Pod,
+ Zone,
+ Cluster,
+ StoragePool)
+from marvin.lib.common import get_zone, get_template
+from marvin.codes import FAILED
class Services:
"""Test Resource Limits Services
"""
@@ -86,13 +85,23 @@ class TestAllocationState(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(
- TestAllocationState,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestAllocationState, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
+
# Get Zone, Domain and templates
- cls.zone = get_zone(cls.api_client, cls.services)
+
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
+ cls.template = get_template(
+ cls.api_client,
+ cls.zone.id,
+ cls.services["ostype"]
+ )
+ if cls.template == FAILED:
+ assert False, "get_template() failed to return template with description %s" % cls.services["ostype"]
+
+
cls.services['mode'] = cls.zone.networktype
cls._cleanup = []
return
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/component/test_asa1000v_fw.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_asa1000v_fw.py b/test/integration/component/test_asa1000v_fw.py
index c8a11ab..43d06d1 100644
--- a/test/integration/component/test_asa1000v_fw.py
+++ b/test/integration/component/test_asa1000v_fw.py
@@ -18,15 +18,15 @@
""" Cisco ASA1000v external firewall
"""
#Import Local Modules
-import marvin
from nose.plugins.attrib import attr
-from marvin.cloudstackTestCase import *
-from marvin.cloudstackAPI import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
-from marvin.sshClient import SshClient
-import datetime
+from marvin.cloudstackTestCase import cloudstackTestCase
+from marvin.lib.utils import cleanup_resources
+from marvin.lib.base import (NetworkOffering,
+ PhysicalNetwork,
+ VNMC,
+ ASA1000V,
+ Cluster)
+from marvin.lib.common import get_zone
class Services:
@@ -101,7 +101,7 @@ class TestASASetup(cloudstackTestCase):
self.apiclient = self.testClient.getApiClient()
self.dbclient = self.testClient.getDbConnection()
- self.zone = get_zone(self.apiclient, self.services)
+ self.zone = get_zone(self.apiclient, self.testClient.getZoneForTests())
self.physicalnetworks = PhysicalNetwork.list(self.apiclient, zoneid=self.zone.id)
self.assertNotEqual(len(self.physicalnetworks), 0, "Check if the list physical network API returns a non-empty response")
self.clusters = Cluster.list(self.apiclient, hypervisor='VMware')
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/component/test_assign_vm.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_assign_vm.py b/test/integration/component/test_assign_vm.py
index 400d5f2..24b63a6 100644
--- a/test/integration/component/test_assign_vm.py
+++ b/test/integration/component/test_assign_vm.py
@@ -20,7 +20,7 @@
#Import Local Modules
from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import cloudstackTestCase
-from marvin.integration.lib.base import (Account,
+from marvin.lib.base import (Account,
Domain,
User,
Project,
@@ -29,7 +29,7 @@ from marvin.integration.lib.base import (Account,
DiskOffering,
ServiceOffering,
VirtualMachine)
-from marvin.integration.lib.common import (get_domain,
+from marvin.lib.common import (get_domain,
get_zone,
get_template,
list_volumes,
@@ -37,7 +37,7 @@ from marvin.integration.lib.common import (get_domain,
list_networks,
list_snapshots,
list_virtual_machines)
-from marvin.integration.lib.utils import cleanup_resources
+from marvin.lib.utils import cleanup_resources
def log_test_exceptions(func):
def test_wrap_exception_log(self, *args, **kwargs):
@@ -98,12 +98,13 @@ class TestVMOwnership(cloudstackTestCase):
@classmethod
def setUpClass(cls):
cls._cleanup = []
- cls.api_client = super(TestVMOwnership,
- cls).getClsTestClient().getApiClient()
- cls.services = Services().services
- # Get Zone Domain and create Domains and sub Domains.
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.testClient = super(TestVMOwnership, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
+ cls.services = Services().services
+ # Get Zone, Domain and templates
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.services['mode'] = cls.zone.networktype
# Get and set template id for VM creation.
cls.template = get_template(cls.api_client,
@@ -353,8 +354,8 @@ class TestVMOwnership(cloudstackTestCase):
# 1. deploy VM in sub subdomain1
# 2. stop VM in sub subdomain1
# 3. assignVirtualMachine to subdomain2
- userapiclient = self.testClient.getUserApiClient(account=self.sdomain_account_user1['account'].name,
- domain=self.sdomain_account_user1['domain'].name,
+ userapiclient = self.testClient.getUserApiClient(UserName=self.sdomain_account_user1['account'].name,
+ DomainName=self.sdomain_account_user1['domain'].name,
type=2)
self.create_vm(self.sdomain_account_user1['account'], self.sdomain_account_user1['domain'])
self.assertRaises(Exception, self.virtual_machine.assign_virtual_machine, userapiclient, self.sdomain_account_user2['account'].name ,self.sdomain_account_user2['domain'].id)
@@ -389,8 +390,8 @@ class TestVMOwnership(cloudstackTestCase):
# Validate the following:
# 1. deploy VM in sub subdomain1 with volumes.
# 3. assignVirtualMachine to subdomain2
- userapiclient = self.testClient.getUserApiClient(account=self.sdomain_account_user1['account'].name,
- domain=self.sdomain_account_user1['domain'].name,
+ userapiclient = self.testClient.getUserApiClient(UserName=self.sdomain_account_user1['account'].name,
+ DomainName=self.sdomain_account_user1['domain'].name,
type=2)
self.create_vm(self.sdomain_account_user1['account'], self.sdomain_account_user1['domain'],volume=self.sdomain_account_user1['volume'])
self.assertRaises(Exception, self.virtual_machine.assign_virtual_machine, userapiclient, self.sdomain_account_user2['account'].name ,self.sdomain_account_user2['domain'].id)
@@ -431,8 +432,8 @@ class TestVMOwnership(cloudstackTestCase):
# Validate the following:
# 1. deploy VM in sub subdomain1 with snapshot.
# 3. assignVirtualMachine to subdomain2
- userapiclient = self.testClient.getUserApiClient(account=self.sdomain_account_user1['account'].name,
- domain=self.sdomain_account_user1['domain'].name,
+ userapiclient = self.testClient.getUserApiClient(UserName=self.sdomain_account_user1['account'].name,
+ DomainName=self.sdomain_account_user1['domain'].name,
type=2)
self.create_vm(self.sdomain_account_user1['account'], self.sdomain_account_user1['domain'], project=self.sdomain_account_user1['project'])
self.assertRaises(Exception, self.virtual_machine.assign_virtual_machine, userapiclient, self.sdomain_account_user2['account'].name ,self.sdomain_account_user2['domain'].id)
@@ -450,8 +451,8 @@ class TestVMOwnership(cloudstackTestCase):
account=self.sdomain_account_user2['account'].name,
domainid=self.sdomain_account_user2['domain'].id,
max=0)
- userapiclient = self.testClient.getUserApiClient(account=self.sdomain_account_user1['account'].name,
- domain=self.sdomain_account_user1['domain'].name,
+ userapiclient = self.testClient.getUserApiClient(UserName=self.sdomain_account_user1['account'].name,
+ DomainName=self.sdomain_account_user1['domain'].name,
type=2)
self.create_vm(self.sdomain_account_user1['account'], self.sdomain_account_user1['domain'], snapshot=True)
self.assertRaises(Exception, self.virtual_machine.assign_virtual_machine, userapiclient, self.sdomain_account_user2['account'].name ,self.sdomain_account_user2['domain'].id)
@@ -470,8 +471,8 @@ class TestVMOwnership(cloudstackTestCase):
account=self.sdomain_account_user2['account'].name,
domainid=self.sdomain_account_user2['domain'].id,
max=0)
- userapiclient = self.testClient.getUserApiClient(account=self.sdomain_account_user1['account'].name,
- domain=self.sdomain_account_user1['domain'].name,
+ userapiclient = self.testClient.getUserApiClient(UserName=self.sdomain_account_user1['account'].name,
+ DomainName=self.sdomain_account_user1['domain'].name,
type=2)
self.create_vm(self.sdomain_account_user1['account'], self.sdomain_account_user1['domain'], snapshot=True, volume=self.sdomain_account_user1['volume'])
self.assertRaises(Exception, self.virtual_machine.assign_virtual_machine, userapiclient, self.sdomain_account_user2['account'].name ,self.sdomain_account_user2['domain'].id)
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/component/test_baremetal.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_baremetal.py b/test/integration/component/test_baremetal.py
index 2439d0d..6ab9146 100644
--- a/test/integration/component/test_baremetal.py
+++ b/test/integration/component/test_baremetal.py
@@ -17,18 +17,18 @@
""" Test for baremetal
"""
#Import Local Modules
-import marvin
-from marvin.cloudstackTestCase import *
-from marvin.cloudstackAPI import *
-from marvin.sshClient import SshClient
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.cloudstackTestCase import cloudstackTestCase
+from marvin.cloudstackAPI import createVlanIpRange
+from marvin.lib.utils import cleanup_resources
+from marvin.lib.base import (NetworkOffering,
+ NetworkServiceProvider,
+ PhysicalNetwork,
+ Network,
+ Pod)
+#from marvin.lib.common import *
from nose.plugins.attrib import attr
-import telnetlib
#Import System modules
-import time
_multiprocess_shared_ = True
class Services:
@@ -89,19 +89,19 @@ class TestBaremetal(cloudstackTestCase):
physical_network = PhysicalNetwork.list(self.apiclient, zoneid=self.zoneid)[0];
dhcp_provider = NetworkServiceProvider.list(self.apiclient, name="BaremetalDhcpProvider", physical_network_id=physical_network.id)[0]
- response = NetworkServiceProvider.update(
+ NetworkServiceProvider.update(
self.apiclient,
id=dhcp_provider.id,
state='Enabled'
)
pxe_provider = NetworkServiceProvider.list(self.apiclient, name="BaremetalPxeProvider", physical_network_id=physical_network.id)[0]
- response = NetworkServiceProvider.update(
+ NetworkServiceProvider.update(
self.apiclient,
id=pxe_provider.id,
state='Enabled'
)
userdata_provider = NetworkServiceProvider.list(self.apiclient, name="BaremetalUserdataProvider", physical_network_id=physical_network.id)[0]
- response = NetworkServiceProvider.update(
+ NetworkServiceProvider.update(
self.apiclient,
id=userdata_provider.id,
state='Enabled'
@@ -119,5 +119,5 @@ class TestBaremetal(cloudstackTestCase):
cmd.startip = "10.1.1.20"
cmd.endip = "10.1.1.40"
cmd.forVirtualNetwork="false"
- response = self.apiclient.createVlanIpRange(cmd)
-
\ No newline at end of file
+ self.apiclient.createVlanIpRange(cmd)
+
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/component/test_base_image_updation.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_base_image_updation.py b/test/integration/component/test_base_image_updation.py
index 3c05996..081d855 100644
--- a/test/integration/component/test_base_image_updation.py
+++ b/test/integration/component/test_base_image_updation.py
@@ -31,7 +31,7 @@ from marvin.codes import (PASS,
from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import cloudstackTestCase
-from marvin.integration.lib.base import (ServiceOffering,
+from marvin.lib.base import (ServiceOffering,
Account,
VirtualMachine,
Volume,
@@ -41,13 +41,13 @@ from marvin.integration.lib.base import (ServiceOffering,
Template
)
-from marvin.integration.lib.common import (get_domain,
+from marvin.lib.common import (get_domain,
get_zone,
get_template,
list_templates
)
-from marvin.integration.lib.utils import (validateList,
+from marvin.lib.utils import (validateList,
cleanup_resources)
import time
@@ -161,14 +161,14 @@ class TestBaseImageUpdate(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(
- TestBaseImageUpdate,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestBaseImageUpdate, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
+
cls.template = get_template(
cls.api_client,
cls.zone.id,
@@ -238,6 +238,7 @@ class TestBaseImageUpdate(cloudstackTestCase):
def setUp(self):
self.apiclient = self.testClient.getApiClient()
+ self.hypervisor = self.testClient.getHypervisorInfo()
self.dbclient = self.testClient.getDbConnection()
self.cleanup = []
@@ -427,7 +428,8 @@ class TestBaseImageUpdate(cloudstackTestCase):
v,
zoneid=self.zone.id,
account=self.account.name,
- domainid=self.account.domainid
+ domainid=self.account.domainid,
+ hypervisor=self.hypervisor
)
self.debug(
"Registered a template of format: %s with ID: %s" % (
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/component/test_blocker_bugs.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_blocker_bugs.py b/test/integration/component/test_blocker_bugs.py
index 2828032..5c9a08c 100644
--- a/test/integration/component/test_blocker_bugs.py
+++ b/test/integration/component/test_blocker_bugs.py
@@ -16,15 +16,29 @@
# under the License.
""" Tests for Blocker bugs
"""
-import marvin
from nose.plugins.attrib import attr
-from marvin.integration.lib.base import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.common import *
+from marvin.lib.base import (Snapshot,
+ Template,
+ Domain,
+ Account,
+ ServiceOffering,
+ Network,
+ VirtualMachine,
+ PublicIPAddress,
+ StaticNATRule,
+ FireWallRule,
+ Volume)
+from marvin.lib.utils import cleanup_resources
+from marvin.lib.common import (get_zone,
+ get_domain,
+ get_template,
+ list_routers,
+ get_builtin_template_info)
#Import Local Modules
-from marvin.cloudstackTestCase import *
-from marvin.cloudstackAPI import *
+from marvin.cloudstackTestCase import cloudstackTestCase
+from marvin.cloudstackAPI import restartNetwork
+import time
class Services:
@@ -95,8 +109,8 @@ class Services:
class TestTemplate(cloudstackTestCase):
def setUp(self):
-
self.apiclient = self.testClient.getApiClient()
+ self.hypervisor = self.testClient.getHypervisorInfo()
self.dbclient = self.testClient.getDbConnection()
self.cleanup = []
return
@@ -110,12 +124,13 @@ class TestTemplate(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.services = Services().services
- cls.api_client = super(TestTemplate, cls).getClsTestClient().getApiClient()
+ cls.testClient = super(TestTemplate, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+ cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.services['mode'] = cls.zone.networktype
cls.services["virtual_machine"]["zoneid"] = cls.zone.id
cls.services["template"]["zoneid"] = cls.zone.id
@@ -173,7 +188,8 @@ class TestTemplate(cloudstackTestCase):
self.services["template"],
zoneid=self.zone.id,
account=self.account.name,
- domainid=self.account.domainid
+ domainid=self.account.domainid,
+ hypervisor=self.hypervisor
)
self.debug(
"Registered a template of format: %s with ID: %s" % (
@@ -242,12 +258,14 @@ class TestNATRules(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(TestNATRules, cls).getClsTestClient().getApiClient()
- cls.services = Services().services
+ cls.testClient = super(TestNATRules, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+ cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
+
cls.services['mode'] = cls.zone.networktype
template = get_template(
cls.api_client,
@@ -448,10 +466,12 @@ class TestRouters(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(TestRouters, cls).getClsTestClient().getApiClient()
+ cls.testClient = super(TestRouters, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.services['mode'] = cls.zone.networktype
cls.template = get_template(
cls.api_client,
@@ -573,11 +593,13 @@ class TestRouterRestart(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(TestRouterRestart, cls).getClsTestClient().getApiClient()
+ cls.testClient = super(TestRouterRestart, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
+ cls.domain = get_domain(cls.api_client)
cls.services['mode'] = cls.zone.networktype
template = get_template(
cls.api_client,
@@ -706,12 +728,14 @@ class TestTemplates(cloudstackTestCase):
@classmethod
def setUpClass(cls):
+ cls.testClient = super(TestTemplates, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
- cls.api_client = super(TestTemplates, cls).getClsTestClient().getApiClient()
+ # Get Zone, Domain and templates
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
+ cls.domain = get_domain(cls.api_client)
- # Get Zone, templates etc
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
cls.services['mode'] = cls.zone.networktype
template = get_template(
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/component/test_cpu_domain_limits.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_cpu_domain_limits.py b/test/integration/component/test_cpu_domain_limits.py
index c0bd9e7..6cca7c8 100644
--- a/test/integration/component/test_cpu_domain_limits.py
+++ b/test/integration/component/test_cpu_domain_limits.py
@@ -19,21 +19,21 @@
"""
# Import Local Modules
from nose.plugins.attrib import attr
-from marvin.cloudstackTestCase import cloudstackTestCase, unittest
-from marvin.integration.lib.base import (
+from marvin.cloudstackTestCase import cloudstackTestCase
+from marvin.lib.base import (
Account,
ServiceOffering,
VirtualMachine,
Resources,
Domain
)
-from marvin.integration.lib.common import (get_domain,
+from marvin.lib.common import (get_domain,
get_zone,
get_template,
findSuitableHostForMigration,
get_resource_type
)
-from marvin.integration.lib.utils import cleanup_resources
+from marvin.lib.utils import cleanup_resources
from marvin.codes import ERROR_NO_HOST_FOR_MIGRATION
class Services:
@@ -91,12 +91,13 @@ class TestDomainCPULimitsUpdateResources(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(TestDomainCPULimitsUpdateResources,
- cls).getClsTestClient().getApiClient()
+ cls.testClient = super(TestDomainCPULimitsUpdateResources, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.services["mode"] = cls.zone.networktype
cls.template = get_template(
cls.api_client,
@@ -237,7 +238,7 @@ class TestDomainCPULimitsUpdateResources(cloudstackTestCase):
self.account = admin
self.domain = domain
- api_client = self.testClient.createUserApiClient(
+ api_client = self.testClient.getUserApiClient(
UserName=self.account.name,
DomainName=self.account.domain)
@@ -310,7 +311,7 @@ class TestDomainCPULimitsUpdateResources(cloudstackTestCase):
self.account = admin
self.domain = domain
- api_client = self.testClient.createUserApiClient(
+ api_client = self.testClient.getUserApiClient(
UserName=self.account.name,
DomainName=self.account.domain)
@@ -371,7 +372,7 @@ class TestDomainCPULimitsUpdateResources(cloudstackTestCase):
self.account = admin
self.domain = domain
- api_client = self.testClient.createUserApiClient(
+ api_client = self.testClient.getUserApiClient(
UserName=self.account.name,
DomainName=self.account.domain)
@@ -435,7 +436,7 @@ class TestDomainCPULimitsUpdateResources(cloudstackTestCase):
self.account = admin
self.domain = domain
- api_client = self.testClient.createUserApiClient(
+ api_client = self.testClient.getUserApiClient(
UserName=self.account.name,
DomainName=self.account.domain)
@@ -505,12 +506,13 @@ class TestMultipleChildDomains(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(TestMultipleChildDomains,
- cls).getClsTestClient().getApiClient()
+ cls.testClient = super(TestMultipleChildDomains, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.services["mode"] = cls.zone.networktype
cls.template = get_template(
cls.api_client,
@@ -689,11 +691,11 @@ class TestMultipleChildDomains(cloudstackTestCase):
self.debug("Setting up account and domain hierarchy")
self.setupAccounts()
- api_client_cadmin_1 = self.testClient.createUserApiClient(
+ api_client_cadmin_1 = self.testClient.getUserApiClient(
UserName=self.cadmin_1.name,
DomainName=self.cadmin_1.domain)
- api_client_cadmin_2 = self.testClient.createUserApiClient(
+ api_client_cadmin_2 = self.testClient.getUserApiClient(
UserName=self.cadmin_2.name,
DomainName=self.cadmin_2.domain)
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/component/test_cpu_limits.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_cpu_limits.py b/test/integration/component/test_cpu_limits.py
index 9868bf2..2cf92f8 100644
--- a/test/integration/component/test_cpu_limits.py
+++ b/test/integration/component/test_cpu_limits.py
@@ -19,21 +19,21 @@
"""
# Import Local Modules
from nose.plugins.attrib import attr
-from marvin.cloudstackTestCase import cloudstackTestCase, unittest
-from marvin.integration.lib.base import (
+from marvin.cloudstackTestCase import cloudstackTestCase
+from marvin.lib.base import (
Account,
ServiceOffering,
VirtualMachine,
Domain,
Resources
)
-from marvin.integration.lib.common import (get_domain,
+from marvin.lib.common import (get_domain,
get_zone,
get_template,
findSuitableHostForMigration,
get_resource_type
)
-from marvin.integration.lib.utils import cleanup_resources
+from marvin.lib.utils import cleanup_resources
from marvin.codes import ERROR_NO_HOST_FOR_MIGRATION
@@ -92,12 +92,13 @@ class TestCPULimits(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(TestCPULimits,
- cls).getClsTestClient().getApiClient()
+ cls.testClient = super(TestCPULimits, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.services["mode"] = cls.zone.networktype
cls.template = get_template(
@@ -352,12 +353,14 @@ class TestDomainCPULimitsConfiguration(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(TestDomainCPULimitsConfiguration,
- cls).getClsTestClient().getApiClient()
+ cls.testClient = super(TestDomainCPULimitsConfiguration, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
+
cls.services["mode"] = cls.zone.networktype
cls.template = get_template(
cls.api_client,
@@ -481,7 +484,7 @@ class TestDomainCPULimitsConfiguration(cloudstackTestCase):
self.account = admin
self.domain = domain
- api_client = self.testClient.createUserApiClient(
+ api_client = self.testClient.getUserApiClient(
UserName=self.account.name,
DomainName=self.account.domain)
@@ -553,7 +556,7 @@ class TestDomainCPULimitsConfiguration(cloudstackTestCase):
self.account = admin
self.domain = domain
- api_client = self.testClient.createUserApiClient(
+ api_client = self.testClient.getUserApiClient(
UserName=self.account.name,
DomainName=self.account.domain)
@@ -613,7 +616,7 @@ class TestDomainCPULimitsConfiguration(cloudstackTestCase):
self.account = admin
self.domain = domain
- api_client = self.testClient.createUserApiClient(
+ api_client = self.testClient.getUserApiClient(
UserName=self.account.name,
DomainName=self.account.domain)
@@ -685,7 +688,7 @@ class TestDomainCPULimitsConfiguration(cloudstackTestCase):
if cpu_account_gc[0].max != 16:
self.skipTest("This test case requires configuration value max.account.cpus to be 16")
- api_client = self.testClient.createUserApiClient(
+ api_client = self.testClient.getUserApiClient(
UserName=self.account.name,
DomainName=self.account.domain)
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/component/test_cpu_max_limits.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_cpu_max_limits.py b/test/integration/component/test_cpu_max_limits.py
index c0d3048..a08ff6d 100644
--- a/test/integration/component/test_cpu_max_limits.py
+++ b/test/integration/component/test_cpu_max_limits.py
@@ -19,8 +19,8 @@
"""
# Import Local Modules
from nose.plugins.attrib import attr
-from marvin.cloudstackTestCase import cloudstackTestCase, unittest
-from marvin.integration.lib.base import (
+from marvin.cloudstackTestCase import cloudstackTestCase
+from marvin.lib.base import (
Account,
ServiceOffering,
VirtualMachine,
@@ -28,11 +28,11 @@ from marvin.integration.lib.base import (
Domain,
Project
)
-from marvin.integration.lib.common import (get_domain,
+from marvin.lib.common import (get_domain,
get_zone,
get_template
)
-from marvin.integration.lib.utils import cleanup_resources
+from marvin.lib.utils import cleanup_resources
class Services:
"""Test resource limit services
@@ -89,12 +89,13 @@ class TestMaxCPULimits(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(TestMaxCPULimits,
- cls).getClsTestClient().getApiClient()
+ cls.testClient = super(TestMaxCPULimits, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.services["mode"] = cls.zone.networktype
cls.template = get_template(
cls.api_client,
@@ -251,7 +252,7 @@ class TestMaxCPULimits(cloudstackTestCase):
self.debug("Setting up account and domain hierarchy")
self.setupAccounts(account_limit=4, domain_limit=2)
- api_client_admin = self.testClient.createUserApiClient(
+ api_client_admin = self.testClient.getUserApiClient(
UserName=self.child_do_admin.name,
DomainName=self.child_do_admin.domain)
@@ -284,7 +285,7 @@ class TestMaxCPULimits(cloudstackTestCase):
self.debug("Setting up account and domain hierarchy")
self.setupAccounts(account_limit=6, domain_limit=8)
- api_client_admin = self.testClient.createUserApiClient(
+ api_client_admin = self.testClient.getUserApiClient(
UserName=self.child_do_admin.name,
DomainName=self.child_do_admin.domain)
@@ -325,7 +326,7 @@ class TestMaxCPULimits(cloudstackTestCase):
self.debug("Setting up account and domain hierarchy")
self.setupAccounts(account_limit=4, domain_limit=4, project_limit=2)
- api_client_admin = self.testClient.createUserApiClient(
+ api_client_admin = self.testClient.getUserApiClient(
UserName=self.child_do_admin.name,
DomainName=self.child_do_admin.domain)
@@ -360,7 +361,7 @@ class TestMaxCPULimits(cloudstackTestCase):
self.debug("Setting up account and domain hierarchy")
self.setupAccounts(account_limit=6, domain_limit=6, project_limit=6)
- api_client_admin = self.testClient.createUserApiClient(
+ api_client_admin = self.testClient.getUserApiClient(
UserName=self.child_do_admin.name,
DomainName=self.child_do_admin.domain)
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/component/test_cpu_project_limits.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_cpu_project_limits.py b/test/integration/component/test_cpu_project_limits.py
index 8a355cf..b33b9f1 100644
--- a/test/integration/component/test_cpu_project_limits.py
+++ b/test/integration/component/test_cpu_project_limits.py
@@ -20,20 +20,20 @@
# Import Local Modules
from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import cloudstackTestCase, unittest
-from marvin.integration.lib.base import (
+from marvin.lib.base import (
Account,
ServiceOffering,
VirtualMachine,
Domain,
Project
)
-from marvin.integration.lib.common import (get_domain,
+from marvin.lib.common import (get_domain,
get_zone,
get_template,
findSuitableHostForMigration,
get_resource_type
)
-from marvin.integration.lib.utils import cleanup_resources
+from marvin.lib.utils import cleanup_resources
from marvin.codes import ERROR_NO_HOST_FOR_MIGRATION
class Services:
@@ -91,12 +91,13 @@ class TestProjectsCPULimits(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(TestProjectsCPULimits,
- cls).getClsTestClient().getApiClient()
+ cls.testClient = super(TestProjectsCPULimits, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.services["mode"] = cls.zone.networktype
cls.template = get_template(
cls.api_client,
@@ -137,7 +138,7 @@ class TestProjectsCPULimits(cloudstackTestCase):
self.debug("Setting up account and domain hierarchy")
self.setupProjectAccounts()
- api_client = self.testClient.createUserApiClient(
+ api_client = self.testClient.getUserApiClient(
UserName=self.admin.name,
DomainName=self.admin.domain)
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/component/test_custom_hostname.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_custom_hostname.py b/test/integration/component/test_custom_hostname.py
index baf4f1b..7eeda49 100644
--- a/test/integration/component/test_custom_hostname.py
+++ b/test/integration/component/test_custom_hostname.py
@@ -20,9 +20,9 @@
import marvin
from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
class Services:
@@ -94,13 +94,13 @@ class TestInstanceNameFlagTrue(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(
- TestInstanceNameFlagTrue,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestInstanceNameFlagTrue, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
- # Get Zone, default template
- cls.zone = get_zone(cls.api_client, cls.services)
+ # Get Zone, Domain and templates
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.services["mode"] = cls.zone.networktype
cls.template = get_template(
cls.api_client,
@@ -108,12 +108,7 @@ class TestInstanceNameFlagTrue(cloudstackTestCase):
cls.services["ostype"]
)
- # Create domains, account etc.
- cls.domain = get_domain(
- cls.api_client,
- cls.services
- )
-
+ # Create account
cls.account = Account.create(
cls.api_client,
cls.services["account"],
@@ -561,13 +556,13 @@ class TestInstanceNameFlagFalse(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(
- TestInstanceNameFlagFalse,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestInstanceNameFlagFalse, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
- # Get Zone, default template
- cls.zone = get_zone(cls.api_client, cls.services)
+ # Get Zone, Domain and templates
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.template = get_template(
cls.api_client,
@@ -575,12 +570,7 @@ class TestInstanceNameFlagFalse(cloudstackTestCase):
cls.services["ostype"]
)
- # Create domains, account etc.
- cls.domain = get_domain(
- cls.api_client,
- cls.services
- )
-
+ # Create account
cls.account = Account.create(
cls.api_client,
cls.services["account"],
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/component/test_deploy_vm_userdata_reg.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_deploy_vm_userdata_reg.py b/test/integration/component/test_deploy_vm_userdata_reg.py
index 912c917..1c9f35c 100755
--- a/test/integration/component/test_deploy_vm_userdata_reg.py
+++ b/test/integration/component/test_deploy_vm_userdata_reg.py
@@ -19,9 +19,9 @@
# this script will cover VMdeployment with Userdata tests
from marvin.cloudstackTestCase import cloudstackTestCase
-from marvin.integration.lib.base import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.common import *
+from marvin.lib.base import *
+from marvin.lib.utils import *
+from marvin.lib.common import *
from nose.plugins.attrib import attr
from marvin.sshClient import SshClient
import unittest
@@ -71,9 +71,10 @@ class TestDeployVmWithUserData(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.apiClient = super(TestDeployVmWithUserData, cls).getClsTestClient().getApiClient()
+ cls.testClient = super(TestDeployVmWithUserData, cls).getClsTestClient()
+ cls.apiClient = cls.testClient.getApiClient()
cls.services = Services().services
- cls.zone = get_zone(cls.apiClient, cls.services)
+ cls.zone = get_zone(cls.apiClient, cls.testClient.getZoneForTests())
if cls.zone.localstorageenabled:
#For devcloud since localstroage is enabled
cls.services["service_offering"]["storagetype"] = "local"
@@ -99,6 +100,10 @@ class TestDeployVmWithUserData(cloudstackTestCase):
cls.user_data_2kl = ''.join(random.choice(string.ascii_uppercase + string.digits) for x in range(1900))
+ def setUp(self):
+ self.apiClient = self.testClient.getApiClient()
+ self.hypervisor = self.testClient.getHypervisorInfo()
+
@attr(tags=["simulator", "devcloud", "basic", "advanced", "provisioning"])
def test_deployvm_userdata_post(self):
@@ -174,7 +179,7 @@ class TestDeployVmWithUserData(cloudstackTestCase):
host.passwd="password"
cmd="cat /var/www/html/userdata/"+deployVmResponse.ipaddress+"/user-data"
- if self.apiClient.hypervisor.lower() == 'vmware':
+ if self.hypervisor.lower() == 'vmware':
try:
result = get_process_status(
@@ -184,7 +189,7 @@ class TestDeployVmWithUserData(cloudstackTestCase):
self.apiClient.connection.passwd,
router.linklocalip,
cmd,
- hypervisor=self.apiClient.hypervisor
+ hypervisor=self.hypervisor
)
res = str(result)
self.assertEqual(res.__contains__(self.userdata),True,"Userdata Not applied Check the failures")
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/component/test_dynamic_compute_offering.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_dynamic_compute_offering.py b/test/integration/component/test_dynamic_compute_offering.py
index cb21caf..da43fdf 100644
--- a/test/integration/component/test_dynamic_compute_offering.py
+++ b/test/integration/component/test_dynamic_compute_offering.py
@@ -24,24 +24,13 @@
Feature Specifications: https://cwiki.apache.org/confluence/display/CLOUDSTACK/Dynamic+Compute+Offering+FS
"""
from marvin.cloudstackTestCase import cloudstackTestCase
-from marvin.integration.lib.utils import (cleanup_resources,
- validateList,
- random_gen)
-from marvin.integration.lib.base import (ServiceOffering,
- VirtualMachine,
- Account,
- Resources,
- AffinityGroup,
- Host)
-from marvin.integration.lib.common import (get_domain,
- get_zone,
- get_template,
- verifyComputeOfferingCreation)
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
from nose.plugins.attrib import attr
from marvin.codes import PASS, ADMIN_ACCOUNT, USER_ACCOUNT
from ddt import ddt, data
-import time
@ddt
class TestDynamicServiceOffering(cloudstackTestCase):
@@ -50,21 +39,22 @@ class TestDynamicServiceOffering(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cloudstackTestClient = super(TestDynamicServiceOffering,cls).getClsTestClient()
- cls.api_client = cloudstackTestClient.getApiClient()
-
- # Fill services from the external config file
- cls.services = cloudstackTestClient.getConfigParser().parsedDict
+ testClient = super(TestDynamicServiceOffering, cls).getClsTestClient()
+ cls.apiclient = testClient.getApiClient()
+ cls.services = testClient.getParsedTestDataConfig()
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
- cls.mode = str(cls.zone.networktype).lower()
- cls.template = get_template(
- cls.api_client,
- cls.zone.id,
- cls.services["ostype"]
- )
+ domain = get_domain(cls.apiclient)
+ cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests())
+ cls.services['mode'] = cls.zone.networktype
+
+ template = get_template(
+ cls.apiclient,
+ cls.zone.id,
+ cls.services["ostype"]
+ )
+ if template == FAILED:
+ assert False, "get_template() failed to return template with description %s" % cls.services["ostype"]
cls.services["virtual_machine"]["zoneid"] = cls.zone.id
cls.services["virtual_machine"]["template"] = cls.template.id
cls._cleanup = []
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/component/test_egress_fw_rules.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_egress_fw_rules.py b/test/integration/component/test_egress_fw_rules.py
index 6060115..4b4b6ee 100644
--- a/test/integration/component/test_egress_fw_rules.py
+++ b/test/integration/component/test_egress_fw_rules.py
@@ -21,7 +21,7 @@
import unittest
from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import cloudstackTestCase
-from marvin.integration.lib.base import (Account,
+from marvin.lib.base import (Account,
Domain,
Router,
Network,
@@ -31,14 +31,14 @@ from marvin.integration.lib.base import (Account,
FireWallRule,
NATRule,
PublicIPAddress)
-from marvin.integration.lib.common import (get_domain,
+from marvin.lib.common import (get_domain,
get_zone,
get_template,
list_routers,
wait_for_cleanup,
list_virtual_machines
)
-from marvin.integration.lib.utils import cleanup_resources, validateList
+from marvin.lib.utils import cleanup_resources, validateList
from marvin.cloudstackAPI import rebootRouter
from marvin.cloudstackAPI.createEgressFirewallRule import createEgressFirewallRuleCmd
from marvin.cloudstackAPI.deleteEgressFirewallRule import deleteEgressFirewallRuleCmd
@@ -132,12 +132,13 @@ class TestEgressFWRules(cloudstackTestCase):
@classmethod
def setUpClass(cls):
cls._cleanup = []
- cls.api_client = super(TestEgressFWRules,
- cls).getClsTestClient().getApiClient()
- cls.services = Services().services
- # Get Zone Domain and create Domains and sub Domains.
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.testClient = super(TestEgressFWRules, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
+ cls.services = Services().services
+ # Get Zone, Domain and templates
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.services['mode'] = cls.zone.networktype
# Get and set template id for VM creation.
cls.template = get_template(cls.api_client,
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/component/test_egress_rules.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_egress_rules.py b/test/integration/component/test_egress_rules.py
index a2443d4..f0b98e4 100644
--- a/test/integration/component/test_egress_rules.py
+++ b/test/integration/component/test_egress_rules.py
@@ -20,13 +20,13 @@
#Import Local Modules
from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import cloudstackTestCase
-from marvin.integration.lib.utils import (random_gen,
+from marvin.lib.utils import (random_gen,
cleanup_resources)
-from marvin.integration.lib.base import (SecurityGroup,
+from marvin.lib.base import (SecurityGroup,
VirtualMachine,
Account,
ServiceOffering)
-from marvin.integration.lib.common import (get_domain,
+from marvin.lib.common import (get_domain,
get_zone,
get_template,
list_virtual_machines)
@@ -149,15 +149,13 @@ class TestDefaultSecurityGroupEgress(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.services = Services().services
- cls.api_client = super(
- TestDefaultSecurityGroupEgress,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestDefaultSecurityGroupEgress, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+ cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.services['mode'] = cls.zone.networktype
template = get_template(
@@ -307,15 +305,13 @@ class TestAuthorizeIngressRule(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.services = Services().services
- cls.api_client = super(
- TestAuthorizeIngressRule,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestAuthorizeIngressRule, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+ cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.services['mode'] = cls.zone.networktype
template = get_template(
@@ -465,15 +461,13 @@ class TestDefaultGroupEgress(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.services = Services().services
- cls.api_client = super(
- TestDefaultGroupEgress,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestDefaultGroupEgress, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+ cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.services['mode'] = cls.zone.networktype
template = get_template(
@@ -663,15 +657,13 @@ class TestDefaultGroupEgressAfterDeploy(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.services = Services().services
- cls.api_client = super(
- TestDefaultGroupEgressAfterDeploy,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestDefaultGroupEgressAfterDeploy, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+ cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.services['mode'] = cls.zone.networktype
template = get_template(
@@ -842,15 +834,13 @@ class TestRevokeEgressRule(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.services = Services().services
- cls.api_client = super(
- TestRevokeEgressRule,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestRevokeEgressRule, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+ cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.services['mode'] = cls.zone.networktype
template = get_template(
@@ -1125,15 +1115,13 @@ class TestInvalidAccountAuthroize(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.services = Services().services
- cls.api_client = super(
- TestInvalidAccountAuthroize,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestInvalidAccountAuthroize, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+ cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.services['mode'] = cls.zone.networktype
template = get_template(
@@ -1246,15 +1234,13 @@ class TestMultipleAccountsEgressRuleNeg(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.services = Services().services
- cls.api_client = super(
- TestMultipleAccountsEgressRuleNeg,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestMultipleAccountsEgressRuleNeg, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+ cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.services['mode'] = cls.zone.networktype
template = get_template(
@@ -1495,15 +1481,13 @@ class TestMultipleAccountsEgressRule(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.services = Services().services
- cls.api_client = super(
- TestMultipleAccountsEgressRule,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestMultipleAccountsEgressRule, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+ cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.services['mode'] = cls.zone.networktype
template = get_template(
@@ -1786,15 +1770,13 @@ class TestStartStopVMWithEgressRule(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.services = Services().services
- cls.api_client = super(
- TestStartStopVMWithEgressRule,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestStartStopVMWithEgressRule, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+ cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.services['mode'] = cls.zone.networktype
template = get_template(
@@ -1993,15 +1975,13 @@ class TestInvalidParametersForEgress(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.services = Services().services
- cls.api_client = super(
- TestInvalidParametersForEgress,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestInvalidParametersForEgress, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+ cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.services['mode'] = cls.zone.networktype
template = get_template(
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/component/test_eip_elb.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_eip_elb.py b/test/integration/component/test_eip_elb.py
index d639d82..0613c4d 100644
--- a/test/integration/component/test_eip_elb.py
+++ b/test/integration/component/test_eip_elb.py
@@ -22,9 +22,9 @@ import marvin
from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
from marvin.sshClient import SshClient
import datetime
@@ -91,11 +91,13 @@ class TestEIP(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(TestEIP, cls).getClsTestClient().getApiClient()
+ cls.testClient = super(TestEIP, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.services['mode'] = cls.zone.networktype
cls.template = get_template(
cls.api_client,
@@ -909,11 +911,13 @@ class TestELB(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(TestELB, cls).getClsTestClient().getApiClient()
+ cls.testClient = super(TestELB, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.services['mode'] = cls.zone.networktype
cls.template = get_template(
cls.api_client,
[06/18] Marvin + test changes from master Signed-off-by:
SrikanteswaraRao Talluri
Posted by da...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/tools/marvin/marvin/deployDataCenter.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/deployDataCenter.py b/tools/marvin/marvin/deployDataCenter.py
index e5a0749..31f663e 100644
--- a/tools/marvin/marvin/deployDataCenter.py
+++ b/tools/marvin/marvin/deployDataCenter.py
@@ -15,469 +15,768 @@
# specific language governing permissions and limitations
# under the License.
-"""Deploy datacenters according to a json configuration file"""
-import configGenerator
-import cloudstackException
-import cloudstackTestClient
-import logging
-from cloudstackAPI import *
-from os import path
-from time import sleep
+"""
+@Desc :
+class DeployDataCenters: Deploys DeleteDataCenters according to a json
+ configuration file.
+class DeleteDataCenters: Deletes a DataCenter based upon the dc cfg
+ settings provided.
+ This settings file is the exported
+ configuration from DeployDataCenters post
+ its success
+"""
+from marvin import configGenerator
+from marvin.cloudstackException import (
+ InvalidParameterException,
+ GetDetailExceptionInfo)
+from marvin.cloudstackAPI import *
+from marvin.codes import (FAILED, SUCCESS)
+from marvin.lib.utils import (random_gen)
+from marvin.config.test_data import test_data
+from sys import exit
+import os
+import pickle
+from time import sleep, strftime, localtime
from optparse import OptionParser
-class deployDataCenters(object):
-
- def __init__(self, cfg, logger=None):
- self.config = cfg
- self.tcRunLogger = logger
+class DeployDataCenters(object):
+
+ '''
+ @Desc : Deploys the Data Center with information provided.
+ Once the Deployment is successful, it will export
+ the DataCenter settings to an obj file
+ ( can be used if wanted to delete the created DC)
+ '''
+
+ def __init__(self,
+ test_client,
+ cfg,
+ logger=None,
+ log_folder_path=None
+ ):
+ self.__testClient = test_client
+ self.__config = cfg
+ self.__tcRunLogger = logger
+ self.__logFolderPath = log_folder_path
+ self.__apiClient = None
+ self.__cleanUp = {}
+
+ def __persistDcConfig(self):
+ try:
+ if self.__logFolderPath:
+ dc_file_path = self.__logFolderPath + "/dc_entries.obj"
+ else:
+ ts = strftime("%b_%d_%Y_%H_%M_%S", localtime())
+ dc_file_path = "dc_entries_" + str(ts) + ".obj"
+ file_to_write = open(dc_file_path, 'w')
+ if file_to_write:
+ pickle.dump(self.__cleanUp, file_to_write)
+ print "\n=== Data Center Settings are dumped to %s===" % \
+ dc_file_path
+ self.__tcRunLogger.debug(
+ "\n=== Data Center Settings are dumped to %s===" %
+ dc_file_path)
+ except Exception as e:
+ print "Exception Occurred while persisting DC Settings: %s" % \
+ GetDetailExceptionInfo(e)
+
+ def __cleanAndExit(self):
+ try:
+ print "\n===deploy dc failed, so cleaning the created entries==="
+ if not test_data.get("deleteDC", None):
+ print "\n=== Deploy DC Clean Up flag not set. So, exiting ==="
+ exit(1)
+ self.__tcRunLogger.debug(
+ "===Deploy DC Failed, So Cleaning to Exit===")
+ remove_dc_obj = DeleteDataCenters(self.__testClient,
+ dc_cfg=self.__cleanUp,
+ tc_run_logger=self.__tcRunLogger
+ )
+ if remove_dc_obj:
+ if remove_dc_obj.removeDataCenter() == FAILED:
+ print "\n===Removing DataCenter Failed==="
+ self.__tcRunLogger.debug(
+ "===Removing DataCenter Failed===")
+ else:
+ print "\n===Removing DataCenter Successful==="
+ self.__tcRunLogger.debug(
+ "===Removing DataCenter Successful===")
+ exit(1)
+ except Exception as e:
+ print "Exception Occurred during DC CleanUp: %s" % \
+ GetDetailExceptionInfo(e)
+
+ def __addToCleanUp(self, type, id):
+ if type not in self.__cleanUp.keys():
+ self.__cleanUp[type] = []
+ self.__cleanUp[type].append(id)
+ if "order" not in self.__cleanUp.keys():
+ self.__cleanUp["order"] = []
+ if type not in self.__cleanUp["order"]:
+ self.__cleanUp["order"].append(type)
def addHosts(self, hosts, zoneId, podId, clusterId, hypervisor):
- if hosts is None:
- return
- for host in hosts:
- hostcmd = addHost.addHostCmd()
- hostcmd.clusterid = clusterId
- hostcmd.cpunumber = host.cpunumer
- hostcmd.cpuspeed = host.cpuspeed
- hostcmd.hostmac = host.hostmac
- hostcmd.hosttags = host.hosttags
- hostcmd.hypervisor = host.hypervisor
- hostcmd.memory = host.memory
- hostcmd.password = host.password
- hostcmd.podid = podId
- hostcmd.url = host.url
- hostcmd.username = host.username
- hostcmd.zoneid = zoneId
- hostcmd.hypervisor = hypervisor
- self.apiClient.addHost(hostcmd)
+ try:
+ if hosts is None:
+ return
+ for host in hosts:
+ hostcmd = addHost.addHostCmd()
+ hostcmd.clusterid = clusterId
+ hostcmd.cpunumber = host.cpunumer
+ hostcmd.cpuspeed = host.cpuspeed
+ hostcmd.hostmac = host.hostmac
+ hostcmd.hosttags = host.hosttags
+ hostcmd.hypervisor = host.hypervisor
+ hostcmd.memory = host.memory
+ hostcmd.password = host.password
+ hostcmd.podid = podId
+ hostcmd.url = host.url
+ hostcmd.username = host.username
+ hostcmd.zoneid = zoneId
+ hostcmd.hypervisor = hypervisor
+ ret = self.__apiClient.addHost(hostcmd)
+ if ret:
+ self.__tcRunLogger.debug("=== Add Host Successful ===")
+ self.__addToCleanUp("Host", ret[0].id)
+ except Exception as e:
+ print "Exception Occurred %s" % GetDetailExceptionInfo(e)
+ self.__tcRunLogger.exception("=== Adding Host Failed ===")
+ self.__cleanAndExit()
def addVmWareDataCenter(self, vmwareDc):
- vdc = addVmwareDc.addVmwareDcCmd()
- vdc.zoneid = vmwareDc.zoneid
- vdc.name = vmwareDc.name
- vdc.vcenter = vmwareDc.vcenter
- vdc.username = vmwareDc.username
- vdc.password = vmwareDc.password
- self.apiClient.addVmwareDc(vdc)
+ try:
+ vdc = addVmwareDc.addVmwareDcCmd()
+ vdc.zoneid = vmwareDc.zoneid
+ vdc.name = vmwareDc.name
+ vdc.vcenter = vmwareDc.vcenter
+ vdc.username = vmwareDc.username
+ vdc.password = vmwareDc.password
+ ret = self.__apiClient.addVmwareDc(vdc)
+ if ret.id:
+ self.__tcRunLogger.debug("=== Adding VmWare DC Successful===")
+ self.__addToCleanUp("VmwareDc", ret.id)
+ except Exception as e:
+ print "Exception Occurred: %s" % GetDetailExceptionInfo(e)
+ self.__tcRunLogger.exception("=== Adding VmWare DC Failed===")
+ self.__cleanAndExit()
def createClusters(self, clusters, zoneId, podId, vmwareDc=None):
- if clusters is None:
- return
-
- if vmwareDc is not None:
- vmwareDc.zoneid = zoneId
- self.addVmWareDataCenter(vmwareDc)
-
- for cluster in clusters:
- clustercmd = addCluster.addClusterCmd()
- clustercmd.clustername = cluster.clustername
- clustercmd.clustertype = cluster.clustertype
- clustercmd.hypervisor = cluster.hypervisor
- clustercmd.password = cluster.password
- clustercmd.podid = podId
- clustercmd.url = cluster.url
- clustercmd.username = cluster.username
- clustercmd.zoneid = zoneId
- clusterresponse = self.apiClient.addCluster(clustercmd)
- clusterId = clusterresponse[0].id
-
- if cluster.hypervisor.lower() != "vmware":
- self.addHosts(cluster.hosts, zoneId, podId, clusterId,
- cluster.hypervisor)
- self.waitForHost(zoneId, clusterId)
- self.createPrimaryStorages(cluster.primaryStorages, zoneId, podId,
- clusterId)
+ try:
+ if clusters is None:
+ return
+ if vmwareDc is not None:
+ vmwareDc.zoneid = zoneId
+ self.addVmWareDataCenter(vmwareDc)
+
+ for cluster in clusters:
+ clustercmd = addCluster.addClusterCmd()
+ clustercmd.clustername = cluster.clustername
+ clustercmd.clustertype = cluster.clustertype
+ clustercmd.hypervisor = cluster.hypervisor
+ clustercmd.password = cluster.password
+ clustercmd.podid = podId
+ clustercmd.url = cluster.url
+ clustercmd.username = cluster.username
+ clustercmd.zoneid = zoneId
+ clusterresponse = self.__apiClient.addCluster(clustercmd)
+ if clusterresponse[0].id:
+ clusterId = clusterresponse[0].id
+ self.__tcRunLogger.\
+ debug("Cluster Name : %s Id : %s Created Successfully"
+ % (str(cluster.clustername), str(clusterId)))
+ self.__addToCleanUp("Cluster", clusterId)
+ if cluster.hypervisor.lower() != "vmware":
+ self.addHosts(cluster.hosts, zoneId, podId, clusterId,
+ cluster.hypervisor)
+ self.waitForHost(zoneId, clusterId)
+ self.createPrimaryStorages(cluster.primaryStorages,
+ zoneId,
+ podId,
+ clusterId)
+ except Exception as e:
+ print "Exception Occurred %s" % GetDetailExceptionInfo(e)
+ self.__tcRunLogger.exception("====Cluster %s Creation Failed"
+ "=====" %
+ str(cluster.clustername))
+ self.__cleanAndExit()
def waitForHost(self, zoneId, clusterId):
"""
Wait for the hosts in the zoneid, clusterid to be up
-
2 retries with 30s delay
"""
- retry, timeout = 2, 30
- cmd = listHosts.listHostsCmd()
- cmd.clusterid, cmd.zoneid = clusterId, zoneId
- hosts = self.apiClient.listHosts(cmd)
- while retry != 0:
- for host in hosts:
- if host.state != 'Up':
- break
- sleep(timeout)
- retry = retry - 1
-
- def createPrimaryStorages(self, primaryStorages, zoneId, podId, clusterId):
- if primaryStorages is None:
- return
- for primary in primaryStorages:
- primarycmd = createStoragePool.createStoragePoolCmd()
- primarycmd.details = primary.details
- primarycmd.name = primary.name
- primarycmd.podid = podId
- primarycmd.tags = primary.tags
- primarycmd.url = primary.url
- primarycmd.zoneid = zoneId
- primarycmd.clusterid = clusterId
- self.apiClient.createStoragePool(primarycmd)
-
- def createPods(self, pods, zoneId, networkId=None):
- if pods is None:
- return
- for pod in pods:
- createpod = createPod.createPodCmd()
- createpod.name = pod.name
- createpod.gateway = pod.gateway
- createpod.netmask = pod.netmask
- createpod.startip = pod.startip
- createpod.endip = pod.endip
- createpod.zoneid = zoneId
- createpodResponse = self.apiClient.createPod(createpod)
- podId = createpodResponse.id
-
- if pod.guestIpRanges is not None and networkId is not None:
- self.createVlanIpRanges("Basic", pod.guestIpRanges, zoneId,
- podId, networkId)
-
- self.createClusters(pod.clusters, zoneId, podId,
- vmwareDc=pod.vmwaredc)
+ try:
+ retry, timeout = 2, 30
+ cmd = listHosts.listHostsCmd()
+ cmd.clusterid, cmd.zoneid = clusterId, zoneId
+ hosts = self.__apiClient.listHosts(cmd)
+ while retry != 0:
+ for host in hosts:
+ if host.state != 'Up':
+ break
+ sleep(timeout)
+ retry = retry - 1
+ except Exception as e:
+ print "\nException Occurred:%s" %\
+ GetDetailExceptionInfo(e)
+ self.__tcRunLogger.exception("=== List Hosts Failed===")
+ self.__cleanAndExit()
+
+ def createPrimaryStorages(self,
+ primaryStorages,
+ zoneId,
+ podId,
+ clusterId):
+ try:
+ if primaryStorages is None:
+ return
+ for primary in primaryStorages:
+ primarycmd = createStoragePool.createStoragePoolCmd()
+ primarycmd.details = primary.details
+ primarycmd.name = primary.name
+ primarycmd.podid = podId
+ primarycmd.tags = primary.tags
+ primarycmd.url = primary.url
+ primarycmd.zoneid = zoneId
+ primarycmd.clusterid = clusterId
+ ret = self.__apiClient.createStoragePool(primarycmd)
+ if ret.id:
+ self.__tcRunLogger.debug(
+ "=== Creating Storage Pool Successful===")
+ self.__addToCleanUp("StoragePool", ret.id)
+ except Exception as e:
+ print "Exception Occurred: %s" % GetDetailExceptionInfo(e)
+ self.__tcRunLogger.\
+ exception("=== Create Storage Pool Failed===")
+ self.__cleanAndExit()
+
+ def createPods(self,
+ pods,
+ zoneId,
+ networkId=None):
+ try:
+ if pods is None:
+ return
+ for pod in pods:
+ createpod = createPod.createPodCmd()
+ createpod.name = pod.name
+ createpod.gateway = pod.gateway
+ createpod.netmask = pod.netmask
+ createpod.startip = pod.startip
+ createpod.endip = pod.endip
+ createpod.zoneid = zoneId
+ createpodResponse = self.__apiClient.createPod(createpod)
+ if createpodResponse.id:
+ podId = createpodResponse.id
+ self.__tcRunLogger.debug("Pod Name : %s Id : %s "
+ "Created Successfully" %
+ (str(pod.name), str(podId)))
+ self.__addToCleanUp("Pod", podId)
+ if pod.guestIpRanges is not None and networkId is not None:
+ self.createVlanIpRanges("Basic", pod.guestIpRanges, zoneId,
+ podId, networkId)
+ self.createClusters(pod.clusters, zoneId, podId,
+ vmwareDc=pod.vmwaredc)
+ except Exception as e:
+ print "Exception Occurred: %s" % GetDetailExceptionInfo(e)
+ self.__tcRunLogger.\
+ exception("====Pod: %s Creation "
+ "Failed=====" % str(pod.name))
+ self.__cleanAndExit()
def createVlanIpRanges(self, mode, ipranges, zoneId, podId=None,
networkId=None, forvirtualnetwork=None):
- if ipranges is None:
- return
- for iprange in ipranges:
- vlanipcmd = createVlanIpRange.createVlanIpRangeCmd()
- vlanipcmd.account = iprange.account
- vlanipcmd.domainid = iprange.domainid
- vlanipcmd.endip = iprange.endip
- vlanipcmd.gateway = iprange.gateway
- vlanipcmd.netmask = iprange.netmask
- vlanipcmd.networkid = networkId
- vlanipcmd.podid = podId
- vlanipcmd.startip = iprange.startip
- vlanipcmd.zoneid = zoneId
- vlanipcmd.vlan = iprange.vlan
- if mode == "Basic":
- if forvirtualnetwork:
- vlanipcmd.forvirtualnetwork = "true"
+ try:
+ if ipranges is None:
+ return
+ for iprange in ipranges:
+ vlanipcmd = createVlanIpRange.createVlanIpRangeCmd()
+ vlanipcmd.account = iprange.account
+ vlanipcmd.domainid = iprange.domainid
+ vlanipcmd.endip = iprange.endip
+ vlanipcmd.gateway = iprange.gateway
+ vlanipcmd.netmask = iprange.netmask
+ vlanipcmd.networkid = networkId
+ vlanipcmd.podid = podId
+ vlanipcmd.startip = iprange.startip
+ vlanipcmd.zoneid = zoneId
+ vlanipcmd.vlan = iprange.vlan
+ if mode == "Basic":
+ if forvirtualnetwork:
+ vlanipcmd.forvirtualnetwork = "true"
+ else:
+ vlanipcmd.forvirtualnetwork = "false"
else:
- vlanipcmd.forvirtualnetwork = "false"
- else:
- vlanipcmd.forvirtualnetwork = "true"
- self.apiClient.createVlanIpRange(vlanipcmd)
+ vlanipcmd.forvirtualnetwork = "true"
+ ret = self.__apiClient.createVlanIpRange(vlanipcmd)
+ if ret.id:
+ self.__tcRunLogger.debug(
+ "=== Creating Vlan Ip Range Successful===")
+ self.__addToCleanUp("VlanIpRange", ret.id)
+ except Exception as e:
+ print "Exception Occurred: %s" % GetDetailExceptionInfo(e)
+ self.__tcRunLogger.\
+ exception("=== Create Vlan Ip Range Failed===")
+ self.__cleanAndExit()
def createSecondaryStorages(self, secondaryStorages, zoneId):
- if secondaryStorages is None:
- return
- for secondary in secondaryStorages:
- secondarycmd = addImageStore.addImageStoreCmd()
- secondarycmd.url = secondary.url
- secondarycmd.provider = secondary.provider
- secondarycmd.details = []
-
- if secondarycmd.provider == 'S3' \
- or secondarycmd.provider == "Swift":
- for key, value in vars(secondary.details).iteritems():
- secondarycmd.details.append({
+ try:
+ if secondaryStorages is None:
+ return
+ for secondary in secondaryStorages:
+ secondarycmd = addImageStore.addImageStoreCmd()
+ secondarycmd.url = secondary.url
+ secondarycmd.provider = secondary.provider
+ secondarycmd.details = []
+
+ if secondarycmd.provider == 'S3' \
+ or secondarycmd.provider == "Swift":
+ for key, value in vars(secondary.details).iteritems():
+ secondarycmd.details.append({
+ 'key': key,
+ 'value': value
+ })
+ if secondarycmd.provider == "NFS":
+ secondarycmd.zoneid = zoneId
+ ret = self.__apiClient.addImageStore(secondarycmd)
+ if ret.id:
+ self.__tcRunLogger.debug(
+ "===Add Image Store Successful===")
+ self.__addToCleanUp("ImageStore", ret.id)
+ except Exception as e:
+ print "Exception Occurred: %s" % GetDetailExceptionInfo(e)
+ self.__tcRunLogger.\
+ exception("=== Add Image Store Failed===")
+ self.__cleanAndExit()
+
+ def createCacheStorages(self, cacheStorages, zoneId):
+ try:
+ if cacheStorages is None:
+ return
+ for cache in cacheStorages:
+ cachecmd = createSecondaryStagingStore.\
+ createSecondaryStagingStoreCmd()
+ cachecmd.url = cache.url
+ cachecmd.provider = cache.provider
+ cachecmd.zoneid = zoneId
+ cachecmd.details = []
+
+ if cache.details:
+ for key, value in vars(cache.details).iteritems():
+ cachecmd.details.append({
'key': key,
'value': value
})
- if secondarycmd.provider == "NFS":
- secondarycmd.zoneid = zoneId
- self.apiClient.addImageStore(secondarycmd)
-
- def createCacheStorages(self, cacheStorages, zoneId):
- if cacheStorages is None:
- return
- for cache in cacheStorages:
- cachecmd = createSecondaryStagingStore.\
- createSecondaryStagingStoreCmd()
- cachecmd.url = cache.url
- cachecmd.provider = cache.provider
- cachecmd.zoneid = zoneId
- cachecmd.details = []
-
- if cache.details:
- for key, value in vars(cache.details).iteritems():
- cachecmd.details.append({
- 'key': key,
- 'value': value
- })
- self.apiClient.createSecondaryStagingStore(cachecmd)
+ ret = self.__apiClient.createSecondaryStagingStore(cachecmd)
+ if ret.id:
+ self.__tcRunLogger.debug(
+ "===Creating Secondary StagingStore Successful===")
+ self.__addToCleanUp("SecondaryStagingStore", ret.id)
+ except Exception as e:
+ print "Exception Occurred: %s" % GetDetailExceptionInfo(e)
+ self.__tcRunLogger.\
+ exception("=== Creating "
+ "SecondaryStagingStorage Failed===")
+ self.__cleanAndExit()
def createNetworks(self, networks, zoneId):
- if networks is None:
- return
- for network in networks:
- networkcmd = createNetwork.createNetworkCmd()
- networkcmd.displaytext = network.displaytext
- networkcmd.name = network.name
- networkcmd.networkofferingid = network.networkofferingid
- networkcmd.zoneid = zoneId
-
- ipranges = network.ipranges
- if ipranges:
- iprange = ipranges.pop()
- networkcmd.startip = iprange.startip
- networkcmd.endip = iprange.endip
- networkcmd.gateway = iprange.gateway
- networkcmd.netmask = iprange.netmask
-
- networkcmdresponse = self.apiClient.createNetwork(networkcmd)
- networkId = networkcmdresponse.id
- return networkId
+ try:
+ if networks is None:
+ return
+ for network in networks:
+ networkcmd = createNetwork.createNetworkCmd()
+ networkcmd.displaytext = network.displaytext
+ networkcmd.name = network.name
+ networkcmd.networkofferingid = network.networkofferingid
+ networkcmd.zoneid = zoneId
+
+ ipranges = network.ipranges
+ if ipranges:
+ iprange = ipranges.pop()
+ networkcmd.startip = iprange.startip
+ networkcmd.endip = iprange.endip
+ networkcmd.gateway = iprange.gateway
+ networkcmd.netmask = iprange.netmask
+ networkcmdresponse = self.__apiClient.createNetwork(networkcmd)
+ if networkcmdresponse.id:
+ networkId = networkcmdresponse.id
+ self.__tcRunLogger.\
+ debug("Creating Network Name : %s Id : %s Successful"
+ % (str(network.name), str(networkId)))
+ self.__addToCleanUp("Network", networkId)
+ return networkId
+ except Exception as e:
+ print "Exception Occurred %s" % GetDetailExceptionInfo(e)
+ self.__tcRunLogger.\
+ exception("====Network : %s "
+ "Creation Failed=====" % str(network.name))
+ self.__cleanAndExit()
def createPhysicalNetwork(self, net, zoneid):
- phynet = createPhysicalNetwork.createPhysicalNetworkCmd()
- phynet.zoneid = zoneid
- phynet.name = net.name
- phynet.isolationmethods = net.isolationmethods
- phynetwrk = self.apiClient.createPhysicalNetwork(phynet)
- self.addTrafficTypes(phynetwrk.id, net.traffictypes)
- return phynetwrk
-
- def updatePhysicalNetwork(self, networkid, state="Enabled", vlan=None):
- upnet = updatePhysicalNetwork.updatePhysicalNetworkCmd()
- upnet.id = networkid
- upnet.state = state
- if vlan:
- upnet.vlan = vlan
- return self.apiClient.updatePhysicalNetwork(upnet)
+ try:
+ phynet = createPhysicalNetwork.createPhysicalNetworkCmd()
+ phynet.zoneid = zoneid
+ phynet.name = net.name
+ phynet.isolationmethods = net.isolationmethods
+ phynetwrk = self.__apiClient.createPhysicalNetwork(phynet)
+ if phynetwrk.id:
+ self.__tcRunLogger.\
+ debug("Creating Physical Network Name : "
+ "%s Id : %s Successful" % (str(phynet.name),
+ str(phynetwrk.id)))
+ self.__addToCleanUp("PhysicalNetwork", phynetwrk.id)
+ self.addTrafficTypes(phynetwrk.id, net.traffictypes)
+ return phynetwrk
+ except Exception as e:
+ print "Exception Occurred: %s" % GetDetailExceptionInfo(e)
+ self.__tcRunLogger.exception("====Physical Network "
+ "Creation Failed=====")
+ self.__cleanAndExit()
+
+ def updatePhysicalNetwork(self, networkid, state="Enabled",
+ vlan=None):
+ try:
+ upnet = updatePhysicalNetwork.updatePhysicalNetworkCmd()
+ upnet.id = networkid
+ upnet.state = state
+ if vlan:
+ upnet.vlan = vlan
+ ret = self.__apiClient.updatePhysicalNetwork(upnet)
+ return ret
+ except Exception as e:
+ print "Exception Occurred: %s" % GetDetailExceptionInfo(e)
+ self.__tcRunLogger.\
+ exception("====Update Physical Network Failed=====")
+ self.__cleanAndExit()
def enableProvider(self, provider_id):
- upnetprov =\
- updateNetworkServiceProvider.updateNetworkServiceProviderCmd()
- upnetprov.id = provider_id
- upnetprov.state = "Enabled"
- self.apiClient.updateNetworkServiceProvider(upnetprov)
+ try:
+ upnetprov =\
+ updateNetworkServiceProvider.updateNetworkServiceProviderCmd()
+ upnetprov.id = provider_id
+ upnetprov.state = "Enabled"
+ ret = self.__apiClient.updateNetworkServiceProvider(upnetprov)
+ if ret.id:
+ self.__tcRunLogger.debug(
+ "===Update Network Service Provider Successfull===")
+ except Exception as e:
+ print "Exception Occurred: %s" % GetDetailExceptionInfo(e)
+ self.__tcRunLogger.\
+ exception(
+ "====Update Network Service Provider Failed=====")
+ self.__cleanAndExit()
def configureProviders(self, phynetwrk, providers):
"""
We will enable the virtualrouter elements for all zones. Other
providers like NetScalers, SRX, etc are explicitly added/configured
"""
-
- for provider in providers:
- pnetprov = listNetworkServiceProviders.\
- listNetworkServiceProvidersCmd()
- pnetprov.physicalnetworkid = phynetwrk.id
- pnetprov.state = "Disabled"
- pnetprov.name = provider.name
- pnetprovres = self.apiClient.listNetworkServiceProviders(pnetprov)
-
- if pnetprovres and len(pnetprovres) > 0:
- if provider.name == 'VirtualRouter'\
- or provider.name == 'VpcVirtualRouter':
- vrprov = listVirtualRouterElements.\
- listVirtualRouterElementsCmd()
- vrprov.nspid = pnetprovres[0].id
- vrprovresponse = self.apiClient.\
- listVirtualRouterElements(vrprov)
- vrprovid = vrprovresponse[0].id
-
- vrconfig = \
- configureVirtualRouterElement.\
- configureVirtualRouterElementCmd()
- vrconfig.enabled = "true"
- vrconfig.id = vrprovid
- self.apiClient.configureVirtualRouterElement(vrconfig)
- self.enableProvider(pnetprovres[0].id)
- elif provider.name == 'InternalLbVm':
- internallbprov = listInternalLoadBalancerElements.\
- listInternalLoadBalancerElementsCmd()
- internallbprov.nspid = pnetprovres[0].id
- internallbresponse = self.apiClient.\
- listInternalLoadBalancerElements(internallbprov)
- internallbid = internallbresponse[0].id
-
- internallbconfig = \
- configureInternalLoadBalancerElement.\
- configureInternalLoadBalancerElementCmd()
- internallbconfig.enabled = "true"
- internallbconfig.id = internallbid
- self.apiClient.\
- configureInternalLoadBalancerElement(internallbconfig)
- self.enableProvider(pnetprovres[0].id)
- elif provider.name == 'SecurityGroupProvider':
- self.enableProvider(pnetprovres[0].id)
- elif provider.name in ['JuniperContrailRouter', 'JuniperContrailVpcRouter']:
- netprov = addNetworkServiceProvider.\
- addNetworkServiceProviderCmd()
- netprov.name = provider.name
- netprov.physicalnetworkid = phynetwrk.id
- result = self.apiClient.addNetworkServiceProvider(netprov)
- self.enableProvider(result.id)
- elif provider.name in ['Netscaler', 'JuniperSRX', 'F5BigIp']:
- netprov = addNetworkServiceProvider.\
- addNetworkServiceProviderCmd()
- netprov.name = provider.name
- netprov.physicalnetworkid = phynetwrk.id
- result = self.apiClient.addNetworkServiceProvider(netprov)
- for device in provider.devices:
- if provider.name == 'Netscaler':
- dev = addNetscalerLoadBalancer.\
- addNetscalerLoadBalancerCmd()
- dev.username = device.username
- dev.password = device.password
- dev.networkdevicetype = device.networkdevicetype
- dev.url = configGenerator.getDeviceUrl(device)
- dev.physicalnetworkid = phynetwrk.id
- self.apiClient.addNetscalerLoadBalancer(dev)
- elif provider.name == 'JuniperSRX':
- dev = addSrxFirewall.addSrxFirewallCmd()
- dev.username = device.username
- dev.password = device.password
- dev.networkdevicetype = device.networkdevicetype
- dev.url = configGenerator.getDeviceUrl(device)
- dev.physicalnetworkid = phynetwrk.id
- self.apiClient.addSrxFirewall(dev)
- elif provider.name == 'F5BigIp':
- dev = addF5LoadBalancer.addF5LoadBalancerCmd()
- dev.username = device.username
- dev.password = device.password
- dev.networkdevicetype = device.networkdevicetype
- dev.url = configGenerator.getDeviceUrl(device)
- dev.physicalnetworkid = phynetwrk.id
- self.apiClient.addF5LoadBalancer(dev)
- else:
- raise cloudstackException.\
- InvalidParameterException("Device %s doesn't match\
- any know provider type" % device)
- self.enableProvider(result.id)
+ try:
+ for provider in providers:
+ pnetprov = listNetworkServiceProviders.\
+ listNetworkServiceProvidersCmd()
+ pnetprov.physicalnetworkid = phynetwrk.id
+ pnetprov.state = "Disabled"
+ pnetprov.name = provider.name
+ pnetprovres = self.__apiClient.listNetworkServiceProviders(
+ pnetprov)
+ if pnetprovres and len(pnetprovres) > 0:
+ if provider.name == 'VirtualRouter'\
+ or provider.name == 'VpcVirtualRouter':
+ vrprov = listVirtualRouterElements.\
+ listVirtualRouterElementsCmd()
+ vrprov.nspid = pnetprovres[0].id
+ vrprovresponse = self.__apiClient.\
+ listVirtualRouterElements(vrprov)
+ vrprovid = vrprovresponse[0].id
+ vrconfig = \
+ configureVirtualRouterElement.\
+ configureVirtualRouterElementCmd()
+ vrconfig.enabled = "true"
+ vrconfig.id = vrprovid
+ self.__apiClient.\
+ configureVirtualRouterElement(vrconfig)
+ self.enableProvider(pnetprovres[0].id)
+ elif provider.name == 'InternalLbVm':
+ internallbprov = listInternalLoadBalancerElements.\
+ listInternalLoadBalancerElementsCmd()
+ internallbprov.nspid = pnetprovres[0].id
+ internallbresponse = self.__apiClient.\
+ listInternalLoadBalancerElements(internallbprov)
+ internallbid = internallbresponse[0].id
+ internallbconfig = \
+ configureInternalLoadBalancerElement.\
+ configureInternalLoadBalancerElementCmd()
+ internallbconfig.enabled = "true"
+ internallbconfig.id = internallbid
+ self.__apiClient.\
+ configureInternalLoadBalancerElement(
+ internallbconfig)
+ self.enableProvider(pnetprovres[0].id)
+ elif provider.name == 'SecurityGroupProvider':
+ self.enableProvider(pnetprovres[0].id)
+ elif provider.name in ['Netscaler', 'JuniperSRX', 'F5BigIp']:
+ netprov = addNetworkServiceProvider.\
+ addNetworkServiceProviderCmd()
+ netprov.name = provider.name
+ netprov.physicalnetworkid = phynetwrk.id
+ result = self.__apiClient.addNetworkServiceProvider(
+ netprov)
+ if result.id:
+ self.__tcRunLogger.\
+ debug("==== AddNetworkServiceProvider "
+ "Successful=====")
+ self.__addToCleanUp(
+ "NetworkServiceProvider",
+ result.id)
+ for device in provider.devices:
+ if provider.name == 'Netscaler':
+ dev = addNetscalerLoadBalancer.\
+ addNetscalerLoadBalancerCmd()
+ dev.username = device.username
+ dev.password = device.password
+ dev.networkdevicetype = device.networkdevicetype
+ dev.url = configGenerator.getDeviceUrl(device)
+ dev.physicalnetworkid = phynetwrk.id
+ ret = self.__apiClient.addNetscalerLoadBalancer(
+ dev)
+ if ret.id:
+ self.__tcRunLogger.\
+ debug("==== AddNetScalerLB "
+ "Successful=====")
+ self.__addToCleanUp(
+ "NetscalerLoadBalancer",
+ ret.id)
+ elif provider.name == 'JuniperSRX':
+ dev = addSrxFirewall.addSrxFirewallCmd()
+ dev.username = device.username
+ dev.password = device.password
+ dev.networkdevicetype = device.networkdevicetype
+ dev.url = configGenerator.getDeviceUrl(device)
+ dev.physicalnetworkid = phynetwrk.id
+ ret = self.__apiClient.addSrxFirewall(dev)
+ if ret.id:
+ self.__tcRunLogger.\
+ debug("==== AddSrx "
+ "Successful=====")
+ self.__addToCleanUp("SrxFirewall", ret.id)
+ elif provider.name == 'F5BigIp':
+ dev = addF5LoadBalancer.addF5LoadBalancerCmd()
+ dev.username = device.username
+ dev.password = device.password
+ dev.networkdevicetype = device.networkdevicetype
+ dev.url = configGenerator.getDeviceUrl(device)
+ dev.physicalnetworkid = phynetwrk.id
+ ret = self.__apiClient.addF5LoadBalancer(dev)
+ if ret.id:
+ self.__tcRunLogger.\
+ debug("==== AddF5 "
+ "Successful=====")
+ self.__addToCleanUp("F5LoadBalancer", ret.id)
+ else:
+ raise InvalidParameterException(
+ "Device %s doesn't match "
+ "any know provider "
+ "type" % device)
+ self.enableProvider(result.id)
+ except Exception as e:
+ print "Exception Occurred: %s" % GetDetailExceptionInfo(e)
+ self.__tcRunLogger.\
+ exception("====List Network "
+ "Service Providers Failed=====")
+ self.__cleanAndExit()
def addTrafficTypes(self, physical_network_id, traffictypes):
[self.addTrafficType(physical_network_id, traffic_type)
for traffic_type in traffictypes]
def addTrafficType(self, physical_network_id, traffictype):
- traffic_type = addTrafficType.addTrafficTypeCmd()
- traffic_type.physicalnetworkid = physical_network_id
- traffic_type.traffictype = traffictype.typ
- traffic_type.kvmnetworklabel = traffictype.kvm\
- if traffictype.kvm is not None else None
- traffic_type.xennetworklabel = traffictype.xen\
- if traffictype.xen is not None else None
- traffic_type.vmwarenetworklabel = traffictype.vmware\
- if traffictype.vmware is not None else None
- traffic_type.simulatorlabel = traffictype.simulator\
- if traffictype.simulator is not None else None
- return self.apiClient.addTrafficType(traffic_type)
+ try:
+ traffic_type = addTrafficType.addTrafficTypeCmd()
+ traffic_type.physicalnetworkid = physical_network_id
+ traffic_type.traffictype = traffictype.typ
+ traffic_type.kvmnetworklabel = traffictype.kvm\
+ if traffictype.kvm is not None else None
+ traffic_type.xennetworklabel = traffictype.xen\
+ if traffictype.xen is not None else None
+ traffic_type.vmwarenetworklabel = traffictype.vmware\
+ if traffictype.vmware is not None else None
+ traffic_type.simulatorlabel = traffictype.simulator\
+ if traffictype.simulator is not None else None
+ ret = self.__apiClient.addTrafficType(traffic_type)
+ if ret.id:
+ self.__tcRunLogger.debug("===Add TrafficType Successful====")
+ self.__addToCleanUp("TrafficType", ret.id)
+ return ret
+ except Exception as e:
+ print "Exception Occurred: %s" % GetDetailExceptionInfo(e)
+ self.__tcRunLogger.\
+ exception("==== Add TrafficType Failed=====")
+ self.__cleanAndExit()
def enableZone(self, zoneid, allocation_state="Enabled"):
- zoneCmd = updateZone.updateZoneCmd()
- zoneCmd.id = zoneid
- zoneCmd.allocationstate = allocation_state
- return self.apiClient.updateZone(zoneCmd)
+ try:
+ zoneCmd = updateZone.updateZoneCmd()
+ zoneCmd.id = zoneid
+ zoneCmd.allocationstate = allocation_state
+ ret = self.__apiClient.updateZone(zoneCmd)
+ if ret.id:
+ self.__tcRunLogger.debug("==== Enable Zone SuccessFul=====")
+ return ret
+ except Exception as e:
+ print "Exception Occurred: %s" % GetDetailExceptionInfo(e)
+ self.__tcRunLogger.exception("==== Enable Zone Failed=====")
+ self.__cleanAndExit()
def updateZoneDetails(self, zoneid, details):
- zoneCmd = updateZone.updateZoneCmd()
- zoneCmd.id = zoneid
- zoneCmd.details = details
- return self.apiClient.updateZone(zoneCmd)
+ try:
+ zoneCmd = updateZone.updateZoneCmd()
+ zoneCmd.id = zoneid
+ zoneCmd.details = details
+ ret = self.__apiClient.updateZone(zoneCmd)
+ if ret.id:
+ self.__tcRunLogger.debug("=== Update Zone SuccessFul===")
+ return ret
+ except Exception as e:
+ print "Exception Occurred: %s" % GetDetailExceptionInfo(e)
+ self.__tcRunLogger.exception("==== Update Zone Failed=====")
+ self.__cleanAndExit()
+
+ def createZone(self, zone, rec=0):
+ try:
+ zoneresponse = self.__apiClient.createZone(zone)
+ if zoneresponse.id:
+ self.__addToCleanUp("Zone", zoneresponse.id)
+ self.__tcRunLogger.\
+ debug("Zone Name : %s Id : %s Created Successfully" %
+ (str(zone.name), str(zoneresponse.id)))
+ return zoneresponse.id
+ else:
+ self.__tcRunLogger.\
+ exception("====Zone : %s Creation Failed=====" %
+ str(zone.name))
+ print "\n====Zone : %s Creation Failed=====" % str(zone.name)
+ if not rec:
+ zone.name = zone.name + "_" + random_gen()
+ self.__tcRunLogger.\
+ debug("====Recreating Zone With New Name : "
+ "%s" % zone.name)
+ print "\n====Recreating Zone With New Name ====", \
+ str(zone.name)
+ return self.createZone(zone, 1)
+ except Exception as e:
+ print "\nException Occurred under createZone : %s" % \
+ GetDetailExceptionInfo(e)
+ self.__tcRunLogger.exception("====Create Zone Failed ===")
+ return FAILED
def createZones(self, zones):
- for zone in zones:
- createzone = createZone.createZoneCmd()
- createzone.dns1 = zone.dns1
- createzone.dns2 = zone.dns2
- createzone.internaldns1 = zone.internaldns1
- createzone.internaldns2 = zone.internaldns2
- createzone.name = zone.name
- createzone.securitygroupenabled = zone.securitygroupenabled
- createzone.localstorageenabled = zone.localstorageenabled
- createzone.networktype = zone.networktype
- if zone.securitygroupenabled != "true":
- createzone.guestcidraddress = zone.guestcidraddress
-
- zoneresponse = self.apiClient.createZone(createzone)
- zoneId = zoneresponse.id
-
- for pnet in zone.physical_networks:
- phynetwrk = self.createPhysicalNetwork(pnet, zoneId)
- self.configureProviders(phynetwrk, pnet.providers)
- self.updatePhysicalNetwork(phynetwrk.id, "Enabled",
- vlan=pnet.vlan)
-
- if zone.networktype == "Basic":
- listnetworkoffering =\
- listNetworkOfferings.listNetworkOfferingsCmd()
- listnetworkoffering.name =\
- "DefaultSharedNetscalerEIPandELBNetworkOffering" \
- if len(filter(lambda x:
- x.typ == 'Public',
- zone.physical_networks[0].
- traffictypes)) > 0 \
- else "DefaultSharedNetworkOfferingWithSGService"
- if zone.networkofferingname is not None:
- listnetworkoffering.name = zone.networkofferingname
-
- listnetworkofferingresponse = \
- self.apiClient.listNetworkOfferings(listnetworkoffering)
-
- guestntwrk = configGenerator.network()
- guestntwrk.displaytext = "guestNetworkForBasicZone"
- guestntwrk.name = "guestNetworkForBasicZone"
- guestntwrk.zoneid = zoneId
- guestntwrk.networkofferingid = \
- listnetworkofferingresponse[0].id
-
- networkid = self.createNetworks([guestntwrk], zoneId)
- self.createPods(zone.pods, zoneId, networkid)
- if self.isEipElbZone(zone):
+ try:
+ for zone in zones:
+ zonecmd = createZone.createZoneCmd()
+ zonecmd.dns1 = zone.dns1
+ zonecmd.dns2 = zone.dns2
+ zonecmd.internaldns1 = zone.internaldns1
+ zonecmd.internaldns2 = zone.internaldns2
+ zonecmd.name = zone.name
+ zonecmd.securitygroupenabled = zone.securitygroupenabled
+ zonecmd.localstorageenabled = zone.localstorageenabled
+ zonecmd.networktype = zone.networktype
+ if zone.securitygroupenabled != "true":
+ zonecmd.guestcidraddress = zone.guestcidraddress
+ zoneId = self.createZone(zonecmd)
+ if zoneId == FAILED:
+ self.__tcRunLogger.\
+ exception(
+ "====Zone: %s Creation Failed. So Exiting=====" %
+ str(zone.name))
+ self.__cleanAndExit()
+ for pnet in zone.physical_networks:
+ phynetwrk = self.createPhysicalNetwork(pnet, zoneId)
+ self.configureProviders(phynetwrk, pnet.providers)
+ self.updatePhysicalNetwork(phynetwrk.id, "Enabled",
+ vlan=pnet.vlan)
+ if zone.networktype == "Basic":
+ listnetworkoffering =\
+ listNetworkOfferings.listNetworkOfferingsCmd()
+ listnetworkoffering.name =\
+ "DefaultSharedNetscalerEIPandELBNetworkOffering" \
+ if len(filter(lambda x:
+ x.typ == 'Public',
+ zone.physical_networks[0].
+ traffictypes)) > 0 \
+ else "DefaultSharedNetworkOfferingWithSGService"
+ if zone.networkofferingname is not None:
+ listnetworkoffering.name = zone.networkofferingname
+ listnetworkofferingresponse = \
+ self.__apiClient.listNetworkOfferings(
+ listnetworkoffering)
+ guestntwrk = configGenerator.network()
+ guestntwrk.displaytext = "guestNetworkForBasicZone"
+ guestntwrk.name = "guestNetworkForBasicZone"
+ guestntwrk.zoneid = zoneId
+ guestntwrk.networkofferingid = \
+ listnetworkofferingresponse[0].id
+ networkid = self.createNetworks([guestntwrk], zoneId)
+ self.createPods(zone.pods, zoneId, networkid)
+ if self.isEipElbZone(zone):
+ self.createVlanIpRanges(
+ zone.networktype, zone.ipranges,
+ zoneId, forvirtualnetwork=True)
+ isPureAdvancedZone = (zone.networktype == "Advanced"
+ and zone.securitygroupenabled != "true")
+ if isPureAdvancedZone:
+ self.createPods(zone.pods, zoneId)
self.createVlanIpRanges(zone.networktype, zone.ipranges,
- zoneId, forvirtualnetwork=True)
-
- isPureAdvancedZone = (zone.networktype == "Advanced"
- and zone.securitygroupenabled != "true")
- if isPureAdvancedZone:
- self.createPods(zone.pods, zoneId)
- self.createVlanIpRanges(zone.networktype, zone.ipranges,
- zoneId)
- elif (zone.networktype == "Advanced"
- and zone.securitygroupenabled == "true"):
- listnetworkoffering =\
- listNetworkOfferings.listNetworkOfferingsCmd()
- listnetworkoffering.name =\
- "DefaultSharedNetworkOfferingWithSGService"
- if zone.networkofferingname is not None:
- listnetworkoffering.name = zone.networkofferingname
-
- listnetworkofferingresponse = \
- self.apiClient.listNetworkOfferings(listnetworkoffering)
-
- networkcmd = createNetwork.createNetworkCmd()
- networkcmd.displaytext = "Shared SG enabled network"
- networkcmd.name = "Shared SG enabled network"
- networkcmd.networkofferingid =\
- listnetworkofferingresponse[0].id
- networkcmd.zoneid = zoneId
-
- ipranges = zone.ipranges
- if ipranges:
- iprange = ipranges.pop()
- networkcmd.startip = iprange.startip
- networkcmd.endip = iprange.endip
- networkcmd.gateway = iprange.gateway
- networkcmd.netmask = iprange.netmask
- networkcmd.vlan = iprange.vlan
-
- networkcmdresponse = self.apiClient.createNetwork(networkcmd)
- networkId = networkcmdresponse.id
- self.createPods(zone.pods, zoneId, networkId)
-
- '''Note: Swift needs cache storage first'''
- self.createCacheStorages(zone.cacheStorages, zoneId)
- self.createSecondaryStorages(zone.secondaryStorages, zoneId)
-
- enabled = getattr(zone, 'enabled', 'True')
- if enabled == 'True' or enabled is None:
- self.enableZone(zoneId, "Enabled")
- details = getattr(zone, 'details')
- if details is not None:
- det = [d.__dict__ for d in details]
- self.updateZoneDetails(zoneId, det)
-
- return
+ zoneId)
+ elif (zone.networktype == "Advanced"
+ and zone.securitygroupenabled == "true"):
+ listnetworkoffering =\
+ listNetworkOfferings.listNetworkOfferingsCmd()
+ listnetworkoffering.name =\
+ "DefaultSharedNetworkOfferingWithSGService"
+ if zone.networkofferingname is not None:
+ listnetworkoffering.name = zone.networkofferingname
+ listnetworkofferingresponse = \
+ self.__apiClient.listNetworkOfferings(
+ listnetworkoffering)
+ networkcmd = createNetwork.createNetworkCmd()
+ networkcmd.displaytext = "Shared SG enabled network"
+ networkcmd.name = "Shared SG enabled network"
+ networkcmd.networkofferingid =\
+ listnetworkofferingresponse[0].id
+ networkcmd.zoneid = zoneId
+ ipranges = zone.ipranges
+ if ipranges:
+ iprange = ipranges.pop()
+ networkcmd.startip = iprange.startip
+ networkcmd.endip = iprange.endip
+ networkcmd.gateway = iprange.gateway
+ networkcmd.netmask = iprange.netmask
+ networkcmd.vlan = iprange.vlan
+ networkcmdresponse = self.__apiClient.createNetwork(
+ networkcmd)
+ if networkcmdresponse.id:
+ self.__addToCleanUp("Network", networkcmdresponse.id)
+ self.__tcRunLogger.\
+ debug("create Network Successful. NetworkId : %s "
+ % str(networkcmdresponse.id))
+ self.createPods(zone.pods, zoneId, networkcmdresponse.id)
+ '''Note: Swift needs cache storage first'''
+ self.createCacheStorages(zone.cacheStorages, zoneId)
+ self.createSecondaryStorages(zone.secondaryStorages, zoneId)
+ enabled = getattr(zone, 'enabled', 'True')
+ if enabled == 'True' or enabled is None:
+ self.enableZone(zoneId, "Enabled")
+ details = getattr(zone, 'details')
+ if details is not None:
+ det = [d.__dict__ for d in details]
+ self.updateZoneDetails(zoneId, det)
+ return
+ except Exception as e:
+ print "\nException Occurred %s" % GetDetailExceptionInfo(e)
+ self.__tcRunLogger.exception("==== Create Zones Failed ===")
def isEipElbZone(self, zone):
if (zone.networktype == "Basic"
@@ -486,64 +785,30 @@ class deployDataCenters(object):
return True
return False
- def registerApiKey(self):
- listuser = listUsers.listUsersCmd()
- listuser.account = "admin"
- listuserRes = self.testClient.getApiClient().listUsers(listuser)
- userId = listuserRes[0].id
- apiKey = listuserRes[0].apikey
- securityKey = listuserRes[0].secretkey
- if apiKey is None:
- registerUser = registerUserKeys.registerUserKeysCmd()
- registerUser.id = userId
- registerUserRes = \
- self.testClient.getApiClient().registerUserKeys(registerUser)
-
- apiKey = registerUserRes.apikey
- securityKey = registerUserRes.secretkey
-
- self.config.mgtSvr[0].port = 8080
- self.config.mgtSvr[0].apiKey = apiKey
- self.config.mgtSvr[0].securityKey = securityKey
- return apiKey, securityKey
-
- def loadCfg(self):
- ''' Retrieving Management Server Connection Details '''
- mgtDetails = self.config.mgtSvr[0]
- ''' Retrieving Database Connection Details'''
- dbSvrDetails = self.config.dbSvr
-
- self.testClient = \
- cloudstackTestClient.\
- cloudstackTestClient(mgtDetails,
- dbSvrDetails,
- logger=self.tcRunLogger)
-
- if mgtDetails.apiKey is None:
- mgtDetails.apiKey, mgtDetails.securityKey = self.registerApiKey()
- mgtDetails.port = 8080
- self.testClient = \
- cloudstackTestClient.cloudstackTestClient(
- mgtDetails,
- dbSvrDetails,
- logger=self.tcRunLogger)
-
- self.apiClient = self.testClient.getApiClient()
- """set hypervisor"""
- if mgtDetails.hypervisor:
- self.apiClient.hypervisor = mgtDetails.hypervisor
- else:
- self.apiClient.hypervisor = "XenServer" # Defaults to Xenserver
+ def setClient(self):
+ '''
+ @Name : setClient
+ @Desc : Sets the API Client retrieved from test client
+ '''
+ self.__apiClient = self.__testClient.getApiClient()
def updateConfiguration(self, globalCfg):
- if globalCfg is None:
- return None
-
- for config in globalCfg:
- updateCfg = updateConfiguration.updateConfigurationCmd()
- updateCfg.name = config.name
- updateCfg.value = config.value
- self.apiClient.updateConfiguration(updateCfg)
+ try:
+ if globalCfg is None or self.__apiClient is None:
+ return None
+ for config in globalCfg:
+ updateCfg = updateConfiguration.updateConfigurationCmd()
+ updateCfg.name = config.name
+ updateCfg.value = config.value
+ ret = self.__apiClient.updateConfiguration(updateCfg)
+ if ret.id:
+ self.__tcRunLogger.debug(
+ "==UpdateConfiguration Successfull===")
+ except Exception as e:
+ print "Exception Occurred %s" % GetDetailExceptionInfo(e)
+ self.__tcRunLogger.\
+ exception("===UpdateConfiguration Failed===")
+ self.__cleanAndExit()
def copyAttributesToCommand(self, source, command):
map(lambda attr: setattr(command, attr, getattr(source, attr, None)),
@@ -551,42 +816,307 @@ class deployDataCenters(object):
["required", "isAsync"], dir(command)))
def configureS3(self, s3):
- if s3 is None:
- return
- command = addS3.addS3Cmd()
- self.copyAttributesToCommand(s3, command)
- self.apiClient.addS3(command)
+ try:
+ if s3 is None:
+ return
+ command = addS3.addS3Cmd()
+ self.copyAttributesToCommand(s3, command)
+ ret = self.__apiClient.addS3(command)
+ if ret.id:
+ self.__tcRunLogger.debug("===AddS3 Successfull===")
+ self.__addToCleanUp("s3", ret.id)
+ except Exception as e:
+ self.__tcRunLogger.exception("====AddS3 Failed===")
+ self.__cleanAndExit()
def deploy(self):
- self.loadCfg()
- self.updateConfiguration(self.config.globalConfig)
- self.createZones(self.config.zones)
- self.configureS3(self.config.s3)
+ try:
+ print "\n==== Deploy DC Started ===="
+ self.__tcRunLogger.debug("\n==== Deploy DC Started ====")
+ '''
+ Step1 : Set the Client
+ '''
+ self.setClient()
+ '''
+ Step2: Update the Configuration
+ '''
+ self.updateConfiguration(self.__config.globalConfig)
+ '''
+ Step3 :Deploy the Zone
+ '''
+ self.createZones(self.__config.zones)
+ self.configureS3(self.__config.s3)
+ '''
+ Persist the Configuration to an external file post DC creation
+ '''
+ self.__persistDcConfig()
+ print "\n====Deploy DC Successful====="
+ self.__tcRunLogger.debug("\n====Deploy DC Successful====")
+ return SUCCESS
+ except Exception as e:
+ print "\nException Occurred Under deploy :%s" % \
+ GetDetailExceptionInfo(e)
+ self.__tcRunLogger.debug("\n====Deploy DC Failed====")
+ print "\n====Deploy DC Failed===="
+ self.__cleanAndExit()
+ return FAILED
+
+
+class DeleteDataCenters:
+
+ '''
+ @Desc : Deletes the Data Center using the settings provided.
+ tc_client :Client for deleting the DC.
+ dc_cfg_file : obj file exported by DeployDataCenter
+ when successfully created DC.
+ This file is serialized one containing
+ entries with successful DC.
+ dc_cfg: If dc_cfg_file, is not available, we can use
+ the dictionary of elements to delete.
+ tc_run_logger: Logger to dump log messages.
+ '''
+
+ def __init__(self,
+ tc_client,
+ dc_cfg_file=None,
+ dc_cfg=None,
+ tc_run_logger=None
+ ):
+ self.__dcCfgFile = dc_cfg_file
+ self.__dcCfg = dc_cfg
+ self.__tcRunLogger = tc_run_logger
+ self.__apiClient = None
+ self.__testClient = tc_client
+
+ def __deleteCmds(self, cmd_name, cmd_obj):
+ '''
+ @Name : __deleteCmds
+ @Desc : Deletes the entities provided by cmd
+ '''
+ if cmd_name.lower() == "deletehostcmd":
+ cmd_obj.forcedestroylocalstorage = "true"
+ cmd_obj.force = "true"
+ '''
+ Step1 : Prepare Host For Maintenance
+ '''
+ host_maint_cmd = prepareHostForMaintenance.\
+ prepareHostForMaintenanceCmd()
+ host_maint_cmd.id = cmd_obj.id
+ host_maint_resp = self.__apiClient.prepareHostForMaintenance(
+ host_maint_cmd)
+ if host_maint_resp:
+ '''
+ Step2 : List Hosts for Resource State
+ '''
+ list_host_cmd = listHosts.listHostsCmd()
+ list_host_cmd.id = cmd_obj.id
+ retries = 3
+ for i in xrange(retries):
+ list_host_resp = self.__apiClient.\
+ listHosts(list_host_cmd)
+ if (list_host_resp) and\
+ (list_host_resp[0].resourcestate == 'Maintenance'):
+ break
+ sleep(30)
+ if cmd_name.lower() == "deletestoragepoolcmd":
+ cmd_obj.forced = "true"
+ store_maint_cmd = enableStorageMaintenance.\
+ enableStorageMaintenanceCmd()
+ store_maint_cmd.id = cmd_obj.id
+ store_maint_resp = self.__apiClient.\
+ enableStorageMaintenance(store_maint_cmd)
+ if store_maint_resp:
+ list_store_cmd = listStoragePools.listStoragePoolsCmd()
+ list_store_cmd.id = cmd_obj.id
+ retries = 3
+ for i in xrange(retries):
+ store_maint_resp = self.__apiClient.\
+ listStoragePools(list_store_cmd)
+ if (store_maint_resp) and \
+ (store_maint_resp[0].state == 'Maintenance'):
+ break
+ sleep(30)
+ return cmd_obj
+
+ def __setClient(self):
+ '''
+ @Name : setClient
+ @Desc : Sets the API Client retrieved from test client
+ '''
+ self.__apiClient = self.__testClient.getApiClient()
+
+ def __cleanEntries(self):
+ '''
+ @Name : __cleanAndEntries
+ @Description: Cleans up the created DC in order of creation
+ '''
+ try:
+ ret = FAILED
+ if "order" in self.__dcCfg.keys() and len(self.__dcCfg["order"]):
+ self.__dcCfg["order"].reverse()
+ print "\n====Clean Up Entries===", self.__dcCfg
+ for type in self.__dcCfg["order"]:
+ self.__tcRunLogger.debug(
+ "====CleanUp Started For Type: %s====" %
+ type)
+ if type:
+ temp_ids = self.__dcCfg[type]
+ ids = [items for items in temp_ids if items]
+ for id in ids:
+ del_mod = "delete" + type
+ del_cmd = getattr(
+ globals()[del_mod],
+ del_mod + "Cmd")
+ del_cmd_obj = del_cmd()
+ del_cmd_resp = getattr(
+ globals()[del_mod],
+ del_mod + "Response")
+ del_cmd_obj.id = id
+ del_cmd_obj = self.__deleteCmds(
+ del_mod +
+ "Cmd",
+ del_cmd_obj)
+ del_func = getattr(self.__apiClient, del_mod)
+ del_cmd_resp = del_func(del_cmd_obj)
+ if del_cmd_resp:
+ self.__tcRunLogger.debug(
+ "====%s CleanUp Failed. ID: %s ===" %
+ (type, id))
+ else:
+ self.__tcRunLogger.debug(
+ "====%s CleanUp Successful. ID : %s===" %
+ (type, id))
+ ret = SUCCESS
+ except Exception as e:
+ print "\n==== Exception Under __cleanEntries: %s ==== % " \
+ % GetDetailExceptionInfo(e)
+ self.__tcRunLogger.exception(
+ "\n==== Exception Under __cleanEntries: %s ==== % " %
+ GetDetailExceptionInfo(e))
+ finally:
+ return ret
+
+ def removeDataCenter(self):
+ '''
+ @Name : removeDataCenter
+ @Desc : Removes the Data Center provided by Configuration
+ If Input dc file configuration is None, uses the cfg provided
+ else uses the dc file to get the configuration
+ '''
+ try:
+ self.__setClient()
+ self.__tcRunLogger.debug("====DeployDC: CleanUp Started====")
+ print "\n====DeployDC: CleanUp Started===="
+ ret = FAILED
+ if self.__dcCfgFile:
+ file_to_read = open(self.__dcCfgFile, 'r')
+ if file_to_read:
+ self.__dcCfg = pickle.load(file_to_read)
+ if self.__dcCfg:
+ ret = self.__cleanEntries()
+ except Exception as e:
+ print "\n==== Exception Under removeDataCenter: %s ====" % \
+ GetDetailExceptionInfo(e)
+ self.__tcRunLogger.exception(
+ "===DeployDC CleanUp FAILED: %s ====" %
+ GetDetailExceptionInfo(e))
+ finally:
+ return ret
+
if __name__ == "__main__":
+ '''
+ @Desc : This module facilitates the following:
+ 1. Deploying DataCenter by using the input provided
+ configuration.
+ EX: python deployDataCenter.py -i <inp-cfg-file>
+ 2. Removes a created DataCenter by providing
+ the input configuration file and data center settings file
+ EX: python deployDataCenter.py -i <inp-cfg-file>
+ -r <dc_exported_entries>
+ '''
parser = OptionParser()
parser.add_option("-i", "--input", action="store",
- default="./datacenterCfg", dest="input", help="the path \
- where the json config file generated, by default is \
- ./datacenterCfg")
-
+ default=None, dest="input",
+ help="the path \
+ where the json config file generated")
+
+ parser.add_option("-r", "--remove", action="store",
+ default=None, dest="remove",
+ help="path to file\
+ where the created dc entries are kept")
(options, args) = parser.parse_args()
+
+ '''
+ Verify the input validity
+ '''
+ if options.input is None and options.remove is None:
+ print "\n==== For DeployDataCenter: Please Specify a " \
+ "Valid Input Configuration File===="
+ print "\n==== For DeleteDataCenters: Please Specify a " \
+ "Valid Input Configuration File and DC Settings===="
+ exit(1)
+
+ '''
+ Imports the Modules Required
+ '''
from marvin.marvinLog import MarvinLog
- cfg = configGenerator.getSetupConfig(options.input)
+ from marvin.cloudstackTestClient import CSTestClient
+
+ '''
+ Step1: Create the Logger
+ '''
log_obj = MarvinLog("CSLog")
- tcRunLogger = log_obj.setLogHandler("/tmp/debug.log")
- deploy = deployDataCenters(cfg, tcRunLogger)
- deploy.deploy()
-
- """
- create = createStoragePool.createStoragePoolCmd()
- create.clusterid = 1
- create.podid = 2
- create.name = "fdffdf"
- create.url = "nfs://jfkdjf/fdkjfkd"
- create.zoneid = 2
-
- deploy = deployDataCenters("./datacenterCfg")
- deploy.loadCfg()
- deploy.apiClient.createStoragePool(create)
- """
+ cfg = configGenerator.getSetupConfig(options.input)
+ log = cfg.logger
+
+ ret = log_obj.createLogs("DeployDataCenter",
+ log)
+ if ret != FAILED:
+ log_folder_path = log_obj.getLogFolderPath()
+ tc_run_logger = log_obj.getLogger()
+ else:
+ print "\n===Log Creation Failed. Please Check==="
+ exit(1)
+
+ '''
+ Step2 : Create Test Client
+ '''
+ obj_tc_client = CSTestClient(cfg.mgtSvr[0], cfg.dbSvr,
+ logger=tc_run_logger)
+ if obj_tc_client and obj_tc_client.createTestClient() == FAILED:
+ print "\n=== TestClient Creation Failed==="
+ exit(1)
+
+ '''
+ Step3: Verify and continue whether to deploy a DC or remove a DC
+ '''
+
+ if (options.input) and (os.path.isfile(options.input)) and \
+ (options.remove is None):
+ '''
+ @Desc : Deploys a Data Center with provided Config
+ '''
+ deploy = DeployDataCenters(obj_tc_client,
+ cfg,
+ tc_run_logger,
+ log_folder_path=log_folder_path)
+ deploy.deploy()
+ exit(1)
+
+ if options.remove and os.path.isfile(options.remove) and options.input:
+ '''
+ @Desc : Removes a Data Center with provided Config
+ '''
+ remove_dc_obj = DeleteDataCenters(obj_tc_client,
+ dc_cfg_file=options.remove,
+ tc_run_logger=tc_run_logger
+ )
+ if remove_dc_obj:
+ if remove_dc_obj.removeDataCenter() == FAILED:
+ print "\n===Removing DataCenter Failed==="
+ tc_run_logger.debug("\n===Removing DataCenter Failed===")
+ else:
+ print "\n===Removing DataCenter Successful==="
+ tc_run_logger.debug("\n===Removing DataCenter Successful===")
+ exit(1)
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/tools/marvin/marvin/integration/__init__.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/integration/__init__.py b/tools/marvin/marvin/integration/__init__.py
deleted file mode 100644
index 57823fc..0000000
--- a/tools/marvin/marvin/integration/__init__.py
+++ /dev/null
@@ -1,18 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/tools/marvin/marvin/integration/lib/__init__.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/integration/lib/__init__.py b/tools/marvin/marvin/integration/lib/__init__.py
deleted file mode 100644
index 978b68a..0000000
--- a/tools/marvin/marvin/integration/lib/__init__.py
+++ /dev/null
@@ -1,16 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
[14/18] Marvin + test changes from master Signed-off-by:
SrikanteswaraRao Talluri
Posted by da...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/component/test_netscaler_lb_algo.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_netscaler_lb_algo.py b/test/integration/component/test_netscaler_lb_algo.py
index 3c18fcd..6eda9a3 100644
--- a/test/integration/component/test_netscaler_lb_algo.py
+++ b/test/integration/component/test_netscaler_lb_algo.py
@@ -22,11 +22,10 @@ import marvin
from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
from marvin.sshClient import SshClient
-import datetime
class Services:
@@ -117,14 +116,13 @@ class TestLbWithRoundRobin(cloudstackTestCase):
@classmethod
def setUpClass(cls):
cls._cleanup = []
- cls.api_client = super(
- TestLbWithRoundRobin,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestLbWithRoundRobin, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.template = get_template(
cls.api_client,
cls.zone.id,
@@ -330,14 +328,13 @@ class TestLbWithLeastConn(cloudstackTestCase):
@classmethod
def setUpClass(cls):
cls._cleanup = []
- cls.api_client = super(
- TestLbWithLeastConn,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestLbWithLeastConn, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.template = get_template(
cls.api_client,
cls.zone.id,
@@ -552,14 +549,13 @@ class TestLbWithSourceIp(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(
- TestLbWithSourceIp,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestLbWithSourceIp, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.template = get_template(
cls.api_client,
cls.zone.id,
@@ -768,14 +764,13 @@ class TestLbAlgoRrLc(cloudstackTestCase):
@classmethod
def setUpClass(cls):
cls._cleanup = []
- cls.api_client = super(
- TestLbAlgoRrLc,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestLbAlgoRrLc, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.template = get_template(
cls.api_client,
cls.zone.id,
@@ -973,14 +968,13 @@ class TestLbAlgoLcRr(cloudstackTestCase):
@classmethod
def setUpClass(cls):
cls._cleanup = []
- cls.api_client = super(
- TestLbAlgoLcRr,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestLbAlgoLcRr, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.template = get_template(
cls.api_client,
cls.zone.id,
@@ -1175,14 +1169,13 @@ class TestLbAlgoRrSb(cloudstackTestCase):
@classmethod
def setUpClass(cls):
cls._cleanup = []
- cls.api_client = super(
- TestLbAlgoRrSb,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestLbAlgoRrSb, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.template = get_template(
cls.api_client,
cls.zone.id,
@@ -1380,14 +1373,13 @@ class TestLbAlgoSbRr(cloudstackTestCase):
@classmethod
def setUpClass(cls):
cls._cleanup = []
- cls.api_client = super(
- TestLbAlgoSbRr,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestLbAlgoSbRr, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.template = get_template(
cls.api_client,
cls.zone.id,
@@ -1588,14 +1580,13 @@ class TestLbAlgoSbLc(cloudstackTestCase):
@classmethod
def setUpClass(cls):
cls._cleanup = []
- cls.api_client = super(
- TestLbAlgoSbLc,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestLbAlgoSbLc, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.template = get_template(
cls.api_client,
cls.zone.id,
@@ -1795,14 +1786,13 @@ class TestLbAlgoLcSb(cloudstackTestCase):
@classmethod
def setUpClass(cls):
cls._cleanup = []
- cls.api_client = super(
- TestLbAlgoLcSb,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestLbAlgoLcSb, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.template = get_template(
cls.api_client,
cls.zone.id,
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/component/test_netscaler_lb_sticky.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_netscaler_lb_sticky.py b/test/integration/component/test_netscaler_lb_sticky.py
index 6c27a08..c333f60 100644
--- a/test/integration/component/test_netscaler_lb_sticky.py
+++ b/test/integration/component/test_netscaler_lb_sticky.py
@@ -22,9 +22,9 @@ import marvin
from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
from marvin.sshClient import SshClient
import datetime
@@ -117,14 +117,13 @@ class TestLbStickyPolicy(cloudstackTestCase):
@classmethod
def setUpClass(cls):
cls._cleanup = []
- cls.api_client = super(
- TestLbStickyPolicy,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestLbStickyPolicy, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.template = get_template(
cls.api_client,
cls.zone.id,
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/component/test_netscaler_nw_off.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_netscaler_nw_off.py b/test/integration/component/test_netscaler_nw_off.py
index a94f01d..d3f1f9e 100644
--- a/test/integration/component/test_netscaler_nw_off.py
+++ b/test/integration/component/test_netscaler_nw_off.py
@@ -22,9 +22,9 @@ import marvin
from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
from marvin.sshClient import SshClient
import datetime
@@ -191,14 +191,13 @@ class TestAddMultipleNetScaler(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(
- TestAddMultipleNetScaler,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestAddMultipleNetScaler, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls._cleanup = []
return
@@ -506,14 +505,13 @@ class TestNetScalerSharedMode(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(
- TestNetScalerSharedMode,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestNetScalerSharedMode, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.template = get_template(
cls.api_client,
cls.zone.id,
@@ -1051,14 +1049,13 @@ class TestNwOffDedicatedNetscaler(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(
- TestNwOffDedicatedNetscaler,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestNwOffDedicatedNetscaler, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.template = get_template(
cls.api_client,
cls.zone.id,
@@ -1217,14 +1214,13 @@ class TestNwOffNetscaler(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(
- TestNwOffNetscaler,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestNwOffNetscaler, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.template = get_template(
cls.api_client,
cls.zone.id,
@@ -1525,14 +1521,13 @@ class TestNwOffSToDUpgrade(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(
- TestNwOffSToDUpgrade,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestNwOffSToDUpgrade, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.template = get_template(
cls.api_client,
cls.zone.id,
@@ -1940,14 +1935,13 @@ class TestNwOffDToSUpgrade(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(
- TestNwOffDToSUpgrade,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestNwOffDToSUpgrade, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.template = get_template(
cls.api_client,
cls.zone.id,
@@ -2341,15 +2335,13 @@ class TestNOWithNetscaler(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(
- TestNOWithNetscaler,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestNOWithNetscaler, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.services['mode'] = cls.zone.networktype
cls.template = get_template(
cls.api_client,
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/component/test_network_offering.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_network_offering.py b/test/integration/component/test_network_offering.py
index 7040722..b0b6906 100644
--- a/test/integration/component/test_network_offering.py
+++ b/test/integration/component/test_network_offering.py
@@ -22,9 +22,9 @@ import marvin
from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
import datetime
@@ -160,14 +160,13 @@ class TestNOVirtualRouter(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(
- TestNOVirtualRouter,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestNOVirtualRouter, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.services['mode'] = cls.zone.networktype
cls.template = get_template(
cls.api_client,
@@ -733,14 +732,13 @@ class TestNetworkUpgrade(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(
- TestNetworkUpgrade,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestNetworkUpgrade, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.services['mode'] = cls.zone.networktype
cls.template = get_template(
cls.api_client,
@@ -1181,14 +1179,13 @@ class TestNetworkUpgrade(cloudstackTestCase):
class TestNOWithOnlySourceNAT(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.apiclient = super(
- TestNOWithOnlySourceNAT,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestNOWithOnlySourceNAT, cls).getClsTestClient()
+ cls.apiclient = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.apiclient, cls.services)
- cls.zone = get_zone(cls.apiclient, cls.services)
+ cls.domain = get_domain(cls.apiclient)
+ cls.zone = get_zone(cls.apiclient, cls.testClient.getZoneForTests())
cls.services['mode'] = cls.zone.networktype
cls.template = get_template(
cls.apiclient,
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/component/test_non_contiguous_vlan.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_non_contiguous_vlan.py b/test/integration/component/test_non_contiguous_vlan.py
index 3ebaf3a..4609af9 100644
--- a/test/integration/component/test_non_contiguous_vlan.py
+++ b/test/integration/component/test_non_contiguous_vlan.py
@@ -28,17 +28,17 @@
from marvin.cloudstackTestCase import (cloudstackTestCase,unittest)
-from marvin.integration.lib.base import (Account,
+from marvin.lib.base import (Account,
ServiceOffering,
PhysicalNetwork,
VirtualMachine,
)
-from marvin.integration.lib.common import (get_zone,
+from marvin.lib.common import (get_zone,
get_pod,
get_domain,
get_template,
setNonContiguousVlanIds)
-from marvin.integration.lib.utils import (cleanup_resources,
+from marvin.lib.utils import (cleanup_resources,
xsplit)
from nose.plugins.attrib import attr
@@ -47,7 +47,7 @@ class Services():
def __init__(self):
self.services = {
- "vlan": {
+ "vlan_nc": {
"partial_range": ["",""],
"full_range": "",
},
@@ -89,12 +89,14 @@ class TestNonContiguousVLANRanges(cloudstackTestCase):
"""
@classmethod
def setUpClass(cls):
- cls.api_client = super(TestNonContiguousVLANRanges, cls).getClsTestClient().getApiClient()
+ cls.testClient = super(TestNonContiguousVLANRanges, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
- # Get Zone, pod, domain
- cls.zone = get_zone(cls.api_client, cls.services)
- cls.pod = get_pod(cls.api_client, cls.zone.id, cls.services)
- cls.domain = get_domain(cls.api_client, cls.services)
+ # Get Zone, Domain and templates
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
+ cls.pod = get_pod(cls.api_client, cls.zone.id)
+ cls.domain = get_domain(cls.api_client)
cls.service_offering = ServiceOffering.create(
cls.api_client,
@@ -123,7 +125,7 @@ class TestNonContiguousVLANRanges(cloudstackTestCase):
def setUp(self):
self.apiclient = self.testClient.getApiClient()
- self.vlan = self.services["vlan"]
+ self.vlan = self.services["vlan_nc"]
self.apiClient = self.testClient.getApiClient()
self.physicalnetwork, self.vlan = setNonContiguousVlanIds(self.apiclient, self.zone.id)
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/component/test_persistent_networks.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_persistent_networks.py b/test/integration/component/test_persistent_networks.py
index 134b9b5..4c1798f 100644
--- a/test/integration/component/test_persistent_networks.py
+++ b/test/integration/component/test_persistent_networks.py
@@ -14,64 +14,35 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
-""" Tests for Persistent Networks without running VMs feature
-
- Test Plan: https://cwiki.apache.org/confluence/display/CLOUDSTACK/Persistent+Networks+without+a+running+VM
-
- Issue Link: https://issues.apache.org/jira/browse/CLOUDSTACK-2232
-
- Feature Specifications: https://cwiki.apache.org/confluence/display/CLOUDSTACK/FS+-+Persistent+Networks
-"""
-from marvin.cloudstackTestCase import cloudstackTestCase, unittest
-from marvin.integration.lib.utils import (cleanup_resources,
- validateList,
- get_hypervisor_type)
-from marvin.integration.lib.base import (Account,
- ServiceOffering,
- NetworkOffering,
- Network,
- VirtualMachine,
- PublicIPAddress,
- FireWallRule,
- Router,
- Host,
- NATRule,
- Project,
- LoadBalancerRule,
- VpcOffering,
- VPC,
- Domain,
- StaticNATRule,
- NetworkACL)
-from marvin.integration.lib.common import (get_domain,
- get_zone,
- get_template,
- wait_for_cleanup,
- add_netscaler,
- verifyNetworkState)
-
+""" Tests for Persistent Networks without running VMs feature"""
+from marvin.cloudstackException import CloudstackAPIException
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
+import netaddr
from nose.plugins.attrib import attr
-from marvin.codes import PASS, FAIL
+from marvin.codes import PASS, FAIL, FAILED
from marvin.sshClient import SshClient
+from marvin.cloudstackTestCase import cloudstackTestCase, unittest
from ddt import ddt, data
import time
@ddt
class TestPersistentNetworks(cloudstackTestCase):
- """Test Persistent Networks without running VMs
- """
-
+ '''
+ Test Persistent Networks without running VMs
+ '''
@classmethod
def setUpClass(cls):
- cloudstackTestClient = super(TestPersistentNetworks,cls).getClsTestClient()
- cls.api_client = cloudstackTestClient.getApiClient()
+ cls.testClient = super(TestPersistentNetworks, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
# Fill services from the external config file
- cls.services = cloudstackTestClient.getConfigParser().parsedDict
+ cls.services = cls.testClient.getParsedTestDataConfig()
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.template = get_template(
cls.api_client,
cls.zone.id,
@@ -1005,20 +976,22 @@ class TestAssignVirtualMachine(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cloudstackTestClient = super(TestAssignVirtualMachine,cls).getClsTestClient()
- cls.api_client = cloudstackTestClient.getApiClient()
+ cls.testClient = super(TestAssignVirtualMachine, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
# Fill services from the external config file
- cls.services = cloudstackTestClient.getConfigParser().parsedDict
+ cls.services = cls.testClient.getParsedTestDataConfig()
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.template = get_template(
cls.api_client,
cls.zone.id,
cls.services["ostype"]
)
+ if cls.template == FAILED:
+ assert False, "get_template() failed to return template with description %s" % cls.services["ostype"]
cls.services["virtual_machine"]["zoneid"] = cls.zone.id
cls.services["virtual_machine"]["template"] = cls.template.id
cls.service_offering = ServiceOffering.create(
@@ -1165,20 +1138,22 @@ class TestProjectAccountOperations(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cloudstackTestClient = super(TestProjectAccountOperations,cls).getClsTestClient()
- cls.api_client = cloudstackTestClient.getApiClient()
+ cls.testClient = super(TestProjectAccountOperations, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
# Fill services from the external config file
- cls.services = cloudstackTestClient.getConfigParser().parsedDict
+ cls.services = cls.testClient.getParsedTestDataConfig()
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.template = get_template(
cls.api_client,
cls.zone.id,
cls.services["ostype"]
)
+ if cls.template == FAILED:
+ assert False, "get_template() failed to return template with description %s" % cls.services["ostype"]
cls.services["virtual_machine"]["zoneid"] = cls.zone.id
cls.services["virtual_machine"]["template"] = cls.template.id
cls.service_offering = ServiceOffering.create(
@@ -1338,20 +1313,22 @@ class TestRestartPersistentNetwork(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cloudstackTestClient = super(TestRestartPersistentNetwork,cls).getClsTestClient()
- cls.api_client = cloudstackTestClient.getApiClient()
+ cls.testClient = super(TestRestartPersistentNetwork, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
# Fill services from the external config file
- cls.services = cloudstackTestClient.getConfigParser().parsedDict
+ cls.services = cls.testClient.getParsedTestDataConfig()
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.template = get_template(
cls.api_client,
cls.zone.id,
cls.services["ostype"]
)
+ if cls.template == FAILED:
+ assert False, "get_template() failed to return template with description %s" % cls.services["ostype"]
cls.services["virtual_machine"]["zoneid"] = cls.zone.id
cls.services["virtual_machine"]["template"] = cls.template.id
cls.service_offering = ServiceOffering.create(
@@ -1618,25 +1595,28 @@ class TestVPCNetworkOperations(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cloudstackTestClient = super(TestVPCNetworkOperations,cls).getClsTestClient()
- cls.api_client = cloudstackTestClient.getApiClient()
+ cls.testClient = super(TestVPCNetworkOperations, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
# Fill services from the external config file
- cls.services = cloudstackTestClient.getConfigParser().parsedDict
+ cls.services = cls.testClient.getParsedTestDataConfig()
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.template = get_template(
cls.api_client,
cls.zone.id,
cls.services["ostype"]
)
+ if cls.template == FAILED:
+ assert False, "get_template() failed to return template with description %s" % cls.services["ostype"]
+
cls.services["virtual_machine"]["zoneid"] = cls.zone.id
cls.services["virtual_machine"]["template"] = cls.template.id
cls.service_offering = ServiceOffering.create(
cls.api_client,
- cls.services["service_offering"]
+ cls.services["service_offerings"]["small"]
)
cls.persistent_network_offering_NoLB = NetworkOffering.create(cls.api_client, cls.services["nw_off_persistent_VPCVR_NoLB"],
conservemode=False)
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/component/test_portable_ip.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_portable_ip.py b/test/integration/component/test_portable_ip.py
index e8bf4f5..61268eb 100644
--- a/test/integration/component/test_portable_ip.py
+++ b/test/integration/component/test_portable_ip.py
@@ -21,25 +21,11 @@
Feature Specifications: https://cwiki.apache.org/confluence/display/CLOUDSTACK/portable+public+IP
"""
from marvin.cloudstackTestCase import cloudstackTestCase
-from marvin.integration.lib.utils import cleanup_resources
-from marvin.integration.lib.base import (Account,
- NetworkOffering,
- ServiceOffering,
- Network,
- VirtualMachine,
- PublicIPAddress,
- FireWallRule,
- NATRule,
- PortablePublicIpRange,
- StaticNATRule)
-from marvin.integration.lib.common import (get_zone,
- get_pod,
- get_domain,
- get_region,
- get_template,
- get_portable_ip_range_services,
- is_public_ip_in_correct_state)
-from netaddr import IPAddress
+from marvin.cloudstackException import CloudstackAPIException
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
+from netaddr import *
from marvin.sshClient import SshClient
from nose.plugins.attrib import attr
@@ -144,6 +130,14 @@ class Services:
"protocol": 'TCP',
},
"ostype": 'CentOS 5.3 (64-bit)',
+ "portableIpRange": {
+ "gateway" : "10.223.252.195",
+ "netmask" : "255.255.255.192",
+ "startip" : "10.223.252.196",
+ "endip" : "10.223.252.197",
+ "vlan" : "1001"
+ }
+
}
class TestCreatePortablePublicIpRanges(cloudstackTestCase):
@@ -153,13 +147,15 @@ class TestCreatePortablePublicIpRanges(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(TestCreatePortablePublicIpRanges, cls).getClsTestClient().getApiClient()
+ cls.testClient = super(TestCreatePortablePublicIpRanges, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.region = get_region(cls.api_client, cls.services)
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
- cls.pod = get_pod(cls.api_client, cls.zone.id, cls.services)
+ cls.region = get_region(cls.api_client)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
+ cls.pod = get_pod(cls.api_client, cls.zone.id)
cls.services['mode'] = cls.zone.networktype
cls.services["domainid"] = cls.domain.id
cls.services["zoneid"] = cls.zone.id
@@ -199,7 +195,7 @@ class TestCreatePortablePublicIpRanges(cloudstackTestCase):
# 1. Create new portable ip range with root admin api
# 2. Portable ip range should be created successfully
- portable_ip_range_services = get_portable_ip_range_services(self.config)
+ portable_ip_range_services = self.services["portableIpRange"]
self.debug(portable_ip_range_services)
@@ -238,12 +234,12 @@ class TestCreatePortablePublicIpRanges(cloudstackTestCase):
domainid=self.domain.id
)
- self.api_client_user = self.testClient.createUserApiClient(
+ self.api_client_user = self.testClient.getUserApiClient(
UserName=self.account.name,
DomainName=self.account.domain
)
- portable_ip_range_services = get_portable_ip_range_services(self.config)
+ portable_ip_range_services = self.services["portableIpRange"]
if portable_ip_range_services is None:
self.skipTest('Failed to read config values related to portable ip range')
@@ -265,7 +261,7 @@ class TestCreatePortablePublicIpRanges(cloudstackTestCase):
# 1. Try to create new portable ip range with invalid region id
# 2. Portable ip range creation should fail
- portable_ip_range_services = get_portable_ip_range_services(self.config)
+ portable_ip_range_services = self.services["portableIpRange"]
if portable_ip_range_services is None:
self.skipTest('Failed to read config values related to portable ip range')
@@ -289,13 +285,15 @@ class TestDeletePortablePublicIpRanges(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(TestDeletePortablePublicIpRanges, cls).getClsTestClient().getApiClient()
+ cls.testClient = super(TestDeletePortablePublicIpRanges, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.region = get_region(cls.api_client, cls.services)
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
- cls.pod = get_pod(cls.api_client, cls.zone.id, cls.services)
+ cls.region = get_region(cls.api_client)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
+ cls.pod = get_pod(cls.api_client, cls.zone.id)
cls.services['mode'] = cls.zone.networktype
cls.services["domainid"] = cls.domain.id
cls.services["zoneid"] = cls.zone.id
@@ -317,7 +315,7 @@ class TestDeletePortablePublicIpRanges(cloudstackTestCase):
self.apiclient = self.testClient.getApiClient()
self.dbclient = self.testClient.getDbConnection()
- portable_ip_range_services = get_portable_ip_range_services(self.config)
+ portable_ip_range_services = self.services["portableIpRange"]
if portable_ip_range_services is None:
self.skipTest('Failed to read config values related to portable ip range')
@@ -378,7 +376,7 @@ class TestDeletePortablePublicIpRanges(cloudstackTestCase):
self.cleanup.append(self.account)
- self.api_client_user = self.testClient.createUserApiClient(
+ self.api_client_user = self.testClient.getUserApiClient(
UserName=self.account.name,
DomainName=self.account.domain
)
@@ -461,13 +459,15 @@ class TestListPortablePublicIpRanges(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(TestListPortablePublicIpRanges, cls).getClsTestClient().getApiClient()
+ cls.testClient = super(TestListPortablePublicIpRanges, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.region = get_region(cls.api_client, cls.services)
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
- cls.pod = get_pod(cls.api_client, cls.zone.id, cls.services)
+ cls.region = get_region(cls.api_client)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
+ cls.pod = get_pod(cls.api_client, cls.zone.id)
cls.services['mode'] = cls.zone.networktype
cls.services["domainid"] = cls.domain.id
cls.services["zoneid"] = cls.zone.id
@@ -490,7 +490,7 @@ class TestListPortablePublicIpRanges(cloudstackTestCase):
self.dbclient = self.testClient.getDbConnection()
#create new portable ip range
- self.portable_ip_range_services = get_portable_ip_range_services(self.config)
+ self.portable_ip_range_services = self.services["portableIpRange"]
if self.portable_ip_range_services is None:
self.skipTest('Failed to read config values related to portable ip range')
@@ -569,7 +569,7 @@ class TestListPortablePublicIpRanges(cloudstackTestCase):
self.cleanup.append(self.account)
- self.api_client_user = self.testClient.createUserApiClient(
+ self.api_client_user = self.testClient.getUserApiClient(
UserName=self.account.name,
DomainName=self.account.domain
)
@@ -585,13 +585,15 @@ class TestAssociatePublicIp(cloudstackTestCase):
"""
@classmethod
def setUpClass(cls):
- cls.api_client = super(TestAssociatePublicIp, cls).getClsTestClient().getApiClient()
+ cls.testClient = super(TestAssociatePublicIp, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.region = get_region(cls.api_client, cls.services)
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
- cls.pod = get_pod(cls.api_client, cls.zone.id, cls.services)
+ cls.region = get_region(cls.api_client)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
+ cls.pod = get_pod(cls.api_client, cls.zone.id)
cls.services['mode'] = cls.zone.networktype
cls.services["domainid"] = cls.domain.id
cls.services["zoneid"] = cls.zone.id
@@ -651,7 +653,7 @@ class TestAssociatePublicIp(cloudstackTestCase):
self.cleanup = []
- portable_ip_range_services = get_portable_ip_range_services(self.config)
+ portable_ip_range_services = self.services["portableIpRange"]
if portable_ip_range_services is None:
self.skipTest('Failed to read config values related to portable ip range')
@@ -909,13 +911,15 @@ class TestDisassociatePublicIp(cloudstackTestCase):
"""
@classmethod
def setUpClass(cls):
- cls.api_client = super(TestDisassociatePublicIp, cls).getClsTestClient().getApiClient()
+ cls.testClient = super(TestDisassociatePublicIp, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.region = get_region(cls.api_client, cls.services)
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
- cls.pod = get_pod(cls.api_client, cls.zone.id, cls.services)
+ cls.region = get_region(cls.api_client)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
+ cls.pod = get_pod(cls.api_client, cls.zone.id)
cls.services['mode'] = cls.zone.networktype
cls.services["domainid"] = cls.domain.id
cls.services["zoneid"] = cls.zone.id
@@ -993,7 +997,7 @@ class TestDisassociatePublicIp(cloudstackTestCase):
self.dbclient = self.testClient.getDbConnection()
self.cleanup = []
- portable_ip_range_services = get_portable_ip_range_services(self.config)
+ portable_ip_range_services = self.services["portableIpRange"]
if portable_ip_range_services is None:
self.skipTest('Failed to read config values related to portable ip range')
@@ -1144,7 +1148,7 @@ class TestDisassociatePublicIp(cloudstackTestCase):
domainid=self.domain.id
)
- self.api_client_user = self.testClient.createUserApiClient(
+ self.api_client_user = self.testClient.getUserApiClient(
UserName=self.user_account.name,
DomainName=self.user_account.domain
)
@@ -1168,14 +1172,16 @@ class TestDeleteAccount(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(TestDeleteAccount, cls).getClsTestClient().getApiClient()
+ cls.testClient = super(TestDeleteAccount, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.region = get_region(cls.api_client, cls.services)
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.region = get_region(cls.api_client)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.services['mode'] = cls.zone.networktype
- cls.pod = get_pod(cls.api_client, cls.zone.id, cls.services)
+ cls.pod = get_pod(cls.api_client, cls.zone.id)
cls.services['mode'] = cls.zone.networktype
cls.services["domainid"] = cls.domain.id
cls.services["zoneid"] = cls.zone.id
@@ -1213,7 +1219,7 @@ class TestDeleteAccount(cloudstackTestCase):
)
self.cleanup = []
- portable_ip_range_services = get_portable_ip_range_services(self.config)
+ portable_ip_range_services = self.services["portableIpRange"]
if portable_ip_range_services is None:
self.skipTest('Failed to read config values related to portable ip range')
@@ -1393,13 +1399,15 @@ class TestPortableIpTransferAcrossNetworks(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(TestPortableIpTransferAcrossNetworks, cls).getClsTestClient().getApiClient()
+ cls.testClient = super(TestPortableIpTransferAcrossNetworks, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.region = get_region(cls.api_client, cls.services)
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
- cls.pod = get_pod(cls.api_client, cls.zone.id, cls.services)
+ cls.region = get_region(cls.api_client)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
+ cls.pod = get_pod(cls.api_client, cls.zone.id)
cls.services['mode'] = cls.zone.networktype
cls.services["domainid"] = cls.domain.id
cls.services["zoneid"] = cls.zone.id
@@ -1488,7 +1496,7 @@ class TestPortableIpTransferAcrossNetworks(cloudstackTestCase):
self.dbclient = self.testClient.getDbConnection()
#create new portable ip range
- self.portable_ip_range_services = get_portable_ip_range_services(self.config)
+ self.portable_ip_range_services = self.services["portableIpRange"]
if self.portable_ip_range_services is None:
self.skipTest('Failed to read config values related to portable ip range')
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/component/test_project_configs.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_project_configs.py b/test/integration/component/test_project_configs.py
index 4d878f7..4b777fe 100644
--- a/test/integration/component/test_project_configs.py
+++ b/test/integration/component/test_project_configs.py
@@ -21,9 +21,9 @@ import marvin
from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
from marvin.sshClient import SshClient
import datetime
@@ -109,13 +109,11 @@ class TestUserProjectCreation(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(
- TestUserProjectCreation,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestUserProjectCreation, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
- # Get Zone
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.services['mode'] = cls.zone.networktype
configs = Configurations.list(
@@ -275,13 +273,11 @@ class TestProjectCreationNegative(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(
- TestProjectCreationNegative,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestProjectCreationNegative, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
- # Get Zone
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.services['mode'] = cls.zone.networktype
# Checking for prereqisits - global configs
@@ -420,17 +416,15 @@ class TestProjectInviteRequired(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(
- TestProjectInviteRequired,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestProjectInviteRequired, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
- # Get Zone
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.services['mode'] = cls.zone.networktype
# Create domains, account etc.
- cls.domain = get_domain(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
# Verify 'project.invite.required' is set to false
configs = Configurations.list(
@@ -572,17 +566,15 @@ class TestProjectInviteRequiredTrue(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(
- TestProjectInviteRequiredTrue,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestProjectInviteRequiredTrue, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
- # Get Zone
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.services['mode'] = cls.zone.networktype
# Create domains, account etc.
- cls.domain = get_domain(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
# Verify 'project.invite.required' is set to true
configs = Configurations.list(
@@ -725,17 +717,15 @@ class TestProjectInviteTimeout(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(
- TestProjectInviteTimeout,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestProjectInviteTimeout, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
- # Get Zone
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.services['mode'] = cls.zone.networktype
# Create domains, account etc.
- cls.domain = get_domain(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
# Verify 'project.invite.required' is set to true
configs = Configurations.list(
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/component/test_project_limits.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_project_limits.py b/test/integration/component/test_project_limits.py
index 7d93876..7941313 100644
--- a/test/integration/component/test_project_limits.py
+++ b/test/integration/component/test_project_limits.py
@@ -21,9 +21,9 @@ import marvin
from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
from marvin.codes import PASS
import datetime
@@ -124,13 +124,11 @@ class TestProjectLimits(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(
- TestProjectLimits,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestProjectLimits, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
- # Get Zone
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.services['mode'] = cls.zone.networktype
# Create domains, account etc.
@@ -502,10 +500,11 @@ class TestResourceLimitsProject(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(TestResourceLimitsProject, cls).getClsTestClient().getApiClient()
+ cls.testClient = super(TestResourceLimitsProject, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
- # Get Zone, Domain and templates
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.services['mode'] = cls.zone.networktype
cls.template = get_template(
@@ -945,14 +944,12 @@ class TestMaxProjectNetworks(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(
- TestMaxProjectNetworks,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestMaxProjectNetworks, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
- # Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
+ cls.domain = get_domain(cls.api_client)
cls.services['mode'] = cls.zone.networktype
cls.template = get_template(
cls.api_client,
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/component/test_project_resources.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_project_resources.py b/test/integration/component/test_project_resources.py
index 7fb23a4..8f81cf9 100644
--- a/test/integration/component/test_project_resources.py
+++ b/test/integration/component/test_project_resources.py
@@ -19,7 +19,7 @@
#Import Local Modules
from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import cloudstackTestCase, unittest
-from marvin.integration.lib.base import (VirtualMachine,
+from marvin.lib.base import (VirtualMachine,
Account,
Project,
NATRule,
@@ -35,7 +35,7 @@ from marvin.integration.lib.base import (VirtualMachine,
DiskOffering,
LoadBalancerRule)
-from marvin.integration.lib.common import (get_zone,
+from marvin.lib.common import (get_zone,
get_template,
get_domain,
list_volumes,
@@ -44,7 +44,7 @@ from marvin.integration.lib.common import (get_zone,
get_free_vlan,
wait_for_cleanup)
-from marvin.integration.lib.utils import cleanup_resources
+from marvin.lib.utils import cleanup_resources
import random
@@ -161,13 +161,11 @@ class TestOfferings(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(
- TestOfferings,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestOfferings, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
- # Get Zone and template
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.services['mode'] = cls.zone.networktype
cls.template = get_template(
cls.api_client,
@@ -342,13 +340,11 @@ class TestNetwork(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(
- TestNetwork,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestNetwork, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
- # Get Zone and template
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.services['mode'] = cls.zone.networktype
cls.template = get_template(
cls.api_client,
@@ -550,13 +546,11 @@ class TestTemplates(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(
- TestTemplates,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestTemplates, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
- # Get Zone, Domain and templates
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.services['mode'] = cls.zone.networktype
cls.template = get_template(
@@ -780,13 +774,11 @@ class TestSnapshots(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(
- TestSnapshots,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestSnapshots, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
- # Get Zone, Domain and templates
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.services['mode'] = cls.zone.networktype
cls.template = get_template(
@@ -928,13 +920,11 @@ class TestPublicIpAddress(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(
- TestPublicIpAddress,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestPublicIpAddress, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
- # Get Zone, Domain and templates
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.services['mode'] = cls.zone.networktype
cls.template = get_template(
@@ -1213,15 +1203,12 @@ class TestSecurityGroup(cloudstackTestCase):
@classmethod
def setUpClass(cls):
+ cls.testClient = super(TestSecurityGroup, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
- cls.api_client = super(
- TestSecurityGroup,
- cls
- ).getClsTestClient().getApiClient()
-
- # Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
+ cls.domain = get_domain(cls.api_client)
cls.services['mode'] = cls.zone.networktype
template = get_template(
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/component/test_project_usage.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_project_usage.py b/test/integration/component/test_project_usage.py
index 10f48a6..16ca8c1 100644
--- a/test/integration/component/test_project_usage.py
+++ b/test/integration/component/test_project_usage.py
@@ -21,9 +21,9 @@ import marvin
from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
from marvin.sshClient import SshClient
import datetime
@@ -116,14 +116,13 @@ class TestVmUsage(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(
- TestVmUsage,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestVmUsage, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.services['mode'] = cls.zone.networktype
template = get_template(
@@ -311,14 +310,13 @@ class TestPublicIPUsage(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(
- TestPublicIPUsage,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestPublicIPUsage, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.services['mode'] = cls.zone.networktype
cls.template = get_template(
@@ -483,14 +481,13 @@ class TestVolumeUsage(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(
- TestVolumeUsage,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestVolumeUsage, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.services['mode'] = cls.zone.networktype
cls.disk_offering = DiskOffering.create(
cls.api_client,
@@ -668,14 +665,13 @@ class TestTemplateUsage(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(
- TestTemplateUsage,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestTemplateUsage, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.services['mode'] = cls.zone.networktype
cls.services["server"]["zoneid"] = cls.zone.id
template = get_template(
@@ -844,11 +840,13 @@ class TestISOUsage(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(TestISOUsage, cls).getClsTestClient().getApiClient()
+ cls.testClient = super(TestISOUsage, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.services['mode'] = cls.zone.networktype
cls.services["server"]["zoneid"] = cls.zone.id
cls.services["iso"]["zoneid"] = cls.zone.id
@@ -990,14 +988,13 @@ class TestLBRuleUsage(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(
- TestLBRuleUsage,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestLBRuleUsage, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.services['mode'] = cls.zone.networktype
template = get_template(
cls.api_client,
@@ -1173,14 +1170,13 @@ class TestSnapshotUsage(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(
- TestSnapshotUsage,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestSnapshotUsage, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.services['mode'] = cls.zone.networktype
template = get_template(
@@ -1351,14 +1347,13 @@ class TestNatRuleUsage(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(
- TestNatRuleUsage,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestNatRuleUsage, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.services['mode'] = cls.zone.networktype
template = get_template(
cls.api_client,
@@ -1534,14 +1529,13 @@ class TestVpnUsage(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(
- TestVpnUsage,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestVpnUsage, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.services['mode'] = cls.zone.networktype
template = get_template(
cls.api_client,
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/component/test_projects.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_projects.py b/test/integration/component/test_projects.py
index 1a00f58..c593fb6 100644
--- a/test/integration/component/test_projects.py
+++ b/test/integration/component/test_projects.py
@@ -21,9 +21,9 @@ import marvin
from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
from marvin.sshClient import SshClient
import datetime
@@ -103,21 +103,15 @@ class TestMultipleProjectCreation(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(
- TestMultipleProjectCreation,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestMultipleProjectCreation, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
- # Get Zone
- cls.zone = get_zone(cls.api_client, cls.services)
+ # Get Zone, Domain and templates
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.services['mode'] = cls.zone.networktype
- # Create domains, account etc.
- cls.domain = get_domain(
- cls.api_client,
- cls.services
- )
-
configs = Configurations.list(
cls.api_client,
name='project.invite.required'
@@ -320,18 +314,14 @@ class TestCrossDomainAccountAdd(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(
- TestCrossDomainAccountAdd,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestCrossDomainAccountAdd, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
- # Get Zone
- cls.zone = get_zone(cls.api_client, cls.services)
+ # Get Zone, Domain and templates
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.services['mode'] = cls.zone.networktype
- cls.domain = get_domain(
- cls.api_client,
- cls.services
- )
configs = Configurations.list(
cls.api_client,
@@ -454,18 +444,14 @@ class TestDeleteAccountWithProject(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(
- TestDeleteAccountWithProject,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestDeleteAccountWithProject, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
- # Get Zone
- cls.zone = get_zone(cls.api_client, cls.services)
+ # Get Zone, Domain and templates
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.services['mode'] = cls.zone.networktype
- cls.domain = get_domain(
- cls.api_client,
- cls.services
- )
configs = Configurations.list(
cls.api_client,
@@ -567,13 +553,12 @@ class TestDeleteDomainWithProject(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(
- TestDeleteDomainWithProject,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestDeleteDomainWithProject, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.services['mode'] = cls.zone.networktype
configs = Configurations.list(
@@ -708,17 +693,13 @@ class TestProjectOwners(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(
- TestProjectOwners,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestProjectOwners, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone
- cls.domain = get_domain(
- cls.api_client,
- cls.services
- )
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
+ cls.domain = get_domain(cls.api_client)
cls.services['mode'] = cls.zone.networktype
configs = Configurations.list(
@@ -1136,18 +1117,14 @@ class TestProjectResources(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(
- TestProjectResources,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestProjectResources, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
+ cls.domain = get_domain(cls.api_client)
cls.services['mode'] = cls.zone.networktype
- cls.domain = get_domain(
- cls.api_client,
- cls.services
- )
configs = Configurations.list(
cls.api_client,
@@ -1440,18 +1417,14 @@ class TestProjectSuspendActivate(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(
- TestProjectSuspendActivate,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestProjectSuspendActivate, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
- # Get Zone, domain, template etc
- cls.zone = get_zone(cls.api_client, cls.services)
+ # Get Zone
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
+ cls.domain = get_domain(cls.api_client)
cls.services['mode'] = cls.zone.networktype
- cls.domain = get_domain(
- cls.api_client,
- cls.services
- )
cls.template = get_template(
cls.api_client,
cls.zone.id,
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/component/test_recurring_snapshots.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_recurring_snapshots.py b/test/integration/component/test_recurring_snapshots.py
index fd1b57d..2ef2bc3 100644
--- a/test/integration/component/test_recurring_snapshots.py
+++ b/test/integration/component/test_recurring_snapshots.py
@@ -18,9 +18,9 @@
from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
class Services:
"""Test Snapshots Services
@@ -126,11 +126,13 @@ class TestRecurringSnapshots(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(TestRecurringSnapshots, cls).getClsTestClient().getApiClient()
+ cls.testClient = super(TestRecurringSnapshots, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.services['mode'] = cls.zone.networktype
cls.disk_offering = DiskOffering.create(
cls.api_client,
@@ -402,4 +404,4 @@ class TestRecurringSnapshots(cloudstackTestCase):
self.services["recurring_snapshot"]["maxsnaps"],
"Check maximum number of recurring snapshots retained"
)
- return
\ No newline at end of file
+ return
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/component/test_redundant_router_cleanups.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_redundant_router_cleanups.py b/test/integration/component/test_redundant_router_cleanups.py
index 84cbc6f..2220d51 100644
--- a/test/integration/component/test_redundant_router_cleanups.py
+++ b/test/integration/component/test_redundant_router_cleanups.py
@@ -16,9 +16,9 @@
# under the License.
from nose.plugins.attrib import attr
-from marvin.integration.lib.base import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.common import *
+from marvin.lib.base import *
+from marvin.lib.utils import *
+from marvin.lib.common import *
#Import Local Modules
from marvin.cloudstackTestCase import cloudstackTestCase
@@ -137,14 +137,13 @@ class TestRedundantRouterNetworkCleanups(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(
- TestRedundantRouterNetworkCleanups,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestRedundantRouterNetworkCleanups, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.template = get_template(
cls.api_client,
cls.zone.id,
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/component/test_redundant_router_services.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_redundant_router_services.py b/test/integration/component/test_redundant_router_services.py
index 5204d6f..707b673 100644
--- a/test/integration/component/test_redundant_router_services.py
+++ b/test/integration/component/test_redundant_router_services.py
@@ -17,9 +17,9 @@
from nose.plugins.attrib import attr
-from marvin.integration.lib.base import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.common import *
+from marvin.lib.base import *
+from marvin.lib.utils import *
+from marvin.lib.common import *
#Import Local Modules
from marvin.cloudstackTestCase import cloudstackTestCase
@@ -138,14 +138,13 @@ class TestEnableVPNOverRvR(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(
- TestEnableVPNOverRvR,
- cls
- ).getClsTestClient().getApiClient()
+ cls.testClient = super(TestEnableVPNOverRvR, cls).getClsTestClient()
+ cls.api_client = cls.testClient.getApiClient()
+
cls.services = Services().services
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.api_client)
+ cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
cls.template = get_template(
cls.api_client,
cls.zone.id,
[08/18] Marvin + test changes from master Signed-off-by:
SrikanteswaraRao Talluri
Posted by da...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/tools/marvin/marvin/cloudstackConnection.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/cloudstackConnection.py b/tools/marvin/marvin/cloudstackConnection.py
index fb03e3b..d006002 100644
--- a/tools/marvin/marvin/cloudstackConnection.py
+++ b/tools/marvin/marvin/cloudstackConnection.py
@@ -21,21 +21,35 @@ import base64
import hmac
import hashlib
import time
-import cloudstackException
from cloudstackAPI import *
import jsonHelper
+from marvin.codes import (
+ FAILED,
+ INVALID_RESPONSE,
+ INVALID_INPUT,
+ JOB_FAILED,
+ JOB_INPROGRESS,
+ JOB_CANCELLED,
+ JOB_SUCCEEDED
+)
from requests import (
ConnectionError,
HTTPError,
Timeout,
RequestException
- )
+)
+from marvin.cloudstackException import GetDetailExceptionInfo
-class cloudConnection(object):
+class CSConnection(object):
+
+ '''
+ @Desc: Connection Class to make API\Command calls to the
+ CloudStack Management Server
+ Sends the GET\POST requests to CS based upon the
+ information provided and retrieves the parsed response.
+ '''
- """ Connections to make API calls to the cloudstack management server
- """
def __init__(self, mgmtDet, asyncTimeout=3600, logger=None,
path='client/api'):
self.apiKey = mgmtDet.apiKey
@@ -44,68 +58,93 @@ class cloudConnection(object):
self.port = mgmtDet.port
self.user = mgmtDet.user
self.passwd = mgmtDet.passwd
- self.certCAPath = mgmtDet.certCAPath
- self.certPath = mgmtDet.certPath
+ self.certPath = ()
+ if mgmtDet.certCAPath != "NA" and mgmtDet.certPath != "NA":
+ self.certPath = (mgmtDet.certCAPath, mgmtDet.certPath)
self.logger = logger
self.path = path
self.retries = 5
+ self.__lastError = ''
self.mgtDetails = mgmtDet
- self.protocol = "http"
self.asyncTimeout = asyncTimeout
self.auth = True
if self.port == 8096 or \
(self.apiKey is None and self.securityKey is None):
self.auth = False
- if mgmtDet.useHttps == "True":
- self.protocol = "https"
- self.baseurl = "%s://%s:%d/%s"\
+ self.protocol = "https" if mgmtDet.useHttps == "True" else "http"
+ self.httpsFlag = True if self.protocol == "https" else False
+ self.baseUrl = "%s://%s:%d/%s"\
% (self.protocol, self.mgtSvr, self.port, self.path)
def __copy__(self):
- return cloudConnection(self.mgtDetails,
- self.asyncTimeout,
- self.logger,
- self.path)
-
- def poll(self, jobid, response):
- """
- polls the completion of a given jobid
- @param jobid:
- @param response:
- @return:
- """
- cmd = queryAsyncJobResult.queryAsyncJobResultCmd()
- cmd.jobid = jobid
- timeout = self.asyncTimeout
-
- while timeout > 0:
- asyncResonse = self.marvinRequest(cmd, response_type=response)
+ return CSConnection(self.mgtDetails,
+ self.asyncTimeout,
+ self.logger,
+ self.path)
- if asyncResonse.jobstatus == 2:
- raise cloudstackException.cloudstackAPIException(
- "asyncquery", asyncResonse.jobresult)
- elif asyncResonse.jobstatus == 1:
- return asyncResonse
-
- time.sleep(5)
- if self.logger is not None:
- self.logger.debug("job: %s still processing,"
- "will timeout in %ds" % (jobid, timeout))
- timeout = timeout - 5
+ def __poll(self, jobid, response_cmd):
+ '''
+ @Name : __poll
+ @Desc: polls for the completion of a given jobid
+ @Input 1. jobid: Monitor the Jobid for CS
+ 2. response_cmd:response command for request cmd
+ @return: FAILED if jobid is cancelled,failed
+ Else return async_response
+ '''
+ try:
+ cmd = queryAsyncJobResult.queryAsyncJobResultCmd()
+ cmd.jobid = jobid
+ timeout = self.asyncTimeout
+ start_time = time.time()
+ end_time = time.time()
+ async_response = FAILED
+ self.logger.debug("=== Jobid: %s Started ===" % (str(jobid)))
+ while timeout > 0:
+ async_response = self.\
+ marvinRequest(cmd, response_type=response_cmd)
+ if async_response != FAILED:
+ job_status = async_response.jobstatus
+ if job_status in [JOB_FAILED,
+ JOB_CANCELLED,
+ JOB_SUCCEEDED]:
+ break
+ time.sleep(5)
+ timeout -= 5
+ self.logger.debug("=== JobId:%s is Still Processing, "
+ "Will TimeOut in:%s ====" % (str(jobid),
+ str(timeout)))
+ end_time = time.time()
+ tot_time = int(start_time - end_time)
+ self.logger.debug(
+ "===Jobid:%s ; StartTime:%s ; EndTime:%s ; "
+ "TotalTime:%s===" %
+ (str(jobid), str(time.ctime(start_time)),
+ str(time.ctime(end_time)), str(tot_time)))
+ return async_response
+ except Exception as e:
+ self.__lastError = e
+ self.logger.exception("==== __poll: Exception Occurred :%s ====" %
+ str(self.__lastError))
+ return FAILED
- raise cloudstackException.cloudstackAPIException(
- "asyncquery", "Async job timeout %s" % jobid)
+ def getLastError(self):
+ '''
+ @Name : getLastError
+ @Desc : Returns the last error from marvinRequest
+ '''
+ return self.__lastError
- def sign(self, payload):
+ def __sign(self, payload):
"""
- signs a given request URL when the apiKey and secretKey are known
-
- @param payload: dict of GET params to be signed
- @return: the signature of the payload
+ @Name : __sign
+ @Desc:signs a given request URL when the apiKey and
+ secretKey are known
+ @Input: payload: dictionary of params be signed
+ @Output: the signature of the payload
"""
params = zip(payload.keys(), payload.values())
params.sort(key=lambda k: str.lower(k[0]))
- hashStr = "&".join(
+ hash_str = "&".join(
["=".join(
[str.lower(r[0]),
str.lower(
@@ -114,168 +153,219 @@ class cloudConnection(object):
) for r in params]
)
signature = base64.encodestring(hmac.new(
- self.securityKey, hashStr, hashlib.sha1).digest()).strip()
- self.logger.debug("Computed Signature by Marvin: %s" % signature)
+ self.securityKey, hash_str, hashlib.sha1).digest()).strip()
return signature
- def request(self, command, auth=True, payload={}, method='GET'):
+ def __sendPostReqToCS(self, url, payload):
+ '''
+ @Name : __sendPostReqToCS
+ @Desc : Sends the POST Request to CS
+ @Input : url: URL to send post req
+ payload:Payload information as part of request
+ @Output: Returns response from POST output
+ else FAILED
+ '''
+ try:
+ response = requests.post(url,
+ params=payload,
+ cert=self.certPath,
+ verify=self.httpsFlag)
+ return response
+ except Exception as e:
+ self.__lastError = e
+ self.logger.\
+ exception("__sendPostReqToCS : Exception "
+ "Occurred: %s" % str(self.__lastError))
+ return FAILED
+
+ def __sendGetReqToCS(self, url, payload):
+ '''
+ @Name : __sendGetReqToCS
+ @Desc : Sends the GET Request to CS
+ @Input : url: URL to send post req
+ payload:Payload information as part of request
+ @Output: Returns response from GET output
+ else FAILED
+ '''
+ try:
+ response = requests.get(url,
+ params=payload,
+ cert=self.certPath,
+ verify=self.httpsFlag)
+ return response
+ except Exception as e:
+ self.__lastError = e
+ self.logger.exception("__sendGetReqToCS : Exception Occurred: %s" %
+ str(self.__lastError))
+ return FAILED
+
+ def __sendCmdToCS(self, command, auth=True, payload={}, method='GET'):
"""
- Makes requests using auth or over integration port
- @param command: cloudstack API command name
+ @Name : __sendCmdToCS
+ @Desc : Makes requests to CS using the Inputs provided
+ @Input: command: cloudstack API command name
eg: deployVirtualMachineCommand
- @param auth: Authentication (apikey,secretKey) => True
+ auth: Authentication (apikey,secretKey) => True
else False for integration.api.port
- @param payload: request data composed as a dictionary
- @param method: GET/POST via HTTP
- @return:
+ payload: request data composed as a dictionary
+ method: GET/POST via HTTP
+ @output: FAILED or else response from CS
"""
- payload["command"] = command
- payload["response"] = "json"
-
- if auth:
- payload["apiKey"] = self.apiKey
- signature = self.sign(payload)
- payload["signature"] = signature
-
try:
- #https_flag : Signifies whether to verify connection over \
- #http or https, \
- #initialized to False, will be set to true if user provided https
- #connection
- https_flag = False
- cert_path = ()
- if self.protocol == "https":
- https_flag = True
- if self.certCAPath != "NA" and self.certPath != "NA":
- cert_path = (self.certCAPath, self.certPath)
+ payload["command"] = command
+ payload["response"] = "json"
- #Verify whether protocol is "http", then call the request over http
- if self.protocol == "http":
+ if auth:
+ payload["apiKey"] = self.apiKey
+ payload["signature"] = self.__sign(payload)
+
+ # Verify whether protocol is "http" or "https", then send the
+ # request
+ if self.protocol in ["http", "https"]:
+ self.logger.debug("Payload: %s" % str(payload))
if method == 'POST':
- response = requests.post(self.baseurl, params=payload,
- verify=https_flag)
- else:
- response = requests.get(self.baseurl, params=payload,
- verify=https_flag)
+ self.logger.debug("=======Sending POST Cmd : %s======="
+ % str(command))
+ return self.__sendPostReqToCS(self.baseUrl, payload)
+ if method == "GET":
+ self.logger.debug("========Sending GET Cmd : %s======="
+ % str(command))
+ return self.__sendGetReqToCS(self.baseUrl, payload)
else:
- '''
- If protocol is https, then create the connection url with \
- user provided certificates \
- provided as part of cert
- '''
- try:
- if method == 'POST':
- response = requests.post(self.baseurl,
- params=payload,
- cert=cert_path,
- verify=https_flag)
- else:
- response = requests.get(self.baseurl, params=payload,
- cert=cert_path,
- verify=https_flag)
- except Exception, e:
- '''
- If an exception occurs with user provided CA certs, \
- then try with default certs, \
- we dont need to mention here the cert path
- '''
- self.logger.debug("Creating CS connection over https \
- didnt worked with user provided certs \
- , so trying with no certs %s" % e)
- if method == 'POST':
- response = requests.post(self.baseurl,
- params=payload,
- verify=https_flag)
- else:
- response = requests.get(self.baseurl,
- params=payload,
- verify=https_flag)
- except ConnectionError, c:
- self.logger.debug("Connection refused. Reason: %s : %s" %
- (self.baseurl, c))
- raise c
- except HTTPError, h:
- self.logger.debug("Http Error.Server returned error code: %s" % h)
- raise h
- except Timeout, t:
- self.logger.debug("Connection timed out with %s" % t)
- raise t
- except RequestException, r:
- self.logger.debug("RequestException from server %s" % r)
- raise r
- except Exception, e:
- self.logger.debug("Error returned by server %s" % r)
- raise e
- else:
- return response
+ self.logger.exception("__sendCmdToCS: Invalid Protocol")
+ return FAILED
+ except Exception as e:
+ self.logger.exception("__sendCmdToCS: Exception:%s" %
+ GetDetailExceptionInfo(e))
+ return FAILED
- def sanitizeCommand(self, cmd):
+ def __sanitizeCmd(self, cmd):
"""
- Removes None values, Validates all required params are present
- @param cmd: Cmd object eg: createPhysicalNetwork
- @return:
+ @Name : __sanitizeCmd
+ @Desc : Removes None values, Validates all required params are present
+ @Input: cmd: Cmd object eg: createPhysicalNetwork
+ @Output: Returns command name, asynchronous or not,request payload
+ FAILED for failed cases
"""
- requests = {}
- required = []
- for attribute in dir(cmd):
- if not attribute.startswith('__'):
- if attribute == "isAsync":
- isAsync = getattr(cmd, attribute)
- elif attribute == "required":
- required = getattr(cmd, attribute)
- else:
- requests[attribute] = getattr(cmd, attribute)
-
- cmdname = cmd.__class__.__name__.replace("Cmd", "")
- for requiredPara in required:
- if requests[requiredPara] is None:
- raise cloudstackException.cloudstackAPIException(
- cmdname, "%s is required" % requiredPara)
- for param, value in requests.items():
- if value is None:
- requests.pop(param)
- elif isinstance(value, list):
- if len(value) == 0:
- requests.pop(param)
- else:
- if not isinstance(value[0], dict):
- requests[param] = ",".join(value)
+ try:
+ cmd_name = ''
+ payload = {}
+ required = []
+ isAsync = "false"
+ for attribute in dir(cmd):
+ if not attribute.startswith('__'):
+ if attribute == "isAsync":
+ isAsync = getattr(cmd, attribute)
+ elif attribute == "required":
+ required = getattr(cmd, attribute)
else:
- requests.pop(param)
- i = 0
- for val in value:
- for k, v in val.iteritems():
- requests["%s[%d].%s" % (param, i, k)] = v
- i = i + 1
- return cmdname.strip(), isAsync, requests
+ payload[attribute] = getattr(cmd, attribute)
+ cmd_name = cmd.__class__.__name__.replace("Cmd", "")
+ for required_param in required:
+ if payload[required_param] is None:
+ self.logger.debug("CmdName: %s Parameter : %s is Required"
+ % (cmd_name, required_param))
+ return FAILED
+ for param, value in payload.items():
+ if value is None:
+ payload.pop(param)
+ elif isinstance(value, list):
+ if len(value) == 0:
+ payload.pop(param)
+ else:
+ if not isinstance(value[0], dict):
+ payload[param] = ",".join(value)
+ else:
+ payload.pop(param)
+ i = 0
+ for val in value:
+ for k, v in val.iteritems():
+ payload["%s[%d].%s" % (param, i, k)] = v
+ i += 1
+ return cmd_name.strip(), isAsync, payload
+ except Exception as e:
+ self.logger.\
+ exception("__sanitizeCmd: CmdName : "
+ "%s : Exception:%s" % (cmd_name,
+ GetDetailExceptionInfo(e)))
+ return FAILED
+
+ def __parseAndGetResponse(self, cmd_response, response_cls, is_async):
+ '''
+ @Name : __parseAndGetResponse
+ @Desc : Verifies the Response(from CS) and returns an
+ appropriate json parsed Response
+ @Input: cmd_response: Command Response from cs
+ response_cls : Mapping class for this Response
+ is_async: Whether the cmd is async or not.
+ @Output:Response output from CS
+ '''
+ try:
+ ret = jsonHelper.getResultObj(cmd_response.json(), response_cls)
+ except TypeError:
+ ret = jsonHelper.getResultObj(cmd_response.json, response_cls)
+
+ '''
+ If the response is asynchronous, poll and return response
+ else return response as it is
+ '''
+ if is_async == "false":
+ self.logger.debug("Response : %s" % str(ret))
+ return ret
+ else:
+ response = self.__poll(ret.jobid, response_cls)
+ self.logger.debug("Response : %s" % str(response))
+ return response.jobresult if response != FAILED else FAILED
def marvinRequest(self, cmd, response_type=None, method='GET', data=''):
"""
- Requester for marvin command objects
- @param cmd: marvin's command from cloudstackAPI
- @param response_type: response type of the command in cmd
- @param method: HTTP GET/POST, defaults to GET
- @return:
+ @Name : marvinRequest
+ @Desc: Handles Marvin Requests
+ @Input cmd: marvin's command from cloudstackAPI
+ response_type: response type of the command in cmd
+ method: HTTP GET/POST, defaults to GET
+ @Output: Response received from CS
+ FAILED In case of Error\Exception
"""
- cmdname, isAsync, payload = self.sanitizeCommand(cmd)
- self.logger.debug("sending %s request: %s %s" % (method, cmdname,
- str(payload)))
- response = self.request(cmdname,
- self.auth,
- payload=payload,
- method=method)
- if response is None:
- return None
- self.logger.debug("Request: %s Response: %s" % (response.url,
- response.text))
try:
- response = jsonHelper.getResultObj(response.json(), response_type)
- except TypeError:
- response = jsonHelper.getResultObj(response.json, response_type)
+ '''
+ 1. Verify the Inputs Provided
+ '''
+ if (cmd is None or cmd == '')or \
+ (response_type is None or response_type == ''):
+ self.logger.exception("marvinRequest : Invalid Command Input")
+ return FAILED
- if isAsync == "false":
- return response
- else:
- asyncJobId = response.jobid
- response = self.poll(asyncJobId, response_type)
- return response.jobresult
+ '''
+ 2. Sanitize the Command
+ '''
+ sanitize_cmd_out = self.__sanitizeCmd(cmd)
+
+ if sanitize_cmd_out == FAILED:
+ return FAILED
+
+ cmd_name, is_async, payload = sanitize_cmd_out
+ '''
+ 3. Send Command to CS
+ '''
+ cmd_response = self.__sendCmdToCS(cmd_name,
+ self.auth,
+ payload=payload,
+ method=method)
+ if cmd_response == FAILED:
+ raise self.__lastError
+
+ '''
+ 4. Check if the Command Response received above is valid or Not.
+ If not return Invalid Response
+ '''
+ ret = self.__parseAndGetResponse(cmd_response,
+ response_type,
+ is_async)
+ if ret == FAILED:
+ raise self.__lastError
+ return ret
+ except Exception as e:
+ self.logger.exception("marvinRequest : CmdName: %s Exception: %s" %
+ (str(cmd), GetDetailExceptionInfo(e)))
+ return FAILED
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/tools/marvin/marvin/cloudstackException.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/cloudstackException.py b/tools/marvin/marvin/cloudstackException.py
index 6200003..c2eb57a 100644
--- a/tools/marvin/marvin/cloudstackException.py
+++ b/tools/marvin/marvin/cloudstackException.py
@@ -15,8 +15,13 @@
# specific language governing permissions and limitations
# under the License.
+import sys
+import traceback
+from marvin.codes import (INVALID_INPUT, EXCEPTION_OCCURRED)
+
+
+class CloudstackAPIException(Exception):
-class cloudstackAPIException(Exception):
def __init__(self, cmd="", result=""):
self.errorMsg = "Execute cmd: %s failed, due to: %s" % (cmd, result)
@@ -25,6 +30,7 @@ class cloudstackAPIException(Exception):
class InvalidParameterException(Exception):
+
def __init__(self, msg=''):
self.errorMsg = msg
@@ -33,6 +39,7 @@ class InvalidParameterException(Exception):
class dbException(Exception):
+
def __init__(self, msg=''):
self.errorMsg = msg
@@ -41,8 +48,18 @@ class dbException(Exception):
class internalError(Exception):
+
def __init__(self, msg=''):
self.errorMsg = msg
def __str__(self):
return self.errorMsg
+
+
+def GetDetailExceptionInfo(e):
+ if e is not None:
+ exc_type, exc_value, exc_traceback = sys.exc_info()
+ return str(repr(traceback.format_exception(
+ exc_type, exc_value, exc_traceback)))
+ else:
+ return EXCEPTION_OCCURRED
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/tools/marvin/marvin/cloudstackTestCase.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/cloudstackTestCase.py b/tools/marvin/marvin/cloudstackTestCase.py
index 6456bb1..5cb4a10 100644
--- a/tools/marvin/marvin/cloudstackTestCase.py
+++ b/tools/marvin/marvin/cloudstackTestCase.py
@@ -16,7 +16,7 @@
# under the License.
import unittest
-from marvin.integration.lib.utils import verifyElementInList
+from marvin.lib.utils import verifyElementInList
from marvin.codes import PASS
@@ -37,7 +37,7 @@ def user(Name, DomainName, AcctType):
class cloudstackTestCase(unittest.case.TestCase):
clstestclient = None
- def assertElementInList(inp, toverify, responsevar=None, pos=0,
+ def assertElementInList(inp, toverify, responsevar=None, pos=0,
assertmsg="TC Failed for reason"):
'''
@Name: assertElementInList
@@ -46,7 +46,7 @@ class cloudstackTestCase(unittest.case.TestCase):
Takes one additional argument of what message to assert with
when failed
'''
- out = verifyElementInList(inp, toverify, responsevar, pos)
+ out = verifyElementInList(inp, toverify, responsevar, pos)
unittest.TestCase.assertEquals(out[0], PASS, "msg:%s" % out[1])
@classmethod
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/tools/marvin/marvin/cloudstackTestClient.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/cloudstackTestClient.py b/tools/marvin/marvin/cloudstackTestClient.py
index 4ac510b..53d48ab 100644
--- a/tools/marvin/marvin/cloudstackTestClient.py
+++ b/tools/marvin/marvin/cloudstackTestClient.py
@@ -15,201 +15,433 @@
# specific language governing permissions and limitations
# under the License.
-import cloudstackConnection
-import asyncJobMgr
-import dbConnection
-from cloudstackAPI import *
-import random
-import string
-import hashlib
-from configGenerator import ConfigManager
-from marvin.integration.lib.utils import random_gen
-
-'''
-@Desc : CloudStackTestClient is encapsulated class for getting various \
- clients viz., apiclient,dbconnection etc
-@Input : mgmtDetails : Management Server Details
- dbSvrDetails: Database Server details of Management \
+from marvin.cloudstackConnection import CSConnection
+from marvin.asyncJobMgr import asyncJobMgr
+from marvin.dbConnection import DbConnection
+from marvin.cloudstackAPI import *
+from marvin.codes import (FAILED, PASS, ADMIN, DOMAIN_ADMIN,
+ USER, SUCCESS, XEN_SERVER)
+from marvin.configGenerator import ConfigManager
+from marvin.cloudstackException import GetDetailExceptionInfo
+from marvin.lib.utils import (random_gen, validateList)
+from marvin.cloudstackAPI.cloudstackAPIClient import CloudStackAPIClient
+
+
+class CSTestClient(object):
+
+ '''
+ @Desc : CloudStackTestClient is encapsulated entity for creating and
+ getting various clients viz., apiclient,
+ user api client, dbconnection, test Data parsed
+ information etc
+ @Input :
+ mgmt_details : Management Server Details
+ dbsvr_details: Database Server details of Management \
Server. Retrieved from configuration file.
- asyncTimeout :
- defaultWorkerThreads :
- logger : provides logging facilities for this library
-'''
-
-
-class cloudstackTestClient(object):
- def __init__(self, mgmtDetails,
- dbSvrDetails, asyncTimeout=3600,
- defaultWorkerThreads=10,
- logger=None):
- self.mgmtDetails = mgmtDetails
- self.connection = \
- cloudstackConnection.cloudConnection(self.mgmtDetails,
- asyncTimeout,
- logger)
- self.apiClient =\
- cloudstackAPIClient.CloudStackAPIClient(self.connection)
- self.dbConnection = None
- if dbSvrDetails is not None:
- self.createDbConnection(dbSvrDetails.dbSvr, dbSvrDetails.port,
- dbSvrDetails.user,
- dbSvrDetails.passwd, dbSvrDetails.db)
- '''
- Provides the Configuration Object to users through getConfigParser
- The purpose of this object is to parse the config
- and provide dictionary of the config so users can
- use that configuration.Users can later call getConfig
- on this object and it will return the default parsed
- config dictionary from default configuration file,
- they can overwrite it with providing their own
- configuration file as well.
- '''
- self.configObj = ConfigManager()
- self.asyncJobMgr = None
- self.id = None
- self.defaultWorkerThreads = defaultWorkerThreads
+ async_timeout : Timeout for Async queries
+ default_worker_threads : Number of worker threads
+ logger : provides logging facilities for this library
+ zone : The zone on which test suites using this test client will run
+ '''
+
+ def __init__(self, mgmt_details,
+ dbsvr_details,
+ async_timeout=3600,
+ logger=None,
+ test_data_filepath=None,
+ zone=None,
+ hypervisor_type=None):
+ self.__mgmtDetails = mgmt_details
+ self.__dbSvrDetails = dbsvr_details
+ self.__csConnection = None
+ self.__dbConnection = None
+ self.__testClient = None
+ self.__asyncTimeOut = async_timeout
+ self.__logger = logger
+ self.__apiClient = None
+ self.__userApiClient = None
+ self.__asyncJobMgr = None
+ self.__id = None
+ self.__hypervisor = hypervisor_type
+ self.__testDataFilePath = test_data_filepath
+ self.__parsedTestDataConfig = None
+ self.__zone = zone
+ self.__setHypervisorInfo()
@property
def identifier(self):
- return self.id
+ return self.__id
@identifier.setter
def identifier(self, id):
- self.id = id
+ self.__id = id
+
+ def getParsedTestDataConfig(self):
+ '''
+ @Name : getParsedTestDataConfig
+ @Desc : Provides the TestData Config needed for
+ Tests are to Run
+ @Output : Returns the Parsed Test Data Dictionary
+ '''
+ return self.__parsedTestDataConfig
+
+ def getZoneForTests(self):
+ '''
+ @Name : getZoneForTests
+ @Desc : Provides the Zone against which Tests are to run
+ If zone name provided to marvin plugin is none
+ it will get it from Test Data Config File
+ Even, if it is not available, return None
+ @Output : Returns the Zone Name
+ '''
+ return self.__zone
+
+ def getHypervisorInfo(self):
+ '''
+ @Name : getHypervisorInfo
+ @Desc : Provides the hypervisor Information to test users
+ @Output : Return Hypervisor Information
+ '''
+ return self.__hypervisor
+
+ def __setHypervisorInfo(self):
+ '''
+ @Name : __setHypervisorInfo
+ @Desc: Set the HyperVisor details;
+ default to XenServer
+ '''
+ try:
+ if not self.__hypervisor:
+ self.__hypervisor = XEN_SERVER
+ return SUCCESS
+ except Exception as e:
+ print "\n Exception Occurred Under __setHypervisorInfo " \
+ "%s" % GetDetailExceptionInfo(e)
+ return FAILED
+
+ def __createApiClient(self):
+ try:
+ '''
+ Step1 : Create a CS Connection Object
+ '''
+ self.__csConnection = CSConnection(self.__mgmtDetails,
+ self.__asyncTimeOut,
+ self.__logger)
- def createDbConnection(self, host="localhost", port=3306, user='cloud',
- passwd='cloud', db='cloud'):
- self.dbConnection = dbConnection.dbConnection(host, port, user,
- passwd, db)
+ '''
+ Step2 : Create API Client with earlier created connection object
+ '''
+ self.__apiClient = CloudStackAPIClient(self.__csConnection)
+
+ '''
+ Step3: If API Key is not provided as part of Management Details,
+ then verify and register
+ '''
+ if self.__mgmtDetails.apiKey is None:
+ list_user = listUsers.listUsersCmd()
+ list_user.account = "admin"
+ list_user_res = self.__apiClient.listUsers(list_user)
+ if list_user_res is None or\
+ (validateList(list_user_res)[0] != PASS):
+ self.__logger.error("__createApiClient: API "
+ "Client Creation Failed")
+ return FAILED
+ user_id = list_user_res[0].id
+ api_key = list_user_res[0].apikey
+ security_key = list_user_res[0].secretkey
+ if api_key is None:
+ ret = self.__getKeys(user_id)
+ if ret != FAILED:
+ self.__mgmtDetails.port = 8080
+ self.__mgmtDetails.apiKey = ret[0]
+ self.__mgmtDetails.securityKey = ret[1]
+ else:
+ self.__logger.error("__createApiClient: API Client "
+ "Creation Failed while "
+ "Registering User")
+ return FAILED
+ else:
+ self.__mgmtDetails.port = 8080
+ self.__mgmtDetails.apiKey = api_key
+ self.__mgmtDetails.securityKey = security_key
+ '''
+ Now Create the Connection objects and Api Client using
+ new details
+ '''
+ self.__csConnection = CSConnection(self.__mgmtDetails,
+ self.__asyncTimeOut,
+ self.__logger)
+ self.__apiClient = CloudStackAPIClient(self.__csConnection)
+ return SUCCESS
+ except Exception as e:
+ self.__logger.exception(" Exception Occurred Under "
+ "__createApiClient: %s" %
+ GetDetailExceptionInfo(e))
+ return FAILED
+
+ def __createDbConnection(self):
+ '''
+ @Name : ___createDbConnection
+ @Desc : Creates the CloudStack DB Connection
+ '''
+ host = "localhost" if self.__dbSvrDetails.dbSvr is None \
+ else self.__dbSvrDetails.dbSvr
+ port = 3306 if self.__dbSvrDetails.port is None \
+ else self.__dbSvrDetails.port
+ user = "cloud" if self.__dbSvrDetails.user is None \
+ else self.__dbSvrDetails.user
+ passwd = 'cloud' if self.__dbSvrDetails.passd is None \
+ else self.__dbSvrDetails.passd
+ db = 'cloud' if self.__dbSvrDetails.db is None \
+ else self.__dbSvrDetails.db
+ self.__dbConnection = DbConnection(host, port, user, passwd, db)
+
+ def __getKeys(self, userid):
+ '''
+ @Name : ___getKeys
+ @Desc : Retrieves the API and Secret Key for the provided Userid
+ @Input: userid: Userid to register
+ @Output: FAILED or tuple with apikey and secretkey
+ '''
+ try:
+ register_user = registerUserKeys.registerUserKeysCmd()
+ register_user.id = userid
+ register_user_res = \
+ self.__apiClient.registerUserKeys(register_user)
+ if not register_user_res:
+ return FAILED
+ return (register_user_res.apikey, register_user_res.secretkey)
+ except Exception as e:
+ self.__logger.exception("Exception Occurred Under __geKeys : "
+ "%s" % GetDetailExceptionInfo(e))
+ return FAILED
+
+ def createTestClient(self):
+ '''
+ @Name : createTestClient
+ @Desc : Creates the Test Client.
+ The test Client is used by test suites
+ Here we create ParsedTestData Config.
+ Creates a DB Connection.
+ Creates an API Client
+ @Output : FAILED In case of an issue\Failure
+ SUCCESS in case of Success of this function
+ '''
+ try:
+ '''
+ 1. Create Config Object
+ Provides the Configuration Object to test suites through
+ getConfigParser. The purpose of this config object is to
+ parse the default config and provide dictionary of the
+ config so users can use that configuration.
+ Users can later call getConfig on this object and it will
+ return the default parsed config dictionary from default
+ configuration file. They can overwrite it with
+ providing their own configuration file as well.
+ '''
+ '''
+ 1. Check Config,Zone,Hypervisor Information
+ '''
+ self.__configObj = ConfigManager(self.__testDataFilePath)
+
+ if not self.__configObj or not self.__hypervisor:
+ self.__logger.error("createTestClient : "
+ "Either Hypervisor is None or "
+ "Not able to create "
+ "ConfigManager Object")
+ return FAILED
+
+ self.__parsedTestDataConfig = self.__configObj.getConfig()
+ self.__logger.debug("Parsing Test data successful")
+
+ '''
+ 2. Create DB Connection
+ '''
+ self.__createDbConnection()
+ '''
+ 3. Creates API Client
+ '''
+ ret = self.__createApiClient()
+ if ret == FAILED:
+ self.__logger.\
+ error("==== Test Client Creation Failed ====")
+ else:
+ self.__logger.\
+ debug("==== Test Client Creation Successful ====")
+ return ret
+ except Exception as e:
+ self.__logger.exception("Exception Occurred "
+ "Under createTestClient "
+ ": %s" % GetDetailExceptionInfo(e))
+ return FAILED
def isAdminContext(self):
"""
- A user is a regular user if he fails to listDomains;
+ @Name : isAdminContext
+ @Desc:A user is a regular user if he fails to listDomains;
if he is a domain-admin, he can list only domains that are non-ROOT;
if he is an admin, he can list the ROOT domain successfully
"""
try:
listdom = listDomains.listDomainsCmd()
listdom.name = 'ROOT'
- listdomres = self.apiClient.listDomains(listdom)
- rootdom = listdomres[0].name
- if rootdom == 'ROOT':
- return 1 # admin
- else:
- return 2 # domain-admin
+ listdomres = self.__apiClient.listDomains(listdom)
+ if listdomres != FAILED:
+ rootdom = listdomres[0].name
+ if rootdom == 'ROOT':
+ return ADMIN
+ else:
+ return DOMAIN_ADMIN
+ return USER
except:
- return 0 # user
+ return USER
- def createUserApiClient(self, UserName, DomainName, acctType=0):
- if not self.isAdminContext():
- return self.apiClient
-
- listDomain = listDomains.listDomainsCmd()
- listDomain.listall = True
- listDomain.name = DomainName
- try:
- domains = self.apiClient.listDomains(listDomain)
- domId = domains[0].id
- except:
- cdomain = createDomain.createDomainCmd()
- cdomain.name = DomainName
- domain = self.apiClient.createDomain(cdomain)
- domId = domain.id
-
- cmd = listAccounts.listAccountsCmd()
- cmd.name = UserName
- cmd.domainid = domId
+ def __createUserApiClient(self, UserName, DomainName, acctType=0):
+ '''
+ @Name : ___createUserApiClient
+ @Desc : Creates a User API Client with given
+ UserName\DomainName Parameters
+ @Input: UserName: Username to be created in cloudstack
+ DomainName: Domain under which the above account be created
+ accType: Type of Account EX: Root,Non Root etc
+ @Output: Return the API client for the user
+ '''
try:
- accounts = self.apiClient.listAccounts(cmd)
- acctId = accounts[0].id
- except:
- createAcctCmd = createAccount.createAccountCmd()
- createAcctCmd.accounttype = acctType
- createAcctCmd.domainid = domId
- createAcctCmd.email = "test-" + random_gen()\
- + "@cloudstack.org"
- createAcctCmd.firstname = UserName
- createAcctCmd.lastname = UserName
- createAcctCmd.password = 'password'
- createAcctCmd.username = UserName
- acct = self.apiClient.createAccount(createAcctCmd)
- acctId = acct.id
-
- listuser = listUsers.listUsersCmd()
- listuser.username = UserName
-
- listuserRes = self.apiClient.listUsers(listuser)
- userId = listuserRes[0].id
- apiKey = listuserRes[0].apikey
- securityKey = listuserRes[0].secretkey
-
- if apiKey is None:
- registerUser = registerUserKeys.registerUserKeysCmd()
- registerUser.id = userId
- registerUserRes = self.apiClient.registerUserKeys(registerUser)
- apiKey = registerUserRes.apikey
- securityKey = registerUserRes.secretkey
-
- mgtDetails = self.mgmtDetails
- mgtDetails.apiKey = apiKey
- mgtDetails.securityKey = securityKey
-
- newUserConnection =\
- cloudstackConnection.cloudConnection(mgtDetails,
- self.connection.asyncTimeout,
- self.connection.logger)
- self.userApiClient =\
- cloudstackAPIClient.CloudStackAPIClient(newUserConnection)
- self.userApiClient.connection = newUserConnection
- self.userApiClient.hypervisor = self.apiClient.hypervisor
- return self.userApiClient
+ if not self.isAdminContext():
+ return self.__apiClient
+
+ listDomain = listDomains.listDomainsCmd()
+ listDomain.listall = True
+ listDomain.name = DomainName
+ try:
+ domains = self.__apiClient.listDomains(listDomain)
+ domId = domains[0].id
+ except:
+ cdomain = createDomain.createDomainCmd()
+ cdomain.name = DomainName
+ domain = self.__apiClient.createDomain(cdomain)
+ domId = domain.id
+
+ cmd = listAccounts.listAccountsCmd()
+ cmd.name = UserName
+ cmd.domainid = domId
+ try:
+ accounts = self.__apiClient.listAccounts(cmd)
+ acctId = accounts[0].id
+ except:
+ createAcctCmd = createAccount.createAccountCmd()
+ createAcctCmd.accounttype = acctType
+ createAcctCmd.domainid = domId
+ createAcctCmd.email = "test-" + random_gen()\
+ + "@cloudstack.org"
+ createAcctCmd.firstname = UserName
+ createAcctCmd.lastname = UserName
+ createAcctCmd.password = 'password'
+ createAcctCmd.username = UserName
+ acct = self.__apiClient.createAccount(createAcctCmd)
+ acctId = acct.id
+
+ listuser = listUsers.listUsersCmd()
+ listuser.username = UserName
+
+ listuserRes = self.__apiClient.listUsers(listuser)
+ userId = listuserRes[0].id
+ apiKey = listuserRes[0].apikey
+ securityKey = listuserRes[0].secretkey
+
+ if apiKey is None:
+ ret = self.__getKeys(userId)
+ if ret != FAILED:
+ mgtDetails = self.__mgmtDetails
+ mgtDetails.apiKey = ret[0]
+ mgtDetails.securityKey = ret[1]
+ else:
+ self.__logger.error("__createUserApiClient: "
+ "User API Client Creation."
+ " While Registering User Failed")
+ return FAILED
+ else:
+ mgtDetails = self.__mgmtDetails
+ mgtDetails.apiKey = apiKey
+ mgtDetails.securityKey = securityKey
+
+ newUserConnection =\
+ CSConnection(mgtDetails,
+ self.__csConnection.asyncTimeout,
+ self.__csConnection.logger)
+ self.__userApiClient = CloudStackAPIClient(newUserConnection)
+ self.__userApiClient.connection = newUserConnection
+ self.__userApiClient.hypervisor = self.__hypervisor
+ return self.__userApiClient
+ except Exception as e:
+ self.__logger.exception("Exception Occurred "
+ "Under getUserApiClient : %s" %
+ GetDetailExceptionInfo(e))
+ return FAILED
def close(self):
- if self.connection is not None:
- self.connection.close()
+ if self.__csConnection is not None:
+ self.__csConnection.close()
def getDbConnection(self):
- return self.dbConnection
+ '''
+ @Name : getDbConnection
+ @Desc : Retrieves the DB Connection Handle
+ '''
+ return self.__dbConnection
def getConfigParser(self):
- return self.configObj
+ '''
+ @Name : getConfigParser
+ @Desc : Provides the ConfigManager Interface to TestClients
+ '''
+ return self.__configObj
def getApiClient(self):
- self.apiClient.id = self.identifier
- return self.apiClient
+ if self.__apiClient:
+ self.__apiClient.id = self.identifier
+ return self.__apiClient
+ return None
- def getUserApiClient(self, account, domain, type=0):
+ def getUserApiClient(self, UserName=None, DomainName=None, type=0):
"""
- 0 - user
- 1 - admin
- 2 - domain admin
+ @Name : getUserApiClient
+ @Desc : Provides the User API Client to test Users
+ 0 - user ; 1 - admin;2 - domain admin
+ @OutPut : FAILED In case of an issue
+ else User API Client
"""
- self.createUserApiClient(account, domain, type)
- if hasattr(self, "userApiClient"):
- return self.userApiClient
- return None
+ if UserName is None or DomainName is None:
+ return FAILED
+ return self.__createUserApiClient(UserName, DomainName, type)
def submitCmdsAndWait(self, cmds, workers=1):
- '''FixME, httplib has issue if more than one thread submitted'''
- if self.asyncJobMgr is None:
- self.asyncJobMgr = asyncJobMgr.asyncJobMgr(self.apiClient,
- self.dbConnection)
- return self.asyncJobMgr.submitCmdsAndWait(cmds, workers)
+ '''
+ @Desc : FixME, httplib has issue if more than one thread submitted
+ '''
+ if self.__asyncJobMgr is None:
+ self.__asyncJobMgr = asyncJobMgr(self.__apiClient,
+ self.__dbConnection)
+ return self.__asyncJobMgr.submitCmdsAndWait(cmds, workers)
def submitJob(self, job, ntimes=1, nums_threads=10, interval=1):
'''
- submit one job and execute the same job ntimes, with nums_threads
- of threads
+ @Desc : submit one job and execute the same job
+ ntimes, with nums_threads of threads
'''
- if self.asyncJobMgr is None:
- self.asyncJobMgr = asyncJobMgr.asyncJobMgr(self.apiClient,
- self.dbConnection)
- self.asyncJobMgr.submitJobExecuteNtimes(job, ntimes, nums_threads,
- interval)
+ if self.__asyncJobMgr is None:
+ self.__asyncJobMgr = asyncJobMgr(self.__apiClient,
+ self.__dbConnection)
+ self.__asyncJobMgr.submitJobExecuteNtimes(job, ntimes,
+ nums_threads,
+ interval)
def submitJobs(self, jobs, nums_threads=10, interval=1):
- '''submit n jobs, execute them with nums_threads of threads'''
- if self.asyncJobMgr is None:
- self.asyncJobMgr = asyncJobMgr.asyncJobMgr(self.apiClient,
- self.dbConnection)
- self.asyncJobMgr.submitJobs(jobs, nums_threads, interval)
+ '''
+ @Desc :submit n jobs, execute them with nums_threads
+ of threads
+ '''
+ if self.__asyncJobMgr is None:
+ self.__asyncJobMgr = asyncJobMgr(self.__apiClient,
+ self.__dbConnection)
+ self.__asyncJobMgr.submitJobs(jobs, nums_threads, interval)
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/tools/marvin/marvin/codegenerator.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/codegenerator.py b/tools/marvin/marvin/codegenerator.py
index e0f056f..1e02ddf 100644
--- a/tools/marvin/marvin/codegenerator.py
+++ b/tools/marvin/marvin/codegenerator.py
@@ -25,6 +25,7 @@ import urllib2
class cmdParameterProperty(object):
+
def __init__(self):
self.name = None
self.required = False
@@ -34,6 +35,7 @@ class cmdParameterProperty(object):
class cloudStackCmd(object):
+
def __init__(self):
self.name = ""
self.desc = ""
@@ -42,7 +44,8 @@ class cloudStackCmd(object):
self.response = []
-class codeGenerator(object):
+class CodeGenerator(object):
+
"""
Apache CloudStack- marvin python classes can be generated from the json
returned by API discovery or from the xml spec of commands generated by
@@ -208,12 +211,12 @@ class codeGenerator(object):
body += self.space + '@property' + self.newline
body += self.space + 'def id(self):' + self.newline
- body += self.space*2 + 'return self._id' + self.newline
+ body += self.space * 2 + 'return self._id' + self.newline
body += self.newline
body += self.space + '@id.setter' + self.newline
body += self.space + 'def id(self, identifier):' + self.newline
- body += self.space*2 + 'self._id = identifier' + self.newline
+ body += self.space * 2 + 'self._id = identifier' + self.newline
body += self.newline
for cmdName in self.cmdsName:
@@ -340,7 +343,7 @@ class codeGenerator(object):
paramProperty.desc = response['description']
if 'type' in response:
if response['type'] in ['list', 'map', 'set']:
- #Here list becomes a subproperty
+ # Here list becomes a subproperty
if 'response' in response:
for innerResponse in response['response']:
subProperty =\
@@ -394,7 +397,7 @@ class codeGenerator(object):
csCmd.request.append(paramProperty)
for response in cmd['response']:
- #FIXME: ExtractImage related APIs return empty dicts in response
+ # FIXME: ExtractImage related APIs return empty dicts in response
if len(response) > 0:
paramProperty = self.constructResponseFromJSON(response)
csCmd.response.append(paramProperty)
@@ -454,7 +457,7 @@ if __name__ == "__main__":
print parser.print_help()
exit(1)
- cg = codeGenerator(folder)
+ cg = CodeGenerator(folder)
if options.spec is not None:
cg.generateCodeFromXML(apiSpecFile)
elif options.endpoint is not None:
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/tools/marvin/marvin/codes.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/codes.py b/tools/marvin/marvin/codes.py
index 92d6cf9..28e907c 100644
--- a/tools/marvin/marvin/codes.py
+++ b/tools/marvin/marvin/codes.py
@@ -47,13 +47,32 @@ YES = "yes"
FAILED = "FAILED"
UNKNOWN_ERROR = "Unknown Error"
EXCEPTION = "EXCEPTION"
+INVALID_RESPONSE = "Invalid Response"
+'''
+Async Job Related Codes
+'''
+JOB_INPROGRESS = 0
+JOB_SUCCEEDED = 1
+JOB_FAILED = 2
+JOB_CANCELLED = 3
+'''
+User Related Codes
+'''
BASIC_ZONE = "basic"
ISOLATED_NETWORK = "ISOLATED"
SHARED_NETWORK = "SHARED"
VPC_NETWORK = "VPC"
-ERROR_NO_HOST_FOR_MIGRATION = "Could not find suitable host for migration, please ensure setup has required no. of hosts"
+ERROR_NO_HOST_FOR_MIGRATION = \
+ "Could not find suitable host for migration, " \
+ "please ensure setup has required no. of hosts"
NAT_RULE = "nat rule"
STATIC_NAT_RULE = "static nat rule"
UNKNOWN = "UNKNOWN"
FAULT = "FAULT"
MASTER = "MASTER"
+ADMIN = 1
+DOMAIN_ADMIN = 2
+USER = 0
+XEN_SERVER = "XenServer"
+ADMIN_ACCOUNT='ADMIN_ACCOUNT'
+USER_ACCOUNT='USER_ACCOUNT'
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/tools/marvin/marvin/config/__init__.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/config/__init__.py b/tools/marvin/marvin/config/__init__.py
new file mode 100644
index 0000000..13a8339
--- /dev/null
+++ b/tools/marvin/marvin/config/__init__.py
@@ -0,0 +1,16 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/tools/marvin/marvin/config/config.cfg
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/config/config.cfg b/tools/marvin/marvin/config/config.cfg
index a278068..a4bbe9d 100644
--- a/tools/marvin/marvin/config/config.cfg
+++ b/tools/marvin/marvin/config/config.cfg
@@ -24,7 +24,7 @@
}
,
"project":
- {
+ {
"name": "Project",
"displaytext": "Test project"
},
@@ -35,6 +35,15 @@
"username": "test-account",
"password": "password"
},
+ "user": {
+ "email": "user@test.com",
+ "firstname": "User",
+ "lastname": "User",
+ "username": "User",
+ # Random characters are appended for unique
+ # username
+ "password": "fr3sca",
+ },
"service_offering": {
"name": "Tiny Instance",
"displaytext": "Tiny Instance",
@@ -74,6 +83,18 @@
"publicport": 22,
"protocol": "TCP"
},
+ "template": {
+ "displaytext": "Public Template",
+ "name": "Public template",
+ "ostype": 'CentOS 5.3 (64-bit)',
+ "url": "",
+ "hypervisor": '',
+ "format": '',
+ "isfeatured": True,
+ "ispublic": True,
+ "isextractable": True,
+ "templatefilter": "self"
+ },
"shared_network": {
"name": "Test Shared Network",
"displaytext": "Test Shared Network",
@@ -126,17 +147,28 @@
"name": "SharedNwOffering",
"displaytext": "SharedNwOffering",
"guestiptype": "Shared",
- "supportedservices": "Dhcp,Dns,UserData",
+ "supportedservices": "Dhcp,Dns,SourceNat,PortForwarding,Vpn,Firewall,Lb,UserData,StaticNat",
"specifyVlan" : "False",
"specifyIpRanges" : "False",
"traffictype": "GUEST",
"serviceProviderList" : {
"Dhcp": "VirtualRouter",
"Dns": "VirtualRouter",
- "UserData": "VirtualRouter"
+ "SourceNat": "VirtualRouter",
+ "PortForwarding": "VirtualRouter",
+ "Vpn": "VirtualRouter",
+ "Firewall": "VirtualRouter",
+ "Lb": "VirtualRouter",
+ "UserData": "VirtualRouter",
+ "StaticNat": "VirtualRouter"
}
},
"security_group" : { "name": "custom_Sec_Grp" },
+ "natrule": {
+ "publicport": 22,
+ "privateport": 22,
+ "protocol": 'TCP',
+ },
"ingress_rule": {
"protocol": "TCP",
"startport": "22",
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/tools/marvin/marvin/config/test_data.cfg
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/config/test_data.cfg b/tools/marvin/marvin/config/test_data.cfg
new file mode 100644
index 0000000..5a3d8aa
--- /dev/null
+++ b/tools/marvin/marvin/config/test_data.cfg
@@ -0,0 +1,427 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+{
+ "region": {
+ "regionid": "2",
+ "regionname": "Region2",
+ "regionendpoint": "http://region2:8080/client"
+ },
+ "zone": "NA",
+
+ "domain": { "name": "domain" },
+
+ "project": {
+ "name": "Project",
+ "displaytext": "Test project"
+ },
+ "account": {
+ "email": "test-account@test.com",
+ "firstname": "test",
+ "lastname": "test",
+ "username": "test-account",
+ "password": "password"
+ },
+ "small": {
+ "displayname": "testserver",
+ "username": "root",
+ "password": "password",
+ "ssh_port": 22,
+ "hypervisor": "XenServer",
+ "privateport": 22,
+ "publicport": 22,
+ "protocol": 'TCP',
+ },
+ "medium": {
+ "displayname": "testserver",
+ "username": "root",
+ "password": "password",
+ "ssh_port": 22,
+ "hypervisor": 'XenServer',
+ "privateport": 22,
+ "publicport": 22,
+ "protocol": 'TCP',
+ },
+ "service_offerings": {
+ "name": "Tiny Instance",
+ "displaytext": "Tiny Instance",
+ "cpunumber": 1,
+ "cpuspeed": 100,
+ "memory": 128,
+
+ "tiny": {
+ "name": "Tiny Instance",
+ "displaytext": "Tiny Instance",
+ "cpunumber": 1,
+ "cpuspeed": 100,
+ "memory": 128,
+ },
+ "small": {
+ "name": "Small Instance",
+ "displaytext": "Small Instance",
+ "cpunumber": 1,
+ "cpuspeed": 100,
+ "memory": 256
+ },
+ "medium": {
+ "name": "Medium Instance",
+ "displaytext": "Medium Instance",
+ "cpunumber": 1,
+ "cpuspeed": 100,
+ "memory": 256,
+ },
+ "big": {
+ "name": "BigInstance",
+ "displaytext": "BigInstance",
+ "cpunumber": 1,
+ "cpuspeed": 100,
+ "memory": 512,
+ }
+ },
+ "disk_offering": {
+ "name": "Disk offering",
+ "displaytext": "Disk offering",
+ "disksize": 1
+ },
+ 'resized_disk_offering': {
+ "displaytext": "Resized",
+ "name": "Resized",
+ "disksize": 3
+ },
+ "network": {
+ "name": "Test Network",
+ "displaytext": "Test Network",
+ "acltype": "Account",
+ },
+ "network2": {
+ "name": "Test Network Shared",
+ "displaytext": "Test Network Shared",
+ "vlan" :1201,
+ "gateway" :"172.16.15.1",
+ "netmask" :"255.255.255.0",
+ "startip" :"172.16.15.21",
+ "endip" :"172.16.15.41",
+ "acltype": "Account",
+ },
+ "network_offering": {
+ "name": 'Test Network offering',
+ "displaytext": 'Test Network offering',
+ "guestiptype": 'Isolated',
+ "supportedservices": 'Dhcp,Dns,SourceNat,PortForwarding',
+ "traffictype": 'GUEST',
+ "availability": 'Optional',
+ "serviceProviderList" : {
+ "Dhcp": 'VirtualRouter',
+ "Dns": 'VirtualRouter',
+ "SourceNat": 'VirtualRouter',
+ "PortForwarding": 'VirtualRouter',
+ },
+ },
+ "isolated_network_offering": {
+ "name": "Network offering-DA services",
+ "displaytext": "Network offering-DA services",
+ "guestiptype": "Isolated",
+ "supportedservices": "Dhcp,Dns,SourceNat,PortForwarding,Vpn,Firewall,Lb,UserData,StaticNat",
+ "traffictype": "GUEST",
+ "availability": "Optional'",
+ "serviceProviderList": {
+ "Dhcp": "VirtualRouter",
+ "Dns": "VirtualRouter",
+ "SourceNat": "VirtualRouter",
+ "PortForwarding": "VirtualRouter",
+ "Vpn": "VirtualRouter",
+ "Firewall": "VirtualRouter",
+ "Lb": "VirtualRouter",
+ "UserData": "VirtualRouter",
+ "StaticNat": "VirtualRouter"
+ }
+ },
+ "isolated_network": {
+ "name": "Isolated Network",
+ "displaytext": "Isolated Network"
+ },
+ "virtual_machine": {
+ "displayname": "Test VM",
+ "username": "root",
+ "password": "password",
+ "ssh_port": 22,
+ "privateport": 22,
+ "publicport": 22,
+ "protocol": "TCP",
+ "affinity": {
+ "name": "webvms",
+ "type": "host anti-affinity",
+ },
+ },
+ "server_without_disk": {
+ "displayname": "Test VM-No Disk",
+ "username": "root",
+ "password": "password",
+ "ssh_port": 22,
+ "hypervisor": 'XenServer',
+ "privateport": 22,
+ "publicport": 22,
+ "protocol": 'TCP',
+ },
+ "shared_network": {
+ "name": "MySharedNetwork - Test",
+ "displaytext": "MySharedNetwork",
+ "vlan" : "",
+ "gateway" :"",
+ "netmask" :"",
+ "startip" :"",
+ "endip" :"",
+ "acltype" : "Domain",
+ "scope":"all"
+ },
+ "shared_network_offering_sg": {
+ "name": "MySharedOffering-sg",
+ "displaytext": "MySharedOffering-sg",
+ "guestiptype": "Shared",
+ "supportedservices": "Dhcp,Dns,UserData,SecurityGroup",
+ "specifyVlan" : "False",
+ "specifyIpRanges" : "False",
+ "traffictype": "GUEST",
+ "serviceProviderList" : {
+ "Dhcp": "VirtualRouter",
+ "Dns": "VirtualRouter",
+ "UserData": "VirtualRouter",
+ "SecurityGroup": "SecurityGroupProvider"
+ }
+ },
+ "shared_network_sg": {
+ "name": "Shared-Network-SG-Test",
+ "displaytext": "Shared-Network_SG-Test",
+ "networkofferingid":"1",
+ "vlan" : "",
+ "gateway" :"",
+ "netmask" :"255.255.255.0",
+ "startip" :"",
+ "endip" :"",
+ "acltype" : "Domain",
+ "scope":"all"
+ },
+ "vpc_offering": {
+ "name": "VPC off",
+ "displaytext": "VPC off",
+ "supportedservices": "Dhcp,Dns,SourceNat,PortForwarding,Vpn,Lb,UserData,StaticNat,NetworkACL"
+ },
+ "vpc": {
+ "name": "TestVPC",
+ "displaytext": "TestVPC",
+ "cidr": "10.0.0.1/24"
+ },
+ "clusters": {
+ 0: {
+ "clustername": "Xen Cluster",
+ "clustertype": "CloudManaged",
+ "hypervisor": "XenServer",
+ },
+ 1: {
+ "clustername": "KVM Cluster",
+ "clustertype": "CloudManaged",
+ "hypervisor": "KVM",
+ },
+ 2: {
+ "hypervisor": 'VMware',
+ "clustertype": 'ExternalManaged',
+ "username": 'administrator',
+ "password": 'fr3sca',
+ "url": 'http://192.168.100.17/CloudStack-Clogeny-Pune/Pune-1',
+ "clustername": 'VMWare Cluster',
+ },
+ },
+ "hosts": {
+ "xenserver": {
+ "hypervisor": 'XenServer',
+ "clustertype": 'CloudManaged',
+ "url": 'http://192.168.100.211',
+ "username": "root",
+ "password": "fr3sca",
+ },
+ "kvm": {
+ "hypervisor": 'KVM',
+ "clustertype": 'CloudManaged',
+ "url": 'http://192.168.100.212',
+ "username": "root",
+ "password": "fr3sca",
+ },
+ "vmware": {
+ "hypervisor": 'VMware',
+ "clustertype": 'ExternalManaged',
+ "url": 'http://192.168.100.203',
+ "username": "administrator",
+ "password": "fr3sca",
+ },
+ },
+ "network_offering_shared": {
+ "name": 'Test Network offering shared',
+ "displaytext": 'Test Network offering Shared',
+ "guestiptype": 'Shared',
+ "supportedservices": 'Dhcp,Dns,UserData',
+ "traffictype": 'GUEST',
+ "specifyVlan" : "True",
+ "specifyIpRanges" : "True",
+ "serviceProviderList" : {
+ "Dhcp": 'VirtualRouter',
+ "Dns": 'VirtualRouter',
+ "UserData": 'VirtualRouter',
+ },
+ },
+ "network_offering_internal_lb": {
+ "name": "Network offering for internal lb service",
+ "displaytext": "Network offering for internal lb service",
+ "guestiptype": "Isolated",
+ "traffictype": "Guest",
+ "supportedservices": "Vpn,Dhcp,Dns,Lb,UserData,SourceNat,StaticNat,PortForwarding,NetworkACL",
+ "serviceProviderList": {
+ "Dhcp": "VpcVirtualRouter",
+ "Dns": "VpcVirtualRouter",
+ "Vpn": "VpcVirtualRouter",
+ "UserData": "VpcVirtualRouter",
+ "Lb": "InternalLbVM",
+ "SourceNat": "VpcVirtualRouter",
+ "StaticNat": "VpcVirtualRouter",
+ "PortForwarding": "VpcVirtualRouter",
+ "NetworkACL": "VpcVirtualRouter",
+ },
+ "serviceCapabilityList": {
+ "SourceNat": {"SupportedSourceNatTypes": "peraccount"},
+ "Lb": {"lbSchemes": "internal", "SupportedLbIsolation": "dedicated"}
+ }
+ },
+
+ "natrule": {
+ "privateport": 22,
+ "publicport": 2222,
+ "protocol": "TCP"
+ },
+ "lbrule": {
+ "name": "SSH",
+ "alg": "roundrobin",
+ "privateport": 22,
+ "publicport": 2222,
+ "protocol": 'TCP'
+ },
+
+ "iso1": {
+ "displaytext": "Test ISO 1",
+ "name": "ISO 1",
+ "url": "http://people.apache.org/~tsp/dummy.iso",
+ "isextractable": True,
+ "isfeatured": True,
+ "ispublic": True,
+ "ostype": "CentOS 5.3 (64-bit)",
+ },
+ "iso2": {
+ "displaytext": "Test ISO 2",
+ "name": "ISO 2",
+ "url": "http://people.apache.org/~tsp/dummy.iso",
+ "isextractable": True,
+ "isfeatured": True,
+ "ispublic": True,
+ "ostype": "CentOS 5.3 (64-bit)",
+ "mode": 'HTTP_DOWNLOAD',
+ },
+ "isfeatured": True,
+ "ispublic": True,
+ "isextractable": True,
+ "bootable": True,
+ "passwordenabled": True,
+
+ "template": {
+ "displaytext": "xs",
+ "name": "xs",
+ "passwordenabled": False,
+ },
+ "template_2": {
+ "displaytext": "Public Template",
+ "name": "Public template",
+ "ostype": "CentOS 5.3 (64-bit)",
+ "isfeatured": True,
+ "ispublic": True,
+ "isextractable": True,
+ "mode": "HTTP_DOWNLOAD",
+ },
+ "templatefilter": 'self',
+
+ "security_group" : { "name": "custom_Sec_Grp" },
+ "ingress_rule": {
+ "protocol": "TCP",
+ "startport": "22",
+ "endport": "22",
+ "cidrlist": "0.0.0.0/0"
+ },
+ "ostype": "CentOS 5.3 (64-bit)",
+ "sleep": 90,
+ "timeout": 10,
+ "advanced_sg": {
+ "zone": {
+ "name": "",
+ "dns1": "8.8.8.8",
+ "internaldns1": "192.168.100.1",
+ "networktype": "Advanced",
+ "securitygroupenabled": "true"
+ },
+ "securitygroupenabled": "true"
+ },
+ "vlan": {
+ "part": ["4090-4091", "4092-4095"],
+ "full": "4090-4095",
+ },
+ "nfs": {
+ "url": "nfs://10.147.28.7/export/home/talluri/testprimary",
+ "name": "Primary XEN"
+ },
+ "iscsi": {
+ "url": "iscsi://192.168.100.21/iqn.2012-01.localdomain.clo-cstack-cos6:iser/1",
+ "name": "Primary iSCSI"
+ },
+ "volume": {"diskname": "Test Volume"},
+ "volume_offerings": {
+ 0: {"diskname": "TestDiskServ"},
+ },
+ "diskdevice": ['/dev/vdc', '/dev/vdb', '/dev/hdb', '/dev/hdc', '/dev/xvdd', '/dev/cdrom', '/dev/sr0', '/dev/cdrom1' ],
+
+ #test_vpc_vpn.py
+ "vpn_user": {
+ "username": "test",
+ "password": "password",
+ },
+ "vpc": {
+ "name": "vpc_vpn",
+ "displaytext": "vpc-vpn",
+ "cidr": "10.1.1.0/24"
+ },
+ "ntwk": {
+ "name": "tier1",
+ "displaytext": "vpc-tier1",
+ "gateway" : "10.1.1.1",
+ "netmask" : "255.255.255.192"
+ },
+ "vpc2": {
+ "name": "vpc2_vpn",
+ "displaytext": "vpc2-vpn",
+ "cidr": "10.2.1.0/24"
+ },
+ "ntwk2": {
+ "name": "tier2",
+ "displaytext": "vpc-tier2",
+ "gateway" : "10.2.1.1",
+ "netmask" : "255.255.255.192"
+ }
+}
[03/18] Marvin + test changes from master Signed-off-by:
SrikanteswaraRao Talluri
Posted by da...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/tools/marvin/marvin/lib/base.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/lib/base.py b/tools/marvin/marvin/lib/base.py
new file mode 100644
index 0000000..ca7fdc6
--- /dev/null
+++ b/tools/marvin/marvin/lib/base.py
@@ -0,0 +1,4086 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+""" Base class for all Cloudstack resources
+ -Virtual machine, Volume, Snapshot etc
+"""
+
+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
+import base64
+
+
+class Domain:
+ """ Domain Life Cycle """
+ def __init__(self, items):
+ self.__dict__.update(items)
+
+ @classmethod
+ def create(cls, apiclient, services, name=None, networkdomain=None,
+ parentdomainid=None):
+ """Creates an domain"""
+
+ cmd = createDomain.createDomainCmd()
+
+ if "domainUUID" in services:
+ cmd.domainid = "-".join([services["domainUUID"], random_gen()])
+
+ if name:
+ cmd.name = "-".join([name, random_gen()])
+ elif "name" in services:
+ cmd.name = "-".join([services["name"], random_gen()])
+
+ if networkdomain:
+ cmd.networkdomain = networkdomain
+ elif "networkdomain" in services:
+ cmd.networkdomain = services["networkdomain"]
+
+ if parentdomainid:
+ cmd.parentdomainid = parentdomainid
+ elif "parentdomainid" in services:
+ cmd.parentdomainid = services["parentdomainid"]
+ try:
+ domain = apiclient.createDomain(cmd)
+ if domain is not None:
+ return Domain(domain.__dict__)
+ except Exception as e:
+ raise e
+
+ def delete(self, apiclient, cleanup=None):
+ """Delete an domain"""
+ cmd = deleteDomain.deleteDomainCmd()
+ cmd.id = self.id
+ if cleanup:
+ cmd.cleanup = cleanup
+ apiclient.deleteDomain(cmd)
+
+ @classmethod
+ def list(cls, apiclient, **kwargs):
+ """Lists domains"""
+ cmd = listDomains.listDomainsCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listDomains(cmd))
+
+
+class Account:
+ """ Account Life Cycle """
+ def __init__(self, items):
+ self.__dict__.update(items)
+
+ @classmethod
+ def create(cls, apiclient, services, admin=False, domainid=None):
+ """Creates an account"""
+ cmd = createAccount.createAccountCmd()
+
+ # 0 - User, 1 - Root Admin, 2 - Domain Admin
+ cmd.accounttype = 2 if (admin and domainid) else int(admin)
+
+ cmd.email = services["email"]
+ cmd.firstname = services["firstname"]
+ cmd.lastname = services["lastname"]
+
+ cmd.password = services["password"]
+
+ username = "-".join([services["username"], random_gen(id=apiclient.id)])
+ # Trim username to 99 characters to prevent failure
+ cmd.username = username[:99] if len(username) > 99 else username
+
+ if "accountUUID" in services:
+ cmd.accountid = "-".join([services["accountUUID"],random_gen()])
+
+ if "userUUID" in services:
+ cmd.userid = "-".join([services["userUUID"],random_gen()])
+
+
+ if domainid:
+ cmd.domainid = domainid
+ account = apiclient.createAccount(cmd)
+
+ return Account(account.__dict__)
+
+ def delete(self, apiclient):
+ """Delete an account"""
+ cmd = deleteAccount.deleteAccountCmd()
+ cmd.id = self.id
+ apiclient.deleteAccount(cmd)
+
+ @classmethod
+ def list(cls, apiclient, **kwargs):
+ """Lists accounts and provides detailed account information for
+ listed accounts"""
+
+ cmd = listAccounts.listAccountsCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listAccounts(cmd))
+
+ def disable(self, apiclient, lock=False):
+ """Disable an account"""
+ cmd = disableAccount.disableAccountCmd()
+ cmd.id = self.id
+ cmd.lock = lock
+ apiclient.disableAccount(cmd)
+
+
+class User:
+ """ User Life Cycle """
+ def __init__(self, items):
+ self.__dict__.update(items)
+
+ @classmethod
+ def create(cls, apiclient, services, account, domainid):
+ cmd = createUser.createUserCmd()
+ """Creates an user"""
+
+ cmd.account = account
+ cmd.domainid = domainid
+ cmd.email = services["email"]
+ cmd.firstname = services["firstname"]
+ cmd.lastname = services["lastname"]
+
+ if "userUUID" in services:
+ cmd.userid = "-".join([services["userUUID"],random_gen()])
+
+ cmd.password = services["password"]
+ cmd.username = "-".join([services["username"], random_gen()])
+ user = apiclient.createUser(cmd)
+
+ return User(user.__dict__)
+
+ def delete(self, apiclient):
+ """Delete an account"""
+ cmd = deleteUser.deleteUserCmd()
+ cmd.id = self.id
+ apiclient.deleteUser(cmd)
+
+ @classmethod
+ def list(cls, apiclient, **kwargs):
+ """Lists users and provides detailed account information for
+ listed users"""
+
+ cmd = listUsers.listUsersCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listUsers(cmd))
+
+ @classmethod
+ def registerUserKeys(cls, apiclient, userid):
+ cmd = registerUserKeys.registerUserKeysCmd()
+ cmd.id = userid
+ return apiclient.registerUserKeys(cmd)
+
+ def update(self, apiclient, **kwargs):
+ """Updates the user details"""
+
+ cmd = updateUser.updateUserCmd()
+ cmd.id = self.id
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return (apiclient.updateUser(cmd))
+
+ @classmethod
+ def update(cls, apiclient, id, **kwargs):
+ """Updates the user details (class method)"""
+
+ cmd = updateUser.updateUserCmd()
+ cmd.id = id
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return (apiclient.updateUser(cmd))
+
+ @classmethod
+ def login(cls, apiclient, username, password, domain=None, domainid=None):
+ """Logins to the CloudStack"""
+
+ cmd = login.loginCmd()
+ cmd.username = username
+ cmd.password = password
+ if domain:
+ cmd.domain = domain
+ if domainid:
+ cmd.domainId = domainid
+ return apiclient.login(cmd)
+
+
+class VirtualMachine:
+ """Manage virtual machine lifecycle"""
+
+ def __init__(self, items, services):
+ self.__dict__.update(items)
+ if "username" in services:
+ self.username = services["username"]
+ else:
+ self.username = 'root'
+ if "password" in services:
+ self.password = services["password"]
+ else:
+ self.password = 'password'
+ if "ssh_port" in services:
+ self.ssh_port = services["ssh_port"]
+ else:
+ self.ssh_port = 22
+ self.ssh_client = None
+ # extract out the ipaddress
+ self.ipaddress = self.nic[0].ipaddress
+
+ @classmethod
+ def ssh_access_group(cls, apiclient, cmd):
+ """
+ Programs the security group with SSH access before deploying virtualmachine
+ @return:
+ """
+ zone_list = Zone.list(
+ apiclient,
+ id=cmd.zoneid if cmd.zoneid else None,
+ domainid=cmd.domainid if cmd.domainid else None
+ )
+ zone = zone_list[0]
+ #check if security groups settings is enabled for the zone
+ if zone.securitygroupsenabled:
+ list_security_groups = SecurityGroup.list(
+ apiclient,
+ account=cmd.account,
+ domainid=cmd.domainid,
+ listall=True,
+ securitygroupname="basic_sec_grp"
+ )
+
+ if not isinstance(list_security_groups, list):
+ basic_mode_security_group = SecurityGroup.create(
+ apiclient,
+ {"name": "basic_sec_grp"},
+ cmd.account,
+ cmd.domainid,
+ )
+ sec_grp_services = {
+ "protocol": "TCP",
+ "startport": 22,
+ "endport": 22,
+ "cidrlist": "0.0.0.0/0"
+ }
+ #Authorize security group for above ingress rule
+ basic_mode_security_group.authorize(apiclient, sec_grp_services, account=cmd.account,
+ domainid=cmd.domainid)
+ else:
+ basic_mode_security_group = list_security_groups[0]
+
+ if isinstance(cmd.securitygroupids, list):
+ cmd.securitygroupids.append(basic_mode_security_group.id)
+ else:
+ cmd.securitygroupids = [basic_mode_security_group.id]
+
+ @classmethod
+ def access_ssh_over_nat(cls, apiclient, services, virtual_machine, allow_egress=False):
+ """
+ Program NAT and PF rules to open up ssh access to deployed guest
+ @return:
+ """
+ public_ip = PublicIPAddress.create(
+ apiclient=apiclient,
+ accountid=virtual_machine.account,
+ zoneid=virtual_machine.zoneid,
+ domainid=virtual_machine.domainid,
+ services=services
+ )
+ FireWallRule.create(
+ apiclient=apiclient,
+ ipaddressid=public_ip.ipaddress.id,
+ protocol='TCP',
+ cidrlist=['0.0.0.0/0'],
+ startport=22,
+ endport=22
+ )
+ nat_rule = NATRule.create(
+ apiclient=apiclient,
+ virtual_machine=virtual_machine,
+ services=services,
+ ipaddressid=public_ip.ipaddress.id
+ )
+ if allow_egress:
+ EgressFireWallRule.create(
+ apiclient=apiclient,
+ networkid=virtual_machine.nic[0].networkid,
+ protocol='All',
+ cidrlist='0.0.0.0/0'
+ )
+ virtual_machine.ssh_ip = nat_rule.ipaddress
+ virtual_machine.public_ip = nat_rule.ipaddress
+
+ @classmethod
+ def create(cls, apiclient, services, templateid=None, accountid=None,
+ domainid=None, zoneid=None, networkids=None, serviceofferingid=None,
+ securitygroupids=None, projectid=None, startvm=None,
+ diskofferingid=None, affinitygroupnames=None, affinitygroupids=None, group=None,
+ hostid=None, keypair=None, ipaddress=None, mode='default', method='GET',hypervisor=None,
+ customcpunumber=None, customcpuspeed=None, custommemory=None, rootdisksize=None):
+ """Create the instance"""
+
+ cmd = deployVirtualMachine.deployVirtualMachineCmd()
+
+ if serviceofferingid:
+ cmd.serviceofferingid = serviceofferingid
+ elif "serviceoffering" in services:
+ cmd.serviceofferingid = services["serviceoffering"]
+
+ if zoneid:
+ cmd.zoneid = zoneid
+ elif "zoneid" in services:
+ cmd.zoneid = services["zoneid"]
+ cmd.hypervisor = hypervisor
+
+ if "displayname" in services:
+ cmd.displayname = services["displayname"]
+
+ if "name" in services:
+ cmd.name = services["name"]
+
+ if accountid:
+ cmd.account = accountid
+ elif "account" in services:
+ cmd.account = services["account"]
+
+ if domainid:
+ cmd.domainid = domainid
+ elif "domainid" in services:
+ cmd.domainid = services["domainid"]
+
+ if networkids:
+ cmd.networkids = networkids
+ allow_egress = False
+ elif "networkids" in services:
+ cmd.networkids = services["networkids"]
+ allow_egress = False
+ else:
+ # When no networkids are passed, network
+ # is created using the "defaultOfferingWithSourceNAT"
+ # which has an egress policy of DENY. But guests in tests
+ # need access to test network connectivity
+ allow_egress = True
+
+ if templateid:
+ cmd.templateid = templateid
+ elif "template" in services:
+ cmd.templateid = services["template"]
+
+ if diskofferingid:
+ cmd.diskofferingid = diskofferingid
+ elif "diskoffering" in services:
+ cmd.diskofferingid = services["diskoffering"]
+
+ if keypair:
+ cmd.keypair = keypair
+ elif "keypair" in services:
+ cmd.keypair = services["keypair"]
+
+ if ipaddress:
+ cmd.ipaddress = ipaddress
+ elif ipaddress in services:
+ cmd.ipaddress = services["ipaddress"]
+
+ if securitygroupids:
+ cmd.securitygroupids = [str(sg_id) for sg_id in securitygroupids]
+
+ if "affinitygroupnames" in services:
+ cmd.affinitygroupnames = services["affinitygroupnames"]
+ elif affinitygroupnames:
+ cmd.affinitygroupnames = affinitygroupnames
+
+ if affinitygroupids:
+ cmd.affinitygroupids = affinitygroupids
+
+ if projectid:
+ cmd.projectid = projectid
+
+ if startvm is not None:
+ cmd.startvm = startvm
+
+ if hostid:
+ cmd.hostid = hostid
+
+ if "userdata" in services:
+ cmd.userdata = base64.urlsafe_b64encode(services["userdata"])
+
+ cmd.details = [{}]
+
+ if customcpunumber:
+ cmd.details[0]["cpuNumber"] = customcpunumber
+
+ if customcpuspeed:
+ cmd.details[0]["cpuSpeed"] = customcpuspeed
+
+ if custommemory:
+ cmd.details[0]["memory"] = custommemory
+
+ if rootdisksize >= 0:
+ cmd.details[0]["rootdisksize"] = rootdisksize
+
+ if group:
+ cmd.group = group
+
+ #program default access to ssh
+ if mode.lower() == 'basic':
+ cls.ssh_access_group(apiclient, cmd)
+
+ virtual_machine = apiclient.deployVirtualMachine(cmd, method=method)
+
+ virtual_machine.ssh_ip = virtual_machine.nic[0].ipaddress
+ if startvm == False:
+ virtual_machine.public_ip = virtual_machine.nic[0].ipaddress
+ return VirtualMachine(virtual_machine.__dict__, services)
+
+ #program ssh access over NAT via PF
+ if mode.lower() == 'advanced':
+ cls.access_ssh_over_nat(apiclient, services, virtual_machine, allow_egress=allow_egress)
+ elif mode.lower() == 'basic':
+ if virtual_machine.publicip is not None:
+ vm_ssh_ip = virtual_machine.publicip #EIP/ELB (netscaler) enabled zone
+ else:
+ vm_ssh_ip = virtual_machine.nic[0].ipaddress #regular basic zone with security group
+ virtual_machine.ssh_ip = vm_ssh_ip
+ virtual_machine.public_ip = vm_ssh_ip
+
+ return VirtualMachine(virtual_machine.__dict__, services)
+
+ def start(self, apiclient):
+ """Start the instance"""
+ cmd = startVirtualMachine.startVirtualMachineCmd()
+ cmd.id = self.id
+ apiclient.startVirtualMachine(cmd)
+
+ def stop(self, apiclient, forced=None):
+ """Stop the instance"""
+ cmd = stopVirtualMachine.stopVirtualMachineCmd()
+ cmd.id = self.id
+ if forced:
+ cmd.forced = forced
+ apiclient.stopVirtualMachine(cmd)
+
+ def reboot(self, apiclient):
+ """Reboot the instance"""
+ cmd = rebootVirtualMachine.rebootVirtualMachineCmd()
+ cmd.id = self.id
+ apiclient.rebootVirtualMachine(cmd)
+
+ def recover(self, apiclient):
+ """Recover the instance"""
+ cmd = recoverVirtualMachine.recoverVirtualMachineCmd()
+ cmd.id = self.id
+ apiclient.recoverVirtualMachine(cmd)
+
+ def restore(self, apiclient, templateid=None):
+ """Restore the instance"""
+ cmd = restoreVirtualMachine.restoreVirtualMachineCmd()
+ cmd.virtualmachineid = self.id
+ if templateid:
+ cmd.templateid = templateid
+ return apiclient.restoreVirtualMachine(cmd)
+
+ def get_ssh_client(self, ipaddress=None, reconnect=False, port=None, keyPairFileLocation=None):
+ """Get SSH object of VM"""
+
+ # If NAT Rules are not created while VM deployment in Advanced mode
+ # then, IP address must be passed
+ if ipaddress != None:
+ self.ssh_ip = ipaddress
+ if port:
+ self.ssh_port = port
+
+ if keyPairFileLocation is not None:
+ self.password = None
+
+ if reconnect:
+ self.ssh_client = is_server_ssh_ready(
+ self.ssh_ip,
+ self.ssh_port,
+ self.username,
+ self.password,
+ keyPairFileLocation=keyPairFileLocation
+ )
+ self.ssh_client = self.ssh_client or is_server_ssh_ready(
+ self.ssh_ip,
+ self.ssh_port,
+ self.username,
+ self.password,
+ keyPairFileLocation=keyPairFileLocation
+ )
+ return self.ssh_client
+
+ def resetSshKey(self, apiclient, **kwargs):
+ """Resets SSH key"""
+
+ cmd = resetSSHKeyForVirtualMachine.resetSSHKeyForVirtualMachineCmd()
+ cmd.id = self.id
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.resetSSHKeyForVirtualMachine(cmd))
+
+ def update(self, apiclient, **kwargs):
+ """Updates the VM data"""
+
+ cmd = updateVirtualMachine.updateVirtualMachineCmd()
+ cmd.id = self.id
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.updateVirtualMachine(cmd))
+
+ def delete(self, apiclient):
+ """Destroy an Instance"""
+ cmd = destroyVirtualMachine.destroyVirtualMachineCmd()
+ cmd.id = self.id
+ apiclient.destroyVirtualMachine(cmd)
+
+ def migrate(self, apiclient, hostid=None):
+ """migrate an Instance"""
+ cmd = migrateVirtualMachine.migrateVirtualMachineCmd()
+ cmd.virtualmachineid = self.id
+ if hostid:
+ cmd.hostid = hostid
+ apiclient.migrateVirtualMachine(cmd)
+
+ def attach_volume(self, apiclient, volume):
+ """Attach volume to instance"""
+ cmd = attachVolume.attachVolumeCmd()
+ cmd.id = volume.id
+ cmd.virtualmachineid = self.id
+ return apiclient.attachVolume(cmd)
+
+ def detach_volume(self, apiclient, volume):
+ """Detach volume to instance"""
+ cmd = detachVolume.detachVolumeCmd()
+ cmd.id = volume.id
+ return apiclient.detachVolume(cmd)
+
+ def add_nic(self, apiclient, networkId, ipaddress=None):
+ """Add a NIC to a VM"""
+ cmd = addNicToVirtualMachine.addNicToVirtualMachineCmd()
+ cmd.virtualmachineid = self.id
+ cmd.networkid = networkId
+
+ if ipaddress:
+ cmd.ipaddress = ipaddress
+
+ return apiclient.addNicToVirtualMachine(cmd)
+
+ def remove_nic(self, apiclient, nicId):
+ """Remove a NIC to a VM"""
+ cmd = removeNicFromVirtualMachine.removeNicFromVirtualMachineCmd()
+ cmd.nicid = nicId
+ cmd.virtualmachineid = self.id
+ return apiclient.removeNicFromVirtualMachine(cmd)
+
+ def update_default_nic(self, apiclient, nicId):
+ """Set a NIC to be the default network adapter for a VM"""
+ cmd = updateDefaultNicForVirtualMachine.updateDefaultNicForVirtualMachineCmd()
+ cmd.nicid = nicId
+ cmd.virtualmachineid = self.id
+ return apiclient.updateDefaultNicForVirtualMachine(cmd)
+
+ def attach_iso(self, apiclient, iso):
+ """Attach ISO to instance"""
+ cmd = attachIso.attachIsoCmd()
+ cmd.id = iso.id
+ cmd.virtualmachineid = self.id
+ return apiclient.attachIso(cmd)
+
+ def detach_iso(self, apiclient):
+ """Detach ISO to instance"""
+ cmd = detachIso.detachIsoCmd()
+ cmd.virtualmachineid = self.id
+ return apiclient.detachIso(cmd)
+
+ def scale_virtualmachine(self, apiclient, serviceOfferingId):
+ """ Scale up of service offering for the Instance"""
+ cmd = scaleVirtualMachine.scaleVirtualMachineCmd()
+ cmd.id = self.id
+ cmd.serviceofferingid = serviceOfferingId
+ return apiclient.scaleVirtualMachine(cmd)
+
+ def change_service_offering(self, apiclient, serviceOfferingId):
+ """Change service offering of the instance"""
+ cmd = changeServiceForVirtualMachine.changeServiceForVirtualMachineCmd()
+ cmd.id = self.id
+ cmd.serviceofferingid = serviceOfferingId
+ return apiclient.changeServiceForVirtualMachine(cmd)
+
+ @classmethod
+ def list(cls, apiclient, **kwargs):
+ """List all VMs matching criteria"""
+
+ cmd = listVirtualMachines.listVirtualMachinesCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listVirtualMachines(cmd))
+
+ def resetPassword(self, apiclient):
+ """Resets VM password if VM created using password enabled template"""
+
+ cmd = resetPasswordForVirtualMachine.resetPasswordForVirtualMachineCmd()
+ cmd.id = self.id
+ try:
+ response = apiclient.resetPasswordForVirtualMachine(cmd)
+ except Exception as e:
+ raise Exception("Reset Password failed! - %s" % e)
+ if response is not None:
+ return response.password
+
+ def assign_virtual_machine(self, apiclient, account, domainid):
+ """Move a user VM to another user under same domain."""
+
+ cmd = assignVirtualMachine.assignVirtualMachineCmd()
+ cmd.virtualmachineid = self.id
+ cmd.account = account
+ cmd.domainid = domainid
+ try:
+ response = apiclient.assignVirtualMachine(cmd)
+ return response
+ except Exception as e:
+ raise Exception("assignVirtualMachine failed - %s" %e)
+
+ def update_affinity_group(self, apiclient, affinitygroupids=None,
+ affinitygroupnames=None):
+ """Update affinity group of a VM"""
+ cmd = updateVMAffinityGroup.updateVMAffinityGroupCmd()
+ cmd.id = self.id
+
+ if affinitygroupids:
+ cmd.affinitygroupids = affinitygroupids
+
+ if affinitygroupnames:
+ cmd.affinitygroupnames = affinitygroupnames
+
+ return apiclient.updateVMAffinityGroup(cmd)
+
+ def scale(self, apiclient, serviceOfferingId,
+ customcpunumber=None, customcpuspeed=None, custommemory=None):
+ """Change service offering of the instance"""
+ cmd = scaleVirtualMachine.scaleVirtualMachineCmd()
+ cmd.id = self.id
+ cmd.serviceofferingid = serviceOfferingId
+ cmd.details = [{"cpuNumber": "","cpuSpeed":"","memory":""}]
+ if customcpunumber:
+ cmd.details[0]["cpuNumber"] = customcpunumber
+ if customcpuspeed:
+ cmd.details[0]["cpuSpeed"] = customcpuspeed
+ if custommemory:
+ cmd.details[0]["memory"] = custommemory
+ return apiclient.scaleVirtualMachine(cmd)
+
+
+class Volume:
+ """Manage Volume Life cycle
+ """
+ def __init__(self, items):
+ self.__dict__.update(items)
+
+ @classmethod
+ def create(cls, apiclient, services, zoneid=None, account=None,
+ domainid=None, diskofferingid=None, projectid=None):
+ """Create Volume"""
+ cmd = createVolume.createVolumeCmd()
+ cmd.name = services["diskname"]
+
+ if diskofferingid:
+ cmd.diskofferingid = diskofferingid
+ elif "diskofferingid" in services:
+ cmd.diskofferingid = services["diskofferingid"]
+
+ if zoneid:
+ cmd.zoneid = zoneid
+ elif "zoneid" in services:
+ cmd.zoneid = services["zoneid"]
+
+ if account:
+ cmd.account = account
+ elif "account" in services:
+ cmd.account = services["account"]
+
+ if domainid:
+ cmd.domainid = domainid
+ elif "domainid" in services:
+ cmd.domainid = services["domainid"]
+
+ if projectid:
+ cmd.projectid = projectid
+ return Volume(apiclient.createVolume(cmd).__dict__)
+
+ @classmethod
+ def create_custom_disk(cls, apiclient, services, account=None,
+ domainid=None, diskofferingid=None):
+ """Create Volume from Custom disk offering"""
+ cmd = createVolume.createVolumeCmd()
+ cmd.name = services["diskname"]
+
+ if diskofferingid:
+ cmd.diskofferingid = diskofferingid
+ elif "customdiskofferingid" in services:
+ cmd.diskofferingid = services["customdiskofferingid"]
+
+ cmd.size = services["customdisksize"]
+ cmd.zoneid = services["zoneid"]
+
+ if account:
+ cmd.account = account
+ else:
+ cmd.account = services["account"]
+
+ if domainid:
+ cmd.domainid = domainid
+ else:
+ cmd.domainid = services["domainid"]
+
+ return Volume(apiclient.createVolume(cmd).__dict__)
+
+ @classmethod
+ def create_from_snapshot(cls, apiclient, snapshot_id, services,
+ account=None, domainid=None):
+ """Create Volume from snapshot"""
+ cmd = createVolume.createVolumeCmd()
+ cmd.name = "-".join([services["diskname"], random_gen()])
+ cmd.snapshotid = snapshot_id
+ cmd.zoneid = services["zoneid"]
+ cmd.size = services["size"]
+ if account:
+ cmd.account = account
+ else:
+ cmd.account = services["account"]
+ if domainid:
+ cmd.domainid = domainid
+ else:
+ cmd.domainid = services["domainid"]
+ return Volume(apiclient.createVolume(cmd).__dict__)
+
+ def delete(self, apiclient):
+ """Delete Volume"""
+ cmd = deleteVolume.deleteVolumeCmd()
+ cmd.id = self.id
+ apiclient.deleteVolume(cmd)
+
+ @classmethod
+ def list(cls, apiclient, **kwargs):
+ """List all volumes matching criteria"""
+
+ cmd = listVolumes.listVolumesCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listVolumes(cmd))
+
+ def resize(self, apiclient, **kwargs):
+ """Resize a volume"""
+ cmd = resizeVolume.resizeVolumeCmd()
+ cmd.id = self.id
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.resizeVolume(cmd))
+
+ @classmethod
+ def upload(cls, apiclient, services, zoneid=None, account=None, domainid=None, url=None):
+ """Uploads the volume to specified account"""
+
+ cmd = uploadVolume.uploadVolumeCmd()
+ if zoneid:
+ cmd.zoneid = zoneid
+ if account:
+ cmd.account = account
+ if domainid:
+ cmd.domainid = domainid
+ cmd.format = services["format"]
+ cmd.name = services["diskname"]
+ if url:
+ cmd.url = url
+ else:
+ cmd.url = services["url"]
+ return Volume(apiclient.uploadVolume(cmd).__dict__)
+
+ def wait_for_upload(self, apiclient, timeout=10, interval=60):
+ """Wait for upload"""
+ # Sleep to ensure template is in proper state before download
+ time.sleep(interval)
+
+ while True:
+ volume_response = Volume.list(
+ apiclient,
+ id=self.id,
+ zoneid=self.zoneid,
+ )
+ if isinstance(volume_response, list):
+
+ volume = volume_response[0]
+ # If volume is ready,
+ # volume.state = Allocated
+ if volume.state == 'Uploaded':
+ break
+
+ elif 'Uploading' in volume.state:
+ time.sleep(interval)
+
+ elif 'Installing' not in volume.state:
+ raise Exception(
+ "Error in uploading volume: status - %s" %
+ volume.state)
+ elif timeout == 0:
+ break
+
+ else:
+ time.sleep(interval)
+ timeout = timeout - 1
+ return
+
+ @classmethod
+ def extract(cls, apiclient, volume_id, zoneid, mode):
+ """Extracts the volume"""
+
+ cmd = extractVolume.extractVolumeCmd()
+ cmd.id = volume_id
+ cmd.zoneid = zoneid
+ cmd.mode = mode
+ return Volume(apiclient.extractVolume(cmd).__dict__)
+
+ @classmethod
+ def migrate(cls, apiclient, **kwargs):
+ """Migrate a volume"""
+ cmd = migrateVolume.migrateVolumeCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.migrateVolume(cmd))
+
+class Snapshot:
+ """Manage Snapshot Lifecycle
+ """
+ def __init__(self, items):
+ self.__dict__.update(items)
+
+ @classmethod
+ def create(cls, apiclient, volume_id, account=None,
+ domainid=None, projectid=None):
+ """Create Snapshot"""
+ cmd = createSnapshot.createSnapshotCmd()
+ cmd.volumeid = volume_id
+ if account:
+ cmd.account = account
+ if domainid:
+ cmd.domainid = domainid
+ if projectid:
+ cmd.projectid = projectid
+ return Snapshot(apiclient.createSnapshot(cmd).__dict__)
+
+ def delete(self, apiclient):
+ """Delete Snapshot"""
+ cmd = deleteSnapshot.deleteSnapshotCmd()
+ cmd.id = self.id
+ apiclient.deleteSnapshot(cmd)
+
+ @classmethod
+ def list(cls, apiclient, **kwargs):
+ """List all snapshots matching criteria"""
+
+ cmd = listSnapshots.listSnapshotsCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listSnapshots(cmd))
+
+
+class Template:
+ """Manage template life cycle"""
+
+ def __init__(self, items):
+ self.__dict__.update(items)
+
+ @classmethod
+ def create(cls, apiclient, services, volumeid=None,
+ account=None, domainid=None, projectid=None):
+ """Create template from Volume"""
+ # Create template from Virtual machine and Volume ID
+ cmd = createTemplate.createTemplateCmd()
+ cmd.displaytext = services["displaytext"]
+ cmd.name = "-".join([services["name"], random_gen()])
+ if "ostypeid" in services:
+ cmd.ostypeid = services["ostypeid"]
+ elif "ostype" in services:
+ # Find OSTypeId from Os type
+ sub_cmd = listOsTypes.listOsTypesCmd()
+ sub_cmd.description = services["ostype"]
+ ostypes = apiclient.listOsTypes(sub_cmd)
+
+ if not isinstance(ostypes, list):
+ raise Exception(
+ "Unable to find Ostype id with desc: %s" %
+ services["ostype"])
+ cmd.ostypeid = ostypes[0].id
+ else:
+ raise Exception(
+ "Unable to find Ostype is required for creating template")
+
+ cmd.isfeatured = services["isfeatured"] if "isfeatured" in services else False
+ cmd.ispublic = services["ispublic"] if "ispublic" in services else False
+ cmd.isextractable = services["isextractable"] if "isextractable" in services else False
+ cmd.passwordenabled = services["passwordenabled"] if "passwordenabled" in services else False
+
+ if volumeid:
+ cmd.volumeid = volumeid
+
+ if account:
+ cmd.account = account
+
+ if domainid:
+ cmd.domainid = domainid
+
+ if projectid:
+ cmd.projectid = projectid
+ return Template(apiclient.createTemplate(cmd).__dict__)
+
+ @classmethod
+ def register(cls, apiclient, services, zoneid=None,
+ account=None, domainid=None, hypervisor=None):
+ """Create template from URL"""
+
+ # Create template from Virtual machine and Volume ID
+ cmd = registerTemplate.registerTemplateCmd()
+ cmd.displaytext = services["displaytext"]
+ cmd.name = "-".join([services["name"], random_gen()])
+ cmd.format = services["format"]
+ cmd.hypervisor = hypervisor
+
+ if "ostypeid" in services:
+ cmd.ostypeid = services["ostypeid"]
+ elif "ostype" in services:
+ # Find OSTypeId from Os type
+ sub_cmd = listOsTypes.listOsTypesCmd()
+ sub_cmd.description = services["ostype"]
+ ostypes = apiclient.listOsTypes(sub_cmd)
+
+ if not isinstance(ostypes, list):
+ raise Exception(
+ "Unable to find Ostype id with desc: %s" %
+ services["ostype"])
+ cmd.ostypeid = ostypes[0].id
+ else:
+ raise Exception(
+ "Unable to find Ostype is required for registering template")
+
+ cmd.url = services["url"]
+
+ if zoneid:
+ cmd.zoneid = zoneid
+ else:
+ cmd.zoneid = services["zoneid"]
+
+ cmd.isfeatured = services["isfeatured"] if "isfeatured" in services else False
+ cmd.ispublic = services["ispublic"] if "ispublic" in services else False
+ cmd.isextractable = services["isextractable"] if "isextractable" in services else False
+ cmd.passwordenabled = services["passwordenabled"] if "passwordenabled" in services else False
+
+ if account:
+ cmd.account = account
+
+ if domainid:
+ cmd.domainid = domainid
+
+ # Register Template
+ template = apiclient.registerTemplate(cmd)
+
+ if isinstance(template, list):
+ return Template(template[0].__dict__)
+
+ @classmethod
+ def extract(cls, apiclient, id, mode, zoneid=None):
+ "Extract template "
+
+ cmd = extractTemplate.extractTemplateCmd()
+ cmd.id = id
+ cmd.mode = mode
+ cmd.zoneid = zoneid
+
+ return apiclient.extractTemplate(cmd)
+
+ @classmethod
+ def create_from_snapshot(cls, apiclient, snapshot, services,
+ random_name=True):
+ """Create Template from snapshot"""
+ # Create template from Virtual machine and Snapshot ID
+ cmd = createTemplate.createTemplateCmd()
+ cmd.displaytext = services["displaytext"]
+ cmd.name = "-".join([
+ services["name"],
+ random_gen()
+ ]) if random_name else services["name"]
+
+ if "ostypeid" in services:
+ cmd.ostypeid = services["ostypeid"]
+ elif "ostype" in services:
+ # Find OSTypeId from Os type
+ sub_cmd = listOsTypes.listOsTypesCmd()
+ sub_cmd.description = services["ostype"]
+ ostypes = apiclient.listOsTypes(sub_cmd)
+
+ if not isinstance(ostypes, list):
+ raise Exception(
+ "Unable to find Ostype id with desc: %s" %
+ services["ostype"])
+ cmd.ostypeid = ostypes[0].id
+ else:
+ raise Exception(
+ "Unable to find Ostype is required for creating template")
+
+ cmd.snapshotid = snapshot.id
+ return Template(apiclient.createTemplate(cmd).__dict__)
+
+ def delete(self, apiclient):
+ """Delete Template"""
+
+ cmd = deleteTemplate.deleteTemplateCmd()
+ cmd.id = self.id
+ apiclient.deleteTemplate(cmd)
+
+ def download(self, apiclient, timeout=5, interval=60):
+ """Download Template"""
+ # Sleep to ensure template is in proper state before download
+ time.sleep(interval)
+
+ while True:
+ template_response = Template.list(
+ apiclient,
+ id=self.id,
+ zoneid=self.zoneid,
+ templatefilter='self'
+ )
+ if isinstance(template_response, list):
+
+ template = template_response[0]
+ # If template is ready,
+ # template.status = Download Complete
+ # Downloading - x% Downloaded
+ # Error - Any other string
+ if template.status == 'Download Complete':
+ break
+
+ elif 'Downloaded' in template.status:
+ time.sleep(interval)
+
+ elif 'Installing' not in template.status:
+ raise Exception(
+ "Error in downloading template: status - %s" %
+ template.status)
+
+ elif timeout == 0:
+ break
+
+ else:
+ time.sleep(interval)
+ timeout = timeout - 1
+ return
+
+ def updatePermissions(self, apiclient, **kwargs):
+ """Updates the template permissions"""
+
+ cmd = updateTemplatePermissions.updateTemplatePermissionsCmd()
+ cmd.id = self.id
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.updateTemplatePermissions(cmd))
+
+ def update(self, apiclient, **kwargs):
+ """Updates the template details"""
+
+ cmd = updateTemplate.updateTemplateCmd()
+ cmd.id = self.id
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.updateTemplate(cmd))
+
+ @classmethod
+ def copy(cls, apiclient, id, sourcezoneid, destzoneid):
+ "Copy Template from source Zone to Destination Zone"
+
+ cmd = copyTemplate.copyTemplateCmd()
+ cmd.id = id
+ cmd.sourcezoneid = sourcezoneid
+ cmd.destzoneid = destzoneid
+
+ return apiclient.copyTemplate(cmd)
+
+ @classmethod
+ def list(cls, apiclient, **kwargs):
+ """List all templates matching criteria"""
+
+ cmd = listTemplates.listTemplatesCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listTemplates(cmd))
+
+
+class Iso:
+ """Manage ISO life cycle"""
+
+ def __init__(self, items):
+ self.__dict__.update(items)
+
+ @classmethod
+ def create(cls, apiclient, services, account=None, domainid=None,
+ projectid=None):
+ """Create an ISO"""
+ # Create ISO from URL
+ cmd = registerIso.registerIsoCmd()
+ cmd.displaytext = services["displaytext"]
+ cmd.name = services["name"]
+ if "ostypeid" in services:
+ cmd.ostypeid = services["ostypeid"]
+ elif "ostype" in services:
+ # Find OSTypeId from Os type
+ sub_cmd = listOsTypes.listOsTypesCmd()
+ sub_cmd.description = services["ostype"]
+ ostypes = apiclient.listOsTypes(sub_cmd)
+
+ if not isinstance(ostypes, list):
+ raise Exception(
+ "Unable to find Ostype id with desc: %s" %
+ services["ostype"])
+ cmd.ostypeid = ostypes[0].id
+ else:
+ raise Exception(
+ "Unable to find Ostype is required for creating ISO")
+
+ cmd.url = services["url"]
+ cmd.zoneid = services["zoneid"]
+
+ if "isextractable" in services:
+ cmd.isextractable = services["isextractable"]
+ if "isfeatured" in services:
+ cmd.isfeatured = services["isfeatured"]
+ if "ispublic" in services:
+ cmd.ispublic = services["ispublic"]
+
+ if account:
+ cmd.account = account
+ if domainid:
+ cmd.domainid = domainid
+ if projectid:
+ cmd.projectid = projectid
+ # Register ISO
+ iso = apiclient.registerIso(cmd)
+
+ if iso:
+ return Iso(iso[0].__dict__)
+
+ def delete(self, apiclient):
+ """Delete an ISO"""
+ cmd = deleteIso.deleteIsoCmd()
+ cmd.id = self.id
+ apiclient.deleteIso(cmd)
+ return
+
+ def download(self, apiclient, timeout=5, interval=60):
+ """Download an ISO"""
+ # Ensuring ISO is successfully downloaded
+ while True:
+ time.sleep(interval)
+
+ cmd = listIsos.listIsosCmd()
+ cmd.id = self.id
+ iso_response = apiclient.listIsos(cmd)
+
+ if isinstance(iso_response, list):
+ response = iso_response[0]
+ # Again initialize timeout to avoid listISO failure
+ timeout = 5
+ # Check whether download is in progress(for Ex:10% Downloaded)
+ # or ISO is 'Successfully Installed'
+ if response.status == 'Successfully Installed':
+ return
+ elif 'Downloaded' not in response.status and \
+ 'Installing' not in response.status:
+ raise Exception(
+ "Error In Downloading ISO: ISO Status - %s" %
+ response.status)
+
+ elif timeout == 0:
+ raise Exception("ISO download Timeout Exception")
+ else:
+ timeout = timeout - 1
+ return
+
+ @classmethod
+ def extract(cls, apiclient, id, mode, zoneid=None):
+ "Extract ISO "
+
+ cmd = extractIso.extractIsoCmd()
+ cmd.id = id
+ cmd.mode = mode
+ cmd.zoneid = zoneid
+
+ return apiclient.extractIso(cmd)
+
+ def update(self, apiclient, **kwargs):
+ """Updates the ISO details"""
+
+ cmd = updateIso.updateIsoCmd()
+ cmd.id = self.id
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.updateIso(cmd))
+
+ @classmethod
+ def copy(cls, apiclient, id, sourcezoneid, destzoneid):
+ "Copy ISO from source Zone to Destination Zone"
+
+ cmd = copyIso.copyIsoCmd()
+ cmd.id = id
+ cmd.sourcezoneid = sourcezoneid
+ cmd.destzoneid = destzoneid
+
+ return apiclient.copyIso(cmd)
+
+ @classmethod
+ def list(cls, apiclient, **kwargs):
+ """Lists all available ISO files."""
+
+ cmd = listIsos.listIsosCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listIsos(cmd))
+
+
+class PublicIPAddress:
+ """Manage Public IP Addresses"""
+
+ def __init__(self, items):
+ self.__dict__.update(items)
+
+ @classmethod
+ def create(cls, apiclient, accountid=None, zoneid=None, domainid=None, services=None,
+ networkid=None, projectid=None, vpcid=None, isportable=False):
+ """Associate Public IP address"""
+ cmd = associateIpAddress.associateIpAddressCmd()
+
+ if accountid:
+ cmd.account = accountid
+ elif "account" in services:
+ cmd.account = services["account"]
+
+ if zoneid:
+ cmd.zoneid = zoneid
+ elif "zoneid" in services:
+ cmd.zoneid = services["zoneid"]
+
+ if domainid:
+ cmd.domainid = domainid
+ elif "domainid" in services:
+ cmd.domainid = services["domainid"]
+
+ if isportable:
+ cmd.isportable = isportable
+
+ if networkid:
+ cmd.networkid = networkid
+
+ if projectid:
+ cmd.projectid = projectid
+
+ if vpcid:
+ cmd.vpcid = vpcid
+ return PublicIPAddress(apiclient.associateIpAddress(cmd).__dict__)
+
+ def delete(self, apiclient):
+ """Dissociate Public IP address"""
+ cmd = disassociateIpAddress.disassociateIpAddressCmd()
+ cmd.id = self.ipaddress.id
+ apiclient.disassociateIpAddress(cmd)
+ return
+
+ @classmethod
+ def list(cls, apiclient, **kwargs):
+ """List all Public IPs matching criteria"""
+
+ cmd = listPublicIpAddresses.listPublicIpAddressesCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listPublicIpAddresses(cmd))
+
+
+class NATRule:
+ """Manage port forwarding rule"""
+
+ def __init__(self, items):
+ self.__dict__.update(items)
+
+ @classmethod
+ def create(cls, apiclient, virtual_machine, services, ipaddressid=None,
+ projectid=None, openfirewall=False, networkid=None, vpcid=None,
+ vmguestip=None):
+ """Create Port forwarding rule"""
+ cmd = createPortForwardingRule.createPortForwardingRuleCmd()
+
+ if ipaddressid:
+ cmd.ipaddressid = ipaddressid
+ elif "ipaddressid" in services:
+ cmd.ipaddressid = services["ipaddressid"]
+
+ cmd.privateport = services["privateport"]
+ cmd.publicport = services["publicport"]
+ if "privateendport" in services:
+ cmd.privateendport = services["privateendport"]
+ if "publicendport" in services:
+ cmd.publicendport = services["publicendport"]
+ cmd.protocol = services["protocol"]
+ cmd.virtualmachineid = virtual_machine.id
+
+ if projectid:
+ cmd.projectid = projectid
+
+ if openfirewall:
+ cmd.openfirewall = True
+
+ if networkid:
+ cmd.networkid = networkid
+
+ if vpcid:
+ cmd.vpcid = vpcid
+
+ if vmguestip:
+ cmd.vmguestip = vmguestip
+
+ return NATRule(apiclient.createPortForwardingRule(cmd).__dict__)
+
+ def delete(self, apiclient):
+ """Delete port forwarding"""
+ cmd = deletePortForwardingRule.deletePortForwardingRuleCmd()
+ cmd.id = self.id
+ apiclient.deletePortForwardingRule(cmd)
+ return
+
+ @classmethod
+ def list(cls, apiclient, **kwargs):
+ """List all NAT rules matching criteria"""
+
+ cmd = listPortForwardingRules.listPortForwardingRulesCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listPortForwardingRules(cmd))
+
+
+class StaticNATRule:
+ """Manage Static NAT rule"""
+
+ def __init__(self, items):
+ self.__dict__.update(items)
+
+ @classmethod
+ def create(cls, apiclient, services, ipaddressid=None, networkid=None, vpcid=None):
+ """Creates static ip forwarding rule"""
+
+ cmd = createFirewallRule.createFirewallRuleCmd()
+ cmd.protocol = services["protocol"]
+ cmd.startport = services["startport"]
+
+ if "endport" in services:
+ cmd.endport = services["endport"]
+
+ if "cidrlist" in services:
+ cmd.cidrlist = services["cidrlist"]
+
+ if ipaddressid:
+ cmd.ipaddressid = ipaddressid
+ elif "ipaddressid" in services:
+ cmd.ipaddressid = services["ipaddressid"]
+
+ if networkid:
+ cmd.networkid = networkid
+
+ if vpcid:
+ cmd.vpcid = vpcid
+ return StaticNATRule(apiclient.createFirewallRule(cmd).__dict__)
+
+ def delete(self, apiclient):
+ """Delete IP forwarding rule"""
+ cmd = deleteIpForwardingRule.deleteIpForwardingRuleCmd()
+ cmd.id = self.id
+ apiclient.deleteIpForwardingRule(cmd)
+ return
+
+ @classmethod
+ def list(cls, apiclient, **kwargs):
+ """List all IP forwarding rules matching criteria"""
+
+ cmd = listIpForwardingRules.listIpForwardingRulesCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listIpForwardingRules(cmd))
+
+ @classmethod
+ def enable(cls, apiclient, ipaddressid, virtualmachineid, networkid=None,
+ vmguestip=None):
+ """Enables Static NAT rule"""
+
+ cmd = enableStaticNat.enableStaticNatCmd()
+ cmd.ipaddressid = ipaddressid
+ cmd.virtualmachineid = virtualmachineid
+ if networkid:
+ cmd.networkid = networkid
+
+ if vmguestip:
+ cmd.vmguestip = vmguestip
+ apiclient.enableStaticNat(cmd)
+ return
+
+ @classmethod
+ def disable(cls, apiclient, ipaddressid, virtualmachineid):
+ """Disables Static NAT rule"""
+
+ cmd = disableStaticNat.disableStaticNatCmd()
+ cmd.ipaddressid = ipaddressid
+ apiclient.disableStaticNat(cmd)
+ return
+
+
+class EgressFireWallRule:
+ """Manage Egress Firewall rule"""
+
+ def __init__(self, items):
+ self.__dict__.update(items)
+
+ @classmethod
+ def create(cls, apiclient, networkid, protocol, cidrlist=None,
+ startport=None, endport=None):
+ """Create Egress Firewall Rule"""
+ cmd = createEgressFirewallRule.createEgressFirewallRuleCmd()
+ cmd.networkid = networkid
+ cmd.protocol = protocol
+ if cidrlist:
+ cmd.cidrlist = cidrlist
+ if startport:
+ cmd.startport = startport
+ if endport:
+ cmd.endport = endport
+
+ return EgressFireWallRule(apiclient.createEgressFirewallRule(cmd).__dict__)
+
+ def delete(self, apiclient):
+ """Delete Egress Firewall rule"""
+ cmd = deleteEgressFirewallRule.deleteEgressFirewallRuleCmd()
+ cmd.id = self.id
+ apiclient.deleteEgressFirewallRule(cmd)
+ return
+
+ @classmethod
+ def list(cls, apiclient, **kwargs):
+ """List all Egress Firewall Rules matching criteria"""
+
+ cmd = listEgressFirewallRules.listEgressFirewallRulesCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listEgressFirewallRules(cmd))
+
+
+
+class FireWallRule:
+ """Manage Firewall rule"""
+
+ def __init__(self, items):
+ self.__dict__.update(items)
+
+ @classmethod
+ def create(cls, apiclient, ipaddressid, protocol, cidrlist=None,
+ startport=None, endport=None, projectid=None, vpcid=None):
+ """Create Firewall Rule"""
+ cmd = createFirewallRule.createFirewallRuleCmd()
+ cmd.ipaddressid = ipaddressid
+ cmd.protocol = protocol
+ if cidrlist:
+ cmd.cidrlist = cidrlist
+ if startport:
+ cmd.startport = startport
+ if endport:
+ cmd.endport = endport
+
+ if projectid:
+ cmd.projectid = projectid
+
+ if vpcid:
+ cmd.vpcid = vpcid
+
+ return FireWallRule(apiclient.createFirewallRule(cmd).__dict__)
+
+ def delete(self, apiclient):
+ """Delete Firewall rule"""
+ cmd = deleteFirewallRule.deleteFirewallRuleCmd()
+ cmd.id = self.id
+ apiclient.deleteFirewallRule(cmd)
+ return
+
+ @classmethod
+ def list(cls, apiclient, **kwargs):
+ """List all Firewall Rules matching criteria"""
+
+ cmd = listFirewallRules.listFirewallRulesCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listFirewallRules(cmd))
+
+
+class ServiceOffering:
+ """Manage service offerings cycle"""
+
+ def __init__(self, items):
+ self.__dict__.update(items)
+
+ @classmethod
+ def create(cls, apiclient, services, domainid=None, **kwargs):
+ """Create Service offering"""
+ cmd = createServiceOffering.createServiceOfferingCmd()
+ cmd.cpunumber = services["cpunumber"]
+ cmd.cpuspeed = services["cpuspeed"]
+ cmd.displaytext = services["displaytext"]
+ cmd.memory = services["memory"]
+ cmd.name = services["name"]
+ if "storagetype" in services:
+ cmd.storagetype = services["storagetype"]
+
+ if "systemvmtype" in services:
+ cmd.systemvmtype = services['systemvmtype']
+
+ if "issystem" in services:
+ cmd.issystem = services['issystem']
+
+ if "tags" in services:
+ cmd.tags = services["tags"]
+
+ if "hosttags" in services:
+ cmd.hosttags = services["hosttags"]
+
+ if "deploymentplanner" in services:
+ cmd.deploymentplanner = services["deploymentplanner"]
+
+ if "serviceofferingdetails" in services:
+ cmd.serviceofferingdetails.append({services['serviceofferingdetails']})
+
+ if "isvolatile" in services:
+ cmd.isvolatile = services["isvolatile"]
+
+ if "offerha" in services:
+ cmd.offerha = services["offerha"]
+
+ # Service Offering private to that domain
+ if domainid:
+ cmd.domainid = domainid
+
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return ServiceOffering(apiclient.createServiceOffering(cmd).__dict__)
+
+ def delete(self, apiclient):
+ """Delete Service offering"""
+ cmd = deleteServiceOffering.deleteServiceOfferingCmd()
+ cmd.id = self.id
+ apiclient.deleteServiceOffering(cmd)
+ return
+
+ @classmethod
+ def list(cls, apiclient, **kwargs):
+ """Lists all available service offerings."""
+
+ cmd = listServiceOfferings.listServiceOfferingsCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listServiceOfferings(cmd))
+
+
+class DiskOffering:
+ """Manage disk offerings cycle"""
+
+ def __init__(self, items):
+ self.__dict__.update(items)
+
+ @classmethod
+ def create(cls, apiclient, services, custom=False, domainid=None):
+ """Create Disk offering"""
+ cmd = createDiskOffering.createDiskOfferingCmd()
+ cmd.displaytext = services["displaytext"]
+ cmd.name = services["name"]
+ if custom:
+ cmd.customized = True
+ else:
+ cmd.disksize = services["disksize"]
+
+ if domainid:
+ cmd.domainid = domainid
+
+ if "storagetype" in services:
+ cmd.storagetype = services["storagetype"]
+
+ return DiskOffering(apiclient.createDiskOffering(cmd).__dict__)
+
+ def delete(self, apiclient):
+ """Delete Disk offering"""
+ cmd = deleteDiskOffering.deleteDiskOfferingCmd()
+ cmd.id = self.id
+ apiclient.deleteDiskOffering(cmd)
+ return
+
+ @classmethod
+ def list(cls, apiclient, **kwargs):
+ """Lists all available disk offerings."""
+
+ cmd = listDiskOfferings.listDiskOfferingsCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listDiskOfferings(cmd))
+
+
+class NetworkOffering:
+ """Manage network offerings cycle"""
+
+ def __init__(self, items):
+ self.__dict__.update(items)
+
+ @classmethod
+ def create(cls, apiclient, services, **kwargs):
+ """Create network offering"""
+
+ cmd = createNetworkOffering.createNetworkOfferingCmd()
+ cmd.displaytext = "-".join([services["displaytext"], random_gen()])
+ cmd.name = "-".join([services["name"], random_gen()])
+ cmd.guestiptype = services["guestiptype"]
+ cmd.supportedservices = ''
+ if "supportedservices" in services:
+ cmd.supportedservices = services["supportedservices"]
+ cmd.traffictype = services["traffictype"]
+
+ if "useVpc" in services:
+ cmd.useVpc = services["useVpc"]
+ cmd.serviceproviderlist = []
+ if "serviceProviderList" in services:
+ for service, provider in services["serviceProviderList"].items():
+ cmd.serviceproviderlist.append({
+ 'service': service,
+ 'provider': provider
+ })
+ if "serviceCapabilityList" in services:
+ cmd.servicecapabilitylist = []
+ for service, capability in services["serviceCapabilityList"].items():
+ for ctype, value in capability.items():
+ cmd.servicecapabilitylist.append({
+ 'service': service,
+ 'capabilitytype': ctype,
+ 'capabilityvalue': value
+ })
+ if "specifyVlan" in services:
+ cmd.specifyVlan = services["specifyVlan"]
+ if "specifyIpRanges" in services:
+ cmd.specifyIpRanges = services["specifyIpRanges"]
+ if "ispersistent" in services:
+ cmd.ispersistent = services["ispersistent"]
+ if "egress_policy" in services:
+ cmd.egressdefaultpolicy = services["egress_policy"]
+
+ cmd.availability = 'Optional'
+
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+
+ return NetworkOffering(apiclient.createNetworkOffering(cmd).__dict__)
+
+ def delete(self, apiclient):
+ """Delete network offering"""
+ cmd = deleteNetworkOffering.deleteNetworkOfferingCmd()
+ cmd.id = self.id
+ apiclient.deleteNetworkOffering(cmd)
+ return
+
+ def update(self, apiclient, **kwargs):
+ """Lists all available network offerings."""
+
+ cmd = updateNetworkOffering.updateNetworkOfferingCmd()
+ cmd.id = self.id
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.updateNetworkOffering(cmd))
+
+ @classmethod
+ def list(cls, apiclient, **kwargs):
+ """Lists all available network offerings."""
+
+ cmd = listNetworkOfferings.listNetworkOfferingsCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listNetworkOfferings(cmd))
+
+
+class SnapshotPolicy:
+ """Manage snapshot policies"""
+
+ def __init__(self, items):
+ self.__dict__.update(items)
+
+ @classmethod
+ def create(cls, apiclient, volumeid, services):
+ """Create Snapshot policy"""
+ cmd = createSnapshotPolicy.createSnapshotPolicyCmd()
+ cmd.intervaltype = services["intervaltype"]
+ cmd.maxsnaps = services["maxsnaps"]
+ cmd.schedule = services["schedule"]
+ cmd.timezone = services["timezone"]
+ cmd.volumeid = volumeid
+ return SnapshotPolicy(apiclient.createSnapshotPolicy(cmd).__dict__)
+
+ def delete(self, apiclient):
+ """Delete Snapshot policy"""
+ cmd = deleteSnapshotPolicies.deleteSnapshotPoliciesCmd()
+ cmd.id = self.id
+ apiclient.deleteSnapshotPolicies(cmd)
+ return
+
+ @classmethod
+ def list(cls, apiclient, **kwargs):
+ """Lists snapshot policies."""
+
+ cmd = listSnapshotPolicies.listSnapshotPoliciesCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listSnapshotPolicies(cmd))
+
+class Hypervisor:
+ """Manage Hypervisor"""
+
+ def __init__(self, items):
+ self.__dict__.update(items)
+
+ @classmethod
+ def list(cls, apiclient, **kwargs):
+ """Lists hypervisors"""
+
+ cmd = listHypervisors.listHypervisorsCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listHypervisors(cmd))
+
+
+class LoadBalancerRule:
+ """Manage Load Balancer rule"""
+
+ def __init__(self, items):
+ self.__dict__.update(items)
+
+ @classmethod
+ def create(cls, apiclient, services, ipaddressid=None, accountid=None,
+ networkid=None, vpcid=None, projectid=None, domainid=None):
+ """Create Load balancing Rule"""
+
+ cmd = createLoadBalancerRule.createLoadBalancerRuleCmd()
+
+ if ipaddressid:
+ cmd.publicipid = ipaddressid
+ elif "ipaddressid" in services:
+ cmd.publicipid = services["ipaddressid"]
+
+ if accountid:
+ cmd.account = accountid
+ elif "account" in services:
+ cmd.account = services["account"]
+
+ if domainid:
+ cmd.domainid = domainid
+
+ if vpcid:
+ cmd.vpcid = vpcid
+ cmd.name = services["name"]
+ cmd.algorithm = services["alg"]
+ cmd.privateport = services["privateport"]
+ cmd.publicport = services["publicport"]
+
+ if "openfirewall" in services:
+ cmd.openfirewall = services["openfirewall"]
+
+ if projectid:
+ cmd.projectid = projectid
+
+ if networkid:
+ cmd.networkid = networkid
+ return LoadBalancerRule(apiclient.createLoadBalancerRule(cmd).__dict__)
+
+ def delete(self, apiclient):
+ """Delete load balancing rule"""
+ cmd = deleteLoadBalancerRule.deleteLoadBalancerRuleCmd()
+ cmd.id = self.id
+ apiclient.deleteLoadBalancerRule(cmd)
+ return
+
+ def assign(self, apiclient, vms):
+ """Assign virtual machines to load balancing rule"""
+ cmd = assignToLoadBalancerRule.assignToLoadBalancerRuleCmd()
+ cmd.id = self.id
+ cmd.virtualmachineids = [str(vm.id) for vm in vms]
+ apiclient.assignToLoadBalancerRule(cmd)
+ return
+
+ def remove(self, apiclient, vms):
+ """Remove virtual machines from load balancing rule"""
+ cmd = removeFromLoadBalancerRule.removeFromLoadBalancerRuleCmd()
+ cmd.id = self.id
+ cmd.virtualmachineids = [str(vm.id) for vm in vms]
+ apiclient.removeFromLoadBalancerRule(cmd)
+ return
+
+ def update(self, apiclient, algorithm=None, description=None, name=None, **kwargs):
+ """Updates the load balancing rule"""
+ cmd = updateLoadBalancerRule.updateLoadBalancerRuleCmd()
+ cmd.id = self.id
+ if algorithm:
+ cmd.algorithm = algorithm
+ if description:
+ cmd.description = description
+ if name:
+ cmd.name = name
+
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return apiclient.updateLoadBalancerRule(cmd)
+
+ def createSticky(self, apiclient, methodname, name, description=None, param=None):
+ """Creates a sticky policy for the LB rule"""
+
+ cmd = createLBStickinessPolicy.createLBStickinessPolicyCmd()
+ cmd.lbruleid = self.id
+ cmd.methodname = methodname
+ cmd.name = name
+ if description:
+ cmd.description = description
+ if param:
+ cmd.param = []
+ for name, value in param.items():
+ cmd.param.append({'name': name, 'value': value})
+ return apiclient.createLBStickinessPolicy(cmd)
+
+ def deleteSticky(self, apiclient, id):
+ """Deletes stickyness policy"""
+
+ cmd = deleteLBStickinessPolicy.deleteLBStickinessPolicyCmd()
+ cmd.id = id
+ return apiclient.deleteLBStickinessPolicy(cmd)
+
+ @classmethod
+ def listStickyPolicies(cls, apiclient, lbruleid, **kwargs):
+ """Lists stickiness policies for load balancing rule"""
+
+ cmd = listLBStickinessPolicies.listLBStickinessPoliciesCmd()
+ cmd.lbruleid = lbruleid
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return apiclient.listLBStickinessPolicies(cmd)
+
+ @classmethod
+ def list(cls, apiclient, **kwargs):
+ """List all Load balancing rules matching criteria"""
+
+ cmd = listLoadBalancerRules.listLoadBalancerRulesCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listLoadBalancerRules(cmd))
+
+
+class Cluster:
+ """Manage Cluster life cycle"""
+
+ def __init__(self, items):
+ self.__dict__.update(items)
+
+ @classmethod
+ def create(cls, apiclient, services, zoneid=None, podid=None, hypervisor=None):
+ """Create Cluster"""
+ cmd = addCluster.addClusterCmd()
+ cmd.clustertype = services["clustertype"]
+ cmd.hypervisor = hypervisor
+
+ if zoneid:
+ cmd.zoneid = zoneid
+ else:
+ cmd.zoneid = services["zoneid"]
+
+ if podid:
+ cmd.podid = podid
+ else:
+ cmd.podid = services["podid"]
+
+ if "username" in services:
+ cmd.username = services["username"]
+ if "password" in services:
+ cmd.password = services["password"]
+ if "url" in services:
+ cmd.url = services["url"]
+ if "clustername" in services:
+ cmd.clustername = services["clustername"]
+
+ return Cluster(apiclient.addCluster(cmd)[0].__dict__)
+
+ def delete(self, apiclient):
+ """Delete Cluster"""
+ cmd = deleteCluster.deleteClusterCmd()
+ cmd.id = self.id
+ apiclient.deleteCluster(cmd)
+ return
+
+ @classmethod
+ def list(cls, apiclient, **kwargs):
+ """List all Clusters matching criteria"""
+
+ cmd = listClusters.listClustersCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listClusters(cmd))
+
+
+class Host:
+ """Manage Host life cycle"""
+
+ def __init__(self, items):
+ self.__dict__.update(items)
+
+ @classmethod
+ def create(cls, apiclient, cluster, services, zoneid=None, podid=None, hypervisor=None):
+ """
+ 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
+
+ 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"]
+
+ '''
+ 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"""
+ # Host must be in maintenance mode before deletion
+ cmd = prepareHostForMaintenance.prepareHostForMaintenanceCmd()
+ cmd.id = self.id
+ apiclient.prepareHostForMaintenance(cmd)
+ time.sleep(30)
+
+ cmd = deleteHost.deleteHostCmd()
+ cmd.id = self.id
+ apiclient.deleteHost(cmd)
+ return
+
+ def enableMaintenance(self, apiclient):
+ """enables maintenance mode Host"""
+
+ cmd = prepareHostForMaintenance.prepareHostForMaintenanceCmd()
+ cmd.id = self.id
+ return apiclient.prepareHostForMaintenance(cmd)
+
+ @classmethod
+ def enableMaintenance(cls, apiclient, id):
+ """enables maintenance mode Host"""
+
+ cmd = prepareHostForMaintenance.prepareHostForMaintenanceCmd()
+ cmd.id = id
+ return apiclient.prepareHostForMaintenance(cmd)
+
+ def cancelMaintenance(self, apiclient):
+ """Cancels maintenance mode Host"""
+
+ cmd = cancelHostMaintenance.cancelHostMaintenanceCmd()
+ cmd.id = self.id
+ return apiclient.cancelHostMaintenance(cmd)
+
+ @classmethod
+ def cancelMaintenance(cls, apiclient, id):
+ """Cancels maintenance mode Host"""
+
+ cmd = cancelHostMaintenance.cancelHostMaintenanceCmd()
+ cmd.id = id
+ return apiclient.cancelHostMaintenance(cmd)
+
+ @classmethod
+ def list(cls, apiclient, **kwargs):
+ """List all Hosts matching criteria"""
+
+ cmd = listHosts.listHostsCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listHosts(cmd))
+
+ @classmethod
+ def listForMigration(cls, apiclient, **kwargs):
+ """List all Hosts for migration matching criteria"""
+
+ cmd = findHostsForMigration.findHostsForMigrationCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.findHostsForMigration(cmd))
+
+ @classmethod
+ def update(cls, apiclient, **kwargs):
+ """Update host information"""
+
+ cmd = updateHost.updateHostCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.updateHost(cmd))
+
+
+class StoragePool:
+ """Manage Storage pools (Primary Storage)"""
+
+ def __init__(self, items):
+ self.__dict__.update(items)
+
+ @classmethod
+ def create(cls, apiclient, services, clusterid=None,
+ zoneid=None, podid=None):
+ """Create Storage pool (Primary Storage)"""
+
+ cmd = createStoragePool.createStoragePoolCmd()
+ cmd.name = services["name"]
+
+ if podid:
+ cmd.podid = podid
+ else:
+ cmd.podid = services["podid"]
+
+ cmd.url = services["url"]
+ if clusterid:
+ cmd.clusterid = clusterid
+ elif "clusterid" in services:
+ cmd.clusterid = services["clusterid"]
+
+ if zoneid:
+ cmd.zoneid = zoneid
+ else:
+ cmd.zoneid = services["zoneid"]
+
+ return StoragePool(apiclient.createStoragePool(cmd).__dict__)
+
+ def delete(self, apiclient):
+ """Delete Storage pool (Primary Storage)"""
+
+ # Storage pool must be in maintenance mode before deletion
+ cmd = enableStorageMaintenance.enableStorageMaintenanceCmd()
+ cmd.id = self.id
+ apiclient.enableStorageMaintenance(cmd)
+ time.sleep(30)
+ cmd = deleteStoragePool.deleteStoragePoolCmd()
+ cmd.id = self.id
+ apiclient.deleteStoragePool(cmd)
+ return
+
+ def enableMaintenance(self, apiclient):
+ """enables maintenance mode Storage pool"""
+
+ cmd = enableStorageMaintenance.enableStorageMaintenanceCmd()
+ cmd.id = self.id
+ return apiclient.enableStorageMaintenance(cmd)
+
+ @classmethod
+ def list(cls, apiclient, **kwargs):
+ """List all storage pools matching criteria"""
+
+ cmd = listStoragePools.listStoragePoolsCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listStoragePools(cmd))
+
+ @classmethod
+ def listForMigration(cls, apiclient, **kwargs):
+ """List all storage pools for migration matching criteria"""
+
+ cmd = findStoragePoolsForMigration.findStoragePoolsForMigrationCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.findStoragePoolsForMigration(cmd))
+
+class Network:
+ """Manage Network pools"""
+
+ def __init__(self, items):
+ self.__dict__.update(items)
+
+ @classmethod
+ def create(cls, apiclient, services, accountid=None, domainid=None,
+ networkofferingid=None, projectid=None,
+ subdomainaccess=None, zoneid=None,
+ gateway=None, netmask=None, vpcid=None, aclid=None):
+ """Create Network for account"""
+ cmd = createNetwork.createNetworkCmd()
+ cmd.name = services["name"]
+ cmd.displaytext = services["displaytext"]
+
+ if networkofferingid:
+ cmd.networkofferingid = networkofferingid
+ elif "networkoffering" in services:
+ cmd.networkofferingid = services["networkoffering"]
+
+ if zoneid:
+ cmd.zoneid = zoneid
+ elif "zoneid" in services:
+ cmd.zoneid = services["zoneid"]
+
+ if subdomainaccess is not None:
+ cmd.subdomainaccess = subdomainaccess
+
+ if gateway:
+ cmd.gateway = gateway
+ elif "gateway" in services:
+ cmd.gateway = services["gateway"]
+ if netmask:
+ cmd.netmask = netmask
+ elif "netmask" in services:
+ cmd.netmask = services["netmask"]
+ if "startip" in services:
+ cmd.startip = services["startip"]
+ if "endip" in services:
+ cmd.endip = services["endip"]
+ if "vlan" in services:
+ cmd.vlan = services["vlan"]
+ if "acltype" in services:
+ cmd.acltype = services["acltype"]
+
+ if accountid:
+ cmd.account = accountid
+ if domainid:
+ cmd.domainid = domainid
+ if projectid:
+ cmd.projectid = projectid
+ if vpcid:
+ cmd.vpcid = vpcid
+ if aclid:
+ cmd.aclid = aclid
+ return Network(apiclient.createNetwork(cmd).__dict__)
+
+ def delete(self, apiclient):
+ """Delete Account"""
+
+ cmd = deleteNetwork.deleteNetworkCmd()
+ cmd.id = self.id
+ apiclient.deleteNetwork(cmd)
+
+ def update(self, apiclient, **kwargs):
+ """Updates network with parameters passed"""
+
+ cmd = updateNetwork.updateNetworkCmd()
+ cmd.id = self.id
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.updateNetwork(cmd))
+
+ def restart(self, apiclient, cleanup=None):
+ """Restarts the network"""
+
+ cmd = restartNetwork.restartNetworkCmd()
+ cmd.id = self.id
+ if cleanup:
+ cmd.cleanup = cleanup
+ return(apiclient.restartNetwork(cmd))
+
+ @classmethod
+ def list(cls, apiclient, **kwargs):
+ """List all Networks matching criteria"""
+
+ cmd = listNetworks.listNetworksCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listNetworks(cmd))
+
+
+class NetworkACL:
+ """Manage Network ACL lifecycle"""
+
+ def __init__(self, items):
+ self.__dict__.update(items)
+
+ @classmethod
+ def create(cls, apiclient, services, networkid=None, protocol=None,
+ number=None, aclid=None, action='Allow', traffictype=None, cidrlist=[]):
+ """Create network ACL rules(Ingress/Egress)"""
+
+ cmd = createNetworkACL.createNetworkACLCmd()
+ if "networkid" in services:
+ cmd.networkid = services["networkid"]
+ elif networkid:
+ cmd.networkid = networkid
+
+ if "protocol" in services:
+ cmd.protocol = services["protocol"]
+ if services["protocol"] == 'ICMP':
+ cmd.icmptype = -1
+ cmd.icmpcode = -1
+ elif protocol:
+ cmd.protocol = protocol
+
+ if "startport" in services:
+ cmd.startport = services["startport"]
+ if "endport" in services:
+ cmd.endport = services["endport"]
+
+ if "cidrlist" in services:
+ cmd.cidrlist = services["cidrlist"]
+ elif cidrlist:
+ cmd.cidrlist = cidrlist
+
+ if "traffictype" in services:
+ cmd.traffictype = services["traffictype"]
+ elif traffictype:
+ cmd.traffictype = traffictype
+
+ if "action" in services:
+ cmd.action = services["action"]
+ elif action:
+ cmd.action = action
+
+ if "number" in services:
+ cmd.number = services["number"]
+ elif number:
+ cmd.number = number
+
+ if "aclid" in services:
+ cmd.aclid = services["aclid"]
+ elif aclid:
+ cmd.aclid = aclid
+
+ # Defaulted to Ingress
+ return NetworkACL(apiclient.createNetworkACL(cmd).__dict__)
+
+ def delete(self, apiclient):
+ """Delete network acl"""
+
+ cmd = deleteNetworkACL.deleteNetworkACLCmd()
+ cmd.id = self.id
+ return apiclient.deleteNetworkACL(cmd)
+
+ @classmethod
+ def list(cls, apiclient, **kwargs):
+ """List Network ACLs"""
+
+ cmd = listNetworkACLs.listNetworkACLsCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listNetworkACLs(cmd))
+
+
+class NetworkACLList:
+ """Manage Network ACL lists lifecycle"""
+
+ def __init__(self, items):
+ self.__dict__.update(items)
+
+ @classmethod
+ def create(cls, apiclient, services, name=None, description=None, vpcid=None):
+ """Create network ACL container list"""
+
+ cmd = createNetworkACLList.createNetworkACLListCmd()
+ if "name" in services:
+ cmd.name = services["name"]
+ elif name:
+ cmd.name = name
+
+ if "description" in services:
+ cmd.description = services["description"]
+ elif description:
+ cmd.description = description
+
+ if "vpcid" in services:
+ cmd.vpcid = services["vpcid"]
+ elif vpcid:
+ cmd.vpcid = vpcid
+
+ return NetworkACLList(apiclient.createNetworkACLList(cmd).__dict__)
+
+ def delete(self, apiclient):
+ """Delete network acl list"""
+
+ cmd = deleteNetworkACLList.deleteNetworkACLListCmd()
+ cmd.id = self.id
+ return apiclient.deleteNetworkACLList(cmd)
+
+ @classmethod
+ def list(cls, apiclient, **kwargs):
+ """List Network ACL lists"""
+
+ cmd = listNetworkACLLists.listNetworkACLListsCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listNetworkACLLists(cmd))
+
+
+class Vpn:
+ """Manage VPN life cycle"""
+
+ def __init__(self, items):
+ self.__dict__.update(items)
+
+ @classmethod
+ def create(cls, apiclient, publicipid, account=None, domainid=None,
+ projectid=None, networkid=None, vpcid=None):
+ """Create VPN for Public IP address"""
+ cmd = createRemoteAccessVpn.createRemoteAccessVpnCmd()
+ cmd.publicipid = publicipid
+ if account:
+ cmd.account = account
+ if domainid:
+ cmd.domainid = domainid
+ if projectid:
+ cmd.projectid = projectid
+ if networkid:
+ cmd.networkid = networkid
+ if vpcid:
+ cmd.vpcid = vpcid
+ return Vpn(apiclient.createRemoteAccessVpn(cmd).__dict__)
+
+ def delete(self, apiclient):
+ """Delete remote VPN access"""
+
+ cmd = deleteRemoteAccessVpn.deleteRemoteAccessVpnCmd()
+ cmd.publicipid = self.publicipid
+ apiclient.deleteRemoteAccessVpn(cmd)
+
+ @classmethod
+ def list(cls, apiclient, **kwargs):
+ """List all VPN matching criteria"""
+
+ cmd = listRemoteAccessVpns.listRemoteAccessVpnsCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listRemoteAccessVpns(cmd))
+
+
+class VpnUser:
+ """Manage VPN user"""
+
+ def __init__(self, items):
+ self.__dict__.update(items)
+
+ @classmethod
+ def create(cls, apiclient, username, password, account=None, domainid=None,
+ projectid=None, rand_name=True):
+ """Create VPN user"""
+ cmd = addVpnUser.addVpnUserCmd()
+ cmd.username = "-".join([username,
+ random_gen()]) if rand_name else username
+ cmd.password = password
+
+ if account:
+ cmd.account = account
+ if domainid:
+ cmd.domainid = domainid
+ if projectid:
+ cmd.projectid = projectid
+ return VpnUser(apiclient.addVpnUser(cmd).__dict__)
+
+ def delete(self, apiclient, projectid=None):
+ """Remove VPN user"""
+
+ cmd = removeVpnUser.removeVpnUserCmd()
+ cmd.username = self.username
+ if projectid:
+ cmd.projectid = projectid
+ else:
+ cmd.account = self.account
+ cmd.domainid = self.domainid
+ apiclient.removeVpnUser(cmd)
+
+ @classmethod
+ def list(cls, apiclient, **kwargs):
+ """List all VPN Users matching criteria"""
+
+ cmd = listVpnUsers.listVpnUsersCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listVpnUsers(cmd))
+
+
+class Zone:
+ """Manage Zone"""
+
+ def __init__(self, items):
+ self.__dict__.update(items)
+
+ @classmethod
+ def create(cls, apiclient, services, domainid=None):
+ """Create zone"""
+ cmd = createZone.createZoneCmd()
+ cmd.dns1 = services["dns1"]
+ cmd.internaldns1 = services["internaldns1"]
+ cmd.name = services["name"]
+ cmd.networktype = services["networktype"]
+
+ if "dns2" in services:
+ cmd.dns2 = services["dns2"]
+ if "internaldns2" in services:
+ cmd.internaldns2 = services["internaldns2"]
+ if domainid:
+ cmd.domainid = domainid
+ if "securitygroupenabled" in services:
+ cmd.securitygroupenabled = services["securitygroupenabled"]
+
+ return Zone(apiclient.createZone(cmd).__dict__)
+
+ def delete(self, apiclient):
+ """Delete Zone"""
+
+ cmd = deleteZone.deleteZoneCmd()
+ cmd.id = self.id
+ apiclient.deleteZone(cmd)
+
+ def update(self, apiclient, **kwargs):
+ """Update the zone"""
+
+ cmd = updateZone.updateZoneCmd()
+ cmd.id = self.id
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return apiclient.updateZone(cmd)
+
+ @classmethod
+ def list(cls, apiclient, **kwargs):
+ """List all Zones matching criteria"""
+
+ cmd = listZones.listZonesCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listZones(cmd))
+
+
+class Pod:
+ """Manage Pod"""
+
+ def __init__(self, items):
+ self.__dict__.update(items)
+
+ @classmethod
+ def create(cls, apiclient, services):
+ """Create Pod"""
+ cmd = createPod.createPodCmd()
+ cmd.gateway = services["gateway"]
+ cmd.netmask = services["netmask"]
+ cmd.name = services["name"]
+ cmd.startip = services["startip"]
+ cmd.endip = services["endip"]
+ cmd.zoneid = services["zoneid"]
+
+ return Pod(apiclient.createPod(cmd).__dict__)
+
+ def delete(self, apiclient):
+ """Delete Pod"""
+
+ cmd = deletePod.deletePodCmd()
+ cmd.id = self.id
+ apiclient.deletePod(cmd)
+
+ @classmethod
+ def list(cls, apiclient, **kwargs):
+ "Returns a default pod for specified zone"
+
+ cmd = listPods.listPodsCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return apiclient.listPods(cmd)
+
+
+class PublicIpRange:
+ """Manage VlanIpRange"""
+
+ def __init__(self, items):
+ self.__dict__.update(items)
+
+ @classmethod
+ def create(cls, apiclient, services):
+ """Create VlanIpRange"""
+
+ cmd = createVlanIpRange.createVlanIpRangeCmd()
+ cmd.gateway = services["gateway"]
+ cmd.netmask = services["netmask"]
+ cmd.forvirtualnetwork = services["forvirtualnetwork"]
+ cmd.startip = services["startip"]
+ cmd.endip = services["endip"]
+ cmd.zoneid = services["zoneid"]
+ if "podid" in services:
+ cmd.podid = services["podid"]
+ cmd.vlan = services["vlan"]
+
+ return PublicIpRange(apiclient.createVlanIpRange(cmd).__dict__)
+
+ def delete(self, apiclient):
+ """Delete VlanIpRange"""
+
+ cmd = deleteVlanIpRange.deleteVlanIpRangeCmd()
+ cmd.id = self.vlan.id
+ apiclient.deleteVlanIpRange(cmd)
+
+ @classmethod
+ def list(cls, apiclient, **kwargs):
+ """Lists all VLAN IP ranges."""
+
+ cmd = listVlanIpRanges.listVlanIpRangesCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listVlanIpRanges(cmd))
+
+ @classmethod
+ def dedicate(cls, apiclient, id, account=None, domainid=None, projectid=None):
+ """Dedicate VLAN IP range"""
+
+ cmd = dedicatePublicIpRange.dedicatePublicIpRangeCmd()
+ cmd.id = id
+ cmd.account = account
+ cmd.domainid = domainid
+ cmd.projectid = projectid
+ return PublicIpRange(apiclient.dedicatePublicIpRange(cmd).__dict__)
+
+ def release(self, apiclient):
+ """Release VLAN IP range"""
+
+ cmd = releasePublicIpRange.releasePublicIpRangeCmd()
+ cmd.id = self.vlan.id
+ return apiclient.releasePublicIpRange(cmd)
+
+
+class PortablePublicIpRange:
+ """Manage portable public Ip Range"""
+
+ def __init__(self, items):
+ self.__dict__.update(items)
+
+ @classmethod
+ def create(cls, apiclient, services):
+ """Create portable public Ip Range"""
+
+ cmd = createPortableIpRange.createPortableIpRangeCmd()
+ cmd.gateway = services["gateway"]
+ cmd.netmask = services["netmask"]
+ cmd.startip = services["startip"]
+ cmd.endip = services["endip"]
+ cmd.regionid = services["regionid"]
+
+ if "vlan" in services:
+ cmd.vlan = services["vlan"]
+
+ return PortablePublicIpRange(apiclient.createPortableIpRange(cmd).__dict__)
+
+ def delete(self, apiclient):
+ """Delete portable IpRange"""
+
+ cmd = deletePortableIpRange.deletePortableIpRangeCmd()
+ cmd.id = self.id
+ apiclient.deletePortableIpRange(cmd)
+
+ @classmethod
+ def list(cls, apiclient, **kwargs):
+ """Lists all portable public IP ranges."""
+
+ cmd = listPortableIpRanges.listPortableIpRangesCmd()
+ [setattr(cmd, k, v) for k, v in kwargs.items()]
+ return(apiclient.listPortableIpRanges(cmd))
+
+class SecondaryStagingStore:
+ """Manage Staging Store"""
+
+ def __init__(self, items):
+ self.__dict__.update(items)
+
+ @classmethod
+ def create(cls, apiclient, url, provider, services=None):
+ """Create Staging Storage"""
+ cmd = createSecondaryStagingStore.createSecondaryStagingStoreCmd()
+ cmd.url = url
+ cmd.provider = provider
+ if services:
+ if "zoneid" in services:
+ cmd.zoneid = services["zoneid"]
+ if "details" in services:
+ cmd.details = services["details"]
+ if "scope" in services:
+ cmd.scope = services["scope"]
+
+ return SecondaryStagingStore(apiclient.createSecondaryStagingStore(cmd).__dict__)
+
+ def delete(self, apiclient):
+ """Delete Staging Storage"""
+ cmd = deleteSecondaryStagingStore.deleteSecondaryStagingStoreCmd()
+ cmd.id = self.id
+ apiclient.deleteSecondaryStagingStore(c
<TRUNCATED>
[04/18] Marvin + test changes from master Signed-off-by:
SrikanteswaraRao Talluri
Posted by da...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/tools/marvin/marvin/integration/lib/common.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/integration/lib/common.py b/tools/marvin/marvin/integration/lib/common.py
deleted file mode 100644
index 02fa5f1..0000000
--- a/tools/marvin/marvin/integration/lib/common.py
+++ /dev/null
@@ -1,1036 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-"""Common functions
-"""
-
-#Import Local Modules
-from marvin.cloudstackAPI import (listConfigurations,
- listPhysicalNetworks,
- listRegions,
- addNetworkServiceProvider,
- updateNetworkServiceProvider,
- listDomains,
- listZones,
- listPods,
- listOsTypes,
- listTemplates,
- updateResourceLimit,
- listRouters,
- listNetworks,
- listClusters,
- listSystemVms,
- listStoragePools,
- listVirtualMachines,
- listLoadBalancerRuleInstances,
- listFirewallRules,
- listVolumes,
- listIsos,
- listAccounts,
- listSnapshotPolicies,
- listDiskOfferings,
- listVlanIpRanges,
- listUsageRecords,
- listNetworkServiceProviders,
- listHosts,
- listPublicIpAddresses,
- listPortForwardingRules,
- listLoadBalancerRules,
- listSnapshots,
- listUsers,
- listEvents,
- listServiceOfferings,
- listVirtualRouterElements,
- listNetworkOfferings,
- listResourceLimits,
- listVPCOfferings)
-from marvin.integration.lib.base import (Configurations,
- NetScaler,
- Template,
- Resources,
- PhysicalNetwork,
- Host,
- PublicIPAddress,
- NetworkOffering,
- Network,
- FireWallRule,
- NATRule,
- StaticNATRule)
-from marvin.integration.lib.utils import (get_process_status,
- xsplit,
- validateList)
-
-from marvin.sshClient import SshClient
-from marvin.codes import (PASS, ISOLATED_NETWORK, VPC_NETWORK,
- BASIC_ZONE, FAIL, NAT_RULE, STATIC_NAT_RULE)
-import random
-
-#Import System modules
-import time
-
-
-def is_config_suitable(apiclient, name, value):
- """
- Ensure if the deployment has the expected `value` for the global setting `name'
- @return: true if value is set, else false
- """
- configs = Configurations.list(apiclient, name=name)
- assert(configs is not None and isinstance(configs, list) and len(configs) > 0)
- return configs[0].value == value
-
-def wait_for_cleanup(apiclient, configs=None):
- """Sleeps till the cleanup configs passed"""
-
- # Configs list consists of the list of global configs
- if not isinstance(configs, list):
- return
- for config in configs:
- cmd = listConfigurations.listConfigurationsCmd()
- cmd.name = config
- cmd.listall = True
- try:
- config_descs = apiclient.listConfigurations(cmd)
- except Exception as e:
- raise Exception("Failed to fetch configurations: %s" % e)
-
- if not isinstance(config_descs, list):
- raise Exception("List configs didn't returned a valid data")
-
- config_desc = config_descs[0]
- # Sleep for the config_desc.value time
- time.sleep(int(config_desc.value))
- return
-
-def add_netscaler(apiclient, zoneid, NSservice):
- """ Adds Netscaler device and enables NS provider"""
-
- cmd = listPhysicalNetworks.listPhysicalNetworksCmd()
- cmd.zoneid = zoneid
- physical_networks = apiclient.listPhysicalNetworks(cmd)
- if isinstance(physical_networks, list):
- physical_network = physical_networks[0]
-
- cmd = listNetworkServiceProviders.listNetworkServiceProvidersCmd()
- cmd.name = 'Netscaler'
- cmd.physicalnetworkid=physical_network.id
- nw_service_providers = apiclient.listNetworkServiceProviders(cmd)
-
- if isinstance(nw_service_providers, list):
- netscaler_provider = nw_service_providers[0]
- else:
- cmd1 = addNetworkServiceProvider.addNetworkServiceProviderCmd()
- cmd1.name = 'Netscaler'
- cmd1.physicalnetworkid = physical_network.id
- netscaler_provider = apiclient.addNetworkServiceProvider(cmd1)
-
- netscaler = NetScaler.add(
- apiclient,
- NSservice,
- physicalnetworkid=physical_network.id
- )
- if netscaler_provider.state != 'Enabled':
- cmd = updateNetworkServiceProvider.updateNetworkServiceProviderCmd()
- cmd.id = netscaler_provider.id
- cmd.state = 'Enabled'
- apiclient.updateNetworkServiceProvider(cmd)
-
- return netscaler
-
-def get_region(apiclient, services=None):
- "Returns a default region"
-
- cmd = listRegions.listRegionsCmd()
- if services:
- if "regionid" in services:
- cmd.id = services["regionid"]
-
- regions = apiclient.listRegions(cmd)
-
- if isinstance(regions, list):
- assert len(regions) > 0
- return regions[0]
- else:
- raise Exception("Failed to find specified region.")
-
-def get_domain(apiclient, services=None):
- "Returns a default domain"
-
- cmd = listDomains.listDomainsCmd()
- if services:
- if "domainid" in services:
- cmd.id = services["domainid"]
-
- domains = apiclient.listDomains(cmd)
-
- if isinstance(domains, list):
- assert len(domains) > 0
- return domains[0]
- else:
- raise Exception("Failed to find specified domain.")
-
-
-def get_zone(apiclient, services=None):
- "Returns a default zone"
-
- cmd = listZones.listZonesCmd()
- if services:
- if "zoneid" in services:
- cmd.id = services["zoneid"]
-
- zones = apiclient.listZones(cmd)
-
- if isinstance(zones, list):
- assert len(zones) > 0, "There are no available zones in the deployment"
- return zones[0]
- else:
- raise Exception("Failed to find specified zone.")
-
-
-def get_pod(apiclient, zoneid, services=None):
- "Returns a default pod for specified zone"
-
- cmd = listPods.listPodsCmd()
- cmd.zoneid = zoneid
-
- if services:
- if "podid" in services:
- cmd.id = services["podid"]
-
- pods = apiclient.listPods(cmd)
-
- if isinstance(pods, list):
- assert len(pods) > 0, "No pods found for zone %s"%zoneid
- return pods[0]
- else:
- raise Exception("Exception: Failed to find specified pod.")
-
-
-def get_template(apiclient, zoneid, ostype, services=None,
- templatefilter='featured',
- templatetype='BUILTIN'):
- "Returns a featured built in template in given zone"
-
- cmd = listTemplates.listTemplatesCmd()
- cmd.templatefilter = templatefilter
- cmd.zoneid = zoneid
-
- if services:
- if "template" in services:
- cmd.id = services["template"]
-
- list_templates = apiclient.listTemplates(cmd)
-
- if isinstance(list_templates, list):
- assert len(list_templates) > 0, "received empty response on featured templates"
- for template in list_templates:
- if template.isready and template.templatetype == templatetype:
- return template
-
- raise Exception("Exception: Failed to find built in template which is in "
- "ready state: %s" % templatetype)
- return
-
-
-def download_systemplates_sec_storage(server, services):
- """Download System templates on sec storage"""
-
- try:
- # Login to management server
- ssh = SshClient(
- server["ipaddress"],
- server["port"],
- server["username"],
- server["password"]
- )
- except Exception:
- raise Exception("SSH access failted for server with IP address: %s" %
- server["ipaddess"])
- # Mount Secondary Storage on Management Server
- cmds = [
- "mkdir -p %s" % services["mnt_dir"],
- "mount -t nfs %s:/%s %s" % (
- services["sec_storage"],
- services["path"],
- services["mnt_dir"]
- ),
- "%s -m %s -u %s -h %s -F" % (
- services["command"],
- services["mnt_dir"],
- services["download_url"],
- services["hypervisor"]
- )
- ]
- for c in cmds:
- result = ssh.execute(c)
-
- res = str(result)
-
- # Unmount the Secondary storage
- ssh.execute("umount %s" % (services["mnt_dir"]))
-
- if res.count("Successfully installed system VM template") == 1:
- return
- else:
- raise Exception("Failed to download System Templates on Sec Storage")
- return
-
-
-def wait_for_ssvms(apiclient, zoneid, podid, interval=60):
- """After setup wait for SSVMs to come Up"""
-
- time.sleep(interval)
- timeout = 40
- while True:
- list_ssvm_response = list_ssvms(
- apiclient,
- systemvmtype='secondarystoragevm',
- zoneid=zoneid,
- podid=podid
- )
- ssvm = list_ssvm_response[0]
- if ssvm.state != 'Running':
- # Sleep to ensure SSVMs are Up and Running
- time.sleep(interval)
- timeout = timeout - 1
- elif ssvm.state == 'Running':
- break
- elif timeout == 0:
- raise Exception("SSVM failed to come up")
- break
-
- timeout = 40
- while True:
- list_ssvm_response = list_ssvms(
- apiclient,
- systemvmtype='consoleproxy',
- zoneid=zoneid,
- podid=podid
- )
- cpvm = list_ssvm_response[0]
- if cpvm.state != 'Running':
- # Sleep to ensure SSVMs are Up and Running
- time.sleep(interval)
- timeout = timeout - 1
- elif cpvm.state == 'Running':
- break
- elif timeout == 0:
- raise Exception("CPVM failed to come up")
- break
- return
-
-def get_builtin_template_info(apiclient, zoneid):
- """Returns hypervisor specific infor for templates"""
-
- list_template_response = Template.list(
- apiclient,
- templatefilter='featured',
- zoneid=zoneid,
- )
-
- for b_template in list_template_response:
- if b_template.templatetype == 'BUILTIN':
- break
-
- extract_response = Template.extract(apiclient,
- b_template.id,
- 'HTTP_DOWNLOAD',
- zoneid)
-
- return extract_response.url, b_template.hypervisor, b_template.format
-
-def download_builtin_templates(apiclient, zoneid, hypervisor, host,
- linklocalip, interval=60):
- """After setup wait till builtin templates are downloaded"""
-
- # Change IPTABLES Rules
- get_process_status(
- host["ipaddress"],
- host["port"],
- host["username"],
- host["password"],
- linklocalip,
- "iptables -P INPUT ACCEPT"
- )
- time.sleep(interval)
- # Find the BUILTIN Templates for given Zone, Hypervisor
- list_template_response = list_templates(
- apiclient,
- hypervisor=hypervisor,
- zoneid=zoneid,
- templatefilter='self'
- )
-
- if not isinstance(list_template_response, list):
- raise Exception("Failed to download BUILTIN templates")
-
- # Ensure all BUILTIN templates are downloaded
- templateid = None
- for template in list_template_response:
- if template.templatetype == "BUILTIN":
- templateid = template.id
-
- # Sleep to ensure that template is in downloading state after adding
- # Sec storage
- time.sleep(interval)
- while True:
- template_response = list_templates(
- apiclient,
- id=templateid,
- zoneid=zoneid,
- templatefilter='self'
- )
- template = template_response[0]
- # If template is ready,
- # template.status = Download Complete
- # Downloading - x% Downloaded
- # Error - Any other string
- if template.status == 'Download Complete':
- break
-
- elif 'Downloaded' in template.status:
- time.sleep(interval)
-
- elif 'Installing' not in template.status:
- raise Exception("ErrorInDownload")
-
- return
-
-
-def update_resource_limit(apiclient, resourcetype, account=None,
- domainid=None, max=None, projectid=None):
- """Updates the resource limit to 'max' for given account"""
-
- cmd = updateResourceLimit.updateResourceLimitCmd()
- cmd.resourcetype = resourcetype
- if account:
- cmd.account = account
- if domainid:
- cmd.domainid = domainid
- if max:
- cmd.max = max
- if projectid:
- cmd.projectid = projectid
- apiclient.updateResourceLimit(cmd)
- return
-
-
-def list_os_types(apiclient, **kwargs):
- """List all os types matching criteria"""
-
- cmd = listOsTypes.listOsTypesCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listOsTypes(cmd))
-
-
-def list_routers(apiclient, **kwargs):
- """List all Routers matching criteria"""
-
- cmd = listRouters.listRoutersCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listRouters(cmd))
-
-
-def list_zones(apiclient, **kwargs):
- """List all Zones matching criteria"""
-
- cmd = listZones.listZonesCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listZones(cmd))
-
-
-def list_networks(apiclient, **kwargs):
- """List all Networks matching criteria"""
-
- cmd = listNetworks.listNetworksCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listNetworks(cmd))
-
-
-def list_clusters(apiclient, **kwargs):
- """List all Clusters matching criteria"""
-
- cmd = listClusters.listClustersCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listClusters(cmd))
-
-
-def list_ssvms(apiclient, **kwargs):
- """List all SSVMs matching criteria"""
-
- cmd = listSystemVms.listSystemVmsCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listSystemVms(cmd))
-
-
-def list_storage_pools(apiclient, **kwargs):
- """List all storage pools matching criteria"""
-
- cmd = listStoragePools.listStoragePoolsCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listStoragePools(cmd))
-
-
-def list_virtual_machines(apiclient, **kwargs):
- """List all VMs matching criteria"""
-
- cmd = listVirtualMachines.listVirtualMachinesCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listVirtualMachines(cmd))
-
-
-def list_hosts(apiclient, **kwargs):
- """List all Hosts matching criteria"""
-
- cmd = listHosts.listHostsCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listHosts(cmd))
-
-
-def list_configurations(apiclient, **kwargs):
- """List configuration with specified name"""
-
- cmd = listConfigurations.listConfigurationsCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listConfigurations(cmd))
-
-
-def list_publicIP(apiclient, **kwargs):
- """List all Public IPs matching criteria"""
-
- cmd = listPublicIpAddresses.listPublicIpAddressesCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listPublicIpAddresses(cmd))
-
-
-def list_nat_rules(apiclient, **kwargs):
- """List all NAT rules matching criteria"""
-
- cmd = listPortForwardingRules.listPortForwardingRulesCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listPortForwardingRules(cmd))
-
-
-def list_lb_rules(apiclient, **kwargs):
- """List all Load balancing rules matching criteria"""
-
- cmd = listLoadBalancerRules.listLoadBalancerRulesCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listLoadBalancerRules(cmd))
-
-
-def list_lb_instances(apiclient, **kwargs):
- """List all Load balancing instances matching criteria"""
-
- cmd = listLoadBalancerRuleInstances.listLoadBalancerRuleInstancesCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listLoadBalancerRuleInstances(cmd))
-
-
-def list_firewall_rules(apiclient, **kwargs):
- """List all Firewall Rules matching criteria"""
-
- cmd = listFirewallRules.listFirewallRulesCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listFirewallRules(cmd))
-
-
-def list_volumes(apiclient, **kwargs):
- """List all volumes matching criteria"""
-
- cmd = listVolumes.listVolumesCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listVolumes(cmd))
-
-
-def list_isos(apiclient, **kwargs):
- """Lists all available ISO files."""
-
- cmd = listIsos.listIsosCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listIsos(cmd))
-
-
-def list_snapshots(apiclient, **kwargs):
- """List all snapshots matching criteria"""
-
- cmd = listSnapshots.listSnapshotsCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listSnapshots(cmd))
-
-
-def list_templates(apiclient, **kwargs):
- """List all templates matching criteria"""
-
- cmd = listTemplates.listTemplatesCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listTemplates(cmd))
-
-
-def list_domains(apiclient, **kwargs):
- """Lists domains"""
-
- cmd = listDomains.listDomainsCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listDomains(cmd))
-
-
-def list_accounts(apiclient, **kwargs):
- """Lists accounts and provides detailed account information for
- listed accounts"""
-
- cmd = listAccounts.listAccountsCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listAccounts(cmd))
-
-
-def list_users(apiclient, **kwargs):
- """Lists users and provides detailed account information for
- listed users"""
-
- cmd = listUsers.listUsersCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listUsers(cmd))
-
-
-def list_snapshot_policy(apiclient, **kwargs):
- """Lists snapshot policies."""
-
- cmd = listSnapshotPolicies.listSnapshotPoliciesCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listSnapshotPolicies(cmd))
-
-
-def list_events(apiclient, **kwargs):
- """Lists events"""
-
- cmd = listEvents.listEventsCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listEvents(cmd))
-
-
-def list_disk_offering(apiclient, **kwargs):
- """Lists all available disk offerings."""
-
- cmd = listDiskOfferings.listDiskOfferingsCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listDiskOfferings(cmd))
-
-
-def list_service_offering(apiclient, **kwargs):
- """Lists all available service offerings."""
-
- cmd = listServiceOfferings.listServiceOfferingsCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listServiceOfferings(cmd))
-
-
-def list_vlan_ipranges(apiclient, **kwargs):
- """Lists all VLAN IP ranges."""
-
- cmd = listVlanIpRanges.listVlanIpRangesCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listVlanIpRanges(cmd))
-
-
-def list_usage_records(apiclient, **kwargs):
- """Lists usage records for accounts"""
-
- cmd = listUsageRecords.listUsageRecordsCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listUsageRecords(cmd))
-
-
-def list_nw_service_prividers(apiclient, **kwargs):
- """Lists Network service providers"""
-
- cmd = listNetworkServiceProviders.listNetworkServiceProvidersCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listNetworkServiceProviders(cmd))
-
-
-def list_virtual_router_elements(apiclient, **kwargs):
- """Lists Virtual Router elements"""
-
- cmd = listVirtualRouterElements.listVirtualRouterElementsCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listVirtualRouterElements(cmd))
-
-
-def list_network_offerings(apiclient, **kwargs):
- """Lists network offerings"""
-
- cmd = listNetworkOfferings.listNetworkOfferingsCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listNetworkOfferings(cmd))
-
-
-def list_resource_limits(apiclient, **kwargs):
- """Lists resource limits"""
-
- cmd = listResourceLimits.listResourceLimitsCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listResourceLimits(cmd))
-
-def list_vpc_offerings(apiclient, **kwargs):
- """ Lists VPC offerings """
-
- cmd = listVPCOfferings.listVPCOfferingsCmd()
- [setattr(cmd, k, v) for k, v in kwargs.items()]
- return(apiclient.listVPCOfferings(cmd))
-
-def update_resource_count(apiclient, domainid, accountid=None,
- projectid=None, rtype=None):
- """updates the resource count
- 0 - VM
- 1 - Public IP
- 2 - Volume
- 3 - Snapshot
- 4 - Template
- 5 - Projects
- 6 - Network
- 7 - VPC
- 8 - CPUs
- 9 - RAM
- 10 - Primary (shared) storage (Volumes)
- 11 - Secondary storage (Snapshots, Templates & ISOs)
- """
-
- Resources.updateCount(apiclient,
- domainid=domainid,
- account=accountid if accountid else None,
- projectid=projectid if projectid else None,
- resourcetype=rtype if rtype else None
- )
- return
-
-def findSuitableHostForMigration(apiclient, vmid):
- """Returns a suitable host for VM migration"""
- suitableHost = None
- try:
- hosts = Host.listForMigration(apiclient, virtualmachineid=vmid,
- )
- except Exception as e:
- raise Exception("Exception while getting hosts list suitable for migration: %s" % e)
-
- suitablehosts = []
- if isinstance(hosts, list) and len(hosts) > 0:
- suitablehosts = [host for host in hosts if (str(host.resourcestate).lower() == "enabled"\
- and str(host.state).lower() == "up")]
- if len(suitablehosts)>0:
- suitableHost = suitablehosts[0]
-
- return suitableHost
-
-def get_resource_type(resource_id):
- """Returns resource type"""
-
- lookup = { 0: "VM",
- 1: "Public IP",
- 2: "Volume",
- 3: "Snapshot",
- 4: "Template",
- 5: "Projects",
- 6: "Network",
- 7: "VPC",
- 8: "CPUs",
- 9: "RAM",
- 10: "Primary (shared) storage (Volumes)",
- 11: "Secondary storage (Snapshots, Templates & ISOs)"
- }
-
- return lookup[resource_id]
-
-def get_portable_ip_range_services(config):
- """ Reads config values related to portable ip and fills up
- services accordingly"""
-
- services = {}
- attributeError = False
-
- if config.portableIpRange.startip:
- services["startip"] = config.portableIpRange.startip
- else:
- attributeError = True
-
- if config.portableIpRange.endip:
- services["endip"] = config.portableIpRange.endip
- else:
- attributeError = True
-
- if config.portableIpRange.netmask:
- services["netmask"] = config.portableIpRange.netmask
- else:
- attributeError = True
-
- if config.portableIpRange.gateway:
- services["gateway"] = config.portableIpRange.gateway
- else:
- attributeError = True
-
- if config.portableIpRange.vlan:
- services["vlan"] = config.portableIpRange.vlan
-
- if attributeError:
- services = None
-
- return services
-
-def get_free_vlan(apiclient, zoneid):
- """
- Find an unallocated VLAN outside the range allocated to the physical network.
-
- @note: This does not guarantee that the VLAN is available for use in
- the deployment's network gear
- @return: physical_network, shared_vlan_tag
- """
- list_physical_networks_response = PhysicalNetwork.list(
- apiclient,
- zoneid=zoneid
- )
- assert isinstance(list_physical_networks_response, list)
- assert len(list_physical_networks_response) > 0, "No physical networks found in zone %s" % zoneid
-
- physical_network = list_physical_networks_response[0]
-
- networks = list_networks(apiclient, zoneid= zoneid, type='Shared')
- usedVlanIds = []
-
- if isinstance(networks, list) and len(networks) > 0:
- usedVlanIds = [int(nw.vlan) for nw in networks if nw.vlan!="untagged"]
-
- if hasattr(physical_network, "vlan") is False:
- while True:
- shared_ntwk_vlan = random.randrange(1,4095)
- if shared_ntwk_vlan in usedVlanIds:
- continue
- else:
- break
- else:
- vlans = xsplit(physical_network.vlan, ['-', ','])
-
- assert len(vlans) > 0
- assert int(vlans[0]) < int(vlans[-1]), "VLAN range %s was improperly split" % physical_network.vlan
-
- retriesCount = 20 #Assuming random function will give different integer each time
-
- shared_ntwk_vlan = None
-
- while True:
-
- if retriesCount == 0:
- break
-
- free_vlan = int(vlans[-1]) + random.randrange(1, 20)
-
- if free_vlan > 4095:
- free_vlan = int(vlans[0]) - random.randrange(1, 20)
- if free_vlan < 0 or (free_vlan in usedVlanIds):
- retriesCount -= 1
- continue
- else:
- shared_ntwk_vlan = free_vlan
- break
-
- return physical_network, shared_ntwk_vlan
-
-def setNonContiguousVlanIds(apiclient, zoneid):
- """
- Form the non contiguous ranges based on currently assigned range in physical network
- """
-
- NonContigVlanIdsAcquired = False
-
- list_physical_networks_response = PhysicalNetwork.list(
- apiclient,
- zoneid=zoneid
- )
- assert isinstance(list_physical_networks_response, list)
- assert len(list_physical_networks_response) > 0, "No physical networks found in zone %s" % zoneid
-
- for physical_network in list_physical_networks_response:
-
- vlans = xsplit(physical_network.vlan, ['-', ','])
-
- assert len(vlans) > 0
- assert int(vlans[0]) < int(vlans[-1]), "VLAN range %s was improperly split" % physical_network.vlan
-
- # Keep some gap between existing vlan and the new vlans which we are going to add
- # So that they are non contiguous
-
- non_contig_end_vlan_id = int(vlans[-1]) + 6
- non_contig_start_vlan_id = int(vlans[0]) - 6
-
- # Form ranges which are consecutive to existing ranges but not immediately contiguous
- # There should be gap in between existing range and new non contiguous ranage
-
- # If you can't add range after existing range, because it's crossing 4095, then
- # select VLAN ids before the existing range such that they are greater than 0, and
- # then add this non contiguoud range
- vlan = { "partial_range": ["",""], "full_range": ""}
-
- if non_contig_end_vlan_id < 4095:
- vlan["partial_range"][0] = str(non_contig_end_vlan_id - 4) + '-' + str(non_contig_end_vlan_id - 3)
- vlan["partial_range"][1] = str(non_contig_end_vlan_id - 1) + '-' + str(non_contig_end_vlan_id)
- vlan["full_range"] = str(non_contig_end_vlan_id - 4) + '-' + str(non_contig_end_vlan_id)
- NonContigVlanIdsAcquired = True
-
- elif non_contig_start_vlan_id > 0:
- vlan["partial_range"][0] = str(non_contig_start_vlan_id) + '-' + str(non_contig_start_vlan_id + 1)
- vlan["partial_range"][1] = str(non_contig_start_vlan_id + 3) + '-' + str(non_contig_start_vlan_id + 4)
- vlan["full_range"] = str(non_contig_start_vlan_id) + '-' + str(non_contig_start_vlan_id + 4)
- NonContigVlanIdsAcquired = True
-
- else:
- NonContigVlanIdsAcquired = False
-
- # If failed to get relevant vlan ids, continue to next physical network
- # else break from loop as we have hot the non contiguous vlan ids for the test purpose
-
- if not NonContigVlanIdsAcquired:
- continue
- else:
- break
-
- # If even through looping from all existing physical networks, failed to get relevant non
- # contiguous vlan ids, then fail the test case
-
- if not NonContigVlanIdsAcquired:
- return None, None
-
- return physical_network, vlan
-
-def is_public_ip_in_correct_state(apiclient, ipaddressid, state):
- """ Check if the given IP is in the correct state (given)
- and return True/False accordingly"""
- retriesCount = 10
- while True:
- portableips = PublicIPAddress.list(apiclient, id=ipaddressid)
- assert validateList(portableips)[0] == PASS, "IPs list validation failed"
- if str(portableips[0].state).lower() == state:
- break
- elif retriesCount == 0:
- return False
- else:
- retriesCount -= 1
- time.sleep(60)
- continue
- return True
-
-def setSharedNetworkParams(networkServices, range=20):
- """Fill up the services dictionary for shared network using random subnet"""
-
- # @range: range decides the endip. Pass the range as "x" if you want the difference between the startip
- # and endip as "x"
- # Set the subnet number of shared networks randomly prior to execution
- # of each test case to avoid overlapping of ip addresses
- shared_network_subnet_number = random.randrange(1,254)
-
- networkServices["gateway"] = "172.16."+str(shared_network_subnet_number)+".1"
- networkServices["startip"] = "172.16."+str(shared_network_subnet_number)+".2"
- networkServices["endip"] = "172.16."+str(shared_network_subnet_number)+"."+str(range+1)
- networkServices["netmask"] = "255.255.255.0"
- return networkServices
-
-def createEnabledNetworkOffering(apiclient, networkServices):
- """Create and enable network offering according to the type
-
- @output: List, containing [ Result,Network Offering,Reason ]
- Ist Argument('Result') : FAIL : If exception or assertion error occurs
- PASS : If network offering
- is created and enabled successfully
- IInd Argument(Net Off) : Enabled network offering
- In case of exception or
- assertion error, it will be None
- IIIrd Argument(Reason) : Reason for failure,
- default to None
- """
- try:
- resultSet = [FAIL, None, None]
- # Create network offering
- network_offering = NetworkOffering.create(apiclient, networkServices, conservemode=False)
-
- # Update network offering state from disabled to enabled.
- NetworkOffering.update(network_offering, apiclient, id=network_offering.id,
- state="enabled")
- except Exception as e:
- resultSet[2] = e
- return resultSet
- return [PASS, network_offering, None]
-
-def shouldTestBeSkipped(networkType, zoneType):
- """Decide which test to skip, according to type of network and zone type"""
-
- # If network type is isolated or vpc and zone type is basic, then test should be skipped
- skipIt = False
- if ((networkType.lower() == str(ISOLATED_NETWORK).lower() or networkType.lower() == str(VPC_NETWORK).lower())
- and (zoneType.lower() == BASIC_ZONE)):
- skipIt = True
- return skipIt
-
-def verifyNetworkState(apiclient, networkid, state):
- """List networks and check if the network state matches the given state"""
- try:
- networks = Network.list(apiclient, id=networkid)
- except Exception as e:
- raise Exception("Failed while fetching network list with error: %s" % e)
- assert validateList(networks)[0] == PASS, "Networks list validation failed, list is %s" % networks
- assert str(networks[0].state).lower() == state, "network state should be %s, it is %s" % (state, networks[0].state)
- return
-
-def verifyComputeOfferingCreation(apiclient, computeofferingid):
- """List Compute offerings by ID and verify that the offering exists"""
-
- cmd = listServiceOfferings.listServiceOfferingsCmd()
- cmd.id = computeofferingid
- serviceOfferings = None
- try:
- serviceOfferings = apiclient.listServiceOfferings(cmd)
- except Exception:
- return FAIL
- if not (isinstance(serviceOfferings, list) and len(serviceOfferings) > 0):
- return FAIL
- return PASS
-
-def createNetworkRulesForVM(apiclient, virtualmachine, ruletype,
- account, networkruledata):
- """Acquire IP, create Firewall and NAT/StaticNAT rule
- (associating it with given vm) for that IP"""
-
- try:
- public_ip = PublicIPAddress.create(
- apiclient,accountid=account.name,
- zoneid=virtualmachine.zoneid,domainid=account.domainid,
- networkid=virtualmachine.nic[0].networkid)
-
- FireWallRule.create(
- apiclient,ipaddressid=public_ip.ipaddress.id,
- protocol='TCP', cidrlist=[networkruledata["fwrule"]["cidr"]],
- startport=networkruledata["fwrule"]["startport"],
- endport=networkruledata["fwrule"]["endport"]
- )
-
- if ruletype == NAT_RULE:
- # Create NAT rule
- NATRule.create(apiclient, virtualmachine,
- networkruledata["natrule"],ipaddressid=public_ip.ipaddress.id,
- networkid=virtualmachine.nic[0].networkid)
- elif ruletype == STATIC_NAT_RULE:
- # Enable Static NAT for VM
- StaticNATRule.enable(apiclient,public_ip.ipaddress.id,
- virtualmachine.id, networkid=virtualmachine.nic[0].networkid)
- except Exception as e:
- [FAIL, e]
- return [PASS, public_ip]
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/tools/marvin/marvin/integration/lib/utils.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/integration/lib/utils.py b/tools/marvin/marvin/integration/lib/utils.py
deleted file mode 100644
index 7e11d52..0000000
--- a/tools/marvin/marvin/integration/lib/utils.py
+++ /dev/null
@@ -1,453 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-"""Utilities functions
-"""
-
-import marvin
-import os
-import time
-import logging
-import string
-import random
-import imaplib
-import email
-import socket
-import urlparse
-import datetime
-from marvin.cloudstackAPI import cloudstackAPIClient, listHosts, listRouters
-from marvin.sshClient import SshClient
-from marvin.codes import (FAIL,
- PASS,
- MATCH_NOT_FOUND,
- INVALID_INPUT,
- EMPTY_LIST)
-
-def restart_mgmt_server(server):
- """Restarts the management server"""
-
- try:
- # Get the SSH client
- ssh = is_server_ssh_ready(
- server["ipaddress"],
- server["port"],
- server["username"],
- server["password"],
- )
- result = ssh.execute("/etc/init.d/cloud-management restart")
- res = str(result)
- # Server Stop - OK
- # Server Start - OK
- if res.count("OK") != 2:
- raise ("ErrorInReboot!")
- except Exception as e:
- raise e
- return
-
-
-def fetch_latest_mail(services, from_mail):
- """Fetch mail"""
-
- # Login to mail server to verify email
- mail = imaplib.IMAP4_SSL(services["server"])
- mail.login(
- services["email"],
- services["password"]
- )
- mail.list()
- mail.select(services["folder"])
- date = (datetime.date.today() - datetime.timedelta(1)).strftime("%d-%b-%Y")
-
- result, data = mail.uid(
- 'search',
- None,
- '(SENTSINCE {date} HEADER FROM "{mail}")'.format(
- date=date,
- mail=from_mail
- )
- )
- # Return False if email is not present
- if data == []:
- return False
-
- latest_email_uid = data[0].split()[-1]
- result, data = mail.uid('fetch', latest_email_uid, '(RFC822)')
- raw_email = data[0][1]
- email_message = email.message_from_string(raw_email)
- result = get_first_text_block(email_message)
- return result
-
-
-def get_first_text_block(email_message_instance):
- """fetches first text block from the mail"""
- maintype = email_message_instance.get_content_maintype()
- if maintype == 'multipart':
- for part in email_message_instance.get_payload():
- if part.get_content_maintype() == 'text':
- return part.get_payload()
- elif maintype == 'text':
- return email_message_instance.get_payload()
-
-
-def random_gen(id=None, size=6, chars=string.ascii_uppercase + string.digits):
- """Generate Random Strings of variable length"""
- randomstr = ''.join(random.choice(chars) for x in range(size))
- if id:
- return ''.join([id, '-', randomstr])
- return randomstr
-
-
-def cleanup_resources(api_client, resources):
- """Delete resources"""
- for obj in resources:
- obj.delete(api_client)
-
-
-def is_server_ssh_ready(ipaddress, port, username, password, retries=20, retryinterv=30, timeout=10.0, keyPairFileLocation=None):
- '''
- @Name: is_server_ssh_ready
- @Input: timeout: tcp connection timeout flag,
- others information need to be added
- @Output:object for SshClient
- Name of the function is little misnomer and is not
- verifying anything as such mentioned
- '''
-
- try:
- ssh = SshClient(
- host=ipaddress,
- port=port,
- user=username,
- passwd=password,
- keyPairFiles=keyPairFileLocation,
- retries=retries,
- delay=retryinterv,
- timeout=timeout)
- except Exception, e:
- raise Exception("SSH connection has Failed. Waited %ss. Error is %s" % (retries * retryinterv, str(e)))
- else:
- return ssh
-
-
-def format_volume_to_ext3(ssh_client, device="/dev/sda"):
- """Format attached storage to ext3 fs"""
- cmds = [
- "echo -e 'n\np\n1\n\n\nw' | fdisk %s" % device,
- "mkfs.ext3 %s1" % device,
- ]
- for c in cmds:
- ssh_client.execute(c)
-
-
-def fetch_api_client(config_file='datacenterCfg'):
- """Fetch the Cloudstack API Client"""
- config = marvin.configGenerator.get_setup_config(config_file)
- mgt = config.mgtSvr[0]
- testClientLogger = logging.getLogger("testClient")
- asyncTimeout = 3600
- return cloudstackAPIClient.CloudStackAPIClient(
- marvin.cloudstackConnection.cloudConnection(
- mgt,
- asyncTimeout,
- testClientLogger
- )
- )
-
-def get_host_credentials(config, hostip):
- """Get login information for a host `hostip` (ipv4) from marvin's `config`
-
- @return the tuple username, password for the host else raise keyerror"""
- for zone in config.zones:
- for pod in zone.pods:
- for cluster in pod.clusters:
- for host in cluster.hosts:
- if str(host.url).startswith('http'):
- hostname = urlparse.urlsplit(str(host.url)).netloc
- else:
- hostname = str(host.url)
- try:
- if socket.getfqdn(hostip) == socket.getfqdn(hostname):
- return host.username, host.password
- except socket.error, e:
- raise Exception("Unresolvable host %s error is %s" % (hostip, e))
- raise KeyError("Please provide the marvin configuration file with credentials to your hosts")
-
-
-def get_process_status(hostip, port, username, password, linklocalip, process, hypervisor=None):
- """Double hop and returns a process status"""
-
- #SSH to the machine
- ssh = SshClient(hostip, port, username, password)
- if (str(hypervisor).lower() == 'vmware'
- or str(hypervisor).lower() == 'hyperv'):
- ssh_command = "ssh -i /var/cloudstack/management/.ssh/id_rsa -ostricthostkeychecking=no "
- else:
- ssh_command = "ssh -i ~/.ssh/id_rsa.cloud -ostricthostkeychecking=no "
-
- ssh_command = ssh_command +\
- "-oUserKnownHostsFile=/dev/null -p 3922 %s %s" % (
- linklocalip,
- process)
-
- # Double hop into router
- timeout = 5
- # Ensure the SSH login is successful
- while True:
- res = ssh.execute(ssh_command)
-
- if res[0] != "Host key verification failed.":
- break
- elif timeout == 0:
- break
-
- time.sleep(5)
- timeout = timeout - 1
- return res
-
-
-def isAlmostEqual(first_digit, second_digit, range=0):
- digits_equal_within_range = False
-
- try:
- if ((first_digit - range) < second_digit < (first_digit + range)):
- digits_equal_within_range = True
- except Exception as e:
- raise e
- return digits_equal_within_range
-
-
-def xsplit(txt, seps):
- """
- Split a string in `txt` by list of delimiters in `seps`
- @param txt: string to split
- @param seps: list of separators
- @return: list of split units
- """
- default_sep = seps[0]
- for sep in seps[1:]: # we skip seps[0] because that's the default separator
- txt = txt.replace(sep, default_sep)
- return [i.strip() for i in txt.split(default_sep)]
-
-def get_hypervisor_type(apiclient):
-
- """Return the hypervisor type of the hosts in setup"""
-
- cmd = listHosts.listHostsCmd()
- cmd.type = 'Routing'
- cmd.listall = True
- hosts = apiclient.listHosts(cmd)
- hosts_list_validation_result = validateList(hosts)
- assert hosts_list_validation_result[0] == PASS, "host list validation failed"
- return hosts_list_validation_result[1].hypervisor
-
-def is_snapshot_on_nfs(apiclient, dbconn, config, zoneid, snapshotid):
- """
- Checks whether a snapshot with id (not UUID) `snapshotid` is present on the nfs storage
-
- @param apiclient: api client connection
- @param @dbconn: connection to the cloudstack db
- @param config: marvin configuration file
- @param zoneid: uuid of the zone on which the secondary nfs storage pool is mounted
- @param snapshotid: uuid of the snapshot
- @return: True if snapshot is found, False otherwise
- """
- # snapshot extension to be appended to the snapshot path obtained from db
- snapshot_extensions = {"vmware": ".ovf",
- "kvm": "",
- "xenserver": ".vhd"}
-
- qresultset = dbconn.execute(
- "select id from snapshots where uuid = '%s';" \
- % str(snapshotid)
- )
- if len(qresultset) == 0:
- raise Exception(
- "No snapshot found in cloudstack with id %s" % snapshotid)
-
-
- snapshotid = qresultset[0][0]
- qresultset = dbconn.execute(
- "select install_path,store_id from snapshot_store_ref where snapshot_id='%s' and store_role='Image';" % snapshotid
- )
-
- assert isinstance(qresultset, list), "Invalid db query response for snapshot %s" % snapshotid
-
- if len(qresultset) == 0:
- #Snapshot does not exist
- return False
-
- from base import ImageStore
- #pass store_id to get the exact storage pool where snapshot is stored
- secondaryStores = ImageStore.list(apiclient, zoneid=zoneid, id=int(qresultset[0][1]))
-
- assert isinstance(secondaryStores, list), "Not a valid response for listImageStores"
- assert len(secondaryStores) != 0, "No image stores found in zone %s" % zoneid
-
- secondaryStore = secondaryStores[0]
-
- if str(secondaryStore.providername).lower() != "nfs":
- raise Exception(
- "is_snapshot_on_nfs works only against nfs secondary storage. found %s" % str(secondaryStore.providername))
-
- hypervisor = get_hypervisor_type(apiclient)
- # append snapshot extension based on hypervisor, to the snapshot path
- snapshotPath = str(qresultset[0][0]) + snapshot_extensions[str(hypervisor).lower()]
-
- nfsurl = secondaryStore.url
- from urllib2 import urlparse
- parse_url = urlparse.urlsplit(nfsurl, scheme='nfs')
- host, path = parse_url.netloc, parse_url.path
-
- if not config.mgtSvr:
- raise Exception("Your marvin configuration does not contain mgmt server credentials")
- mgtSvr, user, passwd = config.mgtSvr[0].mgtSvrIp, config.mgtSvr[0].user, config.mgtSvr[0].passwd
-
- try:
- ssh_client = SshClient(
- mgtSvr,
- 22,
- user,
- passwd
- )
- cmds = [
- "mkdir -p %s /mnt/tmp",
- "mount -t %s %s%s /mnt/tmp" % (
- 'nfs',
- host,
- path,
- ),
- "test -f %s && echo 'snapshot exists'" % (
- os.path.join("/mnt/tmp", snapshotPath)
- ),
- ]
-
- for c in cmds:
- result = ssh_client.execute(c)
-
- # Unmount the Sec Storage
- cmds = [
- "cd",
- "umount /mnt/tmp",
- ]
- for c in cmds:
- ssh_client.execute(c)
- except Exception as e:
- raise Exception("SSH failed for management server: %s - %s" %
- (config.mgtSvr[0].mgtSvrIp, e))
- return 'snapshot exists' in result
-
-def validateList(inp):
- """
- @name: validateList
- @Description: 1. A utility function to validate
- whether the input passed is a list
- 2. The list is empty or not
- 3. If it is list and not empty, return PASS and first element
- 4. If not reason for FAIL
- @Input: Input to be validated
- @output: List, containing [ Result,FirstElement,Reason ]
- Ist Argument('Result') : FAIL : If it is not a list
- If it is list but empty
- PASS : If it is list and not empty
- IInd Argument('FirstElement'): If it is list and not empty,
- then first element
- in it, default to None
- IIIrd Argument( 'Reason' ): Reason for failure ( FAIL ),
- default to None.
- INVALID_INPUT
- EMPTY_LIST
- """
- ret = [FAIL, None, None]
- if inp is None:
- ret[2] = INVALID_INPUT
- return ret
- if not isinstance(inp, list):
- ret[2] = INVALID_INPUT
- return ret
- if len(inp) == 0:
- ret[2] = EMPTY_LIST
- return ret
- return [PASS, inp[0], None]
-
-def verifyElementInList(inp, toverify, responsevar=None, pos=0):
- '''
- @name: verifyElementInList
- @Description:
- 1. A utility function to validate
- whether the input passed is a list.
- The list is empty or not.
- If it is list and not empty, verify
- whether a given element is there in that list or not
- at a given pos
- @Input:
- I : Input to be verified whether its a list or not
- II : Element to verify whether it exists in the list
- III : variable name in response object to verify
- default to None, if None, we will verify for the complete
- first element EX: state of response object object
- IV : Position in the list at which the input element to verify
- default to 0
- @output: List, containing [ Result,Reason ]
- Ist Argument('Result') : FAIL : If it is not a list
- If it is list but empty
- PASS : If it is list and not empty
- and matching element was found
- IIrd Argument( 'Reason' ): Reason for failure ( FAIL ),
- default to None.
- INVALID_INPUT
- EMPTY_LIST
- MATCH_NOT_FOUND
- '''
- if toverify is None or toverify == '' \
- or pos is None or pos < -1 or pos == '':
- return [FAIL, INVALID_INPUT]
- out = validateList(inp)
- if out[0] == FAIL:
- return [FAIL, out[2]]
- if len(inp) > pos:
- if responsevar is None:
- if inp[pos] == toverify:
- return [PASS, None]
- else:
- if responsevar in inp[pos].__dict__ and getattr(inp[pos], responsevar) == toverify:
- return [PASS, None]
- else:
- return [FAIL, MATCH_NOT_FOUND]
- else:
- return [FAIL, MATCH_NOT_FOUND]
-
-def verifyRouterState(apiclient, routerid, allowedstates):
- """List the router and verify that its state is in allowed states
- @output: List, containing [Result, Reason]
- Ist Argument ('Result'): FAIL: If router state is not
- in allowed states
- PASS: If router state is in
- allowed states"""
-
- try:
- cmd = listRouters.listRoutersCmd()
- cmd.id = routerid
- cmd.listall = True
- routers = apiclient.listRouters(cmd)
- except Exception as e:
- return [FAIL, e]
- listvalidationresult = validateList(routers)
- if listvalidationresult[0] == FAIL:
- return [FAIL, listvalidationresult[2]]
- if routers[0].redundantstate not in allowedstates:
- return [FAIL, "Redundant state of the router should be in %s but is %s" %
- (allowedstates, routers[0].redundantstate)]
- return [PASS, None]
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/tools/marvin/marvin/jsonHelper.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/jsonHelper.py b/tools/marvin/marvin/jsonHelper.py
index ae40b8d..3f48a00 100644
--- a/tools/marvin/marvin/jsonHelper.py
+++ b/tools/marvin/marvin/jsonHelper.py
@@ -18,11 +18,13 @@
import cloudstackException
import json
import inspect
-from cloudstackAPI import *
+from marvin.cloudstackAPI import *
class jsonLoader(object):
+
'''The recursive class for building and representing objects with.'''
+
def __init__(self, obj):
for k in obj:
v = obj[k]
@@ -52,6 +54,7 @@ class jsonLoader(object):
class jsonDump(object):
+
@staticmethod
def __serialize(obj):
"""Recursively walk object's hierarchy."""
@@ -145,7 +148,7 @@ def getResultObj(returnObj, responsecls=None):
errMsg = "errorCode: %s, errorText:%s" % (result.errorcode,
result.errortext)
respname = responseName.replace("response", "")
- raise cloudstackException.cloudstackAPIException(respname, errMsg)
+ raise cloudstackException.CloudstackAPIException(respname, errMsg)
if result.count is not None:
for key in result.__dict__.iterkeys():
@@ -247,7 +250,7 @@ due to missing parameter jobid"
}'''
try:
asynJob = getResultObj(result)
- except cloudstackException.cloudstackAPIException, e:
+ except cloudstackException.CloudstackAPIException as e:
print e
result = '{ "queryasyncjobresultresponse" : {} }'
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/tools/marvin/marvin/lib/__init__.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/lib/__init__.py b/tools/marvin/marvin/lib/__init__.py
new file mode 100644
index 0000000..978b68a
--- /dev/null
+++ b/tools/marvin/marvin/lib/__init__.py
@@ -0,0 +1,16 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
[09/18] Marvin + test changes from master Signed-off-by:
SrikanteswaraRao Talluri
Posted by da...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/smoke/test_vm_iam.py
----------------------------------------------------------------------
diff --git a/test/integration/smoke/test_vm_iam.py b/test/integration/smoke/test_vm_iam.py
new file mode 100644
index 0000000..be75a79
--- /dev/null
+++ b/test/integration/smoke/test_vm_iam.py
@@ -0,0 +1,719 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+""" BVT tests for Virtual Machine IAM effect
+"""
+#Import Local Modules
+import marvin
+from marvin.cloudstackTestCase import *
+from marvin.cloudstackAPI import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
+from marvin.codes import FAILED
+from nose.plugins.attrib import attr
+#Import System modules
+import time
+
+_multiprocess_shared_ = True
+class Services:
+ """Test VM Life Cycle Services
+ """
+
+ def __init__(self):
+ self.services = {
+ #data for domains and accounts
+ "domain1": {
+ "name": "Domain1",
+ },
+ "account1A": {
+ "email": "test1A@test.com",
+ "firstname": "test1A",
+ "lastname": "User",
+ "username": "test1A",
+ "password": "password",
+ },
+ "account1B": {
+ "email": "test1B@test.com",
+ "firstname": "test1B",
+ "lastname": "User",
+ "username": "test1B",
+ "password": "password",
+ },
+ "domain2": {
+ "name": "Domain2",
+ },
+ "account2A": {
+ "email": "test2A@test.com",
+ "firstname": "test2A",
+ "lastname": "User",
+ "username": "test2A",
+ "password": "password",
+ },
+ #data reqd for virtual machine creation
+ "virtual_machine1A" : {
+ "name" : "test1Avm",
+ "displayname" : "Test1A VM",
+ },
+ "virtual_machine1B" : {
+ "name" : "test1Bvm",
+ "displayname" : "Test1B VM",
+ },
+ "virtual_machine2A" : {
+ "name" : "test2Avm",
+ "displayname" : "Test2A VM",
+ },
+ #small service offering
+ "service_offering": {
+ "small": {
+ "name": "Small Instance",
+ "displaytext": "Small Instance",
+ "cpunumber": 1,
+ "cpuspeed": 100,
+ "memory": 128,
+ },
+ },
+ "ostype": 'CentOS 5.6 (64-bit)',
+ # iam group and policy information
+ "service_desk_iam_grp" : {
+ "name" : "Service Desk",
+ "description" : "Service Desk IAM Group"
+ },
+ "vm_readonly_iam_policy" : {
+ "name" : "VM Read Only Access",
+ "description" : "VM read only access iam policy"
+ },
+ }
+
+
+
+class TestVMIam(cloudstackTestCase):
+
+ @classmethod
+ def setUpClass(self):
+ testClient = super(TestVMIam, self).getClsTestClient()
+ self.apiclient = testClient.getApiClient()
+ self.services = Services().services
+
+ # backup default apikey and secretkey
+ self.default_apikey = self.apiclient.connection.apiKey
+ self.default_secretkey = self.apiclient.connection.securityKey
+
+ # Create domains and accounts etc
+ self.domain_1 = Domain.create(
+ self.apiclient,
+ self.services["domain1"]
+ )
+ self.domain_2 = Domain.create(
+ self.apiclient,
+ self.services["domain2"]
+ )
+ # Create two accounts for doamin_1
+ self.account_1A = Account.create(
+ self.apiclient,
+ self.services["account1A"],
+ admin=False,
+ domainid=self.domain_1.id
+ )
+
+ self.account_1B = Account.create(
+ self.apiclient,
+ self.services["account1B"],
+ admin=False,
+ domainid=self.domain_1.id
+ )
+
+ # Create an account for domain_2
+ self.account_2A = Account.create(
+ self.apiclient,
+ self.services["account2A"],
+ admin=False,
+ domainid=self.domain_2.id
+ )
+
+ # Fetch user details to register apiKey for them
+ self.user_1A = User.list(
+ self.apiclient,
+ account=self.account_1A.name,
+ domainid=self.account_1A.domainid
+ )[0]
+
+ user_1A_key = User.registerUserKeys(
+ self.apiclient,
+ self.user_1A.id
+ )
+ self.user_1A_apikey = user_1A_key.apikey
+ self.user_1A_secretkey = user_1A_key.secretkey
+
+
+ self.user_1B = User.list(
+ self.apiclient,
+ account=self.account_1B.name,
+ domainid=self.account_1B.domainid
+ )[0]
+
+ user_1B_key = User.registerUserKeys(
+ self.apiclient,
+ self.user_1B.id
+ )
+
+ self.user_1B_apikey = user_1B_key.apikey
+ self.user_1B_secretkey = user_1B_key.secretkey
+
+
+ self.user_2A = User.list(
+ self.apiclient,
+ account=self.account_2A.name,
+ domainid=self.account_2A.domainid
+ )[0]
+
+ user_2A_key = User.registerUserKeys(
+ self.apiclient,
+ self.user_2A.id
+ )
+ self.user_2A_apikey = user_2A_key.apikey
+ self.user_2A_secretkey = user_2A_key.secretkey
+
+ # create service offering
+ self.service_offering = ServiceOffering.create(
+ self.apiclient,
+ self.services["service_offering"]["small"]
+ )
+
+ self.zone = get_zone(self.apiclient, testClient.getZoneForTests())
+ self.services['mode'] = self.zone.networktype
+ self.template = get_template(self.apiclient, self.zone.id, self.services["ostype"])
+
+ # deploy 3 VMs for three accounts
+ self.virtual_machine_1A = VirtualMachine.create(
+ self.apiclient,
+ self.services["virtual_machine1A"],
+ accountid=self.account_1A.name,
+ zoneid=self.zone.id,
+ domainid=self.account_1A.domainid,
+ serviceofferingid=self.service_offering.id,
+ templateid=self.template.id
+ )
+
+ self.virtual_machine_1B = VirtualMachine.create(
+ self.apiclient,
+ self.services["virtual_machine1B"],
+ accountid=self.account_1B.name,
+ zoneid=self.zone.id,
+ domainid=self.account_1B.domainid,
+ serviceofferingid=self.service_offering.id,
+ templateid=self.template.id
+ )
+
+ self.virtual_machine_2A = VirtualMachine.create(
+ self.apiclient,
+ self.services["virtual_machine2A"],
+ accountid=self.account_2A.name,
+ zoneid=self.zone.id,
+ domainid=self.account_2A.domainid,
+ serviceofferingid=self.service_offering.id,
+ templateid=self.template.id
+ )
+
+ self.srv_desk_grp = IAMGroup.create(
+ self.apiclient,
+ self.services["service_desk_iam_grp"]
+ )
+
+ self.vm_read_policy = IAMPolicy.create(
+ self.apiclient,
+ self.services["vm_readonly_iam_policy"]
+ )
+
+ self.srv_desk_grp.attachPolicy(
+ self.apiclient, [self.vm_read_policy]
+ )
+
+ vm_grant_policy_params = {}
+ vm_grant_policy_params['name'] = "policyGrantVirtualMachine" + self.virtual_machine_1A.id
+ vm_grant_policy_params['description'] = "Policy to grant permission to VirtualMachine " + self.virtual_machine_1A.id
+ self.vm_grant_policy = IAMPolicy.create(
+ self.apiclient,
+ vm_grant_policy_params
+ )
+
+ self._cleanup = [
+ self.account_1A,
+ self.account_1B,
+ self.domain_1,
+ self.account_2A,
+ self.domain_2,
+ self.service_offering,
+ self.vm_read_policy,
+ self.srv_desk_grp,
+ self.vm_grant_policy
+ ]
+
+ @classmethod
+ def tearDownClass(self):
+ self.apiclient = super(TestVMIam, self).getClsTestClient().getApiClient()
+ cleanup_resources(self.apiclient, self._cleanup)
+ return
+
+ def setUp(self):
+ self.apiclient = self.testClient.getApiClient()
+ self.dbclient = self.testClient.getDbConnection()
+ self.cleanup = []
+
+ def tearDown(self):
+ # restore back default apikey and secretkey
+ self.apiclient.connection.apiKey = self.default_apikey
+ self.apiclient.connection.securityKey = self.default_secretkey
+ cleanup_resources(self.apiclient, self.cleanup)
+ return
+
+
+
+ @attr(tags = ["devcloud", "advanced", "advancedns", "smoke", "basic", "sg", "selfservice"])
+ def test_01_list_own_vm(self):
+ # listVM command should return owne's VM
+
+ self.debug("Listing VM for account: %s" % self.account_1A.name)
+
+ self.apiclient.connection.apiKey = self.user_1A_apikey
+ self.apiclient.connection.securityKey = self.user_1A_secretkey
+ list_vm_response = list_virtual_machines(
+ self.apiclient
+ )
+ self.assertEqual(
+ isinstance(list_vm_response, list),
+ True,
+ "Check list response returns a valid list"
+ )
+ self.assertEqual(
+ len(list_vm_response),
+ 1,
+ "Check VM available in List Virtual Machines"
+ )
+
+ self.assertEqual(
+ list_vm_response[0].name,
+ self.virtual_machine_1A.name,
+ "Virtual Machine names do not match"
+ )
+
+ self.debug("Listing VM for account: %s" % self.account_1B.name)
+ self.apiclient.connection.apiKey = self.user_1B_apikey
+ self.apiclient.connection.securityKey = self.user_1B_secretkey
+ list_vm_response = list_virtual_machines(
+ self.apiclient
+ )
+ self.assertEqual(
+ isinstance(list_vm_response, list),
+ True,
+ "Check list response returns a valid list"
+ )
+ self.assertEqual(
+ len(list_vm_response),
+ 1,
+ "Check VM available in List Virtual Machines"
+ )
+
+ self.assertEqual(
+ list_vm_response[0].name,
+ self.virtual_machine_1B.name,
+ "Virtual Machine names do not match"
+ )
+
+ self.debug("Listing VM for account: %s" % self.account_2A.name)
+
+ self.apiclient.connection.apiKey = self.user_2A_apikey
+ self.apiclient.connection.securityKey = self.user_2A_secretkey
+ list_vm_response = list_virtual_machines(
+ self.apiclient
+ )
+ self.assertEqual(
+ isinstance(list_vm_response, list),
+ True,
+ "Check list response returns a valid list"
+ )
+ self.assertEqual(
+ len(list_vm_response),
+ 1,
+ "Check VM available in List Virtual Machines"
+ )
+
+ self.assertEqual(
+ list_vm_response[0].name,
+ self.virtual_machine_2A.name,
+ "Virtual Machine names do not match"
+ )
+
+ return
+
+ @attr(tags = ["devcloud", "advanced", "advancedns", "smoke", "basic", "sg", "selfservice"])
+ def test_02_grant_domain_vm(self):
+
+ # Validate the following
+ # 1. Grant domain2 VM access to account_1B
+ # 2. listVM command should return account_1B and domain_2 VMs.
+
+ self.debug("Granting Domain %s VM read only access to account: %s" % (self.domain_2.name, self.account_1B.name))
+
+ self.srv_desk_grp.addAccount(self.apiclient, [self.account_1B])
+ domain_permission = {}
+ domain_permission['action'] = "listVirtualMachines"
+ domain_permission['entitytype'] = "VirtualMachine"
+ domain_permission['scope'] = "DOMAIN"
+ domain_permission['scopeid'] = self.domain_2.id
+ self.vm_read_policy.addPermission(self.apiclient, domain_permission)
+
+ self.debug("Listing VM for account: %s" % self.account_1B.name)
+ self.apiclient.connection.apiKey = self.user_1B_apikey
+ self.apiclient.connection.securityKey = self.user_1B_secretkey
+ list_vm_response = list_virtual_machines(
+ self.apiclient
+ )
+ self.assertEqual(
+ isinstance(list_vm_response, list),
+ True,
+ "Check list response returns a valid list"
+ )
+ self.assertEqual(
+ len(list_vm_response),
+ 2,
+ "Check VM available in List Virtual Machines"
+ )
+
+ list_vm_names = [list_vm_response[0].name, list_vm_response[1].name]
+
+ self.assertEqual( self.virtual_machine_1B.name in list_vm_names,
+ True,
+ "Accessible Virtual Machine names do not match"
+ )
+
+ self.assertEqual( self.virtual_machine_2A.name in list_vm_names,
+ True,
+ "Accessible Virtual Machine names do not match"
+ )
+
+ return
+
+
+ @attr(tags = ["devcloud", "advanced", "advancedns", "smoke", "basic", "sg", "selfservice"])
+ def test_03_grant_account_vm(self):
+
+ # Validate the following
+ # 1. Grant account_1A VM access to account_1B
+ # 2. listVM command should return account_1A and account_1B VMs.
+
+ self.debug("Granting Account %s VM read only access to account: %s" % (self.account_1A.name, self.account_1B.name))
+
+ account_permission = {}
+ account_permission['action'] = "listVirtualMachines"
+ account_permission['entitytype'] = "VirtualMachine"
+ account_permission['scope'] = "ACCOUNT"
+ account_permission['scopeid'] = self.account_1A.id
+ self.vm_read_policy.addPermission(self.apiclient, account_permission)
+
+ self.debug("Listing VM for account: %s" % self.account_1B.name)
+ self.apiclient.connection.apiKey = self.user_1B_apikey
+ self.apiclient.connection.securityKey = self.user_1B_secretkey
+ list_vm_response = list_virtual_machines(
+ self.apiclient
+ )
+ self.assertEqual(
+ isinstance(list_vm_response, list),
+ True,
+ "Check list response returns a valid list"
+ )
+ self.assertEqual(
+ len(list_vm_response),
+ 3,
+ "Check VM available in List Virtual Machines"
+ )
+
+ list_vm_names = [list_vm_response[0].name, list_vm_response[1].name, list_vm_response[2].name]
+
+ self.assertEqual( self.virtual_machine_1B.name in list_vm_names,
+ True,
+ "Accessible Virtual Machine names do not match"
+ )
+
+ self.assertEqual( self.virtual_machine_1A.name in list_vm_names,
+ True,
+ "Accessible Virtual Machine names do not match"
+ )
+
+ self.assertEqual( self.virtual_machine_2A.name in list_vm_names,
+ True,
+ "Accessible Virtual Machine names do not match"
+ )
+
+ return
+
+
+ @attr(tags = ["devcloud", "advanced", "advancedns", "smoke", "basic", "sg", "selfservice"])
+ def test_04_revoke_account_vm(self):
+
+ # Validate the following
+ # 1. Revoke account_1A VM access from account_1B
+ # 2. listVM command should not return account_1A VMs.
+
+ self.debug("Revoking Account %s VM read only access from account: %s" % (self.account_1A.name, self.account_1B.name))
+
+ account_permission = {}
+ account_permission['action'] = "listVirtualMachines"
+ account_permission['entitytype'] = "VirtualMachine"
+ account_permission['scope'] = "ACCOUNT"
+ account_permission['scopeid'] = self.account_1A.id
+ self.vm_read_policy.removePermission(self.apiclient, account_permission)
+
+ self.debug("Listing VM for account: %s" % self.account_1B.name)
+ self.apiclient.connection.apiKey = self.user_1B_apikey
+ self.apiclient.connection.securityKey = self.user_1B_secretkey
+ list_vm_response = list_virtual_machines(
+ self.apiclient
+ )
+ self.assertEqual(
+ isinstance(list_vm_response, list),
+ True,
+ "Check list response returns a valid list"
+ )
+ self.assertEqual(
+ len(list_vm_response),
+ 2,
+ "Check VM available in List Virtual Machines"
+ )
+
+ list_vm_names = [list_vm_response[0].name, list_vm_response[1].name]
+
+
+ self.assertEqual( self.virtual_machine_1A.name in list_vm_names,
+ False,
+ "Accessible Virtual Machine names do not match"
+ )
+ return
+
+
+ @attr(tags = ["devcloud", "advanced", "advancedns", "smoke", "basic", "sg", "selfservice"])
+ def test_05_revoke_domain_vm(self):
+
+ # Validate the following
+ # 1. Revoke account_1A VM access from account_1B
+ # 2. listVM command should not return account_1A VMs.
+
+ self.debug("Revoking Domain %s VM read only access from account: %s" % (self.domain_1.name, self.account_1B.name))
+
+ domain_permission = {}
+ domain_permission['action'] = "listVirtualMachines"
+ domain_permission['entitytype'] = "VirtualMachine"
+ domain_permission['scope'] = "DOMAIN"
+ domain_permission['scopeid'] = self.domain_2.id
+ self.vm_read_policy.removePermission(self.apiclient, domain_permission)
+
+ self.debug("Listing VM for account: %s" % self.account_1B.name)
+ self.apiclient.connection.apiKey = self.user_1B_apikey
+ self.apiclient.connection.securityKey = self.user_1B_secretkey
+ list_vm_response = list_virtual_machines(
+ self.apiclient
+ )
+ self.assertEqual(
+ isinstance(list_vm_response, list),
+ True,
+ "Check list response returns a valid list"
+ )
+ self.assertEqual(
+ len(list_vm_response),
+ 1,
+ "Check VM available in List Virtual Machines"
+ )
+
+ self.assertEqual(
+ list_vm_response[0].name,
+ self.virtual_machine_1B.name,
+ "Virtual Machine names do not match"
+ )
+
+ return
+
+ @attr(tags = ["devcloud", "advanced", "advancedns", "smoke", "basic", "sg", "selfservice"])
+ def test_06_grant_resource_vm(self):
+
+ # Validate the following
+ # 1. Grant a particular vm access to account_1B
+ # 2. listVM command should return account_1B VMs and granted VM.
+
+ self.debug("Granting VM %s read only access to account: %s" % (self.virtual_machine_1A.name, self.account_1B.name))
+
+ res_permission = {}
+ res_permission['action'] = "listVirtualMachines"
+ res_permission['entitytype'] = "VirtualMachine"
+ res_permission['scope'] = "RESOURCE"
+ res_permission['scopeid'] = self.virtual_machine_1A.id
+ self.vm_read_policy.addPermission(self.apiclient, res_permission)
+
+ self.debug("Listing VM for account: %s" % self.account_1B.name)
+ self.apiclient.connection.apiKey = self.user_1B_apikey
+ self.apiclient.connection.securityKey = self.user_1B_secretkey
+ list_vm_response = list_virtual_machines(
+ self.apiclient
+ )
+ self.assertEqual(
+ isinstance(list_vm_response, list),
+ True,
+ "Check list response returns a valid list"
+ )
+ self.assertEqual(
+ len(list_vm_response),
+ 2,
+ "Check VM available in List Virtual Machines"
+ )
+
+ list_vm_names = [list_vm_response[0].name, list_vm_response[1].name]
+
+ self.assertEqual( self.virtual_machine_1B.name in list_vm_names,
+ True,
+ "Accessible Virtual Machine names do not match"
+ )
+
+ self.assertEqual( self.virtual_machine_1A.name in list_vm_names,
+ True,
+ "Accessible Virtual Machine names do not match"
+ )
+
+ return
+
+ @attr(tags = ["devcloud", "advanced", "advancedns", "smoke", "basic", "sg", "selfservice"])
+ def test_07_revoke_resource_vm(self):
+
+ # Validate the following
+ # 1. Grant a particular vm access to account_1B
+ # 2. listVM command should return account_1B VMs and granted VM.
+
+ self.debug("Revoking VM %s read only access from account: %s" % (self.virtual_machine_1A.name, self.account_1B.name))
+
+ res_permission = {}
+ res_permission['action'] = "listVirtualMachines"
+ res_permission['entitytype'] = "VirtualMachine"
+ res_permission['scope'] = "RESOURCE"
+ res_permission['scopeid'] = self.virtual_machine_1A.id
+ self.vm_read_policy.removePermission(self.apiclient, res_permission)
+
+ self.debug("Listing VM for account: %s" % self.account_1B.id)
+ self.apiclient.connection.apiKey = self.user_1B_apikey
+ self.apiclient.connection.securityKey = self.user_1B_secretkey
+ list_vm_response = list_virtual_machines(
+ self.apiclient
+ )
+ self.assertEqual(
+ isinstance(list_vm_response, list),
+ True,
+ "Check list response returns a valid list"
+ )
+ self.assertEqual(
+ len(list_vm_response),
+ 1,
+ "Check VM available in List Virtual Machines"
+ )
+
+ self.assertEqual(
+ list_vm_response[0].name,
+ self.virtual_machine_1B.name,
+ "Virtual Machine names do not match"
+ )
+
+ return
+
+
+ @attr(tags = ["devcloud", "advanced", "advancedns", "smoke", "basic", "sg", "selfservice"])
+ def test_08_policy_attach_account(self):
+
+ # Validate the following
+ # 1. Grant a particular vm access to account_1B by directly attaching policy to account
+ # 2. listVM command should return account_1B VMs and granted VM.
+
+ self.debug("Granting VM %s read only access to account: %s by attaching policy to account" % (self.virtual_machine_1A.name, self.account_1B.name))
+
+ res_permission = {}
+ res_permission['action'] = "listVirtualMachines"
+ res_permission['entitytype'] = "VirtualMachine"
+ res_permission['scope'] = "RESOURCE"
+ res_permission['scopeid'] = self.virtual_machine_1A.id
+ self.vm_grant_policy.addPermission(self.apiclient, res_permission)
+ self.vm_grant_policy.attachAccount(self.apiclient, [self.account_1B])
+
+ self.debug("Listing VM for account: %s" % self.account_1B.id)
+ self.apiclient.connection.apiKey = self.user_1B_apikey
+ self.apiclient.connection.securityKey = self.user_1B_secretkey
+ list_vm_response = list_virtual_machines(
+ self.apiclient
+ )
+ self.assertEqual(
+ isinstance(list_vm_response, list),
+ True,
+ "Check list response returns a valid list"
+ )
+ self.assertEqual(
+ len(list_vm_response),
+ 2,
+ "Check VM available in List Virtual Machines"
+ )
+
+ list_vm_names = [list_vm_response[0].name, list_vm_response[1].name]
+
+ self.assertEqual( self.virtual_machine_1B.name in list_vm_names,
+ True,
+ "Accessible Virtual Machine names do not match"
+ )
+
+ self.assertEqual( self.virtual_machine_1A.name in list_vm_names,
+ True,
+ "Accessible Virtual Machine names do not match"
+ )
+
+ return
+
+ @attr(tags = ["devcloud", "advanced", "advancedns", "smoke", "basic", "sg", "selfservice"])
+ def test_09_policy_detach_account(self):
+
+ # Validate the following
+ # 1. Revoking a particular vm access from account_1B by detaching policy from account
+ # 2. listVM command should return account_1B VMs.
+
+ self.debug("Revoking VM %s read only access from account: %s by detaching policy from account" % (self.virtual_machine_1A.name, self.account_1B.name))
+
+ self.vm_grant_policy.detachAccount(self.apiclient, [self.account_1B])
+
+ self.debug("Listing VM for account: %s" % self.account_1B.id)
+ self.apiclient.connection.apiKey = self.user_1B_apikey
+ self.apiclient.connection.securityKey = self.user_1B_secretkey
+ list_vm_response = list_virtual_machines(
+ self.apiclient
+ )
+ self.assertEqual(
+ isinstance(list_vm_response, list),
+ True,
+ "Check list response returns a valid list"
+ )
+ self.assertEqual(
+ len(list_vm_response),
+ 1,
+ "Check VM available in List Virtual Machines"
+ )
+
+ self.assertEqual(
+ list_vm_response[0].name,
+ self.virtual_machine_1B.name,
+ "Virtual Machine names do not match"
+ )
+
+ return
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/smoke/test_vm_life_cycle.py
----------------------------------------------------------------------
diff --git a/test/integration/smoke/test_vm_life_cycle.py b/test/integration/smoke/test_vm_life_cycle.py
index 7d47f70..f114ec9 100644
--- a/test/integration/smoke/test_vm_life_cycle.py
+++ b/test/integration/smoke/test_vm_life_cycle.py
@@ -18,138 +18,28 @@
"""
#Import Local Modules
from marvin.cloudstackTestCase import cloudstackTestCase
-from marvin.cloudstackAPI import (detachIso,
- attachIso,
- recoverVirtualMachine,
- destroyVirtualMachine)
-from marvin.integration.lib.utils import (cleanup_resources,
- validateList,
- get_hypervisor_type)
-from marvin.integration.lib.base import (Account,
- ServiceOffering,
- VirtualMachine,
- Iso,
- Host)
-from marvin.integration.lib.common import (get_domain,
- get_zone,
- get_template,
- list_virtual_machines,
- list_configurations,
- list_routers,
- list_isos)
-from marvin.codes import PASS
+from marvin.codes import FAILED
+from marvin.cloudstackTestCase import *
+from marvin.cloudstackAPI import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
from nose.plugins.attrib import attr
#Import System modules
import time
_multiprocess_shared_ = True
-class Services:
- """Test VM Life Cycle Services
- """
-
- def __init__(self):
- self.services = {
- "disk_offering":{
- "displaytext": "Small",
- "name": "Small",
- "disksize": 1
- },
- "account": {
- "email": "test@test.com",
- "firstname": "Test",
- "lastname": "User",
- "username": "test",
- # Random characters are appended in create account to
- # ensure unique username generated each time
- "password": "password",
- },
- "small":
- # Create a small virtual machine instance with disk offering
- {
- "displayname": "testserver",
- "username": "root", # VM creds for SSH
- "password": "password",
- "ssh_port": 22,
- "hypervisor": 'XenServer',
- "privateport": 22,
- "publicport": 22,
- "protocol": 'TCP',
- },
- "medium": # Create a medium virtual machine instance
- {
- "displayname": "testserver",
- "username": "root",
- "password": "password",
- "ssh_port": 22,
- "hypervisor": 'XenServer',
- "privateport": 22,
- "publicport": 22,
- "protocol": 'TCP',
- },
- "service_offerings":
- {
- "tiny":
- {
- "name": "Tiny Instance",
- "displaytext": "Tiny Instance",
- "cpunumber": 1,
- "cpuspeed": 100, # in MHz
- "memory": 128, # In MBs
- },
- "small":
- {
- # Small service offering ID to for change VM
- # service offering from medium to small
- "name": "Small Instance",
- "displaytext": "Small Instance",
- "cpunumber": 1,
- "cpuspeed": 100,
- "memory": 256,
- },
- "medium":
- {
- # Medium service offering ID to for
- # change VM service offering from small to medium
- "name": "Medium Instance",
- "displaytext": "Medium Instance",
- "cpunumber": 1,
- "cpuspeed": 100,
- "memory": 256,
- }
- },
- "iso": # ISO settings for Attach/Detach ISO tests
- {
- "displaytext": "Test ISO",
- "name": "testISO",
- "url": "http://people.apache.org/~tsp/dummy.iso",
- # Source URL where ISO is located
- "ostype": 'CentOS 5.3 (64-bit)',
- "mode": 'HTTP_DOWNLOAD', # Downloading existing ISO
- },
- "template": {
- "displaytext": "Cent OS Template",
- "name": "Cent OS Template",
- "passwordenabled": True,
- },
- "diskdevice": ['/dev/vdc', '/dev/vdb', '/dev/hdb', '/dev/hdc', '/dev/xvdd', '/dev/cdrom', '/dev/sr0', '/dev/cdrom1' ],
- # Disk device where ISO is attached to instance
- "mount_dir": "/mnt/tmp",
- "sleep": 60,
- "timeout": 10,
- #Migrate VM to hostid
- "ostype": 'CentOS 5.3 (64-bit)',
- # CentOS 5.3 (64-bit)
- }
-
class TestDeployVM(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.services = Services().services
- cls.apiclient = super(TestDeployVM, cls).getClsTestClient().getApiClient()
+ testClient = super(TestDeployVM, cls).getClsTestClient()
+ cls.apiclient = testClient.getApiClient()
+ cls.services = testClient.getParsedTestDataConfig()
+
# Get Zone, Domain and templates
- domain = get_domain(cls.apiclient, cls.services)
- cls.zone = get_zone(cls.apiclient, cls.services)
+ domain = get_domain(cls.apiclient)
+ cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests())
cls.services['mode'] = cls.zone.networktype
#If local storage is enabled, alter the offerings to use localstorage
@@ -164,13 +54,16 @@ class TestDeployVM(cloudstackTestCase):
cls.zone.id,
cls.services["ostype"]
)
+ if template == FAILED:
+ assert False, "get_template() failed to return template with description %s" % cls.services["ostype"]
+
# Set Zones and disk offerings
cls.services["small"]["zoneid"] = cls.zone.id
cls.services["small"]["template"] = template.id
cls.services["medium"]["zoneid"] = cls.zone.id
cls.services["medium"]["template"] = template.id
- cls.services["iso"]["zoneid"] = cls.zone.id
+ cls.services["iso1"]["zoneid"] = cls.zone.id
cls.account = Account.create(
cls.apiclient,
@@ -303,12 +196,13 @@ class TestVMLifeCycle(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(TestVMLifeCycle, cls).getClsTestClient().getApiClient()
- cls.services = Services().services
+ testClient = super(TestVMLifeCycle, cls).getClsTestClient()
+ cls.apiclient = testClient.getApiClient()
+ cls.services = testClient.getParsedTestDataConfig()
# Get Zone, Domain and templates
- domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ domain = get_domain(cls.apiclient)
+ cls.zone = get_zone(cls.apiclient, cls.testClient.getZoneForTests())
cls.services['mode'] = cls.zone.networktype
#if local storage is enabled, alter the offerings to use localstorage
@@ -319,37 +213,40 @@ class TestVMLifeCycle(cloudstackTestCase):
cls.services["service_offerings"]["medium"]["storagetype"] = 'local'
template = get_template(
- cls.api_client,
+ cls.apiclient,
cls.zone.id,
cls.services["ostype"]
)
+ if template == FAILED:
+ assert False, "get_template() failed to return template with description %s" % cls.services["ostype"]
+
# Set Zones and disk offerings
cls.services["small"]["zoneid"] = cls.zone.id
cls.services["small"]["template"] = template.id
cls.services["medium"]["zoneid"] = cls.zone.id
cls.services["medium"]["template"] = template.id
- cls.services["iso"]["zoneid"] = cls.zone.id
+ cls.services["iso1"]["zoneid"] = cls.zone.id
# Create VMs, NAT Rules etc
cls.account = Account.create(
- cls.api_client,
+ cls.apiclient,
cls.services["account"],
domainid=domain.id
)
cls.small_offering = ServiceOffering.create(
- cls.api_client,
+ cls.apiclient,
cls.services["service_offerings"]["small"]
)
cls.medium_offering = ServiceOffering.create(
- cls.api_client,
+ cls.apiclient,
cls.services["service_offerings"]["medium"]
)
#create small and large virtual machines
cls.small_virtual_machine = VirtualMachine.create(
- cls.api_client,
+ cls.apiclient,
cls.services["small"],
accountid=cls.account.name,
domainid=cls.account.domainid,
@@ -357,7 +254,7 @@ class TestVMLifeCycle(cloudstackTestCase):
mode=cls.services["mode"]
)
cls.medium_virtual_machine = VirtualMachine.create(
- cls.api_client,
+ cls.apiclient,
cls.services["medium"],
accountid=cls.account.name,
domainid=cls.account.domainid,
@@ -365,7 +262,7 @@ class TestVMLifeCycle(cloudstackTestCase):
mode=cls.services["mode"]
)
cls.virtual_machine = VirtualMachine.create(
- cls.api_client,
+ cls.apiclient,
cls.services["small"],
accountid=cls.account.name,
domainid=cls.account.domainid,
@@ -380,8 +277,8 @@ class TestVMLifeCycle(cloudstackTestCase):
@classmethod
def tearDownClass(cls):
- cls.api_client = super(TestVMLifeCycle, cls).getClsTestClient().getApiClient()
- cleanup_resources(cls.api_client, cls._cleanup)
+ cls.apiclient = super(TestVMLifeCycle, cls).getClsTestClient().getApiClient()
+ cleanup_resources(cls.apiclient, cls._cleanup)
return
def setUp(self):
@@ -628,7 +525,7 @@ class TestVMLifeCycle(cloudstackTestCase):
#deploy VM on target host
self.vm_to_migrate = VirtualMachine.create(
- self.api_client,
+ self.apiclient,
self.services["small"],
accountid=self.account.name,
domainid=self.account.domainid,
@@ -641,7 +538,7 @@ class TestVMLifeCycle(cloudstackTestCase):
migrate_host.id
))
- self.vm_to_migrate.migrate(self.api_client, migrate_host.id)
+ self.vm_to_migrate.migrate(self.apiclient, migrate_host.id)
list_vm_response = list_virtual_machines(
self.apiclient,
@@ -733,7 +630,7 @@ class TestVMLifeCycle(cloudstackTestCase):
iso = Iso.create(
self.apiclient,
- self.services["iso"],
+ self.services["iso1"],
account=self.account.name,
domainid=self.account.domainid
)
@@ -760,12 +657,13 @@ class TestVMLifeCycle(cloudstackTestCase):
except Exception as e:
self.fail("SSH failed for virtual machine: %s - %s" %
(self.virtual_machine.ipaddress, e))
-
- cmds = "mkdir -p %s" % self.services["mount_dir"]
+
+ mount_dir = "/mnt/tmp"
+ cmds = "mkdir -p %s" % mount_dir
self.assert_(ssh_client.execute(cmds) == [], "mkdir failed within guest")
for diskdevice in self.services["diskdevice"]:
- res = ssh_client.execute("mount -rt iso9660 {} {}".format(diskdevice, self.services["mount_dir"]))
+ res = ssh_client.execute("mount -rt iso9660 {} {}".format(diskdevice, mount_dir))
if res == []:
self.services["mount"] = diskdevice
break
@@ -790,7 +688,7 @@ class TestVMLifeCycle(cloudstackTestCase):
try:
#Unmount ISO
- command = "umount %s" % self.services["mount_dir"]
+ command = "umount %s" % mount_dir
ssh_client.execute(command)
except Exception as e:
self.fail("SSH failed for virtual machine: %s - %s" %
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/smoke/test_vm_snapshots.py
----------------------------------------------------------------------
diff --git a/test/integration/smoke/test_vm_snapshots.py b/test/integration/smoke/test_vm_snapshots.py
index 65a5acb..e884d42 100644
--- a/test/integration/smoke/test_vm_snapshots.py
+++ b/test/integration/smoke/test_vm_snapshots.py
@@ -16,83 +16,33 @@
# under the License.
# Import Local Modules
-import marvin
+from marvin.codes import FAILED
from nose.plugins.attrib import attr
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
-
-class Services:
- """Test Snapshots Services
- """
-
- def __init__(self):
- self.services = {
- "account": {
- "email": "test@test.com",
- "firstname": "Test",
- "lastname": "User",
- "username": "test",
- # Random characters are appended for unique
- # username
- "password": "password",
- },
- "service_offering": {
- "name": "Tiny Instance",
- "displaytext": "Tiny Instance",
- "cpunumber": 1,
- "cpuspeed": 200, # in MHz
- "memory": 256, # In MBs
- },
- "server": {
- "displayname": "TestVM",
- "username": "root",
- "password": "password",
- "ssh_port": 22,
- "hypervisor": 'XenServer',
- "privateport": 22,
- "publicport": 22,
- "protocol": 'TCP',
- },
- "mgmt_server": {
- "ipaddress": '1.2.2.152',
- "username": "root",
- "password": "password",
- "port": 22,
- },
- "templates": {
- "displaytext": 'Template',
- "name": 'Template',
- "ostype": "CentOS 5.3 (64-bit)",
- "templatefilter": 'self',
- },
- "test_dir": "/tmp",
- "random_data": "random.data",
- "snapshot_name": "TestSnapshot",
- "snapshot_displaytext": "Test",
- "ostype": "CentOS 5.3 (64-bit)",
- "sleep": 60,
- "timeout": 10,
- "mode": 'advanced', # Networking mode: Advanced, Basic
- }
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
class TestVmSnapshot(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(TestVmSnapshot, cls).getClsTestClient().getApiClient()
- cls.services = Services().services
+ testClient = super(TestVmSnapshot, cls).getClsTestClient()
+ cls.apiclient = testClient.getApiClient()
+ cls.services = testClient.getParsedTestDataConfig()
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.apiclient)
+ cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests())
template = get_template(
- cls.api_client,
+ cls.apiclient,
cls.zone.id,
cls.services["ostype"]
)
+ if template == FAILED:
+ assert False, "get_template() failed to return template with description %s" % cls.services["ostype"]
+
cls.services["domainid"] = cls.domain.id
cls.services["server"]["zoneid"] = cls.zone.id
cls.services["templates"]["ostypeid"] = template.ostypeid
@@ -100,27 +50,27 @@ class TestVmSnapshot(cloudstackTestCase):
# Create VMs, NAT Rules etc
cls.account = Account.create(
- cls.api_client,
+ cls.apiclient,
cls.services["account"],
domainid=cls.domain.id
)
- cls.services["account"] = cls.account.name
-
cls.service_offering = ServiceOffering.create(
- cls.api_client,
- cls.services["service_offering"]
+ cls.apiclient,
+ cls.services["service_offerings"]
)
cls.virtual_machine = VirtualMachine.create(
- cls.api_client,
+ cls.apiclient,
cls.services["server"],
templateid=template.id,
accountid=cls.account.name,
domainid=cls.account.domainid,
serviceofferingid=cls.service_offering.id,
- mode=cls.services["mode"]
+ mode=cls.zone.networktype
)
cls.random_data_0 = random_gen(size=100)
+ cls.test_dir = "/tmp"
+ cls.random_data = "random.data"
cls._cleanup = [
cls.service_offering,
cls.account,
@@ -131,7 +81,7 @@ class TestVmSnapshot(cloudstackTestCase):
def tearDownClass(cls):
try:
# Cleanup resources used
- cleanup_resources(cls.api_client, cls._cleanup)
+ cleanup_resources(cls.apiclient, cls._cleanup)
except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e)
return
@@ -160,8 +110,8 @@ class TestVmSnapshot(cloudstackTestCase):
ssh_client = self.virtual_machine.get_ssh_client()
cmds = [
- "echo %s > %s/%s" % (self.random_data_0, self.services["test_dir"], self.services["random_data"]),
- "cat %s/%s" % (self.services["test_dir"], self.services["random_data"])
+ "echo %s > %s/%s" % (self.random_data_0, self.test_dir, self.random_data),
+ "cat %s/%s" % (self.test_dir, self.random_data)
]
for c in cmds:
@@ -184,8 +134,8 @@ class TestVmSnapshot(cloudstackTestCase):
self.apiclient,
self.virtual_machine.id,
"false",
- self.services["snapshot_name"],
- self.services["snapshot_displaytext"]
+ "TestSnapshot",
+ "Dsiplay Text"
)
self.assertEqual(
vm_snapshot.state,
@@ -203,8 +153,8 @@ class TestVmSnapshot(cloudstackTestCase):
ssh_client = self.virtual_machine.get_ssh_client()
cmds = [
- "rm -rf %s/%s" % (self.services["test_dir"], self.services["random_data"]),
- "ls %s/%s" % (self.services["test_dir"], self.services["random_data"])
+ "rm -rf %s/%s" % (self.test_dir, self.random_data),
+ "ls %s/%s" % (self.test_dir, self.random_data)
]
for c in cmds:
@@ -263,7 +213,7 @@ class TestVmSnapshot(cloudstackTestCase):
ssh_client = self.virtual_machine.get_ssh_client(reconnect=True)
cmds = [
- "cat %s/%s" % (self.services["test_dir"], self.services["random_data"])
+ "cat %s/%s" % (self.test_dir, self.random_data)
]
for c in cmds:
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/smoke/test_volumes.py
----------------------------------------------------------------------
diff --git a/test/integration/smoke/test_volumes.py b/test/integration/smoke/test_volumes.py
index d358c8a..f3115af 100644
--- a/test/integration/smoke/test_volumes.py
+++ b/test/integration/smoke/test_volumes.py
@@ -17,14 +17,15 @@
""" BVT tests for Volumes
"""
#Import Local Modules
-import marvin
from marvin.cloudstackTestCase import *
from marvin.cloudstackException import *
from marvin.cloudstackAPI import *
from marvin.sshClient import SshClient
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
+from marvin.lib.utils import checkVolumeSize
+from marvin.codes import SUCCESS
from nose.plugins.attrib import attr
#Import System modules
import os
@@ -34,103 +35,55 @@ import tempfile
_multiprocess_shared_ = True
-class Services:
- """Test Volume Services
- """
-
- def __init__(self):
- self.services = {
- "account": {
- "email": "test@test.com",
- "firstname": "Test",
- "lastname": "User",
- "username": "test",
- # Random characters are appended for unique
- # username
- "password": "password",
- },
- "service_offering": {
- "name": "Tiny Instance",
- "displaytext": "Tiny Instance",
- "cpunumber": 1,
- "cpuspeed": 100, # in MHz
- "memory": 260 # In MBs
-
- },
- "disk_offering": {
- "displaytext": "Small",
- "name": "Small",
- "disksize": 1
- },
- 'resized_disk_offering': {
- "displaytext": "Resized",
- "name": "Resized",
- "disksize": 3
- },
- "volume_offerings": {
- 0: {
- "diskname": "TestDiskServ",
- },
- },
- "customdisksize": 1, # GBs
- "username": "root", # Creds for SSH to VM
- "password": "password",
- "ssh_port": 22,
- "diskname": "TestDiskServ",
- "hypervisor": 'KVM',
- "privateport": 22,
- "publicport": 22,
- "protocol": 'TCP',
- "ostype": 'CentOS 5.5 (64-bit)',
- "sleep": 10,
- "timeout": 600,
- }
-
-
class TestCreateVolume(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(TestCreateVolume, cls).getClsTestClient().getApiClient()
- cls.services = Services().services
-
+ testClient = super(TestCreateVolume, cls).getClsTestClient()
+ cls.apiclient = testClient.getApiClient()
+ cls.services = testClient.getParsedTestDataConfig()
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.apiclient)
+ cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests())
cls.services['mode'] = cls.zone.networktype
cls.disk_offering = DiskOffering.create(
- cls.api_client,
+ cls.apiclient,
cls.services["disk_offering"]
)
+ cls.sparse_disk_offering = DiskOffering.create(
+ cls.apiclient,
+ cls.services["sparse_disk_offering"]
+ )
cls.custom_disk_offering = DiskOffering.create(
- cls.api_client,
+ cls.apiclient,
cls.services["disk_offering"],
custom=True
)
template = get_template(
- cls.api_client,
+ cls.apiclient,
cls.zone.id,
cls.services["ostype"]
)
+ if template == FAILED:
+ assert False, "get_template() failed to return template with description %s" % cls.services["ostype"]
+
cls.services["domainid"] = cls.domain.id
cls.services["zoneid"] = cls.zone.id
cls.services["template"] = template.id
cls.services["customdiskofferingid"] = cls.custom_disk_offering.id
-
+ cls.services["diskname"] = cls.services["volume"]["diskname"]
# Create VMs, NAT Rules etc
cls.account = Account.create(
- cls.api_client,
+ cls.apiclient,
cls.services["account"],
domainid=cls.domain.id
)
-
- cls.services["account"] = cls.account.name
cls.service_offering = ServiceOffering.create(
- cls.api_client,
- cls.services["service_offering"]
+ cls.apiclient,
+ cls.services["service_offerings"]
)
cls.virtual_machine = VirtualMachine.create(
- cls.api_client,
+ cls.apiclient,
cls.services,
accountid=cls.account.name,
domainid=cls.account.domainid,
@@ -172,6 +125,18 @@ class TestCreateVolume(cloudstackTestCase):
self.debug("Created a volume with ID: %s" % volume.id)
self.volumes.append(volume)
+ if self.virtual_machine.hypervisor == "KVM":
+ sparse_volume = Volume.create(
+ self.apiClient,
+ self.services,
+ zoneid=self.zone.id,
+ account=self.account.name,
+ domainid=self.account.domainid,
+ diskofferingid=self.sparse_disk_offering.id
+ )
+ self.debug("Created a sparse volume: %s" % sparse_volume.id)
+ self.volumes.append(sparse_volume)
+
volume = Volume.create_custom_disk(
self.apiClient,
self.services,
@@ -227,7 +192,6 @@ class TestCreateVolume(cloudstackTestCase):
)
if isinstance(list_vm_response, list):
-
vm = list_vm_response[0]
if vm.state == 'Running':
self.debug("VM state: %s" % vm.state)
@@ -236,31 +200,17 @@ class TestCreateVolume(cloudstackTestCase):
if timeout == 0:
raise Exception(
"Failed to start VM (ID: %s) " % vm.id)
-
timeout = timeout - 1
- try:
- ssh = self.virtual_machine.get_ssh_client(
+ vol_sz = str(list_volume_response[0].size)
+ ssh = self.virtual_machine.get_ssh_client(
reconnect=True
)
- c = "/sbin/fdisk -l"
- res = ssh.execute(c)
-
- except Exception as e:
- self.fail("SSH access failed for VM: %s - %s" %
- (self.virtual_machine.ipaddress, e))
-
- # Disk /dev/sda doesn't contain a valid partition table
- # Disk /dev/sda: 21.5 GB, 21474836480 bytes
- result = str(res)
- self.debug("fdisk result: %s" % result)
-
- self.assertEqual(
- str(list_volume_response[0].size) in result,
- True,
- "Check if promised disk size actually available"
- )
+ ret = checkVolumeSize(ssh_handle=ssh,size_to_verify=vol_sz)
+ self.debug(" Volume Size Expected %s Actual :%s" %(vol_sz,ret[1]))
self.virtual_machine.detach_volume(self.apiClient, volume)
+ self.assertEqual(ret[0],SUCCESS,"Check if promised disk size actually available")
+ time.sleep(self.services["sleep"])
def tearDown(self):
#Clean up, terminate the created volumes
@@ -270,8 +220,8 @@ class TestCreateVolume(cloudstackTestCase):
@classmethod
def tearDownClass(cls):
try:
- cls.api_client = super(TestCreateVolume, cls).getClsTestClient().getApiClient()
- cleanup_resources(cls.api_client, cls._cleanup)
+ cls.apiclient = super(TestCreateVolume, cls).getClsTestClient().getApiClient()
+ cleanup_resources(cls.apiclient, cls._cleanup)
except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e)
@@ -280,31 +230,36 @@ class TestVolumes(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.api_client = super(TestVolumes, cls).getClsTestClient().getApiClient()
- cls.services = Services().services
+ testClient = super(TestVolumes, cls).getClsTestClient()
+ cls.apiclient = testClient.getApiClient()
+ cls.services = testClient.getParsedTestDataConfig()
+
# Get Zone, Domain and templates
- cls.domain = get_domain(cls.api_client, cls.services)
- cls.zone = get_zone(cls.api_client, cls.services)
+ cls.domain = get_domain(cls.apiclient)
+ cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests())
cls.services['mode'] = cls.zone.networktype
cls.disk_offering = DiskOffering.create(
- cls.api_client,
+ cls.apiclient,
cls.services["disk_offering"]
)
cls.resized_disk_offering = DiskOffering.create(
- cls.api_client,
+ cls.apiclient,
cls.services["resized_disk_offering"]
)
cls.custom_resized_disk_offering = DiskOffering.create(
- cls.api_client,
+ cls.apiclient,
cls.services["resized_disk_offering"],
custom=True
)
template = get_template(
- cls.api_client,
+ cls.apiclient,
cls.zone.id,
cls.services["ostype"]
)
+ if template == FAILED:
+ assert False, "get_template() failed to return template with description %s" % cls.services["ostype"]
+
cls.services["domainid"] = cls.domain.id
cls.services["zoneid"] = cls.zone.id
cls.services["template"] = template.id
@@ -314,18 +269,16 @@ class TestVolumes(cloudstackTestCase):
# Create VMs, VMs etc
cls.account = Account.create(
- cls.api_client,
+ cls.apiclient,
cls.services["account"],
domainid=cls.domain.id
)
-
- cls.services["account"] = cls.account.name
cls.service_offering = ServiceOffering.create(
- cls.api_client,
- cls.services["service_offering"]
+ cls.apiclient,
+ cls.services["service_offerings"]
)
cls.virtual_machine = VirtualMachine.create(
- cls.api_client,
+ cls.apiclient,
cls.services,
accountid=cls.account.name,
domainid=cls.account.domainid,
@@ -334,7 +287,7 @@ class TestVolumes(cloudstackTestCase):
)
cls.volume = Volume.create(
- cls.api_client,
+ cls.apiclient,
cls.services,
account=cls.account.name,
domainid=cls.account.domainid
@@ -351,7 +304,7 @@ class TestVolumes(cloudstackTestCase):
@classmethod
def tearDownClass(cls):
try:
- cleanup_resources(cls.api_client, cls._cleanup)
+ cleanup_resources(cls.apiclient, cls._cleanup)
except Exception as e:
raise Exception("Warning: Exception during cleanup : %s" % e)
@@ -767,7 +720,7 @@ class TestVolumes(cloudstackTestCase):
self.debug("Delete Volume ID: %s" % self.volume.id)
self.volume_1 = Volume.create(
- self.api_client,
+ self.apiclient,
self.services,
account=self.account.name,
domainid=self.account.domainid
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/test/integration/smoke/test_vpc_vpn.py
----------------------------------------------------------------------
diff --git a/test/integration/smoke/test_vpc_vpn.py b/test/integration/smoke/test_vpc_vpn.py
index d06fd29..1b28447 100644
--- a/test/integration/smoke/test_vpc_vpn.py
+++ b/test/integration/smoke/test_vpc_vpn.py
@@ -17,105 +17,29 @@
""" Tests for VPN in VPC
"""
#Import Local Modules
+from marvin.codes import FAILED
from marvin.cloudstackTestCase import *
from marvin.cloudstackAPI import *
-from marvin.integration.lib.utils import *
-from marvin.integration.lib.base import *
-from marvin.integration.lib.common import *
+from marvin.lib.utils import *
+from marvin.lib.base import *
+from marvin.lib.common import *
from nose.plugins.attrib import attr
import time
-class Services:
- def __init__(self):
- self.services = {
- "account": {
- "email": "test@test.com",
- "firstname": "Test",
- "lastname": "User",
- "username": "test",
- "password": "password",
- },
- "virtual_machine": {
- "displayname": "Test VM",
- "username": "root",
- "password": "password",
- "ssh_port": 22,
- "hypervisor": 'XenServer',
- "privateport": 22,
- "publicport": 22,
- "protocol": 'TCP',
- },
- "ostype": 'CentOS 5.3 (64-bit)',
- "service_offering": {
- "name": "Tiny Instance",
- "displaytext": "Tiny Instance",
- "cpunumber": 1,
- "cpuspeed": 100,
- "memory": 256,
- },
- "network_offering": {
- "name": "Network offering for internal vpc",
- "displaytext": "Network offering for internal vpc",
- "guestiptype": "Isolated",
- "traffictype": "Guest",
- "supportedservices": "Vpn,Dhcp,Dns,Lb,UserData,SourceNat,StaticNat,PortForwarding,NetworkACL",
- "serviceProviderList": {
- "Dhcp": "VpcVirtualRouter",
- "Dns": "VpcVirtualRouter",
- "Vpn": "VpcVirtualRouter",
- "UserData": "VpcVirtualRouter",
- "Lb": "InternalLbVM",
- "SourceNat": "VpcVirtualRouter",
- "StaticNat": "VpcVirtualRouter",
- "PortForwarding": "VpcVirtualRouter",
- "NetworkACL": "VpcVirtualRouter",
- },
- "serviceCapabilityList": {
- "SourceNat": {"SupportedSourceNatTypes": "peraccount"},
- "Lb": {"lbSchemes": "internal", "SupportedLbIsolation": "dedicated"}
- }
- },
- "vpn_user": {
- "username": "test",
- "password": "password",
- },
- "vpc": {
- "name": "vpc_vpn",
- "displaytext": "vpc-vpn",
- "cidr": "10.1.1.0/24"
- },
- "ntwk": {
- "name": "tier1",
- "displaytext": "vpc-tier1",
- "gateway" : "10.1.1.1",
- "netmask" : "255.255.255.192"
- },
- "vpc2": {
- "name": "vpc2_vpn",
- "displaytext": "vpc2-vpn",
- "cidr": "10.2.1.0/24"
- },
- "ntwk2": {
- "name": "tier2",
- "displaytext": "vpc-tier2",
- "gateway" : "10.2.1.1",
- "netmask" : "255.255.255.192"
- }
- }
-
-
class TestVpcRemoteAccessVpn(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.apiclient = super(TestVpcRemoteAccessVpn, cls).getClsTestClient().getApiClient()
- cls.services = Services().services
- cls.zone = get_zone(cls.apiclient, cls.services)
+ testClient = super(TestVpcRemoteAccessVpn, cls).getClsTestClient()
+ cls.apiclient = testClient.getApiClient()
+ cls.services = testClient.getParsedTestDataConfig()
+
+ cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests())
cls.domain = get_domain(cls.apiclient)
cls.service_offering = ServiceOffering.create(
cls.apiclient,
- cls.services["service_offering"]
+ cls.services["service_offerings"]
)
cls.account = Account.create(cls.apiclient, services=cls.services["account"])
cls.template = get_template(
@@ -123,6 +47,9 @@ class TestVpcRemoteAccessVpn(cloudstackTestCase):
cls.zone.id,
cls.services["ostype"]
)
+ if cls.template == FAILED:
+ assert False, "get_template() failed to return template with description %s" % cls.services["ostype"]
+
cls.cleanup = [cls.account]
@attr(tags=["advanced", "selfservice"])
@@ -211,13 +138,15 @@ class TestVpcSite2SiteVpn(cloudstackTestCase):
@classmethod
def setUpClass(cls):
- cls.apiclient = super(TestVpcSite2SiteVpn, cls).getClsTestClient().getApiClient()
- cls.services = Services().services
- cls.zone = get_zone(cls.apiclient, cls.services)
+ testClient = super(TestVpcSite2SiteVpn, cls).getClsTestClient()
+ cls.apiclient = testClient.getApiClient()
+ cls.services = testClient.getParsedTestDataConfig()
+
+ cls.zone = get_zone(cls.apiclient, testClient.getZoneForTests())
cls.domain = get_domain(cls.apiclient)
cls.service_offering = ServiceOffering.create(
cls.apiclient,
- cls.services["service_offering"]
+ cls.services["service_offerings"]
)
cls.account = Account.create(cls.apiclient, services=cls.services["account"])
cls.template = get_template(
@@ -225,6 +154,9 @@ class TestVpcSite2SiteVpn(cloudstackTestCase):
cls.zone.id,
cls.services["ostype"]
)
+ if cls.template == FAILED:
+ assert False, "get_template() failed to return template with description %s" % cls.services["ostype"]
+
cls.cleanup = [cls.account]
@attr(tags=["advanced", "selfservice"], BugId="CLOUDSTACK-6879")
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/tools/marvin/marvin/__init__.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/__init__.py b/tools/marvin/marvin/__init__.py
index 7af168e..7102e3f 100644
--- a/tools/marvin/marvin/__init__.py
+++ b/tools/marvin/marvin/__init__.py
@@ -15,4 +15,4 @@
# specific language governing permissions and limitations
# under the License.
-#Marvin - The cloudstack test client
+# Marvin - The cloudstack test client
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/798a6aa2/tools/marvin/marvin/asyncJobMgr.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/asyncJobMgr.py b/tools/marvin/marvin/asyncJobMgr.py
index e24170e..00e8c19 100644
--- a/tools/marvin/marvin/asyncJobMgr.py
+++ b/tools/marvin/marvin/asyncJobMgr.py
@@ -16,7 +16,7 @@
# under the License.
import threading
-import cloudstackException
+from marvin import cloudstackException
import time
import Queue
import copy
@@ -26,12 +26,14 @@ import datetime
class job(object):
+
def __init__(self):
self.id = None
self.cmd = None
class jobStatus(object):
+
def __init__(self):
self.result = None
self.status = None
@@ -47,6 +49,7 @@ class jobStatus(object):
class workThread(threading.Thread):
+
def __init__(self, in_queue, outqueue, apiClient, db=None, lock=None):
threading.Thread.__init__(self)
self.inqueue = in_queue
@@ -62,7 +65,7 @@ class workThread(threading.Thread):
try:
self.lock.acquire()
result = self.connection.poll(job.jobId, job.responsecls).jobresult
- except cloudstackException.cloudstackAPIException, e:
+ except cloudstackException.CloudstackAPIException as e:
result = str(e)
finally:
self.lock.release()
@@ -102,7 +105,7 @@ class workThread(threading.Thread):
except:
pass
jobstatus.status = True
- except cloudstackException.cloudstackAPIException, e:
+ except cloudstackException.CloudstackAPIException as e:
jobstatus.result = str(e)
jobstatus.status = False
except:
@@ -129,6 +132,7 @@ class workThread(threading.Thread):
class jobThread(threading.Thread):
+
def __init__(self, inqueue, interval):
threading.Thread.__init__(self)
self.inqueue = inqueue
@@ -149,12 +153,14 @@ class jobThread(threading.Thread):
class outputDict(object):
+
def __init__(self):
self.lock = threading.Condition()
self.dict = {}
class asyncJobMgr(object):
+
def __init__(self, apiClient, db):
self.inqueue = Queue.Queue()
self.output = outputDict()