cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t..@apache.org
Subject [47/49] git commit: updated refs/heads/marvin_refactor to 0b5fe9a
Date Sun, 21 Apr 2013 17:03:58 GMT
ipaddress factories

ipaddress doesn't require id to associate but only when disassociate


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/e7ac9e68
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/e7ac9e68
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/e7ac9e68

Branch: refs/heads/marvin_refactor
Commit: e7ac9e687b7787420883e3557fc13d42a51e91b7
Parents: f4006bf
Author: Prasanna Santhanam <tsp@apache.org>
Authored: Sun Apr 21 22:31:00 2013 +0530
Committer: Prasanna Santhanam <tsp@apache.org>
Committed: Sun Apr 21 22:31:00 2013 +0530

----------------------------------------------------------------------
 tools/marvin/marvin/base/IpAddress.py             |    2 +-
 tools/marvin/marvin/factory/IpAddressFactory.py   |    4 +-
 tools/marvin/marvin/factory/test/testFactories.py |   43 +++++++++++++++-
 3 files changed, 45 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e7ac9e68/tools/marvin/marvin/base/IpAddress.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/base/IpAddress.py b/tools/marvin/marvin/base/IpAddress.py
index 6fdfe1e..43d82a1 100644
--- a/tools/marvin/marvin/base/IpAddress.py
+++ b/tools/marvin/marvin/base/IpAddress.py
@@ -36,7 +36,7 @@ class IpAddress(CloudStackEntity.CloudStackEntity):
 
     def associate(self, apiclient, **kwargs):
         cmd = associateIpAddress.associateIpAddressCmd()
-        cmd.id = self.id
+#        cmd.id = self.id
         [setattr(cmd, key, value) for key,value in kwargs.iteritems()]
         ipaddress = apiclient.associateIpAddress(cmd)
         return ipaddress

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e7ac9e68/tools/marvin/marvin/factory/IpAddressFactory.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/factory/IpAddressFactory.py b/tools/marvin/marvin/factory/IpAddressFactory.py
index 6c14e9a..bb4cc8b 100644
--- a/tools/marvin/marvin/factory/IpAddressFactory.py
+++ b/tools/marvin/marvin/factory/IpAddressFactory.py
@@ -15,10 +15,10 @@
 # specific language governing permissions and limitations
 # under the License.
 import factory
-from marvin.base import IpAddress
+from marvin.base.IpAddress import IpAddress
 
 
 class IpAddressFactory(factory.Factory):
 
-    FACTORY_FOR = IpAddress.IpAddress
+    FACTORY_FOR = IpAddress
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e7ac9e68/tools/marvin/marvin/factory/test/testFactories.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/factory/test/testFactories.py b/tools/marvin/marvin/factory/test/testFactories.py
index 81bcca6..d4e947e 100644
--- a/tools/marvin/marvin/factory/test/testFactories.py
+++ b/tools/marvin/marvin/factory/test/testFactories.py
@@ -28,9 +28,12 @@ from marvin.factory.VirtualMachineFactory import *
 from marvin.factory.UserFactory import *
 
 
-from marvin.base.Zone import *
+from marvin.base.ServiceOffering import ServiceOffering
+from marvin.base.Zone import Zone
 from marvin.base.Account import Account
 from marvin.base.Template import Template
+from marvin.base.IpAddress import IpAddress
+from marvin.base.Network import Network
 
 
 
@@ -148,3 +151,41 @@ class UserFactorySubFactoryTest(unittest.TestCase):
         self.assert_(uf.username == user[0].username, msg="Usernames don't match")
 
 
+class IpAddressFactoryTest(unittest.TestCase):
+    def setUp(self):
+        self.apiClient = cloudstackTestClient(mgtSvr='localhost', logging=logging.getLogger('factories.cloudstack')).getApiClient()
+
+    def tearDown(self):
+        pass
+
+    def test_associateIpAddress(self):
+        all_ips = IpAddress.list(apiclient=self.apiClient)
+        self.assert_(len(all_ips) > 0, msg="No free public IPs")
+        firstip = all_ips[0]
+        firstip.associate(apiclient=self.apiClient, zoneid=firstip.zoneid)
+
+    def test_vpcAssociateIpAddress(self):
+        #FIXME: To be written
+        self.assert_(1 == 1)
+
+    def test_associateIpAddressToNetwork(self):
+        accnt = AccountFactory.create(apiclient=self.apiClient)
+        self.assert_(accnt is not None)
+        self.assert_(isinstance(accnt, Account))
+        service = ServiceOffering.list(apiclient=self.apiClient, displaytext='Small')
+        self.assert_(len(service) > 0)
+        template = Template.list(apiclient=self.apiClient, templatefilter="featured")
+        self.assert_(len(template) > 0)
+        zones = Zone.list(apiclient=self.apiClient)
+        vm = VirtualMachineFactory.create(
+            apiclient=self.apiClient,
+            serviceofferingid = service[0].id,
+            templateid = template[0].id,
+            zoneid = zones[0].id,
+            account=accnt.account.name,
+            domainid=accnt.account.domainid)
+        all_ips = IpAddress.list(apiclient=self.apiClient)
+        firstip = all_ips[0]
+        networks = Network.list(apiclient=self.apiClient, account = accnt.account.name, domainid
= accnt.account.domainid)
+        firstip.associate(apiclient=self.apiClient, networkid = networks[0].id)
+        vm.destroy(apiclient=self.apiClient)
\ No newline at end of file


Mime
View raw message