From 414bf4f625059043bfb22b041789ffc7fff7f20d Mon Sep 17 00:00:00 2001 From: Prasanna Santhanam Date: Thu, 18 Apr 2013 07:54:57 +0530 Subject: [PATCH] marvin_refactor: subfactory support for users UserFactory will call on AccountFactory when it needs to be instantiated. Signed-off-by: Prasanna Santhanam --- tools/marvin/marvin/cloudstackConnection.py | 11 +++++------ .../marvin/integration/lib/factory/UserFactory.py | 6 +++--- .../integration/lib/factory/test/testFactories.py | 11 ++++++----- tools/marvin/marvin/integration/lib/utils.py | 1 - 4 files changed, 14 insertions(+), 15 deletions(-) diff --git a/tools/marvin/marvin/cloudstackConnection.py b/tools/marvin/marvin/cloudstackConnection.py index 2c027c36879..50131eb2c3f 100644 --- a/tools/marvin/marvin/cloudstackConnection.py +++ b/tools/marvin/marvin/cloudstackConnection.py @@ -22,17 +22,16 @@ import hmac import hashlib import logging import time -import cloudstackException -from cloudstackAPI import * -import jsonHelper +import marvin.cloudstackException +from marvin.cloudstackAPI import * +import marvin.jsonHelper from requests import ConnectionError from requests import HTTPError from requests import Timeout from requests import RequestException -class cloudConnection(object): - +class CloudConnection(object): """ Connections to make API calls to the cloudstack management server """ def __init__(self, mgmtDet, asyncTimeout=3600, logging=None, @@ -61,7 +60,7 @@ class cloudConnection(object): % (self.protocol, self.mgtSvr, self.port, self.path) def __copy__(self): - return cloudConnection(self.mgtSvr, self.port, self.user, + return CloudConnection(self.mgtSvr, self.port, self.user, self.passwd, self.apiKey, self.securityKey, self.asyncTimeout, self.logging, diff --git a/tools/marvin/marvin/integration/lib/factory/UserFactory.py b/tools/marvin/marvin/integration/lib/factory/UserFactory.py index 9f0cc77d03d..1b13b8bcbec 100644 --- a/tools/marvin/marvin/integration/lib/factory/UserFactory.py +++ b/tools/marvin/marvin/integration/lib/factory/UserFactory.py @@ -16,14 +16,14 @@ # under the License. import factory from marvin.integration.lib.base import User -from marvin.integration.lib.factory import CloudStackBaseFactory +from marvin.integration.lib.factory.CloudStackBaseFactory import CloudStackBaseFactory from marvin.integration.lib.factory.AccountFactory import AccountFactory class UserFactory(CloudStackBaseFactory): FACTORY_FOR = User.User - account = factory.SubFactory(AccountFactory) + account = factory.SubFactory(AccountFactory).factory() email = account.email firstname = account.firstname lastname = account.lastname @@ -31,4 +31,4 @@ class UserFactory(CloudStackBaseFactory): username = account.username class AdminUserFactory(UserFactory): - account = factory.SubFactory(AccountFactory, accounttype=1) + account = factory.SubFactory(AccountFactory, accounttype=1).factory() diff --git a/tools/marvin/marvin/integration/lib/factory/test/testFactories.py b/tools/marvin/marvin/integration/lib/factory/test/testFactories.py index c7a0a2c4075..cb7165f825a 100644 --- a/tools/marvin/marvin/integration/lib/factory/test/testFactories.py +++ b/tools/marvin/marvin/integration/lib/factory/test/testFactories.py @@ -16,6 +16,7 @@ # under the License. import unittest +import logging from marvin.cloudstackTestClient import cloudstackTestClient from marvin.integration.lib.common import get_template @@ -40,7 +41,7 @@ from marvin.integration.lib.base.User import User class AccountFactoryTest(unittest.TestCase): def setUp(self): - self.apiClient = cloudstackTestClient(mgtSvr='localhost').getApiClient() + self.apiClient = cloudstackTestClient(mgtSvr='localhost', logging=logging.getLogger('factories.cloudstack')).getApiClient() def test_userAccountFactory(self): af = AccountFactory() @@ -74,7 +75,7 @@ class AccountFactoryTest(unittest.TestCase): class ServiceOfferingFactoryTest(unittest.TestCase): def setUp(self): - self.apiClient = cloudstackTestClient(mgtSvr='localhost').getApiClient() + self.apiClient = cloudstackTestClient(mgtSvr='localhost', logging=logging.getLogger('factories.cloudstack')).getApiClient() def test_serviceOfferingFactory(self): sf = ServiceOfferingFactory() @@ -89,7 +90,7 @@ class ServiceOfferingFactoryTest(unittest.TestCase): class NetworkOfferingFactoryTest(unittest.TestCase): def setUp(self): - self.apiClient = cloudstackTestClient(mgtSvr='localhost').getApiClient() + self.apiClient = cloudstackTestClient(mgtSvr='localhost', logging=logging.getLogger('factories.cloudstack')).getApiClient() def test_defaultSourceNatOfferingFactory(self): snatOfferingFactory = DefaultIsolatedNetworkOfferingWithSourceNatServiceFactory() @@ -107,7 +108,7 @@ class NetworkOfferingFactoryTest(unittest.TestCase): class VirtualMachineFactoryTest(unittest.TestCase): def setUp(self): - self.apiClient = cloudstackTestClient(mgtSvr='localhost').getApiClient() + self.apiClient = cloudstackTestClient(mgtSvr='localhost', logging=logging.getLogger('factories.cloudstack')).getApiClient() def tearDown(self): pass @@ -123,7 +124,7 @@ class VirtualMachineFactoryTest(unittest.TestCase): class UserFactorySubFactoryTest(unittest.TestCase): def setUp(self): - self.apiClient = cloudstackTestClient(mgtSvr='localhost').getApiClient() + self.apiClient = cloudstackTestClient(mgtSvr='localhost', logging=logging.getLogger('factories.cloudstack')).getApiClient() def tearDown(self): pass diff --git a/tools/marvin/marvin/integration/lib/utils.py b/tools/marvin/marvin/integration/lib/utils.py index 7d662af265c..3170ea73003 100644 --- a/tools/marvin/marvin/integration/lib/utils.py +++ b/tools/marvin/marvin/integration/lib/utils.py @@ -176,7 +176,6 @@ def get_host_credentials(config, hostip): 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"""