You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ts...@apache.org on 2013/06/28 21:22:22 UTC

[01/29] git commit: updated refs/heads/master-6-17-stable to 93712c2

Updated Branches:
  refs/heads/master-6-17-stable ab185fb2b -> 93712c271


CLOUDSTACK-2882: Correct the secondary disk device on KVM

On kvm the disk device serial order is /dev/vda|vdb|vdc and so on.
This also fixes CLOUDSTACK-3018 and removes the redundant test in
blocker bugs. The snapshot related tests are now include in snapshots
suite.

Signed-off-by: Prasanna Santhanam <ts...@apache.org>
(cherry picked from commit 8801205fcf5c0fa8553e41d9730828134a16a7fd)


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

Branch: refs/heads/master-6-17-stable
Commit: eeb8a2fccc77ed8ebf316348f0ef08cb170c802a
Parents: db10cd3
Author: Prasanna Santhanam <ts...@apache.org>
Authored: Tue Jun 18 12:45:39 2013 +0530
Committer: Prasanna Santhanam <ts...@apache.org>
Committed: Sat Jun 29 00:52:06 2013 +0530

----------------------------------------------------------------------
 test/integration/component/test_blocker_bugs.py | 303 -------------------
 test/integration/component/test_snapshots.py    | 247 +++++++++------
 2 files changed, 150 insertions(+), 400 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/eeb8a2fc/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 d099bf1..1f7ac97 100644
--- a/test/integration/component/test_blocker_bugs.py
+++ b/test/integration/component/test_blocker_bugs.py
@@ -68,11 +68,6 @@ class Services:
                                     "publicport": 22,
                                     "protocol": 'TCP',
                         },
-                        "volume": {
-                                   "diskname": "APP Data Volume",
-                                   "size": 1,   # in GBs
-                                   "diskdevice": "/dev/xvdb",   # Data Disk
-                        },
                         "templates": {
                                     "displaytext": 'Template from snapshot',
                                     "name": 'Template from snapshot',
@@ -86,13 +81,6 @@ class Services:
                                     "isextractable": True,
                                     "passwordenabled": True,
                         },
-                        "paths": {
-                                    "mount_dir": "/mnt/tmp",
-                                    "sub_dir": "test",
-                                    "sub_lvl_dir1": "test1",
-                                    "sub_lvl_dir2": "test2",
-                                    "random_data": "random.data",
-                        },
                         "static_nat": {
                                     "startport": 22,
                                     "endport": 22,
@@ -104,297 +92,6 @@ class Services:
                      }
 
 
-class TestSnapshots(cloudstackTestCase):
-
-    @classmethod
-    def setUpClass(cls):
-        cls.api_client = super(TestSnapshots, 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.services['mode'] = cls.zone.networktype
-        cls.disk_offering = DiskOffering.create(
-                                    cls.api_client,
-                                    cls.services["disk_offering"]
-                                    )
-        cls.template = get_template(
-                            cls.api_client,
-                            cls.zone.id,
-                            cls.services["ostype"]
-                            )
-        cls.services["virtual_machine"]["zoneid"] = cls.zone.id
-        cls.services["volume"]["zoneid"] = cls.zone.id
-
-        cls.services["template"] = cls.template.id
-        cls.services["zoneid"] = cls.zone.id
-
-        # Create VMs, NAT Rules etc
-        cls.account = Account.create(
-                            cls.api_client,
-                            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.virtual_machine = VirtualMachine.create(
-                                cls.api_client,
-                                cls.services["virtual_machine"],
-                                templateid=cls.template.id,
-                                accountid=cls.account.name,
-                                domainid=cls.account.domainid,
-                                serviceofferingid=cls.service_offering.id,
-                                mode=cls.services["mode"]
-                                )
-
-        cls._cleanup = [
-                        cls.service_offering,
-                        cls.disk_offering,
-                        cls.account,
-                        ]
-        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 created instance, volumes and snapshots
-            cleanup_resources(self.apiclient, self.cleanup)
-        except Exception as e:
-            raise Exception("Warning: Exception during cleanup : %s" % e)
-        return
-
-    @attr(tags = ["advanced", "advancedns"])
-    def test_01_volume_from_snapshot(self):
-        """TS_BUG_001-Test Creating snapshot from volume having spaces in name(KVM)
-        """
-
-
-        # Validate the following
-        #1. Create a virtual machine and data volume
-        #2. Attach data volume to VM
-        #3. Login to machine; create temp/test directories on data volume
-        #4. Snapshot the Volume
-        #5. Create another Volume from snapshot
-        #6. Mount/Attach volume to another server
-        #7. Compare data
-
-        random_data_0 = random_gen(100)
-        random_data_1 = random_gen(100)
-
-        volume = Volume.create(
-                               self.apiclient,
-                               self.services["volume"],
-                               zoneid=self.zone.id,
-                               account=self.account.name,
-                               domainid=self.account.domainid,
-                               diskofferingid=self.disk_offering.id
-                               )
-        self.debug("Created volume with ID: %s" % volume.id)
-        self.virtual_machine.attach_volume(
-                                           self.apiclient,
-                                           volume
-                                           )
-        self.debug("Attach volume: %s to VM: %s" %
-                                (volume.id, self.virtual_machine.id))
-        try:
-            ssh_client = self.virtual_machine.get_ssh_client()
-        except Exception as e:
-            self.fail("SSH failed for VM: %s" %
-                      self.virtual_machine.ipaddress)
-
-        self.debug("Formatting volume: %s to ext3" % volume.id)
-        #Format partition using ext3
-        format_volume_to_ext3(
-                              ssh_client,
-                              self.services["volume"]["diskdevice"]
-                              )
-        cmds = [
-                    "mkdir -p %s" % self.services["paths"]["mount_dir"],
-                    "mount %s1 %s" % (
-                                      self.services["volume"]["diskdevice"],
-                                      self.services["paths"]["mount_dir"]
-                                      ),
-                    "mkdir -p %s/%s/{%s,%s} " % (
-                                    self.services["paths"]["mount_dir"],
-                                    self.services["paths"]["sub_dir"],
-                                    self.services["paths"]["sub_lvl_dir1"],
-                                    self.services["paths"]["sub_lvl_dir2"]
-                                    ),
-                    "echo %s > %s/%s/%s/%s" % (
-                                    random_data_0,
-                                    self.services["paths"]["mount_dir"],
-                                    self.services["paths"]["sub_dir"],
-                                    self.services["paths"]["sub_lvl_dir1"],
-                                    self.services["paths"]["random_data"]
-                                    ),
-                    "echo %s > %s/%s/%s/%s" % (
-                                    random_data_1,
-                                    self.services["paths"]["mount_dir"],
-                                    self.services["paths"]["sub_dir"],
-                                    self.services["paths"]["sub_lvl_dir2"],
-                                    self.services["paths"]["random_data"]
-                                    ),
-                ]
-        for c in cmds:
-            self.debug("Command: %s" % c)
-            ssh_client.execute(c)
-
-        # Unmount the Sec Storage
-        cmds = [
-                    "umount %s" % (self.services["paths"]["mount_dir"]),
-                ]
-        for c in cmds:
-            self.debug("Command: %s" % c)
-            ssh_client.execute(c)
-
-        list_volume_response = Volume.list(
-                                    self.apiclient,
-                                    virtualmachineid=self.virtual_machine.id,
-                                    type='DATADISK',
-                                    listall=True
-                                    )
-
-        self.assertEqual(
-                         isinstance(list_volume_response, list),
-                         True,
-                         "Check list volume response for valid data"
-                         )
-        volume_response = list_volume_response[0]
-        #Create snapshot from attached volume
-        snapshot = Snapshot.create(
-                                   self.apiclient,
-                                   volume_response.id,
-                                   account=self.account.name,
-                                   domainid=self.account.domainid
-                                   )
-        self.debug("Created snapshot: %s" % snapshot.id)
-        #Create volume from snapshot
-        volume_from_snapshot = Volume.create_from_snapshot(
-                                        self.apiclient,
-                                        snapshot.id,
-                                        self.services["volume"],
-                                        account=self.account.name,
-                                        domainid=self.account.domainid
-                                        )
-        self.debug("Created Volume: %s from Snapshot: %s" % (
-                                            volume_from_snapshot.id,
-                                            snapshot.id))
-        volumes = Volume.list(
-                                self.apiclient,
-                                id=volume_from_snapshot.id
-                                )
-        self.assertEqual(
-                            isinstance(volumes, list),
-                            True,
-                            "Check list response returns a valid list"
-                        )
-
-        self.assertNotEqual(
-                            len(volumes),
-                            None,
-                            "Check Volume list Length"
-                      )
-        self.assertEqual(
-                        volumes[0].id,
-                        volume_from_snapshot.id,
-                        "Check Volume in the List Volumes"
-                    )
-        #Attaching volume to new VM
-        new_virtual_machine = VirtualMachine.create(
-                                    self.apiclient,
-                                    self.services["virtual_machine"],
-                                    templateid=self.template.id,
-                                    accountid=self.account.name,
-                                    domainid=self.account.domainid,
-                                    serviceofferingid=self.service_offering.id,
-                                    mode=self.services["mode"]
-                                )
-        self.debug("Deployed new VM for account: %s" % self.account.name)
-        self.cleanup.append(new_virtual_machine)
-
-        self.debug("Attaching volume: %s to VM: %s" % (
-                                            volume_from_snapshot.id,
-                                            new_virtual_machine.id
-                                            ))
-
-        cmd = attachVolume.attachVolumeCmd()
-        cmd.id = volume_from_snapshot.id
-        cmd.virtualmachineid = new_virtual_machine.id
-        self.apiclient.attachVolume(cmd)
-
-        try:
-            #Login to VM to verify test directories and files
-            ssh = new_virtual_machine.get_ssh_client()
-
-            cmds = [
-                    "mkdir -p %s" % self.services["paths"]["mount_dir"],
-                    "mount %s1 %s" % (
-                                      self.services["volume"]["diskdevice"],
-                                      self.services["paths"]["mount_dir"]
-                                      ),
-               ]
-
-            for c in cmds:
-                self.debug("Command: %s" % c)
-                ssh.execute(c)
-
-            returned_data_0 = ssh.execute(
-                            "cat %s/%s/%s/%s" % (
-                                    self.services["paths"]["mount_dir"],
-                                    self.services["paths"]["sub_dir"],
-                                    self.services["paths"]["sub_lvl_dir1"],
-                                    self.services["paths"]["random_data"]
-                            ))
-            returned_data_1 = ssh.execute(
-                            "cat %s/%s/%s/%s" % (
-                                    self.services["paths"]["mount_dir"],
-                                    self.services["paths"]["sub_dir"],
-                                    self.services["paths"]["sub_lvl_dir2"],
-                                    self.services["paths"]["random_data"]
-                            ))
-        except Exception as e:
-            self.fail("SSH access failed for VM: %s" %
-                                new_virtual_machine.ipaddress)
-        #Verify returned data
-        self.assertEqual(
-                random_data_0,
-                returned_data_0[0],
-                "Verify newly attached volume contents with existing one"
-                )
-        self.assertEqual(
-                random_data_1,
-                returned_data_1[0],
-                "Verify newly attached volume contents with existing one"
-                )
-        # Unmount the Sec Storage
-        cmds = [
-                    "umount %s" % (self.services["paths"]["mount_dir"]),
-                ]
-        for c in cmds:
-            self.debug("Command: %s" % c)
-            ssh_client.execute(c)
-        return
-
-
 class TestTemplate(cloudstackTestCase):
 
     def setUp(self):

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/eeb8a2fc/test/integration/component/test_snapshots.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_snapshots.py b/test/integration/component/test_snapshots.py
index 014b55a..708a8b2 100644
--- a/test/integration/component/test_snapshots.py
+++ b/test/integration/component/test_snapshots.py
@@ -108,6 +108,18 @@ class Services:
                                     "ostype": "CentOS 5.3 (64-bit)",
                                     "templatefilter": 'self',
                                 },
+                        "volume": {
+                                   "diskname": "APP Data Volume",
+                                   "size": 1,   # in GBs
+                                   "diskdevice": "/dev/xvdb",   # Data Disk
+                        },
+                        "paths": {
+                                    "mount_dir": "/mnt/tmp",
+                                    "sub_dir": "test",
+                                    "sub_lvl_dir1": "test1",
+                                    "sub_lvl_dir2": "test2",
+                                    "random_data": "random.data",
+                        },
                         "diskdevice": "/dev/xvda",
                         "diskname": "TestDiskServ",
                         "size": 1,  # GBs
@@ -377,6 +389,11 @@ class TestSnapshots(cloudstackTestCase):
         cls.services["zoneid"] = cls.zone.id
         cls.services["diskoffering"] = cls.disk_offering.id
 
+        #determine device type from hypervisor
+        hosts = Host.list(cls.api_client, id=cls.virtual_machine.hostid)
+        if len(hosts) > 0 and hosts[0].hypervisor.lower() == "kvm":
+            cls.service["volume"]["diskdevice"] = "/dev/vdb"
+
         # Create VMs, NAT Rules etc
         cls.account = Account.create(
                             cls.api_client,
@@ -583,81 +600,102 @@ class TestSnapshots(cloudstackTestCase):
         return
 
     @attr(speed = "slow")
-    @attr(tags = ["advanced", "advancedns", "smoke", "xen"])
-    def test_03_volume_from_snapshot(self):
-        """Create volumes from snapshots
+    @attr(tags = ["advanced", "advancedns", "basic", "sg"])
+    def test_01_volume_from_snapshot(self):
+        """Test Creating snapshot from volume having spaces in name(KVM)
         """
-        #1. Login to machine; create temp/test directories on data volume
-        #2. Snapshot the Volume
-        #3. Create another Volume from snapshot
-        #4. Mount/Attach volume to another server
-        #5. Compare data
+        # Validate the following
+        #1. Create a virtual machine and data volume
+        #2. Attach data volume to VM
+        #3. Login to machine; create temp/test directories on data volume
+        #4. Snapshot the Volume
+        #5. Create another Volume from snapshot
+        #6. Mount/Attach volume to another server
+        #7. Compare data
+
         random_data_0 = random_gen(100)
         random_data_1 = random_gen(100)
 
+        volume = Volume.create(
+                               self.apiclient,
+                               self.services["volume"],
+                               zoneid=self.zone.id,
+                               account=self.account.name,
+                               domainid=self.account.domainid,
+                               diskofferingid=self.disk_offering.id
+                               )
+        self.debug("Created volume with ID: %s" % volume.id)
+        self.virtual_machine.attach_volume(
+                                           self.apiclient,
+                                           volume
+                                           )
+        self.debug("Attach volume: %s to VM: %s" %
+                                (volume.id, self.virtual_machine.id))
+
+
         try:
             ssh_client = self.virtual_machine.get_ssh_client()
+        except Exception as e:
+            self.fail("SSH failed for VM: %s" %
+                      self.virtual_machine.ipaddress)
 
-            #Format partition using ext3
-            format_volume_to_ext3(
+        self.debug("Formatting volume: %s to ext3" % volume.id)
+        #Format partition using ext3
+        format_volume_to_ext3(
                               ssh_client,
-                              self.services["diskdevice"]
+                              self.services["volume"]["diskdevice"]
                               )
-            cmds = [
-                    "mkdir -p %s" % self.services["mount_dir"],
+        cmds = [
+                    "mkdir -p %s" % self.services["paths"]["mount_dir"],
                     "mount %s1 %s" % (
-                                      self.services["diskdevice"],
-                                      self.services["mount_dir"]
+                                      self.services["volume"]["diskdevice"],
+                                      self.services["paths"]["mount_dir"]
                                       ),
                     "mkdir -p %s/%s/{%s,%s} " % (
-                                                self.services["mount_dir"],
-                                                self.services["sub_dir"],
-                                                self.services["sub_lvl_dir1"],
-                                                self.services["sub_lvl_dir2"]
-                                            ),
+                                    self.services["paths"]["mount_dir"],
+                                    self.services["paths"]["sub_dir"],
+                                    self.services["paths"]["sub_lvl_dir1"],
+                                    self.services["paths"]["sub_lvl_dir2"]
+                                    ),
                     "echo %s > %s/%s/%s/%s" % (
-                                                random_data_0,
-                                                self.services["mount_dir"],
-                                                self.services["sub_dir"],
-                                                self.services["sub_lvl_dir1"],
-                                                self.services["random_data"]
-                                            ),
+                                    random_data_0,
+                                    self.services["paths"]["mount_dir"],
+                                    self.services["paths"]["sub_dir"],
+                                    self.services["paths"]["sub_lvl_dir1"],
+                                    self.services["paths"]["random_data"]
+                                    ),
                     "echo %s > %s/%s/%s/%s" % (
-                                                random_data_1,
-                                                self.services["mount_dir"],
-                                                self.services["sub_dir"],
-                                                self.services["sub_lvl_dir2"],
-                                                self.services["random_data"]
-                                            ),
+                                    random_data_1,
+                                    self.services["paths"]["mount_dir"],
+                                    self.services["paths"]["sub_dir"],
+                                    self.services["paths"]["sub_lvl_dir2"],
+                                    self.services["paths"]["random_data"]
+                                    ),
                 ]
-            for c in cmds:
-                self.debug(c)
-                ssh_client.execute(c)
+        for c in cmds:
+            self.debug("Command: %s" % c)
+            ssh_client.execute(c)
 
-        except Exception as e:
-            self.fail("SSH failed for VM with IP: %s" %
-                                self.virtual_machine.ipaddress)
         # Unmount the Sec Storage
         cmds = [
-                    "umount %s" % (self.services["mount_dir"]),
+                    "umount %s" % (self.services["paths"]["mount_dir"]),
                 ]
+        for c in cmds:
+            self.debug("Command: %s" % c)
+            ssh_client.execute(c)
 
-        try:
-            for c in cmds:
-                self.debug(c)
-                ssh_client.execute(c)
-
-        except Exception as e:
-            self.fail("SSH failed for VM with IP: %s" %
-                                self.virtual_machine.ipaddress)
-
-        list_volume_response = list_volumes(
+        list_volume_response = Volume.list(
                                     self.apiclient,
                                     virtualmachineid=self.virtual_machine.id,
                                     type='DATADISK',
                                     listall=True
                                     )
 
+        self.assertEqual(
+                         isinstance(list_volume_response, list),
+                         True,
+                         "Check list volume response for valid data"
+                         )
         volume_response = list_volume_response[0]
         #Create snapshot from attached volume
         snapshot = Snapshot.create(
@@ -666,81 +704,94 @@ class TestSnapshots(cloudstackTestCase):
                                    account=self.account.name,
                                    domainid=self.account.domainid
                                    )
-        self.debug("Created Snapshot from volume: %s" % volume_response.id)
-
+        self.debug("Created snapshot: %s" % snapshot.id)
         #Create volume from snapshot
-        self.debug("Creating volume from snapshot: %s" % snapshot.id)
-        volume = Volume.create_from_snapshot(
+        volume_from_snapshot = Volume.create_from_snapshot(
                                         self.apiclient,
                                         snapshot.id,
-                                        self.services,
+                                        self.services["volume"],
                                         account=self.account.name,
                                         domainid=self.account.domainid
                                         )
-
-        volumes = list_volumes(
+        self.debug("Created Volume: %s from Snapshot: %s" % (
+                                            volume_from_snapshot.id,
+                                            snapshot.id))
+        volumes = Volume.list(
                                 self.apiclient,
-                                id=volume.id
+                                id=volume_from_snapshot.id
                                 )
         self.assertEqual(
                             isinstance(volumes, list),
                             True,
                             "Check list response returns a valid list"
                         )
+
         self.assertNotEqual(
                             len(volumes),
                             None,
                             "Check Volume list Length"
                       )
-
         self.assertEqual(
                         volumes[0].id,
-                        volume.id,
+                        volume_from_snapshot.id,
                         "Check Volume in the List Volumes"
                     )
         #Attaching volume to new VM
-        new_virtual_machine = self.virtual_machine_without_disk
+        new_virtual_machine = VirtualMachine.create(
+                                    self.apiclient,
+                                    self.services["server_without_disk"],
+                                    templateid=self.template.id,
+                                    accountid=self.account.name,
+                                    domainid=self.account.domainid,
+                                    serviceofferingid=self.service_offering.id,
+                                    mode=self.services["mode"]
+                                )
+        self.debug("Deployed new VM for account: %s" % self.account.name)
         self.cleanup.append(new_virtual_machine)
 
-        cmd = attachVolume.attachVolumeCmd()
-        cmd.id = volume.id
-        cmd.virtualmachineid = new_virtual_machine.id
-        self.apiclient.attachVolume(cmd)
+        self.debug("Attaching volume: %s to VM: %s" % (
+                                            volume_from_snapshot.id,
+                                            new_virtual_machine.id
+                                            ))
+
+        self.new_virtual_machine.attach_volume(
+                                           self.apiclient,
+                                           volume_from_snapshot
+                                           )
 
         try:
             #Login to VM to verify test directories and files
             ssh = new_virtual_machine.get_ssh_client()
 
             cmds = [
-                    "mkdir -p %s" % self.services["mount_dir"],
+                    "mkdir -p %s" % self.services["paths"]["mount_dir"],
                     "mount %s1 %s" % (
-                                      self.services["diskdevice"],
-                                      self.services["mount_dir"]
+                                      self.services["volume"]["diskdevice"],
+                                      self.services["paths"]["mount_dir"]
                                       ),
                ]
 
             for c in cmds:
-                self.debug(c)
-                result = ssh.execute(c)
-                self.debug(result)
-
-            returned_data_0 = ssh.execute("cat %s/%s/%s/%s" % (
-                                                self.services["mount_dir"],
-                                                self.services["sub_dir"],
-                                                self.services["sub_lvl_dir1"],
-                                                self.services["random_data"]
-                                    ))
-            returned_data_1 = ssh.execute("cat %s/%s/%s/%s" % (
-                                                self.services["mount_dir"],
-                                                self.services["sub_dir"],
-                                                self.services["sub_lvl_dir2"],
-                                                self.services["random_data"]
-                                    ))
+                self.debug("Command: %s" % c)
+                ssh.execute(c)
 
+            returned_data_0 = ssh.execute(
+                            "cat %s/%s/%s/%s" % (
+                                    self.services["paths"]["mount_dir"],
+                                    self.services["paths"]["sub_dir"],
+                                    self.services["paths"]["sub_lvl_dir1"],
+                                    self.services["paths"]["random_data"]
+                            ))
+            returned_data_1 = ssh.execute(
+                            "cat %s/%s/%s/%s" % (
+                                    self.services["paths"]["mount_dir"],
+                                    self.services["paths"]["sub_dir"],
+                                    self.services["paths"]["sub_lvl_dir2"],
+                                    self.services["paths"]["random_data"]
+                            ))
         except Exception as e:
-            self.fail("SSH failed for VM with IP: %s" %
-                                self.new_virtual_machine.ipaddress)
-
+            self.fail("SSH access failed for VM: %s" %
+                                new_virtual_machine.ipaddress)
         #Verify returned data
         self.assertEqual(
                 random_data_0,
@@ -754,15 +805,11 @@ class TestSnapshots(cloudstackTestCase):
                 )
         # Unmount the Sec Storage
         cmds = [
-                    "umount %s" % (self.services["mount_dir"]),
+                    "umount %s" % (self.services["paths"]["mount_dir"]),
                 ]
-        try:
-            for c in cmds:
-                ssh_client.execute(c)
-
-        except Exception as e:
-            self.fail("SSH failed for VM with IP: %s" %
-                                self.new_virtual_machine.ipaddress)
+        for c in cmds:
+            self.debug("Command: %s" % c)
+            ssh_client.execute(c)
         return
 
     @attr(speed = "slow")
@@ -1182,6 +1229,7 @@ class TestSnapshots(cloudstackTestCase):
                                     new_virtual_machine.ipaddress)
         return
 
+
 class TestCreateVMsnapshotTemplate(cloudstackTestCase):
 
     @classmethod
@@ -1560,7 +1608,7 @@ class TestAccountSnapshotClean(cloudstackTestCase):
         return
 
     @attr(speed = "slow")
-    @attr(tags = ["advanced", "advancedns"])
+    @attr(tags = ["advanced", "advancedns", "basic", "sg"])
     def test_02_accountSnapshotClean(self):
         """Test snapshot cleanup after account deletion
         """
@@ -1852,6 +1900,11 @@ class TestSnapshotDetachedDisk(cloudstackTestCase):
 
         cls.services["template"] = template.id
 
+        #determine device type from hypervisor
+        hosts = Host.list(cls.api_client, id=cls.virtual_machine.hostid)
+        if len(hosts) > 0 and hosts[0].hypervisor.lower() == "kvm":
+            cls.service["volume"]["diskdevice"] = "/dev/vdb"
+
         # Create VMs, NAT Rules etc
         cls.account = Account.create(
                             cls.api_client,
@@ -1905,7 +1958,7 @@ class TestSnapshotDetachedDisk(cloudstackTestCase):
         return
 
     @attr(speed = "slow")
-    @attr(tags = ["advanced", "advancedns", "xen"])
+    @attr(tags = ["advanced", "advancedns", "basic", "sg"])
     def test_03_snapshot_detachedDisk(self):
         """Test snapshot from detached disk
         """
@@ -1941,7 +1994,7 @@ class TestSnapshotDetachedDisk(cloudstackTestCase):
             #Format partition using ext3
             format_volume_to_ext3(
                               ssh_client,
-                              self.services["diskdevice"]
+                              self.services["volume"]["diskdevice"]
                               )
             cmds = [
                     "mkdir -p %s" % self.services["mount_dir"],


[19/29] git commit: updated refs/heads/master-6-17-stable to 93712c2

Posted by ts...@apache.org.
Baremetal: Test cases
(cherry picked from commit b0a3210695a0759cf4fb7110987886dc81cac8b2)


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

Branch: refs/heads/master-6-17-stable
Commit: 77a01f34f1518b2fc4fb42538e28769a0ef2ce2d
Parents: 07f28ae
Author: Sheng Yang <sh...@citrix.com>
Authored: Thu Jun 20 16:44:06 2013 -0700
Committer: Prasanna Santhanam <ts...@apache.org>
Committed: Sat Jun 29 00:52:08 2013 +0530

----------------------------------------------------------------------
 test/integration/component/test_baremetal.py | 122 ++++++++++++++++++++++
 1 file changed, 122 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/77a01f34/test/integration/component/test_baremetal.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_baremetal.py b/test/integration/component/test_baremetal.py
new file mode 100644
index 0000000..887010b
--- /dev/null
+++ b/test/integration/component/test_baremetal.py
@@ -0,0 +1,122 @@
+# 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 for baremetal
+"""
+#Import Local Modules
+import marvin
+from marvin.cloudstackTestCase import *
+from marvin.cloudstackAPI import *
+from marvin import remoteSSHClient
+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 telnetlib
+
+#Import System modules
+import time
+_multiprocess_shared_ = True
+
+class Services:
+    """Test Baremetal
+    """
+
+    def __init__(self):
+        self.services = {
+                         "network_offering": {
+                                    "name": 'Baremetal_network_offering',
+                                    "displaytext": 'Baremetal_network_offering',
+                                    "guestiptype": 'Shared',
+                                    "supportedservices": 'Dhcp,UserData,BaremetalPxeService',
+                                    "specifyVlan": "true",
+                                    "specifyIpRanges": "true",
+                                    "traffictype": 'GUEST',
+                                    "availability": 'Optional',
+                                    "conservemode": 'false',
+                                    "serviceProviderList": {
+                                            "Dhcp": 'BaremetalDhcpProvider',
+                                            "UserData": 'BaremetalUserdataProvider',
+                                            "BaremetalPxeService": 'BaremetalPxeProvider',
+                                        },
+                                    },
+                         "network" :{
+                                     "name" : "defaultBaremetalNetwork",
+                                     "displaytext" : "defaultBaremetalNetwork",
+                                     },
+                         "ostype": 'CentOS 5.3 (64-bit)',
+                         # Cent OS 5.3 (64 bit)
+                         "sleep": 60,
+                         "timeout": 10,
+                    }
+class TestBaremetal(cloudstackTestCase):
+    zoneid = 1
+
+    def setUp(self):
+        self.apiclient = self.testClient.getApiClient()
+        self.services = Services().services
+        self.cleanup = []
+
+    def tearDown(self):
+        try:
+            self.debug("Cleaning up the resources")
+            #Clean up, terminate the created network offerings
+            cleanup_resources(self.apiclient, self.cleanup)
+            self.debug("Cleanup complete!")
+        except Exception as e:
+            raise Exception("Warning: Exception during cleanup : %s" % e)
+        return
+
+    @attr(tags = ["baremetal", "basic"])
+    def test_baremetal(self):
+        self.debug("Test create baremetal network offering")
+        networkoffering = NetworkOffering.create(self.apiclient, self.services["network_offering"])
+        networkoffering.update(self.apiclient, state="Enabled")
+        self.cleanup.append(networkoffering)
+
+        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(
+                                          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(
+                                          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(
+                                          self.apiclient,
+                                          id=userdata_provider.id,
+                                          state='Enabled'
+                                          )
+
+        network = Network.create(self.apiclient, self.services["network"], zoneid=self.zoneid, networkofferingid=networkoffering.id)
+        self.cleanup.insert(0, network)
+
+        pod = Pod.list(self.apiclient)[0]
+        cmd = createVlanIpRange.createVlanIpRangeCmd()
+        cmd.podid = pod.id
+        cmd.networkid = network.id
+        cmd.gateway = "10.1.1.1"
+        cmd.netmask = "255.255.255.0"
+        cmd.startip = "10.1.1.20"
+        cmd.endip = "10.1.1.40"
+        cmd.forVirtualNetwork="false"
+        response = self.apiclient.createVlanIpRange(cmd)


[13/29] git commit: updated refs/heads/master-6-17-stable to 93712c2

Posted by ts...@apache.org.
NAT rule creation gives ipaddress as nat_rule.ipaddress

Signed-off-by: Prasanna Santhanam <ts...@apache.org>
(cherry picked from commit 97eb35c82b1a5a638818391d6a1dbdcb2a9e3990)


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

Branch: refs/heads/master-6-17-stable
Commit: 8c28f007b7923964adfa7cf12e84f246411b8b2e
Parents: 9d970a0
Author: Prasanna Santhanam <ts...@apache.org>
Authored: Tue Jun 18 14:22:26 2013 +0530
Committer: Prasanna Santhanam <ts...@apache.org>
Committed: Sat Jun 29 00:52:07 2013 +0530

----------------------------------------------------------------------
 test/integration/smoke/test_network.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8c28f007/test/integration/smoke/test_network.py
----------------------------------------------------------------------
diff --git a/test/integration/smoke/test_network.py b/test/integration/smoke/test_network.py
index a75ffeb..121bda0 100644
--- a/test/integration/smoke/test_network.py
+++ b/test/integration/smoke/test_network.py
@@ -1163,7 +1163,7 @@ class TestRebootRouter(cloudstackTestCase):
             self.debug("SSH into VM (ID : %s ) after reboot" % self.vm_1.id)
 
             remoteSSHClient(
-                                    self.nat_rule.ipaddress.ipaddress,
+                                    self.nat_rule.ipaddress,
                                     self.services["natrule"]["publicport"],
                                     self.vm_1.username,
                                     self.vm_1.password


[28/29] git commit: updated refs/heads/master-6-17-stable to 93712c2

Posted by ts...@apache.org.
Fix reviewboard messup of python indentation

Signed-off-by: Prasanna Santhanam <ts...@apache.org>
(cherry picked from commit 8dc99d92b6f82e435610dfcc01d3458a99503119)


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

Branch: refs/heads/master-6-17-stable
Commit: 3789548cdf1657251e11df4cf6a5bd50a64f0200
Parents: 012a2d2
Author: Prasanna Santhanam <ts...@apache.org>
Authored: Wed Jun 26 17:12:54 2013 +0530
Committer: Prasanna Santhanam <ts...@apache.org>
Committed: Sat Jun 29 00:52:09 2013 +0530

----------------------------------------------------------------------
 test/integration/smoke/test_routers.py | 64 ++++++++++++++---------------
 1 file changed, 32 insertions(+), 32 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3789548c/test/integration/smoke/test_routers.py
----------------------------------------------------------------------
diff --git a/test/integration/smoke/test_routers.py b/test/integration/smoke/test_routers.py
index 2e4553b..6fa08e0 100644
--- a/test/integration/smoke/test_routers.py
+++ b/test/integration/smoke/test_routers.py
@@ -171,7 +171,7 @@ class TestRouterServices(cloudstackTestCase):
                             "Check list host returns a valid list"
                         )
         host = hosts[0]
-        
+
         self.debug("Router ID: %s, state: %s" % (router.id, router.state))
 
         self.assertEqual(
@@ -180,32 +180,32 @@ class TestRouterServices(cloudstackTestCase):
                             "Check list router response for router state"
                         )
 
-   if self.apiclient.hypervisor.lower() == 'vmware':
-           result = get_process_status(
-                               self.apiclient.connection.mgtSvr,
-                               22,
-                           self.apiclient.connection.user,
-                           self.apiclient.connection.passwd,
-                           router.linklocalip,
-                           "service dnsmasq status",
-                               hypervisor=self.apiclient.hypervisor
-                           )
-   else:
-            result = get_process_status(
-                                host.ipaddress,
-                                self.services['virtual_machine']["publicport"],
-                                self.vm_1.username,
-                                self.vm_1.password,
-                                router.linklocalip,
-                                "service dnsmasq status"
-                                )
-        res = str(result)
-        self.debug("Dnsmasq process status: %s" % res)
+        if self.apiclient.hypervisor.lower() == 'vmware':
+               result = get_process_status(
+                                   self.apiclient.connection.mgtSvr,
+                                   22,
+                               self.apiclient.connection.user,
+                               self.apiclient.connection.passwd,
+                               router.linklocalip,
+                               "service dnsmasq status",
+                                   hypervisor=self.apiclient.hypervisor
+                               )
+        else:
+                result = get_process_status(
+                                    host.ipaddress,
+                                    self.services['virtual_machine']["publicport"],
+                                    self.vm_1.username,
+                                    self.vm_1.password,
+                                    router.linklocalip,
+                                    "service dnsmasq status"
+                                    )
+                res = str(result)
+                self.debug("Dnsmasq process status: %s" % res)
 
-        self.assertEqual(
-                            res.count("running"),
-                            1,
-                            "Check dnsmasq service is running or not"
+                self.assertEqual(
+                                res.count("running"),
+                                1,
+                                "Check dnsmasq service is running or not"
                         )
         return
 
@@ -253,7 +253,7 @@ class TestRouterServices(cloudstackTestCase):
                             "Check list router response for router state"
                         )
 
-   if self.apiclient.hypervisor.lower() == 'vmware':
+        if self.apiclient.hypervisor.lower() == 'vmware':
            result = get_process_status(
                            self.apiclient.connection.mgtSvr,
                                22,
@@ -263,7 +263,7 @@ class TestRouterServices(cloudstackTestCase):
                            "service dnsmasq status",
                                hypervisor=self.apiclient.hypervisor
                            )
-   else:
+        else:
             result = get_process_status(
                                 host.ipaddress,
                                 self.services['virtual_machine']["publicport"],
@@ -281,7 +281,7 @@ class TestRouterServices(cloudstackTestCase):
                             "Check dnsmasq service is running or not"
                         )
 
-   if self.apiclient.hypervisor.lower() == 'vmware':
+        if self.apiclient.hypervisor.lower() == 'vmware':
            result = get_process_status(
                                self.apiclient.connection.mgtSvr,
                            22,
@@ -291,7 +291,7 @@ class TestRouterServices(cloudstackTestCase):
                            "service haproxy status",
                            hypervisor=self.apiclient.hypervisor
                            )
-   else:
+        else:
             result = get_process_status(
                                 host.ipaddress,
                                 self.services['virtual_machine']["publicport"],
@@ -456,7 +456,7 @@ class TestRouterServices(cloudstackTestCase):
                         )
         host = hosts[0]
 
-   if self.apiclient.hypervisor.lower() == 'vmware':
+        if self.apiclient.hypervisor.lower() == 'vmware':
            res = get_process_status(
                            self.apiclient.connection.mgtSvr,
                            22,
@@ -466,7 +466,7 @@ class TestRouterServices(cloudstackTestCase):
                            "uptime",
                            hypervisor=self.apiclient.hypervisor
                            )
-   else:
+        else:
             res = get_process_status(
                                 host.ipaddress,
                                 self.services['virtual_machine']["publicport"],


[06/29] Split Redundant Router tests

Posted by ts...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b9524157/test/integration/component/test_redundant_router_network_rules.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_redundant_router_network_rules.py b/test/integration/component/test_redundant_router_network_rules.py
new file mode 100644
index 0000000..3806bef
--- /dev/null
+++ b/test/integration/component/test_redundant_router_network_rules.py
@@ -0,0 +1,1416 @@
+# 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.
+
+from nose.plugins.attrib import attr
+from marvin.integration.lib.base import *
+from marvin.integration.lib.utils import *
+from marvin.integration.lib.common import *
+
+#Import Local Modules
+from marvin.cloudstackTestCase import cloudstackTestCase
+from marvin.cloudstackAPI import *
+
+class Services:
+    """Test Services for customer defects
+    """
+
+    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,
+                                    "memory": 128,
+                        },
+                        "disk_offering": {
+                                    "displaytext": "Small",
+                                    "name": "Small",
+                                    "disksize": 1
+                        },
+                        "virtual_machine": {
+                                    "displayname": "Test VM",
+                                    "username": "root",
+                                    "password": "password",
+                                    "ssh_port": 22,
+                                    "hypervisor": 'XenServer',
+                                    "privateport": 22,
+                                    "publicport": 22,
+                                    "protocol": 'TCP',
+                        },
+                        "static_nat": {
+                                    "startport": 22,
+                                    "endport": 22,
+                                    "protocol": "TCP"
+                        },
+                        "network_offering": {
+                                    "name": 'Network offering-RVR services',
+                                    "displaytext": 'Network off-RVR services',
+                                    "guestiptype": 'Isolated',
+                                    "supportedservices": 'Vpn,Dhcp,Dns,SourceNat,PortForwarding,Firewall,Lb,UserData,StaticNat',
+                                    "traffictype": 'GUEST',
+                                    "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"
+                                        },
+                                    },
+                        },
+                        "host": {
+                                 "username": "root",
+                                 "password": "password",
+                                 "publicport": 22,
+                        },
+                        "network": {
+                                  "name": "Test Network",
+                                  "displaytext": "Test Network",
+                                },
+                        "lbrule": {
+                                    "name": "SSH",
+                                    "alg": "roundrobin",
+                                    # Algorithm used for load balancing
+                                    "privateport": 22,
+                                    "publicport": 22,
+                                    "openfirewall": True,
+                                },
+                        "natrule": {
+                                    "privateport": 22,
+                                    "publicport": 22,
+                                    "protocol": "TCP"
+                                },
+                        "natrule_221": {
+                                    "privateport": 22,
+                                    "publicport": 221,
+                                    "protocol": "TCP"
+                                },
+                        "fw_rule": {
+                                    "startport": 1,
+                                    "endport": 6000,
+                                    "cidr": '55.55.0.0/11',
+                                    # Any network (For creating FW rule)
+                                    "protocol": 'TCP',
+                                },
+                        "ostype": 'CentOS 5.3 (64-bit)',
+                        "sleep": 60,
+            }
+
+class TestRedundantRouterRulesLifeCycle(cloudstackTestCase):
+
+    @classmethod
+    def setUpClass(cls):
+        cls.api_client = super(
+                               TestRedundantRouterRulesLifeCycle,
+                               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.template = get_template(
+                            cls.api_client,
+                            cls.zone.id,
+                            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.network_offering = NetworkOffering.create(
+                                            cls.api_client,
+                                            cls.services["network_offering"],
+                                            conservemode=True
+                                            )
+        # Enable Network offering
+        cls.network_offering.update(cls.api_client, state='Enabled')
+
+        cls._cleanup = [
+                        cls.service_offering,
+                        cls.network_offering,
+                        ]
+        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.account = Account.create(
+                                     self.apiclient,
+                                     self.services["account"],
+                                     admin=True,
+                                     domainid=self.domain.id
+                                     )
+        self._clean.insert(0, self.account)
+        return
+
+    @attr(tags=["advanced", "advancedns", "ssh"])
+    def test_applyNetworkRules_MasterDown_deleteNetworkRules(self):
+        """Test apply network rules when master & backup routers rebooted
+        """
+
+        # Steps to validate
+        # 1. listNetworks should show the created network in allocated state
+        # 2. listRouters returns no running routers
+        # 3. VMs should be deployed and in Running state
+        # 4. should list MASTER and BACKUP routers
+        # 5. listPublicIpAddresses for networkid should show acquired IP addr
+        # 6. listStaticNats for the network associated
+        # 7. listFirewallRules should show allowed ports open
+        # 8. ssh to succeed to the guestVM
+        # 9. listPublicIpAddresses for networkid should show acquired IP addr
+        # 10. listPortForwardRules to show open ports 221, 222
+        # 11. ssh should succeed for both ports
+        # 12. listPublicIpAddresses for networkid should show acquired IP addr
+        # 13 and 14. listLoadBalancerRules should show associated VMs for
+        #    public IP
+        # 15. ssh should succeed to the user VMs
+        # 16. listRouters should show one Router in MASTER state and Running
+        # 17. ssh should work for PF, FW, and LB ips
+        # 18. listRouters should show both routers MASTER and BACKUP in
+        #    Running state
+        # 19. listPortForwardingRules, listFirewallRules, listLoadBalancerRule
+        #    should return empty response
+        # 20. listPublicIpAddresses should show now more addresses
+
+        # Creating network using the network offering created
+        self.debug("Creating network with network offering: %s" %
+                                                    self.network_offering.id)
+        network = Network.create(
+                                self.apiclient,
+                                self.services["network"],
+                                accountid=self.account.name,
+                                domainid=self.account.domainid,
+                                networkofferingid=self.network_offering.id,
+                                zoneid=self.zone.id
+                                )
+        self.debug("Created network with ID: %s" % network.id)
+
+        networks = Network.list(
+                                self.apiclient,
+                                id=network.id,
+                                listall=True
+                                )
+        self.assertEqual(
+            isinstance(networks, list),
+            True,
+            "List networks should return a valid response for created network"
+             )
+        nw_response = networks[0]
+
+        self.debug("Network state: %s" % nw_response.state)
+        self.assertEqual(
+                    nw_response.state,
+                    "Allocated",
+                    "The network should be in allocated state after creation"
+                    )
+
+        self.debug("Listing routers for network: %s" % network.name)
+        routers = Router.list(
+                              self.apiclient,
+                              networkid=network.id,
+                              listall=True
+                              )
+        self.assertEqual(
+            routers,
+            None,
+            "Routers should not be spawned when network is in allocated state"
+            )
+
+        self.debug("Deploying VM in account: %s" % self.account.name)
+
+        # Spawn an instance in that network
+        virtual_machine = VirtualMachine.create(
+                                  self.apiclient,
+                                  self.services["virtual_machine"],
+                                  accountid=self.account.name,
+                                  domainid=self.account.domainid,
+                                  serviceofferingid=self.service_offering.id,
+                                  networkids=[str(network.id)]
+                                  )
+        self.debug("Deployed VM in network: %s" % network.id)
+
+        vms = VirtualMachine.list(
+                                  self.apiclient,
+                                  id=virtual_machine.id,
+                                  listall=True
+                                  )
+        self.assertEqual(
+                         isinstance(vms, list),
+                         True,
+                         "List Vms should return a valid list"
+                         )
+        vm = vms[0]
+        self.assertEqual(
+                         vm.state,
+                         "Running",
+                         "Vm should be in running state after deployment"
+                         )
+
+        self.debug("Listing routers for network: %s" % network.name)
+        routers = Router.list(
+                              self.apiclient,
+                              networkid=network.id,
+                              listall=True
+                              )
+        self.assertEqual(
+                    isinstance(routers, list),
+                    True,
+                    "list router should return Master and backup routers"
+                    )
+        self.assertEqual(
+                    len(routers),
+                    2,
+                    "Length of the list router should be 2 (Backup & master)"
+                    )
+
+        if routers[0].redundantstate == 'MASTER':
+            master_router = routers[0]
+            backup_router = routers[1]
+        else:
+            master_router = routers[1]
+            backup_router = routers[0]
+
+        self.debug("Associating public IP for network: %s" % network.name)
+        public_ip = PublicIPAddress.create(
+                                self.apiclient,
+                                accountid=self.account.name,
+                                zoneid=self.zone.id,
+                                domainid=self.account.domainid,
+                                networkid=network.id
+                                )
+        self.debug("Associated %s with network %s" % (
+                                        public_ip.ipaddress.ipaddress,
+                                        network.id
+                                        ))
+        self.debug("Enabling static NAT for IP: %s" %
+                                            public_ip.ipaddress.ipaddress)
+        try:
+            static_nat = StaticNATRule.create(
+                                    self.apiclient,
+                                    self.services["fw_rule"],
+                                    ipaddressid=public_ip.ipaddress.id
+                                  )
+            static_nat.enable(
+                              self.apiclient,
+                              ipaddressid=public_ip.ipaddress.id,
+                              virtualmachineid=virtual_machine.id
+                              )
+            self.debug("Static NAT enabled for IP: %s" %
+                                            public_ip.ipaddress.ipaddress)
+        except Exception as e:
+            self.fail("Failed to enable static NAT on IP: %s - %s" % (
+                                            public_ip.ipaddress.ipaddress, e))
+
+        public_ips = PublicIPAddress.list(
+                                          self.apiclient,
+                                          networkid=network.id,
+                                          listall=True,
+                                          isstaticnat=True
+                                          )
+        self.assertEqual(
+                         isinstance(public_ips, list),
+                         True,
+                         "List public Ip for network should list the Ip addr"
+                         )
+        self.assertEqual(
+                         public_ips[0].ipaddress,
+                         public_ip.ipaddress.ipaddress,
+                         "List public Ip for network should list the Ip addr"
+                         )
+
+        self.debug("creating a FW rule on IP: %s" %
+                                    public_ip.ipaddress.ipaddress)
+        fw_rule = FireWallRule.create(
+                            self.apiclient,
+                            ipaddressid=public_ip.ipaddress.id,
+                            protocol='TCP',
+                            cidrlist=[self.services["fw_rule"]["cidr"]],
+                            startport=self.services["fw_rule"]["startport"],
+                            endport=self.services["fw_rule"]["endport"]
+                            )
+        self.debug("Created a firewall rule on 22 port of IP: %s" %
+                                            public_ip.ipaddress.ipaddress)
+
+        self.debug("Associating public IP for network: %s" % network.name)
+        public_ip_2 = PublicIPAddress.create(
+                                self.apiclient,
+                                accountid=self.account.name,
+                                zoneid=self.zone.id,
+                                domainid=self.account.domainid,
+                                networkid=network.id
+                                )
+        self.debug("Associated %s with network %s" % (
+                                        public_ip_2.ipaddress.ipaddress,
+                                        network.id
+                                        ))
+
+        nat_rule = NATRule.create(
+                                  self.apiclient,
+                                  virtual_machine,
+                                  self.services["natrule_221"],
+                                  ipaddressid=public_ip_2.ipaddress.id,
+                                  openfirewall=True
+                                  )
+
+        self.debug("Associating public IP for network: %s" % network.name)
+        public_ip_3 = PublicIPAddress.create(
+                                self.apiclient,
+                                accountid=self.account.name,
+                                zoneid=self.zone.id,
+                                domainid=self.account.domainid,
+                                networkid=network.id
+                                )
+        self.debug("Associated %s with network %s" % (
+                                        public_ip_3.ipaddress.ipaddress,
+                                        network.id
+                                        ))
+
+        self.debug("Creating LB rule for IP address: %s" %
+                                        public_ip_3.ipaddress.ipaddress)
+
+        lb_rule = LoadBalancerRule.create(
+                                    self.apiclient,
+                                    self.services["lbrule"],
+                                    ipaddressid=public_ip_3.ipaddress.id,
+                                    accountid=self.account.name,
+                                    networkid=network.id
+                                )
+
+        self.debug("Adding %s to the LB rule %s" % (
+                                                virtual_machine.name,
+                                                lb_rule.name
+                                                ))
+        lb_rule.assign(self.apiclient, [virtual_machine])
+
+        self.debug("Starting router ID: %s" % master_router.id)
+
+        for router in routers:
+            try:
+                self.debug("Rebooting router ID: %s" % master_router.id)
+                #Stop the router
+                cmd = rebootRouter.rebootRouterCmd()
+                cmd.id = router.id
+                self.apiclient.rebootRouter(cmd)
+            except Exception as e:
+                self.fail("Failed to reboot router..")
+
+        self.debug("Listing routers for network: %s" % network.name)
+        routers = Router.list(
+                              self.apiclient,
+                              networkid=network.id,
+                              listall=True
+                              )
+        self.assertEqual(
+                    isinstance(routers, list),
+                    True,
+                    "list router should return Master and backup routers"
+                    )
+        self.assertEqual(
+                    len(routers),
+                    2,
+                    "Length of the list router should be 2 (Backup & master)"
+                    )
+        for router in routers:
+            self.assertEqual(
+                             router.state,
+                             "Running",
+                             "Router state should be running"
+                             )
+        self.debug("Trying to SSH into the virtual machine")
+        try:
+            virtual_machine.get_ssh_client(
+                                    ipaddress=public_ip.ipaddress.ipaddress)
+            self.debug("SSH to guest VM succeeded")
+        except Exception as e:
+            self.fail("SSH to guest VM failed: %s" % e)
+
+        self.debug("Trying to SSH into the virtual machine")
+        try:
+            virtual_machine.get_ssh_client(
+                                ipaddress=public_ip_2.ipaddress.ipaddress,
+                                reconnect=True,
+                                port=self.services["natrule_221"]["publicport"]
+                               )
+            self.debug("SSH to guest VM succeeded")
+        except Exception as e:
+            self.fail("SSH to guest VM failed: %s" % e)
+
+        self.debug("Trying to SSH into the virtual machine")
+        try:
+            virtual_machine.get_ssh_client(
+                                ipaddress=public_ip_3.ipaddress.ipaddress,
+                                reconnect=True,
+                                port=self.services["lbrule"]["publicport"]
+                               )
+            self.debug("SSH to guest VM succeeded")
+        except Exception as e:
+            self.fail("SSH to guest VM failed: %s" % e)
+
+        return
+
+    @attr(tags=["advanced", "advancedns", "ssh"])
+    def test_applyRules_restartRvRNetwork(self):
+        """Test apply rules after network restart
+        """
+
+        # Steps to validate
+        # 1. listNetworks should show the created network in allocated state
+        # 2. listRouters returns no running routers
+        # 3. VMs should be deployed and in Running state
+        # 4. should list MASTER and BACKUP routers
+        # 5. listPublicIpAddresses for networkid should show acquired IP addr
+        # 6. listStaticNats for the network associated
+        # 7. listFirewallRules should show allowed ports open
+        # 8. ssh to succeed to the guestVM
+        # 9. listPublicIpAddresses for networkid should show acquired IP addr
+        # 10. listPortForwardRules to show open ports 221, 222
+        # 11. ssh should succeed for both ports
+        # 12. listPublicIpAddresses for networkid should show acquired IP addr
+        # 13 and 14. listLoadBalancerRules should show associated VMs for
+        #    public IP
+        # 15. ssh should succeed to the user VMs
+        # 16. listRouters should show one Router in MASTER state and Running &
+        #    one in BACKUP and Running
+        # 17. ssh should work for PF, FW, and LB ips
+        # 18. listRouters should show one Router in MASTER state and Running &
+        #    one in BACKUP and Running
+        # 19. ssh should work for PF, FW, and LB ips
+        # 20. listPortForwardingRules, listFirewallRules, listLoadBalancerRule
+        #     should return empty response
+        # 21. listPublicIpAddresses should show now more addresses
+
+        # Creating network using the network offering created
+        self.debug("Creating network with network offering: %s" %
+                                                    self.network_offering.id)
+        network = Network.create(
+                                self.apiclient,
+                                self.services["network"],
+                                accountid=self.account.name,
+                                domainid=self.account.domainid,
+                                networkofferingid=self.network_offering.id,
+                                zoneid=self.zone.id
+                                )
+        self.debug("Created network with ID: %s" % network.id)
+
+        networks = Network.list(
+                                self.apiclient,
+                                id=network.id,
+                                listall=True
+                                )
+        self.assertEqual(
+            isinstance(networks, list),
+            True,
+            "List networks should return a valid response for created network"
+             )
+        nw_response = networks[0]
+
+        self.debug("Network state: %s" % nw_response.state)
+        self.assertEqual(
+                    nw_response.state,
+                    "Allocated",
+                    "The network should be in allocated state after creation"
+                    )
+
+        self.debug("Listing routers for network: %s" % network.name)
+        routers = Router.list(
+                              self.apiclient,
+                              networkid=network.id,
+                              listall=True
+                              )
+        self.assertEqual(
+            routers,
+            None,
+            "Routers should not be spawned when network is in allocated state"
+            )
+
+        self.debug("Deploying VM in account: %s" % self.account.name)
+
+        # Spawn an instance in that network
+        virtual_machine = VirtualMachine.create(
+                                  self.apiclient,
+                                  self.services["virtual_machine"],
+                                  accountid=self.account.name,
+                                  domainid=self.account.domainid,
+                                  serviceofferingid=self.service_offering.id,
+                                  networkids=[str(network.id)]
+                                  )
+        self.debug("Deployed VM in network: %s" % network.id)
+
+        vms = VirtualMachine.list(
+                                  self.apiclient,
+                                  id=virtual_machine.id,
+                                  listall=True
+                                  )
+        self.assertEqual(
+                         isinstance(vms, list),
+                         True,
+                         "List Vms should return a valid list"
+                         )
+        vm = vms[0]
+        self.assertEqual(
+                         vm.state,
+                         "Running",
+                         "Vm should be in running state after deployment"
+                         )
+
+        self.debug("Listing routers for network: %s" % network.name)
+        routers = Router.list(
+                              self.apiclient,
+                              networkid=network.id,
+                              listall=True
+                              )
+        self.assertEqual(
+                    isinstance(routers, list),
+                    True,
+                    "list router should return Master and backup routers"
+                    )
+        self.assertEqual(
+                    len(routers),
+                    2,
+                    "Length of the list router should be 2 (Backup & master)"
+                    )
+
+        if routers[0].redundantstate == 'MASTER':
+            master_router = routers[0]
+            backup_router = routers[1]
+        else:
+            master_router = routers[1]
+            backup_router = routers[0]
+
+        self.debug("Associating public IP for network: %s" % network.name)
+        public_ip = PublicIPAddress.create(
+                                self.apiclient,
+                                accountid=self.account.name,
+                                zoneid=self.zone.id,
+                                domainid=self.account.domainid,
+                                networkid=network.id
+                                )
+        self.debug("Associated %s with network %s" % (
+                                        public_ip.ipaddress.ipaddress,
+                                        network.id
+                                        ))
+        self.debug("Enabling static NAT for IP: %s" %
+                                            public_ip.ipaddress.ipaddress)
+        try:
+            static_nat = StaticNATRule.create(
+                                    self.apiclient,
+                                    self.services["fw_rule"],
+                                    ipaddressid=public_ip.ipaddress.id
+                                  )
+            static_nat.enable(
+                              self.apiclient,
+                              ipaddressid=public_ip.ipaddress.id,
+                              virtualmachineid=virtual_machine.id
+                              )
+            self.debug("Static NAT enabled for IP: %s" %
+                                            public_ip.ipaddress.ipaddress)
+        except Exception as e:
+            self.fail("Failed to enable static NAT on IP: %s - %s" % (
+                                            public_ip.ipaddress.ipaddress, e))
+
+        public_ips = PublicIPAddress.list(
+                                          self.apiclient,
+                                          networkid=network.id,
+                                          listall=True,
+                                          isstaticnat=True
+                                          )
+        self.assertEqual(
+                         isinstance(public_ips, list),
+                         True,
+                         "List public Ip for network should list the Ip addr"
+                         )
+        self.assertEqual(
+                         public_ips[0].ipaddress,
+                         public_ip.ipaddress.ipaddress,
+                         "List public Ip for network should list the Ip addr"
+                         )
+
+        self.debug("creating a FW rule on IP: %s" %
+                                    public_ip.ipaddress.ipaddress)
+        fw_rule = FireWallRule.create(
+                            self.apiclient,
+                            ipaddressid=public_ip.ipaddress.id,
+                            protocol='TCP',
+                            cidrlist=[self.services["fw_rule"]["cidr"]],
+                            startport=self.services["fw_rule"]["startport"],
+                            endport=self.services["fw_rule"]["endport"]
+                            )
+        self.debug("Created a firewall rule on 22 port of IP: %s" %
+                                            public_ip.ipaddress.ipaddress)
+
+        self.debug("Associating public IP for network: %s" % network.name)
+        public_ip_2 = PublicIPAddress.create(
+                                self.apiclient,
+                                accountid=self.account.name,
+                                zoneid=self.zone.id,
+                                domainid=self.account.domainid,
+                                networkid=network.id
+                                )
+        self.debug("Associated %s with network %s" % (
+                                        public_ip_2.ipaddress.ipaddress,
+                                        network.id
+                                        ))
+
+        nat_rule = NATRule.create(
+                                  self.apiclient,
+                                  virtual_machine,
+                                  self.services["natrule_221"],
+                                  ipaddressid=public_ip_2.ipaddress.id,
+                                  openfirewall=True
+                                  )
+
+        self.debug("Associating public IP for network: %s" % network.name)
+        public_ip_3 = PublicIPAddress.create(
+                                self.apiclient,
+                                accountid=self.account.name,
+                                zoneid=self.zone.id,
+                                domainid=self.account.domainid,
+                                networkid=network.id
+                                )
+        self.debug("Associated %s with network %s" % (
+                                        public_ip_3.ipaddress.ipaddress,
+                                        network.id
+                                        ))
+
+        self.debug("Creating LB rule for IP address: %s" %
+                                        public_ip_3.ipaddress.ipaddress)
+
+        lb_rule = LoadBalancerRule.create(
+                                    self.apiclient,
+                                    self.services["lbrule"],
+                                    ipaddressid=public_ip_3.ipaddress.id,
+                                    accountid=self.account.name,
+                                    networkid=network.id
+                                )
+
+        self.debug("Adding %s to the LB rule %s" % (
+                                                virtual_machine.name,
+                                                lb_rule.name
+                                                ))
+        lb_rule.assign(self.apiclient, [virtual_machine])
+
+        self.debug("Restarting network ID: %s with cleanup true" %
+                                                                network.id)
+
+        try:
+            network.restart(self.apiclient, cleanup=True)
+        except Exception as e:
+                self.fail("Failed to cleanup network")
+
+        self.debug("Listing routers for network: %s" % network.name)
+        routers = Router.list(
+                              self.apiclient,
+                              networkid=network.id,
+                              listall=True
+                              )
+        self.assertEqual(
+                    isinstance(routers, list),
+                    True,
+                    "list router should return Master and backup routers"
+                    )
+        self.assertEqual(
+                    len(routers),
+                    2,
+                    "Length of the list router should be 2 (Backup & master)"
+                    )
+        for router in routers:
+            self.assertEqual(
+                             router.state,
+                             "Running",
+                             "Router state should be running"
+                             )
+        self.debug("Trying to SSH into the virtual machine")
+        try:
+            virtual_machine.get_ssh_client(
+                                    ipaddress=public_ip.ipaddress.ipaddress)
+            self.debug("SSH to guest VM succeeded")
+        except Exception as e:
+            self.fail("SSH to guest VM failed: %s" % e)
+
+        self.debug("Trying to SSH into the virtual machine")
+        try:
+            virtual_machine.get_ssh_client(
+                                ipaddress=public_ip_2.ipaddress.ipaddress,
+                                reconnect=True,
+                                port=self.services["natrule_221"]["publicport"]
+                               )
+            self.debug("SSH to guest VM succeeded")
+        except Exception as e:
+            self.fail("SSH to guest VM failed: %s" % e)
+
+        self.debug("Trying to SSH into the virtual machine")
+        try:
+            virtual_machine.get_ssh_client(
+                                ipaddress=public_ip_3.ipaddress.ipaddress,
+                                reconnect=True,
+                                port=self.services["lbrule"]["publicport"]
+                               )
+            self.debug("SSH to guest VM succeeded")
+        except Exception as e:
+            self.fail("SSH to guest VM failed: %s" % e)
+
+        self.debug("Restarting network ID: %s with cleanup false" %
+                                                                network.id)
+
+        try:
+            network.restart(self.apiclient, cleanup=False)
+        except Exception as e:
+                self.fail("Failed to cleanup network")
+
+        self.debug("Listing routers for network: %s" % network.name)
+        routers = Router.list(
+                              self.apiclient,
+                              networkid=network.id,
+                              listall=True
+                              )
+        self.assertEqual(
+                    isinstance(routers, list),
+                    True,
+                    "list router should return Master and backup routers"
+                    )
+        self.assertEqual(
+                    len(routers),
+                    2,
+                    "Length of the list router should be 2 (Backup & master)"
+                    )
+        for router in routers:
+            self.assertEqual(
+                             router.state,
+                             "Running",
+                             "Router state should be running"
+                             )
+        self.debug("Trying to SSH into the virtual machine")
+        try:
+            virtual_machine.get_ssh_client(
+                                    ipaddress=public_ip.ipaddress.ipaddress)
+            self.debug("SSH to guest VM succeeded")
+        except Exception as e:
+            self.fail("SSH to guest VM failed: %s" % e)
+
+        self.debug("Trying to SSH into the virtual machine")
+        try:
+            virtual_machine.get_ssh_client(
+                                ipaddress=public_ip_2.ipaddress.ipaddress,
+                                reconnect=True,
+                                port=self.services["natrule_221"]["publicport"]
+                               )
+            self.debug("SSH to guest VM succeeded")
+        except Exception as e:
+            self.fail("SSH to guest VM failed: %s" % e)
+
+        self.debug("Trying to SSH into the virtual machine")
+        try:
+            virtual_machine.get_ssh_client(
+                                ipaddress=public_ip_3.ipaddress.ipaddress,
+                                reconnect=True,
+                                port=self.services["lbrule"]["publicport"]
+                               )
+            self.debug("SSH to guest VM succeeded")
+        except Exception as e:
+            self.fail("SSH to guest VM failed: %s" % e)
+        return
+
+    @attr(tags=["advanced", "advancedns", "ssh"])
+    def test_apply_and__delete_NetworkRulesOnRvR(self):
+        """Test apply and delete network rules on redundant router
+        """
+
+        # Steps to validate
+        # 1. listNetworks should show the created network in allocated state
+        # 2. listRouters returns no running routers
+        # 3. VMs should be deployed and in Running state
+        # 4. should list MASTER and BACKUP routers
+        # 5. listPublicIpAddresses for networkid should show acquired IP
+        # 6. listRemoteAccessVpns for the network associated should show the
+        #    VPN created
+        # 7. listRemoteAccessVpns for the network associated should return
+        #    empty response
+
+        # Creating network using the network offering created
+        self.debug("Creating network with network offering: %s" %
+                                                    self.network_offering.id)
+        network = Network.create(
+                                self.apiclient,
+                                self.services["network"],
+                                accountid=self.account.name,
+                                domainid=self.account.domainid,
+                                networkofferingid=self.network_offering.id,
+                                zoneid=self.zone.id
+                                )
+        self.debug("Created network with ID: %s" % network.id)
+
+        networks = Network.list(
+                                self.apiclient,
+                                id=network.id,
+                                listall=True
+                                )
+        self.assertEqual(
+            isinstance(networks, list),
+            True,
+            "List networks should return a valid response for created network"
+             )
+        nw_response = networks[0]
+
+        self.debug("Network state: %s" % nw_response.state)
+        self.assertEqual(
+                    nw_response.state,
+                    "Allocated",
+                    "The network should be in allocated state after creation"
+                    )
+
+        self.debug("Listing routers for network: %s" % network.name)
+        routers = Router.list(
+                              self.apiclient,
+                              networkid=network.id,
+                              listall=True
+                              )
+        self.assertEqual(
+            routers,
+            None,
+            "Routers should not be spawned when network is in allocated state"
+            )
+
+        self.debug("Deploying VM in account: %s" % self.account.name)
+
+        # Spawn an instance in that network
+        virtual_machine = VirtualMachine.create(
+                                  self.apiclient,
+                                  self.services["virtual_machine"],
+                                  accountid=self.account.name,
+                                  domainid=self.account.domainid,
+                                  serviceofferingid=self.service_offering.id,
+                                  networkids=[str(network.id)]
+                                  )
+        self.debug("Deployed VM in network: %s" % network.id)
+
+        vms = VirtualMachine.list(
+                                  self.apiclient,
+                                  id=virtual_machine.id,
+                                  listall=True
+                                  )
+        self.assertEqual(
+                         isinstance(vms, list),
+                         True,
+                         "List Vms should return a valid list"
+                         )
+        vm = vms[0]
+        self.assertEqual(
+                         vm.state,
+                         "Running",
+                         "Vm should be in running state after deployment"
+                         )
+
+        self.debug("Listing routers for network: %s" % network.name)
+        routers = Router.list(
+                              self.apiclient,
+                              networkid=network.id,
+                              listall=True
+                              )
+        self.assertEqual(
+                    isinstance(routers, list),
+                    True,
+                    "list router should return Master and backup routers"
+                    )
+        self.assertEqual(
+                    len(routers),
+                    2,
+                    "Length of the list router should be 2 (Backup & master)"
+                    )
+
+        self.debug("Associating public IP for network: %s" % network.name)
+        public_ip = PublicIPAddress.create(
+                                self.apiclient,
+                                accountid=self.account.name,
+                                zoneid=self.zone.id,
+                                domainid=self.account.domainid,
+                                networkid=network.id
+                                )
+        self.debug("Associated %s with network %s" % (
+                                        public_ip.ipaddress.ipaddress,
+                                        network.id
+                                        ))
+        self.debug("Enabling static NAT for IP: %s" %
+                                            public_ip.ipaddress.ipaddress)
+        try:
+            static_nat = StaticNATRule.create(
+                                    self.apiclient,
+                                    self.services["fw_rule"],
+                                    ipaddressid=public_ip.ipaddress.id
+                                  )
+            self.debug("Static NAT enabled for IP: %s" %
+                                            public_ip.ipaddress.ipaddress)
+            static_nat.enable(
+                              self.apiclient,
+                              ipaddressid=public_ip.ipaddress.id,
+                              virtualmachineid=virtual_machine.id
+                              )
+        except Exception as e:
+            self.fail("Failed to enable static NAT on IP: %s - %s" % (
+                                            public_ip.ipaddress.ipaddress, e))
+
+        public_ips = PublicIPAddress.list(
+                                          self.apiclient,
+                                          networkid=network.id,
+                                          listall=True,
+                                          isstaticnat=True
+                                          )
+        self.assertEqual(
+                         isinstance(public_ips, list),
+                         True,
+                         "List public Ip for network should list the Ip addr"
+                         )
+        self.assertEqual(
+                         public_ips[0].ipaddress,
+                         public_ip.ipaddress.ipaddress,
+                         "List public Ip for network should list the Ip addr"
+                         )
+
+        self.debug("creating a FW rule on IP: %s" %
+                                    public_ip.ipaddress.ipaddress)
+        fw_rule = FireWallRule.create(
+                            self.apiclient,
+                            ipaddressid=public_ip.ipaddress.id,
+                            protocol='TCP',
+                            cidrlist=[self.services["fw_rule"]["cidr"]],
+                            startport=self.services["fw_rule"]["startport"],
+                            endport=self.services["fw_rule"]["endport"]
+                            )
+        self.debug("Created a firewall rule on 22 port of IP: %s" %
+                                            public_ip.ipaddress.ipaddress)
+
+        self.debug("Trying to SSH into the virtual machine")
+        try:
+            virtual_machine.get_ssh_client(
+                                    ipaddress=public_ip.ipaddress.ipaddress)
+            self.debug("SSH to guest VM succeeded")
+        except Exception as e:
+            self.fail("SSH to guest VM failed: %s" % e)
+
+        self.debug("Associating public IP for network: %s" % network.name)
+        public_ip_2 = PublicIPAddress.create(
+                                self.apiclient,
+                                accountid=self.account.name,
+                                zoneid=self.zone.id,
+                                domainid=self.account.domainid,
+                                networkid=network.id
+                                )
+        self.debug("Associated %s with network %s" % (
+                                        public_ip_2.ipaddress.ipaddress,
+                                        network.id
+                                        ))
+
+        nat_rule = NATRule.create(
+                                  self.apiclient,
+                                  virtual_machine,
+                                  self.services["natrule_221"],
+                                  ipaddressid=public_ip_2.ipaddress.id,
+                                  openfirewall=True
+                                  )
+
+        self.debug("Trying to SSH into the virtual machine")
+        try:
+            virtual_machine.get_ssh_client(
+                            ipaddress=public_ip_2.ipaddress.ipaddress,
+                            reconnect=True,
+                            port=self.services["natrule_221"]["publicport"]
+                           )
+            self.debug("SSH to guest VM succeeded")
+        except Exception as e:
+            self.fail("SSH to guest VM failed: %s" % e)
+
+        self.debug("Associating public IP for network: %s" % network.name)
+        public_ip_3 = PublicIPAddress.create(
+                                self.apiclient,
+                                accountid=self.account.name,
+                                zoneid=self.zone.id,
+                                domainid=self.account.domainid,
+                                networkid=network.id
+                                )
+        self.debug("Associated %s with network %s" % (
+                                        public_ip_3.ipaddress.ipaddress,
+                                        network.id
+                                        ))
+
+        self.debug("Creating LB rule for IP address: %s" %
+                                        public_ip_3.ipaddress.ipaddress)
+
+        lb_rule = LoadBalancerRule.create(
+                                    self.apiclient,
+                                    self.services["lbrule"],
+                                    ipaddressid=public_ip_3.ipaddress.id,
+                                    accountid=self.account.name,
+                                    networkid=network.id
+                                )
+
+        self.debug("Adding %s to the LB rule %s" % (
+                                                virtual_machine.name,
+                                                lb_rule.name
+                                                ))
+        lb_rule.assign(self.apiclient, [virtual_machine])
+
+        self.debug("Trying to SSH into the virtual machine")
+        try:
+            virtual_machine.get_ssh_client(
+                                ipaddress=public_ip_3.ipaddress.ipaddress,
+                                reconnect=True,
+                                port=self.services["lbrule"]["publicport"]
+                               )
+            self.debug("SSH to guest VM succeeded")
+        except Exception as e:
+            self.fail("SSH to guest VM failed: %s" % e)
+        return
+
+    @attr(tags=["advanced", "advancedns", "ssh"])
+    def test_applyNetworkRules_MasterDown_deleteNetworkRules(self):
+        """Test apply network rules when master down and delete network rules
+        """
+
+        # Steps to validate
+        # 1. listNetworks should show the created network in allocated state
+        # 2. listRouters returns no running routers
+        # 3. VMs should be deployed and in Running state
+        # 4. should list MASTER and BACKUP routers
+        # 5. listPublicIpAddresses for networkid should show acquired IP addr
+        # 6. listStaticNats for the network associated
+        # 7. listFirewallRules should show allowed ports open
+        # 8. ssh to succeed to the guestVM
+        # 9. listPublicIpAddresses for networkid should show acquired IP addr
+        # 10. listPortForwardRules to show open ports 221, 222
+        # 11. ssh should succeed for both ports
+        # 12. listPublicIpAddresses for networkid should show acquired IP addr
+        # 13 and 14. listLoadBalancerRules should show associated VMs for
+        #    public IP
+        # 15. ssh should succeed to the user VMs
+        # 16. listRouters should show one Router in MASTER state and Running
+        # 17. ssh should work for PF, FW, and LB ips
+        # 18. listRouters should show both routers MASTER and BACKUP in
+        #    Running state
+        # 19. listPortForwardingRules, listFirewallRules, listLoadBalancerRule
+        #    should return empty response
+        # 20. listPublicIpAddresses should show now more addresses
+
+        # Creating network using the network offering created
+        self.debug("Creating network with network offering: %s" %
+                                                    self.network_offering.id)
+        network = Network.create(
+                                self.apiclient,
+                                self.services["network"],
+                                accountid=self.account.name,
+                                domainid=self.account.domainid,
+                                networkofferingid=self.network_offering.id,
+                                zoneid=self.zone.id
+                                )
+        self.debug("Created network with ID: %s" % network.id)
+
+        networks = Network.list(
+                                self.apiclient,
+                                id=network.id,
+                                listall=True
+                                )
+        self.assertEqual(
+            isinstance(networks, list),
+            True,
+            "List networks should return a valid response for created network"
+             )
+        nw_response = networks[0]
+
+        self.debug("Network state: %s" % nw_response.state)
+        self.assertEqual(
+                    nw_response.state,
+                    "Allocated",
+                    "The network should be in allocated state after creation"
+                    )
+
+        self.debug("Listing routers for network: %s" % network.name)
+        routers = Router.list(
+                              self.apiclient,
+                              networkid=network.id,
+                              listall=True
+                              )
+        self.assertEqual(
+            routers,
+            None,
+            "Routers should not be spawned when network is in allocated state"
+            )
+
+        self.debug("Deploying VM in account: %s" % self.account.name)
+
+        # Spawn an instance in that network
+        virtual_machine = VirtualMachine.create(
+                                  self.apiclient,
+                                  self.services["virtual_machine"],
+                                  accountid=self.account.name,
+                                  domainid=self.account.domainid,
+                                  serviceofferingid=self.service_offering.id,
+                                  networkids=[str(network.id)]
+                                  )
+        self.debug("Deployed VM in network: %s" % network.id)
+
+        vms = VirtualMachine.list(
+                                  self.apiclient,
+                                  id=virtual_machine.id,
+                                  listall=True
+                                  )
+        self.assertEqual(
+                         isinstance(vms, list),
+                         True,
+                         "List Vms should return a valid list"
+                         )
+        vm = vms[0]
+        self.assertEqual(
+                         vm.state,
+                         "Running",
+                         "Vm should be in running state after deployment"
+                         )
+
+        self.debug("Listing routers for network: %s" % network.name)
+        routers = Router.list(
+                              self.apiclient,
+                              networkid=network.id,
+                              listall=True
+                              )
+        self.assertEqual(
+                    isinstance(routers, list),
+                    True,
+                    "list router should return Master and backup routers"
+                    )
+        self.assertEqual(
+                    len(routers),
+                    2,
+                    "Length of the list router should be 2 (Backup & master)"
+                    )
+
+        if routers[0].redundantstate == 'MASTER':
+            master_router = routers[0]
+            backup_router = routers[1]
+        else:
+            master_router = routers[1]
+            backup_router = routers[0]
+
+        self.debug("Stopping router ID: %s" % master_router.id)
+
+        try:
+            Router.stop(self.apiclient, id=master_router.id)
+        except Exception as e:
+            self.fail("Failed to stop master router..")
+
+        self.debug("Associating public IP for network: %s" % network.name)
+        public_ip = PublicIPAddress.create(
+                                self.apiclient,
+                                accountid=self.account.name,
+                                zoneid=self.zone.id,
+                                domainid=self.account.domainid,
+                                networkid=network.id
+                                )
+        self.debug("Associated %s with network %s" % (
+                                        public_ip.ipaddress.ipaddress,
+                                        network.id
+                                        ))
+        self.debug("Enabling static NAT for IP: %s" %
+                                            public_ip.ipaddress.ipaddress)
+        try:
+            static_nat = StaticNATRule.create(
+                                    self.apiclient,
+                                    self.services["fw_rule"],
+                                    ipaddressid=public_ip.ipaddress.id
+                                  )
+            static_nat.enable(
+                              self.apiclient,
+                              ipaddressid=public_ip.ipaddress.id,
+                              virtualmachineid=virtual_machine.id
+                              )
+            self.debug("Static NAT enabled for IP: %s" %
+                                            public_ip.ipaddress.ipaddress)
+        except Exception as e:
+            self.fail("Failed to enable static NAT on IP: %s - %s" % (
+                                            public_ip.ipaddress.ipaddress, e))
+
+        public_ips = PublicIPAddress.list(
+                                          self.apiclient,
+                                          networkid=network.id,
+                                          listall=True,
+                                          isstaticnat=True
+                                          )
+        self.assertEqual(
+                         isinstance(public_ips, list),
+                         True,
+                         "List public Ip for network should list the Ip addr"
+                         )
+        self.assertEqual(
+                         public_ips[0].ipaddress,
+                         public_ip.ipaddress.ipaddress,
+                         "List public Ip for network should list the Ip addr"
+                         )
+
+        self.debug("creating a FW rule on IP: %s" %
+                                    public_ip.ipaddress.ipaddress)
+        fw_rule = FireWallRule.create(
+                            self.apiclient,
+                            ipaddressid=public_ip.ipaddress.id,
+                            protocol='TCP',
+                            cidrlist=[self.services["fw_rule"]["cidr"]],
+                            startport=self.services["fw_rule"]["startport"],
+                            endport=self.services["fw_rule"]["endport"]
+                            )
+        self.debug("Created a firewall rule on 22 port of IP: %s" %
+                                            public_ip.ipaddress.ipaddress)
+
+        self.debug("Trying to SSH into the virtual machine")
+        try:
+            virtual_machine.get_ssh_client(
+                                    ipaddress=public_ip.ipaddress.ipaddress)
+            self.debug("SSH to guest VM succeeded")
+        except Exception as e:
+            self.fail("SSH to guest VM failed: %s" % e)
+
+        self.debug("Associating public IP for network: %s" % network.name)
+        public_ip_2 = PublicIPAddress.create(
+                                self.apiclient,
+                                accountid=self.account.name,
+                                zoneid=self.zone.id,
+                                domainid=self.account.domainid,
+                                networkid=network.id
+                                )
+        self.debug("Associated %s with network %s" % (
+                                        public_ip_2.ipaddress.ipaddress,
+                                        network.id
+                                        ))
+
+        nat_rule = NATRule.create(
+                                  self.apiclient,
+                                  virtual_machine,
+                                  self.services["natrule_221"],
+                                  ipaddressid=public_ip_2.ipaddress.id,
+                                  openfirewall=True
+                                  )
+
+        self.debug("Trying to SSH into the virtual machine")
+        try:
+            virtual_machine.get_ssh_client(
+                                ipaddress=public_ip_2.ipaddress.ipaddress,
+                                reconnect=True,
+                                port=self.services["natrule_221"]["publicport"]
+                               )
+            self.debug("SSH to guest VM succeeded")
+        except Exception as e:
+            self.fail("SSH to guest VM failed: %s" % e)
+
+        self.debug("Associating public IP for network: %s" % network.name)
+        public_ip_3 = PublicIPAddress.create(
+                                self.apiclient,
+                                accountid=self.account.name,
+                                zoneid=self.zone.id,
+                                domainid=self.account.domainid,
+                                networkid=network.id
+                                )
+        self.debug("Associated %s with network %s" % (
+                                        public_ip_3.ipaddress.ipaddress,
+                                        network.id
+                                        ))
+
+        self.debug("Creating LB rule for IP address: %s" %
+                                        public_ip_3.ipaddress.ipaddress)
+
+        lb_rule = LoadBalancerRule.create(
+                                    self.apiclient,
+                                    self.services["lbrule"],
+                                    ipaddressid=public_ip_3.ipaddress.id,
+                                    accountid=self.account.name,
+                                    networkid=network.id
+                                )
+
+        self.debug("Adding %s to the LB rule %s" % (
+                                                virtual_machine.name,
+                                                lb_rule.name
+                                                ))
+        lb_rule.assign(self.apiclient, [virtual_machine])
+
+        self.debug("Trying to SSH into the virtual machine")
+        try:
+            virtual_machine.get_ssh_client(
+                                ipaddress=public_ip_3.ipaddress.ipaddress,
+                                reconnect=True,
+                                port=self.services["lbrule"]["publicport"]
+                               )
+            self.debug("SSH to guest VM succeeded")
+        except Exception as e:
+            self.fail("SSH to guest VM failed: %s" % e)
+
+        self.debug("Starting router ID: %s" % master_router.id)
+
+        try:
+            Router.start(self.apiclient, id=master_router.id)
+        except Exception as e:
+            self.fail("Failed to start master router..")
+
+        self.debug("Listing routers for network: %s" % network.name)
+        routers = Router.list(
+                              self.apiclient,
+                              networkid=network.id,
+                              listall=True
+                              )
+        self.assertEqual(
+                    isinstance(routers, list),
+                    True,
+                    "list router should return Master and backup routers"
+                    )
+        self.assertEqual(
+                    len(routers),
+                    2,
+                    "Length of the list router should be 2 (Backup & master)"
+                    )
+        for router in routers:
+            self.assertEqual(
+                             router.state,
+                             "Running",
+                             "Router state should be running"
+                             )
+        return
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b9524157/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
new file mode 100644
index 0000000..b120106
--- /dev/null
+++ b/test/integration/component/test_redundant_router_services.py
@@ -0,0 +1,375 @@
+# 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.
+
+
+from nose.plugins.attrib import attr
+from marvin.integration.lib.base import *
+from marvin.integration.lib.utils import *
+from marvin.integration.lib.common import *
+
+#Import Local Modules
+from marvin.cloudstackTestCase import cloudstackTestCase
+from marvin.cloudstackAPI import *
+
+class Services:
+    """Test Services for customer defects
+    """
+
+    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,
+                                    "memory": 128,
+                        },
+                        "disk_offering": {
+                                    "displaytext": "Small",
+                                    "name": "Small",
+                                    "disksize": 1
+                        },
+                        "virtual_machine": {
+                                    "displayname": "Test VM",
+                                    "username": "root",
+                                    "password": "password",
+                                    "ssh_port": 22,
+                                    "hypervisor": 'XenServer',
+                                    "privateport": 22,
+                                    "publicport": 22,
+                                    "protocol": 'TCP',
+                        },
+                        "static_nat": {
+                                    "startport": 22,
+                                    "endport": 22,
+                                    "protocol": "TCP"
+                        },
+                        "network_offering": {
+                                    "name": 'Network offering-RVR services',
+                                    "displaytext": 'Network off-RVR services',
+                                    "guestiptype": 'Isolated',
+                                    "supportedservices": 'Vpn,Dhcp,Dns,SourceNat,PortForwarding,Firewall,Lb,UserData,StaticNat',
+                                    "traffictype": 'GUEST',
+                                    "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"
+                                        },
+                                    },
+                        },
+                        "host": {
+                                 "username": "root",
+                                 "password": "password",
+                                 "publicport": 22,
+                        },
+                        "network": {
+                                  "name": "Test Network",
+                                  "displaytext": "Test Network",
+                                },
+                        "lbrule": {
+                                    "name": "SSH",
+                                    "alg": "roundrobin",
+                                    # Algorithm used for load balancing
+                                    "privateport": 22,
+                                    "publicport": 22,
+                                    "openfirewall": True,
+                                },
+                        "natrule": {
+                                    "privateport": 22,
+                                    "publicport": 22,
+                                    "protocol": "TCP"
+                                },
+                        "natrule_221": {
+                                    "privateport": 22,
+                                    "publicport": 221,
+                                    "protocol": "TCP"
+                                },
+                        "fw_rule": {
+                                    "startport": 1,
+                                    "endport": 6000,
+                                    "cidr": '55.55.0.0/11',
+                                    # Any network (For creating FW rule)
+                                    "protocol": 'TCP',
+                                },
+                        "ostype": 'CentOS 5.3 (64-bit)',
+                        "sleep": 60,
+            }
+
+
+class TestEnableVPNOverRvR(cloudstackTestCase):
+
+    @classmethod
+    def setUpClass(cls):
+        cls.api_client = super(
+                               TestEnableVPNOverRvR,
+                               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.template = get_template(
+                            cls.api_client,
+                            cls.zone.id,
+                            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.network_offering = NetworkOffering.create(
+                                            cls.api_client,
+                                            cls.services["network_offering"],
+                                            conservemode=True
+                                            )
+        # Enable Network offering
+        cls.network_offering.update(cls.api_client, state='Enabled')
+
+        cls._cleanup = [
+                        cls.service_offering,
+                        cls.network_offering,
+                        ]
+        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.account = Account.create(
+                                     self.apiclient,
+                                     self.services["account"],
+                                     admin=True,
+                                     domainid=self.domain.id
+                                     )
+        self._cleanup.insert(0, self.account)
+        return
+
+    @attr(tags=["advanced", "advancedns", "ssh"])
+    def test_enableVPNOverRvR(self):
+        """Test redundant router internals
+        """
+
+        # Steps to validate
+        # 1. listNetworks should show the created network in allocated state
+        # 2. listRouters returns no running routers
+        # 3. VMs should be deployed and in Running state
+        # 4. should list MASTER and BACKUP routers
+        # 5. listPublicIpAddresses for networkid should show acquired IP addr
+        # 6. listRemoteAccessVpns for the network associated should show VPN
+        #    created
+        # 7. listRemoteAccessVpns for the network associated should return
+        #    empty response
+
+        # Creating network using the network offering created
+        self.debug("Creating network with network offering: %s" %
+                                                    self.network_offering.id)
+        network = Network.create(
+                                self.apiclient,
+                                self.services["network"],
+                                accountid=self.account.name,
+                                domainid=self.account.domainid,
+                                networkofferingid=self.network_offering.id,
+                                zoneid=self.zone.id
+                                )
+        self.debug("Created network with ID: %s" % network.id)
+
+        networks = Network.list(
+                                self.apiclient,
+                                id=network.id,
+                                listall=True
+                                )
+        self.assertEqual(
+            isinstance(networks, list),
+            True,
+            "List networks should return a valid response for created network"
+             )
+        nw_response = networks[0]
+
+        self.debug("Network state: %s" % nw_response.state)
+        self.assertEqual(
+                    nw_response.state,
+                    "Allocated",
+                    "The network should be in allocated state after creation"
+                    )
+
+        self.debug("Listing routers for network: %s" % network.name)
+        routers = Router.list(
+                              self.apiclient,
+                              networkid=network.id,
+                              listall=True
+                              )
+        self.assertEqual(
+            routers,
+            None,
+            "Routers should not be spawned when network is in allocated state"
+            )
+
+        self.debug("Deploying VM in account: %s" % self.account.name)
+
+        # Spawn an instance in that network
+        virtual_machine = VirtualMachine.create(
+                                  self.apiclient,
+                                  self.services["virtual_machine"],
+                                  accountid=self.account.name,
+                                  domainid=self.account.domainid,
+                                  serviceofferingid=self.service_offering.id,
+                                  networkids=[str(network.id)]
+                                  )
+        self.debug("Deployed VM in network: %s" % network.id)
+
+        vms = VirtualMachine.list(
+                                  self.apiclient,
+                                  id=virtual_machine.id,
+                                  listall=True
+                                  )
+        self.assertEqual(
+                         isinstance(vms, list),
+                         True,
+                         "List Vms should return a valid list"
+                         )
+        vm = vms[0]
+        self.assertEqual(
+                         vm.state,
+                         "Running",
+                         "Vm should be in running state after deployment"
+                         )
+
+        self.debug("Listing routers for network: %s" % network.name)
+        routers = Router.list(
+                              self.apiclient,
+                              networkid=network.id,
+                              listall=True
+                              )
+        self.assertEqual(
+                    isinstance(routers, list),
+                    True,
+                    "list router should return Master and backup routers"
+                    )
+        self.assertEqual(
+                    len(routers),
+                    2,
+                    "Length of the list router should be 2 (Backup & master)"
+                    )
+
+        self.debug("Associating public IP for network: %s" % network.name)
+        public_ip = PublicIPAddress.create(
+                                self.apiclient,
+                                accountid=self.account.name,
+                                zoneid=self.zone.id,
+                                domainid=self.account.domainid,
+                                networkid=network.id
+                                )
+        self.debug("Associated %s with network %s" % (
+                                        public_ip.ipaddress.ipaddress,
+                                        network.id
+                                        ))
+
+        self.debug("Creating a remote access VPN for account: %s" %
+                                                self.account.name)
+
+        try:
+            vpn = Vpn.create(
+                         self.apiclient,
+                         publicipid=public_ip.ipaddress.id,
+                         account=self.account.name,
+                         domainid=self.account.domainid
+                         )
+        except Exception as e:
+            self.fail("Failed to create VPN for account: %s - %s" % (
+                                                 self.account.name, e))
+
+        try:
+            vpnuser = VpnUser.create(
+                                 self.apiclient,
+                                 username="root",
+                                 password="password",
+                                 account=self.account.name,
+                                 domainid=self.account.domainid
+                                 )
+        except Exception as e:
+            self.fail("Failed to create VPN user: %s" % e)
+
+        self.debug("Checking if the remote access VPN is created or not?")
+        remote_vpns = Vpn.list(
+                               self.apiclient,
+                               account=self.account.name,
+                               domainid=self.account.domainid,
+                               publicipid=public_ip.ipaddress.id,
+                               listall=True
+                               )
+        self.assertEqual(
+                         isinstance(remote_vpns, list),
+                         True,
+                         "List remote VPNs should not return empty response"
+                         )
+        self.debug("Deleting the remote access VPN for account: %s" %
+                                                self.account.name)
+
+        try:
+            vpn.delete(self.apiclient)
+        except Exception as e:
+            self.fail("Failed to delete VPN : %s" % e)
+
+        self.debug("Checking if the remote access VPN is created or not?")
+        remote_vpns = Vpn.list(
+                               self.apiclient,
+                               account=self.account.name,
+                               domainid=self.account.domainid,
+                               publicipid=public_ip.ipaddress.id,
+                               listall=True
+                               )
+        self.assertEqual(
+                         remote_vpns,
+                         None,
+                         "List remote VPNs should not return empty response"
+                         )
+        return


[23/29] git commit: updated refs/heads/master-6-17-stable to 93712c2

Posted by ts...@apache.org.
Split out snapshot tests for speedup

Breaking down snapshot tests
- recurring snapshots
- limits
- garbage collection
- smoke/basic scenario: take snapshot of root disk

Signed-off-by: Prasanna Santhanam <ts...@apache.org>
(cherry picked from commit 82c75c7faebf40fe21400c4980d803db75e78407)


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

Branch: refs/heads/master-6-17-stable
Commit: c7e2ca564158a14d5a452f650e505e8b287d4833
Parents: c2eb17b
Author: Prasanna Santhanam <ts...@apache.org>
Authored: Thu Jun 20 16:47:55 2013 +0530
Committer: Prasanna Santhanam <ts...@apache.org>
Committed: Sat Jun 29 00:52:08 2013 +0530

----------------------------------------------------------------------
 .../component/test_recurring_snapshots.py       |  405 +++++
 test/integration/component/test_snapshot_gc.py  |  474 ++++++
 .../component/test_snapshot_limits.py           |  384 +++++
 test/integration/component/test_snapshots.py    | 1546 +++---------------
 test/integration/smoke/test_snapshots.py        |  345 ++++
 5 files changed, 1822 insertions(+), 1332 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c7e2ca56/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
new file mode 100644
index 0000000..06df170
--- /dev/null
+++ b/test/integration/component/test_recurring_snapshots.py
@@ -0,0 +1,405 @@
+# 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.
+
+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,
+                    }
+
+
+class TestRecurringSnapshots(cloudstackTestCase):
+
+    @classmethod
+    def setUpClass(cls):
+        cls.api_client = super(TestRecurringSnapshots, 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.services['mode'] = cls.zone.networktype
+        cls.disk_offering = DiskOffering.create(
+                                    cls.api_client,
+                                    cls.services["disk_offering"]
+                                    )
+        template = get_template(
+                            cls.api_client,
+                            cls.zone.id,
+                            cls.services["ostype"]
+                            )
+
+        cls.services["domainid"] = cls.domain.id
+        cls.services["server_with_disk"]["zoneid"] = cls.zone.id
+        cls.services["server_with_disk"]["diskoffering"] = cls.disk_offering.id
+
+        cls.services["server_without_disk"]["zoneid"] = cls.zone.id
+
+        cls.services["templates"]["ostypeid"] = template.ostypeid
+        cls.services["zoneid"] = cls.zone.id
+        cls.services["diskoffering"] = cls.disk_offering.id
+
+        # Create VMs, NAT Rules etc
+        cls.account = Account.create(
+                            cls.api_client,
+                            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.virtual_machine = cls.virtual_machine_with_disk = \
+                    VirtualMachine.create(
+                                cls.api_client,
+                                cls.services["server_with_disk"],
+                                templateid=template.id,
+                                accountid=cls.account.name,
+                                domainid=cls.account.domainid,
+                                serviceofferingid=cls.service_offering.id,
+                                mode=cls.services["mode"]
+                                )
+        cls.virtual_machine_without_disk = \
+                    VirtualMachine.create(
+                                    cls.api_client,
+                                    cls.services["server_without_disk"],
+                                    templateid=template.id,
+                                    accountid=cls.account.name,
+                                    domainid=cls.account.domainid,
+                                    serviceofferingid=cls.service_offering.id,
+                                    mode=cls.services["mode"]
+                                    )
+        cls._cleanup = [
+                        cls.service_offering,
+                        cls.disk_offering,
+                        cls.account,
+                        ]
+        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 created instance, volumes and snapshots
+            cleanup_resources(self.apiclient, self.cleanup)
+        except Exception as e:
+            raise Exception("Warning: Exception during cleanup : %s" % e)
+        return
+
+    @attr(speed = "slow")
+    @attr(tags = ["advanced", "advancedns", "smoke"])
+    def test_recurring_snapshot_root_disk(self):
+        """Test Recurring Snapshot Root Disk
+        """
+        #1. Create snapshot policy for root disk
+        #2. ListSnapshot policy should return newly created policy
+        #3. Verify only most recent number (maxsnaps) snapshots retailed
+
+        volume = list_volumes(
+                        self.apiclient,
+                        virtualmachineid=self.virtual_machine_with_disk.id,
+                        type='ROOT',
+                        listall=True
+                        )
+        self.assertEqual(
+                            isinstance(volume, list),
+                            True,
+                            "Check list response returns a valid list"
+                        )
+        recurring_snapshot = SnapshotPolicy.create(
+                                           self.apiclient,
+                                           volume[0].id,
+                                           self.services["recurring_snapshot"]
+                                        )
+        self.cleanup.append(recurring_snapshot)
+
+        #ListSnapshotPolicy should return newly created policy
+        list_snapshots_policy = list_snapshot_policy(
+                                                     self.apiclient,
+                                                     id=recurring_snapshot.id,
+                                                     volumeid=volume[0].id
+                                                     )
+        self.assertEqual(
+                            isinstance(list_snapshots_policy, list),
+                            True,
+                            "Check list response returns a valid list"
+                        )
+        self.assertNotEqual(
+                            list_snapshots_policy,
+                            None,
+                            "Check if result exists in list item call"
+                            )
+        snapshots_policy = list_snapshots_policy[0]
+        self.assertEqual(
+                        snapshots_policy.id,
+                        recurring_snapshot.id,
+                        "Check recurring snapshot id in list resources call"
+                        )
+        self.assertEqual(
+                        snapshots_policy.maxsnaps,
+                        self.services["recurring_snapshot"]["maxsnaps"],
+                        "Check interval type in list resources call"
+                        )
+        # Sleep for (maxsnaps+1) hours to verify
+        # only maxsnaps snapshots are retained
+        time.sleep(
+            (self.services["recurring_snapshot"]["maxsnaps"]) * 3600
+            )
+
+        timeout = self.services["timeout"]
+        while True:
+            snapshots = list_snapshots(
+                        self.apiclient,
+                        volumeid=volume[0].id,
+                        intervaltype=\
+                        self.services["recurring_snapshot"]["intervaltype"],
+                        snapshottype='RECURRING',
+                        listall=True
+                        )
+
+            if isinstance(snapshots, list):
+                break
+
+            elif timeout == 0:
+                raise Exception("List snapshots API call failed.")
+
+            time.sleep(1)
+            timeout = timeout - 1
+
+        self.assertEqual(
+                            isinstance(snapshots, list),
+                            True,
+                            "Check list response returns a valid list"
+                        )
+
+        self.assertEqual(
+                         len(snapshots),
+                         self.services["recurring_snapshot"]["maxsnaps"],
+                         "Check maximum number of recurring snapshots retained"
+                        )
+        return
+
+    @attr(speed = "slow")
+    @attr(tags = ["advanced", "advancedns", "smoke"])
+    def test_recurring_snapshot_data_disk(self):
+        """Test Recurring Snapshot data Disk
+        """
+        #1. Create snapshot policy for data disk
+        #2. ListSnapshot policy should return newly created policy
+        #3. Verify only most recent number (maxsnaps) snapshots retailed
+
+        volume = list_volumes(
+                        self.apiclient,
+                        virtualmachineid=self.virtual_machine_with_disk.id,
+                        type='DATADISK',
+                        listall=True
+                        )
+
+        self.assertEqual(
+                            isinstance(volume, list),
+                            True,
+                            "Check list response returns a valid list"
+                        )
+
+        recurring_snapshot = SnapshotPolicy.create(
+                                    self.apiclient,
+                                    volume[0].id,
+                                    self.services["recurring_snapshot"]
+                                )
+        self.cleanup.append(recurring_snapshot)
+        #ListSnapshotPolicy should return newly created policy
+        list_snapshots_policy = list_snapshot_policy(
+                                                     self.apiclient,
+                                                     id=recurring_snapshot.id,
+                                                     volumeid=volume[0].id
+                                                     )
+
+        self.assertEqual(
+                            isinstance(list_snapshots_policy, list),
+                            True,
+                            "Check list response returns a valid list"
+                        )
+
+        self.assertNotEqual(
+                            list_snapshots_policy,
+                            None,
+                            "Check if result exists in list item call"
+                            )
+        snapshots_policy = list_snapshots_policy[0]
+        self.assertEqual(
+                        snapshots_policy.id,
+                        recurring_snapshot.id,
+                        "Check recurring snapshot id in list resources call"
+                        )
+        self.assertEqual(
+                            snapshots_policy.maxsnaps,
+                            self.services["recurring_snapshot"]["maxsnaps"],
+                            "Check interval type in list resources call"
+                        )
+
+        # Sleep for (maxsnaps) hours to verify only maxsnaps snapshots are
+        # retained
+        time.sleep(
+            (self.services["recurring_snapshot"]["maxsnaps"]) * 3600
+            )
+
+        timeout = self.services["timeout"]
+        while True:
+            snapshots = list_snapshots(
+                            self.apiclient,
+                            volumeid=volume[0].id,
+                            intervaltype=\
+                            self.services["recurring_snapshot"]["intervaltype"],
+                            snapshottype='RECURRING',
+                            listall=True
+                            )
+
+            if isinstance(snapshots, list):
+                break
+
+            elif timeout == 0:
+                raise Exception("List snapshots API call failed.")
+
+            time.sleep(1)
+            timeout = timeout - 1
+
+        self.assertEqual(
+                            isinstance(snapshots, list),
+                            True,
+                            "Check list response returns a valid list"
+                        )
+        self.assertEqual(
+                         len(snapshots),
+                         self.services["recurring_snapshot"]["maxsnaps"],
+                         "Check maximum number of recurring snapshots retained"
+                         )
+        return
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c7e2ca56/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
new file mode 100644
index 0000000..369543d
--- /dev/null
+++ b/test/integration/component/test_snapshot_gc.py
@@ -0,0 +1,474 @@
+# 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 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.remoteSSHClient import remoteSSHClient
+
+
+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,
+                    }
+
+
+class TestAccountSnapshotClean(cloudstackTestCase):
+
+    @classmethod
+    def setUpClass(cls):
+        cls.api_client = super(TestAccountSnapshotClean, 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.services['mode'] = cls.zone.networktype
+
+        template = get_template(
+                            cls.api_client,
+                            cls.zone.id,
+                            cls.services["ostype"]
+                            )
+        cls.services["server"]["zoneid"] = cls.zone.id
+
+        cls.services["template"] = template.id
+
+        # Create VMs, NAT Rules etc
+        cls.account = Account.create(
+                            cls.api_client,
+                            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.virtual_machine = VirtualMachine.create(
+                                cls.api_client,
+                                cls.services["server"],
+                                templateid=template.id,
+                                accountid=cls.account.name,
+                                domainid=cls.account.domainid,
+                                serviceofferingid=cls.service_offering.id
+                                )
+        # Get the Root disk of VM
+        volumes = list_volumes(
+                            cls.api_client,
+                            virtualmachineid=cls.virtual_machine.id,
+                            type='ROOT',
+                            listall=True
+                            )
+        volume = volumes[0]
+
+        # Create a snapshot from the ROOTDISK
+        cls.snapshot = Snapshot.create(cls.api_client, volumes[0].id)
+
+        cls._cleanup = [
+                        cls.service_offering,
+                        ]
+        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 created instance, volumes and snapshots
+            cleanup_resources(self.apiclient, self.cleanup)
+        except Exception as e:
+            raise Exception("Warning: Exception during cleanup : %s" % e)
+        return
+
+    @attr(speed = "slow")
+    @attr(tags = ["advanced", "advancedns", "basic", "sg"])
+    def test_02_accountSnapshotClean(self):
+        """Test snapshot cleanup after account deletion
+        """
+        # Validate the following
+        # 1. listAccounts API should list out the newly created account
+        # 2. listVirtualMachines() command should return the deployed VM.
+        #    State of this VM should be "Running"
+        # 3. a)listSnapshots should list the snapshot that was created.
+        #    b)verify that secondary storage NFS share contains the reqd volume
+        #      under /secondary/snapshots/$accountid/$volumeid/$snapshot_uuid
+        # 4. a)listAccounts should not list account that is deleted
+        #    b) snapshot image($snapshot_uuid) should be deleted from the
+        #       /secondary/snapshots/$accountid/$volumeid/
+
+        accounts = list_accounts(
+                                 self.apiclient,
+                                 id=self.account.id
+                                 )
+        self.assertEqual(
+                            isinstance(accounts, list),
+                            True,
+                            "Check list response returns a valid list"
+                        )
+        self.assertNotEqual(
+                             len(accounts),
+                             0,
+                             "Check list Accounts response"
+                             )
+
+        # VM should be in 'Running' state
+        virtual_machines = list_virtual_machines(
+                                self.apiclient,
+                                id=self.virtual_machine.id
+                                )
+        self.assertEqual(
+                            isinstance(virtual_machines, list),
+                            True,
+                            "Check list response returns a valid list"
+                        )
+        self.assertNotEqual(
+                             len(virtual_machines),
+                             0,
+                             "Check list virtual machines response"
+                             )
+        for virtual_machine in virtual_machines:
+            self.debug("VM ID: %s, VM state: %s" % (
+                                            virtual_machine.id,
+                                            virtual_machine.state
+                                            ))
+            self.assertEqual(
+                        virtual_machine.state,
+                        'Running',
+                        "Check list VM response for Running state"
+                    )
+
+        # Verify the snapshot was created or not
+        snapshots = list_snapshots(
+                                   self.apiclient,
+                                   id=self.snapshot.id
+                                   )
+        self.assertEqual(
+                            isinstance(snapshots, list),
+                            True,
+                            "Check list response returns a valid list"
+                        )
+        self.assertNotEqual(
+                            snapshots,
+                            None,
+                            "Check if result exists in list snapshots call"
+                            )
+        self.assertEqual(
+                            snapshots[0].id,
+                            self.snapshot.id,
+                            "Check snapshot id in list resources call"
+                        )
+
+        # Fetch values from database
+        qresultset = self.dbclient.execute(
+                        "select backup_snap_id, account_id, volume_id from snapshots where uuid = '%s';" \
+                        % self.snapshot.id
+                        )
+        self.assertEqual(
+                            isinstance(qresultset, list),
+                            True,
+                            "Check DB response returns a valid list"
+                        )
+        self.assertNotEqual(
+                            len(qresultset),
+                            0,
+                            "Check DB Query result set"
+                            )
+
+        qresult = qresultset[0]
+        snapshot_uuid = qresult[0]      # backup_snap_id = snapshot UUID
+        account_id = qresult[1]
+        volume_id = qresult[2]
+
+        # Get the Secondary Storage details from  list Hosts
+        hosts = list_hosts(
+                                 self.apiclient,
+                                 type='SecondaryStorage',
+                                 zoneid=self.zone.id
+                            )
+        self.assertEqual(
+                            isinstance(hosts, list),
+                            True,
+                            "Check list response returns a valid list"
+                        )
+        uuids = []
+        for host in hosts:
+            # hosts[0].name = "nfs://192.168.100.21/export/test"
+            parse_url = (host.name).split('/')
+            # parse_url = ['nfs:', '', '192.168.100.21', 'export', 'test']
+
+            # Stripping end ':' from storage type
+            storage_type = parse_url[0][:-1]
+            # Split IP address and export path from name
+            sec_storage_ip = parse_url[2]
+            # Sec Storage IP: 192.168.100.21
+
+            if sec_storage_ip[-1] != ":":
+                sec_storage_ip = sec_storage_ip + ":"
+
+            export_path = '/'.join(parse_url[3:])
+            # Export path: export/test
+
+            # Sleep to ensure that snapshot is reflected in sec storage
+            time.sleep(self.services["sleep"])
+            try:
+                # Login to Secondary storage VM to check snapshot present on sec disk
+                ssh_client = remoteSSHClient(
+                                    self.services["mgmt_server"]["ipaddress"],
+                                    self.services["mgmt_server"]["port"],
+                                    self.services["mgmt_server"]["username"],
+                                    self.services["mgmt_server"]["password"],
+                                    )
+
+                cmds = [
+                    "mkdir -p %s" % self.services["paths"]["mount_dir"],
+                    "mount -t %s %s/%s %s" % (
+                                         storage_type,
+                                         sec_storage_ip,
+                                         export_path,
+                                         self.services["paths"]["mount_dir"]
+                                         ),
+                    "ls %s/snapshots/%s/%s" % (
+                                               self.services["paths"]["mount_dir"],
+                                               account_id,
+                                               volume_id
+                                               ),
+                ]
+
+                for c in cmds:
+                    self.debug("command: %s" % c)
+                    result = ssh_client.execute(c)
+                    self.debug("Result: %s" % result)
+
+                uuids.append(result)
+
+                # Unmount the Sec Storage
+                cmds = [
+                    "umount %s" % (self.services["mount_dir"]),
+                    ]
+                for c in cmds:
+                    result = ssh_client.execute(c)
+            except Exception as e:
+                self.fail("SSH failed for management server: %s - %s" %
+                                (self.services["mgmt_server"]["ipaddress"], e))
+
+        res = str(uuids)
+        self.assertEqual(
+                        res.count(snapshot_uuid),
+                        1,
+                        "Check snapshot UUID in secondary storage and database"
+                        )
+
+        self.debug("Deleting account: %s" % self.account.name)
+        # Delete account
+        self.account.delete(self.apiclient)
+
+        interval = list_configurations(
+                                    self.apiclient,
+                                    name='account.cleanup.interval'
+                                    )
+        self.assertEqual(
+                            isinstance(interval, list),
+                            True,
+                            "Check list response returns a valid list"
+                        )
+        self.debug("account.cleanup.interval: %s" % interval[0].value)
+
+        # Wait for account cleanup interval
+        time.sleep(int(interval[0].value) * 2)
+
+        accounts = list_accounts(
+                                 self.apiclient,
+                                 id=self.account.id
+                                 )
+
+        self.assertEqual(
+            accounts,
+            None,
+            "List accounts should return empty list after account deletion"
+            )
+
+        uuids = []
+        for host in hosts:
+            # hosts[0].name = "nfs://192.168.100.21/export/test"
+            parse_url = (host.name).split('/')
+            # parse_url = ['nfs:', '', '192.168.100.21', 'export', 'test']
+
+            # Stripping end ':' from storage type
+            storage_type = parse_url[0][:-1]
+            # Split IP address and export path from name
+            sec_storage_ip = parse_url[2]
+            # Sec Storage IP: 192.168.100.21
+
+            if sec_storage_ip[-1] != ":":
+                sec_storage_ip = sec_storage_ip + ":"
+
+            export_path = '/'.join(parse_url[3:])
+            # Export path: export/test
+
+            try:
+                cmds = [
+                        "mount -t %s %s/%s %s" % (
+                                         storage_type,
+                                         sec_storage_ip,
+                                         export_path,
+                                         self.services["paths"]["mount_dir"]
+                                         ),
+                        "ls %s/snapshots/%s/%s" % (
+                                               self.services["paths"]["mount_dir"],
+                                               account_id,
+                                               volume_id
+                                               ),
+                        ]
+
+                for c in cmds:
+                    self.debug("command: %s" % c)
+                    result = ssh_client.execute(c)
+                    self.debug("Result: %s" % result)
+
+                uuids.append(result)
+                # Unmount the Sec Storage
+                cmds = [
+                    "umount %s" % (self.services["paths"]["mount_dir"]),
+                    ]
+                for c in cmds:
+                    self.debug("command: %s" % c)
+                    result = ssh_client.execute(c)
+                    self.debug("Result: %s" % result)
+
+            except Exception as e:
+                self.fail("SSH failed for management server: %s - %s" %
+                                (self.services["mgmt_server"]["ipaddress"], e))
+
+        res = str(uuids)
+        self.assertNotEqual(
+                        res.count(snapshot_uuid),
+                        1,
+                        "Check snapshot UUID in secondary storage and database"
+                        )
+        return
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c7e2ca56/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
new file mode 100644
index 0000000..5acd066
--- /dev/null
+++ b/test/integration/component/test_snapshot_limits.py
@@ -0,0 +1,384 @@
+# 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 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.remoteSSHClient import remoteSSHClient
+
+
+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,
+                    }
+
+
+class TestSnapshotLimit(cloudstackTestCase):
+
+    @classmethod
+    def setUpClass(cls):
+        cls.api_client = super(TestSnapshotLimit, 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.services['mode'] = cls.zone.networktype
+
+        template = get_template(
+                            cls.api_client,
+                            cls.zone.id,
+                            cls.services["ostype"]
+                            )
+        cls.services["server"]["zoneid"] = cls.zone.id
+
+        cls.services["template"] = template.id
+
+        # Create VMs, NAT Rules etc
+        cls.account = Account.create(
+                            cls.api_client,
+                            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.virtual_machine = VirtualMachine.create(
+                                cls.api_client,
+                                cls.services["server"],
+                                templateid=template.id,
+                                accountid=cls.account.name,
+                                domainid=cls.account.domainid,
+                                serviceofferingid=cls.service_offering.id
+                                )
+        cls._cleanup = [
+                        cls.service_offering,
+                        cls.account,
+                        ]
+        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 created instance, volumes and snapshots
+            cleanup_resources(self.apiclient, self.cleanup)
+        except Exception as e:
+            raise Exception("Warning: Exception during cleanup : %s" % e)
+        return
+
+    @attr(speed = "slow")
+    @attr(tags = ["advanced", "advancedns"])
+    def test_04_snapshot_limit(self):
+        """Test snapshot limit in snapshot policies
+        """
+        # Validate the following
+        # 1. Perform hourly recurring snapshot on the root disk of VM and keep
+        #    the maxsnapshots as 1
+        # 2. listSnapshots should list the snapshot that was created
+        #    snapshot folder in secondary storage should contain only one
+        #    snapshot image(/secondary/snapshots/$accountid/$volumeid/)
+
+        # Get the Root disk of VM
+        volumes = list_volumes(
+                            self.apiclient,
+                            virtualmachineid=self.virtual_machine.id,
+                            type='ROOT',
+                            listall=True
+                            )
+        self.assertEqual(
+                            isinstance(volumes, list),
+                            True,
+                            "Check list response returns a valid list"
+                        )
+        volume = volumes[0]
+
+        # Create a snapshot policy
+        recurring_snapshot = SnapshotPolicy.create(
+                                           self.apiclient,
+                                           volume.id,
+                                           self.services["recurring_snapshot"]
+                                        )
+        self.cleanup.append(recurring_snapshot)
+
+        snapshot_policy = list_snapshot_policy(
+                                        self.apiclient,
+                                        id=recurring_snapshot.id,
+                                        volumeid=volume.id
+                                        )
+        self.assertEqual(
+                            isinstance(snapshot_policy, list),
+                            True,
+                            "Check list response returns a valid list"
+                        )
+
+        self.assertNotEqual(
+                            snapshot_policy,
+                            None,
+                            "Check if result exists in list item call"
+                            )
+
+        self.assertEqual(
+                        snapshot_policy[0].id,
+                        recurring_snapshot.id,
+                        "Check recurring snapshot id in list resources call"
+                        )
+        self.assertEqual(
+                        snapshot_policy[0].maxsnaps,
+                        self.services["recurring_snapshot"]["maxsnaps"],
+                        "Check interval type in list resources call"
+                        )
+        # Sleep for (maxsnaps+1) hours to verify
+        # only maxsnaps snapshots are retained
+        time.sleep(
+            (self.services["recurring_snapshot"]["maxsnaps"]) * 3600
+            )
+
+        # Verify the snapshot was created or not
+        snapshots = list_snapshots(
+                        self.apiclient,
+                        volumeid=volume.id,
+                        intervaltype=\
+                        self.services["recurring_snapshot"]["intervaltype"],
+                        snapshottype='RECURRING',
+                        listall=True
+                        )
+
+        self.assertEqual(
+                            isinstance(snapshots, list),
+                            True,
+                            "Check list response returns a valid list"
+                        )
+        self.assertEqual(
+                         len(snapshots),
+                         self.services["recurring_snapshot"]["maxsnaps"],
+                         "Check maximum number of recurring snapshots retained"
+                        )
+        snapshot = snapshots[0]
+        # Sleep to ensure that snapshot is reflected in sec storage
+        time.sleep(self.services["sleep"])
+
+        # Fetch values from database
+        qresultset = self.dbclient.execute(
+                        "select backup_snap_id, account_id, volume_id from snapshots where uuid = '%s';" \
+                        % snapshot.id
+                        )
+        self.assertEqual(
+                            isinstance(qresultset, list),
+                            True,
+                            "Check DBQuery returns a valid list"
+                        )
+        self.assertNotEqual(
+                            len(qresultset),
+                            0,
+                            "Check DB Query result set"
+                            )
+
+        qresult = qresultset[0]
+        snapshot_uuid = qresult[0]      # backup_snap_id = snapshot UUID
+        account_id = qresult[1]
+        volume_id = qresult[2]
+
+        # Get the Secondary Storage details from  list Hosts
+        hosts = list_hosts(
+                                 self.apiclient,
+                                 type='SecondaryStorage',
+                                 zoneid=self.zone.id
+                                 )
+        self.assertEqual(
+                            isinstance(hosts, list),
+                            True,
+                            "Check list response returns a valid list"
+                        )
+        uuids = []
+        for host in hosts:
+            # hosts[0].name = "nfs://192.168.100.21/export/test"
+            parse_url = (host.name).split('/')
+            # parse_url = ['nfs:', '', '192.168.100.21', 'export', 'test']
+
+            # Stripping end ':' from storage type
+            storage_type = parse_url[0][:-1]
+            # Split IP address and export path from name
+            sec_storage_ip = parse_url[2]
+            # Sec Storage IP: 192.168.100.21
+
+            if sec_storage_ip[-1] != ":":
+                sec_storage_ip = sec_storage_ip + ":"
+
+            export_path = '/'.join(parse_url[3:])
+            # Export path: export/test
+            try:
+                # Login to VM to check snapshot present on sec disk
+                ssh_client = remoteSSHClient(
+                                    self.services["mgmt_server"]["ipaddress"],
+                                    self.services["mgmt_server"]["port"],
+                                    self.services["mgmt_server"]["username"],
+                                    self.services["mgmt_server"]["password"],
+                                    )
+
+                cmds = [
+                    "mkdir -p %s" % self.services["paths"]["mount_dir"],
+                    "mount -t %s %s/%s %s" % (
+                                         storage_type,
+                                         sec_storage_ip,
+                                         export_path,
+                                         self.services["paths"]["mount_dir"]
+                                         ),
+                    "ls %s/snapshots/%s/%s" % (
+                                               self.services["paths"]["mount_dir"],
+                                               account_id,
+                                               volume_id
+                                               ),
+                ]
+
+                for c in cmds:
+                    result = ssh_client.execute(c)
+
+                uuids.append(result)
+
+                # Unmount the Sec Storage
+                cmds = [
+                    "umount %s" % (self.services["paths"]["mount_dir"]),
+                    ]
+                for c in cmds:
+                    result = ssh_client.execute(c)
+            except Exception as e:
+                raise Exception(
+                        "SSH access failed for management server: %s - %s" %
+                                    (self.services["mgmt_server"]["ipaddress"], e))
+
+        res = str(uuids)
+        self.assertEqual(
+                        res.count(snapshot_uuid),
+                        1,
+                        "Check snapshot UUID in secondary storage and database"
+                        )
+        return
\ No newline at end of file


[09/29] git commit: updated refs/heads/master-6-17-stable to 93712c2

Posted by ts...@apache.org.
Split Redundant Router tests

Each module of redundant router contains related tests for
services, network rules, upgrades, redundancy etc.

Signed-off-by: Prasanna Santhanam <ts...@apache.org>
(cherry picked from commit 13e1f4fc1ec2fde00050f964553524a630bb9b57)


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

Branch: refs/heads/master-6-17-stable
Commit: b9524157dd81edd0a46d55dfd749a071622ab9bd
Parents: 6363550
Author: Prasanna Santhanam <ts...@apache.org>
Authored: Wed Jun 19 14:17:50 2013 +0530
Committer: Prasanna Santhanam <ts...@apache.org>
Committed: Sat Jun 29 00:52:07 2013 +0530

----------------------------------------------------------------------
 .../component/test_redundant_router.py          | 3814 +-----------------
 .../component/test_redundant_router_cleanups.py |  675 ++++
 ...test_redundant_router_deployment_planning.py | 1006 +++++
 .../test_redundant_router_network_rules.py      | 1416 +++++++
 .../component/test_redundant_router_services.py |  375 ++
 .../component/test_redundant_router_upgrades.py |  486 +++
 6 files changed, 3969 insertions(+), 3803 deletions(-)
----------------------------------------------------------------------



[08/29] Split Redundant Router tests

Posted by ts...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b9524157/test/integration/component/test_redundant_router.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_redundant_router.py b/test/integration/component/test_redundant_router.py
index 814f3e2..5f7b1ca 100644
--- a/test/integration/component/test_redundant_router.py
+++ b/test/integration/component/test_redundant_router.py
@@ -15,8 +15,6 @@
 # specific language governing permissions and limitations
 # under the License.
 
-from random import random
-import marvin
 from nose.plugins.attrib import attr
 from marvin.integration.lib.base import *
 from marvin.integration.lib.utils import *
@@ -132,8 +130,6 @@ class Services:
                                 },
                         "ostype": 'CentOS 5.3 (64-bit)',
                         "sleep": 60,
-                        "mode": 'advanced',
-                        # Networking mode, Advanced, Basic
             }
 
 
@@ -221,6 +217,14 @@ class TestCreateRvRNetworkOffering(cloudstackTestCase):
                      1,
                     "List network off should have newly created network off"
                      )
+        for service in network_offs[0].service:
+            if service.name == 'SourceNat':
+                self.debug("Verifying SourceNat capabilites")
+                for capability in service.capability:
+                    if capability.name == 'RedundantRouter':
+                        self.assertTrue(capability.value=='true')
+                        self.debug("RedundantRouter is enabled")
+
         return
 
 
@@ -476,7 +480,7 @@ class TestCreateRvRNetworkNonDefaultGuestCidr(cloudstackTestCase):
 
     @attr(tags=["advanced", "advancedns", "ssh"])
     def test_createRvRNetwork(self):
-        """Test create network with redundant routers
+        """Test create network with non-default guest cidr with redundant routers
         """
 
         # Validate the following:
@@ -903,12 +907,12 @@ class TestRVRInternals(cloudstackTestCase):
         return
 
 
-class TestRedundancy(cloudstackTestCase):
+class TestRvRRedundancy(cloudstackTestCase):
 
     @classmethod
     def setUpClass(cls):
         cls.api_client = super(
-                               TestRedundancy,
+                               TestRvRRedundancy,
                                cls
                                ).getClsTestClient().getApiClient()
         cls.services = Services().services
@@ -1531,3799 +1535,3 @@ class TestRedundancy(cloudstackTestCase):
                     "Redundant state of the router should be BACKUP"
                     )
         return
-
-
-class TestApplyAndDeleteNetworkRulesOnRvR(cloudstackTestCase):
-
-    @classmethod
-    def setUpClass(cls):
-        cls.api_client = super(
-                               TestApplyAndDeleteNetworkRulesOnRvR,
-                               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.template = get_template(
-                            cls.api_client,
-                            cls.zone.id,
-                            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.network_offering = NetworkOffering.create(
-                                            cls.api_client,
-                                            cls.services["network_offering"],
-                                            conservemode=True
-                                            )
-        # Enable Network offering
-        cls.network_offering.update(cls.api_client, state='Enabled')
-
-        cls._cleanup = [
-                        cls.service_offering,
-                        cls.network_offering,
-                        ]
-        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.account = Account.create(
-                                     self.apiclient,
-                                     self.services["account"],
-                                     admin=True,
-                                     domainid=self.domain.id
-                                     )
-        self.cleanup = []
-        self.cleanup.insert(0, self.account)
-        return
-
-    @attr(tags=["advanced", "advancedns", "ssh"])
-    def test_apply_and__delete_NetworkRulesOnRvR(self):
-        """Test apply and delete network rules on redundant router
-        """
-
-        # Steps to validate
-        # 1. listNetworks should show the created network in allocated state
-        # 2. listRouters returns no running routers
-        # 3. VMs should be deployed and in Running state
-        # 4. should list MASTER and BACKUP routers
-        # 5. listPublicIpAddresses for networkid should show acquired IP
-        # 6. listRemoteAccessVpns for the network associated should show the
-        #    VPN created
-        # 7. listRemoteAccessVpns for the network associated should return
-        #    empty response
-
-        # Creating network using the network offering created
-        self.debug("Creating network with network offering: %s" %
-                                                    self.network_offering.id)
-        network = Network.create(
-                                self.apiclient,
-                                self.services["network"],
-                                accountid=self.account.name,
-                                domainid=self.account.domainid,
-                                networkofferingid=self.network_offering.id,
-                                zoneid=self.zone.id
-                                )
-        self.debug("Created network with ID: %s" % network.id)
-
-        networks = Network.list(
-                                self.apiclient,
-                                id=network.id,
-                                listall=True
-                                )
-        self.assertEqual(
-            isinstance(networks, list),
-            True,
-            "List networks should return a valid response for created network"
-             )
-        nw_response = networks[0]
-
-        self.debug("Network state: %s" % nw_response.state)
-        self.assertEqual(
-                    nw_response.state,
-                    "Allocated",
-                    "The network should be in allocated state after creation"
-                    )
-
-        self.debug("Listing routers for network: %s" % network.name)
-        routers = Router.list(
-                              self.apiclient,
-                              networkid=network.id,
-                              listall=True
-                              )
-        self.assertEqual(
-            routers,
-            None,
-            "Routers should not be spawned when network is in allocated state"
-            )
-
-        self.debug("Deploying VM in account: %s" % self.account.name)
-
-        # Spawn an instance in that network
-        virtual_machine = VirtualMachine.create(
-                                  self.apiclient,
-                                  self.services["virtual_machine"],
-                                  accountid=self.account.name,
-                                  domainid=self.account.domainid,
-                                  serviceofferingid=self.service_offering.id,
-                                  networkids=[str(network.id)]
-                                  )
-        self.debug("Deployed VM in network: %s" % network.id)
-
-        vms = VirtualMachine.list(
-                                  self.apiclient,
-                                  id=virtual_machine.id,
-                                  listall=True
-                                  )
-        self.assertEqual(
-                         isinstance(vms, list),
-                         True,
-                         "List Vms should return a valid list"
-                         )
-        vm = vms[0]
-        self.assertEqual(
-                         vm.state,
-                         "Running",
-                         "Vm should be in running state after deployment"
-                         )
-
-        self.debug("Listing routers for network: %s" % network.name)
-        routers = Router.list(
-                              self.apiclient,
-                              networkid=network.id,
-                              listall=True
-                              )
-        self.assertEqual(
-                    isinstance(routers, list),
-                    True,
-                    "list router should return Master and backup routers"
-                    )
-        self.assertEqual(
-                    len(routers),
-                    2,
-                    "Length of the list router should be 2 (Backup & master)"
-                    )
-
-        self.debug("Associating public IP for network: %s" % network.name)
-        public_ip = PublicIPAddress.create(
-                                self.apiclient,
-                                accountid=self.account.name,
-                                zoneid=self.zone.id,
-                                domainid=self.account.domainid,
-                                networkid=network.id
-                                )
-        self.debug("Associated %s with network %s" % (
-                                        public_ip.ipaddress.ipaddress,
-                                        network.id
-                                        ))
-        self.debug("Enabling static NAT for IP: %s" %
-                                            public_ip.ipaddress.ipaddress)
-        try:
-            static_nat = StaticNATRule.create(
-                                    self.apiclient,
-                                    self.services["fw_rule"],
-                                    ipaddressid=public_ip.ipaddress.id
-                                  )
-            self.debug("Static NAT enabled for IP: %s" %
-                                            public_ip.ipaddress.ipaddress)
-            static_nat.enable(
-                              self.apiclient,
-                              ipaddressid=public_ip.ipaddress.id,
-                              virtualmachineid=virtual_machine.id
-                              )
-        except Exception as e:
-            self.fail("Failed to enable static NAT on IP: %s - %s" % (
-                                            public_ip.ipaddress.ipaddress, e))
-
-        public_ips = PublicIPAddress.list(
-                                          self.apiclient,
-                                          networkid=network.id,
-                                          listall=True,
-                                          isstaticnat=True
-                                          )
-        self.assertEqual(
-                         isinstance(public_ips, list),
-                         True,
-                         "List public Ip for network should list the Ip addr"
-                         )
-        self.assertEqual(
-                         public_ips[0].ipaddress,
-                         public_ip.ipaddress.ipaddress,
-                         "List public Ip for network should list the Ip addr"
-                         )
-
-        self.debug("creating a FW rule on IP: %s" %
-                                    public_ip.ipaddress.ipaddress)
-        fw_rule = FireWallRule.create(
-                            self.apiclient,
-                            ipaddressid=public_ip.ipaddress.id,
-                            protocol='TCP',
-                            cidrlist=[self.services["fw_rule"]["cidr"]],
-                            startport=self.services["fw_rule"]["startport"],
-                            endport=self.services["fw_rule"]["endport"]
-                            )
-        self.debug("Created a firewall rule on 22 port of IP: %s" %
-                                            public_ip.ipaddress.ipaddress)
-
-        self.debug("Trying to SSH into the virtual machine")
-        try:
-            virtual_machine.get_ssh_client(
-                                    ipaddress=public_ip.ipaddress.ipaddress)
-            self.debug("SSH to guest VM succeeded")
-        except Exception as e:
-            self.fail("SSH to guest VM failed: %s" % e)
-
-        self.debug("Associating public IP for network: %s" % network.name)
-        public_ip_2 = PublicIPAddress.create(
-                                self.apiclient,
-                                accountid=self.account.name,
-                                zoneid=self.zone.id,
-                                domainid=self.account.domainid,
-                                networkid=network.id
-                                )
-        self.debug("Associated %s with network %s" % (
-                                        public_ip_2.ipaddress.ipaddress,
-                                        network.id
-                                        ))
-
-        nat_rule = NATRule.create(
-                                  self.apiclient,
-                                  virtual_machine,
-                                  self.services["natrule_221"],
-                                  ipaddressid=public_ip_2.ipaddress.id,
-                                  openfirewall=True
-                                  )
-
-        self.debug("Trying to SSH into the virtual machine")
-        try:
-            virtual_machine.get_ssh_client(
-                            ipaddress=public_ip_2.ipaddress.ipaddress,
-                            reconnect=True,
-                            port=self.services["natrule_221"]["publicport"]
-                           )
-            self.debug("SSH to guest VM succeeded")
-        except Exception as e:
-            self.fail("SSH to guest VM failed: %s" % e)
-
-        self.debug("Associating public IP for network: %s" % network.name)
-        public_ip_3 = PublicIPAddress.create(
-                                self.apiclient,
-                                accountid=self.account.name,
-                                zoneid=self.zone.id,
-                                domainid=self.account.domainid,
-                                networkid=network.id
-                                )
-        self.debug("Associated %s with network %s" % (
-                                        public_ip_3.ipaddress.ipaddress,
-                                        network.id
-                                        ))
-
-        self.debug("Creating LB rule for IP address: %s" %
-                                        public_ip_3.ipaddress.ipaddress)
-
-        lb_rule = LoadBalancerRule.create(
-                                    self.apiclient,
-                                    self.services["lbrule"],
-                                    ipaddressid=public_ip_3.ipaddress.id,
-                                    accountid=self.account.name,
-                                    networkid=network.id
-                                )
-
-        self.debug("Adding %s to the LB rule %s" % (
-                                                virtual_machine.name,
-                                                lb_rule.name
-                                                ))
-        lb_rule.assign(self.apiclient, [virtual_machine])
-
-        self.debug("Trying to SSH into the virtual machine")
-        try:
-            virtual_machine.get_ssh_client(
-                                ipaddress=public_ip_3.ipaddress.ipaddress,
-                                reconnect=True,
-                                port=self.services["lbrule"]["publicport"]
-                               )
-            self.debug("SSH to guest VM succeeded")
-        except Exception as e:
-            self.fail("SSH to guest VM failed: %s" % e)
-        return
-
-
-class TestEnableVPNOverRvR(cloudstackTestCase):
-
-    @classmethod
-    def setUpClass(cls):
-        cls.api_client = super(
-                               TestEnableVPNOverRvR,
-                               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.template = get_template(
-                            cls.api_client,
-                            cls.zone.id,
-                            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.network_offering = NetworkOffering.create(
-                                            cls.api_client,
-                                            cls.services["network_offering"],
-                                            conservemode=True
-                                            )
-        # Enable Network offering
-        cls.network_offering.update(cls.api_client, state='Enabled')
-
-        cls._cleanup = [
-                        cls.service_offering,
-                        cls.network_offering,
-                        ]
-        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.account = Account.create(
-                                     self.apiclient,
-                                     self.services["account"],
-                                     admin=True,
-                                     domainid=self.domain.id
-                                     )
-        self._cleanup.insert(0, self.account)
-        return
-
-    @attr(tags=["advanced", "advancedns", "ssh"])
-    def test_enableVPNOverRvR(self):
-        """Test redundant router internals
-        """
-
-        # Steps to validate
-        # 1. listNetworks should show the created network in allocated state
-        # 2. listRouters returns no running routers
-        # 3. VMs should be deployed and in Running state
-        # 4. should list MASTER and BACKUP routers
-        # 5. listPublicIpAddresses for networkid should show acquired IP addr
-        # 6. listRemoteAccessVpns for the network associated should show VPN
-        #    created
-        # 7. listRemoteAccessVpns for the network associated should return
-        #    empty response
-
-        # Creating network using the network offering created
-        self.debug("Creating network with network offering: %s" %
-                                                    self.network_offering.id)
-        network = Network.create(
-                                self.apiclient,
-                                self.services["network"],
-                                accountid=self.account.name,
-                                domainid=self.account.domainid,
-                                networkofferingid=self.network_offering.id,
-                                zoneid=self.zone.id
-                                )
-        self.debug("Created network with ID: %s" % network.id)
-
-        networks = Network.list(
-                                self.apiclient,
-                                id=network.id,
-                                listall=True
-                                )
-        self.assertEqual(
-            isinstance(networks, list),
-            True,
-            "List networks should return a valid response for created network"
-             )
-        nw_response = networks[0]
-
-        self.debug("Network state: %s" % nw_response.state)
-        self.assertEqual(
-                    nw_response.state,
-                    "Allocated",
-                    "The network should be in allocated state after creation"
-                    )
-
-        self.debug("Listing routers for network: %s" % network.name)
-        routers = Router.list(
-                              self.apiclient,
-                              networkid=network.id,
-                              listall=True
-                              )
-        self.assertEqual(
-            routers,
-            None,
-            "Routers should not be spawned when network is in allocated state"
-            )
-
-        self.debug("Deploying VM in account: %s" % self.account.name)
-
-        # Spawn an instance in that network
-        virtual_machine = VirtualMachine.create(
-                                  self.apiclient,
-                                  self.services["virtual_machine"],
-                                  accountid=self.account.name,
-                                  domainid=self.account.domainid,
-                                  serviceofferingid=self.service_offering.id,
-                                  networkids=[str(network.id)]
-                                  )
-        self.debug("Deployed VM in network: %s" % network.id)
-
-        vms = VirtualMachine.list(
-                                  self.apiclient,
-                                  id=virtual_machine.id,
-                                  listall=True
-                                  )
-        self.assertEqual(
-                         isinstance(vms, list),
-                         True,
-                         "List Vms should return a valid list"
-                         )
-        vm = vms[0]
-        self.assertEqual(
-                         vm.state,
-                         "Running",
-                         "Vm should be in running state after deployment"
-                         )
-
-        self.debug("Listing routers for network: %s" % network.name)
-        routers = Router.list(
-                              self.apiclient,
-                              networkid=network.id,
-                              listall=True
-                              )
-        self.assertEqual(
-                    isinstance(routers, list),
-                    True,
-                    "list router should return Master and backup routers"
-                    )
-        self.assertEqual(
-                    len(routers),
-                    2,
-                    "Length of the list router should be 2 (Backup & master)"
-                    )
-
-        self.debug("Associating public IP for network: %s" % network.name)
-        public_ip = PublicIPAddress.create(
-                                self.apiclient,
-                                accountid=self.account.name,
-                                zoneid=self.zone.id,
-                                domainid=self.account.domainid,
-                                networkid=network.id
-                                )
-        self.debug("Associated %s with network %s" % (
-                                        public_ip.ipaddress.ipaddress,
-                                        network.id
-                                        ))
-
-        self.debug("Creating a remote access VPN for account: %s" %
-                                                self.account.name)
-
-        try:
-            vpn = Vpn.create(
-                         self.apiclient,
-                         publicipid=public_ip.ipaddress.id,
-                         account=self.account.name,
-                         domainid=self.account.domainid
-                         )
-        except Exception as e:
-            self.fail("Failed to create VPN for account: %s - %s" % (
-                                                 self.account.name, e))
-
-        try:
-            vpnuser = VpnUser.create(
-                                 self.apiclient,
-                                 username="root",
-                                 password="password",
-                                 account=self.account.name,
-                                 domainid=self.account.domainid
-                                 )
-        except Exception as e:
-            self.fail("Failed to create VPN user: %s" % e)
-
-        self.debug("Checking if the remote access VPN is created or not?")
-        remote_vpns = Vpn.list(
-                               self.apiclient,
-                               account=self.account.name,
-                               domainid=self.account.domainid,
-                               publicipid=public_ip.ipaddress.id,
-                               listall=True
-                               )
-        self.assertEqual(
-                         isinstance(remote_vpns, list),
-                         True,
-                         "List remote VPNs should not return empty response"
-                         )
-        self.debug("Deleting the remote access VPN for account: %s" %
-                                                self.account.name)
-
-        try:
-            vpn.delete(self.apiclient)
-        except Exception as e:
-            self.fail("Failed to delete VPN : %s" % e)
-
-        self.debug("Checking if the remote access VPN is created or not?")
-        remote_vpns = Vpn.list(
-                               self.apiclient,
-                               account=self.account.name,
-                               domainid=self.account.domainid,
-                               publicipid=public_ip.ipaddress.id,
-                               listall=True
-                               )
-        self.assertEqual(
-                         remote_vpns,
-                         None,
-                         "List remote VPNs should not return empty response"
-                         )
-        return
-
-
-class TestNetworkRulesMasterDownDeleteNetworkRules(cloudstackTestCase):
-
-    @classmethod
-    def setUpClass(cls):
-        cls.api_client = super(
-                               TestNetworkRulesMasterDownDeleteNetworkRules,
-                               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.template = get_template(
-                            cls.api_client,
-                            cls.zone.id,
-                            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.network_offering = NetworkOffering.create(
-                                            cls.api_client,
-                                            cls.services["network_offering"],
-                                            conservemode=True
-                                            )
-        # Enable Network offering
-        cls.network_offering.update(cls.api_client, state='Enabled')
-
-        cls._cleanup = [
-                        cls.service_offering,
-                        cls.network_offering,
-                        ]
-        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.account = Account.create(
-                                     self.apiclient,
-                                     self.services["account"],
-                                     admin=True,
-                                     domainid=self.domain.id
-                                     )
-        self._cleanup.insert(0, self.account)
-        return
-
-    @attr(tags=["advanced", "advancedns", "ssh"])
-    def test_applyNetworkRules_MasterDown_deleteNetworkRules(self):
-        """Test apply network rules when master down and delete network rules
-        """
-
-        # Steps to validate
-        # 1. listNetworks should show the created network in allocated state
-        # 2. listRouters returns no running routers
-        # 3. VMs should be deployed and in Running state
-        # 4. should list MASTER and BACKUP routers
-        # 5. listPublicIpAddresses for networkid should show acquired IP addr
-        # 6. listStaticNats for the network associated
-        # 7. listFirewallRules should show allowed ports open
-        # 8. ssh to succeed to the guestVM
-        # 9. listPublicIpAddresses for networkid should show acquired IP addr
-        # 10. listPortForwardRules to show open ports 221, 222
-        # 11. ssh should succeed for both ports
-        # 12. listPublicIpAddresses for networkid should show acquired IP addr
-        # 13 and 14. listLoadBalancerRules should show associated VMs for
-        #    public IP
-        # 15. ssh should succeed to the user VMs
-        # 16. listRouters should show one Router in MASTER state and Running
-        # 17. ssh should work for PF, FW, and LB ips
-        # 18. listRouters should show both routers MASTER and BACKUP in
-        #    Running state
-        # 19. listPortForwardingRules, listFirewallRules, listLoadBalancerRule
-        #    should return empty response
-        # 20. listPublicIpAddresses should show now more addresses
-
-        # Creating network using the network offering created
-        self.debug("Creating network with network offering: %s" %
-                                                    self.network_offering.id)
-        network = Network.create(
-                                self.apiclient,
-                                self.services["network"],
-                                accountid=self.account.name,
-                                domainid=self.account.domainid,
-                                networkofferingid=self.network_offering.id,
-                                zoneid=self.zone.id
-                                )
-        self.debug("Created network with ID: %s" % network.id)
-
-        networks = Network.list(
-                                self.apiclient,
-                                id=network.id,
-                                listall=True
-                                )
-        self.assertEqual(
-            isinstance(networks, list),
-            True,
-            "List networks should return a valid response for created network"
-             )
-        nw_response = networks[0]
-
-        self.debug("Network state: %s" % nw_response.state)
-        self.assertEqual(
-                    nw_response.state,
-                    "Allocated",
-                    "The network should be in allocated state after creation"
-                    )
-
-        self.debug("Listing routers for network: %s" % network.name)
-        routers = Router.list(
-                              self.apiclient,
-                              networkid=network.id,
-                              listall=True
-                              )
-        self.assertEqual(
-            routers,
-            None,
-            "Routers should not be spawned when network is in allocated state"
-            )
-
-        self.debug("Deploying VM in account: %s" % self.account.name)
-
-        # Spawn an instance in that network
-        virtual_machine = VirtualMachine.create(
-                                  self.apiclient,
-                                  self.services["virtual_machine"],
-                                  accountid=self.account.name,
-                                  domainid=self.account.domainid,
-                                  serviceofferingid=self.service_offering.id,
-                                  networkids=[str(network.id)]
-                                  )
-        self.debug("Deployed VM in network: %s" % network.id)
-
-        vms = VirtualMachine.list(
-                                  self.apiclient,
-                                  id=virtual_machine.id,
-                                  listall=True
-                                  )
-        self.assertEqual(
-                         isinstance(vms, list),
-                         True,
-                         "List Vms should return a valid list"
-                         )
-        vm = vms[0]
-        self.assertEqual(
-                         vm.state,
-                         "Running",
-                         "Vm should be in running state after deployment"
-                         )
-
-        self.debug("Listing routers for network: %s" % network.name)
-        routers = Router.list(
-                              self.apiclient,
-                              networkid=network.id,
-                              listall=True
-                              )
-        self.assertEqual(
-                    isinstance(routers, list),
-                    True,
-                    "list router should return Master and backup routers"
-                    )
-        self.assertEqual(
-                    len(routers),
-                    2,
-                    "Length of the list router should be 2 (Backup & master)"
-                    )
-
-        if routers[0].redundantstate == 'MASTER':
-            master_router = routers[0]
-            backup_router = routers[1]
-        else:
-            master_router = routers[1]
-            backup_router = routers[0]
-
-        self.debug("Stopping router ID: %s" % master_router.id)
-
-        try:
-            Router.stop(self.apiclient, id=master_router.id)
-        except Exception as e:
-            self.fail("Failed to stop master router..")
-
-        self.debug("Associating public IP for network: %s" % network.name)
-        public_ip = PublicIPAddress.create(
-                                self.apiclient,
-                                accountid=self.account.name,
-                                zoneid=self.zone.id,
-                                domainid=self.account.domainid,
-                                networkid=network.id
-                                )
-        self.debug("Associated %s with network %s" % (
-                                        public_ip.ipaddress.ipaddress,
-                                        network.id
-                                        ))
-        self.debug("Enabling static NAT for IP: %s" %
-                                            public_ip.ipaddress.ipaddress)
-        try:
-            static_nat = StaticNATRule.create(
-                                    self.apiclient,
-                                    self.services["fw_rule"],
-                                    ipaddressid=public_ip.ipaddress.id
-                                  )
-            static_nat.enable(
-                              self.apiclient,
-                              ipaddressid=public_ip.ipaddress.id,
-                              virtualmachineid=virtual_machine.id
-                              )
-            self.debug("Static NAT enabled for IP: %s" %
-                                            public_ip.ipaddress.ipaddress)
-        except Exception as e:
-            self.fail("Failed to enable static NAT on IP: %s - %s" % (
-                                            public_ip.ipaddress.ipaddress, e))
-
-        public_ips = PublicIPAddress.list(
-                                          self.apiclient,
-                                          networkid=network.id,
-                                          listall=True,
-                                          isstaticnat=True
-                                          )
-        self.assertEqual(
-                         isinstance(public_ips, list),
-                         True,
-                         "List public Ip for network should list the Ip addr"
-                         )
-        self.assertEqual(
-                         public_ips[0].ipaddress,
-                         public_ip.ipaddress.ipaddress,
-                         "List public Ip for network should list the Ip addr"
-                         )
-
-        self.debug("creating a FW rule on IP: %s" %
-                                    public_ip.ipaddress.ipaddress)
-        fw_rule = FireWallRule.create(
-                            self.apiclient,
-                            ipaddressid=public_ip.ipaddress.id,
-                            protocol='TCP',
-                            cidrlist=[self.services["fw_rule"]["cidr"]],
-                            startport=self.services["fw_rule"]["startport"],
-                            endport=self.services["fw_rule"]["endport"]
-                            )
-        self.debug("Created a firewall rule on 22 port of IP: %s" %
-                                            public_ip.ipaddress.ipaddress)
-
-        self.debug("Trying to SSH into the virtual machine")
-        try:
-            virtual_machine.get_ssh_client(
-                                    ipaddress=public_ip.ipaddress.ipaddress)
-            self.debug("SSH to guest VM succeeded")
-        except Exception as e:
-            self.fail("SSH to guest VM failed: %s" % e)
-
-        self.debug("Associating public IP for network: %s" % network.name)
-        public_ip_2 = PublicIPAddress.create(
-                                self.apiclient,
-                                accountid=self.account.name,
-                                zoneid=self.zone.id,
-                                domainid=self.account.domainid,
-                                networkid=network.id
-                                )
-        self.debug("Associated %s with network %s" % (
-                                        public_ip_2.ipaddress.ipaddress,
-                                        network.id
-                                        ))
-
-        nat_rule = NATRule.create(
-                                  self.apiclient,
-                                  virtual_machine,
-                                  self.services["natrule_221"],
-                                  ipaddressid=public_ip_2.ipaddress.id,
-                                  openfirewall=True
-                                  )
-
-        self.debug("Trying to SSH into the virtual machine")
-        try:
-            virtual_machine.get_ssh_client(
-                                ipaddress=public_ip_2.ipaddress.ipaddress,
-                                reconnect=True,
-                                port=self.services["natrule_221"]["publicport"]
-                               )
-            self.debug("SSH to guest VM succeeded")
-        except Exception as e:
-            self.fail("SSH to guest VM failed: %s" % e)
-
-        self.debug("Associating public IP for network: %s" % network.name)
-        public_ip_3 = PublicIPAddress.create(
-                                self.apiclient,
-                                accountid=self.account.name,
-                                zoneid=self.zone.id,
-                                domainid=self.account.domainid,
-                                networkid=network.id
-                                )
-        self.debug("Associated %s with network %s" % (
-                                        public_ip_3.ipaddress.ipaddress,
-                                        network.id
-                                        ))
-
-        self.debug("Creating LB rule for IP address: %s" %
-                                        public_ip_3.ipaddress.ipaddress)
-
-        lb_rule = LoadBalancerRule.create(
-                                    self.apiclient,
-                                    self.services["lbrule"],
-                                    ipaddressid=public_ip_3.ipaddress.id,
-                                    accountid=self.account.name,
-                                    networkid=network.id
-                                )
-
-        self.debug("Adding %s to the LB rule %s" % (
-                                                virtual_machine.name,
-                                                lb_rule.name
-                                                ))
-        lb_rule.assign(self.apiclient, [virtual_machine])
-
-        self.debug("Trying to SSH into the virtual machine")
-        try:
-            virtual_machine.get_ssh_client(
-                                ipaddress=public_ip_3.ipaddress.ipaddress,
-                                reconnect=True,
-                                port=self.services["lbrule"]["publicport"]
-                               )
-            self.debug("SSH to guest VM succeeded")
-        except Exception as e:
-            self.fail("SSH to guest VM failed: %s" % e)
-
-        self.debug("Starting router ID: %s" % master_router.id)
-
-        try:
-            Router.start(self.apiclient, id=master_router.id)
-        except Exception as e:
-            self.fail("Failed to start master router..")
-
-        self.debug("Listing routers for network: %s" % network.name)
-        routers = Router.list(
-                              self.apiclient,
-                              networkid=network.id,
-                              listall=True
-                              )
-        self.assertEqual(
-                    isinstance(routers, list),
-                    True,
-                    "list router should return Master and backup routers"
-                    )
-        self.assertEqual(
-                    len(routers),
-                    2,
-                    "Length of the list router should be 2 (Backup & master)"
-                    )
-        for router in routers:
-            self.assertEqual(
-                             router.state,
-                             "Running",
-                             "Router state should be running"
-                             )
-        return
-
-
-class TestApplyDeleteNetworkRulesRebootRouter(cloudstackTestCase):
-
-    @classmethod
-    def setUpClass(cls):
-        cls.api_client = super(
-                               TestApplyDeleteNetworkRulesRebootRouter,
-                               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.template = get_template(
-                            cls.api_client,
-                            cls.zone.id,
-                            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.network_offering = NetworkOffering.create(
-                                            cls.api_client,
-                                            cls.services["network_offering"],
-                                            conservemode=True
-                                            )
-        # Enable Network offering
-        cls.network_offering.update(cls.api_client, state='Enabled')
-
-        cls._cleanup = [
-                        cls.service_offering,
-                        cls.network_offering,
-                        ]
-        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.account = Account.create(
-                                     self.apiclient,
-                                     self.services["account"],
-                                     admin=True,
-                                     domainid=self.domain.id
-                                     )
-        self._clean.insert(0, self.account)
-        return
-
-    @attr(tags=["advanced", "advancedns", "ssh"])
-    def test_applyNetworkRules_MasterDown_deleteNetworkRules(self):
-        """Test apply network rules when master & backup routers rebooted
-        """
-
-        # Steps to validate
-        # 1. listNetworks should show the created network in allocated state
-        # 2. listRouters returns no running routers
-        # 3. VMs should be deployed and in Running state
-        # 4. should list MASTER and BACKUP routers
-        # 5. listPublicIpAddresses for networkid should show acquired IP addr
-        # 6. listStaticNats for the network associated
-        # 7. listFirewallRules should show allowed ports open
-        # 8. ssh to succeed to the guestVM
-        # 9. listPublicIpAddresses for networkid should show acquired IP addr
-        # 10. listPortForwardRules to show open ports 221, 222
-        # 11. ssh should succeed for both ports
-        # 12. listPublicIpAddresses for networkid should show acquired IP addr
-        # 13 and 14. listLoadBalancerRules should show associated VMs for
-        #    public IP
-        # 15. ssh should succeed to the user VMs
-        # 16. listRouters should show one Router in MASTER state and Running
-        # 17. ssh should work for PF, FW, and LB ips
-        # 18. listRouters should show both routers MASTER and BACKUP in
-        #    Running state
-        # 19. listPortForwardingRules, listFirewallRules, listLoadBalancerRule
-        #    should return empty response
-        # 20. listPublicIpAddresses should show now more addresses
-
-        # Creating network using the network offering created
-        self.debug("Creating network with network offering: %s" %
-                                                    self.network_offering.id)
-        network = Network.create(
-                                self.apiclient,
-                                self.services["network"],
-                                accountid=self.account.name,
-                                domainid=self.account.domainid,
-                                networkofferingid=self.network_offering.id,
-                                zoneid=self.zone.id
-                                )
-        self.debug("Created network with ID: %s" % network.id)
-
-        networks = Network.list(
-                                self.apiclient,
-                                id=network.id,
-                                listall=True
-                                )
-        self.assertEqual(
-            isinstance(networks, list),
-            True,
-            "List networks should return a valid response for created network"
-             )
-        nw_response = networks[0]
-
-        self.debug("Network state: %s" % nw_response.state)
-        self.assertEqual(
-                    nw_response.state,
-                    "Allocated",
-                    "The network should be in allocated state after creation"
-                    )
-
-        self.debug("Listing routers for network: %s" % network.name)
-        routers = Router.list(
-                              self.apiclient,
-                              networkid=network.id,
-                              listall=True
-                              )
-        self.assertEqual(
-            routers,
-            None,
-            "Routers should not be spawned when network is in allocated state"
-            )
-
-        self.debug("Deploying VM in account: %s" % self.account.name)
-
-        # Spawn an instance in that network
-        virtual_machine = VirtualMachine.create(
-                                  self.apiclient,
-                                  self.services["virtual_machine"],
-                                  accountid=self.account.name,
-                                  domainid=self.account.domainid,
-                                  serviceofferingid=self.service_offering.id,
-                                  networkids=[str(network.id)]
-                                  )
-        self.debug("Deployed VM in network: %s" % network.id)
-
-        vms = VirtualMachine.list(
-                                  self.apiclient,
-                                  id=virtual_machine.id,
-                                  listall=True
-                                  )
-        self.assertEqual(
-                         isinstance(vms, list),
-                         True,
-                         "List Vms should return a valid list"
-                         )
-        vm = vms[0]
-        self.assertEqual(
-                         vm.state,
-                         "Running",
-                         "Vm should be in running state after deployment"
-                         )
-
-        self.debug("Listing routers for network: %s" % network.name)
-        routers = Router.list(
-                              self.apiclient,
-                              networkid=network.id,
-                              listall=True
-                              )
-        self.assertEqual(
-                    isinstance(routers, list),
-                    True,
-                    "list router should return Master and backup routers"
-                    )
-        self.assertEqual(
-                    len(routers),
-                    2,
-                    "Length of the list router should be 2 (Backup & master)"
-                    )
-
-        if routers[0].redundantstate == 'MASTER':
-            master_router = routers[0]
-            backup_router = routers[1]
-        else:
-            master_router = routers[1]
-            backup_router = routers[0]
-
-        self.debug("Associating public IP for network: %s" % network.name)
-        public_ip = PublicIPAddress.create(
-                                self.apiclient,
-                                accountid=self.account.name,
-                                zoneid=self.zone.id,
-                                domainid=self.account.domainid,
-                                networkid=network.id
-                                )
-        self.debug("Associated %s with network %s" % (
-                                        public_ip.ipaddress.ipaddress,
-                                        network.id
-                                        ))
-        self.debug("Enabling static NAT for IP: %s" %
-                                            public_ip.ipaddress.ipaddress)
-        try:
-            static_nat = StaticNATRule.create(
-                                    self.apiclient,
-                                    self.services["fw_rule"],
-                                    ipaddressid=public_ip.ipaddress.id
-                                  )
-            static_nat.enable(
-                              self.apiclient,
-                              ipaddressid=public_ip.ipaddress.id,
-                              virtualmachineid=virtual_machine.id
-                              )
-            self.debug("Static NAT enabled for IP: %s" %
-                                            public_ip.ipaddress.ipaddress)
-        except Exception as e:
-            self.fail("Failed to enable static NAT on IP: %s - %s" % (
-                                            public_ip.ipaddress.ipaddress, e))
-
-        public_ips = PublicIPAddress.list(
-                                          self.apiclient,
-                                          networkid=network.id,
-                                          listall=True,
-                                          isstaticnat=True
-                                          )
-        self.assertEqual(
-                         isinstance(public_ips, list),
-                         True,
-                         "List public Ip for network should list the Ip addr"
-                         )
-        self.assertEqual(
-                         public_ips[0].ipaddress,
-                         public_ip.ipaddress.ipaddress,
-                         "List public Ip for network should list the Ip addr"
-                         )
-
-        self.debug("creating a FW rule on IP: %s" %
-                                    public_ip.ipaddress.ipaddress)
-        fw_rule = FireWallRule.create(
-                            self.apiclient,
-                            ipaddressid=public_ip.ipaddress.id,
-                            protocol='TCP',
-                            cidrlist=[self.services["fw_rule"]["cidr"]],
-                            startport=self.services["fw_rule"]["startport"],
-                            endport=self.services["fw_rule"]["endport"]
-                            )
-        self.debug("Created a firewall rule on 22 port of IP: %s" %
-                                            public_ip.ipaddress.ipaddress)
-
-        self.debug("Associating public IP for network: %s" % network.name)
-        public_ip_2 = PublicIPAddress.create(
-                                self.apiclient,
-                                accountid=self.account.name,
-                                zoneid=self.zone.id,
-                                domainid=self.account.domainid,
-                                networkid=network.id
-                                )
-        self.debug("Associated %s with network %s" % (
-                                        public_ip_2.ipaddress.ipaddress,
-                                        network.id
-                                        ))
-
-        nat_rule = NATRule.create(
-                                  self.apiclient,
-                                  virtual_machine,
-                                  self.services["natrule_221"],
-                                  ipaddressid=public_ip_2.ipaddress.id,
-                                  openfirewall=True
-                                  )
-
-        self.debug("Associating public IP for network: %s" % network.name)
-        public_ip_3 = PublicIPAddress.create(
-                                self.apiclient,
-                                accountid=self.account.name,
-                                zoneid=self.zone.id,
-                                domainid=self.account.domainid,
-                                networkid=network.id
-                                )
-        self.debug("Associated %s with network %s" % (
-                                        public_ip_3.ipaddress.ipaddress,
-                                        network.id
-                                        ))
-
-        self.debug("Creating LB rule for IP address: %s" %
-                                        public_ip_3.ipaddress.ipaddress)
-
-        lb_rule = LoadBalancerRule.create(
-                                    self.apiclient,
-                                    self.services["lbrule"],
-                                    ipaddressid=public_ip_3.ipaddress.id,
-                                    accountid=self.account.name,
-                                    networkid=network.id
-                                )
-
-        self.debug("Adding %s to the LB rule %s" % (
-                                                virtual_machine.name,
-                                                lb_rule.name
-                                                ))
-        lb_rule.assign(self.apiclient, [virtual_machine])
-
-        self.debug("Starting router ID: %s" % master_router.id)
-
-        for router in routers:
-            try:
-                self.debug("Rebooting router ID: %s" % master_router.id)
-                #Stop the router
-                cmd = rebootRouter.rebootRouterCmd()
-                cmd.id = router.id
-                self.apiclient.rebootRouter(cmd)
-            except Exception as e:
-                self.fail("Failed to reboot router..")
-
-        self.debug("Listing routers for network: %s" % network.name)
-        routers = Router.list(
-                              self.apiclient,
-                              networkid=network.id,
-                              listall=True
-                              )
-        self.assertEqual(
-                    isinstance(routers, list),
-                    True,
-                    "list router should return Master and backup routers"
-                    )
-        self.assertEqual(
-                    len(routers),
-                    2,
-                    "Length of the list router should be 2 (Backup & master)"
-                    )
-        for router in routers:
-            self.assertEqual(
-                             router.state,
-                             "Running",
-                             "Router state should be running"
-                             )
-        self.debug("Trying to SSH into the virtual machine")
-        try:
-            virtual_machine.get_ssh_client(
-                                    ipaddress=public_ip.ipaddress.ipaddress)
-            self.debug("SSH to guest VM succeeded")
-        except Exception as e:
-            self.fail("SSH to guest VM failed: %s" % e)
-
-        self.debug("Trying to SSH into the virtual machine")
-        try:
-            virtual_machine.get_ssh_client(
-                                ipaddress=public_ip_2.ipaddress.ipaddress,
-                                reconnect=True,
-                                port=self.services["natrule_221"]["publicport"]
-                               )
-            self.debug("SSH to guest VM succeeded")
-        except Exception as e:
-            self.fail("SSH to guest VM failed: %s" % e)
-
-        self.debug("Trying to SSH into the virtual machine")
-        try:
-            virtual_machine.get_ssh_client(
-                                ipaddress=public_ip_3.ipaddress.ipaddress,
-                                reconnect=True,
-                                port=self.services["lbrule"]["publicport"]
-                               )
-            self.debug("SSH to guest VM succeeded")
-        except Exception as e:
-            self.fail("SSH to guest VM failed: %s" % e)
-
-        return
-
-
-class TestRestartRvRNetworkWithoutCleanup(cloudstackTestCase):
-
-    @classmethod
-    def setUpClass(cls):
-        cls.api_client = super(
-                               TestRestartRvRNetworkWithoutCleanup,
-                               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.template = get_template(
-                            cls.api_client,
-                            cls.zone.id,
-                            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.network_offering = NetworkOffering.create(
-                                            cls.api_client,
-                                            cls.services["network_offering"],
-                                            conservemode=True
-                                            )
-        # Enable Network offering
-        cls.network_offering.update(cls.api_client, state='Enabled')
-
-        cls._cleanup = [
-                        cls.service_offering,
-                        cls.network_offering,
-                        ]
-        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.account = Account.create(
-                                     self.apiclient,
-                                     self.services["account"],
-                                     admin=True,
-                                     domainid=self.domain.id
-                                     )
-        self._cleanup.insert(0, self.account)
-        return
-
-    @attr(tags=["advanced", "advancedns", "ssh"])
-    def test_restartRvRNetwork_withoutCleanup(self):
-        """Test apply rules after network restart
-        """
-
-        # Steps to validate
-        # 1. createNetwork using network offering for redundant virtual router
-        # 2. listRouters in above network
-        # 3. deployVM in above user account in the created network
-        # 4. restartNetwork cleanup=false
-        # 5. listRouters in the account
-        # 6. delete the account
-
-        # Creating network using the network offering created
-        self.debug("Creating network with network offering: %s" %
-                                                    self.network_offering.id)
-        network = Network.create(
-                                self.apiclient,
-                                self.services["network"],
-                                accountid=self.account.name,
-                                domainid=self.account.domainid,
-                                networkofferingid=self.network_offering.id,
-                                zoneid=self.zone.id
-                                )
-        self.debug("Created network with ID: %s" % network.id)
-
-        networks = Network.list(
-                                self.apiclient,
-                                id=network.id,
-                                listall=True
-                                )
-        self.assertEqual(
-            isinstance(networks, list),
-            True,
-            "List networks should return a valid response for created network"
-             )
-        nw_response = networks[0]
-
-        self.debug("Network state: %s" % nw_response.state)
-        self.assertEqual(
-                    nw_response.state,
-                    "Allocated",
-                    "The network should be in allocated state after creation"
-                    )
-
-        self.debug("Listing routers for network: %s" % network.name)
-        routers = Router.list(
-                              self.apiclient,
-                              networkid=network.id,
-                              listall=True
-                              )
-        self.assertEqual(
-            routers,
-            None,
-            "Routers should not be spawned when network is in allocated state"
-            )
-
-        self.debug("Deploying VM in account: %s" % self.account.name)
-
-        # Spawn an instance in that network
-        virtual_machine = VirtualMachine.create(
-                                  self.apiclient,
-                                  self.services["virtual_machine"],
-                                  accountid=self.account.name,
-                                  domainid=self.account.domainid,
-                                  serviceofferingid=self.service_offering.id,
-                                  networkids=[str(network.id)]
-                                  )
-        self.debug("Deployed VM in network: %s" % network.id)
-
-        vms = VirtualMachine.list(
-                                  self.apiclient,
-                                  id=virtual_machine.id,
-                                  listall=True
-                                  )
-        self.assertEqual(
-                         isinstance(vms, list),
-                         True,
-                         "List Vms should return a valid list"
-                         )
-        vm = vms[0]
-        self.assertEqual(
-                         vm.state,
-                         "Running",
-                         "Vm should be in running state after deployment"
-                         )
-
-        self.debug("Listing routers for network: %s" % network.name)
-        routers = Router.list(
-                              self.apiclient,
-                              networkid=network.id,
-                              listall=True
-                              )
-        self.assertEqual(
-                    isinstance(routers, list),
-                    True,
-                    "list router should return Master and backup routers"
-                    )
-        self.assertEqual(
-                    len(routers),
-                    2,
-                    "Length of the list router should be 2 (Backup & master)"
-                    )
-
-        if routers[0].redundantstate == 'MASTER':
-            master_router = routers[0]
-            backup_router = routers[1]
-        else:
-            master_router = routers[1]
-            backup_router = routers[0]
-
-        self.debug("restarting network with cleanup=False")
-        try:
-            network.restart(self.apiclient, cleanup=False)
-        except Exception as e:
-                self.fail("Failed to cleanup network - %s" % e)
-
-        self.debug("Listing routers for network: %s" % network.name)
-        routers = Router.list(
-                              self.apiclient,
-                              networkid=network.id,
-                              listall=True
-                              )
-        self.assertEqual(
-                    isinstance(routers, list),
-                    True,
-                    "list router should return Master and backup routers"
-                    )
-        self.assertEqual(
-                    len(routers),
-                    2,
-                    "Length of the list router should be 2 (Backup & master)"
-                    )
-        for router in routers:
-            self.assertEqual(
-                             router.state,
-                             "Running",
-                             "Router state should be running"
-                             )
-            self.assertIn(
-                    router.linklocalip,
-                    [master_router.linklocalip, backup_router.linklocalip],
-                    "Routers should have same linklocal IP after nw restart"
-                  )
-        return
-
-
-class TestRestartRvRNetworkWithCleanup(cloudstackTestCase):
-
-    @classmethod
-    def setUpClass(cls):
-        cls.api_client = super(
-                               TestRestartRvRNetworkWithCleanup,
-                               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.template = get_template(
-                            cls.api_client,
-                            cls.zone.id,
-                            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.network_offering = NetworkOffering.create(
-                                            cls.api_client,
-                                            cls.services["network_offering"],
-                                            conservemode=True
-                                            )
-        # Enable Network offering
-        cls.network_offering.update(cls.api_client, state='Enabled')
-
-        cls._cleanup = [
-                        cls.service_offering,
-                        cls.network_offering,
-                        ]
-        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.account = Account.create(
-                                     self.apiclient,
-                                     self.services["account"],
-                                     admin=True,
-                                     domainid=self.domain.id
-                                     )
-        self._cleanup.insert(0, self.account)
-        return
-
-    @attr(tags=["advanced", "advancedns", "ssh"])
-    def test_restartRvRNetwork_withCleanup(self):
-        """Test Restart network with cleanup
-        """
-
-        # Steps to validate
-        # 1. createNetwork using network offering for redundant virtual router
-        # 2. listRouters in above network
-        # 3. deployVM in above user account in the created network
-        # 4. restartNetwork cleanup=false
-        # 5. listRouters in the account
-        # 6. delete the account
-
-        # Creating network using the network offering created
-        self.debug("Creating network with network offering: %s" %
-                                                    self.network_offering.id)
-        network = Network.create(
-                                self.apiclient,
-                                self.services["network"],
-                                accountid=self.account.name,
-                                domainid=self.account.domainid,
-                                networkofferingid=self.network_offering.id,
-                                zoneid=self.zone.id
-                                )
-        self.debug("Created network with ID: %s" % network.id)
-
-        networks = Network.list(
-                                self.apiclient,
-                                id=network.id,
-                                listall=True
-                                )
-        self.assertEqual(
-            isinstance(networks, list),
-            True,
-            "List networks should return a valid response for created network"
-             )
-        nw_response = networks[0]
-
-        self.debug("Network state: %s" % nw_response.state)
-        self.assertEqual(
-                    nw_response.state,
-                    "Allocated",
-                    "The network should be in allocated state after creation"
-                    )
-
-        self.debug("Listing routers for network: %s" % network.name)
-        routers = Router.list(
-                              self.apiclient,
-                              networkid=network.id,
-                              listall=True
-                              )
-        self.assertEqual(
-            routers,
-            None,
-            "Routers should not be spawned when network is in allocated state"
-            )
-
-        self.debug("Deploying VM in account: %s" % self.account.name)
-
-        # Spawn an instance in that network
-        virtual_machine = VirtualMachine.create(
-                                  self.apiclient,
-                                  self.services["virtual_machine"],
-                                  accountid=self.account.name,
-                                  domainid=self.account.domainid,
-                                  serviceofferingid=self.service_offering.id,
-                                  networkids=[str(network.id)]
-                                  )
-        self.debug("Deployed VM in network: %s" % network.id)
-
-        vms = VirtualMachine.list(
-                                  self.apiclient,
-                                  id=virtual_machine.id,
-                                  listall=True
-                                  )
-        self.assertEqual(
-                         isinstance(vms, list),
-                         True,
-                         "List Vms should return a valid list"
-                         )
-        vm = vms[0]
-        self.assertEqual(
-                         vm.state,
-                         "Running",
-                         "Vm should be in running state after deployment"
-                         )
-
-        self.debug("Listing routers for network: %s" % network.name)
-        routers = Router.list(
-                              self.apiclient,
-                              networkid=network.id,
-                              listall=True
-                              )
-        self.assertEqual(
-                    isinstance(routers, list),
-                    True,
-                    "list router should return Master and backup routers"
-                    )
-        self.assertEqual(
-                    len(routers),
-                    2,
-                    "Length of the list router should be 2 (Backup & master)"
-                    )
-
-        if routers[0].redundantstate == 'MASTER':
-            master_router = routers[0]
-            backup_router = routers[1]
-        else:
-            master_router = routers[1]
-            backup_router = routers[0]
-
-        self.debug("restarting network with cleanup=True")
-        try:
-            network.restart(self.apiclient, cleanup=True)
-        except Exception as e:
-                self.fail("Failed to cleanup network - %s" % e)
-
-        self.debug("Listing routers for network: %s" % network.name)
-        routers = Router.list(
-                              self.apiclient,
-                              networkid=network.id,
-                              listall=True
-                              )
-        self.assertEqual(
-                    isinstance(routers, list),
-                    True,
-                    "list router should return Master and backup routers"
-                    )
-        self.assertEqual(
-                    len(routers),
-                    2,
-                    "Length of the list router should be 2 (Backup & master)"
-                    )
-        for router in routers:
-            self.assertEqual(
-                             router.state,
-                             "Running",
-                             "Router state should be running"
-                             )
-            self.assertIn(
-                    router.linklocalip,
-                    [master_router.linklocalip, backup_router.linklocalip],
-                    "Routers should have same linklocal IP after nw restart"
-                  )
-        return
-
-
-class TestDeleteRvRNetwork(cloudstackTestCase):
-
-    @classmethod
-    def setUpClass(cls):
-        cls.api_client = super(
-                               TestDeleteRvRNetwork,
-                               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.template = get_template(
-                            cls.api_client,
-                            cls.zone.id,
-                            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.network_offering = NetworkOffering.create(
-                                            cls.api_client,
-                                            cls.services["network_offering"],
-                                            conservemode=True
-                                            )
-        # Enable Network offering
-        cls.network_offering.update(cls.api_client, state='Enabled')
-
-        cls._cleanup = [
-                        cls.service_offering,
-                        cls.network_offering,
-                        ]
-        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.account = Account.create(
-                                     self.apiclient,
-                                     self.services["account"],
-                                     admin=True,
-                                     domainid=self.domain.id
-                                     )
-        self._cleanup.insert(0, self.account)
-        return
-
-    @attr(tags=["advanced", "advancedns", "ssh"])
-    def test_restartRvRNetwork_withCleanup(self):
-        """Test Restart network with cleanup
-        """
-
-        # Steps to validate
-        # 1. createNetwork using network offering for redundant virtual router
-        # 2. listRouters in above network
-        # 3. deployVM in above user account in the created network
-        # 4. restartNetwork cleanup=false
-        # 5. listRouters in the account
-        # 6. delete the account
-
-        # Creating network using the network offering created
-        self.debug("Creating network with network offering: %s" %
-                                                    self.network_offering.id)
-        network = Network.create(
-                                self.apiclient,
-                                self.services["network"],
-                                accountid=self.account.name,
-                                domainid=self.account.domainid,
-                                networkofferingid=self.network_offering.id,
-                                zoneid=self.zone.id
-                                )
-        self.debug("Created network with ID: %s" % network.id)
-
-        networks = Network.list(
-                                self.apiclient,
-                                id=network.id,
-                                listall=True
-                                )
-        self.assertEqual(
-            isinstance(networks, list),
-            True,
-            "List networks should return a valid response for created network"
-             )
-        nw_response = networks[0]
-
-        self.debug("Network state: %s" % nw_response.state)
-        self.assertEqual(
-                    nw_response.state,
-                    "Allocated",
-                    "The network should be in allocated state after creation"
-                    )
-
-        self.debug("Listing routers for network: %s" % network.name)
-        routers = Router.list(
-                              self.apiclient,
-                              networkid=network.id,
-                              listall=True
-                              )
-        self.assertEqual(
-            routers,
-            None,
-            "Routers should not be spawned when network is in allocated state"
-            )
-
-        self.debug("Deploying VM in account: %s" % self.account.name)
-
-        # Spawn an instance in that network
-        virtual_machine = VirtualMachine.create(
-                                  self.apiclient,
-                                  self.services["virtual_machine"],
-                                  accountid=self.account.name,
-                                  domainid=self.account.domainid,
-                                  serviceofferingid=self.service_offering.id,
-                                  networkids=[str(network.id)]
-                                  )
-        self.debug("Deployed VM in network: %s" % network.id)
-
-        vms = VirtualMachine.list(
-                                  self.apiclient,
-                                  id=virtual_machine.id,
-                                  listall=True
-                                  )
-        self.assertEqual(
-                         isinstance(vms, list),
-                         True,
-                         "List Vms should return a valid list"
-                         )
-        vm = vms[0]
-        self.assertEqual(
-                         vm.state,
-                         "Running",
-                         "Vm should be in running state after deployment"
-                         )
-
-        self.debug("Listing routers for network: %s" % network.name)
-        routers = Router.list(
-                              self.apiclient,
-                              networkid=network.id,
-                              listall=True
-                              )
-        self.assertEqual(
-                    isinstance(routers, list),
-                    True,
-                    "list router should return Master and backup routers"
-                    )
-        self.assertEqual(
-                    len(routers),
-                    2,
-                    "Length of the list router should be 2 (Backup & master)"
-                    )
-
-        self.debug("Trying to delete the network with running Vms")
-        with self.assertRaises(Exception):
-            network.delete(self.apiclient, cleanup=True)
-
-        self.debug("Network delete failed!")
-        self.debug("Destroying the user VMs for account: %s" %
-                                        self.account.name)
-
-        try:
-            virtual_machine.delete(self.apiclient)
-        except Exception as e:
-            self.fail("Failed to delete guest Vm from account: %s - %s" %
-                                            (self.account.name, e))
-
-        interval = list_configurations(
-                                    self.apiclient,
-                                    name='expunge.delay'
-                                    )
-        delay = int(interval[0].value)
-        interval = list_configurations(
-                                    self.apiclient,
-                                    name='expunge.interval'
-                                    )
-        exp = int(interval[0].value)
-
-        self.debug("Sleeping for exp delay + interval time")
-        # Sleep to ensure that all resources are deleted
-        time.sleep((delay + exp) * 2)
-
-        self.debug("Trying to delete guest network for account: %s" %
-                                                self.account.name)
-        try:
-            network.delete(self.apiclient)
-        except Exception as e:
-            self.fail("Failed to delete network: %s" % e)
-        return
-
-
-class TestNetworkGCRvR(cloudstackTestCase):
-
-    @classmethod
-    def setUpClass(cls):
-        cls.api_client = super(
-                               TestNetworkGCRvR,
-                               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.template = get_template(
-                            cls.api_client,
-                            cls.zone.id,
-                            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.network_offering = NetworkOffering.create(
-                                            cls.api_client,
-                                            cls.services["network_offering"],
-                                            conservemode=True
-                                            )
-        # Enable Network offering
-        cls.network_offering.update(cls.api_client, state='Enabled')
-
-        cls._cleanup = [
-                        cls.service_offering,
-                        cls.network_offering,
-                        ]
-        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.account = Account.create(
-                                     self.apiclient,
-                                     self.services["account"],
-                                     admin=True,
-                                     domainid=self.domain.id
-                                     )
-        self._cleanup.insert(0, self.account)
-        return
-
-    @attr(tags=["advanced", "advancedns", "ssh"])
-    def test_networkGC_RvR(self):
-        """Test network garbage collection with RVR
-        """
-
-        # Steps to validate
-        # 1. createNetwork using network offering for redundant virtual router
-        # 2. listRouters in above network
-        # 3. deployVM in above user account in the created network
-        # 4. stop the running user VM
-        # 5. wait for network.gc time
-        # 6. listRouters
-        # 7. start the routers MASTER and BACK
-        # 8. wait for network.gc time and listRouters
-        # 9. delete the account
-
-        # Creating network using the network offering created
-        self.debug("Creating network with network offering: %s" %
-                                                    self.network_offering.id)
-        network = Network.create(
-                                self.apiclient,
-                                self.services["network"],
-                                accountid=self.account.name,
-                                domainid=self.account.domainid,
-                                networkofferingid=self.network_offering.id,
-                                zoneid=self.zone.id
-                                )
-        self.debug("Created network with ID: %s" % network.id)
-
-        networks = Network.list(
-                                self.apiclient,
-                                id=netw

<TRUNCATED>

[21/29] Split out snapshot tests for speedup

Posted by ts...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c7e2ca56/test/integration/smoke/test_snapshots.py
----------------------------------------------------------------------
diff --git a/test/integration/smoke/test_snapshots.py b/test/integration/smoke/test_snapshots.py
new file mode 100644
index 0000000..06777e4
--- /dev/null
+++ b/test/integration/smoke/test_snapshots.py
@@ -0,0 +1,345 @@
+# 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.
+
+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,
+                    }
+
+
+class TestSnapshotRootDisk(cloudstackTestCase):
+
+    @classmethod
+    def setUpClass(cls):
+        cls.api_client = super(TestSnapshotRootDisk, 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.services['mode'] = cls.zone.networktype
+
+        template = get_template(
+                            cls.api_client,
+                            cls.zone.id,
+                            cls.services["ostype"]
+                            )
+        cls.services["domainid"] = cls.domain.id
+        cls.services["server_without_disk"]["zoneid"] = cls.zone.id
+        cls.services["templates"]["ostypeid"] = template.ostypeid
+        cls.services["zoneid"] = cls.zone.id
+
+        # Create VMs, NAT Rules etc
+        cls.account = Account.create(
+                            cls.api_client,
+                            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.virtual_machine = cls.virtual_machine_with_disk = \
+                    VirtualMachine.create(
+                                cls.api_client,
+                                cls.services["server_without_disk"],
+                                templateid=template.id,
+                                accountid=cls.account.name,
+                                domainid=cls.account.domainid,
+                                serviceofferingid=cls.service_offering.id,
+                                mode=cls.services["mode"]
+                                )
+        cls._cleanup = [
+                        cls.service_offering,
+                        cls.account,
+                        ]
+        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 created instance, volumes and snapshots
+            cleanup_resources(self.apiclient, self.cleanup)
+        except Exception as e:
+            raise Exception("Warning: Exception during cleanup : %s" % e)
+        return
+
+    @attr(speed = "slow")
+    @attr(tags = ["advanced", "advancedns", "smoke"])
+    def test_01_snapshot_root_disk(self):
+        """Test Snapshot Root Disk
+        """
+
+        # Validate the following
+        # 1. listSnapshots should list the snapshot that was created.
+        # 2. verify that secondary storage NFS share contains
+        #    the reqd volume under
+        #    /secondary/snapshots//$account_id/$volumeid/$snapshot_uuid
+        # 3. verify backup_snap_id was non null in the `snapshots` table
+
+        volumes = list_volumes(
+                            self.apiclient,
+                            virtualmachineid=self.virtual_machine_with_disk.id,
+                            type='ROOT',
+                            listall=True
+                            )
+
+        snapshot = Snapshot.create(
+                                   self.apiclient,
+                                   volumes[0].id,
+                                   account=self.account.name,
+                                   domainid=self.account.domainid
+                                   )
+        self.debug("Snapshot created: ID - %s" % snapshot.id)
+
+        snapshots = list_snapshots(
+                                  self.apiclient,
+                                  id=snapshot.id
+                                  )
+        self.assertEqual(
+                            isinstance(snapshots, list),
+                            True,
+                            "Check list response returns a valid list"
+                        )
+
+        self.assertNotEqual(
+                            snapshots,
+                            None,
+                            "Check if result exists in list item call"
+                            )
+        self.assertEqual(
+                            snapshots[0].id,
+                            snapshot.id,
+                            "Check resource id in list resources call"
+                        )
+        self.debug(
+            "select backup_snap_id, account_id, volume_id from snapshots where uuid = '%s';" \
+            % str(snapshot.id)
+            )
+        qresultset = self.dbclient.execute(
+                        "select backup_snap_id, account_id, volume_id from snapshots where uuid = '%s';" \
+                        % str(snapshot.id)
+                        )
+        self.assertNotEqual(
+                            len(qresultset),
+                            0,
+                            "Check DB Query result set"
+                            )
+
+        qresult = qresultset[0]
+
+        snapshot_uuid = qresult[0]      # backup_snap_id = snapshot UUID
+        account_id = qresult[1]
+        volume_id = qresult[2]
+
+        self.assertNotEqual(
+                            str(snapshot_uuid),
+                            'NULL',
+                            "Check if backup_snap_id is not null"
+                        )
+
+        # Get the Secondary Storage details from  list Hosts
+        hosts = list_hosts(
+                                 self.apiclient,
+                                 type='SecondaryStorage',
+                                 zoneid=self.zone.id
+                                 )
+        self.assertEqual(
+                            isinstance(hosts, list),
+                            True,
+                            "Check list response returns a valid list"
+                        )
+        uuids = []
+        for host in hosts:
+            # hosts[0].name = "nfs://192.168.100.21/export/test"
+            parse_url = (host.name).split('/')
+            # parse_url = ['nfs:', '', '192.168.100.21', 'export', 'test']
+
+            # Split IP address and export path from name
+            sec_storage_ip = parse_url[2]
+            # Sec Storage IP: 192.168.100.21
+
+            export_path = '/'.join(parse_url[3:])
+            # Export path: export/test
+
+            try:
+                # Login to VM to check snapshot present on sec disk
+                ssh_client = self.virtual_machine_with_disk.get_ssh_client()
+
+                cmds = [
+                    "mkdir -p %s" % self.services["paths"]["mount_dir"],
+                    "mount %s/%s %s" % (
+                                         sec_storage_ip,
+                                         export_path,
+                                         self.services["paths"]["mount_dir"]
+                                         ),
+                    "ls %s/snapshots/%s/%s" % (
+                                               self.services["paths"]["mount_dir"],
+                                               account_id,
+                                               volume_id
+                                               ),
+                    ]
+
+                for c in cmds:
+                    self.debug(c)
+                    result = ssh_client.execute(c)
+                    self.debug(result)
+
+            except Exception:
+                self.fail("SSH failed for Virtual machine: %s" %
+                                self.virtual_machine_with_disk.ipaddress)
+
+            uuids.append(result)
+            # Unmount the Sec Storage
+            cmds = [
+                    "umount %s" % (self.services["mount_dir"]),
+                    ]
+            try:
+                for c in cmds:
+                    self.debug(c)
+                    result = ssh_client.execute(c)
+                    self.debug(result)
+
+            except Exception as e:
+                self.fail("SSH failed for Virtual machine: %s" %
+                                self.virtual_machine_with_disk.ipaddress)
+
+        res = str(uuids)
+        # Check snapshot UUID in secondary storage and database
+        self.assertEqual(
+                        res.count(snapshot_uuid),
+                        1,
+                        "Check snapshot UUID in secondary storage and database"
+                        )
+        return
\ No newline at end of file


[02/29] git commit: updated refs/heads/master-6-17-stable to 93712c2

Posted by ts...@apache.org.
import tag missing from test_shared_networks.py

Signed-off-by: Prasanna Santhanam <ts...@apache.org>
(cherry picked from commit 76520e807f2595818baaab383e71dbcf3708e94d)


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

Branch: refs/heads/master-6-17-stable
Commit: db10cd3079914edfbbf31dfcbfa616765d1eef3b
Parents: 4127e17
Author: rayeesn <ra...@citrix.com>
Authored: Mon Jun 17 07:22:00 2013 -0700
Committer: Prasanna Santhanam <ts...@apache.org>
Committed: Sat Jun 29 00:52:06 2013 +0530

----------------------------------------------------------------------
 test/integration/component/test_shared_networks.py | 1 +
 1 file changed, 1 insertion(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/db10cd30/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 cb2b55f..6bcfbfd 100644
--- a/test/integration/component/test_shared_networks.py
+++ b/test/integration/component/test_shared_networks.py
@@ -19,6 +19,7 @@
 """
 #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 *


[16/29] git commit: updated refs/heads/master-6-17-stable to 93712c2

Posted by ts...@apache.org.
CLOUDSTACK-2254: Tests for Affinity and Anti Affinity rules

TestCreateAffinityGroup
TestListAffinityGroups
TestDeleteAffinityGroups
TestUpdateVMAffinityGroups
TestDeployVMAffinityGroups
TestAffinityGroupsAdminUser

Signed-off-by: Prasanna Santhanam <ts...@apache.org>
(cherry picked from commit 3c0c6cb0b3c21d08d88763b229c17f4b41c74145)


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

Branch: refs/heads/master-6-17-stable
Commit: 7bad7327236366b662518ed644aaad6fa4a3ac6b
Parents: 2c87763
Author: Girish Shilamkar <gi...@clogeny.com>
Authored: Tue May 21 13:23:10 2013 +0530
Committer: Prasanna Santhanam <ts...@apache.org>
Committed: Sat Jun 29 00:52:08 2013 +0530

----------------------------------------------------------------------
 .../component/test_affinity_groups.py           | 1547 ++++++++++++++++++
 tools/marvin/marvin/integration/lib/base.py     |   38 +-
 2 files changed, 1572 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7bad7327/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
new file mode 100644
index 0000000..79e35e0
--- /dev/null
+++ b/test/integration/component/test_affinity_groups.py
@@ -0,0 +1,1547 @@
+#!/usr/bin/env python
+# 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.
+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 import remoteSSHClient
+from nose.plugins.attrib import attr
+
+class Services:
+    """Test Account Services
+    """
+
+    def __init__(self):
+        self.services = {
+            "domain": {
+                "name": "Domain",
+            },
+            "account": {
+                "email": "newtest@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": 64,
+                # In MBs
+            },
+            "ostype": 'CentOS 5.3 (64-bit)',
+            "host_anti_affinity_0": {
+                    "name": "TestAffGrp_HA_0",
+                    "type": "host anti-affinity",
+                },
+            "host_anti_affinity_1": {
+                    "name": "TestAffGrp_HA_1",
+                    "type": "host anti-affinity",
+                },
+            "virtual_machine" : {
+                "hypervisor" : "KVM",
+            },
+            "new_domain": {
+                "name": "New Domain",
+            },
+            "new_account": {
+                "email": "domain@test.com",
+                "firstname": "Domain",
+                "lastname": "Admin",
+                "username": "do_admin",
+                # Random characters are appended for unique
+                # username
+                "password": "password",
+            },
+            "new_account1": {
+                "email": "user@test.com",
+                "firstname": "User",
+                "lastname": "User",
+                "username": "user",
+                # Random characters are appended for unique
+                # username
+                "password": "password",
+            },
+
+        }
+
+class TestCreateAffinityGroup(cloudstackTestCase):
+    """
+    Test various scenarios for Create Affinity Group API
+    """
+
+    @classmethod
+    def setUpClass(cls):
+
+        cls.api_client = super(TestCreateAffinityGroup, 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.template = get_template(
+            cls.api_client,
+            cls.zone.id,
+            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.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._cleanup = [
+            cls.service_offering,
+            cls.account,
+        ]
+        return
+
+    def setUp(self):
+        self.apiclient = self.testClient.getApiClient()
+        self.dbclient = self.testClient.getDbConnection()
+        self.cleanup = []
+
+    def tearDown(self):
+        try:
+            # Clean up, terminate the created instance, volumes and snapshots
+            cleanup_resources(self.apiclient, self.cleanup)
+        except Exception as e:
+            raise Exception("Warning: Exception during cleanup : %s" % e)
+        return
+
+    @classmethod
+    def tearDownClass(cls):
+        try:
+            cls.api_client = super(TestCreateAffinityGroup, cls).getClsTestClient().getApiClient()
+            #Clean up, terminate the created templates
+            cleanup_resources(cls.api_client, cls._cleanup)
+        except Exception as e:
+            raise Exception("Warning: Exception during cleanup : %s" % e)
+
+    def create_aff_grp(self, api_client=None, aff_grp=None,
+                  acc=None, domainid=None):
+
+        if api_client == None:
+            api_client = self.api_client
+        if aff_grp == None:
+            self.services["host_anti_affinity_0"]
+        if acc == None:
+            acc = self.account.name
+        if domainid == None:
+            domainid = self.domain.id
+
+        try:
+            self.aff_grp = AffinityGroup.create(api_client, aff_grp, acc, domainid)
+        except Exception as e:
+            raise Exception("Error: Creation of Affinity Group failed : %s" %e)
+
+    @attr(tags=["simulator", "basic", "advanced"])
+    def test_01_admin_create_aff_grp(self):
+
+        self.create_aff_grp(aff_grp=self.services["host_anti_affinity_0"])
+        self.debug("Created Affinity Group: %s" %self.aff_grp.name)
+
+        list_aff_grps = AffinityGroup.list(self.api_client)
+        AffinityGroup.delete(self.api_client, list_aff_grps[0].name)
+        self.debug("Deleted Affinity Group: %s" %list_aff_grps[0].name)
+
+    @attr(tags=["simulator", "basic", "advanced"])
+    def test_02_doadmin_create_aff_grp(self):
+
+        self.new_domain = Domain.create(self.api_client, self.services["new_domain"])
+        self.do_admin = Account.create(self.api_client, self.services["new_account"],
+                                      admin=True, domainid=self.new_domain.id)
+        self.cleanup.append(self.do_admin)
+        self.cleanup.append(self.new_domain)
+
+        self.create_aff_grp(aff_grp=self.services["host_anti_affinity_0"],
+                            acc=self.do_admin.name, domainid=self.new_domain.id)
+
+        AffinityGroup.delete(self.api_client, name=self.aff_grp.name,
+                             account=self.do_admin.name, domainid=self.new_domain.id)
+        self.debug("Deleted Affinity Group: %s" %self.aff_grp.name)
+
+
+    @attr(tags=["simulator", "basic", "advanced"])
+    def test_03_user_create_aff_grp(self):
+
+        self.user = Account.create(self.api_client, self.services["new_account"],
+                                  domainid=self.domain.id)
+
+        self.cleanup.append(self.user)
+        self.create_aff_grp(aff_grp=self.services["host_anti_affinity_0"],
+                            acc=self.user.name, domainid=self.domain.id)
+
+        AffinityGroup.delete(self.api_client, name=self.aff_grp.name,
+                             account=self.user.name, domainid=self.domain.id)
+        self.debug("Deleted Affinity Group: %s" %self.aff_grp.name)
+
+
+    @attr(tags=["simulator", "basic", "advanced"])
+    def test_04_user_create_aff_grp_existing_name(self):
+
+        self.user = Account.create(self.api_client, self.services["new_account"],
+                                  domainid=self.domain.id)
+
+        self.cleanup.append(self.user)
+        self.create_aff_grp(aff_grp=self.services["host_anti_affinity_0"],
+                            acc=self.user.name, domainid=self.domain.id)
+        with self.assertRaises(Exception):
+            self.create_aff_grp(aff_grp=self.services["host_anti_affinity_0"],
+                            acc=self.user.name, domainid=self.domain.id)
+
+        AffinityGroup.delete(self.api_client, name=self.aff_grp.name,
+                             account=self.user.name, domainid=self.domain.id)
+        self.debug("Deleted Affinity Group: %s" %self.aff_grp.name)
+
+    @attr(tags=["simulator", "basic", "advanced"])
+    def test_05_create_aff_grp_same_name_diff_acc(self):
+
+        self.user = Account.create(self.api_client, self.services["new_account"],
+                                  domainid=self.domain.id)
+
+        self.cleanup.append(self.user)
+        self.create_aff_grp(aff_grp=self.services["host_anti_affinity_0"],
+                            acc=self.user.name, domainid=self.domain.id)
+
+        try:
+            self.create_aff_grp(aff_grp=self.services["host_anti_affinity_0"])
+        except Exception:
+            self.debug("Error: Creating affinity group with same name from different account failed.")
+
+        AffinityGroup.delete(self.api_client, name=self.aff_grp.name,
+                             account=self.user.name, domainid=self.domain.id)
+        self.debug("Deleted Affinity Group: %s" %self.aff_grp.name)
+
+    @attr(tags=["simulator", "basic", "advanced"])
+    def test_06_create_aff_grp_nonexisting_type(self):
+
+        self.non_existing_aff_grp = {
+                    "name": "TestAffGrp_HA",
+                    "type": "Incorrect type",
+                }
+        with self.assertRaises(Exception):
+            self.create_aff_grp(aff_grp=self.non_existing_aff_grp)
+
+class TestListAffinityGroups(cloudstackTestCase):
+
+    @classmethod
+    def setUpClass(cls):
+
+        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.template = get_template(
+            cls.api_client,
+            cls.zone.id,
+            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.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.__cleanup = [
+            cls.service_offering,
+            cls.account,
+        ]
+
+        # Create multiple Affinity Groups
+        return
+
+    def setUp(self):
+        self.apiclient = self.testClient.getApiClient()
+        self.dbclient = self.testClient.getDbConnection()
+        self.aff_grp = []
+        self.cleanup = []
+
+    def tearDown(self):
+        try:
+            cls.api_client = super(TestListAffinityGroups, cls).getClsTestClient().getApiClient()
+            #Clean up, terminate the created templates
+            cleanup_resources(cls.api_client, cls.cleanup)
+        except Exception as e:
+            raise Exception("Warning: Exception during cleanup : %s" % e)
+
+    @classmethod
+    def tearDownClass(cls):
+
+        try:
+            cls.api_client = super(TestListAffinityGroups, cls).getClsTestClient().getApiClient()
+            #Clean up, terminate the created templates
+            cleanup_resources(cls.api_client, cls.__cleanup)
+        except Exception as e:
+            raise Exception("Warning: Exception during cleanup : %s" % e)
+
+    def create_aff_grp(self, api_client=None, aff_grp=None,
+                  acc=None, domainid=None):
+
+        if api_client == None:
+            api_client = self.api_client
+        if aff_grp == None:
+            self.services["host_anti_affinity_0"]
+        #if acc == None:
+        #    acc = self.account.name
+        #if domainid == None:
+        #    domainid = self.domain.id
+
+        try:
+            self.aff_grp.append(AffinityGroup.create(api_client,
+                                                     aff_grp, acc, domainid))
+        except Exception as e:
+            raise Exception("Error: Creation of Affinity Group failed : %s" %e)
+
+    def create_vm_in_aff_grps(self, ag_list):
+   #try:
+   self.debug('Creating VM in AffinityGroup=%s' % ag_list[0])
+   vm = VirtualMachine.create(
+               self.api_client,
+               self.services["virtual_machine"],
+               templateid=self.template.id,
+               #accountid=self.account.name,
+               #domainid=self.account.domainid,
+               serviceofferingid=self.service_offering.id,
+               affinitygroupnames=ag_list
+            )
+   self.debug('Created VM=%s in Affinity Group=%s' %
+           (vm.id, ag_list[0]))
+   #except Exception:
+       #self.debug('Unable to create VM in a Affinity Group=%s'
+       #                 % ag_list[0])
+
+   list_vm = list_virtual_machines(self.api_client, id=vm.id)
+
+        self.assertEqual(isinstance(list_vm, list), True,
+                         "Check list response returns a valid list")
+        self.assertNotEqual(len(list_vm),0,
+                            "Check VM available in List Virtual Machines")
+
+        vm_response = list_vm[0]
+        self.assertEqual(vm_response.state, 'Running',
+                         msg="VM is not in Running state")
+
+        return vm, vm_response.hostid
+
+    def test_01_list_aff_grps_for_vm(self):
+        """
+           List affinity group for a vm
+        """
+
+        self.create_aff_grp(aff_grp=self.services["host_anti_affinity_0"])
+        list_aff_grps = AffinityGroup.list(self.api_client)
+
+        vm, hostid = self.create_vm_in_aff_grps([self.aff_grp[0].name])
+        list_aff_grps = AffinityGroup.list(self.api_client,
+                                           virtualmachineid=vm.id)
+
+        self.assertEqual(list_aff_grps[0].name, self.aff_grp[0].name,
+                         "Listing Affinity Group by VM id failed")
+
+        vm.delete(self.api_client)
+        #Wait for expunge interval to cleanup VM
+        wait_for_cleanup(self.apiclient, ["expunge.delay", "expunge.interval"])
+
+        AffinityGroup.delete(self.api_client, self.aff_grp[0].name)
+
+    def test_02_list_multiple_aff_grps_for_vm(self):
+        """
+           List multiple affinity groups associated with a vm
+        """
+
+        self.create_aff_grp(aff_grp=self.services["host_anti_affinity_0"])
+        self.create_aff_grp(aff_grp=self.services["host_anti_affinity_1"])
+
+        aff_grps_names = [self.aff_grp[0].name, self.aff_grp[1].name]
+        vm, hostid = self.create_vm_in_aff_grps(aff_grps_names)
+        list_aff_grps = AffinityGroup.list(self.api_client,
+                                           virtualmachineid=vm.id)
+
+        list_aff_grps_names = [list_aff_grps[0].name, list_aff_grps[1].name]
+
+        aff_grps_names.sort()
+        list_aff_grps_names.sort()
+        self.assertEqual(aff_grps_names, list_aff_grps_names,
+                         "One of the Affinity Groups is missing %s"
+                         %list_aff_grps_names)
+
+        vm.delete(self.api_client)
+        #Wait for expunge interval to cleanup VM
+        wait_for_cleanup(self.apiclient, ["expunge.delay", "expunge.interval"])
+
+        for i in aff_grps_names:
+            AffinityGroup.delete(self.api_client, i)
+
+    def test_03_list_aff_grps_by_id(self):
+        """
+           List affinity groups by id
+        """
+
+        self.create_aff_grp(aff_grp=self.services["host_anti_affinity_0"])
+        print self.aff_grp[0].__dict__
+        list_aff_grps = AffinityGroup.list(self.api_client)
+        list_aff_grps = AffinityGroup.list(self.api_client, id=list_aff_grps[0].id)
+        self.assertEqual(list_aff_grps[0].name, self.aff_grp[0].name,
+                         "Listing Affinity Group by VM id failed")
+
+        AffinityGroup.delete(self.api_client, self.aff_grp[0].name)
+
+    def test_04_list_aff_grps_by_name(self):
+        """
+            List Affinity Groups by name
+        """
+
+        self.create_aff_grp(aff_grp=self.services["host_anti_affinity_0"])
+        list_aff_grps = AffinityGroup.list(self.api_client,
+                                           name=self.aff_grp[0].name)
+        self.assertEqual(list_aff_grps[0].name, self.aff_grp[0].name,
+                         "Listing Affinity Group by name failed")
+
+        AffinityGroup.delete(self.api_client, self.aff_grp[0].name)
+
+    def test_05_list_aff_grps_by_non_existing_id(self):
+        """
+            List Affinity Groups by non-existing id
+        """
+
+        self.create_aff_grp(aff_grp=self.services["host_anti_affinity_0"])
+        list_aff_grps = AffinityGroup.list(self.api_client,
+                                           id=1234)
+        self.assertEqual(list_aff_grps, None,
+                         "Listing Affinity Group by non-existing id succeeded.")
+
+        AffinityGroup.delete(self.api_client, self.aff_grp[0].name)
+
+    def test_06_list_aff_grps_by_non_existing_name(self):
+        """
+            List Affinity Groups by non-existing name
+        """
+
+        self.create_aff_grp(aff_grp=self.services["host_anti_affinity_0"])
+        list_aff_grps = AffinityGroup.list(self.api_client,
+                                           name="NonexistingName")
+        self.assertEqual(list_aff_grps, None,
+                         "Listing Affinity Group by non-existing name succeeded.")
+
+        AffinityGroup.delete(self.api_client, self.aff_grp[0].name)
+
+class TestDeleteAffinityGroups(cloudstackTestCase):
+
+    @classmethod
+    def setUpClass(cls):
+
+        cls.api_client = super(TestDeleteAffinityGroups, 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.template = get_template(
+            cls.api_client,
+            cls.zone.id,
+            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.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.__cleanup = [
+            cls.service_offering,
+            cls.account,
+        ]
+
+        # Create multiple Affinity Groups
+        return
+
+    def setUp(self):
+        self.apiclient = self.testClient.getApiClient()
+        self.dbclient = self.testClient.getDbConnection()
+        self.aff_grp = []
+        self.cleanup = []
+
+    def tearDown(self):
+        try:
+            self.api_client = super(TestDeleteAffinityGroups,self).getClsTestClient().getApiClient()
+            #Clean up, terminate the created templates
+            cleanup_resources(self.api_client, self.cleanup)
+        except Exception as e:
+            raise Exception("Warning: Exception during cleanup : %s" % e)
+
+    @classmethod
+    def tearDownClass(cls):
+
+        try:
+            cls.api_client = super(TestDeleteAffinityGroups, cls).getClsTestClient().getApiClient()
+            #Clean up, terminate the created templates
+            cleanup_resources(cls.api_client, cls.__cleanup)
+        except Exception as e:
+            raise Exception("Warning: Exception during cleanup : %s" % e)
+
+    def create_aff_grp(self, api_client=None, aff_grp=None,
+                  acc=None, domainid=None):
+
+        if api_client == None:
+            api_client = self.api_client
+        if aff_grp == None:
+            self.services["host_anti_affinity_0"]
+        #if acc == None:
+        #    acc = self.account.name
+        #if domainid == None:
+        #    domainid = self.domain.id
+
+        try:
+            self.aff_grp.append(AffinityGroup.create(api_client,
+                                                     aff_grp, acc, domainid))
+        except Exception as e:
+            raise Exception("Error: Creation of Affinity Group failed : %s" %e)
+
+    def create_vm_in_aff_grps(self, ag_list):
+   #try:
+   self.debug('Creating VM in AffinityGroup=%s' % ag_list[0])
+   vm = VirtualMachine.create(
+               self.api_client,
+               self.services["virtual_machine"],
+               templateid=self.template.id,
+               #accountid=self.account.name,
+               #domainid=self.account.domainid,
+               serviceofferingid=self.service_offering.id,
+               affinitygroupnames=ag_list
+            )
+   self.debug('Created VM=%s in Affinity Group=%s' %
+           (vm.id, ag_list[0]))
+   #except Exception:
+       #self.debug('Unable to create VM in a Affinity Group=%s'
+       #                 % ag_list[0])
+
+   list_vm = list_virtual_machines(self.api_client, id=vm.id)
+
+        self.assertEqual(isinstance(list_vm, list), True,
+                         "Check list response returns a valid list")
+        self.assertNotEqual(len(list_vm),0,
+                            "Check VM available in Delete Virtual Machines")
+
+        vm_response = list_vm[0]
+        self.assertEqual(vm_response.state, 'Running',
+                         msg="VM is not in Running state")
+
+        return vm, vm_response.hostid
+
+    def test_01_delete_aff_grp_by_id(self):
+        """
+            Delete Afifnity Group by id.
+        """
+
+        self.create_aff_grp(aff_grp=self.services["host_anti_affinity_0"])
+        self.create_aff_grp(aff_grp=self.services["host_anti_affinity_1"])
+
+        list_aff_grps = AffinityGroup.list(self.api_client,
+                                           name=self.aff_grp[0].name)
+
+        AffinityGroup.delete(self.api_client, id=list_aff_grps[0].id)
+
+        AffinityGroup.delete(self.api_client, name=self.aff_grp[1].name)
+
+    def test_02_delete_aff_grp_for_acc(self):
+        """
+            Delete Afifnity Group for an account.
+        """
+
+        self.create_aff_grp(aff_grp=self.services["host_anti_affinity_0"],
+                            acc=self.account.name, domainid=self.domain.id)
+        self.create_aff_grp(aff_grp=self.services["host_anti_affinity_1"],
+                            acc=self.account.name, domainid=self.domain.id)
+
+        AffinityGroup.delete(self.api_client, account=self.account.name,
+                             domainid=self.domain.id, name=self.aff_grp[0].name)
+
+        with self.assertRaises(Exception):
+            vm, hostid = self.create_vm_in_aff_grps([self.aff_grp[0].name])
+
+        AffinityGroup.delete(self.api_client, account=self.account.name,
+                             domainid=self.domain.id, name=self.aff_grp[1].name)
+
+    def test_03_delete_aff_grp_with_vms(self):
+        """
+            Delete Afifnity Group which has vms in it.
+        """
+
+        self.create_aff_grp(aff_grp=self.services["host_anti_affinity_0"],
+                            acc=self.account.name, domainid=self.domain.id)
+        self.create_aff_grp(aff_grp=self.services["host_anti_affinity_1"],
+                            acc=self.account.name, domainid=self.domain.id)
+
+        vm, hostid = self.create_vm_in_aff_grps([self.aff_grp[0].name,
+                                                 self.aff_grp[1].name])
+
+        AffinityGroup.delete(self.api_client, account=self.account.name,
+                             domainid=self.domain.id, name=self.aff_grp[0].name)
+
+        vm_list = list_virtual_machines(self.apiclient,
+                                                 id=self.virtual_machine.id)
+
+
+        vm.delete(self.api_client)
+        #Wait for expunge interval to cleanup VM
+        wait_for_cleanup(self.apiclient, ["expunge.delay", "expunge.interval"])
+
+        AffinityGroup.delete(self.api_client, account=self.account.name,
+                             domainid=self.domain.id, name=self.aff_grp[0].name)
+        AffinityGroup.delete(self.api_client, account=self.account.name,
+                             domainid=self.domain.id, name=self.aff_grp[1].name)
+
+    def test_04_delete_aff_grp_with_vms(self):
+        """
+            Delete Affinity Group which has after updating affinity group for
+            vms in it.
+        """
+
+        self.create_aff_grp(aff_grp=self.services["host_anti_affinity_0"])
+
+        vm1, hostid1 = self.create_vm_in_aff_grps([self.aff_grp[0].name])
+        vm2, hostid2 = self.create_vm_in_aff_grps([self.aff_grp[0].name])
+
+        with self.assertRaises(Exception):
+            AffinityGroup.delete(self.api_client, name=self.aff_grp[0].name)
+
+        vm1.update_affinity_group(self.api_client, affinitygroupnames=[])
+
+        with self.assertRaises(Exception):
+            AffinityGroup.delete(self.api_client, name=self.aff_grp[0].name)
+
+        vm2.update_affinity_group(self.api_client, affinitygroupnames=[])
+
+        AffinityGroup.delete(self.api_client, name=self.aff_grp[0].name)
+
+        vm1.delete(self.api_client)
+        vm2.delete(self.api_client)
+        #Wait for expunge interval to cleanup VM
+        wait_for_cleanup(self.apiclient, ["expunge.delay", "expunge.interval"])
+
+        AffinityGroup.delete(self.api_client, name=self.aff_grp[1].name)
+
+    def test_05_delete_aff_grp_id(self):
+        """
+            Delete Affinity Group with id which does not belong to this user
+        """
+
+        self.user1 = Account.create(self.api_client,
+                                       self.services["new_account"])
+
+        self.cleanup.append(self.user1)
+        self.create_aff_grp(aff_grp=self.services["host_anti_affinity_0"],
+                            acc=self.user1.name,
+                            domainid=self.domain.id)
+
+        self.user2 = Account.create(self.apiclient, self.services["new_account1"])
+        self.cleanup.append(self.user2)
+
+        userapiclient = self.testClient.createUserApiClient(
+                                        UserName=self.user2.name,
+                                        DomainName=self.user2.domain,
+                                        acctType=0)
+
+        self.create_aff_grp(api_client=userapiclient,
+                            aff_grp=self.services["host_anti_affinity_1"])
+
+        list_aff_grps = AffinityGroup.list(self.api_client,
+                                           name=self.aff_grp[0].name)
+
+        # Delete Affinity group belonging to different user by id
+        with self.assertRaises(Exception):
+            AffinityGroup.delete(userapiclient, name=list_aff_grps.id)
+
+        #Cleanup
+        AffinityGroup.delete(self.api_client, name=self.aff_grp[0].name)
+        AffinityGroup.delete(userapiclient, name=self.aff_grp[1].name)
+
+    def test_06_delete_aff_grp_name(self):
+        """
+            Delete Affinity Group by name which does not belong to this user
+        """
+
+        self.user1 = Account.create(self.api_client,
+                                       self.services["new_account"])
+
+        self.cleanup.append(self.user1)
+        self.create_aff_grp(aff_grp=self.services["host_anti_affinity_0"],
+                            acc=self.user1.name,
+                            domainid=self.domain.id)
+
+        self.user2 = Account.create(self.apiclient, self.services["new_account1"])
+        self.cleanup.append(self.user2)
+
+        userapiclient = self.testClient.createUserApiClient(
+                                        UserName=self.user2.name,
+                                        DomainName=self.user2.domain,
+                                        acctType=0)
+
+        self.create_aff_grp(api_client=userapiclient,
+                            aff_grp=self.services["host_anti_affinity_1"])
+
+        # Delete Affinity group belonging to different user by name
+        with self.assertRaises(Exception):
+            AffinityGroup.delete(userapiclient, name=self.aff_grp[0].name)
+
+        #Cleanup
+        AffinityGroup.delete(self.api_client, name=self.aff_grp[0].name)
+        AffinityGroup.delete(userapiclient, name=self.aff_grp[1].name)
+
+class TestUpdateVMAffinityGroups(cloudstackTestCase):
+
+    @classmethod
+    def setUpClass(cls):
+
+        cls.api_client = super(TestUpdateVMAffinityGroups, 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.template = get_template(
+            cls.api_client,
+            cls.zone.id,
+            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.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.__cleanup = [
+            cls.service_offering,
+            cls.account,
+        ]
+
+        # Create multiple Affinity Groups
+        return
+
+    def setUp(self):
+        self.apiclient = self.testClient.getApiClient()
+        self.dbclient = self.testClient.getDbConnection()
+        self.aff_grp = []
+        self.cleanup = []
+
+    def tearDown(self):
+        try:
+            self.api_client = super(TestUpdateVMAffinityGroups,self).getClsTestClient().getApiClient()
+            #Clean up, terminate the created templates
+            cleanup_resources(self.api_client, self.cleanup)
+        except Exception as e:
+            raise Exception("Warning: Exception during cleanup : %s" % e)
+
+    @classmethod
+    def tearDownClass(cls):
+
+        try:
+            cls.api_client = super(TestUpdateVMAffinityGroups, cls).getClsTestClient().getApiClient()
+            #Clean up, terminate the created templates
+            cleanup_resources(cls.api_client, cls.__cleanup)
+        except Exception as e:
+            raise Exception("Warning: Exception during cleanup : %s" % e)
+
+    def create_aff_grp(self, api_client=None, aff_grp=None,
+                  acc=None, domainid=None):
+
+        if api_client == None:
+            api_client = self.api_client
+        if aff_grp == None:
+            self.services["host_anti_affinity_0"]
+        #if acc == None:
+        #    acc = self.account.name
+        #if domainid == None:
+        #    domainid = self.domain.id
+
+        try:
+            self.aff_grp.append(AffinityGroup.create(api_client,
+                                                     aff_grp, acc, domainid))
+        except Exception as e:
+            raise Exception("Error: Creation of Affinity Group failed : %s" %e)
+
+    def create_vm_in_aff_grps(self, ag_list):
+   #try:
+   self.debug('Creating VM in AffinityGroup=%s' % ag_list[0])
+   vm = VirtualMachine.create(
+               self.api_client,
+               self.services["virtual_machine"],
+               templateid=self.template.id,
+               #accountid=self.account.name,
+               #domainid=self.account.domainid,
+               serviceofferingid=self.service_offering.id,
+               affinitygroupnames=ag_list
+            )
+   self.debug('Created VM=%s in Affinity Group=%s' %
+           (vm.id, ag_list[0]))
+   #except Exception:
+       #self.debug('Unable to create VM in a Affinity Group=%s'
+       #                 % ag_list[0])
+
+   list_vm = list_virtual_machines(self.api_client, id=vm.id)
+
+        self.assertEqual(isinstance(list_vm, list), True,
+                         "Check list response returns a valid list")
+        self.assertNotEqual(len(list_vm),0,
+                            "Check VM available in Delete Virtual Machines")
+
+        vm_response = list_vm[0]
+        self.assertEqual(vm_response.state, 'Running',
+                         msg="VM is not in Running state")
+
+        return vm, vm_response.hostid
+
+    def test_01_update_aff_grp_by_ids(self):
+        """
+            Update the list of affinityGroups by using affinity groupids
+
+        """
+        self.create_aff_grp(aff_grp=self.services["host_anti_affinity_0"])
+        self.create_aff_grp(aff_grp=self.services["host_anti_affinity_1"])
+
+        vm1, hostid1 = self.create_vm_in_aff_grps([self.aff_grp[0].name])
+        vm2, hostid2 = self.create_vm_in_aff_grps([self.aff_grp[0].name])
+
+        vm1.stop(self.api_client)
+
+        list_aff_grps = AffinityGroup.list(self.api_client)
+
+        self.assertEqual(len(list_aff_grps), 2 , "2 affinity groups should be present")
+
+        vm1.update_affinity_group(self.api_client,
+                                  affinitygroupids=[list_aff_grps[0].id,
+                                                    list_aff_grps[1].id])
+
+        list_aff_grps = AffinityGroup.list(self.api_client,
+                                           virtualmachineid=vm1.id)
+
+        list_aff_grps_names = [list_aff_grps[0].name, list_aff_grps[1].name]
+
+        aff_grps_names = [self.aff_grp[0].name, self.aff_grp[1].name]
+        aff_grps_names.sort()
+        list_aff_grps_names.sort()
+        self.assertEqual(aff_grps_names, list_aff_grps_names,
+                         "One of the Affinity Groups is missing %s"
+                         %list_aff_grps_names)
+
+        vm1.start(self.api_client)
+
+        vm_status = VirtualMachine.list(self.api_client, id=vm1.id)
+        self.assertNotEqual(vm_status[0].hostid, hostid2, "The virtual machine "
+                         "started on host %s violating the host anti-affinity"
+                         "rule" %vm_status[0].hostid)
+
+        vm1.delete(self.api_client)
+        vm2.delete(self.api_client)
+        #Wait for expunge interval to cleanup VM
+        wait_for_cleanup(self.apiclient, ["expunge.delay", "expunge.interval"])
+        for i in aff_grps_names:
+            AffinityGroup.delete(self.api_client, i)
+
+    def test_02_update_aff_grp_by_names(self):
+        """
+            Update the list of affinityGroups by using affinity groupnames
+
+        """
+        self.create_aff_grp(aff_grp=self.services["host_anti_affinity_0"])
+        self.create_aff_grp(aff_grp=self.services["host_anti_affinity_1"])
+        vm1, hostid1 = self.create_vm_in_aff_grps([self.aff_grp[0].name])
+        vm2, hostid2 = self.create_vm_in_aff_grps([self.aff_grp[0].name])
+
+        vm1.stop(self.api_client)
+
+        vm1.update_affinity_group(self.api_client,
+                                  affinitygroupnames=[self.aff_grp[0].name,
+                                                    self.aff_grp[1].name])
+
+        list_aff_grps = AffinityGroup.list(self.api_client,
+                                           virtualmachineid=vm1.id)
+
+        list_aff_grps_names = [list_aff_grps[0].name, list_aff_grps[1].name]
+
+        aff_grps_names = [self.aff_grp[0].name, self.aff_grp[1].name]
+        aff_grps_names.sort()
+        list_aff_grps_names.sort()
+        self.assertEqual(aff_grps_names, list_aff_grps_names,
+                         "One of the Affinity Groups is missing %s"
+                         %list_aff_grps_names)
+
+        vm1.start(self.api_client)
+
+        vm_status = VirtualMachine.list(self.api_client, id=vm1.id)
+        self.assertNotEqual(vm_status[0].hostid, hostid2, "The virtual machine "
+                         "started on host %s violating the host anti-affinity"
+                         "rule" %vm_status[0].hostid)
+
+        vm1.delete(self.api_client)
+        vm2.delete(self.api_client)
+        #Wait for expunge interval to cleanup VM
+        wait_for_cleanup(self.apiclient, ["expunge.delay", "expunge.interval"])
+        for i in aff_grps_names:
+            AffinityGroup.delete(self.api_client, i)
+
+    def test_03_update_aff_grp_for_vm_with_no_aff_grp(self):
+        """
+            Update the list of affinityGroups for vm which is not associated
+            with any affinity groups.
+
+        """
+        self.create_aff_grp(aff_grp=self.services["host_anti_affinity_0"])
+        self.create_aff_grp(aff_grp=self.services["host_anti_affinity_1"])
+        vm1, hostid1 = self.create_vm_in_aff_grps([])
+        vm2, hostid2 = self.create_vm_in_aff_grps([self.aff_grp[0].name])
+
+        vm1.stop(self.api_client)
+
+        vm1.update_affinity_group(self.api_client,
+                                  affinitygroupnames=[self.aff_grp[0].name])
+
+        vm1.start(self.api_client)
+
+        vm_status = VirtualMachine.list(self.api_client, id=vm1.id)
+        self.assertNotEqual(vm_status[0].hostid, hostid2, "The virtual machine "
+                         "started on host %s violating the host anti-affinity"
+                         "rule" %vm_status[0].hostid)
+
+        vm1.delete(self.api_client)
+        vm2.delete(self.api_client)
+        #Wait for expunge interval to cleanup VM
+        wait_for_cleanup(self.apiclient, ["expunge.delay", "expunge.interval"])
+        aff_grps_names = [self.aff_grp[0].name, self.aff_grp[1].name]
+        for i in aff_grps_names:
+            AffinityGroup.delete(self.api_client, i)
+
+    def test_04_update_aff_grp_remove_all(self):
+        """
+            Update the list of Affinity Groups to empty list
+        """
+
+        self.create_aff_grp(aff_grp=self.services["host_anti_affinity_0"])
+        self.create_aff_grp(aff_grp=self.services["host_anti_affinity_1"])
+        vm1, hostid1 = self.create_vm_in_aff_grps([self.aff_grp[0].name])
+
+        aff_grps_names = [self.aff_grp[0].name, self.aff_grp[1].name]
+        vm1.stop(self.api_client)
+
+        vm1.update_affinity_group(self.api_client,
+                                  affinitygroupnames=[])
+
+        vm1.start(self.api_client)
+        list_aff_grps = AffinityGroup.list(self.api_client,
+                                           virtualmachineid=vm.id)
+        self.assertEqual(list_aff_grps, [], "The affinity groups list is not empyty")
+
+        vm1.delete(self.api_client)
+        #Wait for expunge interval to cleanup VM
+        wait_for_cleanup(self.apiclient, ["expunge.delay", "expunge.interval"])
+        for i in aff_grps_names:
+            AffinityGroup.delete(self.api_client, i)
+
+    def test_05_update_aff_grp_on_running_vm(self):
+        """
+            Update the list of Affinity Groups on running vm
+        """
+
+        self.create_aff_grp(aff_grp=self.services["host_anti_affinity_0"])
+        self.create_aff_grp(aff_grp=self.services["host_anti_affinity_1"])
+        vm1, hostid1 = self.create_vm_in_aff_grps([self.aff_grp[0].name])
+
+        aff_grps_names = [self.aff_grp[0].name, self.aff_grp[1].name]
+        with self.assertRaises(Exception):
+            vm1.update_affinity_group(self.api_client, affinitygroupnames=[])
+
+        vm1.delete(self.api_client)
+        #Wait for expunge interval to cleanup VM
+        wait_for_cleanup(self.apiclient, ["expunge.delay", "expunge.interval"])
+        for i in aff_grps_names:
+            AffinityGroup.delete(self.api_client, i)
+
+class TestDeployVMAffinityGroups(cloudstackTestCase):
+
+    @classmethod
+    def setUpClass(cls):
+
+        cls.api_client = super(TestDeployVMAffinityGroups, 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.template = get_template(
+            cls.api_client,
+            cls.zone.id,
+            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.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.__cleanup = [
+            cls.service_offering,
+            cls.account,
+        ]
+
+        # Create multiple Affinity Groups
+        return
+
+    def setUp(self):
+        self.apiclient = self.testClient.getApiClient()
+        self.dbclient = self.testClient.getDbConnection()
+        self.aff_grp = []
+        self.cleanup = []
+
+    def tearDown(self):
+        try:
+            self.api_client = super(TestDeployVMAffinityGroups,self).getClsTestClient().getApiClient()
+            #Clean up, terminate the created templates
+            cleanup_resources(self.api_client, self.cleanup)
+        except Exception as e:
+            raise Exception("Warning: Exception during cleanup : %s" % e)
+
+    @classmethod
+    def tearDownClass(cls):
+
+        try:
+            cls.api_client = super(TestDeployVMAffinityGroups, cls).getClsTestClient().getApiClient()
+            #Clean up, terminate the created templates
+            cleanup_resources(cls.api_client, cls.__cleanup)
+        except Exception as e:
+            raise Exception("Warning: Exception during cleanup : %s" % e)
+
+    def create_aff_grp(self, api_client=None, aff_grp=None,
+                  acc=None, domainid=None):
+
+        if api_client == None:
+            api_client = self.api_client
+        if aff_grp == None:
+            self.services["host_anti_affinity_0"]
+        #if acc == None:
+        #    acc = self.account.name
+        #if domainid == None:
+        #    domainid = self.domain.id
+
+        try:
+            self.aff_grp.append(AffinityGroup.create(api_client,
+                                                     aff_grp, acc, domainid))
+        except Exception as e:
+            raise Exception("Error: Creation of Affinity Group failed : %s" %e)
+
+    def create_vm_in_aff_grps(self, api_client=None, ag_list=None, ag_ids=None):
+
+        if api_client == None:
+            api_client = self.api_client
+   self.debug('Creating VM in AffinityGroup=%s' % ag_list)
+   vm = VirtualMachine.create(
+               api_client,
+               self.services["virtual_machine"],
+               templateid=self.template.id,
+               #accountid=self.account.name,
+               #domainid=self.account.domainid,
+               serviceofferingid=self.service_offering.id,
+               affinitygroupnames=ag_list,
+                affinitygroupids=ag_ids
+            )
+   self.debug('Created VM=%s in Affinity Group=%s' %
+           (vm.id, ag_list))
+
+   list_vm = list_virtual_machines(self.api_client, id=vm.id)
+
+        self.assertEqual(isinstance(list_vm, list), True,
+                         "Check list response returns a valid list")
+        self.assertNotEqual(len(list_vm),0,
+                            "Check VM available in Delete Virtual Machines")
+
+        vm_response = list_vm[0]
+        self.assertEqual(vm_response.state, 'Running',
+                         msg="VM is not in Running state")
+
+        return vm, vm_response.hostid
+
+    @attr(tags=["simulator", "basic", "advanced", "multihost"])
+    def test_01_deploy_vm_without_aff_grp(self):
+        """
+            Deploy VM without affinity group
+        """
+
+        vm1, hostid1 = self.create_vm_in_aff_grps()
+
+        vm1.delete(self.api_client)
+        #Wait for expunge interval to cleanup VM
+        wait_for_cleanup(self.apiclient, ["expunge.delay", "expunge.interval"])
+
+    @attr(tags=["simulator", "basic", "advanced", "multihost"])
+    def test_02_deploy_vm_by_aff_grp_name(self):
+        """
+            Deploy VM by aff grp name
+        """
+
+        self.create_aff_grp(aff_grp=self.services["host_anti_affinity_0"])
+        vm1, hostid1 = self.create_vm_in_aff_grps([self.aff_grp[0].name])
+
+        vm1.delete(self.api_client)
+        wait_for_cleanup(self.apiclient, ["expunge.delay", "expunge.interval"])
+        AffinityGroup.delete(self.api_client, self.aff_grp[0].name)
+
+    @attr(tags=["simulator", "basic", "advanced", "multihost"])
+    def test_03_deploy_vm_by_aff_grp_id(self):
+        """
+            Deploy VM by aff grp id
+        """
+        self.create_aff_grp(aff_grp=self.services["host_anti_affinity_0"])
+
+        list_aff_grps = AffinityGroup.list(self.api_client,
+                                           name=self.aff_grp[0].name)
+
+        vm1, hostid1 = self.create_vm_in_aff_grps(ag_ids=[list_aff_grps[0].id])
+
+        vm1.delete(self.api_client)
+        wait_for_cleanup(self.apiclient, ["expunge.delay", "expunge.interval"])
+        AffinityGroup.delete(self.api_client, self.aff_grp[0].name)
+
+    @attr(tags=["simulator", "basic", "advanced", "multihost"])
+    def test_04_deploy_vm_anti_affinity_group(self):
+        """
+        test DeployVM in anti-affinity groups
+
+        deploy VM1 and VM2 in the same host-anti-affinity groups
+        Verify that the vms are deployed on separate hosts
+        """
+        self.create_aff_grp(aff_grp=self.services["host_anti_affinity_0"])
+        vm1, hostid1 = self.create_vm_in_aff_grps(ag_list=[self.aff_grp[0].name])
+        vm2, hostid2 = self.create_vm_in_aff_grps(ag_list=[self.aff_grp[0].name])
+
+        self.assertNotEqual(hostid1, hostid2,
+            msg="Both VMs of affinity group %s are on the same host"
+            % self.aff_grp[0].name)
+
+        vm1.delete(self.api_client)
+        vm2.delete(self.api_client)
+        wait_for_cleanup(self.apiclient, ["expunge.delay", "expunge.interval"])
+        AffinityGroup.delete(self.api_client, self.aff_grp[0].name)
+
+    @attr(tags=["simulator", "basic", "advanced", "multihost"])
+    def test_05_deploy_vm_by_id(self):
+        """
+            Deploy vms by affinity group id
+        """
+        self.create_aff_grp(aff_grp=self.services["host_anti_affinity_0"])
+
+        list_aff_grps = AffinityGroup.list(self.api_client,
+                                           name=self.aff_grp[0].name)
+
+        vm1, hostid1 = self.create_vm_in_aff_grps(ag_ids=[list_aff_grps[0].id])
+        vm2, hostid2 = self.create_vm_in_aff_grps(ag_ids=[list_aff_grps[0].id])
+
+        self.assertNotEqual(hostid1, hostid2,
+            msg="Both VMs of affinity group %s are on the same host"
+            % self.aff_grp[0].name)
+
+        vm1.delete(self.api_client)
+        vm2.delete(self.api_client)
+        wait_for_cleanup(self.apiclient, ["expunge.delay", "expunge.interval"])
+        AffinityGroup.delete(self.api_client, self.aff_grp[0].name)
+
+    @attr(tags=["simulator", "basic", "advanced", "multihost"])
+    def test_06_deploy_vm_aff_grp_of_other_user_by_name(self):
+        """
+            Deploy vm in affinity group of another user by name
+        """
+
+        self.user1 = Account.create(self.api_client,
+                                       self.services["new_account"])
+
+        self.cleanup.append(self.user1)
+        self.create_aff_grp(aff_grp=self.services["host_anti_affinity_0"],
+                            acc=self.user1.name,
+                            domainid=self.domain.id)
+
+        self.user2 = Account.create(self.apiclient, self.services["new_account1"])
+        self.cleanup.append(self.user2)
+
+        userapiclient = self.testClient.createUserApiClient(
+                                        UserName=self.user2.name,
+                                        DomainName=self.user2.domain,
+                                        acctType=0)
+
+        self.create_aff_grp(api_client=userapiclient,
+                            aff_grp=self.services["host_anti_affinity_1"])
+
+        with self.assertRaises(Exception):
+            vm1, hostid1 = self.create_vm_in_aff_grps(api_client=userapiclient,
+                                                  ag_list=[self.aff_grp[0].name])
+
+
+        AffinityGroup.delete(self.api_client, self.aff_grp[0].name)
+        AffinityGroup.delete(userapiclient, self.aff_grp[1].name)
+
+    @attr(tags=["simulator", "basic", "advanced", "multihost"])
+    def test_07_deploy_vm_aff_grp_of_other_user_by_id(self):
+        """
+            Deploy vm in affinity group of another user by id
+        """
+
+        self.user1 = Account.create(self.api_client,
+                                       self.services["new_account"])
+
+        self.cleanup.append(self.user1)
+        self.create_aff_grp(aff_grp=self.services["host_anti_affinity_0"],
+                            acc=self.user1.name,
+                            domainid=self.domain.id)
+
+        self.user2 = Account.create(self.apiclient, self.services["new_account1"])
+        self.cleanup.append(self.user2)
+
+        userapiclient = self.testClient.createUserApiClient(
+                                        UserName=self.user2.name,
+                                        DomainName=self.user2.domain,
+                                        acctType=0)
+
+        self.create_aff_grp(api_client=userapiclient,
+                            aff_grp=self.services["host_anti_affinity_1"])
+
+        list_aff_grps = AffinityGroup.list(self.api_client,
+                                           name=self.aff_grp[0].name)
+
+        # Deploy VM in Affinity group belonging to different user by id
+        with self.assertRaises(Exception):
+            vm1, hostid1 = self.create_vm_in_aff_grps(api_client=userapiclient,
+                                                  ag_ids=[list_aff_grps[0].id])
+
+        AffinityGroup.delete(self.api_client, self.aff_grp[0].name)
+        AffinityGroup.delete(userapiclient, self.aff_grp[1].name)
+
+    @attr(tags=["simulator", "basic", "advanced", "multihost"])
+    def test_08_deploy_vm_multiple_aff_grps(self):
+        """
+            Deploy vm in multiple affinity groups
+        """
+
+        self.create_aff_grp(aff_grp=self.services["host_anti_affinity_0"])
+        self.create_aff_grp(aff_grp=self.services["host_anti_affinity_1"])
+        vm1, hostid1 = self.create_vm_in_aff_grps(ag_list=[self.aff_grp[0].name,
+                                                   self.aff_grp[1].name])
+
+        list_aff_grps = AffinityGroup.list(self.api_client,
+                                           virtualmachineid=vm1.id)
+
+        aff_grps_names = [self.aff_grp[0].name, self.aff_grp[1].name]
+        list_aff_grps_names = [list_aff_grps[0].name, list_aff_grps[1].name]
+
+        aff_grps_names.sort()
+        list_aff_grps_names.sort()
+        self.assertEqual(aff_grps_names, list_aff_grps_names,
+                         "One of the Affinity Groups is missing %s"
+                         %list_aff_grps_names)
+
+        vm1.delete(self.api_client)
+        wait_for_cleanup(self.apiclient, ["expunge.delay", "expunge.interval"])
+        AffinityGroup.delete(self.api_client, self.aff_grp[0].name)
+        AffinityGroup.delete(self.api_client, self.aff_grp[1].name)
+
+    @attr(tags=["simulator", "basic", "advanced", "multihost"])
+    def test_09_deploy_vm_multiple_aff_grps(self):
+        """
+            Deploy multiple vms in multiple affinity groups
+        """
+
+        self.create_aff_grp(aff_grp=self.services["host_anti_affinity_0"])
+        self.create_aff_grp(aff_grp=self.services["host_anti_affinity_1"])
+        vm1, hostid1 = self.create_vm_in_aff_grps(ag_list=[self.aff_grp[0].name,
+                                                   self.aff_grp[1].name])
+        vm2, hostid2 = self.create_vm_in_aff_grps(ag_list=[self.aff_grp[0].name,
+                                                   self.aff_grp[1].name])
+
+        aff_grps_names = [self.aff_grp[0].name, self.aff_grp[1].name]
+        aff_grps_names.sort()
+
+        for vm in [vm1, vm2]:
+            list_aff_grps = AffinityGroup.list(self.api_client,
+                                           virtualmachineid=vm.id)
+
+            list_aff_grps_names = [list_aff_grps[0].name, list_aff_grps[1].name]
+
+            list_aff_grps_names.sort()
+            self.assertEqual(aff_grps_names, list_aff_grps_names,
+                         "One of the Affinity Groups is missing %s"
+                         %list_aff_grps_names)
+
+        vm1.delete(self.api_client)
+        vm2.delete(self.api_client)
+        wait_for_cleanup(self.apiclient, ["expunge.delay", "expunge.interval"])
+
+        AffinityGroup.delete(self.api_client, self.aff_grp[0].name)
+        AffinityGroup.delete(self.api_client, self.aff_grp[1].name)
+
+    @attr(tags=["simulator", "basic", "advanced", "multihost"])
+    def test_10_deploy_vm_by_aff_grp_name_and_id(self):
+        """
+            Deploy VM by aff grp name and id
+        """
+
+        self.create_aff_grp(aff_grp=self.services["host_anti_affinity_0"])
+        list_aff_grps = AffinityGroup.list(self.api_client,
+                                           name=self.aff_grp[0].name)
+
+        with self.assertRaises(Exception):
+            vm1, hostid1 = self.create_vm_in_aff_grps(ag_list=[self.aff_grp[0].name],
+                                                  ag_ids=[list_aff_grps[0].id])
+
+        AffinityGroup.delete(self.api_client, self.aff_grp[0].name)
+
+class TestAffinityGroupsAdminUser(cloudstackTestCase):
+
+    @classmethod
+    def setUpClass(cls):
+
+        cls.api_client = super(TestAffinityGroupsAdminUser, 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.template = get_template(
+            cls.api_client,
+            cls.zone.id,
+            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.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.__cleanup = [
+            cls.service_offering,
+            cls.account,
+        ]
+
+        # Create multiple Affinity Groups
+        return
+
+    def setUp(self):
+        self.apiclient = self.testClient.getApiClient()
+        self.dbclient = self.testClient.getDbConnection()
+        self.aff_grp = []
+        self.cleanup = []
+
+    def tearDown(self):
+        try:
+            self.api_client = super(TestAffinityGroupsAdminUser,self).getClsTestClient().getApiClient()
+            #Clean up, terminate the created templates
+            cleanup_resources(self.api_client, self.cleanup)
+        except Exception as e:
+            raise Exception("Warning: Exception during cleanup : %s" % e)
+
+    @classmethod
+    def tearDownClass(cls):
+
+        try:
+            cls.api_client = super(TestAffinityGroupsAdminUser, cls).getClsTestClient().getApiClient()
+            #Clean up, terminate the created templates
+            cleanup_resources(cls.api_client, cls.__cleanup)
+        except Exception as e:
+            raise Exception("Warning: Exception during cleanup : %s" % e)
+
+    def create_aff_grp(self, api_client=None, aff_grp=None,
+                  acc=None, domainid=None):
+
+        if api_client == None:
+            api_client = self.api_client
+        if aff_grp == None:
+            self.services["host_anti_affinity_0"]
+        #if acc == None:
+        #    acc = self.account.name
+        #if domainid == None:
+        #    domainid = self.domain.id
+
+        try:
+            self.aff_grp.append(AffinityGroup.create(api_client,
+                                                     aff_grp, acc, domainid))
+        except Exception as e:
+            raise Exception("Error: Creation of Affinity Group failed : %s" %e)
+
+    def create_vm_in_aff_grps(self, api_client=None, ag_list=None, ag_ids=None):
+
+        if api_client == None:
+            api_client = self.api_client
+   self.debug('Creating VM in AffinityGroup=%s' % ag_list)
+   vm = VirtualMachine.create(
+               api_client,
+               self.services["virtual_machine"],
+               templateid=self.template.id,
+               #accountid=self.account.name,
+               #domainid=self.account.domainid,
+               serviceofferingid=self.service_offering.id,
+               affinitygroupnames=ag_list,
+                affinitygroupids=ag_ids
+            )
+   self.debug('Created VM=%s in Affinity Group=%s' %
+           (vm.id, ag_list))
+
+   list_vm = list_virtual_machines(self.api_client, id=vm.id)
+
+        self.assertEqual(isinstance(list_vm, list), True,
+                         "Check list response returns a valid list")
+        self.assertNotEqual(len(list_vm),0,
+                            "Check VM available in Delete Virtual Machines")
+
+        vm_response = list_vm[0]
+        self.assertEqual(vm_response.state, 'Running',
+                         msg="VM is not in Running state")
+
+        return vm, vm_response.hostid
+
+    @attr(tags=["simulator", "basic", "advanced", "multihost"])
+    def test_01_deploy_vm_another_user(self):
+        """
+            Deploy vm in Affinity Group belonging to regular user
+        """
+        self.user1 = Account.create(self.api_client,
+                                       self.services["new_account"])
+
+        self.cleanup.append(self.user1)
+        userapiclient = self.testClient.createUserApiClient(
+                                        UserName=self.user1.name,
+                                        DomainName=self.user1.domain,
+                                        acctType=0)
+
+        self.create_aff_grp(api_client=userapiclient,
+                            aff_grp=self.services["host_anti_affinity_0"])
+
+        with self.assertRaises(Exception):
+            vm1, hostid1 = self.create_vm_in_aff_grps(ag_list=[self.aff_grp[0].name])
+
+        AffinityGroup.delete(userapiclient, self.aff_grp[0].name)
+
+    @attr(tags=["simulator", "basic", "advanced", "multihost"])
+    def test_02_create_aff_grp_user(self):
+        """
+            Create Affinity Group forregular user
+        """
+
+        self.user = Account.create(self.api_client, self.services["new_account"],
+                                  domainid=self.domain.id)
+
+        self.cleanup.append(self.user)
+        self.create_aff_grp(aff_grp=self.services["host_anti_affinity_0"],
+                            acc=self.user.name, domainid=self.domain.id)
+
+        AffinityGroup.delete(self.api_client, name=self.aff_grp[0].name,
+                             account=self.user.name, domainid=self.domain.id)
+        self.debug("Deleted Affinity Group: %s" %self.aff_grp[0].name)
+
+    @attr(tags=["simulator", "basic", "advanced", "multihost"])
+    def test_03_list_aff_grp_all_users(self):
+        """
+            List Affinity Groups for all the users
+        """
+
+        self.user1 = Account.create(self.api_client,
+                                       self.services["new_account"])
+
+        self.cleanup.append(self.user1)
+        userapiclient = self.testClient.createUserApiClient(
+                                        UserName=self.user1.name,
+                                        DomainName=self.user1.domain,
+                                        acctType=0)
+
+        self.create_aff_grp(api_client=userapiclient,
+                            aff_grp=self.services["host_anti_affinity_0"])
+
+        list_aff_grps = AffinityGroup.list(self.api_client)
+        print list_aff_grps
+        self.assertNotEqual(list_aff_grps, [], "Admin not able to list Affinity "
+                         "Groups of users")
+        AffinityGroup.delete(userapiclient, self.aff_grp[0].name)

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7bad7327/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
index 503ed64..710d9a9 100755
--- a/tools/marvin/marvin/integration/lib/base.py
+++ b/tools/marvin/marvin/integration/lib/base.py
@@ -2965,28 +2965,40 @@ class AffinityGroup:
         self.__dict__.update(items)
 
     @classmethod
-    def create(cls, apiclient, services, account=None, domainid=None):
-        agCmd = createAffinityGroup.createAffinityGroupCmd()
-        agCmd.name = services['name']
-        agCmd.displayText = services['displaytext'] if 'displaytext' in services else services['name']
-        agCmd.type = services['type']
-        agCmd.account = services['account'] if 'account' in services else account
-        agCmd.domainid = services['domainid'] if 'domainid' in services else domainid
-        return AffinityGroup(apiclient.createAffinityGroup(agCmd).__dict__)
+    def create(cls, apiclient, aff_grp, account=None, domainid=None):
+        cmd = createAffinityGroup.createAffinityGroupCmd()
+        cmd.name = aff_grp['name']
+        cmd.displayText = aff_grp['name']
+        cmd.type = aff_grp['type']
+        #if account is not None:
+        #    cmd.account = account
+        #if domainid is not None:
+        #    cmd.domainid = domainid
+        return AffinityGroup(apiclient.createAffinityGroup(cmd).__dict__)
 
     def update(self, apiclient):
         pass
 
-    def delete(self, apiclient):
+    @classmethod
+    def delete(cls, apiclient, name=None, id=None, account=None,
+               domainid=None):
         cmd = deleteAffinityGroup.deleteAffinityGroupCmd()
-        cmd.id = self.id
-        return apiclient.deleteVPC(cmd)
+        if id is not None:
+            cmd.id = id
+        if name is not None:
+            cmd.name = name
+        if account is not None:
+            cmd.account = account
+        if domainid is not None:
+            cmd.domaindid = domainid
+
+        return apiclient.deleteAffinityGroup(cmd)
 
     @classmethod
     def list(cls, apiclient, **kwargs):
         cmd = listAffinityGroups.listAffinityGroupsCmd()
         [setattr(cmd, k, v) for k, v in kwargs.items()]
-        return(apiclient.listVPCs(cmd))
+        return apiclient.listAffinityGroups(cmd)
 
 class StaticRoute:
     """Manage static route lifecycle"""
@@ -3373,4 +3385,4 @@ class ApplicationLoadBalancer:
         """List all appln load balancers"""
         cmd = listLoadBalancers.listLoadBalancersCmd()
         [setattr(cmd, k, v) for k, v in kwargs.items()]
-        return(apiclient.listLoadBalancerRules(cmd))
\ No newline at end of file
+        return(apiclient.listLoadBalancerRules(cmd))


[03/29] git commit: updated refs/heads/master-6-17-stable to 93712c2

Posted by ts...@apache.org.
Removed junk characters from test_netscaler_lb.py

Signed-off-by: Prasanna Santhanam <ts...@apache.org>
(cherry picked from commit 85ed2160876826fa28088a716657f6c7bcbf84ec)


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

Branch: refs/heads/master-6-17-stable
Commit: 4127e17ca505bab4558187d3154746ea4d2f6fcc
Parents: ab185fb
Author: rayeesn <ra...@citrix.com>
Authored: Tue Jun 18 11:02:08 2013 +0530
Committer: Prasanna Santhanam <ts...@apache.org>
Committed: Sat Jun 29 00:52:06 2013 +0530

----------------------------------------------------------------------
 test/integration/component/test_netscaler_lb.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4127e17c/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 b4e6c30..9d06275 100644
--- a/test/integration/component/test_netscaler_lb.py
+++ b/test/integration/component/test_netscaler_lb.py
@@ -1085,7 +1085,7 @@ class TestAddMultipleVmsLb(cloudstackTestCase):
         # 3. Acquire Ip address and create LB rule on it. Add multiple VMs to
         #    this rule. LB rule should be
         # In Netscaler: For every Vm added to the LB rule:
-        # 1. A server and service instance is created using guest VM’s IP and
+        # 1. A server and service instance is created using guest VMs IP and
         #    port number on the Netscaler LB device,
         # 2. This service is bound to lb virtual server corresponding to lb
         #    rule.


[24/29] git commit: updated refs/heads/master-6-17-stable to 93712c2

Posted by ts...@apache.org.
CLOUDSTACK-1758: Fix ssvm test failures, where ssh to ssvm failed.

Signed-off-by: Prasanna Santhanam <ts...@apache.org>
(cherry picked from commit 5140473f2b754c1f178aae7946798d95027ec69a)


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

Branch: refs/heads/master-6-17-stable
Commit: 7733ddb575f55e70c3d6864aaac925e5f32a7d16
Parents: aaa9fc0
Author: Girish Shilamkar <gi...@clogeny.com>
Authored: Wed Jun 19 20:26:43 2013 +0530
Committer: Prasanna Santhanam <ts...@apache.org>
Committed: Sat Jun 29 00:52:08 2013 +0530

----------------------------------------------------------------------
 test/integration/smoke/test_ssvm.py | 42 +++++++++++++++++++++++++++++---
 1 file changed, 39 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7733ddb5/test/integration/smoke/test_ssvm.py
----------------------------------------------------------------------
diff --git a/test/integration/smoke/test_ssvm.py b/test/integration/smoke/test_ssvm.py
index d637f96..6893472 100644
--- a/test/integration/smoke/test_ssvm.py
+++ b/test/integration/smoke/test_ssvm.py
@@ -334,7 +334,19 @@ class TestSSVMs(cloudstackTestCase):
 
         self.debug("Running SSVM check script")
 
-        result = get_process_status(
+        if self.apiclient.hypervisor.lower() == 'vmware':
+            #SSH into SSVMs is done via management server for Vmware
+            result = get_process_status(
+                                self.apiclient.connection.mgtSvr,
+                                22,
+                                self.apiclient.connection.user,
+                                self.apiclient.connection.passwd,
+                                ssvm.privateip,
+                                "/usr/local/cloud/systemvm/ssvm-check.sh |grep -e ERROR -e WARNING -e FAIL",
+                                hypervisor=self.apiclient.hypervisor
+                                )
+        else:
+            result = get_process_status(
                                 host.ipaddress,
                                 self.services['host']["publicport"],
                                 self.services['host']["username"],
@@ -358,7 +370,19 @@ class TestSSVMs(cloudstackTestCase):
                         )
 
         #Check status of cloud service
-        result = get_process_status(
+        if self.apiclient.hypervisor.lower() == 'vmware':
+            #SSH into SSVMs is done via management server for Vmware
+            result = get_process_status(
+                                self.apiclient.connection.mgtSvr,
+                                22,
+                                self.apiclient.connection.user,
+                                self.apiclient.connection.passwd,
+                                ssvm.privateip,
+                                "service cloud status",
+                                hypervisor=self.apiclient.hypervisor
+                                )
+        else:
+            result = get_process_status(
                                 host.ipaddress,
                                 self.services['host']["publicport"],
                                 self.services['host']["username"],
@@ -426,7 +450,19 @@ class TestSSVMs(cloudstackTestCase):
 
         self.debug("Checking cloud process status")
 
-        result = get_process_status(
+        if self.apiclient.hypervisor.lower() == 'vmware':
+            #SSH into SSVMs is done via management server for vmware
+            result = get_process_status(
+                                self.apiclient.connection.mgtSvr,
+                                22,
+                                self.apiclient.connection.user,
+                                self.apiclient.connection.passwd,
+                                cpvm.privateip,
+                                "service cloud status",
+                                hypervisor=self.apiclient.hypervisor
+                                )
+        else:
+            result = get_process_status(
                                 host.ipaddress,
                                 self.services['host']["publicport"],
                                 self.services['host']["username"],


[27/29] git commit: updated refs/heads/master-6-17-stable to 93712c2

Posted by ts...@apache.org.
cmds is not a list. just regular string to ssh

Signed-off-by: Prasanna Santhanam <ts...@apache.org>
(cherry picked from commit 2af6db24ed35a95b5bb9493003b241617b5d7835)


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

Branch: refs/heads/master-6-17-stable
Commit: 012a2d2d426efc9fc3f22f51dbb7572d82a8abfd
Parents: 7bad732
Author: Prasanna Santhanam <ts...@apache.org>
Authored: Tue Jun 25 19:39:15 2013 +0530
Committer: Prasanna Santhanam <ts...@apache.org>
Committed: Sat Jun 29 00:52:09 2013 +0530

----------------------------------------------------------------------
 test/integration/smoke/test_vm_life_cycle.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/012a2d2d/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 b54182e..c2c2592 100644
--- a/test/integration/smoke/test_vm_life_cycle.py
+++ b/test/integration/smoke/test_vm_life_cycle.py
@@ -747,7 +747,7 @@ class TestVMLifeCycle(cloudstackTestCase):
             self.fail("SSH failed for virtual machine: %s - %s" %
                                 (self.virtual_machine.ipaddress, e))
 
-        cmds = [ "mkdir -p %s" % self.services["mount_dir"] ]
+        cmds = "mkdir -p %s" % self.services["mount_dir"]
         self.assert_(ssh_client.execute(cmds) == [], "mkdir failed within guest")
 
         for diskdevice in self.services["diskdevice"]:


[05/29] Split Redundant Router tests

Posted by ts...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b9524157/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
new file mode 100644
index 0000000..6d9ad09
--- /dev/null
+++ b/test/integration/component/test_redundant_router_upgrades.py
@@ -0,0 +1,486 @@
+# 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.
+
+
+from nose.plugins.attrib import attr
+from marvin.integration.lib.base import *
+from marvin.integration.lib.utils import *
+from marvin.integration.lib.common import *
+
+#Import Local Modules
+from marvin.cloudstackTestCase import cloudstackTestCase
+from marvin.cloudstackAPI import *
+
+class Services:
+    """Test Services for customer defects
+    """
+
+    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,
+                                    "memory": 128,
+                        },
+                        "disk_offering": {
+                                    "displaytext": "Small",
+                                    "name": "Small",
+                                    "disksize": 1
+                        },
+                        "virtual_machine": {
+                                    "displayname": "Test VM",
+                                    "username": "root",
+                                    "password": "password",
+                                    "ssh_port": 22,
+                                    "hypervisor": 'XenServer',
+                                    "privateport": 22,
+                                    "publicport": 22,
+                                    "protocol": 'TCP',
+                        },
+                        "static_nat": {
+                                    "startport": 22,
+                                    "endport": 22,
+                                    "protocol": "TCP"
+                        },
+                        "network_offering": {
+                                    "name": 'Network offering-RVR services',
+                                    "displaytext": 'Network off-RVR services',
+                                    "guestiptype": 'Isolated',
+                                    "supportedservices": 'Vpn,Dhcp,Dns,SourceNat,PortForwarding,Firewall,Lb,UserData,StaticNat',
+                                    "traffictype": 'GUEST',
+                                    "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"
+                                        },
+                                    },
+                        },
+                        "host": {
+                                 "username": "root",
+                                 "password": "password",
+                                 "publicport": 22,
+                        },
+                        "network": {
+                                  "name": "Test Network",
+                                  "displaytext": "Test Network",
+                                },
+                        "lbrule": {
+                                    "name": "SSH",
+                                    "alg": "roundrobin",
+                                    # Algorithm used for load balancing
+                                    "privateport": 22,
+                                    "publicport": 22,
+                                    "openfirewall": True,
+                                },
+                        "natrule": {
+                                    "privateport": 22,
+                                    "publicport": 22,
+                                    "protocol": "TCP"
+                                },
+                        "natrule_221": {
+                                    "privateport": 22,
+                                    "publicport": 221,
+                                    "protocol": "TCP"
+                                },
+                        "fw_rule": {
+                                    "startport": 1,
+                                    "endport": 6000,
+                                    "cidr": '55.55.0.0/11',
+                                    # Any network (For creating FW rule)
+                                    "protocol": 'TCP',
+                                },
+                        "ostype": 'CentOS 5.3 (64-bit)',
+                        "sleep": 60,
+            }
+
+class TestRvRUpgradeDowngrade(cloudstackTestCase):
+
+    @classmethod
+    def setUpClass(cls):
+        cls.api_client = super(
+                               TestRvRUpgradeDowngrade,
+                               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.template = get_template(
+                            cls.api_client,
+                            cls.zone.id,
+                            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.network_offering = NetworkOffering.create(
+                                            cls.api_client,
+                                            cls.services["network_offering"],
+                                            conservemode=True
+                                            )
+        # Enable Network offering
+        cls.network_offering.update(cls.api_client, state='Enabled')
+
+        cls._cleanup = [
+                        cls.service_offering,
+                        cls.network_offering,
+                        ]
+        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.account = Account.create(
+                                     self.apiclient,
+                                     self.services["account"],
+                                     admin=True,
+                                     domainid=self.domain.id
+                                     )
+        self._cleanup.insert(0, self.account)
+        return
+
+    @attr(tags=["advanced", "advancedns", "ssh"])
+    def test_upgradeVR_to_redundantVR(self):
+        """Test upgrade virtual router to redundant virtual router
+        """
+
+        # Steps to validate
+        # 1. create a network with DefaultNetworkOfferingWithSourceNATservice
+        #    (all VR based services)
+        # 2. deploy a VM in the above network and listRouters
+        # 3. create a network Offering that has redundant router enabled and
+        #    all VR based services
+        # 4. updateNetwork created above to the offfering in 3.
+        # 5. listRouters in the network
+        # 6. delete account in which resources are created
+        # Validate the following
+        # 1. listNetworks should show the created network in allocated state
+        # 2. VM should be deployed and in Running state and there should be
+        #    one Router running for this network
+        # 3. listNetworkOfferings should show craeted offering for RvR
+        # 4. listNetworks shows the network still successfully implemented
+        # 5. listRouters shows two routers Up and Running (MASTER and BACKUP)
+
+        network_offerings = NetworkOffering.list(
+                            self.apiclient,
+                            name='DefaultIsolatedNetworkOfferingWithSourceNatService',
+                            listall=True
+                         )
+        self.assertEqual(
+                    isinstance(network_offerings, list),
+                    True,
+                    "List network offering should not return empty response"
+                    )
+
+        network_off_vr = network_offerings[0]
+        # Creating network using the network offering created
+        self.debug("Creating network with network offering: %s" %
+                                                        network_off_vr.id)
+        network = Network.create(
+                                self.apiclient,
+                                self.services["network"],
+                                accountid=self.account.name,
+                                domainid=self.account.domainid,
+                                networkofferingid=network_off_vr.id,
+                                zoneid=self.zone.id
+                                )
+        self.debug("Created network with ID: %s" % network.id)
+
+        networks = Network.list(
+                                self.apiclient,
+                                id=network.id,
+                                listall=True
+                                )
+        self.assertEqual(
+            isinstance(networks, list),
+            True,
+            "List networks should return a valid response for created network"
+             )
+        nw_response = networks[0]
+
+        self.debug("Network state: %s" % nw_response.state)
+        self.assertEqual(
+                    nw_response.state,
+                    "Allocated",
+                    "The network should be in allocated state after creation"
+                    )
+
+        self.debug("Deploying VM in account: %s" % self.account.name)
+
+        # Spawn an instance in that network
+        virtual_machine = VirtualMachine.create(
+                                  self.apiclient,
+                                  self.services["virtual_machine"],
+                                  accountid=self.account.name,
+                                  domainid=self.account.domainid,
+                                  serviceofferingid=self.service_offering.id,
+                                  networkids=[str(network.id)]
+                                  )
+        self.debug("Deployed VM in the account: %s" %
+                                    self.account.name)
+
+        vms = VirtualMachine.list(
+                                  self.apiclient,
+                                  id=virtual_machine.id,
+                                  listall=True
+                                  )
+        self.assertEqual(
+                         isinstance(vms, list),
+                         True,
+                         "List Vms should return a valid list"
+                         )
+        vm = vms[0]
+        self.assertEqual(
+                         vm.state,
+                         "Running",
+                         "Vm should be in running state after deployment"
+                         )
+
+        self.debug("Listing routers for account: %s" %
+                                        self.account.name)
+        routers = Router.list(
+                              self.apiclient,
+                              account=self.account.name,
+                              domainid=self.account.domainid,
+                              listall=True
+                              )
+        self.assertEqual(
+                    isinstance(routers, list),
+                    True,
+                    "list router should return only one router"
+                    )
+        self.assertEqual(
+                    len(routers),
+                    1,
+                    "Length of the list router should be 1"
+                    )
+
+        self.debug("Upgrading the network to RVR network offering..")
+        try:
+            network.update(
+                           self.apiclient,
+                           networkofferingid=self.network_offering.id
+                           )
+        except Exception as e:
+            self.fail("Failed to upgrade the network from VR to RVR: %s" % e)
+
+        self.debug("Listing routers for account: %s" %
+                                        self.account.name)
+        routers = Router.list(
+                              self.apiclient,
+                              account=self.account.name,
+                              domainid=self.account.domainid,
+                              listall=True
+                              )
+        self.assertEqual(
+                    isinstance(routers, list),
+                    True,
+                    "list router should return two routers"
+                    )
+        self.assertEqual(
+                    len(routers),
+                    2,
+                    "Length of the list router should be 2 (MASTER & BACKUP)"
+                    )
+        return
+
+    @attr(tags=["advanced", "advancedns", "ssh"])
+    def test_downgradeRvR_to_VR(self):
+        """Test downgrade redundant virtual router to virtual router
+        """
+
+        # Steps to validate
+        # 1. create a network Offering that has redundant router enabled and
+        #    all VR based services
+        # 2. create a network with above offering
+        # 3. deploy a VM in the above network and listRouters
+        # 4. create a network Offering that has redundant router disabled and
+        #    all VR based services
+        # 5. updateNetwork - downgrade - created above to the offfering in 4.
+        # 6. listRouters in the network
+        # 7. delete account in which resources are created
+        # Validate the following
+        # 1. listNetworkOfferings should show craeted offering for RvR
+        # 2. listNetworks should show the created network in allocated state
+        # 3. VM should be deployed and in Running state and there should be
+        #    two routers (MASTER and BACKUP) for this network
+        # 4. listNetworkOfferings should show craeted offering for VR
+        # 5. listNetworks shows the network still successfully implemented
+        # 6. listRouters shows only one router for this network in Running
+
+        # Creating network using the network offering created
+        self.debug("Creating network with network offering: %s" %
+                                                    self.network_offering.id)
+        network = Network.create(
+                                self.apiclient,
+                                self.services["network"],
+                                accountid=self.account.name,
+                                domainid=self.account.domainid,
+                                networkofferingid=self.network_offering.id,
+                                zoneid=self.zone.id
+                                )
+        self.debug("Created network with ID: %s" % network.id)
+
+        networks = Network.list(
+                                self.apiclient,
+                                id=network.id,
+                                listall=True
+                                )
+        self.assertEqual(
+            isinstance(networks, list),
+            True,
+            "List networks should return a valid response for created network"
+             )
+        nw_response = networks[0]
+
+        self.debug("Network state: %s" % nw_response.state)
+        self.assertEqual(
+                    nw_response.state,
+                    "Allocated",
+                    "The network should be in allocated state after creation"
+                    )
+
+        self.debug("Deploying VM in account: %s" % self.account.name)
+
+        # Spawn an instance in that network
+        virtual_machine = VirtualMachine.create(
+                                  self.apiclient,
+                                  self.services["virtual_machine"],
+                                  accountid=self.account.name,
+                                  domainid=self.account.domainid,
+                                  serviceofferingid=self.service_offering.id,
+                                  networkids=[str(network.id)]
+                                  )
+        self.debug("Deployed VM in the account: %s" %
+                                    self.account.name)
+
+        vms = VirtualMachine.list(
+                                  self.apiclient,
+                                  id=virtual_machine.id,
+                                  listall=True
+                                  )
+        self.assertEqual(
+                         isinstance(vms, list),
+                         True,
+                         "List Vms should return a valid list"
+                         )
+        vm = vms[0]
+        self.assertEqual(
+                         vm.state,
+                         "Running",
+                         "Vm should be in running state after deployment"
+                         )
+
+        self.debug("Listing routers for account: %s" %
+                                        self.account.name)
+        routers = Router.list(
+                              self.apiclient,
+                              account=self.account.name,
+                              domainid=self.account.domainid,
+                              listall=True
+                              )
+        self.assertEqual(
+                    isinstance(routers, list),
+                    True,
+                    "list router should return two routers"
+                    )
+        self.assertEqual(
+                    len(routers),
+                    2,
+                    "Length of the list router should be 2 (MASTER & BACKUP)"
+                    )
+
+        network_offerings = NetworkOffering.list(
+                            self.apiclient,
+                            name='DefaultIsolatedNetworkOfferingWithSourceNatService',
+                            listall=True
+                         )
+        self.assertEqual(
+                    isinstance(network_offerings, list),
+                    True,
+                    "List network offering should not return empty response"
+                    )
+
+        network_off_vr = network_offerings[0]
+
+        self.debug("Upgrading the network to RVR network offering..")
+        try:
+            network.update(
+                           self.apiclient,
+                           networkofferingid=network_off_vr.id
+                           )
+        except Exception as e:
+            self.fail("Failed to upgrade the network from VR to RVR: %s" % e)
+
+        self.debug("Listing routers for account: %s" %
+                                        self.account.name)
+        routers = Router.list(
+                              self.apiclient,
+                              account=self.account.name,
+                              domainid=self.account.domainid,
+                              listall=True
+                              )
+        self.assertEqual(
+                    isinstance(routers, list),
+                    True,
+                    "list router should return only one router"
+                    )
+        self.assertEqual(
+                    len(routers),
+                    1,
+                    "Length of the list router should be 1"
+                    )
+        return


[11/29] git commit: updated refs/heads/master-6-17-stable to 93712c2

Posted by ts...@apache.org.
Remove wait during cleanup

Cleanups need not wait at teardown for accounts to be removed. This
slows down the test case. Send the cleanup request and forget instead

Signed-off-by: Prasanna Santhanam <ts...@apache.org>
(cherry picked from commit b0d186ce5bd42a9120243d1f32adabc6851865a5)


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

Branch: refs/heads/master-6-17-stable
Commit: 6363550bf10db9bb84ba1affdd2a7438eacfed5d
Parents: 4510667
Author: Prasanna Santhanam <ts...@apache.org>
Authored: Wed Jun 19 12:47:42 2013 +0530
Committer: Prasanna Santhanam <ts...@apache.org>
Committed: Sat Jun 29 00:52:07 2013 +0530

----------------------------------------------------------------------
 .../component/test_redundant_router.py          | 301 ++-----------------
 1 file changed, 28 insertions(+), 273 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6363550b/test/integration/component/test_redundant_router.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_redundant_router.py b/test/integration/component/test_redundant_router.py
index 914b174..814f3e2 100644
--- a/test/integration/component/test_redundant_router.py
+++ b/test/integration/component/test_redundant_router.py
@@ -23,10 +23,8 @@ from marvin.integration.lib.utils import *
 from marvin.integration.lib.common import *
 
 #Import Local Modules
-from marvin.cloudstackTestCase import *
+from marvin.cloudstackTestCase import cloudstackTestCase
 from marvin.cloudstackAPI import *
-from marvin import remoteSSHClient
-
 
 class Services:
     """Test Services for customer defects
@@ -88,10 +86,10 @@ class Services:
                                             "UserData": 'VirtualRouter',
                                             "StaticNat": 'VirtualRouter',
                                         },
-                                    "servicecapabilitylist": {
+                                    "serviceCapabilityList": {
                                         "SourceNat": {
                                             "SupportedSourceNatTypes": "peraccount",
-                                            "RedundantRouter": 'true',
+                                            "RedundantRouter": "true",
                                         },
                                         "lb": {
                                                "SupportedLbIsolation": "dedicated"
@@ -190,6 +188,7 @@ class TestCreateRvRNetworkOffering(cloudstackTestCase):
         # Validate the following
         # 1. Redundant Router offering should be created successfully and
         #    listed in listNetworkOfferings response
+        # assert if RvR capability is enabled
 
         self.debug("Creating network offering with redundant VR capability")
         try:
@@ -281,22 +280,7 @@ class TestCreateRvRNetwork(cloudstackTestCase):
                                      admin=True,
                                      domainid=self.domain.id
                                      )
-        self.cleanup = []
-        return
-
-    def tearDown(self):
-        try:
-            self.account.delete(self.apiclient)
-            interval = list_configurations(
-                                    self.apiclient,
-                                    name='account.cleanup.interval'
-                                    )
-            # Sleep to ensure that all resources are deleted
-            time.sleep(int(interval[0].value) * 2)
-            #Clean up, terminate the created network offerings
-            cleanup_resources(self.apiclient, self.cleanup)
-        except Exception as e:
-            raise Exception("Warning: Exception during cleanup : %s" % e)
+        self._cleanup.insert(0, self.account)
         return
 
     @attr(tags=["advanced", "advancedns", "ssh"])
@@ -487,22 +471,7 @@ class TestCreateRvRNetworkNonDefaultGuestCidr(cloudstackTestCase):
                                      admin=True,
                                      domainid=self.domain.id
                                      )
-        self.cleanup = []
-        return
-
-    def tearDown(self):
-        try:
-            self.account.delete(self.apiclient)
-            interval = list_configurations(
-                                    self.apiclient,
-                                    name='account.cleanup.interval'
-                                    )
-            # Sleep to ensure that all resources are deleted
-            time.sleep(int(interval[0].value) * 2)
-            #Clean up, terminate the created network offerings
-            cleanup_resources(self.apiclient, self.cleanup)
-        except Exception as e:
-            raise Exception("Warning: Exception during cleanup : %s" % e)
+        self._cleanup.insert(0, self.account)
         return
 
     @attr(tags=["advanced", "advancedns", "ssh"])
@@ -701,22 +670,7 @@ class TestRVRInternals(cloudstackTestCase):
                                      admin=True,
                                      domainid=self.domain.id
                                      )
-        self.cleanup = []
-        return
-
-    def tearDown(self):
-        try:
-            self.account.delete(self.apiclient)
-            interval = list_configurations(
-                                    self.apiclient,
-                                    name='account.cleanup.interval'
-                                    )
-            # Sleep to ensure that all resources are deleted
-            time.sleep(int(interval[0].value) * 2)
-            #Clean up, terminate the created network offerings
-            cleanup_resources(self.apiclient, self.cleanup)
-        except Exception as e:
-            raise Exception("Warning: Exception during cleanup : %s" % e)
+        self._cleanup.insert(0, self.account)
         return
 
     @attr(tags=["advanced", "advancedns", "ssh"])
@@ -1029,22 +983,7 @@ class TestRedundancy(cloudstackTestCase):
                                   networkids=[str(self.network.id)]
                                   )
         self.debug("Deployed VM in network: %s" % self.network.id)
-        self.cleanup = []
-        return
-
-    def tearDown(self):
-        try:
-            self.account.delete(self.apiclient)
-            interval = list_configurations(
-                                    self.apiclient,
-                                    name='account.cleanup.interval'
-                                    )
-            # Sleep to ensure that all resources are deleted
-            time.sleep(int(interval[0].value) * 2)
-            #Clean up, terminate the created network offerings
-            cleanup_resources(self.apiclient, self.cleanup)
-        except Exception as e:
-            raise Exception("Warning: Exception during cleanup : %s" % e)
+        self._cleanup.insert(0, self.account)
         return
 
     @attr(tags=["advanced", "advancedns", "ssh"])
@@ -1100,9 +1039,7 @@ class TestRedundancy(cloudstackTestCase):
 
         self.debug("Stopping the MASTER router")
         try:
-            cmd = stopRouter.stopRouterCmd()
-            cmd.id = master_router.id
-            self.apiclient.stopRouter(cmd)
+            Router.stop(self.apiclient, id=master_router.id)
         except Exception as e:
             self.fail("Failed to stop master router: %s" % e)
 
@@ -1144,9 +1081,7 @@ class TestRedundancy(cloudstackTestCase):
 
         self.debug("Starting the old MASTER router")
         try:
-            cmd = startRouter.startRouter(cmd)
-            cmd.id = master_router.id
-            self.apiclient.startRouter(cmd)
+            Router.start(self.apiclient, id=master_router.id)
             self.debug("old MASTER router started")
         except Exception as e:
             self.fail("Failed to stop master router: %s" % e)
@@ -1227,9 +1162,7 @@ class TestRedundancy(cloudstackTestCase):
 
         self.debug("Stopping the BACKUP router")
         try:
-            cmd = stopRouter.stopRouterCmd()
-            cmd.id = backup_router.id
-            self.apiclient.stopRouter(cmd)
+            Router.stop(self.apiclient, id=backup_router.id)
         except Exception as e:
             self.fail("Failed to stop backup router: %s" % e)
 
@@ -1271,9 +1204,7 @@ class TestRedundancy(cloudstackTestCase):
 
         self.debug("Starting the old BACKUP router")
         try:
-            cmd = startRouter.startRouter(cmd)
-            cmd.id = backup_router.id
-            self.apiclient.startRouter(cmd)
+            Router.start(self.apiclient, id=backup_router.id)
             self.debug("old BACKUP router started")
         except Exception as e:
             self.fail("Failed to stop master router: %s" % e)
@@ -1348,9 +1279,7 @@ class TestRedundancy(cloudstackTestCase):
 
         self.debug("Rebooting the master router")
         try:
-            cmd = rebootRouter.rebootRouterCmd()
-            cmd.id = master_router.id
-            self.apiclient.rebootRouter(cmd)
+            Router.reboot(self.apiclient, id=master_router.id)
         except Exception as e:
             self.fail("Failed to reboot MASTER router: %s" % e)
 
@@ -1442,9 +1371,7 @@ class TestRedundancy(cloudstackTestCase):
 
         self.debug("Rebooting the backuo router")
         try:
-            cmd = rebootRouter.rebootRouterCmd()
-            cmd.id = backup_router.id
-            self.apiclient.rebootRouter(cmd)
+            Router.reboot(self.apiclient, id=backup_router.id)
         except Exception as e:
             self.fail("Failed to reboot BACKUP router: %s" % e)
 
@@ -1536,9 +1463,7 @@ class TestRedundancy(cloudstackTestCase):
 
         self.debug("Stopping the backup router")
         try:
-            cmd = stopRouter.stopRouterCmd()
-            cmd.id = backup_router.id
-            self.apiclient.stopRouter(cmd)
+            Router.stop(self.apiclient, id=backup_router.id)
         except Exception as e:
             self.fail("Failed to stop BACKUP router: %s" % e)
 
@@ -1665,21 +1590,7 @@ class TestApplyAndDeleteNetworkRulesOnRvR(cloudstackTestCase):
                                      domainid=self.domain.id
                                      )
         self.cleanup = []
-        return
-
-    def tearDown(self):
-        try:
-            self.account.delete(self.apiclient)
-            interval = list_configurations(
-                                    self.apiclient,
-                                    name='account.cleanup.interval'
-                                    )
-            # Sleep to ensure that all resources are deleted
-            time.sleep(int(interval[0].value) * 2)
-            #Clean up, terminate the created network offerings
-            cleanup_resources(self.apiclient, self.cleanup)
-        except Exception as e:
-            raise Exception("Warning: Exception during cleanup : %s" % e)
+        self.cleanup.insert(0, self.account)
         return
 
     @attr(tags=["advanced", "advancedns", "ssh"])
@@ -1989,22 +1900,7 @@ class TestEnableVPNOverRvR(cloudstackTestCase):
                                      admin=True,
                                      domainid=self.domain.id
                                      )
-        self.cleanup = []
-        return
-
-    def tearDown(self):
-        try:
-            self.account.delete(self.apiclient)
-            interval = list_configurations(
-                                    self.apiclient,
-                                    name='account.cleanup.interval'
-                                    )
-            # Sleep to ensure that all resources are deleted
-            time.sleep(int(interval[0].value) * 2)
-            #Clean up, terminate the created network offerings
-            cleanup_resources(self.apiclient, self.cleanup)
-        except Exception as e:
-            raise Exception("Warning: Exception during cleanup : %s" % e)
+        self._cleanup.insert(0, self.account)
         return
 
     @attr(tags=["advanced", "advancedns", "ssh"])
@@ -2245,22 +2141,7 @@ class TestNetworkRulesMasterDownDeleteNetworkRules(cloudstackTestCase):
                                      admin=True,
                                      domainid=self.domain.id
                                      )
-        self.cleanup = []
-        return
-
-    def tearDown(self):
-        try:
-            self.account.delete(self.apiclient)
-            interval = list_configurations(
-                                    self.apiclient,
-                                    name='account.cleanup.interval'
-                                    )
-            # Sleep to ensure that all resources are deleted
-            time.sleep(int(interval[0].value) * 2)
-            #Clean up, terminate the created network offerings
-            cleanup_resources(self.apiclient, self.cleanup)
-        except Exception as e:
-            raise Exception("Warning: Exception during cleanup : %s" % e)
+        self._cleanup.insert(0, self.account)
         return
 
     @attr(tags=["advanced", "advancedns", "ssh"])
@@ -2393,10 +2274,7 @@ class TestNetworkRulesMasterDownDeleteNetworkRules(cloudstackTestCase):
         self.debug("Stopping router ID: %s" % master_router.id)
 
         try:
-            #Stop the router
-            cmd = stopRouter.stopRouterCmd()
-            cmd.id = master_router.id
-            self.apiclient.stopRouter(cmd)
+            Router.stop(self.apiclient, id=master_router.id)
         except Exception as e:
             self.fail("Failed to stop master router..")
 
@@ -2545,10 +2423,7 @@ class TestNetworkRulesMasterDownDeleteNetworkRules(cloudstackTestCase):
         self.debug("Starting router ID: %s" % master_router.id)
 
         try:
-            #Stop the router
-            cmd = startRouter.startRouterCmd()
-            cmd.id = master_router.id
-            self.apiclient.startRouter(cmd)
+            Router.start(self.apiclient, id=master_router.id)
         except Exception as e:
             self.fail("Failed to start master router..")
 
@@ -2633,22 +2508,7 @@ class TestApplyDeleteNetworkRulesRebootRouter(cloudstackTestCase):
                                      admin=True,
                                      domainid=self.domain.id
                                      )
-        self.cleanup = []
-        return
-
-    def tearDown(self):
-        try:
-            self.account.delete(self.apiclient)
-            interval = list_configurations(
-                                    self.apiclient,
-                                    name='account.cleanup.interval'
-                                    )
-            # Sleep to ensure that all resources are deleted
-            time.sleep(int(interval[0].value) * 2)
-            #Clean up, terminate the created network offerings
-            cleanup_resources(self.apiclient, self.cleanup)
-        except Exception as e:
-            raise Exception("Warning: Exception during cleanup : %s" % e)
+        self._clean.insert(0, self.account)
         return
 
     @attr(tags=["advanced", "advancedns", "ssh"])
@@ -3013,22 +2873,7 @@ class TestRestartRvRNetworkWithoutCleanup(cloudstackTestCase):
                                      admin=True,
                                      domainid=self.domain.id
                                      )
-        self.cleanup = []
-        return
-
-    def tearDown(self):
-        try:
-            self.account.delete(self.apiclient)
-            interval = list_configurations(
-                                    self.apiclient,
-                                    name='account.cleanup.interval'
-                                    )
-            # Sleep to ensure that all resources are deleted
-            time.sleep(int(interval[0].value) * 2)
-            #Clean up, terminate the created network offerings
-            cleanup_resources(self.apiclient, self.cleanup)
-        except Exception as e:
-            raise Exception("Warning: Exception during cleanup : %s" % e)
+        self._cleanup.insert(0, self.account)
         return
 
     @attr(tags=["advanced", "advancedns", "ssh"])
@@ -3234,22 +3079,7 @@ class TestRestartRvRNetworkWithCleanup(cloudstackTestCase):
                                      admin=True,
                                      domainid=self.domain.id
                                      )
-        self.cleanup = []
-        return
-
-    def tearDown(self):
-        try:
-            self.account.delete(self.apiclient)
-            interval = list_configurations(
-                                    self.apiclient,
-                                    name='account.cleanup.interval'
-                                    )
-            # Sleep to ensure that all resources are deleted
-            time.sleep(int(interval[0].value) * 2)
-            #Clean up, terminate the created network offerings
-            cleanup_resources(self.apiclient, self.cleanup)
-        except Exception as e:
-            raise Exception("Warning: Exception during cleanup : %s" % e)
+        self._cleanup.insert(0, self.account)
         return
 
     @attr(tags=["advanced", "advancedns", "ssh"])
@@ -3455,22 +3285,7 @@ class TestDeleteRvRNetwork(cloudstackTestCase):
                                      admin=True,
                                      domainid=self.domain.id
                                      )
-        self.cleanup = []
-        return
-
-    def tearDown(self):
-        try:
-            self.account.delete(self.apiclient)
-            interval = list_configurations(
-                                    self.apiclient,
-                                    name='account.cleanup.interval'
-                                    )
-            # Sleep to ensure that all resources are deleted
-            time.sleep(int(interval[0].value) * 2)
-            #Clean up, terminate the created network offerings
-            cleanup_resources(self.apiclient, self.cleanup)
-        except Exception as e:
-            raise Exception("Warning: Exception during cleanup : %s" % e)
+        self._cleanup.insert(0, self.account)
         return
 
     @attr(tags=["advanced", "advancedns", "ssh"])
@@ -3671,22 +3486,7 @@ class TestNetworkGCRvR(cloudstackTestCase):
                                      admin=True,
                                      domainid=self.domain.id
                                      )
-        self.cleanup = []
-        return
-
-    def tearDown(self):
-        try:
-            self.account.delete(self.apiclient)
-            interval = list_configurations(
-                                    self.apiclient,
-                                    name='account.cleanup.interval'
-                                    )
-            # Sleep to ensure that all resources are deleted
-            time.sleep(int(interval[0].value) * 2)
-            #Clean up, terminate the created network offerings
-            cleanup_resources(self.apiclient, self.cleanup)
-        except Exception as e:
-            raise Exception("Warning: Exception during cleanup : %s" % e)
+        self._cleanup.insert(0, self.account)
         return
 
     @attr(tags=["advanced", "advancedns", "ssh"])
@@ -3936,22 +3736,7 @@ class TestApplyRulesRestartRvRNetwork(cloudstackTestCase):
                                      admin=True,
                                      domainid=self.domain.id
                                      )
-        self.cleanup = []
-        return
-
-    def tearDown(self):
-        try:
-            self.account.delete(self.apiclient)
-            interval = list_configurations(
-                                    self.apiclient,
-                                    name='account.cleanup.interval'
-                                    )
-            # Sleep to ensure that all resources are deleted
-            time.sleep(int(interval[0].value) * 2)
-            #Clean up, terminate the created network offerings
-            cleanup_resources(self.apiclient, self.cleanup)
-        except Exception as e:
-            raise Exception("Warning: Exception during cleanup : %s" % e)
+        self._cleanup.insert(0, self.account)
         return
 
     @attr(tags=["advanced", "advancedns", "ssh"])
@@ -4373,22 +4158,7 @@ class TestUpgradeDowngradeRVR(cloudstackTestCase):
                                      admin=True,
                                      domainid=self.domain.id
                                      )
-        self.cleanup = []
-        return
-
-    def tearDown(self):
-        try:
-            self.account.delete(self.apiclient)
-            interval = list_configurations(
-                                    self.apiclient,
-                                    name='account.cleanup.interval'
-                                    )
-            # Sleep to ensure that all resources are deleted
-            time.sleep(int(interval[0].value) * 2)
-            #Clean up, terminate the created network offerings
-            cleanup_resources(self.apiclient, self.cleanup)
-        except Exception as e:
-            raise Exception("Warning: Exception during cleanup : %s" % e)
+        self._cleanup.insert(0, self.account)
         return
 
     @attr(tags=["advanced", "advancedns", "ssh"])
@@ -4741,22 +4511,7 @@ class TestRVRWithDiffEnvs(cloudstackTestCase):
                                      admin=True,
                                      domainid=self.domain.id
                                      )
-        self.cleanup = []
-        return
-
-    def tearDown(self):
-        try:
-            self.account.delete(self.apiclient)
-            interval = list_configurations(
-                                    self.apiclient,
-                                    name='account.cleanup.interval'
-                                    )
-            # Sleep to ensure that all resources are deleted
-            time.sleep(int(interval[0].value) * 2)
-            #Clean up, terminate the created network offerings
-            cleanup_resources(self.apiclient, self.cleanup)
-        except Exception as e:
-            raise Exception("Warning: Exception during cleanup : %s" % e)
+        self._cleanup.insert(0, self.account)
         return
 
     @attr(tags=["advanced", "advancedns", "ssh"])


[29/29] git commit: updated refs/heads/master-6-17-stable to 93712c2

Posted by ts...@apache.org.
CLOUDSTACK-3074: include support for vmwaredc mapping to zone

vmware dc can be mapped to the zone after CLOUDSTACK-1963. include
support in marvin for adding the vmwaredc.

vmwaredc : {
    name:
    username:
    vcenter:
    password:
    zoneid:
}

Will be sent during pod creation before cluster creation.

Signed-off-by: Prasanna Santhanam <ts...@apache.org>
(cherry picked from commit 9f4b7dcff896810e2276e02fa034de283964bf49)

Conflicts:
	tools/marvin/marvin/configGenerator.py

Signed-off-by: Prasanna Santhanam <ts...@apache.org>


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

Branch: refs/heads/master-6-17-stable
Commit: 93712c2715c540150b86efdcc8e02c8f7facd0dc
Parents: 3789548
Author: Prasanna Santhanam <ts...@apache.org>
Authored: Sat Jun 29 00:38:52 2013 +0530
Committer: Prasanna Santhanam <ts...@apache.org>
Committed: Sat Jun 29 00:52:09 2013 +0530

----------------------------------------------------------------------
 tools/marvin/marvin/configGenerator.py  | 13 ++++++++++++-
 tools/marvin/marvin/deployDataCenter.py | 16 ++++++++++++++--
 2 files changed, 26 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/93712c27/tools/marvin/marvin/configGenerator.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/configGenerator.py b/tools/marvin/marvin/configGenerator.py
index bd83efb..917e428 100644
--- a/tools/marvin/marvin/configGenerator.py
+++ b/tools/marvin/marvin/configGenerator.py
@@ -94,10 +94,21 @@ class pod():
         self.endip = None
         self.zoneid = None
         self.clusters = []
+        self.vmwaredc = []
         '''Used in basic network mode'''
         self.guestIpRanges = []
 
-class cluster():
+
+class VmwareDc(object):
+    def __init__(self):
+        self.zoneid = None
+        self.name = None
+        self.vcenter = None
+        self.username = None
+        self.password = None
+
+
+class cluster(object):
     def __init__(self):
         self.clustername = None
         self.clustertype = None

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/93712c27/tools/marvin/marvin/deployDataCenter.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/deployDataCenter.py b/tools/marvin/marvin/deployDataCenter.py
index cf5cf78..f00b486 100644
--- a/tools/marvin/marvin/deployDataCenter.py
+++ b/tools/marvin/marvin/deployDataCenter.py
@@ -52,10 +52,22 @@ class deployDataCenters():
             hostcmd.hypervisor = hypervisor
             self.apiClient.addHost(hostcmd)
 
-    def createClusters(self, clusters, zoneId, podId):
+    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)
+
+    def createClusters(self, clusters, zoneId, podId, vmwareDc=None):
         if clusters is None:
             return
 
+        if vmwareDc:
+            self.addVmWareDataCenter(vmwareDc)
+
         for cluster in clusters:
             clustercmd = addCluster.addClusterCmd()
             clustercmd.clustername = cluster.clustername
@@ -106,7 +118,7 @@ class deployDataCenters():
                 self.createVlanIpRanges("Basic", pod.guestIpRanges, zoneId,\
                                         podId, networkId)
 
-            self.createClusters(pod.clusters, zoneId, podId)
+            self.createClusters(pod.clusters, zoneId, podId, vmwareDc=pod.vmwaredc)
 
     def createVlanIpRanges(self, mode, ipranges, zoneId, podId=None,\
                            networkId=None, forvirtualnetwork=None):


[15/29] git commit: updated refs/heads/master-6-17-stable to 93712c2

Posted by ts...@apache.org.
CLOUDSTACK-3021: Correct the order of resources

Resources are ordered so that the cleanup succeeds.
domains are deleted after accounts under the domain are removed.

Signed-off-by: Prasanna Santhanam <ts...@apache.org>
(cherry picked from commit b6850c28dc664e88c0128ddbae7c3ee468290350)


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

Branch: refs/heads/master-6-17-stable
Commit: 9eeacd11215d6b3661941f7a54a334b510d37a7c
Parents: 8c28f00
Author: Rayees Namathponnan <ra...@citrix.com>
Authored: Tue Jun 18 02:43:52 2013 -0400
Committer: Prasanna Santhanam <ts...@apache.org>
Committed: Sat Jun 29 00:52:07 2013 +0530

----------------------------------------------------------------------
 test/integration/component/test_accounts.py | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9eeacd11/test/integration/component/test_accounts.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_accounts.py b/test/integration/component/test_accounts.py
index ec135b1..39ff3ea 100644
--- a/test/integration/component/test_accounts.py
+++ b/test/integration/component/test_accounts.py
@@ -753,13 +753,14 @@ class TestServiceOfferingHierarchy(cloudstackTestCase):
                             domainid=cls.domain_2.id
                             )
 
-        cls._cleanup = [
-                        cls.account_1,
-                        cls.account_2,
-                        cls.service_offering,
-                        cls.domain_1,
-                        cls.domain_2,
-                        ]
+   cls._cleanup = [
+                   cls.account_2,
+                   cls.domain_2,
+                   cls.service_offering,
+                   cls.account_1,
+                   cls.domain_1,
+                       ]
+
         return
 
     @classmethod


[07/29] Split Redundant Router tests

Posted by ts...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b9524157/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
new file mode 100644
index 0000000..98d7647
--- /dev/null
+++ b/test/integration/component/test_redundant_router_cleanups.py
@@ -0,0 +1,675 @@
+# 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.
+
+from nose.plugins.attrib import attr
+from marvin.integration.lib.base import *
+from marvin.integration.lib.utils import *
+from marvin.integration.lib.common import *
+
+#Import Local Modules
+from marvin.cloudstackTestCase import cloudstackTestCase
+from marvin.cloudstackAPI import *
+
+class Services:
+    """Test Services for customer defects
+    """
+
+    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,
+                                    "memory": 128,
+                        },
+                        "disk_offering": {
+                                    "displaytext": "Small",
+                                    "name": "Small",
+                                    "disksize": 1
+                        },
+                        "virtual_machine": {
+                                    "displayname": "Test VM",
+                                    "username": "root",
+                                    "password": "password",
+                                    "ssh_port": 22,
+                                    "hypervisor": 'XenServer',
+                                    "privateport": 22,
+                                    "publicport": 22,
+                                    "protocol": 'TCP',
+                        },
+                        "static_nat": {
+                                    "startport": 22,
+                                    "endport": 22,
+                                    "protocol": "TCP"
+                        },
+                        "network_offering": {
+                                    "name": 'Network offering-RVR services',
+                                    "displaytext": 'Network off-RVR services',
+                                    "guestiptype": 'Isolated',
+                                    "supportedservices": 'Vpn,Dhcp,Dns,SourceNat,PortForwarding,Firewall,Lb,UserData,StaticNat',
+                                    "traffictype": 'GUEST',
+                                    "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"
+                                        },
+                                    },
+                        },
+                        "host": {
+                                 "username": "root",
+                                 "password": "password",
+                                 "publicport": 22,
+                        },
+                        "network": {
+                                  "name": "Test Network",
+                                  "displaytext": "Test Network",
+                                },
+                        "lbrule": {
+                                    "name": "SSH",
+                                    "alg": "roundrobin",
+                                    # Algorithm used for load balancing
+                                    "privateport": 22,
+                                    "publicport": 22,
+                                    "openfirewall": True,
+                                },
+                        "natrule": {
+                                    "privateport": 22,
+                                    "publicport": 22,
+                                    "protocol": "TCP"
+                                },
+                        "natrule_221": {
+                                    "privateport": 22,
+                                    "publicport": 221,
+                                    "protocol": "TCP"
+                                },
+                        "fw_rule": {
+                                    "startport": 1,
+                                    "endport": 6000,
+                                    "cidr": '55.55.0.0/11',
+                                    # Any network (For creating FW rule)
+                                    "protocol": 'TCP',
+                                },
+                        "ostype": 'CentOS 5.3 (64-bit)',
+                        "sleep": 60,
+            }
+
+
+class TestRedundantRouterNetworkCleanups(cloudstackTestCase):
+
+    @classmethod
+    def setUpClass(cls):
+        cls.api_client = super(
+                               TestRedundantRouterNetworkCleanups,
+                               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.template = get_template(
+                            cls.api_client,
+                            cls.zone.id,
+                            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.network_offering = NetworkOffering.create(
+                                            cls.api_client,
+                                            cls.services["network_offering"],
+                                            conservemode=True
+                                            )
+        # Enable Network offering
+        cls.network_offering.update(cls.api_client, state='Enabled')
+
+        cls._cleanup = [
+                        cls.service_offering,
+                        cls.network_offering,
+                        ]
+        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.account = Account.create(
+                                     self.apiclient,
+                                     self.services["account"],
+                                     admin=True,
+                                     domainid=self.domain.id
+                                     )
+        self._cleanup.insert(0, self.account)
+        return
+
+    @attr(tags=["advanced", "advancedns", "ssh"])
+    def test_restart_ntwk_no_cleanup(self):
+        """Test restarting RvR network without cleanup
+        """
+
+        # Steps to validate
+        # 1. createNetwork using network offering for redundant virtual router
+        # 2. listRouters in above network
+        # 3. deployVM in above user account in the created network
+        # 4. restartNetwork cleanup=false
+        # 5. listRouters in the account
+        # 6. delete the account
+
+        # Creating network using the network offering created
+        self.debug("Creating network with network offering: %s" %
+                                                    self.network_offering.id)
+        network = Network.create(
+                                self.apiclient,
+                                self.services["network"],
+                                accountid=self.account.name,
+                                domainid=self.account.domainid,
+                                networkofferingid=self.network_offering.id,
+                                zoneid=self.zone.id
+                                )
+        self.debug("Created network with ID: %s" % network.id)
+
+        networks = Network.list(
+                                self.apiclient,
+                                id=network.id,
+                                listall=True
+                                )
+        self.assertEqual(
+            isinstance(networks, list),
+            True,
+            "List networks should return a valid response for created network"
+             )
+        nw_response = networks[0]
+
+        self.debug("Network state: %s" % nw_response.state)
+        self.assertEqual(
+                    nw_response.state,
+                    "Allocated",
+                    "The network should be in allocated state after creation"
+                    )
+
+        self.debug("Listing routers for network: %s" % network.name)
+        routers = Router.list(
+                              self.apiclient,
+                              networkid=network.id,
+                              listall=True
+                              )
+        self.assertEqual(
+            routers,
+            None,
+            "Routers should not be spawned when network is in allocated state"
+            )
+
+        self.debug("Deploying VM in account: %s" % self.account.name)
+
+        # Spawn an instance in that network
+        virtual_machine = VirtualMachine.create(
+                                  self.apiclient,
+                                  self.services["virtual_machine"],
+                                  accountid=self.account.name,
+                                  domainid=self.account.domainid,
+                                  serviceofferingid=self.service_offering.id,
+                                  networkids=[str(network.id)]
+                                  )
+        self.debug("Deployed VM in network: %s" % network.id)
+
+        vms = VirtualMachine.list(
+                                  self.apiclient,
+                                  id=virtual_machine.id,
+                                  listall=True
+                                  )
+        self.assertEqual(
+                         isinstance(vms, list),
+                         True,
+                         "List Vms should return a valid list"
+                         )
+        vm = vms[0]
+        self.assertEqual(
+                         vm.state,
+                         "Running",
+                         "Vm should be in running state after deployment"
+                         )
+
+        self.debug("Listing routers for network: %s" % network.name)
+        routers = Router.list(
+                              self.apiclient,
+                              networkid=network.id,
+                              listall=True
+                              )
+        self.assertEqual(
+                    isinstance(routers, list),
+                    True,
+                    "list router should return Master and backup routers"
+                    )
+        self.assertEqual(
+                    len(routers),
+                    2,
+                    "Length of the list router should be 2 (Backup & master)"
+                    )
+
+        if routers[0].redundantstate == 'MASTER':
+            master_router = routers[0]
+            backup_router = routers[1]
+        else:
+            master_router = routers[1]
+            backup_router = routers[0]
+
+        self.debug("restarting network with cleanup=False")
+        try:
+            network.restart(self.apiclient, cleanup=False)
+        except Exception as e:
+                self.fail("Failed to cleanup network - %s" % e)
+
+        self.debug("Listing routers for network: %s" % network.name)
+        routers = Router.list(
+                              self.apiclient,
+                              networkid=network.id,
+                              listall=True
+                              )
+        self.assertEqual(
+                    isinstance(routers, list),
+                    True,
+                    "list router should return Master and backup routers"
+                    )
+        self.assertEqual(
+                    len(routers),
+                    2,
+                    "Length of the list router should be 2 (Backup & master)"
+                    )
+        for router in routers:
+            self.assertEqual(
+                             router.state,
+                             "Running",
+                             "Router state should be running"
+                             )
+            self.assertIn(
+                    router.linklocalip,
+                    [master_router.linklocalip, backup_router.linklocalip],
+                    "Routers should have same linklocal IP after nw restart"
+                  )
+        return
+
+    @attr(tags=["advanced", "advancedns", "ssh"])
+    def test_restart_ntwk_with_cleanup(self):
+        """Test restart RvR network with cleanup
+        """
+
+        # Steps to validate
+        # 1. createNetwork using network offering for redundant virtual router
+        # 2. listRouters in above network
+        # 3. deployVM in above user account in the created network
+        # 4. restartNetwork cleanup=false
+        # 5. listRouters in the account
+        # 6. delete the account
+
+        # Creating network using the network offering created
+        self.debug("Creating network with network offering: %s" %
+                                                    self.network_offering.id)
+        network = Network.create(
+                                self.apiclient,
+                                self.services["network"],
+                                accountid=self.account.name,
+                                domainid=self.account.domainid,
+                                networkofferingid=self.network_offering.id,
+                                zoneid=self.zone.id
+                                )
+        self.debug("Created network with ID: %s" % network.id)
+
+        networks = Network.list(
+                                self.apiclient,
+                                id=network.id,
+                                listall=True
+                                )
+        self.assertEqual(
+            isinstance(networks, list),
+            True,
+            "List networks should return a valid response for created network"
+             )
+        nw_response = networks[0]
+
+        self.debug("Network state: %s" % nw_response.state)
+        self.assertEqual(
+                    nw_response.state,
+                    "Allocated",
+                    "The network should be in allocated state after creation"
+                    )
+
+        self.debug("Listing routers for network: %s" % network.name)
+        routers = Router.list(
+                              self.apiclient,
+                              networkid=network.id,
+                              listall=True
+                              )
+        self.assertEqual(
+            routers,
+            None,
+            "Routers should not be spawned when network is in allocated state"
+            )
+
+        self.debug("Deploying VM in account: %s" % self.account.name)
+
+        # Spawn an instance in that network
+        virtual_machine = VirtualMachine.create(
+                                  self.apiclient,
+                                  self.services["virtual_machine"],
+                                  accountid=self.account.name,
+                                  domainid=self.account.domainid,
+                                  serviceofferingid=self.service_offering.id,
+                                  networkids=[str(network.id)]
+                                  )
+        self.debug("Deployed VM in network: %s" % network.id)
+
+        vms = VirtualMachine.list(
+                                  self.apiclient,
+                                  id=virtual_machine.id,
+                                  listall=True
+                                  )
+        self.assertEqual(
+                         isinstance(vms, list),
+                         True,
+                         "List Vms should return a valid list"
+                         )
+        vm = vms[0]
+        self.assertEqual(
+                         vm.state,
+                         "Running",
+                         "Vm should be in running state after deployment"
+                         )
+
+        self.debug("Listing routers for network: %s" % network.name)
+        routers = Router.list(
+                              self.apiclient,
+                              networkid=network.id,
+                              listall=True
+                              )
+        self.assertEqual(
+                    isinstance(routers, list),
+                    True,
+                    "list router should return Master and backup routers"
+                    )
+        self.assertEqual(
+                    len(routers),
+                    2,
+                    "Length of the list router should be 2 (Backup & master)"
+                    )
+
+        if routers[0].redundantstate == 'MASTER':
+            master_router = routers[0]
+            backup_router = routers[1]
+        else:
+            master_router = routers[1]
+            backup_router = routers[0]
+
+        self.debug("restarting network with cleanup=True")
+        try:
+            network.restart(self.apiclient, cleanup=True)
+        except Exception as e:
+                self.fail("Failed to cleanup network - %s" % e)
+
+        self.debug("Listing routers for network: %s" % network.name)
+        routers = Router.list(
+                              self.apiclient,
+                              networkid=network.id,
+                              listall=True
+                              )
+        self.assertEqual(
+                    isinstance(routers, list),
+                    True,
+                    "list router should return Master and backup routers"
+                    )
+        self.assertEqual(
+                    len(routers),
+                    2,
+                    "Length of the list router should be 2 (Backup & master)"
+                    )
+        for router in routers:
+            self.assertEqual(
+                             router.state,
+                             "Running",
+                             "Router state should be running"
+                             )
+            self.assertIn(
+                    router.linklocalip,
+                    [master_router.linklocalip, backup_router.linklocalip],
+                    "Routers should have same linklocal IP after nw restart"
+                  )
+        return
+
+    @attr(tags=["advanced", "advancedns", "ssh"])
+    def test_network_gc(self):
+        """Test network garbage collection with RVR
+        """
+
+        # Steps to validate
+        # 1. createNetwork using network offering for redundant virtual router
+        # 2. listRouters in above network
+        # 3. deployVM in above user account in the created network
+        # 4. stop the running user VM
+        # 5. wait for network.gc time
+        # 6. listRouters
+        # 7. start the routers MASTER and BACK
+        # 8. wait for network.gc time and listRouters
+        # 9. delete the account
+
+        # Creating network using the network offering created
+        self.debug("Creating network with network offering: %s" %
+                                                    self.network_offering.id)
+        network = Network.create(
+                                self.apiclient,
+                                self.services["network"],
+                                accountid=self.account.name,
+                                domainid=self.account.domainid,
+                                networkofferingid=self.network_offering.id,
+                                zoneid=self.zone.id
+                                )
+        self.debug("Created network with ID: %s" % network.id)
+
+        networks = Network.list(
+                                self.apiclient,
+                                id=network.id,
+                                listall=True
+                                )
+        self.assertEqual(
+            isinstance(networks, list),
+            True,
+            "List networks should return a valid response for created network"
+             )
+        nw_response = networks[0]
+
+        self.debug("Network state: %s" % nw_response.state)
+        self.assertEqual(
+                    nw_response.state,
+                    "Allocated",
+                    "The network should be in allocated state after creation"
+                    )
+
+        self.debug("Listing routers for network: %s" % network.name)
+        routers = Router.list(
+                              self.apiclient,
+                              networkid=network.id,
+                              listall=True
+                              )
+        self.assertEqual(
+            routers,
+            None,
+            "Routers should not be spawned when network is in allocated state"
+            )
+
+        self.debug("Deploying VM in account: %s" % self.account.name)
+
+        # Spawn an instance in that network
+        virtual_machine = VirtualMachine.create(
+                                  self.apiclient,
+                                  self.services["virtual_machine"],
+                                  accountid=self.account.name,
+                                  domainid=self.account.domainid,
+                                  serviceofferingid=self.service_offering.id,
+                                  networkids=[str(network.id)]
+                                  )
+        self.debug("Deployed VM in network: %s" % network.id)
+
+        vms = VirtualMachine.list(
+                                  self.apiclient,
+                                  id=virtual_machine.id,
+                                  listall=True
+                                  )
+        self.assertEqual(
+                         isinstance(vms, list),
+                         True,
+                         "List Vms should return a valid list"
+                         )
+        vm = vms[0]
+        self.assertEqual(
+                         vm.state,
+                         "Running",
+                         "Vm should be in running state after deployment"
+                         )
+
+        self.debug("Listing routers for network: %s" % network.name)
+        routers = Router.list(
+                              self.apiclient,
+                              networkid=network.id,
+                              listall=True
+                              )
+        self.assertEqual(
+                    isinstance(routers, list),
+                    True,
+                    "list router should return Master and backup routers"
+                    )
+        self.assertEqual(
+                    len(routers),
+                    2,
+                    "Length of the list router should be 2 (Backup & master)"
+                    )
+
+        self.debug("Stopping the user VM: %s" % virtual_machine.name)
+
+        try:
+            virtual_machine.stop(self.apiclient)
+        except Exception as e:
+            self.fail("Failed to stop guest Vm: %s - %s" %
+                                            (virtual_machine.name, e))
+
+        interval = list_configurations(
+                                    self.apiclient,
+                                    name='network.gc.interval'
+                                    )
+        delay = int(interval[0].value)
+        interval = list_configurations(
+                                    self.apiclient,
+                                    name='network.gc.wait'
+                                    )
+        exp = int(interval[0].value)
+
+        self.debug("Sleeping for network gc wait + interval time")
+        # Sleep to ensure that all resources are deleted
+        time.sleep((delay + exp) * 2)
+
+        routers = Router.list(
+                              self.apiclient,
+                              networkid=network.id,
+                              listall=True
+                              )
+        self.assertEqual(
+                    isinstance(routers, list),
+                    True,
+                    "list router should return Master and backup routers"
+                    )
+        for router in routers:
+            self.assertEqual(
+                             router.state,
+                             "Stopped",
+                             "Router should be in stopped state"
+                             )
+            self.debug("Starting the stopped router again")
+            cmd = startRouter.startRouterCmd()
+            cmd.id = router.id
+            self.apiclient.startRouter(cmd)
+
+        routers = Router.list(
+                              self.apiclient,
+                              networkid=network.id,
+                              listall=True
+                              )
+        self.assertEqual(
+                    isinstance(routers, list),
+                    True,
+                    "list router should return Master and backup routers"
+                    )
+        for router in routers:
+            self.assertEqual(
+                             router.state,
+                             "Running",
+                             "Router should be in running state"
+                             )
+
+        self.debug("Sleeping for network gc wait + interval time")
+        # Sleep to ensure that all resources are deleted
+        time.sleep((delay + exp) * 2)
+
+        routers = Router.list(
+                              self.apiclient,
+                              networkid=network.id,
+                              listall=True
+                              )
+        self.assertEqual(
+                    isinstance(routers, list),
+                    True,
+                    "list router should return Master and backup routers"
+                    )
+        for router in routers:
+            self.assertEqual(
+                             router.state,
+                             "Stopped",
+                             "Router should be in stopped state"
+                             )
+        return
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b9524157/test/integration/component/test_redundant_router_deployment_planning.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_redundant_router_deployment_planning.py b/test/integration/component/test_redundant_router_deployment_planning.py
new file mode 100644
index 0000000..e40beac
--- /dev/null
+++ b/test/integration/component/test_redundant_router_deployment_planning.py
@@ -0,0 +1,1006 @@
+# 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.
+
+from nose.plugins.attrib import attr
+from marvin.integration.lib.base import *
+from marvin.integration.lib.utils import *
+from marvin.integration.lib.common import *
+
+#Import Local Modules
+from marvin.cloudstackTestCase import cloudstackTestCase
+from marvin.cloudstackAPI import *
+
+class Services:
+    """Test Services for customer defects
+    """
+
+    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,
+                                    "memory": 128,
+                        },
+                        "disk_offering": {
+                                    "displaytext": "Small",
+                                    "name": "Small",
+                                    "disksize": 1
+                        },
+                        "virtual_machine": {
+                                    "displayname": "Test VM",
+                                    "username": "root",
+                                    "password": "password",
+                                    "ssh_port": 22,
+                                    "hypervisor": 'XenServer',
+                                    "privateport": 22,
+                                    "publicport": 22,
+                                    "protocol": 'TCP',
+                        },
+                        "static_nat": {
+                                    "startport": 22,
+                                    "endport": 22,
+                                    "protocol": "TCP"
+                        },
+                        "network_offering": {
+                                    "name": 'Network offering-RVR services',
+                                    "displaytext": 'Network off-RVR services',
+                                    "guestiptype": 'Isolated',
+                                    "supportedservices": 'Vpn,Dhcp,Dns,SourceNat,PortForwarding,Firewall,Lb,UserData,StaticNat',
+                                    "traffictype": 'GUEST',
+                                    "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"
+                                        },
+                                    },
+                        },
+                        "host": {
+                                 "username": "root",
+                                 "password": "password",
+                                 "publicport": 22,
+                        },
+                        "network": {
+                                  "name": "Test Network",
+                                  "displaytext": "Test Network",
+                                },
+                        "lbrule": {
+                                    "name": "SSH",
+                                    "alg": "roundrobin",
+                                    # Algorithm used for load balancing
+                                    "privateport": 22,
+                                    "publicport": 22,
+                                    "openfirewall": True,
+                                },
+                        "natrule": {
+                                    "privateport": 22,
+                                    "publicport": 22,
+                                    "protocol": "TCP"
+                                },
+                        "natrule_221": {
+                                    "privateport": 22,
+                                    "publicport": 221,
+                                    "protocol": "TCP"
+                                },
+                        "fw_rule": {
+                                    "startport": 1,
+                                    "endport": 6000,
+                                    "cidr": '55.55.0.0/11',
+                                    # Any network (For creating FW rule)
+                                    "protocol": 'TCP',
+                                },
+                        "ostype": 'CentOS 5.3 (64-bit)',
+                        "sleep": 60,
+            }
+
+class TestRvRDeploymentPlanning(cloudstackTestCase):
+
+    @classmethod
+    def setUpClass(cls):
+        cls.api_client = super(
+                               TestRvRDeploymentPlanning,
+                               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.template = get_template(
+                            cls.api_client,
+                            cls.zone.id,
+                            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.network_offering = NetworkOffering.create(
+                                            cls.api_client,
+                                            cls.services["network_offering"],
+                                            conservemode=True
+                                            )
+        # Enable Network offering
+        cls.network_offering.update(cls.api_client, state='Enabled')
+
+        cls._cleanup = [
+                        cls.service_offering,
+                        cls.network_offering,
+                        ]
+        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.account = Account.create(
+                                     self.apiclient,
+                                     self.services["account"],
+                                     admin=True,
+                                     domainid=self.domain.id
+                                     )
+        self._cleanup.insert(0, self.account)
+        return
+
+    @attr(tags=["advanced", "advancedns", "ssh"])
+    def test_RvR_multipods(self):
+        """Test RvR with muti pods
+        """
+
+        # Steps to validate
+        # 0. listPods should have at least 2 pods
+        # 1. create a network offering for redundant router
+        # 2. create a network out of this offering
+        # 3. deploy a VM in this network
+        # 4. listRouters
+        # 5. delete the account
+        # Validate the following
+        # 1. listNetworkOfferings should show created offering for RvR
+        # 2. listNetworks should show the created network in allocated state
+        # 3. VM should be deployed and in Running state
+        # 4. There should be two routers (MASTER and BACKUP) for this network
+        #    ensure both routers should be on different pods
+
+        self.debug("Checking if the current zone has 2 active pods in it..")
+        pods = Pod.list(
+                        self.apiclient,
+                        zoneid=self.zone.id,
+                        listall=True,
+                        allocationstate="Enabled"
+                        )
+        self.assertEqual(
+                         isinstance(pods, list),
+                         True,
+                         "List pods should not return an empty response"
+                         )
+
+        if len(pods) < 2:
+            raise unittest.SkipTest("The env don't have 2 pods req for test")
+
+        # Creating network using the network offering created
+        self.debug("Creating network with network offering: %s" %
+                                                    self.network_offering.id)
+        network = Network.create(
+                                self.apiclient,
+                                self.services["network"],
+                                accountid=self.account.name,
+                                domainid=self.account.domainid,
+                                networkofferingid=self.network_offering.id,
+                                zoneid=self.zone.id
+                                )
+        self.debug("Created network with ID: %s" % network.id)
+
+        networks = Network.list(
+                                self.apiclient,
+                                id=network.id,
+                                listall=True
+                                )
+        self.assertEqual(
+            isinstance(networks, list),
+            True,
+            "List networks should return a valid response for created network"
+             )
+        nw_response = networks[0]
+
+        self.debug("Network state: %s" % nw_response.state)
+        self.assertEqual(
+                    nw_response.state,
+                    "Allocated",
+                    "The network should be in allocated state after creation"
+                    )
+
+        self.debug("Listing routers for network: %s" % network.name)
+        routers = Router.list(
+                              self.apiclient,
+                              networkid=network.id,
+                              listall=True
+                              )
+        self.assertEqual(
+            routers,
+            None,
+            "Routers should not be spawned when network is in allocated state"
+            )
+
+        self.debug("Deploying VM in account: %s" % self.account.name)
+
+        # Spawn an instance in that network
+        virtual_machine = VirtualMachine.create(
+                                  self.apiclient,
+                                  self.services["virtual_machine"],
+                                  accountid=self.account.name,
+                                  domainid=self.account.domainid,
+                                  serviceofferingid=self.service_offering.id,
+                                  networkids=[str(network.id)]
+                                  )
+        self.debug("Deployed VM in network: %s" % network.id)
+
+        vms = VirtualMachine.list(
+                                  self.apiclient,
+                                  id=virtual_machine.id,
+                                  listall=True
+                                  )
+        self.assertEqual(
+                         isinstance(vms, list),
+                         True,
+                         "List Vms should return a valid list"
+                         )
+        vm = vms[0]
+        self.assertEqual(
+                         vm.state,
+                         "Running",
+                         "Vm should be in running state after deployment"
+                         )
+
+        self.debug("Listing routers for network: %s" % network.name)
+        routers = Router.list(
+                              self.apiclient,
+                              networkid=network.id,
+                              listall=True
+                              )
+        self.assertEqual(
+                    isinstance(routers, list),
+                    True,
+                    "list router should return Master and backup routers"
+                    )
+        self.assertEqual(
+                    len(routers),
+                    2,
+                    "Length of the list router should be 2 (Backup & master)"
+                    )
+        self.assertNotEqual(
+                            routers[0].podid,
+                            routers[1].podid,
+                            "Both the routers should be in different pods"
+                            )
+        return
+
+    @attr(tags=["advanced", "advancedns", "ssh"])
+    def test_RvR_multicluster(self):
+        """Test RvR with muti clusters
+        """
+
+        # Steps to validate
+        # 0. listClusters should have at least two clusters (if there are
+        #    multiple pods, disable all except one with two clusters)
+        # 1. create a network offering for redundant router
+        # 2. create a network out of this offering
+        # 3. deploy a VM in this network on a host in either of clusters
+        #    found in 0. (specify hostid for deployment)
+        # 4. listRouters
+        # 5. delete the account
+        # 6. enable all disabled pods
+        # Validate the following
+        # 1. listNetworkOfferings should show created offering for RvR
+        # 2. listNetworks should show the created network in allocated state
+        # 3. VM should be deployed and in Running state
+        # 4. There should be two routers (MASTER and BACKUP) for this network
+        #    ensure both routers should be on different pods
+
+        self.debug("Checking if the current zone has 2 active pods in it..")
+        pods = Pod.list(
+                        self.apiclient,
+                        zoneid=self.zone.id,
+                        listall=True,
+                        allocationstate="Enabled"
+                        )
+        self.assertEqual(
+                         isinstance(pods, list),
+                         True,
+                         "List pods should not return an empty response"
+                         )
+        enabled_pod = pods[0]
+
+        self.debug("Cheking if pod has atleast 2 clusters")
+        clusters = Cluster.list(
+                                self.apiclient,
+                                podid=enabled_pod.id,
+                                listall=True
+                                )
+        self.assertEqual(
+                         isinstance(clusters, list),
+                         True,
+                         "List clusters should not return empty response"
+                         )
+        if len(clusters) < 2:
+            raise unittest.SkipTest(
+                            "The env don't have 2 clusters req for test")
+
+        self.debug("disable all pods except one!")
+        if len(pods) > 1:
+            for pod in pods:
+                cmd = updatePod.updatePodCmd()
+                cmd.id = pod.id
+                cmd.allocationstate = 'Disabled'
+                self.apiclient.updatePod(cmd)
+
+            self.debug("Warning: Disabled all pods in zone")
+
+            cmd = updatePod.updatePodCmd()
+            cmd.id = pods[0].id
+            cmd.allocationstate = 'Enabled'
+            self.apiclient.updatePod(cmd)
+            self.debug("Enabled first pod for testing..")
+
+        # Creating network using the network offering created
+        self.debug("Creating network with network offering: %s" %
+                                                    self.network_offering.id)
+        network = Network.create(
+                                self.apiclient,
+                                self.services["network"],
+                                accountid=self.account.name,
+                                domainid=self.account.domainid,
+                                networkofferingid=self.network_offering.id,
+                                zoneid=self.zone.id
+                                )
+        self.debug("Created network with ID: %s" % network.id)
+
+        networks = Network.list(
+                                self.apiclient,
+                                id=network.id,
+                                listall=True
+                                )
+        self.assertEqual(
+            isinstance(networks, list),
+            True,
+            "List networks should return a valid response for created network"
+             )
+        nw_response = networks[0]
+
+        self.debug("Network state: %s" % nw_response.state)
+        self.assertEqual(
+                    nw_response.state,
+                    "Allocated",
+                    "The network should be in allocated state after creation"
+                    )
+
+        self.debug("Listing routers for network: %s" % network.name)
+        routers = Router.list(
+                              self.apiclient,
+                              networkid=network.id,
+                              listall=True
+                              )
+        self.assertEqual(
+            routers,
+            None,
+            "Routers should not be spawned when network is in allocated state"
+            )
+
+        self.debug("Deploying VM in account: %s" % self.account.name)
+
+        # Spawn an instance in that network
+        virtual_machine = VirtualMachine.create(
+                                  self.apiclient,
+                                  self.services["virtual_machine"],
+                                  accountid=self.account.name,
+                                  domainid=self.account.domainid,
+                                  serviceofferingid=self.service_offering.id,
+                                  networkids=[str(network.id)]
+                                  )
+        self.debug("Deployed VM in network: %s" % network.id)
+
+        vms = VirtualMachine.list(
+                                  self.apiclient,
+                                  id=virtual_machine.id,
+                                  listall=True
+                                  )
+        self.assertEqual(
+                         isinstance(vms, list),
+                         True,
+                         "List Vms should return a valid list"
+                         )
+        vm = vms[0]
+        self.assertEqual(
+                         vm.state,
+                         "Running",
+                         "Vm should be in running state after deployment"
+                         )
+
+        self.debug("Listing routers for network: %s" % network.name)
+        routers = Router.list(
+                              self.apiclient,
+                              networkid=network.id,
+                              listall=True
+                              )
+        self.assertEqual(
+                    isinstance(routers, list),
+                    True,
+                    "list router should return Master and backup routers"
+                    )
+        self.assertEqual(
+                    len(routers),
+                    2,
+                    "Length of the list router should be 2 (Backup & master)"
+                    )
+
+        hosts = Host.list(
+                          self.apiclient,
+                          id=routers[0].hostid,
+                          listall=True
+                          )
+        self.assertEqual(
+                         isinstance(hosts, list),
+                         True,
+                         "List host should return a valid data"
+                         )
+        first_host = hosts[0]
+
+        hosts = Host.list(
+                          self.apiclient,
+                          id=routers[1].hostid,
+                          listall=True
+                          )
+        self.assertEqual(
+                         isinstance(hosts, list),
+                         True,
+                         "List host should return a valid data"
+                         )
+        second_host = hosts[0]
+
+        # Checking if the cluster IDs of both routers are different?
+        self.assertNotEqual(
+                            first_host.clusterid,
+                            second_host.clusterid,
+                            "Both the routers should be in different clusters"
+                            )
+        self.debug("Enabling remaining pods if any..")
+        pods = Pod.list(
+                        self.apiclient,
+                        zoneid=self.zone.id,
+                        listall=True,
+                        allocationstate="Disabled"
+                        )
+
+        for pod in pods:
+            cmd = updatePod.updatePodCmd()
+            cmd.id = pod.id
+            cmd.allocationstate = 'Enabled'
+            self.apiclient.updatePod(cmd)
+        return
+
+    @attr(tags=["advanced", "advancedns", "ssh"])
+    def test_RvR_multiprimarystorage(self):
+        """Test RvR with muti primary storage
+        """
+
+        # Steps to validate
+        # 0. listStoragePools should have atleast two pools in a single
+        #    cluster (disable pods/clusters as necessary)
+        # 1. create a network offering for redundant router
+        # 2. create a network out of this offering
+        # 3. deploy a VM in this network on a host in the cluster from 0
+        #    (specify hostid for deployment)
+        # 4. listRouters
+        # 5. delete the account
+        # 6. enable the clusters and pods
+        # Validate the following
+        # 1. listNetworkOfferings should show created offering for RvR
+        # 2. listNetworks should show the created network in allocated state
+        # 3. VM should be deployed and in Running state and on the specified
+        #    host
+        # 4. There should be two routers (MASTER and BACKUP) for this network
+        #    ensure both routers should be on different storage pools
+
+        self.debug(
+            "Checking if the current zone has multiple active pods in it..")
+        pods = Pod.list(
+                        self.apiclient,
+                        zoneid=self.zone.id,
+                        listall=True,
+                        allocationstate="Enabled"
+                        )
+        self.assertEqual(
+                         isinstance(pods, list),
+                         True,
+                         "List pods should not return an empty response"
+                         )
+
+        enabled_pod = pods[0]
+        self.debug("Cheking if pod has multiple clusters")
+        clusters = Cluster.list(
+                                self.apiclient,
+                                podid=enabled_pod.id,
+                                listall=True
+                                )
+        self.assertEqual(
+                         isinstance(clusters, list),
+                         True,
+                         "List clusters should not return empty response"
+                         )
+
+        enabled_cluster = clusters[0]
+
+        self.debug("Cheking if cluster has multiple storage pools")
+        storage_pools = StoragePool.list(
+                                self.apiclient,
+                                clusterid=enabled_cluster.id,
+                                listall=True
+                                )
+        self.assertEqual(
+                         isinstance(storage_pools, list),
+                         True,
+                         "List storage pools should not return empty response"
+                         )
+
+        if len(storage_pools) < 2:
+            raise unittest.SkipTest(
+                            "The env don't have 2 storage pools req for test")
+
+        self.debug("disable all pods except one!")
+        if len(pods) > 1:
+            for pod in pods:
+                cmd = updatePod.updatePodCmd()
+                cmd.id = pod.id
+                cmd.allocationstate = 'Disabled'
+                self.apiclient.updatePod(cmd)
+
+            self.debug("Warning: Disabled all pods in zone")
+
+            cmd = updatePod.updatePodCmd()
+            cmd.id = pods[0].id
+            cmd.allocationstate = 'Enabled'
+            self.apiclient.updatePod(cmd)
+            self.debug("Enabled first pod for testing..")
+
+        self.debug("disable all clusters except one!")
+        if len(pods) > 1:
+            for cluster in clusters:
+                cmd = updateCluster.updateClusterCmd()
+                cmd.id = cluster.id
+                cmd.allocationstate = 'Disabled'
+                self.apiclient.updateCluster(cmd)
+
+            self.debug("Warning: Disabled all pods in zone")
+
+            cmd = updateCluster.updateClusterCmd()
+            cmd.id = clusters[0].id
+            cmd.allocationstate = 'Enabled'
+            self.apiclient.updateCluster(cmd)
+            self.debug("Enabled first cluster for testing..")
+
+        # Creating network using the network offering created
+        self.debug("Creating network with network offering: %s" %
+                                                    self.network_offering.id)
+        network = Network.create(
+                                self.apiclient,
+                                self.services["network"],
+                                accountid=self.account.name,
+                                domainid=self.account.domainid,
+                                networkofferingid=self.network_offering.id,
+                                zoneid=self.zone.id
+                                )
+        self.debug("Created network with ID: %s" % network.id)
+
+        networks = Network.list(
+                                self.apiclient,
+                                id=network.id,
+                                listall=True
+                                )
+        self.assertEqual(
+            isinstance(networks, list),
+            True,
+            "List networks should return a valid response for created network"
+             )
+        nw_response = networks[0]
+
+        self.debug("Network state: %s" % nw_response.state)
+        self.assertEqual(
+                    nw_response.state,
+                    "Allocated",
+                    "The network should be in allocated state after creation"
+                    )
+
+        self.debug("Listing routers for network: %s" % network.name)
+        routers = Router.list(
+                              self.apiclient,
+                              networkid=network.id,
+                              listall=True
+                              )
+        self.assertEqual(
+            routers,
+            None,
+            "Routers should not be spawned when network is in allocated state"
+            )
+
+        self.debug("Retrieving the list of hosts in the cluster")
+        hosts = Host.list(
+                          self.apiclient,
+                          clusterid=enabled_cluster.id,
+                          listall=True
+                          )
+        self.assertEqual(
+                         isinstance(hosts, list),
+                         True,
+                         "List hosts should not return an empty response"
+                         )
+        host = hosts[0]
+
+        self.debug("Deploying VM in account: %s" % self.account.name)
+
+        # Spawn an instance in that network
+        virtual_machine = VirtualMachine.create(
+                                  self.apiclient,
+                                  self.services["virtual_machine"],
+                                  accountid=self.account.name,
+                                  domainid=self.account.domainid,
+                                  serviceofferingid=self.service_offering.id,
+                                  networkids=[str(network.id)],
+                                  hostid=host.id
+                                  )
+        self.debug("Deployed VM in network: %s" % network.id)
+
+        vms = VirtualMachine.list(
+                                  self.apiclient,
+                                  id=virtual_machine.id,
+                                  listall=True
+                                  )
+        self.assertEqual(
+                         isinstance(vms, list),
+                         True,
+                         "List Vms should return a valid list"
+                         )
+        vm = vms[0]
+        self.assertEqual(
+                         vm.state,
+                         "Running",
+                         "Vm should be in running state after deployment"
+                         )
+
+        self.debug("Listing routers for network: %s" % network.name)
+        routers = Router.list(
+                              self.apiclient,
+                              networkid=network.id,
+                              listall=True
+                              )
+        self.assertEqual(
+                    isinstance(routers, list),
+                    True,
+                    "list router should return Master and backup routers"
+                    )
+        self.assertEqual(
+                    len(routers),
+                    2,
+                    "Length of the list router should be 2 (Backup & master)"
+                    )
+        self.assertNotEqual(
+                    routers[0].hostid,
+                    routers[1].hostid,
+                    "Both the routers should be in different storage pools"
+                            )
+        self.debug("Enabling remaining pods if any..")
+        pods = Pod.list(
+                        self.apiclient,
+                        zoneid=self.zone.id,
+                        listall=True,
+                        allocationstate="Disabled"
+                        )
+        self.assertEqual(
+                         isinstance(pods, list),
+                         True,
+                         "List pods should not return an empty response"
+                         )
+
+        for pod in pods:
+            cmd = updatePod.updatePodCmd()
+            cmd.id = pod.id
+            cmd.allocationstate = 'Enabled'
+            self.apiclient.updatePod(cmd)
+
+        clusters = Cluster.list(
+                                self.apiclient,
+                                allocationstate="Disabled",
+                                podid=enabled_pod.id,
+                                listall=True
+                                )
+
+        for cluster in clusters:
+                cmd = updateCluster.updateClusterCmd()
+                cmd.id = cluster.id
+                cmd.allocationstate = 'Enabled'
+                self.apiclient.updateCluster(cmd)
+        return
+
+    @attr(tags=["advanced", "advancedns", "ssh"])
+    def test_RvR_multihosts(self):
+        """Test RvR with muti hosts
+        """
+
+        # Steps to validate
+        # 0. listHosts should have atleast two hosts in a single cluster
+        #    (disable pods/clusters as necessary)
+        # 1. create a network offering for redundant router
+        # 2. create a network out of this offering
+        # 3. deploy a VM in this network on a host in the cluster from 0
+        #    (specify hostid for deployment)
+        # 4. listRouters
+        # 5. delete the account
+        # 6. enable the clusters and pods
+        # Validate the following
+        # 1. listNetworkOfferings should show created offering for RvR
+        # 2. listNetworks should show the created network in allocated state
+        # 3. VM should be deployed and in Running state and on specified host
+        # 4. There should be two routers (MASTER and BACKUP) for this network
+        #    ensure both routers should be on different hosts
+
+        self.debug(
+            "Checking if the current zone has multiple active pods in it..")
+        pods = Pod.list(
+                        self.apiclient,
+                        zoneid=self.zone.id,
+                        listall=True,
+                        allocationstate="Enabled"
+                        )
+        self.assertEqual(
+                         isinstance(pods, list),
+                         True,
+                         "List pods should not return an empty response"
+                         )
+
+        enabled_pod = pods[0]
+        self.debug("Cheking if pod has multiple clusters")
+        clusters = Cluster.list(
+                                self.apiclient,
+                                podid=enabled_pod.id,
+                                listall=True
+                                )
+        self.assertEqual(
+                         isinstance(clusters, list),
+                         True,
+                         "List clusters should not return empty response"
+                         )
+
+        enabled_cluster = clusters[0]
+
+        self.debug("Cheking if cluster has multiple hosts")
+        hosts = Host.list(
+                                self.apiclient,
+                                clusterid=enabled_cluster.id,
+                                listall=True
+                                )
+        self.assertEqual(
+                         isinstance(hosts, list),
+                         True,
+                         "List hosts should not return empty response"
+                         )
+
+        if len(hosts) < 2:
+            raise unittest.SkipTest(
+                            "The env don't have 2 hosts req for test")
+
+        self.debug("disable all pods except one!")
+        if len(pods) > 1:
+            for pod in pods:
+                cmd = updatePod.updatePodCmd()
+                cmd.id = pod.id
+                cmd.allocationstate = 'Disabled'
+                self.apiclient.updatePod(cmd)
+
+            self.debug("Warning: Disabled all pods in zone")
+
+            cmd = updatePod.updatePodCmd()
+            cmd.id = pods[0].id
+            cmd.allocationstate = 'Enabled'
+            self.apiclient.updatePod(cmd)
+            self.debug("Enabled first pod for testing..")
+
+        self.debug("disable all clusters except one!")
+        if len(pods) > 1:
+            for cluster in clusters:
+                cmd = updateCluster.updateClusterCmd()
+                cmd.id = cluster.id
+                cmd.allocationstate = 'Disabled'
+                self.apiclient.updateCluster(cmd)
+
+            self.debug("Warning: Disabled all pods in zone")
+
+            cmd = updateCluster.updateClusterCmd()
+            cmd.id = clusters[0].id
+            cmd.allocationstate = 'Enabled'
+            self.apiclient.updateCluster(cmd)
+            self.debug("Enabled first cluster for testing..")
+
+        # Creating network using the network offering created
+        self.debug("Creating network with network offering: %s" %
+                                                    self.network_offering.id)
+        network = Network.create(
+                                self.apiclient,
+                                self.services["network"],
+                                accountid=self.account.name,
+                                domainid=self.account.domainid,
+                                networkofferingid=self.network_offering.id,
+                                zoneid=self.zone.id
+                                )
+        self.debug("Created network with ID: %s" % network.id)
+
+        networks = Network.list(
+                                self.apiclient,
+                                id=network.id,
+                                listall=True
+                                )
+        self.assertEqual(
+            isinstance(networks, list),
+            True,
+            "List networks should return a valid response for created network"
+             )
+        nw_response = networks[0]
+
+        self.debug("Network state: %s" % nw_response.state)
+        self.assertEqual(
+                    nw_response.state,
+                    "Allocated",
+                    "The network should be in allocated state after creation"
+                    )
+
+        self.debug("Listing routers for network: %s" % network.name)
+        routers = Router.list(
+                              self.apiclient,
+                              networkid=network.id,
+                              listall=True
+                              )
+        self.assertEqual(
+            routers,
+            None,
+            "Routers should not be spawned when network is in allocated state"
+            )
+
+        self.debug("Retrieving the list of hosts in the cluster")
+        hosts = Host.list(
+                          self.apiclient,
+                          clusterid=enabled_cluster.id,
+                          listall=True
+                          )
+        self.assertEqual(
+                         isinstance(hosts, list),
+                         True,
+                         "List hosts should not return an empty response"
+                         )
+        host = hosts[0]
+
+        self.debug("Deploying VM in account: %s" % self.account.name)
+
+        # Spawn an instance in that network
+        virtual_machine = VirtualMachine.create(
+                                  self.apiclient,
+                                  self.services["virtual_machine"],
+                                  accountid=self.account.name,
+                                  domainid=self.account.domainid,
+                                  serviceofferingid=self.service_offering.id,
+                                  networkids=[str(network.id)],
+                                  hostid=host.id
+                                  )
+        self.debug("Deployed VM in network: %s" % network.id)
+
+        vms = VirtualMachine.list(
+                                  self.apiclient,
+                                  id=virtual_machine.id,
+                                  listall=True
+                                  )
+        self.assertEqual(
+                         isinstance(vms, list),
+                         True,
+                         "List Vms should return a valid list"
+                         )
+        vm = vms[0]
+        self.assertEqual(
+                         vm.state,
+                         "Running",
+                         "Vm should be in running state after deployment"
+                         )
+
+        self.debug("Listing routers for network: %s" % network.name)
+        routers = Router.list(
+                              self.apiclient,
+                              networkid=network.id,
+                              listall=True
+                              )
+        self.assertEqual(
+                    isinstance(routers, list),
+                    True,
+                    "list router should return Master and backup routers"
+                    )
+        self.assertEqual(
+                    len(routers),
+                    2,
+                    "Length of the list router should be 2 (Backup & master)"
+                  )
+        self.assertNotEqual(
+                            routers[0].hostid,
+                            routers[1].hostid,
+                            "Both the routers should be in different hosts"
+                            )
+        self.debug("Enabling remaining pods if any..")
+        pods = Pod.list(
+                        self.apiclient,
+                        zoneid=self.zone.id,
+                        listall=True,
+                        allocationstate="Disabled"
+                        )
+
+        if pods is not None:
+            for pod in pods:
+                cmd = updatePod.updatePodCmd()
+                cmd.id = pod.id
+                cmd.allocationstate = 'Enabled'
+                self.apiclient.updatePod(cmd)
+
+        clusters = Cluster.list(
+                                self.apiclient,
+                                allocationstate="Disabled",
+                                podid=enabled_pod.id,
+                                listall=True
+                                )
+        if clusters is not None:
+            for cluster in clusters:
+                cmd = updateCluster.updateClusterCmd()
+                cmd.id = cluster.id
+                cmd.allocationstate = 'Enabled'
+                self.apiclient.updateCluster(cmd)
+        return
\ No newline at end of file


[26/29] git commit: updated refs/heads/master-6-17-stable to 93712c2

Posted by ts...@apache.org.
CLOUDSTACK-3060: condition for vmware while getting process status.

Signed-off-by: Prasanna Santhanam <ts...@apache.org>
(cherry picked from commit 1fc7aeaaea80e30651a47024cf928ff11fb29e9c)


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

Branch: refs/heads/master-6-17-stable
Commit: 2c8776341471d3785238c4446918264ddcd401a8
Parents: 77a01f3
Author: Gaurav Aradhye <ga...@clogeny.com>
Authored: Thu Jun 20 00:27:29 2013 -0400
Committer: Prasanna Santhanam <ts...@apache.org>
Committed: Sat Jun 29 00:52:08 2013 +0530

----------------------------------------------------------------------
 test/integration/smoke/test_routers.py | 52 ++++++++++++++++++++++++++---
 1 file changed, 48 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2c877634/test/integration/smoke/test_routers.py
----------------------------------------------------------------------
diff --git a/test/integration/smoke/test_routers.py b/test/integration/smoke/test_routers.py
index d89acf9..2e4553b 100644
--- a/test/integration/smoke/test_routers.py
+++ b/test/integration/smoke/test_routers.py
@@ -180,7 +180,18 @@ class TestRouterServices(cloudstackTestCase):
                             "Check list router response for router state"
                         )
 
-        result = get_process_status(
+   if self.apiclient.hypervisor.lower() == 'vmware':
+           result = get_process_status(
+                               self.apiclient.connection.mgtSvr,
+                               22,
+                           self.apiclient.connection.user,
+                           self.apiclient.connection.passwd,
+                           router.linklocalip,
+                           "service dnsmasq status",
+                               hypervisor=self.apiclient.hypervisor
+                           )
+   else:
+            result = get_process_status(
                                 host.ipaddress,
                                 self.services['virtual_machine']["publicport"],
                                 self.vm_1.username,
@@ -242,7 +253,18 @@ class TestRouterServices(cloudstackTestCase):
                             "Check list router response for router state"
                         )
 
-        result = get_process_status(
+   if self.apiclient.hypervisor.lower() == 'vmware':
+           result = get_process_status(
+                           self.apiclient.connection.mgtSvr,
+                               22,
+                           self.apiclient.connection.user,
+                           self.apiclient.connection.passwd,
+                           router.linklocalip,
+                           "service dnsmasq status",
+                               hypervisor=self.apiclient.hypervisor
+                           )
+   else:
+            result = get_process_status(
                                 host.ipaddress,
                                 self.services['virtual_machine']["publicport"],
                                 self.vm_1.username,
@@ -259,7 +281,18 @@ class TestRouterServices(cloudstackTestCase):
                             "Check dnsmasq service is running or not"
                         )
 
-        result = get_process_status(
+   if self.apiclient.hypervisor.lower() == 'vmware':
+           result = get_process_status(
+                               self.apiclient.connection.mgtSvr,
+                           22,
+                           self.apiclient.connection.user,
+                           self.apiclient.connection.passwd,
+                           router.linklocalip,
+                           "service haproxy status",
+                           hypervisor=self.apiclient.hypervisor
+                           )
+   else:
+            result = get_process_status(
                                 host.ipaddress,
                                 self.services['virtual_machine']["publicport"],
                                 self.vm_1.username,
@@ -423,7 +456,18 @@ class TestRouterServices(cloudstackTestCase):
                         )
         host = hosts[0]
 
-        res = get_process_status(
+   if self.apiclient.hypervisor.lower() == 'vmware':
+           res = get_process_status(
+                           self.apiclient.connection.mgtSvr,
+                           22,
+                           self.apiclient.connection.user,
+                           self.apiclient.connection.passwd,
+                           router.linklocalip,
+                           "uptime",
+                           hypervisor=self.apiclient.hypervisor
+                           )
+   else:
+            res = get_process_status(
                                 host.ipaddress,
                                 self.services['virtual_machine']["publicport"],
                                 self.vm_1.username,


[22/29] Split out snapshot tests for speedup

Posted by ts...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c7e2ca56/test/integration/component/test_snapshots.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_snapshots.py b/test/integration/component/test_snapshots.py
index 708a8b2..18dcefd 100644
--- a/test/integration/component/test_snapshots.py
+++ b/test/integration/component/test_snapshots.py
@@ -17,7 +17,6 @@
 """ P1 tests for Snapshots
 """
 #Import Local Modules
-import marvin
 from nose.plugins.attrib import attr
 from marvin.cloudstackTestCase import *
 from marvin.cloudstackAPI import *
@@ -111,7 +110,7 @@ class Services:
                         "volume": {
                                    "diskname": "APP Data Volume",
                                    "size": 1,   # in GBs
-                                   "diskdevice": "/dev/xvdb",   # Data Disk
+                                   "diskdevice": ['/dev/xvdb', '/dev/sdb', '/dev/hdb', '/dev/vdb' ],   # Data Disk
                         },
                         "paths": {
                                     "mount_dir": "/mnt/tmp",
@@ -120,15 +119,6 @@ class Services:
                                     "sub_lvl_dir2": "test2",
                                     "random_data": "random.data",
                         },
-                        "diskdevice": "/dev/xvda",
-                        "diskname": "TestDiskServ",
-                        "size": 1,  # GBs
-
-                        "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,
@@ -136,229 +126,6 @@ class Services:
                     }
 
 
-class TestSnapshotRootDisk(cloudstackTestCase):
-
-    @classmethod
-    def setUpClass(cls):
-        cls.api_client = super(TestSnapshotRootDisk, 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.services['mode'] = cls.zone.networktype
-
-        template = get_template(
-                            cls.api_client,
-                            cls.zone.id,
-                            cls.services["ostype"]
-                            )
-        cls.services["domainid"] = cls.domain.id
-        cls.services["server_without_disk"]["zoneid"] = cls.zone.id
-        cls.services["templates"]["ostypeid"] = template.ostypeid
-        cls.services["zoneid"] = cls.zone.id
-
-        # Create VMs, NAT Rules etc
-        cls.account = Account.create(
-                            cls.api_client,
-                            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.virtual_machine = cls.virtual_machine_with_disk = \
-                    VirtualMachine.create(
-                                cls.api_client,
-                                cls.services["server_without_disk"],
-                                templateid=template.id,
-                                accountid=cls.account.name,
-                                domainid=cls.account.domainid,
-                                serviceofferingid=cls.service_offering.id,
-                                mode=cls.services["mode"]
-                                )
-        cls._cleanup = [
-                        cls.service_offering,
-                        cls.account,
-                        ]
-        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 created instance, volumes and snapshots
-            cleanup_resources(self.apiclient, self.cleanup)
-        except Exception as e:
-            raise Exception("Warning: Exception during cleanup : %s" % e)
-        return
-
-    @attr(speed = "slow")
-    @attr(tags = ["advanced", "advancedns", "smoke"])
-    def test_01_snapshot_root_disk(self):
-        """Test Snapshot Root Disk
-        """
-
-        # Validate the following
-        # 1. listSnapshots should list the snapshot that was created.
-        # 2. verify that secondary storage NFS share contains
-        #    the reqd volume under
-        #    /secondary/snapshots//$account_id/$volumeid/$snapshot_uuid
-        # 3. verify backup_snap_id was non null in the `snapshots` table
-
-        volumes = list_volumes(
-                            self.apiclient,
-                            virtualmachineid=self.virtual_machine_with_disk.id,
-                            type='ROOT',
-                            listall=True
-                            )
-
-        snapshot = Snapshot.create(
-                                   self.apiclient,
-                                   volumes[0].id,
-                                   account=self.account.name,
-                                   domainid=self.account.domainid
-                                   )
-        self.debug("Snapshot created: ID - %s" % snapshot.id)
-
-        snapshots = list_snapshots(
-                                  self.apiclient,
-                                  id=snapshot.id
-                                  )
-        self.assertEqual(
-                            isinstance(snapshots, list),
-                            True,
-                            "Check list response returns a valid list"
-                        )
-
-        self.assertNotEqual(
-                            snapshots,
-                            None,
-                            "Check if result exists in list item call"
-                            )
-        self.assertEqual(
-                            snapshots[0].id,
-                            snapshot.id,
-                            "Check resource id in list resources call"
-                        )
-        self.debug(
-            "select backup_snap_id, account_id, volume_id from snapshots where uuid = '%s';" \
-            % str(snapshot.id)
-            )
-        qresultset = self.dbclient.execute(
-                        "select backup_snap_id, account_id, volume_id from snapshots where uuid = '%s';" \
-                        % str(snapshot.id)
-                        )
-        self.assertNotEqual(
-                            len(qresultset),
-                            0,
-                            "Check DB Query result set"
-                            )
-
-        qresult = qresultset[0]
-
-        snapshot_uuid = qresult[0]      # backup_snap_id = snapshot UUID
-        account_id = qresult[1]
-        volume_id = qresult[2]
-
-        self.assertNotEqual(
-                            str(snapshot_uuid),
-                            'NULL',
-                            "Check if backup_snap_id is not null"
-                        )
-        
-        # Get the Secondary Storage details from  list Hosts
-        hosts = list_hosts(
-                                 self.apiclient,
-                                 type='SecondaryStorage',
-                                 zoneid=self.zone.id
-                                 )
-        self.assertEqual(
-                            isinstance(hosts, list),
-                            True,
-                            "Check list response returns a valid list"
-                        )
-        uuids = []
-        for host in hosts:
-            # hosts[0].name = "nfs://192.168.100.21/export/test"
-            parse_url = (host.name).split('/')
-            # parse_url = ['nfs:', '', '192.168.100.21', 'export', 'test']
-
-            # Split IP address and export path from name
-            sec_storage_ip = parse_url[2]
-            # Sec Storage IP: 192.168.100.21
-
-            export_path = '/'.join(parse_url[3:])
-            # Export path: export/test
-
-            try:
-                # Login to VM to check snapshot present on sec disk
-                ssh_client = self.virtual_machine_with_disk.get_ssh_client()
-
-                cmds = [
-                    "mkdir -p %s" % self.services["mount_dir"],
-                    "mount %s/%s %s" % (
-                                         sec_storage_ip,
-                                         export_path,
-                                         self.services["mount_dir"]
-                                         ),
-                    "ls %s/snapshots/%s/%s" % (
-                                               self.services["mount_dir"],
-                                               account_id,
-                                               volume_id
-                                               ),
-                    ]
-
-                for c in cmds:
-                    self.debug(c)
-                    result = ssh_client.execute(c)
-                    self.debug(result)
-
-            except Exception:
-                self.fail("SSH failed for Virtual machine: %s" %
-                                self.virtual_machine_with_disk.ipaddress)
-
-            uuids.append(result)
-            # Unmount the Sec Storage
-            cmds = [
-                    "umount %s" % (self.services["mount_dir"]),
-                    ]
-            try:
-                for c in cmds:
-                    self.debug(c)
-                    result = ssh_client.execute(c)
-                    self.debug(result)
-
-            except Exception as e:
-                self.fail("SSH failed for Virtual machine: %s" %
-                                self.virtual_machine_with_disk.ipaddress)
-        
-        res = str(uuids)
-        # Check snapshot UUID in secondary storage and database
-        self.assertEqual(
-                        res.count(snapshot_uuid),
-                        1,
-                        "Check snapshot UUID in secondary storage and database"
-                        )
-        return
-
-
 class TestSnapshots(cloudstackTestCase):
 
     @classmethod
@@ -389,11 +156,6 @@ class TestSnapshots(cloudstackTestCase):
         cls.services["zoneid"] = cls.zone.id
         cls.services["diskoffering"] = cls.disk_offering.id
 
-        #determine device type from hypervisor
-        hosts = Host.list(cls.api_client, id=cls.virtual_machine.hostid)
-        if len(hosts) > 0 and hosts[0].hypervisor.lower() == "kvm":
-            cls.service["volume"]["diskdevice"] = "/dev/vdb"
-
         # Create VMs, NAT Rules etc
         cls.account = Account.create(
                             cls.api_client,
@@ -555,14 +317,14 @@ class TestSnapshots(cloudstackTestCase):
                 ssh_client = self.virtual_machine_with_disk.get_ssh_client()
 
                 cmds = [
-                    "mkdir -p %s" % self.services["mount_dir"],
+                    "mkdir -p %s" % self.services["paths"]["mount_dir"],
                     "mount %s/%s %s" % (
                                          sec_storage_ip,
                                          export_path,
-                                         self.services["mount_dir"]
+                                         self.services["paths"]["mount_dir"]
                                          ),
                     "ls %s/snapshots/%s/%s" % (
-                                               self.services["mount_dir"],
+                                               self.services["paths"]["mount_dir"],
                                                account_id,
                                                volume_id
                                                ),
@@ -579,7 +341,7 @@ class TestSnapshots(cloudstackTestCase):
             uuids.append(result)
             # Unmount the Sec Storage
             cmds = [
-                    "umount %s" % (self.services["mount_dir"]),
+                    "umount %s" % (self.services["paths"]["mount_dir"]),
                     ]
             try:
                 for c in cmds:
@@ -854,192 +616,213 @@ class TestSnapshots(cloudstackTestCase):
         return
 
     @attr(speed = "slow")
-    @attr(tags = ["advanced", "advancedns", "smoke"])
-    def test_05_recurring_snapshot_root_disk(self):
-        """Test Recurring Snapshot Root Disk
+    @attr(tags = ["advanced", "advancedns", "basic", "sg"])
+    def test_03_snapshot_detachedDisk(self):
+        """Test snapshot from detached disk
         """
-        #1. Create snapshot policy for root disk
-        #2. ListSnapshot policy should return newly created policy
-        #3. Verify only most recent number (maxsnaps) snapshots retailed
+        # Validate the following
+        # 1. login in VM  and write some data on data disk(use fdisk to
+        #    partition datadisk,fdisk /dev/sdb, and make filesystem using
+        #    mkfs.ext3)
+        # 2. Detach the data disk and write some data on data disk
+        # 3. perform the snapshot on the detached volume
+        # 4. listvolumes with VM id shouldn't show the detached volume
+        # 5. listSnapshots should list the snapshot that was created
+        # 6. verify that secondary storage NFS share contains the reqd volume
+        #    under /secondary/snapshots/$accountid/$volumeid/$snapshot_uuid
+        # 7. verify backup_snap_id was non null in the `snapshots` table
 
-        volume = list_volumes(
-                        self.apiclient,
-                        virtualmachineid=self.virtual_machine_with_disk.id,
-                        type='ROOT',
-                        listall=True
-                        )
-        self.assertEqual(
-                            isinstance(volume, list),
-                            True,
-                            "Check list response returns a valid list"
-                        )
-        recurring_snapshot = SnapshotPolicy.create(
-                                           self.apiclient,
-                                           volume[0].id,
-                                           self.services["recurring_snapshot"]
-                                        )
-        self.cleanup.append(recurring_snapshot)
-
-        #ListSnapshotPolicy should return newly created policy
-        list_snapshots_policy = list_snapshot_policy(
-                                                     self.apiclient,
-                                                     id=recurring_snapshot.id,
-                                                     volumeid=volume[0].id
-                                                     )
+        volumes = list_volumes(
+                               self.apiclient,
+                               virtualmachineid=self.virtual_machine.id,
+                               type='DATADISK',
+                               listall=True
+                               )
         self.assertEqual(
-                            isinstance(list_snapshots_policy, list),
+                            isinstance(volumes, list),
                             True,
                             "Check list response returns a valid list"
                         )
-        self.assertNotEqual(
-                            list_snapshots_policy,
-                            None,
-                            "Check if result exists in list item call"
-                            )
-        snapshots_policy = list_snapshots_policy[0]
-        self.assertEqual(
-                        snapshots_policy.id,
-                        recurring_snapshot.id,
-                        "Check recurring snapshot id in list resources call"
-                        )
-        self.assertEqual(
-                        snapshots_policy.maxsnaps,
-                        self.services["recurring_snapshot"]["maxsnaps"],
-                        "Check interval type in list resources call"
-                        )
-        # Sleep for (maxsnaps+1) hours to verify
-        # only maxsnaps snapshots are retained
-        time.sleep(
-            (self.services["recurring_snapshot"]["maxsnaps"]) * 3600
-            )
+        volume = volumes[0]
+        random_data_0 = random_gen(100)
+        random_data_1 = random_gen(100)
+        try:
+            ssh_client = self.virtual_machine.get_ssh_client()
 
-        timeout = self.services["timeout"]
-        while True: 
-            snapshots = list_snapshots(
-                        self.apiclient,
-                        volumeid=volume[0].id,
-                        intervaltype=\
-                        self.services["recurring_snapshot"]["intervaltype"],
-                        snapshottype='RECURRING',
-                        listall=True
-                        )
-                
-            if isinstance(snapshots, list):
-                break
-                    
-            elif timeout == 0:
-                raise Exception("List snapshots API call failed.")
+            #Format partition using ext3
+            format_volume_to_ext3(
+                              ssh_client,
+                              self.services["volume"]["diskdevice"]
+                              )
+            cmds = [
+                    "mkdir -p %s" % self.services["paths"]["mount_dir"],
+                    "mount %s1 %s" % (
+                                      self.services["volume"]["diskdevice"],
+                                      self.services["paths"]["mount_dir"]
+                                      ),
+                    "pushd %s" % self.services["mount_dir"],
+                    "mkdir -p %s/{%s,%s} " % (
+                                                self.services["sub_dir"],
+                                                self.services["sub_lvl_dir1"],
+                                                self.services["sub_lvl_dir2"]
+                                            ),
+                    "echo %s > %s/%s/%s" % (
+                                               random_data_0,
+                                                self.services["sub_dir"],
+                                                self.services["sub_lvl_dir1"],
+                                                self.services["random_data"]
+                                            ),
+                    "echo %s > %s/%s/%s" % (
+                                                random_data_1,
+                                                self.services["sub_dir"],
+                                                self.services["sub_lvl_dir2"],
+                                                self.services["random_data"]
+                                            ),
+                    "sync",
+                ]
+            for c in cmds:
+                self.debug(ssh_client.execute(c))
+
+            #detach volume from VM
+            cmd = detachVolume.detachVolumeCmd()
+            cmd.id = volume.id
+            self.apiclient.detachVolume(cmd)
 
-            time.sleep(1)
-            timeout = timeout - 1
+            #Create snapshot from detached volume
+            snapshot = Snapshot.create(self.apiclient, volume.id)
+            self.cleanup.append(snapshot)
 
-        self.assertEqual(
-                            isinstance(snapshots, list),
-                            True,
-                            "Check list response returns a valid list"
+            volumes = list_volumes(
+                               self.apiclient,
+                               virtualmachineid=self.virtual_machine.id,
+                               type='DATADISK',
+                               listall=True
+                               )
+
+            self.assertEqual(
+                            volumes,
+                            None,
+                            "Check Volume is detached"
+                      )
+
+            # Verify the snapshot was created or not
+            snapshots = list_snapshots(
+                                   self.apiclient,
+                                   id=snapshot.id
+                                   )
+            self.assertNotEqual(
+                            snapshots,
+                            None,
+                            "Check if result exists in list snapshots call"
+                            )
+            self.assertEqual(
+                            snapshots[0].id,
+                            snapshot.id,
+                            "Check snapshot id in list resources call"
                         )
+        except Exception as e:
+            self.fail("SSH failed for VM with IP: %s - %s" %
+                                (self.virtual_machine.ipaddress, e))
 
-        self.assertEqual(
-                         len(snapshots),
-                         self.services["recurring_snapshot"]["maxsnaps"],
-                         "Check maximum number of recurring snapshots retained"
+        # Fetch values from database
+        qresultset = self.dbclient.execute(
+                        "select backup_snap_id, account_id, volume_id from snapshots where uuid = '%s';" \
+                        % snapshot.id
                         )
-        return
+        self.assertNotEqual(
+                            len(qresultset),
+                            0,
+                            "Check DB Query result set"
+                            )
 
-    @attr(speed = "slow")
-    @attr(tags = ["advanced", "advancedns", "smoke"])
-    def test_06_recurring_snapshot_data_disk(self):
-        """Test Recurring Snapshot data Disk
-        """
-        #1. Create snapshot policy for data disk
-        #2. ListSnapshot policy should return newly created policy
-        #3. Verify only most recent number (maxsnaps) snapshots retailed
+        qresult = qresultset[0]
+        snapshot_uuid = qresult[0]      # backup_snap_id = snapshot UUID
+        account_id = qresult[1]
+        volume_id = qresult[2]
 
-        volume = list_volumes(
-                        self.apiclient,
-                        virtualmachineid=self.virtual_machine_with_disk.id,
-                        type='DATADISK',
-                        listall=True
+        self.assertNotEqual(
+                            str(qresult[0]),
+                            'NULL',
+                            "Check if backup_snap_id is not null"
                         )
 
+        # Get the Secondary Storage details from  list Hosts
+        hosts = list_hosts(
+                                 self.apiclient,
+                                 type='SecondaryStorage',
+                                 zoneid=self.zone.id
+                                 )
         self.assertEqual(
-                            isinstance(volume, list),
+                            isinstance(hosts, list),
                             True,
                             "Check list response returns a valid list"
                         )
+        uuids = []
+        for host in hosts:
+            # hosts[0].name = "nfs://192.168.100.21/export/test"
+            parse_url = (host.name).split('/')
+            # parse_url = ['nfs:', '', '192.168.100.21', 'export', 'test']
 
-        recurring_snapshot = SnapshotPolicy.create(
-                                    self.apiclient,
-                                    volume[0].id,
-                                    self.services["recurring_snapshot"]
-                                )
-        self.cleanup.append(recurring_snapshot)
-        #ListSnapshotPolicy should return newly created policy
-        list_snapshots_policy = list_snapshot_policy(
-                                                     self.apiclient,
-                                                     id=recurring_snapshot.id,
-                                                     volumeid=volume[0].id
-                                                     )
+            # Stripping end ':' from storage type
+            storage_type = parse_url[0][:-1]
 
-        self.assertEqual(
-                            isinstance(list_snapshots_policy, list),
-                            True,
-                            "Check list response returns a valid list"
-                        )
+            # Split IP address and export path from name
+            sec_storage_ip = parse_url[2]
+            # Sec Storage IP: 192.168.100.21
 
-        self.assertNotEqual(
-                            list_snapshots_policy,
-                            None,
-                            "Check if result exists in list item call"
-                            )
-        snapshots_policy = list_snapshots_policy[0]
-        self.assertEqual(
-                        snapshots_policy.id,
-                        recurring_snapshot.id,
-                        "Check recurring snapshot id in list resources call"
-                        )
-        self.assertEqual(
-                            snapshots_policy.maxsnaps,
-                            self.services["recurring_snapshot"]["maxsnaps"],
-                            "Check interval type in list resources call"
-                        )
+            if sec_storage_ip[-1] != ":":
+                sec_storage_ip = sec_storage_ip + ":"
 
-        # Sleep for (maxsnaps) hours to verify only maxsnaps snapshots are
-        # retained
-        time.sleep(
-            (self.services["recurring_snapshot"]["maxsnaps"]) * 3600
-            )
-        
-        timeout = self.services["timeout"]
-        while True: 
-            snapshots = list_snapshots(
-                            self.apiclient,
-                            volumeid=volume[0].id,
-                            intervaltype=\
-                            self.services["recurring_snapshot"]["intervaltype"],
-                            snapshottype='RECURRING',
-                            listall=True
-                            )
-                
-            if isinstance(snapshots, list):
-                break
-                    
-            elif timeout == 0:
-                raise Exception("List snapshots API call failed.")
+            export_path = '/'.join(parse_url[3:])
+            # Export path: export/test
+
+            # Sleep to ensure that snapshot is reflected in sec storage
+            time.sleep(self.services["sleep"])
+            try:
+                # Login to Management server to check snapshot present on
+                # sec disk
+                ssh_client = remoteSSHClient(
+                                    self.services["mgmt_server"]["ipaddress"],
+                                    self.services["mgmt_server"]["port"],
+                                    self.services["mgmt_server"]["username"],
+                                    self.services["mgmt_server"]["password"],
+                                    )
+
+                cmds = [
+                    "mkdir -p %s" % self.services["mount_dir"],
+                    "mount -t %s %s/%s %s" % (
+                                         storage_type,
+                                         sec_storage_ip,
+                                         export_path,
+                                         self.services["mount_dir"]
+                                         ),
+                    "ls %s/snapshots/%s/%s" % (
+                                               self.services["mount_dir"],
+                                               account_id,
+                                               volume_id
+                                               ),
+                        ]
+
+                for c in cmds:
+                    result = ssh_client.execute(c)
 
-            time.sleep(1)
-            timeout = timeout - 1
+                uuids.append(result)
+                # Unmount the Sec Storage
+                cmds = [
+                        "umount %s" % (self.services["mount_dir"]),
+                        ]
+                for c in cmds:
+                    result = ssh_client.execute(c)
+            except Exception as e:
+                self.fail("SSH failed for management server: %s - %s" %
+                                (self.services["mgmt_server"]["ipaddress"], e))
 
+        res = str(uuids)
         self.assertEqual(
-                            isinstance(snapshots, list),
-                            True,
-                            "Check list response returns a valid list"
+                        res.count(snapshot_uuid),
+                        1,
+                        "Check snapshot UUID in secondary storage and database"
                         )
-        self.assertEqual(
-                         len(snapshots),
-                         self.services["recurring_snapshot"]["maxsnaps"],
-                         "Check maximum number of recurring snapshots retained"
-                         )
         return
 
     @attr(speed = "slow")
@@ -1063,30 +846,30 @@ class TestSnapshots(cloudstackTestCase):
             ssh_client = self.virtual_machine.get_ssh_client()
 
             cmds = [
-                    "mkdir -p %s" % self.services["mount_dir"],
+                    "mkdir -p %s" % self.services["paths"]["mount_dir"],
                     "mount %s1 %s" % (
                                       self.services["rootdisk"],
-                                      self.services["mount_dir"]
+                                      self.services["paths"]["mount_dir"]
                                       ),
                     "mkdir -p %s/%s/{%s,%s} " % (
-                                                self.services["mount_dir"],
-                                                self.services["sub_dir"],
-                                                self.services["sub_lvl_dir1"],
-                                                self.services["sub_lvl_dir2"]
+                                                self.services["paths"]["mount_dir"],
+                                                self.services["paths"]["sub_dir"],
+                                                self.services["paths"]["sub_lvl_dir1"],
+                                                self.services["paths"]["sub_lvl_dir2"]
                                             ),
                     "echo %s > %s/%s/%s/%s" % (
                                                 random_data_0,
-                                                self.services["mount_dir"],
-                                                self.services["sub_dir"],
-                                                self.services["sub_lvl_dir1"],
-                                                self.services["random_data"]
+                                                self.services["paths"]["mount_dir"],
+                                                self.services["paths"]["sub_dir"],
+                                                self.services["paths"]["sub_lvl_dir1"],
+                                                self.services["paths"]["random_data"]
                                             ),
                     "echo %s > %s/%s/%s/%s" % (
                                                 random_data_1,
-                                                self.services["mount_dir"],
-                                                self.services["sub_dir"],
-                                                self.services["sub_lvl_dir2"],
-                                                self.services["random_data"]
+                                                self.services["paths"]["mount_dir"],
+                                                self.services["paths"]["sub_dir"],
+                                                self.services["paths"]["sub_lvl_dir2"],
+                                                self.services["paths"]["random_data"]
                                         ),
 		             "sync",
                 ]
@@ -1102,7 +885,7 @@ class TestSnapshots(cloudstackTestCase):
 
         # Unmount the Volume
         cmds = [
-                    "umount %s" % (self.services["mount_dir"]),
+                    "umount %s" % (self.services["paths"]["mount_dir"]),
                 ]
         for c in cmds:
             self.debug(c)
@@ -1177,10 +960,10 @@ class TestSnapshots(cloudstackTestCase):
             ssh = new_virtual_machine.get_ssh_client()
 
             cmds = [
-                    "mkdir -p %s" % self.services["mount_dir"],
+                    "mkdir -p %s" % self.services["paths"]["mount_dir"],
                     "mount %s1 %s" % (
                                       self.services["rootdisk"],
-                                      self.services["mount_dir"]
+                                      self.services["paths"]["mount_dir"]
                                       )
                ]
 
@@ -1188,17 +971,17 @@ class TestSnapshots(cloudstackTestCase):
                 ssh.execute(c)
 
             returned_data_0 = ssh.execute("cat %s/%s/%s/%s" % (
-                                                self.services["mount_dir"],
-                                                self.services["sub_dir"],
-                                                self.services["sub_lvl_dir1"],
-                                                self.services["random_data"]
+                                                self.services["paths"]["mount_dir"],
+                                                self.services["paths"]["sub_dir"],
+                                                self.services["paths"]["sub_lvl_dir1"],
+                                                self.services["paths"]["random_data"]
                                     ))
             self.debug(returned_data_0)
             returned_data_1 = ssh.execute("cat %s/%s/%s/%s" % (
-                                                self.services["mount_dir"],
-                                                self.services["sub_dir"],
-                                                self.services["sub_lvl_dir2"],
-                                                self.services["random_data"]
+                                                self.services["paths"]["mount_dir"],
+                                                self.services["paths"]["sub_dir"],
+                                                self.services["paths"]["sub_lvl_dir2"],
+                                                self.services["paths"]["random_data"]
                                     ))
             self.debug(returned_data_1)
         except Exception as e:
@@ -1230,11 +1013,11 @@ class TestSnapshots(cloudstackTestCase):
         return
 
 
-class TestCreateVMsnapshotTemplate(cloudstackTestCase):
+class TestCreateVMSnapshotTemplate(cloudstackTestCase):
 
     @classmethod
     def setUpClass(cls):
-        cls.api_client = super(TestCreateVMsnapshotTemplate, cls).getClsTestClient().getApiClient()
+        cls.api_client = super(TestCreateVMSnapshotTemplate, cls).getClsTestClient().getApiClient()
         cls.services = Services().services
         # Get Zone, Domain and templates
         cls.domain = get_domain(cls.api_client, cls.services)
@@ -1480,15 +1263,15 @@ class TestCreateVMsnapshotTemplate(cloudstackTestCase):
                                     )
 
                 cmds = [
-                    "mkdir -p %s" % self.services["mount_dir"],
+                    "mkdir -p %s" % self.services["paths"]["mount_dir"],
                     "mount -t %s %s/%s %s" % (
                                          storage_type,
                                          sec_storage_ip,
                                          export_path,
-                                         self.services["mount_dir"]
+                                         self.services["paths"]["mount_dir"]
                                          ),
                     "ls %s/snapshots/%s/%s" % (
-                                               self.services["mount_dir"],
+                                               self.services["paths"]["mount_dir"],
                                                account_id,
                                                volume_id
                                                ),
@@ -1526,907 +1309,6 @@ class TestCreateVMsnapshotTemplate(cloudstackTestCase):
         return
 
 
-class TestAccountSnapshotClean(cloudstackTestCase):
-
-    @classmethod
-    def setUpClass(cls):
-        cls.api_client = super(TestAccountSnapshotClean, 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.services['mode'] = cls.zone.networktype
-
-        template = get_template(
-                            cls.api_client,
-                            cls.zone.id,
-                            cls.services["ostype"]
-                            )
-        cls.services["server"]["zoneid"] = cls.zone.id
-
-        cls.services["template"] = template.id
-
-        # Create VMs, NAT Rules etc
-        cls.account = Account.create(
-                            cls.api_client,
-                            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.virtual_machine = VirtualMachine.create(
-                                cls.api_client,
-                                cls.services["server"],
-                                templateid=template.id,
-                                accountid=cls.account.name,
-                                domainid=cls.account.domainid,
-                                serviceofferingid=cls.service_offering.id
-                                )
-        # Get the Root disk of VM
-        volumes = list_volumes(
-                            cls.api_client,
-                            virtualmachineid=cls.virtual_machine.id,
-                            type='ROOT',
-                            listall=True
-                            )
-        volume = volumes[0]
-
-        # Create a snapshot from the ROOTDISK
-        cls.snapshot = Snapshot.create(cls.api_client, volumes[0].id)
-
-        cls._cleanup = [
-                        cls.service_offering,
-                        ]
-        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 created instance, volumes and snapshots
-            cleanup_resources(self.apiclient, self.cleanup)
-        except Exception as e:
-            raise Exception("Warning: Exception during cleanup : %s" % e)
-        return
-
-    @attr(speed = "slow")
-    @attr(tags = ["advanced", "advancedns", "basic", "sg"])
-    def test_02_accountSnapshotClean(self):
-        """Test snapshot cleanup after account deletion
-        """
-        # Validate the following
-        # 1. listAccounts API should list out the newly created account
-        # 2. listVirtualMachines() command should return the deployed VM.
-        #    State of this VM should be "Running"
-        # 3. a)listSnapshots should list the snapshot that was created.
-        #    b)verify that secondary storage NFS share contains the reqd volume
-        #      under /secondary/snapshots/$accountid/$volumeid/$snapshot_uuid
-        # 4. a)listAccounts should not list account that is deleted
-        #    b) snapshot image($snapshot_uuid) should be deleted from the
-        #       /secondary/snapshots/$accountid/$volumeid/
-
-        accounts = list_accounts(
-                                 self.apiclient,
-                                 id=self.account.id
-                                 )
-        self.assertEqual(
-                            isinstance(accounts, list),
-                            True,
-                            "Check list response returns a valid list"
-                        )
-        self.assertNotEqual(
-                             len(accounts),
-                             0,
-                             "Check list Accounts response"
-                             )
-
-        # VM should be in 'Running' state
-        virtual_machines = list_virtual_machines(
-                                self.apiclient,
-                                id=self.virtual_machine.id
-                                )
-        self.assertEqual(
-                            isinstance(virtual_machines, list),
-                            True,
-                            "Check list response returns a valid list"
-                        )
-        self.assertNotEqual(
-                             len(virtual_machines),
-                             0,
-                             "Check list virtual machines response"
-                             )
-        for virtual_machine in virtual_machines:
-            self.debug("VM ID: %s, VM state: %s" % (
-                                            virtual_machine.id,
-                                            virtual_machine.state
-                                            ))
-            self.assertEqual(
-                        virtual_machine.state,
-                        'Running',
-                        "Check list VM response for Running state"
-                    )
-
-        # Verify the snapshot was created or not
-        snapshots = list_snapshots(
-                                   self.apiclient,
-                                   id=self.snapshot.id
-                                   )
-        self.assertEqual(
-                            isinstance(snapshots, list),
-                            True,
-                            "Check list response returns a valid list"
-                        )
-        self.assertNotEqual(
-                            snapshots,
-                            None,
-                            "Check if result exists in list snapshots call"
-                            )
-        self.assertEqual(
-                            snapshots[0].id,
-                            self.snapshot.id,
-                            "Check snapshot id in list resources call"
-                        )
-
-        # Fetch values from database
-        qresultset = self.dbclient.execute(
-                        "select backup_snap_id, account_id, volume_id from snapshots where uuid = '%s';" \
-                        % self.snapshot.id
-                        )
-        self.assertEqual(
-                            isinstance(qresultset, list),
-                            True,
-                            "Check DB response returns a valid list"
-                        )
-        self.assertNotEqual(
-                            len(qresultset),
-                            0,
-                            "Check DB Query result set"
-                            )
-
-        qresult = qresultset[0]
-        snapshot_uuid = qresult[0]      # backup_snap_id = snapshot UUID
-        account_id = qresult[1]
-        volume_id = qresult[2]
-
-        # Get the Secondary Storage details from  list Hosts
-        hosts = list_hosts(
-                                 self.apiclient,
-                                 type='SecondaryStorage',
-                                 zoneid=self.zone.id
-                            )
-        self.assertEqual(
-                            isinstance(hosts, list),
-                            True,
-                            "Check list response returns a valid list"
-                        )
-        uuids = []
-        for host in hosts:
-            # hosts[0].name = "nfs://192.168.100.21/export/test"
-            parse_url = (host.name).split('/')
-            # parse_url = ['nfs:', '', '192.168.100.21', 'export', 'test']
-
-            # Stripping end ':' from storage type
-            storage_type = parse_url[0][:-1]
-            # Split IP address and export path from name
-            sec_storage_ip = parse_url[2]
-            # Sec Storage IP: 192.168.100.21
-
-            if sec_storage_ip[-1] != ":":
-                sec_storage_ip = sec_storage_ip + ":"
-
-            export_path = '/'.join(parse_url[3:])
-            # Export path: export/test
-
-            # Sleep to ensure that snapshot is reflected in sec storage
-            time.sleep(self.services["sleep"])
-            try:
-                # Login to Secondary storage VM to check snapshot present on sec disk
-                ssh_client = remoteSSHClient(
-                                    self.services["mgmt_server"]["ipaddress"],
-                                    self.services["mgmt_server"]["port"],
-                                    self.services["mgmt_server"]["username"],
-                                    self.services["mgmt_server"]["password"],
-                                    )
-
-                cmds = [
-                    "mkdir -p %s" % self.services["mount_dir"],
-                    "mount -t %s %s/%s %s" % (
-                                         storage_type,
-                                         sec_storage_ip,
-                                         export_path,
-                                         self.services["mount_dir"]
-                                         ),
-                    "ls %s/snapshots/%s/%s" % (
-                                               self.services["mount_dir"],
-                                               account_id,
-                                               volume_id
-                                               ),
-                ]
-
-                for c in cmds:
-                    self.debug("command: %s" % c)
-                    result = ssh_client.execute(c)
-                    self.debug("Result: %s" % result)
-
-                uuids.append(result)
-
-                # Unmount the Sec Storage
-                cmds = [
-                    "umount %s" % (self.services["mount_dir"]),
-                    ]
-                for c in cmds:
-                    result = ssh_client.execute(c)
-            except Exception as e:
-                self.fail("SSH failed for management server: %s - %s" %
-                                (self.services["mgmt_server"]["ipaddress"], e))
-
-        res = str(uuids)
-        self.assertEqual(
-                        res.count(snapshot_uuid),
-                        1,
-                        "Check snapshot UUID in secondary storage and database"
-                        )
-
-        self.debug("Deleting account: %s" % self.account.name)
-        # Delete account
-        self.account.delete(self.apiclient)
-
-        interval = list_configurations(
-                                    self.apiclient,
-                                    name='account.cleanup.interval'
-                                    )
-        self.assertEqual(
-                            isinstance(interval, list),
-                            True,
-                            "Check list response returns a valid list"
-                        )
-        self.debug("account.cleanup.interval: %s" % interval[0].value)
-
-        # Wait for account cleanup interval
-        time.sleep(int(interval[0].value) * 2)
-
-        accounts = list_accounts(
-                                 self.apiclient,
-                                 id=self.account.id
-                                 )
-
-        self.assertEqual(
-            accounts,
-            None,
-            "List accounts should return empty list after account deletion"
-            )
-
-        uuids = []
-        for host in hosts:
-            # hosts[0].name = "nfs://192.168.100.21/export/test"
-            parse_url = (host.name).split('/')
-            # parse_url = ['nfs:', '', '192.168.100.21', 'export', 'test']
-
-            # Stripping end ':' from storage type
-            storage_type = parse_url[0][:-1]
-            # Split IP address and export path from name
-            sec_storage_ip = parse_url[2]
-            # Sec Storage IP: 192.168.100.21
-
-            if sec_storage_ip[-1] != ":":
-                sec_storage_ip = sec_storage_ip + ":"
-
-            export_path = '/'.join(parse_url[3:])
-            # Export path: export/test
-
-            try:
-                cmds = [
-                        "mount -t %s %s/%s %s" % (
-                                         storage_type,
-                                         sec_storage_ip,
-                                         export_path,
-                                         self.services["mount_dir"]
-                                         ),
-                        "ls %s/snapshots/%s/%s" % (
-                                               self.services["mount_dir"],
-                                               account_id,
-                                               volume_id
-                                               ),
-                        ]
-
-                for c in cmds:
-                    self.debug("command: %s" % c)
-                    result = ssh_client.execute(c)
-                    self.debug("Result: %s" % result)
-
-                uuids.append(result)
-                # Unmount the Sec Storage
-                cmds = [
-                    "umount %s" % (self.services["mount_dir"]),
-                    ]
-                for c in cmds:
-                    self.debug("command: %s" % c)
-                    result = ssh_client.execute(c)
-                    self.debug("Result: %s" % result)
-
-            except Exception as e:
-                self.fail("SSH failed for management server: %s - %s" %
-                                (self.services["mgmt_server"]["ipaddress"], e))
-
-        res = str(uuids)
-        self.assertNotEqual(
-                        res.count(snapshot_uuid),
-                        1,
-                        "Check snapshot UUID in secondary storage and database"
-                        )
-        return
-
-
-class TestSnapshotDetachedDisk(cloudstackTestCase):
-
-    @classmethod
-    def setUpClass(cls):
-        cls.api_client = super(TestSnapshotDetachedDisk, 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.services['mode'] = cls.zone.networktype
-
-        cls.disk_offering = DiskOffering.create(
-                                    cls.api_client,
-                                    cls.services["disk_offering"]
-                                    )
-        template = get_template(
-                            cls.api_client,
-                            cls.zone.id,
-                            cls.services["ostype"]
-                            )
-        cls.services["server"]["zoneid"] = cls.zone.id
-        cls.services["server"]["diskoffering"] = cls.disk_offering.id
-
-        cls.services["template"] = template.id
-
-        #determine device type from hypervisor
-        hosts = Host.list(cls.api_client, id=cls.virtual_machine.hostid)
-        if len(hosts) > 0 and hosts[0].hypervisor.lower() == "kvm":
-            cls.service["volume"]["diskdevice"] = "/dev/vdb"
-
-        # Create VMs, NAT Rules etc
-        cls.account = Account.create(
-                            cls.api_client,
-                            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.virtual_machine = VirtualMachine.create(
-                                cls.api_client,
-                                cls.services["server"],
-                                templateid=template.id,
-                                accountid=cls.account.name,
-                                domainid=cls.account.domainid,
-                                serviceofferingid=cls.service_offering.id,
-                                mode=cls.services["mode"]
-                                )
-        cls._cleanup = [
-                        cls.service_offering,
-                        cls.disk_offering,
-                        cls.account,
-                        ]
-        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 created instance, volumes and snapshots
-            cleanup_resources(self.apiclient, self.cleanup)
-        except Exception as e:
-            raise Exception("Warning: Exception during cleanup : %s" % e)
-        return
-
-    @attr(speed = "slow")
-    @attr(tags = ["advanced", "advancedns", "basic", "sg"])
-    def test_03_snapshot_detachedDisk(self):
-        """Test snapshot from detached disk
-        """
-        # Validate the following
-        # 1. login in VM  and write some data on data disk(use fdisk to
-        #    partition datadisk,fdisk /dev/sdb, and make filesystem using
-        #    mkfs.ext3)
-        # 2. Detach the data disk and write some data on data disk
-        # 3. perform the snapshot on the detached volume
-        # 4. listvolumes with VM id shouldn't show the detached volume
-        # 5. listSnapshots should list the snapshot that was created
-        # 6. verify that secondary storage NFS share contains the reqd volume
-        #    under /secondary/snapshots/$accountid/$volumeid/$snapshot_uuid
-        # 7. verify backup_snap_id was non null in the `snapshots` table
-
-        volumes = list_volumes(
-                               self.apiclient,
-                               virtualmachineid=self.virtual_machine.id,
-                               type='DATADISK',
-                               listall=True
-                               )
-        self.assertEqual(
-                            isinstance(volumes, list),
-                            True,
-                            "Check list response returns a valid list"
-                        )
-        volume = volumes[0]
-        random_data_0 = random_gen(100)
-        random_data_1 = random_gen(100)
-        try:
-            ssh_client = self.virtual_machine.get_ssh_client()
-
-            #Format partition using ext3
-            format_volume_to_ext3(
-                              ssh_client,
-                              self.services["volume"]["diskdevice"]
-                              )
-            cmds = [
-                    "mkdir -p %s" % self.services["mount_dir"],
-                    "mount %s1 %s" % (
-                                      self.services["diskdevice"],
-                                      self.services["mount_dir"]
-                                      ),
-                    "pushd %s" % self.services["mount_dir"],
-                    "mkdir -p %s/{%s,%s} " % (
-                                                self.services["sub_dir"],
-                                                self.services["sub_lvl_dir1"],
-                                                self.services["sub_lvl_dir2"]
-                                            ),
-                    "echo %s > %s/%s/%s" % (
-                                               random_data_0,
-                                                self.services["sub_dir"],
-                                                self.services["sub_lvl_dir1"],
-                                                self.services["random_data"]
-                                            ),
-                    "echo %s > %s/%s/%s" % (
-                                                random_data_1,
-                                                self.services["sub_dir"],
-                                                self.services["sub_lvl_dir2"],
-                                                self.services["random_data"]
-                                            ),
-                    "sync",
-                ]
-            for c in cmds:
-                self.debug(ssh_client.execute(c))
-
-            #detach volume from VM
-            cmd = detachVolume.detachVolumeCmd()
-            cmd.id = volume.id
-            self.apiclient.detachVolume(cmd)
-
-            #Create snapshot from detached volume
-            snapshot = Snapshot.create(self.apiclient, volume.id)
-            self.cleanup.append(snapshot)
-
-            volumes = list_volumes(
-                               self.apiclient,
-                               virtualmachineid=self.virtual_machine.id,
-                               type='DATADISK',
-                               listall=True
-                               )
-
-            self.assertEqual(
-                            volumes,
-                            None,
-                            "Check Volume is detached"
-                      )
-
-            # Verify the snapshot was created or not
-            snapshots = list_snapshots(
-                                   self.apiclient,
-                                   id=snapshot.id
-                                   )
-            self.assertNotEqual(
-                            snapshots,
-                            None,
-                            "Check if result exists in list snapshots call"
-                            )
-            self.assertEqual(
-                            snapshots[0].id,
-                            snapshot.id,
-                            "Check snapshot id in list resources call"
-                        )
-        except Exception as e:
-            self.fail("SSH failed for VM with IP: %s - %s" %
-                                (self.virtual_machine.ipaddress, e))
-
-        # Fetch values from database
-        qresultset = self.dbclient.execute(
-                        "select backup_snap_id, account_id, volume_id from snapshots where uuid = '%s';" \
-                        % snapshot.id
-                        )
-        self.assertNotEqual(
-                            len(qresultset),
-                            0,
-                            "Check DB Query result set"
-                            )
-
-        qresult = qresultset[0]
-        snapshot_uuid = qresult[0]      # backup_snap_id = snapshot UUID
-        account_id = qresult[1]
-        volume_id = qresult[2]
-
-        self.assertNotEqual(
-                            str(qresult[0]),
-                            'NULL',
-                            "Check if backup_snap_id is not null"
-                        )
-
-        # Get the Secondary Storage details from  list Hosts
-        hosts = list_hosts(
-                                 self.apiclient,
-                                 type='SecondaryStorage',
-                                 zoneid=self.zone.id
-                                 )
-        self.assertEqual(
-                            isinstance(hosts, list),
-                            True,
-                            "Check list response returns a valid list"
-                        )
-        uuids = []
-        for host in hosts:
-            # hosts[0].name = "nfs://192.168.100.21/export/test"
-            parse_url = (host.name).split('/')
-            # parse_url = ['nfs:', '', '192.168.100.21', 'export', 'test']
-
-            # Stripping end ':' from storage type
-            storage_type = parse_url[0][:-1]
-
-            # Split IP address and export path from name
-            sec_storage_ip = parse_url[2]
-            # Sec Storage IP: 192.168.100.21
-
-            if sec_storage_ip[-1] != ":":
-                sec_storage_ip = sec_storage_ip + ":"
-
-            export_path = '/'.join(parse_url[3:])
-            # Export path: export/test
-
-            # Sleep to ensure that snapshot is reflected in sec storage
-            time.sleep(self.services["sleep"])
-            try:
-                # Login to Management server to check snapshot present on
-                # sec disk
-                ssh_client = remoteSSHClient(
-                                    self.services["mgmt_server"]["ipaddress"],
-                                    self.services["mgmt_server"]["port"],
-                                    self.services["mgmt_server"]["username"],
-                                    self.services["mgmt_server"]["password"],
-                                    )
-
-                cmds = [
-                    "mkdir -p %s" % self.services["mount_dir"],
-                    "mount -t %s %s/%s %s" % (
-                                         storage_type,
-                                         sec_storage_ip,
-                                         export_path,
-                                         self.services["mount_dir"]
-                                         ),
-                    "ls %s/snapshots/%s/%s" % (
-                                               self.services["mount_dir"],
-                                               account_id,
-                                               volume_id
-                                               ),
-                        ]
-
-                for c in cmds:
-                    result = ssh_client.execute(c)
-
-                uuids.append(result)
-                # Unmount the Sec Storage
-                cmds = [
-                        "umount %s" % (self.services["mount_dir"]),
-                        ]
-                for c in cmds:
-                    result = ssh_client.execute(c)
-            except Exception as e:
-                self.fail("SSH failed for management server: %s - %s" %
-                                (self.services["mgmt_server"]["ipaddress"], e))
-
-        res = str(uuids)
-        self.assertEqual(
-                        res.count(snapshot_uuid),
-                        1,
-                        "Check snapshot UUID in secondary storage and database"
-                        )
-        return
-
-
-class TestSnapshotLimit(cloudstackTestCase):
-
-    @classmethod
-    def setUpClass(cls):
-        cls.api_client = super(TestSnapshotLimit, 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.services['mode'] = cls.zone.networktype
-
-        template = get_template(
-                            cls.api_client,
-                            cls.zone.id,
-                            cls.services["ostype"]
-                            )
-        cls.services["server"]["zoneid"] = cls.zone.id
-
-        cls.services["template"] = template.id
-
-        # Create VMs, NAT Rules etc
-        cls.account = Account.create(
-                            cls.api_client,
-                            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.virtual_machine = VirtualMachine.create(
-                                cls.api_client,
-                                cls.services["server"],
-                                templateid=template.id,
-                                accountid=cls.account.name,
-                                domainid=cls.account.domainid,
-                                serviceofferingid=cls.service_offering.id
-                                )
-        cls._cleanup = [
-                        cls.service_offering,
-                        cls.account,
-                        ]
-        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 created instance, volumes and snapshots
-            cleanup_resources(self.apiclient, self.cleanup)
-        except Exception as e:
-            raise Exception("Warning: Exception during cleanup : %s" % e)
-        return
-
-    @attr(speed = "slow")
-    @attr(tags = ["advanced", "advancedns"])
-    def test_04_snapshot_limit(self):
-        """Test snapshot limit in snapshot policies
-        """
-        # Validate the following
-        # 1. Perform hourly recurring snapshot on the root disk of VM and keep
-        #    the maxsnapshots as 1
-        # 2. listSnapshots should list the snapshot that was created
-        #    snapshot folder in secondary storage should contain only one
-        #    snapshot image(/secondary/snapshots/$accountid/$volumeid/)
-
-        # Get the Root disk of VM
-        volumes = list_volumes(
-                            self.apiclient,
-                            virtualmachineid=self.virtual_machine.id,
-                            type='ROOT',
-                            listall=True
-                            )
-        self.assertEqual(
-                            isinstance(volumes, list),
-                            True,
-                            "Check list response returns a valid list"
-                        )
-        volume = volumes[0]
-
-        # Create a snapshot policy
-        recurring_snapshot = SnapshotPolicy.create(
-                                           self.apiclient,
-                                           volume.id,
-                                           self.services["recurring_snapshot"]
-                                        )
-        self.cleanup.append(recurring_snapshot)
-
-        snapshot_policy = list_snapshot_policy(
-                                        self.apiclient,
-                                        id=recurring_snapshot.id,
-                                        volumeid=volume.id
-                                        )
-        self.assertEqual(
-                            isinstance(snapshot_policy, list),
-                            True,
-                            "Check list response returns a valid list"
-                        )
-
-        self.assertNotEqual(
-                            snapshot_policy,
-                            None,
-                            "Check if result exists in list item call"
-                            )
-
-        self.assertEqual(
-                        snapshot_policy[0].id,
-                        recurring_snapshot.id,
-                        "Check recurring snapshot id in list resources call"
-                        )
-        self.assertEqual(
-                        snapshot_policy[0].maxsnaps,
-                        self.services["recurring_snapshot"]["maxsnaps"],
-                        "Check interval type in list resources call"
-                        )
-        # Sleep for (maxsnaps+1) hours to verify
-        # only maxsnaps snapshots are retained
-        time.sleep(
-            (self.services["recurring_snapshot"]["maxsnaps"]) * 3600
-            )
-
-        # Verify the snapshot was created or not
-        snapshots = list_snapshots(
-                        self.apiclient,
-                        volumeid=volume.id,
-                        intervaltype=\
-                        self.services["recurring_snapshot"]["intervaltype"],
-                        snapshottype='RECURRING',
-                        listall=True
-                        )
-
-        self.assertEqual(
-                            isinstance(snapshots, list),
-                            True,
-                            "Check list response returns a valid list"
-                        )
-        self.assertEqual(
-                         len(snapshots),
-                         self.services["recurring_snapshot"]["maxsnaps"],
-                         "Check maximum number of recurring snapshots retained"
-                        )
-        snapshot = snapshots[0]
-        # Sleep to ensure that snapshot is reflected in sec storage
-        time.sleep(self.services["sleep"])
-
-        # Fetch values from database
-        qresultset = self.dbclient.execute(
-                        "select backup_snap_id, account_id, volume_id from snapshots where uuid = '%s';" \
-                        % snapshot.id
-                        )
-        self.assertEqual(
-                            isinstance(qresultset, list),
-                            True,
-                            "Check DBQuery returns a valid list"
-                        )
-        self.assertNotEqual(
-                            len(qresultset),
-                            0,
-                            "Check DB Query result set"
-                            )
-
-        qresult = qresultset[0]
-        snapshot_uuid = qresult[0]      # backup_snap_id = snapshot UUID
-        account_id = qresult[1]
-        volume_id = qresult[2]
-
-        # Get the Secondary Storage details from  list Hosts
-        hosts = list_hosts(
-                                 self.apiclient,
-                                 type='SecondaryStorage',
-                                 zoneid=self.zone.id
-                                 )
-        self.assertEqual(
-                            isinstance(hosts, list),
-                            True,
-                            "Check list response returns a valid list"
-                        )
-        uuids = []
-        for host in hosts:
-            # hosts[0].name = "nfs://192.168.100.21/export/test"
-            parse_url = (host.name).split('/')
-            # parse_url = ['nfs:', '', '192.168.100.21', 'export', 'test']
-
-            # Stripping end ':' from storage type
-            storage_type = parse_url[0][:-1]
-            # Split IP address and export path from name
-            sec_storage_ip = parse_url[2]
-            # Sec Storage IP: 192.168.100.21
-
-            if sec_storage_ip[-1] != ":":
-                sec_storage_ip = sec_storage_ip + ":"
-
-            export_path = '/'.join(parse_url[3:])
-            # Export path: export/test
-            try:
-                # Login to VM to check snapshot present on sec disk
-                ssh_client = remoteSSHClient(
-                                    self.services["mgmt_server"]["ipaddress"],
-                                    self.services["mgmt_server"]["port"],
-                                    self.services["mgmt_server"]["username"],
-                                    self.services["mgmt_server"]["password"],
-                                    )
-
-                cmds = [
-                    "mkdir -p %s" % self.services["mount_dir"],
-                    "mount -t %s %s/%s %s" % (
-                                         storage_type,
-                                         sec_storage_ip,
-                                         export_path,
-                                         self.services["mount_dir"]
-                                         ),
-                    "ls %s/snapshots/%s/%s" % (
-                                               self.services["mount_dir"],
-                                               account_id,
-                                               volume_id
-                                               ),
-                ]
-
-                for c in cmds:
-                    result = ssh_client.execute(c)
-
-                uuids.append(result)
-
-                # Unmount the Sec Storage
-                cmds = [
-                    "umount %s" % (self.services["mount_dir"]),
-                    ]
-                for c in cmds:
-                    result = ssh_client.execute(c)
-            except Exception as e:
-                raise Exception(
-                        "SSH access failed for management server: %s - %s" %
-                                    (self.services["mgmt_server"]["ipaddress"], e))
-
-        res = str(uuids)
-        self.assertEqual(
-                        res.count(snapshot_uuid),
-                        1,
-                        "Check snapshot UUID in secondary storage and database"
-                        )
-        return
-
-
 class TestSnapshotEvents(cloudstackTestCase):
 
     @classmethod


[25/29] git commit: updated refs/heads/master-6-17-stable to 93712c2

Posted by ts...@apache.org.
Test Volumes: do not assume max.volumes attachable to guest

1.Current Implementation assumes 6 as the max volumes that can be
attached to disk.  Actually it depends on the hypervisor capabilities.

2.Modified the script to get the max limit from hypervsior capabilities.

Signed-off-by: sanjeevneelarapu <sa...@citrix.com>
Signed-off-by: Prasanna Santhanam <ts...@apache.org>
(cherry picked from commit 64e3074c7ea74afa3f48c21949335bb9208aca40)


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

Branch: refs/heads/master-6-17-stable
Commit: 8312741cc01dd444c385fccf37974ea033b44058
Parents: c7e2ca5
Author: sanjeevneelarapu <sa...@citrix.com>
Authored: Fri Jun 21 16:00:42 2013 +0530
Committer: Prasanna Santhanam <ts...@apache.org>
Committed: Sat Jun 29 00:52:08 2013 +0530

----------------------------------------------------------------------
 test/integration/component/test_volumes.py | 65 +++++++++++++++++++++++--
 1 file changed, 60 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8312741c/test/integration/component/test_volumes.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_volumes.py b/test/integration/component/test_volumes.py
index 369cefc..e06bac9 100644
--- a/test/integration/component/test_volumes.py
+++ b/test/integration/component/test_volumes.py
@@ -58,7 +58,6 @@ class Services:
                         },
                         "volume": {
                                 "diskname": "TestDiskServ",
-                                "max": 6,
                         },
                          "virtual_machine": {
                                     "displayname": "testVM",
@@ -97,6 +96,7 @@ class TestAttachVolume(cloudstackTestCase):
         # 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.services['mode'] = cls.zone.networktype
         cls.disk_offering = DiskOffering.create(
                                     cls.api_client,
@@ -110,7 +110,25 @@ class TestAttachVolume(cloudstackTestCase):
         cls.services["zoneid"] = cls.zone.id
         cls.services["virtual_machine"]["zoneid"] = cls.zone.id
         cls.services["virtual_machine"]["template"] = template.id
-
+        #get max data volumes limit based on the hypervisor type and version
+        listHost = Host.list(
+                             cls.api_client,
+                             hypervisor = cls.services["virtual_machine"]["hypervisor"],
+                             type ='Routing',
+                             zoneid = cls.zone.id,
+                             podid = cls.pod.id,
+                             )
+        ver = listHost[0].hypervisorversion
+        cmd = listHypervisorCapabilities.listHypervisorCapabilitiesCmd()
+        cmd.hypervisor = cls.services["virtual_machine"]["hypervisor"]
+        res = cls.api_client.listHypervisorCapabilities(cmd)
+        cls.debug('Hypervisor Capabilities: {}'.format(res))
+        for i in range(len(res)):
+            if res[i].hypervisorversion == ver:
+                break
+        max_data_volumes = int(res[i].maxdatavolumeslimit)
+        cls.debug('max data volumes:{}'.format(max_data_volumes))
+        cls.services["volume"]["max"] = max_data_volumes
         # Create VMs, NAT Rules etc
         cls.account = Account.create(
                             cls.api_client,
@@ -368,6 +386,7 @@ class TestAttachDetachVolume(cloudstackTestCase):
         # 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.services['mode'] = cls.zone.networktype
         cls.disk_offering = DiskOffering.create(
                                     cls.api_client,
@@ -381,7 +400,25 @@ class TestAttachDetachVolume(cloudstackTestCase):
         cls.services["zoneid"] = cls.zone.id
         cls.services["virtual_machine"]["zoneid"] = cls.zone.id
         cls.services["virtual_machine"]["template"] = template.id
-
+        #get max data volumes limit based on the hypervisor type and version
+        listHost = Host.list(
+                             cls.api_client,
+                             hypervisor = cls.services["virtual_machine"]["hypervisor"],
+                             type ='Routing',
+                             zoneid = cls.zone.id,
+                             podid = cls.pod.id,
+                             )
+        ver = listHost[0].hypervisorversion
+        cmd = listHypervisorCapabilities.listHypervisorCapabilitiesCmd()
+        cmd.hypervisor = cls.services["virtual_machine"]["hypervisor"]
+        res = cls.api_client.listHypervisorCapabilities(cmd)
+        cls.debug('Hypervisor Capabilities: {}'.format(res))
+        for i in range(len(res)):
+            if res[i].hypervisorversion == ver:
+                break
+        max_data_volumes = int(res[i].maxdatavolumeslimit)
+        cls.debug('max data volumes:{}'.format(max_data_volumes))
+        cls.services["volume"]["max"] = max_data_volumes
         # Create VMs, NAT Rules etc
         cls.account = Account.create(
                             cls.api_client,
@@ -614,6 +651,7 @@ class TestAttachVolumeISO(cloudstackTestCase):
         # 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.services['mode'] = cls.zone.networktype
         cls.disk_offering = DiskOffering.create(
                                     cls.api_client,
@@ -628,14 +666,31 @@ class TestAttachVolumeISO(cloudstackTestCase):
         cls.services["virtual_machine"]["zoneid"] = cls.zone.id
         cls.services["iso"]["zoneid"] = cls.zone.id
         cls.services["virtual_machine"]["template"] = template.id
-
+        #get max data volumes limit based on the hypervisor type and version
+        listHost = Host.list(
+                             cls.api_client,
+                             hypervisor = cls.services["virtual_machine"]["hypervisor"],
+                             type ='Routing',
+                             zoneid = cls.zone.id,
+                             podid = cls.pod.id,
+                             )
+        ver = listHost[0].hypervisorversion
+        cmd = listHypervisorCapabilities.listHypervisorCapabilitiesCmd()
+        cmd.hypervisor = cls.services["virtual_machine"]["hypervisor"]
+        res = cls.api_client.listHypervisorCapabilities(cmd)
+        cls.debug('Hypervisor Capabilities: {}'.format(res))
+        for i in range(len(res)):
+            if res[i].hypervisorversion == ver:
+                break
+        max_data_volumes = int(res[i].maxdatavolumeslimit)
+        cls.debug('max data volumes:{}'.format(max_data_volumes))
+        cls.services["volume"]["max"] = max_data_volumes
         # Create VMs, NAT Rules etc
         cls.account = Account.create(
                             cls.api_client,
                             cls.services["account"],
                             domainid=cls.domain.id
                             )
-
         cls.services["account"] = cls.account.name
         cls.service_offering = ServiceOffering.create(
                                             cls.api_client,


[14/29] git commit: updated refs/heads/master-6-17-stable to 93712c2

Posted by ts...@apache.org.
serviceCapabilityList is case sensitive

Signed-off-by: Prasanna Santhanam <ts...@apache.org>
(cherry picked from commit 24258648bf2fc298318e8cf446b62ecf6b8afef8)


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

Branch: refs/heads/master-6-17-stable
Commit: 4510667f44560afe37f9cf881c37b41425aee796
Parents: 9eeacd1
Author: Prasanna Santhanam <ts...@apache.org>
Authored: Wed Jun 19 12:46:36 2013 +0530
Committer: Prasanna Santhanam <ts...@apache.org>
Committed: Sat Jun 29 00:52:07 2013 +0530

----------------------------------------------------------------------
 test/integration/component/test_netscaler_configs.py         | 2 +-
 test/integration/component/test_netscaler_lb.py              | 2 +-
 test/integration/component/test_netscaler_nw_off.py          | 5 ++---
 test/integration/component/test_vpc_network.py               | 2 +-
 test/integration/component/test_vpc_network_lbrules.py       | 3 ---
 test/integration/component/test_vpc_network_pfrules.py       | 3 ---
 test/integration/component/test_vpc_network_staticnatrule.py | 3 ---
 7 files changed, 5 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4510667f/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 3c18c00..5de0843 100644
--- a/test/integration/component/test_netscaler_configs.py
+++ b/test/integration/component/test_netscaler_configs.py
@@ -104,7 +104,7 @@ class Services:
                                             "UserData": 'VirtualRouter',
                                             "StaticNat": 'VirtualRouter',
                                     },
-                                    "servicecapabilitylist": {
+                                    "serviceCapabilityList": {
                                         "SourceNat": {
                                             "SupportedSourceNatTypes": "peraccount"
                                         },

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4510667f/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 9d06275..534ffb1 100644
--- a/test/integration/component/test_netscaler_lb.py
+++ b/test/integration/component/test_netscaler_lb.py
@@ -93,7 +93,7 @@ class Services:
                                             "UserData": 'VirtualRouter',
                                             "StaticNat": 'VirtualRouter',
                                     },
-                                    "servicecapabilitylist": {
+                                    "serviceCapabilityList": {
                                         "SourceNat": {
                                             "SupportedSourceNatTypes": "peraccount"
                                         },

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4510667f/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 cd3b48e..256d1be 100644
--- a/test/integration/component/test_netscaler_nw_off.py
+++ b/test/integration/component/test_netscaler_nw_off.py
@@ -117,7 +117,7 @@ class Services:
                                             "UserData": 'VirtualRouter',
                                             "StaticNat": 'VirtualRouter',
                                     },
-                                    "servicecapabilitylist": {
+                                    "serviceCapabilityList": {
                                         "SourceNat": {
                                             "SupportedSourceNatTypes": "peraccount"
                                         },
@@ -157,11 +157,10 @@ class Services:
                                     "publicport": 22,
                                     "openfirewall": False,
                          },
-                         "ostypeid": '01853327-513e-4508-9628-f1f55db1946f',
+                         "ostype": 'Cent OS 5.3 (64 bit)',
                          # Cent OS 5.3 (64 bit)
                          "sleep": 60,
                          "timeout": 10,
-                         "mode": 'advanced'
                     }
 
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4510667f/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 a997f43..9d5081f 100644
--- a/test/integration/component/test_vpc_network.py
+++ b/test/integration/component/test_vpc_network.py
@@ -752,7 +752,7 @@ class TestVPCNetwork(cloudstackTestCase):
         self.validate_vpc_network(vpc)
 
         # Enable redundant router capability for the network offering
-        self.services["network"]["servicecapabilitylist"] = {
+        self.services["network"]["serviceCapabilityList"] = {
                                                 "SourceNat": {
                                                     "RedundantRouter": "true",
                                                     },

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4510667f/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 3461bb4..b0357fa 100644
--- a/test/integration/component/test_vpc_network_lbrules.py
+++ b/test/integration/component/test_vpc_network_lbrules.py
@@ -87,8 +87,6 @@ class Services:
                                             "StaticNat": 'VpcVirtualRouter',
                                             "NetworkACL": 'VpcVirtualRouter'
                                         },
-                                    "servicecapabilitylist": {
-                                    },
                                 },
                         "network_offering_no_lb": {
                                     "name": 'VPC Network offering',
@@ -176,7 +174,6 @@ class Services:
                         "ostype": 'CentOS 5.3 (64-bit)',
                         "sleep": 60,
                         "timeout": 10,
-                        "mode": 'advanced'
                     }
 
 class TestVPCNetworkLBRules(cloudstackTestCase):

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4510667f/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 8d1d9ec..b478b6a 100644
--- a/test/integration/component/test_vpc_network_pfrules.py
+++ b/test/integration/component/test_vpc_network_pfrules.py
@@ -84,8 +84,6 @@ class Services:
                     "StaticNat": 'VpcVirtualRouter',
                     "NetworkACL": 'VpcVirtualRouter'
                 },
-                "servicecapabilitylist": {
-                },
             },
             "network_offering_no_lb": {
                 "name": 'VPC Network offering',
@@ -175,7 +173,6 @@ class Services:
             "ostype": 'CentOS 5.3 (64-bit)',
             "sleep": 60,
             "timeout": 10,
-            "mode": 'advanced'
         }
 
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4510667f/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 bed1b52..c5d9e57 100644
--- a/test/integration/component/test_vpc_network_staticnatrule.py
+++ b/test/integration/component/test_vpc_network_staticnatrule.py
@@ -83,8 +83,6 @@ class Services:
                                                         "StaticNat": 'VpcVirtualRouter',
                                                         "NetworkACL": 'VpcVirtualRouter'
                                                     },
-                                                "servicecapabilitylist": {
-                                                },
                                         },
                                 "network_offering_no_lb": {
                                                 "name": 'VPC Network offering',
@@ -174,7 +172,6 @@ class Services:
                                 "ostype": 'CentOS 5.3 (64-bit)',
                                 "sleep": 60,
                                 "timeout": 10,
-                                "mode": 'advanced'
                         }
 
 


[04/29] git commit: updated refs/heads/master-6-17-stable to 93712c2

Posted by ts...@apache.org.
Don't wait for account gc

Account GC is automatic, it's not required to wait for cleanup in the
tearDown method

Signed-off-by: Prasanna Santhanam <ts...@apache.org>
(cherry picked from commit b91978545acd2513754e20b7dfabcbf4b745dd0a)


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

Branch: refs/heads/master-6-17-stable
Commit: 9d4a64c74809ece2246585b9d9bc853bec1fe149
Parents: b952415
Author: Prasanna Santhanam <ts...@apache.org>
Authored: Wed Jun 19 15:16:45 2013 +0530
Committer: Prasanna Santhanam <ts...@apache.org>
Committed: Sat Jun 29 00:52:07 2013 +0530

----------------------------------------------------------------------
 test/integration/component/test_vpc.py | 20 +-------------------
 1 file changed, 1 insertion(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9d4a64c7/test/integration/component/test_vpc.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_vpc.py b/test/integration/component/test_vpc.py
index cc70695..742f6ae 100644
--- a/test/integration/component/test_vpc.py
+++ b/test/integration/component/test_vpc.py
@@ -224,25 +224,7 @@ class TestVPC(cloudstackTestCase):
                                      admin=True,
                                      domainid=self.domain.id
                                      )
-        self.cleanup = [self.account]
-        return
-
-    def tearDown(self):
-        try:
-            #Clean up, terminate the created network offerings
-            cleanup_resources(self.apiclient, self.cleanup)
-            interval = list_configurations(
-                                    self.apiclient,
-                                    name='network.gc.interval'
-                                    )
-            wait = list_configurations(
-                                    self.apiclient,
-                                    name='network.gc.wait'
-                                   )
-            # Sleep to ensure that all resources are deleted
-            time.sleep(int(interval[0].value) + int(wait[0].value))
-        except Exception as e:
-            raise Exception("Warning: Exception during cleanup : %s" % e)
+        self._cleanup.insert(0, self.account)
         return
 
     def validate_vpc_offering(self, vpc_offering):


[20/29] git commit: updated refs/heads/master-6-17-stable to 93712c2

Posted by ts...@apache.org.
CLOUDSTACK-3021: Order removal of resources

Sub domain removed before parent domain. Also fixed indentation issue in
cleanup list of class TestServiceOfferingHierarchy

Signed-off-by: Prasanna Santhanam <ts...@apache.org>
(cherry picked from commit 4c51c60ef7517a7719764da94d81cd082caafdf9)


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

Branch: refs/heads/master-6-17-stable
Commit: 07f28ae5dc0e9cb29dc856286096e5a0179bb698
Parents: 8312741
Author: Gaurav Aradhye <ga...@clogeny.com>
Authored: Thu Jun 20 02:51:17 2013 -0400
Committer: Prasanna Santhanam <ts...@apache.org>
Committed: Sat Jun 29 00:52:08 2013 +0530

----------------------------------------------------------------------
 test/integration/component/test_accounts.py | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/07f28ae5/test/integration/component/test_accounts.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_accounts.py b/test/integration/component/test_accounts.py
index 39ff3ea..ee38c6d 100644
--- a/test/integration/component/test_accounts.py
+++ b/test/integration/component/test_accounts.py
@@ -753,12 +753,12 @@ class TestServiceOfferingHierarchy(cloudstackTestCase):
                             domainid=cls.domain_2.id
                             )
 
-   cls._cleanup = [
-                   cls.account_2,
-                   cls.domain_2,
-                   cls.service_offering,
-                   cls.account_1,
-                   cls.domain_1,
+       cls._cleanup = [
+                       cls.account_2,
+                       cls.domain_2,
+                       cls.service_offering,
+                       cls.account_1,
+                       cls.domain_1,
                        ]
 
         return
@@ -888,11 +888,11 @@ class TesttemplateHierarchy(cloudstackTestCase):
                                             domainid=cls.domain_1.id
                                         )
         cls._cleanup = [
-                        cls.template,
-                        cls.account_1,
                         cls.account_2,
-                        cls.domain_1,
                         cls.domain_2,
+           cls.template,
+                        cls.account_1,
+                        cls.domain_1,
                         ]
         return
 


[17/29] git commit: updated refs/heads/master-6-17-stable to 93712c2

Posted by ts...@apache.org.
Cycle all possible device combinations for ISO attach/detach

Signed-off-by: Prasanna Santhanam <ts...@apache.org>
(cherry picked from commit c1e37f60ac8e3adbb527e29f29d804020dd4b7de)


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

Branch: refs/heads/master-6-17-stable
Commit: c2eb17b416333ed75cc1c13392063fc43b0fc394
Parents: 7733ddb
Author: Prasanna Santhanam <ts...@apache.org>
Authored: Thu Jun 20 16:47:05 2013 +0530
Committer: Prasanna Santhanam <ts...@apache.org>
Committed: Sat Jun 29 00:52:08 2013 +0530

----------------------------------------------------------------------
 test/integration/smoke/test_vm_life_cycle.py | 36 +++++++++++------------
 1 file changed, 18 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c2eb17b4/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 a728347..b54182e 100644
--- a/test/integration/smoke/test_vm_life_cycle.py
+++ b/test/integration/smoke/test_vm_life_cycle.py
@@ -116,7 +116,7 @@ class Services:
                     "name": "Cent OS Template",
                     "passwordenabled": True,
                 },
-            "diskdevice": '/dev/xvdd',
+            "diskdevice": ['/dev/xvdd', '/dev/cdrom', '/dev/sr0', '/dev/cdrom1' ],
             # Disk device where ISO is attached to instance
             "mount_dir": "/mnt/tmp",
             "sleep": 60,
@@ -696,9 +696,9 @@ class TestVMLifeCycle(cloudstackTestCase):
                     )
         return
 
-    @attr(tags = ["advanced", "advancedns", "smoke", "basic", "sg"])
+    @attr(tags = ["advanced", "advancedns", "smoke", "basic", "sg", "needle"])
     def test_10_attachAndDetach_iso(self):
-        """Test for detach ISO to virtual machine"""
+        """Test for attach and detach ISO to virtual machine"""
 
         # Validate the following
         # 1. Create ISO
@@ -747,20 +747,20 @@ class TestVMLifeCycle(cloudstackTestCase):
             self.fail("SSH failed for virtual machine: %s - %s" %
                                 (self.virtual_machine.ipaddress, e))
 
-        cmds = [
-                    "mkdir -p %s" % self.services["mount_dir"],
-                    "mount -rt iso9660 %s %s" \
-                                % (
-                                   self.services["diskdevice"],
-                                   self.services["mount_dir"]
-                                   ),
-            ]
-        for c in cmds:
-            res = ssh_client.execute(c)
-            self.assertEqual(res, [], "Check mount is successful or not")
-            c = "fdisk -l|grep %s|head -1" % self.services["diskdevice"]
-            res = ssh_client.execute(c)
-            #Disk /dev/xvdd: 4393 MB, 4393723904 bytes
+        cmds = [ "mkdir -p %s" % self.services["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"]))
+            if res == []:
+                self.services["mount"] = diskdevice
+                break
+        else:
+            self.skipTest("No mount points matched. Mount was unsuccessful")
+
+        c = "fdisk -l|grep %s|head -1" % self.services["mount"]
+        res = ssh_client.execute(c)
+        self.debug("Found a mount point at %s" % res)
 
         # Res may contain more than one strings depending on environment
         # Split strings to form new list which is used for assertion on ISO size 
@@ -806,7 +806,7 @@ class TestVMLifeCycle(cloudstackTestCase):
                                 (self.virtual_machine.ipaddress, e))
 
         # Check if ISO is properly detached from VM (using fdisk)
-        result = self.services["diskdevice"] in str(res)
+        result = self.services["mount"] in str(res)
 
         self.assertEqual(
                          result,


[10/29] git commit: updated refs/heads/master-6-17-stable to 93712c2

Posted by ts...@apache.org.
Fix vpc network tests and reduce delay by removing wait for cleanup

CIDR dictionary changes in the test causing the subsequent test to fail.
Reinitialize the dictionary at the beginning of the test

Signed-off-by: Prasanna Santhanam <ts...@apache.org>
(cherry picked from commit 7d6b4a4a97ff6c2b7cfa956e765f18b40bc10da0)


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

Branch: refs/heads/master-6-17-stable
Commit: 335920d757ecfd8b9b5e580fe63974d594543fe2
Parents: 9d4a64c
Author: Prasanna Santhanam <ts...@apache.org>
Authored: Wed Jun 19 16:52:45 2013 +0530
Committer: Prasanna Santhanam <ts...@apache.org>
Committed: Sat Jun 29 00:52:07 2013 +0530

----------------------------------------------------------------------
 test/integration/component/test_vpc.py         | 24 +++----
 test/integration/component/test_vpc_network.py | 78 +++------------------
 2 files changed, 20 insertions(+), 82 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/335920d7/test/integration/component/test_vpc.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_vpc.py b/test/integration/component/test_vpc.py
index 742f6ae..63c10aa 100644
--- a/test/integration/component/test_vpc.py
+++ b/test/integration/component/test_vpc.py
@@ -202,7 +202,6 @@ class TestVPC(cloudstackTestCase):
         cls.vpc_off.update(cls.api_client, state='Enabled')
         cls._cleanup = [
                         cls.service_offering,
-                        cls.vpc_off
                         ]
         return
 
@@ -435,7 +434,7 @@ class TestVPC(cloudstackTestCase):
 
     @attr(tags=["advanced", "intervlan"])
     def test_04_delete_vpc_with_networks(self):
-        """ Test delete VPC having with networks
+        """ Test delete VPC having networks
         """
 
         # Validate the following
@@ -757,7 +756,7 @@ class TestVPC(cloudstackTestCase):
                                      self.apiclient,
                                      self.services["account"],
                                 )
-        self.cleanup.append(self.user)
+        self._cleanup.append(self.user)
 
         self.services["vpc"]["cidr"] = "10.1.1.1/16"
         self.debug("creating a VPC network in the account: %s" %
@@ -1841,7 +1840,7 @@ class TestVPC(cloudstackTestCase):
 
     @attr(tags=["advanced", "intervlan"])
     def test_13_deploy_vm_with_vpc_netdomain(self):
-        """ Test deployment of vm in a VPC with netdomain
+        """ Test deployment of vm in a VPC with network domain
         """
 
         # 1. Create VPC with providing networkDomain.
@@ -1918,7 +1917,7 @@ class TestVPC(cloudstackTestCase):
                             self.services["account"]
                             )
         self.debug("Created account: %s" % user.name)
-        self.cleanup.append(user)
+        self._cleanup.append(user)
 
         self.services["vpc"]["cidr"] = "10.1.1.1/16"
         self.debug("creating a VPC network in the account: %s" %
@@ -1999,7 +1998,7 @@ class TestVPC(cloudstackTestCase):
                             self.services["account"]
                             )
         self.debug("Created account: %s" % user.name)
-        self.cleanup.append(user)
+        self._cleanup.append(user)
 
         self.services["vpc"]["cidr"] = "10.1.1.1/16"
         self.debug("creating a VPC network in the account: %s" %
@@ -2075,7 +2074,7 @@ class TestVPC(cloudstackTestCase):
                             self.services["account"]
                             )
         self.debug("Created account: %s" % user.name)
-        self.cleanup.append(user)
+        self._cleanup.append(user)
 
         self.services["vpc"]["cidr"] = "10.1.1.1/16"
         self.debug("creating a VPC network in the account: %s" %
@@ -2159,7 +2158,7 @@ class TestVPC(cloudstackTestCase):
                             self.services["domain_admin"]
                             )
         self.debug("Created account: %s" % domain_admin.name)
-        self.cleanup.append(domain_admin)
+        self._cleanup.append(domain_admin)
         da_apiclient = self.testClient.getUserApiClient(
                                         account=domain_admin.name,
                                         domain=domain_admin.domain,
@@ -2170,7 +2169,7 @@ class TestVPC(cloudstackTestCase):
                             self.services["account"]
                             )
         self.debug("Created account: %s" % user.name)
-        self.cleanup.append(user)
+        self._cleanup.append(user)
 
         self.services["vpc"]["cidr"] = "10.1.1.1/16"
         self.debug("creating a VPC network in the account: %s" %
@@ -2194,8 +2193,7 @@ class TestVPC(cloudstackTestCase):
 
     @attr(tags=["advanced", "intervlan"])
     def test_18_create_net_for_user_diff_domain_by_doadmin(self):
-        """ Test creation of network by domain admin for user from different
-            domain.
+        """ Test creation of network by domain admin for user from different domain
         """
 
         #1. As domain admin account , Create VPC(name,zoneId,cidr,vpcOfferingId,networkDomain) without passing Account/domain ID.
@@ -2211,7 +2209,7 @@ class TestVPC(cloudstackTestCase):
                             self.services["domain_admin"]
                             )
         self.debug("Created account: %s" % domain_admin.name)
-        self.cleanup.append(domain_admin)
+        self._cleanup.append(domain_admin)
         da_apiclient = self.testClient.getUserApiClient(
                                         account=domain_admin.name,
                                         domain=self.services["domain"]["name"],
@@ -2222,7 +2220,7 @@ class TestVPC(cloudstackTestCase):
                             self.services["account"]
                             )
         self.debug("Created account: %s" % user.name)
-        self.cleanup.append(user)
+        self._cleanup.append(user)
 
         self.services["vpc"]["cidr"] = "10.1.1.1/16"
         self.debug("creating a VPC network in the account: %s" %

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/335920d7/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 9d5081f..d76996a 100644
--- a/test/integration/component/test_vpc_network.py
+++ b/test/integration/component/test_vpc_network.py
@@ -72,7 +72,6 @@ class Services:
                 },
                 "serviceCapabilityList": {
                     "SourceNat": {"SupportedSourceNatTypes": "peraccount"},
-                    "Lb": {"lbSchemes": "public", "SupportedLbIsolation": "dedicated"}
                 },
             },
             "network_off_netscaler": {
@@ -95,7 +94,6 @@ class Services:
                 },
                 "serviceCapabilityList": {
                     "SourceNat": {"SupportedSourceNatTypes": "peraccount"},
-                    "Lb": {"lbSchemes": "public", "SupportedLbIsolation": "dedicated"}
                 },
             },
             "network_off_shared": {
@@ -229,25 +227,7 @@ class TestVPCNetwork(cloudstackTestCase):
                                      admin=True,
                                      domainid=self.domain.id
                                      )
-        self.cleanup = [self.account]
-        return
-
-    def tearDown(self):
-        try:
-            #Clean up, terminate the created network offerings
-            cleanup_resources(self.apiclient, self.cleanup)
-            interval = list_configurations(
-                                    self.apiclient,
-                                    name='network.gc.interval'
-                                    )
-            wait = list_configurations(
-                                    self.apiclient,
-                                    name='network.gc.wait'
-                                   )
-            # Sleep to ensure that all resources are deleted
-            time.sleep(int(interval[0].value) + int(wait[0].value))
-        except Exception as e:
-            raise Exception("Warning: Exception during cleanup : %s" % e)
+        self._cleanup.insert(0, self.account)
         return
 
     def validate_vpc_offering(self, vpc_offering):
@@ -394,7 +374,7 @@ class TestVPCNetwork(cloudstackTestCase):
 
     @attr(tags=["advanced", "intervlan"])
     def test_02_create_network_fail(self):
-        """ Test create network in VPC
+        """ Test create network in VPC mismatched services (Should fail)
         """
 
         # Validate the following
@@ -712,7 +692,7 @@ class TestVPCNetwork(cloudstackTestCase):
 
     @attr(tags=["advanced", "intervlan"])
     def test_06_create_network_with_rvr(self):
-        """ Test create network with eredundant router capability
+        """ Test create network with redundant router capability
         """
 
         # Validate the following
@@ -1094,25 +1074,7 @@ class TestVPCNetworkRanges(cloudstackTestCase):
                                      admin=True,
                                      domainid=self.domain.id
                                      )
-        self.cleanup = [self.account]
-        return
-
-    def tearDown(self):
-        try:
-            #Clean up, terminate the created network offerings
-            cleanup_resources(self.apiclient, self.cleanup)
-            interval = list_configurations(
-                                    self.apiclient,
-                                    name='network.gc.interval'
-                                    )
-            wait = list_configurations(
-                                    self.apiclient,
-                                    name='network.gc.wait'
-                                   )
-            # Sleep to ensure that all resources are deleted
-            time.sleep(int(interval[0].value) + int(wait[0].value))
-        except Exception as e:
-            raise Exception("Warning: Exception during cleanup : %s" % e)
+        self._cleanup.insert(0, self.account)
         return
 
     def validate_vpc_offering(self, vpc_offering):
@@ -1365,6 +1327,7 @@ class TestVPCNetworkRanges(cloudstackTestCase):
         # 3. Add network2 with cidr - 10.1.1.1/24  to this VPC
         # 4. Add network3 with cidr - 10.1.1.1/26  to this VPC
         # 5. Network creation in step 3 & 4 should fail.
+        self.services = Services().services
 
         self.debug("Creating a VPC offering")
         vpc_off = VpcOffering.create(
@@ -1606,19 +1569,7 @@ class TestVPCNetworkUpgrade(cloudstackTestCase):
                                      admin=True,
                                      domainid=self.domain.id
                                      )
-        self.cleanup = [self.account]
-        return
-
-    def tearDown(self):
-        try:
-            #Clean up, terminate the created network offerings
-            cleanup_resources(self.apiclient, self.cleanup)
-            wait_for_cleanup(self.apiclient, [
-                                              "network.gc.interval",
-                                              "network.gc.wait"])
-
-        except Exception as e:
-            raise Exception("Warning: Exception during cleanup : %s" % e)
+        self._cleanup.insert(0, self.account)
         return
 
     def validate_vpc_offering(self, vpc_offering):
@@ -1673,8 +1624,7 @@ class TestVPCNetworkUpgrade(cloudstackTestCase):
 
     @attr(tags=["advanced", "intervlan"])
     def test_01_network_services_upgrade(self):
-        """ Test update Network that is part of a VPC to a network offering
-            that has more services.
+        """ Test update Network that is part of a VPC to a network offering that has more services
         """
 
         # Validate the following
@@ -2027,8 +1977,7 @@ class TestVPCNetworkUpgrade(cloudstackTestCase):
 
     @attr(tags=["advanced", "intervlan"])
     def test_02_network_vpcvr2vr_upgrade(self):
-        """ Test update Network that is NOT part of a VPC to a nw offering
-            that has services that are provided by VPCVR and vice versa.
+        """ Test update Network that is NOT part of a VPC to a nw offering that has services that are provided by VPCVR and vice versa
         """
 
         # Validate the following
@@ -2298,7 +2247,6 @@ class TestVPCNetworkGc(cloudstackTestCase):
                 cmd = stopVirtualMachine.stopVirtualMachineCmd()
                 cmd.id = vm.id
                 self.apiclient.stopVirtualMachine(cmd)
-        self.cleanup = []
         return
 
     def tearDown(self):
@@ -2311,15 +2259,7 @@ class TestVPCNetworkGc(cloudstackTestCase):
                                   )
         for vm in vms:
             if vm.state == "Stopped":
-                cmd = startVirtualMachine.startVirtualMachineCmd()
-                cmd.id = vm.id
-                self.apiclient.startVirtualMachine(cmd)
-
-        try:
-            #Clean up, terminate the created network offerings
-            cleanup_resources(self.apiclient, self.cleanup)
-        except Exception as e:
-            raise Exception("Warning: Exception during cleanup : %s" % e)
+                vm.start(self.apiclient)
         return
 
     def validate_vpc_offering(self, vpc_offering):


[12/29] git commit: updated refs/heads/master-6-17-stable to 93712c2

Posted by ts...@apache.org.
Remove invalid references to diskdevice from tests

Signed-off-by: Prasanna Santhanam <ts...@apache.org>
(cherry picked from commit 9e2eeb21ab8da66e50618838f225a4df4ad51309)


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

Branch: refs/heads/master-6-17-stable
Commit: 9d970a032a4a0077cf5884fbd1e5a5bfaf166729
Parents: eeb8a2f
Author: Prasanna Santhanam <ts...@apache.org>
Authored: Tue Jun 18 12:47:50 2013 +0530
Committer: Prasanna Santhanam <ts...@apache.org>
Committed: Sat Jun 29 00:52:07 2013 +0530

----------------------------------------------------------------------
 test/integration/component/test_explicit_dedication.py | 3 ---
 test/integration/component/test_implicit_planner.py    | 3 ---
 test/integration/component/test_redundant_router.py    | 7 -------
 test/integration/component/test_storage_motion.py      | 3 ---
 test/integration/component/test_volumes.py             | 3 ---
 test/integration/smoke/test_nic.py                     | 3 ---
 test/integration/smoke/test_resource_detail.py         | 3 ---
 test/integration/smoke/test_scale_vm.py                | 3 ---
 test/integration/smoke/test_vm_life_cycle.py           | 2 +-
 test/integration/smoke/test_volumes.py                 | 1 -
 10 files changed, 1 insertion(+), 30 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9d970a03/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 21a4904..e1991ac 100644
--- a/test/integration/component/test_explicit_dedication.py
+++ b/test/integration/component/test_explicit_dedication.py
@@ -87,9 +87,6 @@ class Services:
                     "name": "Cent OS Template",
                     "passwordenabled": True,
                 },
-                "diskdevice": '/dev/xvdd',
-                # Disk device where ISO is attached to instance
-                "mount_dir": "/mnt/tmp",
                 "sleep": 60,
                 "timeout": 10,
                 "ostype": 'CentOS 5.3 (64-bit)'

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9d970a03/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 ffcd248..854b481 100644
--- a/test/integration/component/test_implicit_planner.py
+++ b/test/integration/component/test_implicit_planner.py
@@ -80,9 +80,6 @@ class Services:
                     "name": "Cent OS Template",
                     "passwordenabled": True,
                 },
-            "diskdevice": '/dev/xvdd',
-            # Disk device where ISO is attached to instance
-            "mount_dir": "/mnt/tmp",
             "sleep": 60,
             "timeout": 10,
             #Migrate VM to hostid

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9d970a03/test/integration/component/test_redundant_router.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_redundant_router.py b/test/integration/component/test_redundant_router.py
index a87818a..914b174 100644
--- a/test/integration/component/test_redundant_router.py
+++ b/test/integration/component/test_redundant_router.py
@@ -65,13 +65,6 @@ class Services:
                                     "publicport": 22,
                                     "protocol": 'TCP',
                         },
-                        "volume": {
-                                   "diskname": "APP Data Volume",
-                                   "size": 1,
-                                   # in GBs
-                                   "diskdevice": "/dev/xvdb",
-                                   # Data Disk
-                        },
                         "static_nat": {
                                     "startport": 22,
                                     "endport": 22,

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9d970a03/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 0dcc7f8..eda77d1 100644
--- a/test/integration/component/test_storage_motion.py
+++ b/test/integration/component/test_storage_motion.py
@@ -79,9 +79,6 @@ class Services:
                     "name": "Cent OS Template",
                     "passwordenabled": True,
                 },
-            "diskdevice": '/dev/xvdd',
-            # Disk device where ISO is attached to instance
-            "mount_dir": "/mnt/tmp",
             "sleep": 60,
             "timeout": 10,
             #Migrate VM to hostid

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9d970a03/test/integration/component/test_volumes.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_volumes.py b/test/integration/component/test_volumes.py
index 34a0679..369cefc 100644
--- a/test/integration/component/test_volumes.py
+++ b/test/integration/component/test_volumes.py
@@ -26,10 +26,7 @@ from marvin.integration.lib.base import *
 from marvin.integration.lib.common import *
 from marvin.remoteSSHClient import remoteSSHClient
 #Import System modules
-import os
-import urllib
 import time
-import tempfile
 
 
 class Services:

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9d970a03/test/integration/smoke/test_nic.py
----------------------------------------------------------------------
diff --git a/test/integration/smoke/test_nic.py b/test/integration/smoke/test_nic.py
index 8e8d340..0d43a92 100644
--- a/test/integration/smoke/test_nic.py
+++ b/test/integration/smoke/test_nic.py
@@ -122,9 +122,6 @@ class Services:
                 "name": "Cent OS Template",
                 "passwordenabled": True,
             },
-            "diskdevice": '/dev/xvdd',
-            # Disk device where ISO is attached to instance
-            "mount_dir": "/mnt/tmp",
             "sleep": 60,
             "timeout": 10,
             #Migrate VM to hostid

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9d970a03/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 1d5db3a..93bc2ff 100644
--- a/test/integration/smoke/test_resource_detail.py
+++ b/test/integration/smoke/test_resource_detail.py
@@ -91,9 +91,6 @@ class Services:
                     "name": "xs",
                     "passwordenabled": False,
                 },
-            "diskdevice": '/dev/xvdd',
-            # Disk device where ISO is attached to instance
-            "mount_dir": "/mnt/tmp",
             "sleep": 60,
             "timeout": 10,
             #Migrate VM to hostid

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9d970a03/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 e79e126..fd8d61e 100644
--- a/test/integration/smoke/test_scale_vm.py
+++ b/test/integration/smoke/test_scale_vm.py
@@ -85,9 +85,6 @@ class Services:
                     "name": "xs",
                     "passwordenabled": False,
                 },
-            "diskdevice": '/dev/xvdd',
-            # Disk device where ISO is attached to instance
-            "mount_dir": "/mnt/tmp",
             "sleep": 60,
             "timeout": 10,
             #Migrate VM to hostid

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9d970a03/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 9aaa13f..a728347 100644
--- a/test/integration/smoke/test_vm_life_cycle.py
+++ b/test/integration/smoke/test_vm_life_cycle.py
@@ -739,7 +739,7 @@ class TestVMLifeCycle(cloudstackTestCase):
         self.debug("Found %s host" % hosts[0].hypervisor)
 
         if hosts[0].hypervisor.lower() == "kvm":
-            self.services["diskdevice"] = "/dev/vda"
+            self.services["diskdevice"] = "/dev/vdb"
 
         try:
             ssh_client = self.virtual_machine.get_ssh_client()

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9d970a03/test/integration/smoke/test_volumes.py
----------------------------------------------------------------------
diff --git a/test/integration/smoke/test_volumes.py b/test/integration/smoke/test_volumes.py
index 7039c6f..4c4b780 100644
--- a/test/integration/smoke/test_volumes.py
+++ b/test/integration/smoke/test_volumes.py
@@ -80,7 +80,6 @@ class Services:
                         "privateport": 22,
                         "publicport": 22,
                         "protocol": 'TCP',
-                        "diskdevice": "/dev/xvdb",
                         "ostype": 'CentOS 5.5 (64-bit)',
                         "sleep": 10,
                         "timeout": 600,


[18/29] git commit: updated refs/heads/master-6-17-stable to 93712c2

Posted by ts...@apache.org.
Prevent waits at cleanup

Do not wait until gc finishes cleanup of resources. This delays tests
and is dependant on the deployment. Some have large cleanup.intervals.
Assume cleanup succeeds and proceed

Signed-off-by: Prasanna Santhanam <ts...@apache.org>
(cherry picked from commit c8f744dbc36b192620c8b494cc41cfb18e1d81be)


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

Branch: refs/heads/master-6-17-stable
Commit: aaa9fc0482da6b1de86837ae6f6576439590f953
Parents: 335920d
Author: Prasanna Santhanam <ts...@apache.org>
Authored: Wed Jun 19 17:05:24 2013 +0530
Committer: Prasanna Santhanam <ts...@apache.org>
Committed: Sat Jun 29 00:52:08 2013 +0530

----------------------------------------------------------------------
 .../integration/component/test_vpc_offerings.py | 52 +++++---------------
 1 file changed, 11 insertions(+), 41 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/aaa9fc04/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 a111d7d..cf37d90 100644
--- a/test/integration/component/test_vpc_offerings.py
+++ b/test/integration/component/test_vpc_offerings.py
@@ -130,7 +130,6 @@ class Services:
                          # Cent OS 5.3 (64 bit)
                          "sleep": 60,
                          "timeout": 10,
-                         "mode": 'advanced'
                     }
 
 
@@ -181,36 +180,7 @@ class TestVPCOffering(cloudstackTestCase):
                                      admin=True,
                                      domainid=self.domain.id
                                      )
-        self.cleanup = []
-        return
-
-    def tearDown(self):
-        try:
-            #Clean up, terminate the created network offering
-            self.account.delete(self.apiclient)
-            interval = list_configurations(
-                                    self.apiclient,
-                                    name='network.gc.interval'
-                                    )
-            wait = list_configurations(
-                                    self.apiclient,
-                                    name='network.gc.wait'
-                                    )
-            # Sleep to ensure that all resources are deleted
-            time.sleep(int(interval[0].value) + int(wait[0].value))
-            cleanup_resources(self.apiclient, self.cleanup)
-            interval = list_configurations(
-                                    self.apiclient,
-                                    name='network.gc.interval'
-                                    )
-            wait = list_configurations(
-                                    self.apiclient,
-                                    name='network.gc.wait'
-                                    )
-            # Sleep to ensure that all resources are deleted
-            time.sleep(int(interval[0].value) + int(wait[0].value))
-        except Exception as e:
-            raise Exception("Warning: Exception during cleanup : %s" % e)
+        self._cleanup.insert(0, self.account)
         return
 
     def validate_vpc_offering(self, vpc_offering):
@@ -273,7 +243,7 @@ class TestVPCOffering(cloudstackTestCase):
                                      )
 
         self.debug("Check if the VPC offering is created successfully?")
-        self.cleanup.append(vpc_off)
+        self._cleanup.append(vpc_off)
         self.validate_vpc_offering(vpc_off)
         return
 
@@ -581,7 +551,7 @@ class TestVPCOffering(cloudstackTestCase):
                                      self.services["vpc_offering"]
                                      )
 
-        self.cleanup.append(vpc_off)
+        self._cleanup.append(vpc_off)
         self.validate_vpc_offering(vpc_off)
 
         self.debug("Enabling the VPC offering created")
@@ -700,7 +670,7 @@ class TestVPCOffering(cloudstackTestCase):
                                      self.services["vpc_offering"]
                                      )
 
-        self.cleanup.append(vpc_off)
+        self._cleanup.append(vpc_off)
         self.validate_vpc_offering(vpc_off)
 
         self.debug("Enabling the VPC offering created")
@@ -821,7 +791,7 @@ class TestVPCOffering(cloudstackTestCase):
                                      self.services["vpc_offering"]
                                      )
 
-        self.cleanup.append(vpc_off)
+        self._cleanup.append(vpc_off)
         self.validate_vpc_offering(vpc_off)
 
         self.debug("Enabling the VPC offering created")
@@ -934,7 +904,7 @@ class TestVPCOffering(cloudstackTestCase):
                              )
             self.validate_vpc_offering(vpc_off)
             # Appending to cleanup to delete after test
-            self.cleanup.append(vpc_off)
+            self._cleanup.append(vpc_off)
         except Exception as e:
             self.fail("Failed to create the VPC offering - %s" % e)
         return
@@ -958,7 +928,7 @@ class TestVPCOffering(cloudstackTestCase):
                                      self.services["vpc_offering"]
                                      )
 
-        self.cleanup.append(vpc_off)
+        self._cleanup.append(vpc_off)
         self.validate_vpc_offering(vpc_off)
 
         self.debug("Enabling the VPC offering created")
@@ -1054,7 +1024,7 @@ class TestVPCOffering(cloudstackTestCase):
                                      self.apiclient,
                                      self.services["vpc_offering"]
                                      )
-        self.cleanup.append(vpc_off_1)
+        self._cleanup.append(vpc_off_1)
         self.validate_vpc_offering(vpc_off_1)
         self.debug("Disabling the VPC offering created")
         vpc_off_1.update(self.apiclient, state='Disabled')
@@ -1064,7 +1034,7 @@ class TestVPCOffering(cloudstackTestCase):
                                      self.services["vpc_offering"]
                                      )
 
-        self.cleanup.append(vpc_off_2)
+        self._cleanup.append(vpc_off_2)
         self.validate_vpc_offering(vpc_off_2)
         self.debug("Enabling the VPC offering created")
         vpc_off_2.update(self.apiclient, state='Enabled')
@@ -1074,7 +1044,7 @@ class TestVPCOffering(cloudstackTestCase):
                                      self.services["vpc_offering"]
                                      )
 
-        self.cleanup.append(vpc_off_3)
+        self._cleanup.append(vpc_off_3)
         self.validate_vpc_offering(vpc_off_3)
         self.debug("Enabling the VPC offering created")
         vpc_off_3.update(self.apiclient, state='Enabled')
@@ -1083,7 +1053,7 @@ class TestVPCOffering(cloudstackTestCase):
                                      self.apiclient,
                                      self.services["vpc_offering"]
                                      )
-        self.validate_vpc_offering(vpc_off_4)
+        self._cleanup.append(vpc_off_4)
         self.debug("Enabling the VPC offering created")
         vpc_off_4.update(self.apiclient, state='Enabled')