You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ki...@apache.org on 2014/10/21 16:56:39 UTC

[01/50] [abbrv] git commit: updated refs/heads/baremetal-systemvm to 23482b1

Repository: cloudstack
Updated Branches:
  refs/heads/baremetal-systemvm c1aa35fc0 -> 23482b142


Merge branch 'vpc-refactor-clean-for-PR' of https://github.com/schubergphilis/cloudstack


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

Branch: refs/heads/baremetal-systemvm
Commit: 771d05238160764b4eb222d80696a3dce1422fa6
Parents: e4a8bbc 1e87d7b
Author: Daan Hoogland <da...@onecht.net>
Authored: Tue Oct 14 20:14:50 2014 +0200
Committer: Daan Hoogland <da...@onecht.net>
Committed: Tue Oct 14 20:14:50 2014 +0200

----------------------------------------------------------------------
 .../com/cloud/network/element/OvsElement.java   |  139 +-
 .../spring-server-core-managers-context.xml     |   33 +-
 .../network/element/VirtualRouterElement.java   |  423 +--
 .../element/VpcVirtualRouterElement.java        |  162 +-
 .../network/router/CommandSetupHelper.java      | 1029 +++++++
 .../com/cloud/network/router/NetworkHelper.java |   81 +
 .../cloud/network/router/NetworkHelperImpl.java |  757 +++++
 .../cloud/network/router/NicProfileHelper.java  |   31 +
 .../network/router/NicProfileHelperImpl.java    |  110 +
 .../network/router/RouterControlHelper.java     |   70 +
 .../router/VirtualNetworkApplianceManager.java  |   66 +-
 .../VirtualNetworkApplianceManagerImpl.java     | 2738 +++---------------
 .../network/router/VpcNetworkHelperImpl.java    |  154 +
 .../VpcVirtualNetworkApplianceManager.java      |   63 +-
 .../VpcVirtualNetworkApplianceManagerImpl.java  |  972 +------
 .../cloud/network/rules/AdvancedVpnRules.java   |   60 +
 .../com/cloud/network/rules/BasicVpnRules.java  |   48 +
 .../com/cloud/network/rules/DhcpEntryRules.java |   80 +
 .../com/cloud/network/rules/DhcpPvlanRules.java |   67 +
 .../cloud/network/rules/DhcpSubNetRules.java    |  174 ++
 .../com/cloud/network/rules/FirewallRules.java  |   94 +
 .../cloud/network/rules/IpAssociationRules.java |   48 +
 .../cloud/network/rules/LoadBalancingRules.java |   79 +
 .../cloud/network/rules/NetworkAclsRules.java   |   54 +
 .../cloud/network/rules/NicPlugInOutRules.java  |  218 ++
 .../network/rules/PasswordToRouterRules.java    |   66 +
 .../network/rules/PrivateGatewayRules.java      |  150 +
 .../com/cloud/network/rules/RuleApplier.java    |   45 +
 .../cloud/network/rules/RuleApplierWrapper.java |   32 +
 .../network/rules/SshKeyToRouterRules.java      |   89 +
 .../com/cloud/network/rules/StaticNatRules.java |   46 +
 .../cloud/network/rules/StaticRoutesRules.java  |   47 +
 .../cloud/network/rules/UserdataPwdRules.java   |   80 +
 .../network/rules/UserdataToRouterRules.java    |   69 +
 .../rules/VirtualNetworkApplianceFactory.java   |  177 ++
 .../network/rules/VpcIpAssociationRules.java    |   92 +
 .../com/cloud/network/vpc/VpcManagerImpl.java   |   23 +-
 .../topology/AdvancedNetworkTopology.java       |  231 ++
 .../topology/AdvancedNetworkVisitor.java        |  215 ++
 .../network/topology/BasicNetworkTopology.java  |  440 +++
 .../network/topology/BasicNetworkVisitor.java   |  319 ++
 .../network/topology/NetworkTopology.java       |   90 +
 .../topology/NetworkTopologyContext.java        |   52 +
 .../topology/NetworkTopologyVisitor.java        |   63 +
 .../deployment/RouterDeploymentDefinition.java  |  457 +++
 .../RouterDeploymentDefinitionBuilder.java      |  217 ++
 .../VpcRouterDeploymentDefinition.java          |  182 ++
 .../element/VirtualRouterElementTest.java       |   10 +-
 .../network/router/NetworkHelperImplTest.java   |  156 +
 .../network/router/RouterControlHelperTest.java |  105 +
 .../VirtualNetworkApplianceManagerImplTest.java |  283 +-
 .../MockVpcVirtualNetworkApplianceManager.java  |  229 +-
 .../RouterDeploymentDefinitionTest.java         |  941 ++++++
 .../RouterDeploymentDefinitionTestBase.java     |  134 +
 .../VpcRouterDeploymentDefinitionTest.java      |  230 ++
 55 files changed, 9072 insertions(+), 3948 deletions(-)
----------------------------------------------------------------------



[15/50] [abbrv] git commit: updated refs/heads/baremetal-systemvm to 23482b1

Posted by ki...@apache.org.
CLOUDSTACK-7690: Added missing unittest import to test_escalations_volumes.py

fixed pep8 issues

Signed-off-by: SrikanteswaraRao Talluri <ta...@apache.org>


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

Branch: refs/heads/baremetal-systemvm
Commit: bd9d57e20c4f8bd49fd403841cff909016987ced
Parents: 35e05a6
Author: Gaurav Aradhye <ga...@clogeny.com>
Authored: Thu Oct 9 12:58:27 2014 +0530
Committer: SrikanteswaraRao Talluri <ta...@apache.org>
Committed: Wed Oct 15 11:02:33 2014 +0530

----------------------------------------------------------------------
 .../component/test_escalations_volumes.py       | 77 +++++++++++++-------
 1 file changed, 52 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bd9d57e2/test/integration/component/test_escalations_volumes.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_escalations_volumes.py b/test/integration/component/test_escalations_volumes.py
index bf5e37c..7290325 100644
--- a/test/integration/component/test_escalations_volumes.py
+++ b/test/integration/component/test_escalations_volumes.py
@@ -16,10 +16,10 @@
 # under the License.
 
 # Import Local Modules
-from marvin.cloudstackTestCase import cloudstackTestCase
+from marvin.cloudstackTestCase import cloudstackTestCase, unittest
 from marvin.cloudstackAPI import createVolume, createTemplate
 from marvin.lib.utils import (cleanup_resources,
-                              random_gen,validateList)
+                              random_gen, validateList)
 from marvin.lib.base import (Account,
                              VirtualMachine,
                              ServiceOffering,
@@ -34,6 +34,7 @@ from marvin.lib.common import (get_domain,
 from nose.plugins.attrib import attr
 from marvin.codes import PASS
 
+
 class TestVolumes(cloudstackTestCase):
 
     @classmethod
@@ -208,7 +209,7 @@ class TestVolumes(cloudstackTestCase):
                 volume_created.name,
                 "Newly created volume name and the test data\
                 volume name are not matching"
-                )
+            )
 
         # Listing all the volumes again after creation of volumes
         list_volumes_after = Volume.list(
@@ -239,7 +240,7 @@ class TestVolumes(cloudstackTestCase):
             self.services["pagesize"],
             "List Volume response is not matching with\
             the page size length for page 1"
-            )
+        )
 
         # Listing all the volumes in page2
         list_volumes_page2 = Volume.list(
@@ -335,7 +336,7 @@ class TestVolumes(cloudstackTestCase):
             volume_created.name,
             "Newly created volume name and\
             the test data volume name are not matching"
-            )
+        )
         # Listing all the volumes for a user after creating a data volume
         list_volumes_after = Volume.list(
             self.userapiclient,
@@ -464,7 +465,9 @@ class TestVolumes(cloudstackTestCase):
         Step6: Resizing data volume
         """
         if self.hypervisor.lower() in ['hyperv']:
-            raise unittest.SkipTest("This featureis not supported on existing hypervisor. Hence, skipping the test")
+            raise unittest.SkipTest(
+                "This featureis not supported on existing\
+                        hypervisor. Hence, skipping the test")
         # Listing volumes for a user before creating a volume
         list_volumes_before = Volume.list(
             self.userapiclient,
@@ -585,7 +588,9 @@ class TestVolumes(cloudstackTestCase):
         Step6: Resizing custom volume
         """
         if self.hypervisor.lower() in ['hyperv']:
-            raise unittest.SkipTest("This featureis not supported on existing hypervisor. Hence, skipping the test")
+            raise unittest.SkipTest(
+                "This featureis not supported on existing\
+                        hypervisor. Hence, skipping the test")
         # Listing all the disk offerings
         list_disk_offerings = DiskOffering.list(self.apiClient)
 
@@ -710,7 +715,9 @@ class TestVolumes(cloudstackTestCase):
         Step5: Creating Template from Snapshot
         """
         if self.hypervisor.lower() in ['hyperv']:
-            raise unittest.SkipTest("This featureis not supported on existing hypervisor. Hence, skipping the test")
+            raise unittest.SkipTest(
+                "This featureis not supported on existing\
+                        hypervisor. Hence, skipping the test")
         list_volumes_before = Volume.list(
             self.userapiclient,
             listall=self.services["listall"])
@@ -1473,7 +1480,9 @@ class TestVolumes(cloudstackTestCase):
                 list returns none
         """
         if self.hypervisor.lower() in ['hyperv']:
-            raise unittest.SkipTest("This featureis not supported on existing hypervisor. Hence, skipping the test")
+            raise unittest.SkipTest(
+                "This featureis not supported on existing\
+                        hypervisor. Hence, skipping the test")
         list_volumes_before = Volume.list(
             self.userapiclient,
             listall=self.services["listall"])
@@ -1803,7 +1812,7 @@ class TestVolumes(cloudstackTestCase):
         )
         return
 
-    @attr(tags=["advanced","basic","sg"], required_hardware="true")
+    @attr(tags=["advanced", "basic", "sg"], required_hardware="true")
     def test_13_volume_custom_disk_size(self):
         """
         @Desc:Create volume from custom disk offering does not work as expected
@@ -1811,18 +1820,23 @@ class TestVolumes(cloudstackTestCase):
         Step2:Create Volume with size x
         Step3:Attach that volume to a vm
         Step4:Create another volume with size y
-        Step5:Verify that the new volume is created with size Y but not with size X
+        Step5:Verify that the new volume is created with size Y
+              but not with size X
         """
         if self.hypervisor.lower() in ['hyperv']:
-            raise unittest.SkipTest("This featureis not supported on existing hypervisor. Hence, skipping the test")
+            raise unittest.SkipTest(
+                "This featureis not supported on existing\
+                        hypervisor. Hence, skipping the test")
         disk_offering = DiskOffering.create(
             self.api_client,
             self.services["disk_offering"],
             custom=True
         )
-        self.assertIsNotNone(disk_offering,"Failed to create custom disk offering")
+        self.assertIsNotNone(
+            disk_offering,
+            "Failed to create custom disk offering")
         self.cleanup.append(disk_offering)
-        self.services["custom_volume"]["customdisksize"]=2
+        self.services["custom_volume"]["customdisksize"] = 2
         vol1 = Volume.create_custom_disk(
             self.userapiclient,
             self.services["custom_volume"],
@@ -1830,19 +1844,26 @@ class TestVolumes(cloudstackTestCase):
             domainid=self.domain.id,
             diskofferingid=disk_offering.id
         )
-        self.assertIsNotNone(vol1,"Volume creation failed with custom disk size")
+        self.assertIsNotNone(
+            vol1,
+            "Volume creation failed with custom disk size")
         vol1_res = Volume.list(
             self.userapiclient,
             id=vol1.id
         )
-        self.assertEqual(validateList(vol1_res)[0],PASS,"Volume list returned invalid response")
+        self.assertEqual(
+            validateList(vol1_res)[0],
+            PASS,
+            "Volume list returned invalid response")
         self.cleanup.append(vol1)
         vol1_size = vol1_res[0].size
         try:
-            self.virtual_machine.attach_volume(self.userapiclient,vol1)
+            self.virtual_machine.attach_volume(self.userapiclient, vol1)
         except Exception as e:
-            self.fail("Attaching custom data disk to vm failed with error{}".format(e))
-        self.services["custom_volume"]["customdisksize"]=3
+            self.fail(
+                "Attaching custom data disk to vm failed\
+                        with error{}".format(e))
+        self.services["custom_volume"]["customdisksize"] = 3
         vol2 = Volume.create_custom_disk(
             self.userapiclient,
             self.services["custom_volume"],
@@ -1850,22 +1871,28 @@ class TestVolumes(cloudstackTestCase):
             domainid=self.domain.id,
             diskofferingid=disk_offering.id
         )
-        self.assertIsNotNone(vol2,"Failed to create custom data disk with size %s" %
-                             self.services["custom_volume"]["customdisksize"])
+        self.assertIsNotNone(
+            vol2,
+            "Failed to create custom data disk with size %s" %
+            self.services["custom_volume"]["customdisksize"])
         self.cleanup.append(vol2)
         vol2_res = Volume.list(
             self.userapiclient,
             id=vol2.id
         )
-        self.assertEqual(validateList(vol2_res)[0],PASS,"Volume list returned invalid response")
-        vol2_size=vol2_res[0].size
+        self.assertEqual(
+            validateList(vol2_res)[0],
+            PASS,
+            "Volume list returned invalid response")
+        vol2_size = vol2_res[0].size
         self.assertNotEqual(
             vol1_size,
             vol2_size,
-            "Creating volume from custom disk offering does not work as expected"
+            "Creating volume from custom disk offering does not work\
+                    as expected"
         )
         try:
-            self.virtual_machine.detach_volume(self.userapiclient,vol1)
+            self.virtual_machine.detach_volume(self.userapiclient, vol1)
         except Exception as e:
             self.fail("Detaching volume failed with error %s" % e)
         return


[40/50] [abbrv] git commit: updated refs/heads/baremetal-systemvm to 23482b1

Posted by ki...@apache.org.
CLOUDSTACK-7731: UI > Infrastructure > Virtual Routers > group by XXXXXXX view > listView > detailView > add View All link > not show "group by XXXXXXX" in select view dropdown.


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

Branch: refs/heads/baremetal-systemvm
Commit: 7004deb528657c7e5403118926836b7fd19717c0
Parents: a3eaff8
Author: Jessica Wang <je...@apache.org>
Authored: Wed Oct 15 17:02:21 2014 -0700
Committer: Jessica Wang <je...@apache.org>
Committed: Thu Oct 16 12:34:55 2014 -0700

----------------------------------------------------------------------
 ui/scripts/system.js | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7004deb5/ui/scripts/system.js
----------------------------------------------------------------------
diff --git a/ui/scripts/system.js b/ui/scripts/system.js
index f87de62..ef4d7c1 100644
--- a/ui/scripts/system.js
+++ b/ui/scripts/system.js
@@ -9391,7 +9391,16 @@
         subsections: {
             virtualRouters: {
                 sectionSelect: {
-                    label: 'label.select-view'
+                    label: 'label.select-view',
+                    preFilter: function(args) {                    	
+                    	//Only clicking ViewAll Link("view all Virtual Routers") in "Virtual Routers group by XXXXXXX" detailView will have "routerGroupByXXXXXXX" included in args.context
+                        if (("routerGroupByZone" in args.context) || ("routerGroupByPod" in args.context) || ("routerGroupByCluster" in args.context) || ("routerGroupByAccount" in args.context)) {
+                        	return ["routerNoGroup"];
+                        }
+                        else {
+                        	return ["routerNoGroup", "routerGroupByZone", "routerGroupByPod", "routerGroupByCluster", "routerGroupByAccount"];
+                        }
+                    }
                 },
                 sections: {
                     routerNoGroup: {


[41/50] [abbrv] git commit: updated refs/heads/baremetal-systemvm to 23482b1

Posted by ki...@apache.org.
CLOUDSTACK-7731: UI > Infrastructure > Virtual Routers > group by XXXXXXX view > listView > detailView > add View All link > show read-only text "group by zone/pod/cluster/account" in select view area.


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

Branch: refs/heads/baremetal-systemvm
Commit: 6239447f0538b9f0408afc19143c592ba37e6783
Parents: 7004deb
Author: Jessica Wang <je...@apache.org>
Authored: Thu Oct 16 12:01:20 2014 -0700
Committer: Jessica Wang <je...@apache.org>
Committed: Thu Oct 16 12:35:25 2014 -0700

----------------------------------------------------------------------
 ui/scripts/system.js | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6239447f/ui/scripts/system.js
----------------------------------------------------------------------
diff --git a/ui/scripts/system.js b/ui/scripts/system.js
index ef4d7c1..31e991d 100644
--- a/ui/scripts/system.js
+++ b/ui/scripts/system.js
@@ -9394,11 +9394,16 @@
                     label: 'label.select-view',
                     preFilter: function(args) {                    	
                     	//Only clicking ViewAll Link("view all Virtual Routers") in "Virtual Routers group by XXXXXXX" detailView will have "routerGroupByXXXXXXX" included in args.context
-                        if (("routerGroupByZone" in args.context) || ("routerGroupByPod" in args.context) || ("routerGroupByCluster" in args.context) || ("routerGroupByAccount" in args.context)) {
-                        	return ["routerNoGroup"];
-                        }
-                        else {
-                        	return ["routerNoGroup", "routerGroupByZone", "routerGroupByPod", "routerGroupByCluster", "routerGroupByAccount"];
+                        if ("routerGroupByZone" in args.context) {
+                        	return ["routerGroupByZone"]; // read-only (i.e. text "group by Zone") 
+                        } else if ( "routerGroupByPod" in args.context) {
+                        	return ["routerGroupByPod"]; // read-only (i.e. text "group by Pod") 
+                        } else if ("routerGroupByCluster" in args.context) {
+                        	return ["routerGroupByCluster"]; // read-only (i.e. text "group by Cluster") 
+                        } else if ("routerGroupByAccount" in args.context) {
+                        	return ["routerGroupByAccount"]; // read-only (i.e. text "group by Account") 
+                        } else {
+                        	return ["routerNoGroup", "routerGroupByZone", "routerGroupByPod", "routerGroupByCluster", "routerGroupByAccount"]; //editable dropdown 
                         }
                     }
                 },


[39/50] [abbrv] git commit: updated refs/heads/baremetal-systemvm to 23482b1

Posted by ki...@apache.org.
CLOUDSTACK-7736: UI - listView widget - select view dropdown on top of listView - prefilter() - include original args.context when passing it to prefilter().


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

Branch: refs/heads/baremetal-systemvm
Commit: a3eaff8bb689f6d41e85acf8c424a96606edbb05
Parents: 8fb7cfa
Author: Jessica Wang <je...@apache.org>
Authored: Wed Oct 15 17:00:11 2014 -0700
Committer: Jessica Wang <je...@apache.org>
Committed: Thu Oct 16 12:34:26 2014 -0700

----------------------------------------------------------------------
 ui/scripts/ui/widgets/listView.js | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a3eaff8b/ui/scripts/ui/widgets/listView.js
----------------------------------------------------------------------
diff --git a/ui/scripts/ui/widgets/listView.js b/ui/scripts/ui/widgets/listView.js
index 38a9cd5..07b60d9 100644
--- a/ui/scripts/ui/widgets/listView.js
+++ b/ui/scripts/ui/widgets/listView.js
@@ -1589,7 +1589,7 @@
 
             sectionPreFilter = args.sectionSelect.preFilter ?
                 args.sectionSelect.preFilter({
-                    context: cloudStack.context
+                    context: $.extend({}, cloudStack.context, args.context)
                 }) : null;
         } else {
             $sectionSelect.hide();


[33/50] [abbrv] git commit: updated refs/heads/baremetal-systemvm to 23482b1

Posted by ki...@apache.org.
CLOUDSTACK-7739: Add new vGPU types K160Q, K180Q, K280Q to the CloudStack UI.


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

Branch: refs/heads/baremetal-systemvm
Commit: 1f8cf0bee4f3fbe1c673dbc89c627f89d04da51f
Parents: ec6a666
Author: Sanjay Tripathi <sa...@citrix.com>
Authored: Wed Oct 15 11:19:50 2014 +0530
Committer: Sanjay Tripathi <sa...@citrix.com>
Committed: Thu Oct 16 14:38:33 2014 +0530

----------------------------------------------------------------------
 .../configuration/ConfigurationManagerImpl.java     |  9 ---------
 ui/scripts/configuration.js                         | 16 ++++++++++++++--
 2 files changed, 14 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1f8cf0be/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
index 7dac143..1f71c0f 100755
--- a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
+++ b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
@@ -2147,7 +2147,6 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
             }
             detailsVO = new ArrayList<ServiceOfferingDetailsVO>();
             for (Entry<String, String> detailEntry : details.entrySet()) {
-                String value = null;
                 if (detailEntry.getKey().equals(GPU.Keys.pciDevice.toString())) {
                     if (detailEntry.getValue() == null) {
                         throw new InvalidParameterValueException("Please specify a GPU Card.");
@@ -2157,14 +2156,6 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
                     if (detailEntry.getValue() == null) {
                         throw new InvalidParameterValueException("vGPUType value cannot be null");
                     }
-                    for (GPU.vGPUType entry : GPU.vGPUType.values()) {
-                        if (detailEntry.getValue().equals(entry.getType())) {
-                            value = entry.getType();
-                        }
-                    }
-                    if (value == null) {
-                        throw new InvalidParameterValueException("Please specify valid vGPU type");
-                    }
                 }
                 detailsVO.add(new ServiceOfferingDetailsVO(offering.getId(), detailEntry.getKey(), detailEntry.getValue(), true));
             }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1f8cf0be/ui/scripts/configuration.js
----------------------------------------------------------------------
diff --git a/ui/scripts/configuration.js b/ui/scripts/configuration.js
index b074b00..f88ba85 100644
--- a/ui/scripts/configuration.js
+++ b/ui/scripts/configuration.js
@@ -475,8 +475,8 @@
                                             });
 
                                             var vGpuMap = {};
-                                            vGpuMap['Group of NVIDIA Corporation GK107GL [GRID K1] GPUs'] = ['passthrough', 'GRID K100', 'GRID K120Q', 'GRID K140Q'];
-                                            vGpuMap['Group of NVIDIA Corporation GK104GL [GRID K2] GPUs'] = ['passthrough', 'GRID K200', 'GRID K220Q', 'GRID K240Q', 'GRID K260Q'];
+                                            vGpuMap['Group of NVIDIA Corporation GK107GL [GRID K1] GPUs'] = ['passthrough', 'GRID K100', 'GRID K120Q', 'GRID K140Q', 'GRID K160Q', 'GRID K180Q'];
+                                            vGpuMap['Group of NVIDIA Corporation GK104GL [GRID K2] GPUs'] = ['passthrough', 'GRID K200', 'GRID K220Q', 'GRID K240Q', 'GRID K260Q', 'GRID K280Q'];
 
                                             args.$select.change(function() {
                                                 var gpu = $(this).val();
@@ -533,6 +533,14 @@
                                                 description: 'GRID K140Q'
                                             });
                                             items.push({
+                                                id: 'GRID K160Q',
+                                                description: 'GRID K160Q'
+                                            });
+                                            items.push({
+                                                id: 'GRID K180Q',
+                                                description: 'GRID K180Q'
+                                            });
+                                            items.push({
                                                 id: 'GRID K200',
                                                 description: 'GRID K200'
                                             });
@@ -548,6 +556,10 @@
                                                 id: 'GRID K260Q',
                                                 description: 'GRID K260Q'
                                             });
+                                            items.push({
+                                                id: 'GRID K280Q',
+                                                description: 'GRID K280Q'
+                                            });
                                             args.response.success({
                                                 data: items
                                             });


[34/50] [abbrv] git commit: updated refs/heads/baremetal-systemvm to 23482b1

Posted by ki...@apache.org.
Merge remote-tracking branch 'origin/4.5' into merge-master

Conflicts:
	engine/schema/src/com/cloud/upgrade/dao/Upgrade441to450.java
	plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/BaremetalManagerImpl.java
	plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/BaremetalVlanManager.java
	plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/BaremetalVlanManagerImpl.java
	plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalKickStartServiceImpl.java
	plugins/hypervisors/vmware/src/com/cloud/storage/resource/VmwareStorageProcessor.java
	server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
	server/src/com/cloud/network/router/VpcVirtualNetworkApplianceManagerImpl.java
	setup/db/db/schema-441to450.sql
	test/integration/component/test_deploy_vgpu_vm.py
	tools/marvin/marvin/config/test_data.py


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

Branch: refs/heads/baremetal-systemvm
Commit: 148efbb73f0e084614eff62f48ea9fa964c64da8
Parents: 1f8cf0b 420d4e0
Author: Daan Hoogland <da...@onecht.net>
Authored: Thu Oct 16 12:29:37 2014 +0200
Committer: Daan Hoogland <da...@onecht.net>
Committed: Thu Oct 16 12:29:37 2014 +0200

----------------------------------------------------------------------
 api/src/com/cloud/event/EventTypes.java         |   1 -
 .../PrepareKickstartPxeServerCommand.java       |  84 ++++++
 .../core/spring-baremetal-core-context.xml      |   8 +-
 .../baremetal/manager/BaremetalManager.java     |   3 -
 .../baremetal/manager/BaremetalManagerImpl.java |   3 -
 .../baremetal/manager/BaremetalVlanManager.java |   1 -
 .../manager/BaremetalVlanManagerImpl.java       |   7 +-
 .../networkservice/BareMetalResourceBase.java   |  47 +--
 .../BaremetalKickStartPxeResource.java          |   1 +
 .../BaremetalKickStartServiceImpl.java          |  12 +-
 .../networkservice/BaremetalPxeElement.java     |   5 +-
 .../Force10BaremetalSwitchBackend.java          | 116 ++------
 .../PrepareKickstartPxeServerCommand.java       |  83 ------
 .../BaremetalProvisionDoneNotificationCmd.java  |  87 ------
 server/src/com/cloud/configuration/Config.java  |  36 +--
 .../deploy/DeploymentPlanningManagerImpl.java   |  11 +-
 .../VirtualNetworkApplianceManagerImpl.java     |   2 -
 .../com/cloud/resource/ResourceManagerImpl.java |  15 +
 .../com/cloud/storage/VolumeApiServiceImpl.java |  12 +-
 .../cloud/storage/VolumeApiServiceImplTest.java |  24 +-
 .../patches/debian/config/etc/dnsmasq.conf.tmpl |   6 +-
 .../config/opt/cloud/bin/baremetal_snat.sh      |  21 +-
 .../debian/config/opt/cloud/bin/prepare_pxe.sh  |  28 +-
 .../component/test_deploy_vgpu_vm.py            | 291 ++++++++++++++++++-
 .../com/cloud/utils/xmlobject/XmlObject.java    |  15 +-
 .../cloud/utils/xmlobject/XmlObjectParser.java  |  22 +-
 .../cloud/utils/xmlobject/TestXmlObject.java    |   5 -
 27 files changed, 486 insertions(+), 460 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/148efbb7/plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/BaremetalManagerImpl.java
----------------------------------------------------------------------
diff --cc plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/BaremetalManagerImpl.java
index f826ae9,f6a4113..076a1bc
--- a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/BaremetalManagerImpl.java
+++ b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/BaremetalManagerImpl.java
@@@ -118,41 -107,6 +116,40 @@@ public class BaremetalManagerImpl exten
      public List<Class<?>> getCommands() {
          List<Class<?>> cmds = new ArrayList<Class<?>>();
          cmds.add(AddBaremetalHostCmd.class);
-         cmds.add(BaremetalProvisionDoneNotificationCmd.class);
          return cmds;
      }
 +
 +    @Override
 +    public void notifyProvisionDone(BaremetalProvisionDoneNotificationCmd cmd) {
 +        QueryBuilder<HostVO> hq = QueryBuilder.create(HostVO.class);
 +        hq.and(hq.entity().getPrivateMacAddress(), SearchCriteria.Op.EQ, cmd.getMac());
 +        HostVO host = hq.find();
 +        if (host == null) {
 +            throw new CloudRuntimeException(String.format("cannot find host[mac:%s]", cmd.getMac()));
 +        }
 +
 +        _hostDao.loadDetails(host);
 +        String vmName = host.getDetail("vmName");
 +        if (vmName == null) {
 +            throw new CloudRuntimeException(String.format("cannot find any baremetal instance running on host[mac:%s]", cmd.getMac()));
 +        }
 +
 +        QueryBuilder<VMInstanceVO> vmq = QueryBuilder.create(VMInstanceVO.class);
 +        vmq.and(vmq.entity().getInstanceName(), SearchCriteria.Op.EQ, vmName);
 +        VMInstanceVO vm = vmq.find();
 +
 +        if (vm == null) {
 +            throw new CloudRuntimeException(String.format("cannot find baremetal instance[name:%s]", vmName));
 +        }
 +
 +        if (State.Starting != vm.getState()) {
 +            throw new CloudRuntimeException(String.format("baremetal instance[name:%s, state:%s] is not in state of Starting", vmName, vm.getState()));
 +        }
 +
 +        vm.setState(State.Running);
 +        vm.setLastHostId(vm.getHostId());
 +        vmDao.update(vm.getId(), vm);
 +        s_logger.debug(String.format("received baremetal provision done notification for vm[id:%s name:%s] running on host[mac:%s, ip:%s]",
 +                vm.getId(), vm.getInstanceName(), host.getPrivateMacAddress(), host.getPrivateIpAddress()));
 +    }
  }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/148efbb7/plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/BaremetalVlanManager.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/148efbb7/plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/BaremetalVlanManagerImpl.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/148efbb7/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BareMetalResourceBase.java
----------------------------------------------------------------------
diff --cc plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BareMetalResourceBase.java
index ab863dc,fedfb8b..8ed50ef
--- a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BareMetalResourceBase.java
+++ b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BareMetalResourceBase.java
@@@ -58,9 -59,8 +58,7 @@@ import com.cloud.configuration.Config
  import com.cloud.host.Host.Type;
  import com.cloud.hypervisor.Hypervisor;
  import com.cloud.resource.ServerResource;
 -import com.cloud.utils.Pair;
  import com.cloud.utils.component.ManagerBase;
- import com.cloud.utils.db.QueryBuilder;
- import com.cloud.utils.db.SearchCriteria;
  import com.cloud.utils.exception.CloudRuntimeException;
  import com.cloud.utils.script.OutputInterpreter;
  import com.cloud.utils.script.Script;
@@@ -404,12 -391,11 +392,12 @@@ public class BareMetalResourceBase exte
                  VMInstanceVO vm = vms.get(0);
                  SecurityGroupHttpClient client = new SecurityGroupHttpClient();
                  HashMap<String, Pair<Long, Long>> nwGrpStates = client.sync(vm.getInstanceName(), vm.getId(), vm.getPrivateIpAddress());
-                 return new PingRoutingWithNwGroupsCommand(getType(), id, null, nwGrpStates);
+                 return new PingRoutingWithNwGroupsCommand(getType(), id, getHostVmStateReport(), nwGrpStates);
              }
          } else {
 -            return new PingRoutingCommand(getType(), id, getHostVmStateReport());
 +            return new PingRoutingCommand(getType(), id, null);
          }
 +            */
      }
  
      protected Answer execute(IpmISetBootDevCommand cmd) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/148efbb7/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalKickStartServiceImpl.java
----------------------------------------------------------------------
diff --cc plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalKickStartServiceImpl.java
index 7f6b0bf,2786e13..f668155
--- a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalKickStartServiceImpl.java
+++ b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalKickStartServiceImpl.java
@@@ -224,24 -218,20 +223,19 @@@ public class BaremetalKickStartServiceI
              throw new CloudRuntimeException(String.format("cannot find management nic on virtual router[id:%s]", vr.getId()));
          }
  
-         String internalServerIp = _configDao.getValue(Config.BaremetalInternalStorageServer.key());
-         if (internalServerIp == null) {
-             throw new CloudRuntimeException(String.format("please specify 'baremetal.internal.storage.server.ip', which is the http server/nfs server storing kickstart files and ISO files, in global setting"));
-         }
- 
          List<String> tuple =  parseKickstartUrl(profile);
 -        Pair<Boolean, String> ret = SshHelper.sshExecute(mgmtNic.getIp4Address(), 3922, "root", getSystemVMKeyFile(), null,
 -                String.format("/usr/bin/prepare_pxe.sh %s %s %s %s %s", tuple.get(1), tuple.get(2), profile.getTemplate().getUuid(),
 -                        String.format("01-%s", nic.getMacAddress().replaceAll(":", "-")), tuple.get(0))
 -                );
 +        String cmd =  String.format("/opt/cloud/bin/prepare_pxe.sh %s %s %s %s %s %s", tuple.get(1), tuple.get(2), profile.getTemplate().getUuid(),
 +                String.format("01-%s", nic.getMacAddress().replaceAll(":", "-")).toLowerCase(), tuple.get(0), nic.getMacAddress().toLowerCase());
 +        s_logger.debug(String.format("prepare pxe on virtual router[ip:%s], cmd: %s", mgmtNic.getIp4Address(), cmd));
 +        Pair<Boolean, String> ret = SshHelper.sshExecute(mgmtNic.getIp4Address(), 3922, "root", getSystemVMKeyFile(), null, cmd);
          if (!ret.first()) {
              throw new CloudRuntimeException(String.format("failed preparing PXE in virtual router[id:%s], because %s", vr.getId(), ret.second()));
          }
  
-         //String internalServerIp = "10.223.110.231";
 -        //String internalServerIp = _configDao.getValue(Config.BaremetalInternalStorageServer.key());
+         String internalServerIp = "10.223.110.231";
 -        ret = SshHelper.sshExecute(mgmtNic.getIp4Address(), 3922, "root", getSystemVMKeyFile(), null,
 -                String.format("/usr/bin/baremetal_snat.sh %s %s", mgmtNic.getIp4Address(), internalServerIp)
 -                );
 +        cmd = String.format("/opt/cloud/bin/baremetal_snat.sh %s %s %s", mgmtNic.getIp4Address(), internalServerIp, mgmtNic.getGateway());
 +        s_logger.debug(String.format("prepare SNAT on virtual router[ip:%s], cmd: %s", mgmtNic.getIp4Address(), cmd));
 +        ret = SshHelper.sshExecute(mgmtNic.getIp4Address(), 3922, "root", getSystemVMKeyFile(), null, cmd);
          if (!ret.first()) {
              throw new CloudRuntimeException(String.format("failed preparing PXE in virtual router[id:%s], because %s", vr.getId(), ret.second()));
          }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/148efbb7/server/src/com/cloud/deploy/DeploymentPlanningManagerImpl.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/148efbb7/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
----------------------------------------------------------------------
diff --cc server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
index 315bdde,cc9ced4..be7cb37
mode 100644,100755..100644
--- a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
+++ b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/148efbb7/server/src/com/cloud/resource/ResourceManagerImpl.java
----------------------------------------------------------------------
diff --cc server/src/com/cloud/resource/ResourceManagerImpl.java
index c7ba80a,a0a3adf..cdad91e
--- a/server/src/com/cloud/resource/ResourceManagerImpl.java
+++ b/server/src/com/cloud/resource/ResourceManagerImpl.java
@@@ -1631,23 -1631,22 +1631,38 @@@ public class ResourceManagerImpl extend
                  clusterId = c.getId();
              }
          }
+         if (startup instanceof StartupRoutingCommand) {
+             StartupRoutingCommand ssCmd = ((StartupRoutingCommand)startup);
+             List<String> implicitHostTags = ssCmd.getHostTags();
+             if (!implicitHostTags.isEmpty()) {
+                 if (hostTags == null) {
+                     hostTags = _hostTagsDao.gethostTags(host.getId());
+                 }
+                 if (hostTags != null) {
+                     implicitHostTags.removeAll(hostTags);
+                     hostTags.addAll(implicitHostTags);
+                 } else {
+                     hostTags = implicitHostTags;
+                 }
+             }
+         }
  
 +        if (startup instanceof StartupRoutingCommand) {
 +            StartupRoutingCommand ssCmd = ((StartupRoutingCommand)startup);
 +            List<String> implicitHostTags = ssCmd.getHostTags();
 +            if (!implicitHostTags.isEmpty()) {
 +                if (hostTags == null) {
 +                    hostTags = _hostTagsDao.gethostTags(host.getId());
 +                }
 +                if (hostTags != null) {
 +                    implicitHostTags.removeAll(hostTags);
 +                    hostTags.addAll(implicitHostTags);
 +                } else {
 +                    hostTags = implicitHostTags;
 +                }
 +            }
 +        }
 +
          host.setDataCenterId(dc.getId());
          host.setPodId(podId);
          host.setClusterId(clusterId);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/148efbb7/systemvm/patches/debian/config/opt/cloud/bin/baremetal_snat.sh
----------------------------------------------------------------------
diff --cc systemvm/patches/debian/config/opt/cloud/bin/baremetal_snat.sh
index 22e5669,0000000..f35a16f
mode 100755,000000..100755
--- a/systemvm/patches/debian/config/opt/cloud/bin/baremetal_snat.sh
+++ b/systemvm/patches/debian/config/opt/cloud/bin/baremetal_snat.sh
@@@ -1,54 -1,0 +1,35 @@@
 +#!/bin/bash
 +
 +#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.
 +
 +set +u
 +
 +mgmt_nic_ip=$1
 +internal_server_ip=$2
- gateway_ip=$3
 +
 +ip route | grep "$internal_server_ip" > /dev/null
 +
 +if [ $? -ne 0 ]; then
-     ip route add $internal_server_ip via $gateway_ip
++    ip route add $internal_server_ip via $mgmt_nic_ip
 +fi
 +
 +iptables-save | grep -- "-A POSTROUTING -d $internal_server_ip" > /dev/null
 +
 +if [ $? -ne 0 ]; then
 +    iptables -t nat -A POSTROUTING -d $internal_server_ip -j SNAT --to-source $mgmt_nic_ip
 +fi
- 
- 
- iptables-save | grep -- "-A INPUT -i eth0 -p udp -m udp --dport 69 -j ACCEPT" > /dev/null
- if [ $? -ne 0 ]; then
-     iptables -I INPUT -i eth0 -p udp -m udp --dport 69 -j ACCEPT
- fi
- 
- iptables-save | grep -- "-A FORWARD -i eth1 -o eth0 -j ACCEPT" > /dev/null
- if [ $? -ne 0 ]; then
-     iptables -A FORWARD -i eth1 -o eth0 -j ACCEPT
- fi
- 
- rule="-A FORWARD -d $internal_server_ip/32 -i eth0 -o eth1 -j ACCEPT"
- iptables-save | grep -- "$rule" > /dev/null
- if [ $? -ne 0 ]; then 
-     iptables -I FORWARD -d $internal_server_ip/32 -i eth0 -o eth1 -j ACCEPT
- fi
- 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/148efbb7/systemvm/patches/debian/config/opt/cloud/bin/prepare_pxe.sh
----------------------------------------------------------------------
diff --cc systemvm/patches/debian/config/opt/cloud/bin/prepare_pxe.sh
index 5bc1a93,0000000..bd9ece6
mode 100755,000000..100755
--- a/systemvm/patches/debian/config/opt/cloud/bin/prepare_pxe.sh
+++ b/systemvm/patches/debian/config/opt/cloud/bin/prepare_pxe.sh
@@@ -1,77 -1,0 +1,77 @@@
 +#!/bin/sh
 +#
 +# 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.
 +#
 +
 +set +u
 +
 +err_exit() {
 +    echo $1
 +    exit 1
 +}
 +
 +success() {
 +    exit 0
 +}
 +
 +TFTP_ROOT='/opt/tftpboot'
 +PXELINUX_CFG_DIR='/opt/tftpboot/pxelinux.cfg'
 +
 +kernel_nfs_path=$1
 +kernel_file_name=`basename $kernel_nfs_path`
 +initrd_nfs_path=$2
 +initrd_file_name=`basename $initrd_nfs_path`
 +tmpt_uuid=$3
 +pxe_cfg_filename=$4
 +ks_file=$5
 +
- kernel_path=$tmpt_uuid/$kernel_file_name
- initrd_path=$tmpt_uuid/$initrd_file_name
- 
- cat > $PXELINUX_CFG_DIR/$pxe_cfg_filename <<EOF
- DEFAULT default
- PROMPT 1
- TIMEOUT 26
- DISPLAY boot.msg
- LABEL default
- KERNEL $kernel_path
- APPEND ramdisk_size=66000 initrd=$initrd_path ks=$ks_file
- 
- EOF
- 
 +tmpt_dir=$TFTP_ROOT/$tmpt_uuid
 +if [ -d $tmpt_dir ]; then
 +    success
 +fi
 +
 +mkdir -p $tmpt_dir
 +
++kernel_path=$tmpt_uuid/$kernel_file_name
++initrd_path=$tmpt_uuid/$initrd_file_name
++
 +mnt_path=/tmp/$(uuid)
 +
 +mkdir -p $mnt_path
 +mount `dirname $kernel_nfs_path` $mnt_path
 +cp -f $mnt_path/$kernel_file_name $tmpt_dir/$kernel_file_name
 +umount $mnt_path
 +
 +mount `dirname $initrd_nfs_path` $mnt_path
 +cp -f $mnt_path/$initrd_file_name $tmpt_dir/$initrd_file_name
 +umount $mnt_path
 +
++cat > $PXELINUX_CFG_DIR/$pxe_cfg_filename <<EOF
++DEFAULT default
++PROMPT 1
++TIMEOUT 26
++DISPLAY boot.msg
++LABEL default
++KERNEL $kernel_path
++APPEND ramdisk_size=66000 initrd=$initrd_path ks=$ks_file
++
++EOF
++
 +success
 +
 +

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/148efbb7/test/integration/component/test_deploy_vgpu_vm.py
----------------------------------------------------------------------
diff --cc test/integration/component/test_deploy_vgpu_vm.py
index 0284eab,b5af092..6cd6c2c
--- a/test/integration/component/test_deploy_vgpu_vm.py
+++ b/test/integration/component/test_deploy_vgpu_vm.py
@@@ -1172,20 -520,308 +1172,296 @@@ class TestvGPUWindowsVm(cloudstackTestC
          cmd.serviceofferingid = self.destvgpuoffering.id
          self.apiclient.changeServiceForVirtualMachine(cmd)
  
 -        self.debug("Starting VM - ID: %s" % vm.id)
 -        self.start_vm()
 +        self.debug("Starting VM - ID: %s" % vmcard.id)
 +        self.start_life_cycle_vm(vmcard)
          time.sleep(self.testdata["vgpu"]["sleep"])
 -
 +        vm=self.check_for_vm(desttype,self.destvgpuoffering.id,vmcard.id)
              # Ensure that VM is in running state
 -        vm=self.check_for_vm(desttype,self.destvgpuoffering.id,vm.id)
 -        self.check_for_vGPU_resource(vm.hostid,vm.instancename,vm.serviceofferingid,vm.vgpu)
 -        self.delete_vgpu_service_offering(self.destvgpuoffering)
 -        self.delete_vgpu_service_offering(self.sourcevgpuoffering)
 -        self.destroy_vm()
 -        return
 +        if destmodel!="None":
 +           self.check_for_vGPU_resource(vm.hostid,vm.instancename,vm.serviceofferingid,vm.vgpu)
  
 -    @attr(tags = ['advanced', 'basic' , 'vgpu'], required_hardware="true")
 -    def deploy_vm(self,type,model):
 +        self.revert_vm_snapshot(vm)
 +
 +        self.delete_vm_snapshot(vm)
  
 -        self.vgpuoffering=self.vgpu_serviceoffering_creation(type,model)
 -        if self.vgpuoffering is not None:
 -              self.deploy_vGPU_windows_vm(self.vgpuoffering.id,type)
 -              time.sleep(self.testdata["vgpu"]["sleep"])
 -              vm=self.check_for_vm(type,self.vgpuoffering.id,self.virtual_machine.id)
 -              self.check_for_vGPU_resource(vm.hostid,vm.instancename,vm.serviceofferingid,vm.vgpu)
 -              self.destroy_vm()
 -              self.delete_vgpu_service_offering(self.vgpuoffering)
 -        return
  
  
+     def new_template_register(self,guestostype):
+ 
+         template1 = get_windows_template(self.apiclient, self.zone.id ,ostype_desc=guestostype)
+ 
+         if  template1 == FAILED:
+             if "http://pleaseupdateURL/dummy.vhd" in cls.testdata["vgpu"] [guestostype]["url"]:
+                 raise unittest.SkipTest("Check Test Data file if it has the valid template URL")
+             template1 = Template.register(
+                    self.apiclient,
+                    self.testdata["vgpu"] [guestostype],
+                    hypervisor = "XenServer",
+                    zoneid=cls.zone.id,
+                    domainid=cls.account.domainid,
+                    account=cls.account.name
+                    )
+             timeout = self.testdata["vgpu"]["timeout"]
+ 
+             while True:
+                   time.sleep(self.testdata["vgpu"]["sleep"])
+                   list_template_response = Template.list(
+                        self.apiclient,
+                        templatefilter=\
+                        self.testdata["templatefilter"],
+                        id=template1.id
+                         )
+                   if (isinstance(list_template_response, list)) is not True:
+                       raise unittest.SkipTest("Check list template api response returns a valid list")
+ 
+                   if len(list_template_response) is None :
+                       raise unittest.SkipTest("Check template registered is in List Templates")
+ 
+                   template_response = list_template_response[0]
+                   if template_response.isready == True:
+                       break
+                   if timeout == 0:
+                       raise unittest.SkipTest("Failed to download template(ID: %s)" % template_response.id)
+ 
+                   timeout = timeout - 1
+         return(template1.id)
+ 
+     def deploy_vm_lifecycle(self):
+         """
+         Create Service Offerings for Both K1 and K2 cards to be used for VM life cycle tests
+         """
+ 
+         if(self.k1hosts != 0):
+             if(self.k140qgpuhosts != 0):
+                 gtype = "GRID K140Q"
+             elif(self.k120qgpuhosts != 0):
+                 gtype = "GRID K120Q"
+             elif(self.k100gpuhosts !=0):
+                 gtype = "GRID K100"
+             else:
+                 gtype = "passthrough"
+ 
+             self.testdata["vgpu"]["service_offerings"][gtype]["serviceofferingdetails"] = [{'pciDevice':'Group of NVIDIA Corporation GK107GL [GRID K1] GPUs'},
+                                                                                        {'vgpuType':gtype}]
+             try:
+                self.__class__.k100_vgpu_service_offering = ServiceOffering.create(
+                                                                     self.apiclient,
+                                                                     self.testdata["vgpu"]["service_offerings"][gtype]
+                                                                     )
+             except Exception as e:
+                self.fail("Failed to create the service offering, %s" % e)
+ 
+         if(self.k2hosts != 0):
+             if(self.k240qgpuhosts != 0):
+                 gtype = "GRID K240Q"
+             elif(cls.k220qgpuhosts != 0):
+                 gtype = "GRID K220Q"
+             elif(self.k200gpuhosts !=0):
+                 gtype = "GRID K200"
+             else:
+                 gtype = "passthrough"
+ 
+             self.testdata["vgpu"]["service_offerings"][gtype]["serviceofferingdetails"] = [{'pciDevice': 'Group of NVIDIA Corporation GK104GL [GRID K2] GPUs'},
+                                                                                        {'vgpuType':gtype}]
+             try:
+                self.__class__.k200_vgpu_service_offering = ServiceOffering.create(
+                                                                     self.apiclient,
+                                                                     self.testdata["vgpu"]["service_offerings"][gtype]
+                                                                     )
+             except Exception as e:
+               self.fail("Failed to create the service offering, %s" % e)
+ 
+         win8templateid=self.new_template_register("Windows 8 (64-bit)")
+         win2012templateid=self.new_template_register("Windows Server 2012 (64-bit)")
+         win7templateid=self.new_template_register("Windows 7 (64-bit)")
+ 
+         """
+         Create Virtual Machines for Both K1 and K2 cards to be used for VM life cycle tests
+         """
+ 
+         if(self.k1hosts != 0):
+             self.__class__.vm_k1_card = VirtualMachine.create(
+             self.apiclient,
+             self.testdata["virtual_machine"],
+             accountid=self.account.name,
+             zoneid=self.zone.id,
+             domainid=self.account.domainid,
+             serviceofferingid=self.k100_vgpu_service_offering.id,
+             templateid=win8templateid
+             )
+         if(self.k2hosts !=0):
+             self.__class__.vm_k2_card = VirtualMachine.create(
+             self.apiclient,
+             self.testdata["virtual_machine"],
+             accountid=self.account.name,
+             zoneid=self.zone.id,
+             domainid=self.account.domainid,
+             serviceofferingid=self.k200_vgpu_service_offering.id,
+             templateid=win2012templateid
+             )
+         if(self.k2hosts !=0):
+             self.__class__.vm2_k2_card = VirtualMachine.create(
+             self.apiclient,
+             self.testdata["virtual_machine"],
+             accountid=self.account.name,
+             zoneid=self.zone.id,
+             domainid=self.account.domainid,
+             serviceofferingid=self.k200_vgpu_service_offering.id,
+             templateid=win7templateid
+             )
+         return
+ 
+ 
+     def check_gpu_resources_released_vm(self,gpuhostid,vm_vgpu_type,rcapacity):
+         hhosts = list_hosts(
+                self.apiclient,
+                hypervisor="XenServer",
+                id=gpuhostid
+                )
+         self.assertEqual(
+                             isinstance(hhosts, list),
+                             True,
+                             "Check list hosts response returns a valid list"
+                         )
+ 
+         self.assertNotEqual(
+                             len(hhosts),
+                             0,
+                             "Check Host details are available in List Hosts"
+                         )
+         for ggroup in hhosts:
+                if ggroup.ipaddress not in self.nongpuhosts:
+                   for gp in ggroup.gpugroup:
+                       #if gp.gpugroupname == "Group of NVIDIA Corporation GK104GL [GRID K2] GPUs":
+                          for gptype in gp.vgpu:
+                              if gptype.vgputype==vm_vgpu_type:
+                                 self.debug("Latest remainingcapacity is %s and before remainingcapacity is %s"%(gptype.remainingcapacity,rcapacity))
+                                 if gptype.remainingcapacity != rcapacity+1:
+                                    self.fail("Host capacity is not updated .GPU resources should be released when VM is stopped/Destroyed ")
+         return
+ 
+     def check_vm_state(self,vmid):
+         list_vm_response = list_virtual_machines(
+                                                      self.apiclient,
+                                                      id=vmid
+                                                      )
+ 
+         if list_vm_response is None:
+             return("Expunge")
+         return(list_vm_response[0].state)
+ 
+     def check_host_vgpu_remaining_capacity(self,gpuhostid,gtype):
+         gputhosts = list_hosts(
+                self.apiclient,
+                hypervisor="XenServer",
+                id=gpuhostid
+                )
+         vgpucapacity=0
+         for ghost in gputhosts:
+             if ghost.gpugroup is not None:
+                         for gp in ghost.gpugroup:
+                             #if gp.gpugroupname == gpucard:
+                                for gptype in gp.vgpu:
+                                    if gptype.vgputype == gtype:
+                                       vgpucapacity=vgpucapacity+gptype.remainingcapacity
+ 
+         return(vgpucapacity)
+ 
+     def verify_vm(self,vm_gpu_card):
+         if(vm_gpu_card):
+           vm_gpu_card.getState(
+                                    self.apiclient,
+                                    "Running")
+ 
+           self.check_for_vGPU_resource(vm_gpu_card.hostid,vm_gpu_card.instancename,vm_gpu_card.serviceofferingid,vm_gpu_card.vgpu)
+ 
+     def stop_life_cycle_vm (self,vm_gpu_card):
+ 
+         if(vm_gpu_card):
+           vm_gpu_card.stop(self.apiclient)
+           time.sleep(self.testdata["vgpu"]["sleep"])
+           vm_gpu_card.getState(
+                                    self.apiclient,
+                                    "Stopped")
+ 
+     def start_life_cycle_vm(self,vm_gpu_card):
+ 
+         if(vm_gpu_card):
+           vm_gpu_card.start(self.apiclient)
+           time.sleep(self.testdata["vgpu"]["sleep"])
+ 
+     def restore_life_cycle_vm(self,vm_gpu_card):
+         if(vm_gpu_card):
+           vm_gpu_card.restore(self.apiclient)
+           time.sleep(self.testdata["vgpu"]["sleep"])
+ 
+     def reboot_life_cycle_vm(self,vm_gpu_card):
+ 
+         if(vm_gpu_card):
+           vm_gpu_card.reboot(self.apiclient)
+           time.sleep(self.testdata["vgpu"]["sleep"])
+ 
+     def delete_vm_life_cycle_vm(self,vm_gpu_card):
+         if(vm_gpu_card):
+           vm_gpu_card.delete(self.apiclient)
+           time.sleep(self.testdata["vgpu"]["sleep"])
+           vm_gpu_card.getState(
+                                    self.apiclient,
+                                    "Destroyed")
+ 
+     def recover_vm_life_cycle_vm(self,vm_gpu_card):
+         if(vm_gpu_card):
+           vm_gpu_card.recover(self.apiclient)
+           vm_gpu_card.getState(
+                                    self.apiclient,
+                                    "Stopped")
+ 
+ 
+     def recovervm(self,vm_gpu_card):
+         if self.check_vm_state(vm_gpu_card.id)=="Expunge":
+             raise unittest.SkipTest("VM is already deleted hence skipping")
+         self.recover_vm_life_cycle_vm(vm_gpu_card)
+         self.start_life_cycle_vm(vm_gpu_card)
+         self.verify_vm(vm_gpu_card)
+         return
+ 
+ 
+     def startvm(self,vm_gpu_card):
+ 
+         self.start_life_cycle_vm(vm_gpu_card)
+         self.verify_vm(vm_gpu_card)
+         return
+ 
+     def stopvm(self,vm_gpu_card):
+ 
+         rcapacity=self.check_host_vgpu_remaining_capacity(vm_gpu_card.hostid,vm_gpu_card.vgpu)
+         self.stop_life_cycle_vm(vm_gpu_card)
+         self.check_gpu_resources_released_vm(vm_gpu_card.hostid,vm_gpu_card.vgpu,rcapacity)
+         return
+ 
+     def deletevm(self,vm_gpu_card):
+ 
+         rcapacity=self.check_host_vgpu_remaining_capacity(vm_gpu_card.hostid,vm_gpu_card.vgpu)
+         hostid=vm_gpu_card.hostid
+         vgputype=vm_gpu_card.vgpu
+         self.delete_vm_life_cycle_vm(vm_gpu_card)
+         self.check_gpu_resources_released_vm(hostid,vgputype,rcapacity)
+         return
+ 
+     def restorevm(self,vm_gpu_card):
+ 
+         self.restore_life_cycle_vm(vm_gpu_card)
+         self.verify_vm(vm_gpu_card)
+         return
+ 
+ 
+     def rebootvm(self,vm_vgpu_card):
+ 
+         self.reboot_life_cycle_vm(vm_vgpu_card)
+         self.verify_vm(vm_vgpu_card)
+         return
+ 
+ 
      def test_01_list_vgpu_host_details(self):
          """   list vGPU host details  """
          hhosts = list_hosts(
@@@ -1494,17 -1130,10 +1770,15 @@@
  
          self.debug("Check if deployed VMs are in running state?")
  
- 
 -        self.verify_vm(self.__class__.vm_k1_card)
 -        self.verify_vm(self.__class__.vm_k2_card)
 -        self.verify_vm(self.__class__.vm2_k2_card)
 +        if self.__class__.vm_k1_card is not None:
 +            self.verify_vm(self.__class__.vm_k1_card)
 +
 +        if self.__class__.vm_k2_card is not None:
 +            self.verify_vm(self.__class__.vm_k2_card)
 +
 +        if self.__class__.vm2_k2_card is not None:
 +            self.verify_vm(self.__class__.vm2_k2_card)
  
- 
          self.__class__.vmlifecycletest=1
          return
  
@@@ -1515,17 -1144,10 +1789,15 @@@
          if self.__class__.vmlifecycletest==0:
              raise unittest.SkipTest("VM Life Cycle Deploy VM test failed hence skipping")
  
- 
 -        self.stopvm(self.__class__.vm_k1_card)
 -        self.stopvm(self.__class__.vm_k2_card)
 -        self.stopvm(self.__class__.vm2_k2_card)
 +        if self.__class__.vm_k1_card:
 +            self.stopvm(self.__class__.vm_k1_card)
 +
 +        if self.__class__.vm_k2_card:
 +            self.stopvm(self.__class__.vm_k2_card)
 +
 +        if self.__class__.vm2_k2_card:
 +            self.stopvm(self.__class__.vm2_k2_card)
  
- 
          return
  
      @attr(tags = ['advanced', 'basic' , 'vgpu'], required_hardware="true")
@@@ -1535,15 -1157,9 +1807,14 @@@
          if self.__class__.vmlifecycletest==0:
              raise unittest.SkipTest("VM Life Cycle Deploy VM test failed hence skipping")
  
- 
 -        self.startvm(self.__class__.vm_k1_card)
 -        self.startvm(self.__class__.vm_k2_card)
 -        self.startvm(self.__class__.vm2_k2_card)
 +        if self.__class__.vm_k1_card:
 +            self.startvm(self.__class__.vm_k1_card)
 +
 +        if self.__class__.vm_k2_card:
 +            self.startvm(self.__class__.vm_k2_card)
 +
 +        if self.__class__.vm2_k2_card:
 +            self.startvm(self.__class__.vm2_k2_card)
  
          return
  
@@@ -1555,15 -1171,10 +1826,13 @@@
          if self.__class__.vmlifecycletest==0:
              raise unittest.SkipTest("VM Life Cycle Deploy VM test failed hence skipping")
  
- 
 -        self.restorevm(self.__class__.vm_k1_card)
 -        self.restorevm(self.__class__.vm_k2_card)
 -        self.restorevm(self.__class__.vm2_k2_card)
 +        if self.__class__.vm_k1_card:
 +            self.restorevm(self.__class__.vm_k1_card)
 +        if self.__class__.vm_k2_card:
 +            self.restorevm(self.__class__.vm_k2_card)
 +        if self.__class__.vm2_k2_card:
 +            self.restorevm(self.__class__.vm2_k2_card)
  
- 
          return
  
      @attr(tags = ['advanced', 'basic' , 'vgpu'], required_hardware="true")
@@@ -1770,19 -1199,12 +2039,24 @@@
          if self.__class__.vmlifecycletest==0:
              raise unittest.SkipTest("VM Life Cycle Deploy VM test failed hence skipping")
  
 +        if self.__class__.vm_k2_card:
 +            self.deletevm(self.__class__.vm_k2_card)
 +
 +        if self.__class__.vm_k1_card:
 +            self.deletevm(self.__class__.vm_k1_card)
 +
 +        if self.__class__.vm2_k2_card:
 +            self.deletevm(self.__class__.vm2_k2_card)
 +
 +        if self.__class__.nonvgpu:
 +            self.deletevm(self.__class__.nonvgpu)
 +
 +        self.cleanup.append(self.__class__.nonvgpu_service_offerin)
+ 
+         self.deletevm(self.__class__.vm_k1_card)
+         self.deletevm(self.__class__.vm_k2_card)
+         self.deletevm(self.__class__.vm2_k2_card)
+ 
 -
          self.cleanup.append(self.__class__.k100_vgpu_service_offering)
          self.cleanup.append(self.__class__.k200_vgpu_service_offering)
  
@@@ -1959,6 -1373,6 +2233,3 @@@
          except Exception as e:
              self.debug("Warning! Exception in tearDown: %s" % e)
  
--
--
--


[46/50] [abbrv] git commit: updated refs/heads/baremetal-systemvm to 23482b1

Posted by ki...@apache.org.
CLOUDSTACK-7749: AsyncJob GC thread cannot purge queue items that have been blocking for too long if exception is thrown in expunging some unfinished or completed old jobs, this will make some future jobs stuck.


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

Branch: refs/heads/baremetal-systemvm
Commit: 248e4fbdacb1372da94cbcf49ca23a14c8c9b514
Parents: a1b913d
Author: Min Chen <mi...@citrix.com>
Authored: Thu Oct 16 18:15:50 2014 -0700
Committer: Min Chen <mi...@citrix.com>
Committed: Fri Oct 17 10:43:59 2014 -0700

----------------------------------------------------------------------
 .../jobs/dao/SyncQueueItemDaoImpl.java          |  2 +-
 .../jobs/impl/AsyncJobManagerImpl.java          | 57 ++++++++++++--------
 2 files changed, 35 insertions(+), 24 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/248e4fbd/framework/jobs/src/org/apache/cloudstack/framework/jobs/dao/SyncQueueItemDaoImpl.java
----------------------------------------------------------------------
diff --git a/framework/jobs/src/org/apache/cloudstack/framework/jobs/dao/SyncQueueItemDaoImpl.java b/framework/jobs/src/org/apache/cloudstack/framework/jobs/dao/SyncQueueItemDaoImpl.java
index 41f1419..167d9f5 100644
--- a/framework/jobs/src/org/apache/cloudstack/framework/jobs/dao/SyncQueueItemDaoImpl.java
+++ b/framework/jobs/src/org/apache/cloudstack/framework/jobs/dao/SyncQueueItemDaoImpl.java
@@ -147,7 +147,7 @@ public class SyncQueueItemDaoImpl extends GenericDaoBase<SyncQueueItemVO, Long>
         SearchBuilder<SyncQueueItemVO> sbItem = createSearchBuilder();
         sbItem.and("lastProcessMsid", sbItem.entity().getLastProcessMsid(), SearchCriteria.Op.NNULL);
         sbItem.and("lastProcessNumber", sbItem.entity().getLastProcessNumber(), SearchCriteria.Op.NNULL);
-        sbItem.and("lastProcessNumber", sbItem.entity().getLastProcessTime(), SearchCriteria.Op.NNULL);
+        sbItem.and("lastProcessTime", sbItem.entity().getLastProcessTime(), SearchCriteria.Op.NNULL);
         sbItem.and("lastProcessTime2", sbItem.entity().getLastProcessTime(), SearchCriteria.Op.LT);
 
         sbItem.done();

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/248e4fbd/framework/jobs/src/org/apache/cloudstack/framework/jobs/impl/AsyncJobManagerImpl.java
----------------------------------------------------------------------
diff --git a/framework/jobs/src/org/apache/cloudstack/framework/jobs/impl/AsyncJobManagerImpl.java b/framework/jobs/src/org/apache/cloudstack/framework/jobs/impl/AsyncJobManagerImpl.java
index 7e65ede..04fab24 100644
--- a/framework/jobs/src/org/apache/cloudstack/framework/jobs/impl/AsyncJobManagerImpl.java
+++ b/framework/jobs/src/org/apache/cloudstack/framework/jobs/impl/AsyncJobManagerImpl.java
@@ -769,46 +769,57 @@ public class AsyncJobManagerImpl extends ManagerBase implements AsyncJobManager,
 
             public void reallyRun() {
                 try {
-                    s_logger.trace("Begin cleanup expired async-jobs");
+                    s_logger.info("Begin cleanup expired async-jobs");
 
-                    Date cutTime = new Date(DateUtil.currentGMTTime().getTime() - JobExpireMinutes.value() * 60000);
+                    // forcefully cancel blocking queue items if they've been staying there for too long
+                    List<SyncQueueItemVO> blockItems = _queueMgr.getBlockedQueueItems(JobCancelThresholdMinutes.value() * 60000, false);
+                    if (blockItems != null && blockItems.size() > 0) {
+                        for (SyncQueueItemVO item : blockItems) {
+                            try {
+                                if (item.getContentType().equalsIgnoreCase(SyncQueueItem.AsyncJobContentType)) {
+                                    s_logger.info("Remove Job-" + item.getContentId() + " from Queue-" + item.getId() + " since it has been blocked for too long");
+                                    completeAsyncJob(item.getContentId(), JobInfo.Status.FAILED, 0, "Job is cancelled as it has been blocking others for too long");
+
+                                    _jobMonitor.unregisterByJobId(item.getContentId());
+                                }
+
+                                // purge the item and resume queue processing
+                                _queueMgr.purgeItem(item.getId());
+                            } catch (Throwable e) {
+                                s_logger.error("Unexpected exception when trying to remove job from sync queue, ", e);
+                            }
+                        }
+                    }
 
+                    Date cutTime = new Date(DateUtil.currentGMTTime().getTime() - JobExpireMinutes.value() * 60000);
                     // limit to 100 jobs per turn, this gives cleanup throughput as 600 jobs per minute
                     // hopefully this will be fast enough to balance potential growth of job table
                     // 1) Expire unfinished jobs that weren't processed yet
                     List<AsyncJobVO> unfinishedJobs = _jobDao.getExpiredUnfinishedJobs(cutTime, 100);
                     for (AsyncJobVO job : unfinishedJobs) {
-                        s_logger.info("Expunging unfinished job " + job);
+                        try {
+                            s_logger.info("Expunging unfinished job-" + job.getId());
 
-                        _jobMonitor.unregisterByJobId(job.getId());
-                        expungeAsyncJob(job);
+                            _jobMonitor.unregisterByJobId(job.getId());
+                            expungeAsyncJob(job);
+                        } catch (Throwable e) {
+                            s_logger.error("Unexpected exception when trying to expunge job-" + job.getId(), e);
+                        }
                     }
 
                     // 2) Expunge finished jobs
                     List<AsyncJobVO> completedJobs = _jobDao.getExpiredCompletedJobs(cutTime, 100);
                     for (AsyncJobVO job : completedJobs) {
-                        s_logger.trace("Expunging completed job " + job);
-
-                        expungeAsyncJob(job);
-                    }
-
-                    // forcefully cancel blocking queue items if they've been staying there for too long
-                    List<SyncQueueItemVO> blockItems = _queueMgr.getBlockedQueueItems(JobCancelThresholdMinutes.value() * 60000, false);
-                    if (blockItems != null && blockItems.size() > 0) {
-                        for (SyncQueueItemVO item : blockItems) {
-                            if (item.getContentType().equalsIgnoreCase(SyncQueueItem.AsyncJobContentType)) {
-                                s_logger.info("Remove Job-" + item.getContentId() + " from Queue-" + item.getId() + " since it has been blocked for too long");
-                                completeAsyncJob(item.getContentId(), JobInfo.Status.FAILED, 0, "Job is cancelled as it has been blocking others for too long");
-
-                                _jobMonitor.unregisterByJobId(item.getContentId());
-                            }
+                        try {
+                            s_logger.info("Expunging completed job-" + job.getId());
 
-                            // purge the item and resume queue processing
-                            _queueMgr.purgeItem(item.getId());
+                            expungeAsyncJob(job);
+                        } catch (Throwable e) {
+                            s_logger.error("Unexpected exception when trying to expunge job-" + job.getId(), e);
                         }
                     }
 
-                    s_logger.trace("End cleanup expired async-jobs");
+                    s_logger.info("End cleanup expired async-jobs");
                 } catch (Throwable e) {
                     s_logger.error("Unexpected exception when trying to execute queue item, ", e);
                 }


[13/50] [abbrv] git commit: updated refs/heads/baremetal-systemvm to 23482b1

Posted by ki...@apache.org.
CLOUDSTACK-7693: Fixing pep8 issues

pep8 fixes for test_routers.py

Signed-off-by: SrikanteswaraRao Talluri <ta...@apache.org>


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

Branch: refs/heads/baremetal-systemvm
Commit: 159a372fddad93cababe64978f5c2b50b431db4f
Parents: 71c9804
Author: Gaurav Aradhye <ga...@clogeny.com>
Authored: Thu Oct 9 15:30:43 2014 +0530
Committer: SrikanteswaraRao Talluri <ta...@apache.org>
Committed: Wed Oct 15 10:58:15 2014 +0530

----------------------------------------------------------------------
 .../component/test_recurring_snapshots.py       |  497 +++---
 test/integration/component/test_routers.py      | 1422 +++++++++---------
 2 files changed, 984 insertions(+), 935 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/159a372f/test/integration/component/test_recurring_snapshots.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_recurring_snapshots.py b/test/integration/component/test_recurring_snapshots.py
index faa6787..58dd769 100644
--- a/test/integration/component/test_recurring_snapshots.py
+++ b/test/integration/component/test_recurring_snapshots.py
@@ -16,110 +16,125 @@
 # under the License.
 
 from nose.plugins.attrib import attr
-from marvin.cloudstackTestCase import *
-from marvin.cloudstackAPI import *
-from marvin.lib.utils import *
-from marvin.lib.base import *
-from marvin.lib.common import *
+from marvin.cloudstackTestCase import cloudstackTestCase
+from marvin.lib.utils import (cleanup_resources)
+from marvin.lib.base import (Account,
+                             DiskOffering,
+                             ServiceOffering,
+                             VirtualMachine,
+                             SnapshotPolicy)
+from marvin.lib.common import (get_zone,
+                               get_domain,
+                               get_template,
+                               list_snapshots,
+                               list_volumes,
+                               list_snapshot_policy
+                               )
+import time
+
 
 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
+            "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,
-                    }
+            },
+            "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
+                # Data Disk
+                "diskdevice": ['/dev/xvdb', '/dev/sdb',
+                               '/dev/hdb', '/dev/vdb'],
+            },
+            "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):
@@ -135,14 +150,14 @@ class TestRecurringSnapshots(cloudstackTestCase):
         cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
         cls.services['mode'] = cls.zone.networktype
         cls.disk_offering = DiskOffering.create(
-                                    cls.api_client,
-                                    cls.services["disk_offering"]
-                                    )
+            cls.api_client,
+            cls.services["disk_offering"]
+        )
         template = get_template(
-                            cls.api_client,
-                            cls.zone.id,
-                            cls.services["ostype"]
-                            )
+            cls.api_client,
+            cls.zone.id,
+            cls.services["ostype"]
+        )
 
         cls.services["domainid"] = cls.domain.id
         cls.services["server_with_disk"]["zoneid"] = cls.zone.id
@@ -156,48 +171,48 @@ class TestRecurringSnapshots(cloudstackTestCase):
 
         # Create VMs, NAT Rules etc
         cls.account = Account.create(
-                            cls.api_client,
-                            cls.services["account"],
-                            domainid=cls.domain.id
-                            )
+            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.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"]
-                                )
+            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"]
-                                    )
+            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,
-                        ]
+            cls.service_offering,
+            cls.disk_offering,
+            cls.account,
+        ]
         return
 
     @classmethod
     def tearDownClass(cls):
         try:
-            #Cleanup resources used
+            # Cleanup resources used
             cleanup_resources(cls.api_client, cls._cleanup)
         except Exception as e:
             raise Exception("Warning: Exception during cleanup : %s" % e)
@@ -211,82 +226,81 @@ class TestRecurringSnapshots(cloudstackTestCase):
 
     def tearDown(self):
         try:
-            #Clean up, terminate the created instance, volumes and snapshots
+            # 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(speed="slow")
     @attr(tags=["advanced", "advancedns", "smoke"], required_hardware="false")
     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
+        # 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.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"
-                        )
+            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.apiclient,
+            volume[0].id,
+            self.services["recurring_snapshot"]
+        )
         self.cleanup.append(recurring_snapshot)
 
-        #ListSnapshotPolicy should return newly created policy
+        # ListSnapshotPolicy should return newly created policy
         list_snapshots_policy = list_snapshot_policy(
-                                                     self.apiclient,
-                                                     id=recurring_snapshot.id,
-                                                     volumeid=volume[0].id
-                                                     )
+            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"
-                        )
+            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"
-                            )
+            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"
-                        )
+            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"
-                        )
+            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
-                        )
+                self.apiclient,
+                volumeid=volume[0].id,
+                intervaltype=self.services["recurring_snapshot"]
+                ["intervaltype"],
+                snapshottype='RECURRING',
+                listall=True)
 
             if isinstance(snapshots, list):
                 break
@@ -298,92 +312,91 @@ class TestRecurringSnapshots(cloudstackTestCase):
             timeout = timeout - 1
 
         self.assertEqual(
-                            isinstance(snapshots, list),
-                            True,
-                            "Check list response returns a valid list"
-                        )
+            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"
-                        )
+            len(snapshots),
+            self.services["recurring_snapshot"]["maxsnaps"],
+            "Check maximum number of recurring snapshots retained"
+        )
         return
 
-    @attr(speed = "slow")
+    @attr(speed="slow")
     @attr(tags=["advanced", "advancedns", "smoke"], required_hardware="false")
     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
+        # 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.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"
-                        )
+            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.apiclient,
+            volume[0].id,
+            self.services["recurring_snapshot"]
+        )
         self.cleanup.append(recurring_snapshot)
-        #ListSnapshotPolicy should return newly created policy
+        # ListSnapshotPolicy should return newly created policy
         list_snapshots_policy = list_snapshot_policy(
-                                                     self.apiclient,
-                                                     id=recurring_snapshot.id,
-                                                     volumeid=volume[0].id
-                                                     )
+            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"
-                        )
+            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"
-                            )
+            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"
-                        )
+            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"
-                        )
+            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
-                            )
+                self.apiclient,
+                volumeid=volume[0].id,
+                intervaltype=self.services["recurring_snapshot"]
+                ["intervaltype"],
+                snapshottype='RECURRING',
+                listall=True)
 
             if isinstance(snapshots, list):
                 break
@@ -395,13 +408,13 @@ class TestRecurringSnapshots(cloudstackTestCase):
             timeout = timeout - 1
 
         self.assertEqual(
-                            isinstance(snapshots, list),
-                            True,
-                            "Check list response returns a valid list"
-                        )
+            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"
-                         )
+            len(snapshots),
+            self.services["recurring_snapshot"]["maxsnaps"],
+            "Check maximum number of recurring snapshots retained"
+        )
         return


[31/50] [abbrv] git commit: updated refs/heads/baremetal-systemvm to 23482b1

Posted by ki...@apache.org.
CLOUDSTACK-7739: Add new vGPU types K160Q, K180Q, K280Q to the CloudStack UI.


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

Branch: refs/heads/baremetal-systemvm
Commit: 420d4e0da0307a8e7b0e530da1a5aedcc209516e
Parents: 5025071
Author: Sanjay Tripathi <sa...@citrix.com>
Authored: Wed Oct 15 11:19:50 2014 +0530
Committer: Sanjay Tripathi <sa...@citrix.com>
Committed: Thu Oct 16 14:25:30 2014 +0530

----------------------------------------------------------------------
 .../configuration/ConfigurationManagerImpl.java     |  9 ---------
 ui/scripts/configuration.js                         | 16 ++++++++++++++--
 2 files changed, 14 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/420d4e0d/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
index 7dac143..1f71c0f 100755
--- a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
+++ b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
@@ -2147,7 +2147,6 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
             }
             detailsVO = new ArrayList<ServiceOfferingDetailsVO>();
             for (Entry<String, String> detailEntry : details.entrySet()) {
-                String value = null;
                 if (detailEntry.getKey().equals(GPU.Keys.pciDevice.toString())) {
                     if (detailEntry.getValue() == null) {
                         throw new InvalidParameterValueException("Please specify a GPU Card.");
@@ -2157,14 +2156,6 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
                     if (detailEntry.getValue() == null) {
                         throw new InvalidParameterValueException("vGPUType value cannot be null");
                     }
-                    for (GPU.vGPUType entry : GPU.vGPUType.values()) {
-                        if (detailEntry.getValue().equals(entry.getType())) {
-                            value = entry.getType();
-                        }
-                    }
-                    if (value == null) {
-                        throw new InvalidParameterValueException("Please specify valid vGPU type");
-                    }
                 }
                 detailsVO.add(new ServiceOfferingDetailsVO(offering.getId(), detailEntry.getKey(), detailEntry.getValue(), true));
             }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/420d4e0d/ui/scripts/configuration.js
----------------------------------------------------------------------
diff --git a/ui/scripts/configuration.js b/ui/scripts/configuration.js
index b074b00..f88ba85 100644
--- a/ui/scripts/configuration.js
+++ b/ui/scripts/configuration.js
@@ -475,8 +475,8 @@
                                             });
 
                                             var vGpuMap = {};
-                                            vGpuMap['Group of NVIDIA Corporation GK107GL [GRID K1] GPUs'] = ['passthrough', 'GRID K100', 'GRID K120Q', 'GRID K140Q'];
-                                            vGpuMap['Group of NVIDIA Corporation GK104GL [GRID K2] GPUs'] = ['passthrough', 'GRID K200', 'GRID K220Q', 'GRID K240Q', 'GRID K260Q'];
+                                            vGpuMap['Group of NVIDIA Corporation GK107GL [GRID K1] GPUs'] = ['passthrough', 'GRID K100', 'GRID K120Q', 'GRID K140Q', 'GRID K160Q', 'GRID K180Q'];
+                                            vGpuMap['Group of NVIDIA Corporation GK104GL [GRID K2] GPUs'] = ['passthrough', 'GRID K200', 'GRID K220Q', 'GRID K240Q', 'GRID K260Q', 'GRID K280Q'];
 
                                             args.$select.change(function() {
                                                 var gpu = $(this).val();
@@ -533,6 +533,14 @@
                                                 description: 'GRID K140Q'
                                             });
                                             items.push({
+                                                id: 'GRID K160Q',
+                                                description: 'GRID K160Q'
+                                            });
+                                            items.push({
+                                                id: 'GRID K180Q',
+                                                description: 'GRID K180Q'
+                                            });
+                                            items.push({
                                                 id: 'GRID K200',
                                                 description: 'GRID K200'
                                             });
@@ -548,6 +556,10 @@
                                                 id: 'GRID K260Q',
                                                 description: 'GRID K260Q'
                                             });
+                                            items.push({
+                                                id: 'GRID K280Q',
+                                                description: 'GRID K280Q'
+                                            });
                                             args.response.success({
                                                 data: items
                                             });


[11/50] [abbrv] git commit: updated refs/heads/baremetal-systemvm to 23482b1

Posted by ki...@apache.org.
CLOUDSTACK-7693: Fixing pep8 issues

pep8 fixes for test_routers.py

Signed-off-by: SrikanteswaraRao Talluri <ta...@apache.org>


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

Branch: refs/heads/baremetal-systemvm
Commit: 35e05a69a51496c343cf3bf8545c9d3650d4c6e8
Parents: 58cfbcd
Author: Gaurav Aradhye <ga...@clogeny.com>
Authored: Thu Oct 9 15:30:43 2014 +0530
Committer: SrikanteswaraRao Talluri <ta...@apache.org>
Committed: Wed Oct 15 10:56:55 2014 +0530

----------------------------------------------------------------------
 .../component/test_recurring_snapshots.py       |  497 +++---
 test/integration/component/test_routers.py      | 1422 +++++++++---------
 2 files changed, 984 insertions(+), 935 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/35e05a69/test/integration/component/test_recurring_snapshots.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_recurring_snapshots.py b/test/integration/component/test_recurring_snapshots.py
index faa6787..58dd769 100644
--- a/test/integration/component/test_recurring_snapshots.py
+++ b/test/integration/component/test_recurring_snapshots.py
@@ -16,110 +16,125 @@
 # under the License.
 
 from nose.plugins.attrib import attr
-from marvin.cloudstackTestCase import *
-from marvin.cloudstackAPI import *
-from marvin.lib.utils import *
-from marvin.lib.base import *
-from marvin.lib.common import *
+from marvin.cloudstackTestCase import cloudstackTestCase
+from marvin.lib.utils import (cleanup_resources)
+from marvin.lib.base import (Account,
+                             DiskOffering,
+                             ServiceOffering,
+                             VirtualMachine,
+                             SnapshotPolicy)
+from marvin.lib.common import (get_zone,
+                               get_domain,
+                               get_template,
+                               list_snapshots,
+                               list_volumes,
+                               list_snapshot_policy
+                               )
+import time
+
 
 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
+            "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,
-                    }
+            },
+            "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
+                # Data Disk
+                "diskdevice": ['/dev/xvdb', '/dev/sdb',
+                               '/dev/hdb', '/dev/vdb'],
+            },
+            "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):
@@ -135,14 +150,14 @@ class TestRecurringSnapshots(cloudstackTestCase):
         cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
         cls.services['mode'] = cls.zone.networktype
         cls.disk_offering = DiskOffering.create(
-                                    cls.api_client,
-                                    cls.services["disk_offering"]
-                                    )
+            cls.api_client,
+            cls.services["disk_offering"]
+        )
         template = get_template(
-                            cls.api_client,
-                            cls.zone.id,
-                            cls.services["ostype"]
-                            )
+            cls.api_client,
+            cls.zone.id,
+            cls.services["ostype"]
+        )
 
         cls.services["domainid"] = cls.domain.id
         cls.services["server_with_disk"]["zoneid"] = cls.zone.id
@@ -156,48 +171,48 @@ class TestRecurringSnapshots(cloudstackTestCase):
 
         # Create VMs, NAT Rules etc
         cls.account = Account.create(
-                            cls.api_client,
-                            cls.services["account"],
-                            domainid=cls.domain.id
-                            )
+            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.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"]
-                                )
+            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"]
-                                    )
+            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,
-                        ]
+            cls.service_offering,
+            cls.disk_offering,
+            cls.account,
+        ]
         return
 
     @classmethod
     def tearDownClass(cls):
         try:
-            #Cleanup resources used
+            # Cleanup resources used
             cleanup_resources(cls.api_client, cls._cleanup)
         except Exception as e:
             raise Exception("Warning: Exception during cleanup : %s" % e)
@@ -211,82 +226,81 @@ class TestRecurringSnapshots(cloudstackTestCase):
 
     def tearDown(self):
         try:
-            #Clean up, terminate the created instance, volumes and snapshots
+            # 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(speed="slow")
     @attr(tags=["advanced", "advancedns", "smoke"], required_hardware="false")
     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
+        # 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.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"
-                        )
+            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.apiclient,
+            volume[0].id,
+            self.services["recurring_snapshot"]
+        )
         self.cleanup.append(recurring_snapshot)
 
-        #ListSnapshotPolicy should return newly created policy
+        # ListSnapshotPolicy should return newly created policy
         list_snapshots_policy = list_snapshot_policy(
-                                                     self.apiclient,
-                                                     id=recurring_snapshot.id,
-                                                     volumeid=volume[0].id
-                                                     )
+            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"
-                        )
+            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"
-                            )
+            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"
-                        )
+            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"
-                        )
+            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
-                        )
+                self.apiclient,
+                volumeid=volume[0].id,
+                intervaltype=self.services["recurring_snapshot"]
+                ["intervaltype"],
+                snapshottype='RECURRING',
+                listall=True)
 
             if isinstance(snapshots, list):
                 break
@@ -298,92 +312,91 @@ class TestRecurringSnapshots(cloudstackTestCase):
             timeout = timeout - 1
 
         self.assertEqual(
-                            isinstance(snapshots, list),
-                            True,
-                            "Check list response returns a valid list"
-                        )
+            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"
-                        )
+            len(snapshots),
+            self.services["recurring_snapshot"]["maxsnaps"],
+            "Check maximum number of recurring snapshots retained"
+        )
         return
 
-    @attr(speed = "slow")
+    @attr(speed="slow")
     @attr(tags=["advanced", "advancedns", "smoke"], required_hardware="false")
     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
+        # 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.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"
-                        )
+            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.apiclient,
+            volume[0].id,
+            self.services["recurring_snapshot"]
+        )
         self.cleanup.append(recurring_snapshot)
-        #ListSnapshotPolicy should return newly created policy
+        # ListSnapshotPolicy should return newly created policy
         list_snapshots_policy = list_snapshot_policy(
-                                                     self.apiclient,
-                                                     id=recurring_snapshot.id,
-                                                     volumeid=volume[0].id
-                                                     )
+            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"
-                        )
+            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"
-                            )
+            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"
-                        )
+            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"
-                        )
+            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
-                            )
+                self.apiclient,
+                volumeid=volume[0].id,
+                intervaltype=self.services["recurring_snapshot"]
+                ["intervaltype"],
+                snapshottype='RECURRING',
+                listall=True)
 
             if isinstance(snapshots, list):
                 break
@@ -395,13 +408,13 @@ class TestRecurringSnapshots(cloudstackTestCase):
             timeout = timeout - 1
 
         self.assertEqual(
-                            isinstance(snapshots, list),
-                            True,
-                            "Check list response returns a valid list"
-                        )
+            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"
-                         )
+            len(snapshots),
+            self.services["recurring_snapshot"]["maxsnaps"],
+            "Check maximum number of recurring snapshots retained"
+        )
         return


[09/50] [abbrv] git commit: updated refs/heads/baremetal-systemvm to 23482b1

Posted by ki...@apache.org.
vGPU VMSnapshot Test Automation


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

Branch: refs/heads/baremetal-systemvm
Commit: 58cfbcdf98318c3c50162f5b45b2f6320b81819b
Parents: e70dde0
Author: sailajamada <sa...@citrix.com>
Authored: Wed Oct 15 10:32:34 2014 +0530
Committer: sailajamada <sa...@citrix.com>
Committed: Wed Oct 15 10:32:34 2014 +0530

----------------------------------------------------------------------
 .../component/test_deploy_vgpu_vm.py            | 684 +++++++++++++++++--
 1 file changed, 635 insertions(+), 49 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/58cfbcdf/test/integration/component/test_deploy_vgpu_vm.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_deploy_vgpu_vm.py b/test/integration/component/test_deploy_vgpu_vm.py
index b5af092..0284eab 100644
--- a/test/integration/component/test_deploy_vgpu_vm.py
+++ b/test/integration/component/test_deploy_vgpu_vm.py
@@ -19,15 +19,15 @@
 
 #All tests inherit from cloudstackTestCase
 from marvin.cloudstackTestCase import cloudstackTestCase, unittest
-from marvin.cloudstackAPI import changeServiceForVirtualMachine,updateServiceOffering,listConfigurations
+from marvin.cloudstackAPI import changeServiceForVirtualMachine,updateServiceOffering,listConfigurations,startVirtualMachine
 
 #Import Integration Libraries
 
 #base - contains all resources as entities and defines create, delete, list operations on them
-from marvin.lib.base import Account, VirtualMachine, ServiceOffering , Template , Host
+from marvin.lib.base import Account, VirtualMachine, ServiceOffering , Template , Host, VmSnapshot
 
 #utils - utility classes for common cleanup, external library wrappers etc
-from marvin.lib.utils import cleanup_resources
+from marvin.lib.utils import cleanup_resources,random_gen
 
 #common - commonly used methods for all tests are listed here
 from marvin.lib.common import get_zone, get_domain, get_template, list_hosts ,list_service_offering, get_windows_template, get_pod, list_clusters, list_virtual_machines
@@ -72,10 +72,14 @@ class TestvGPUWindowsVm(cloudstackTestCase):
              cls.k1hosts=0
              cls.k100_vgpu_service_offering=[]
              cls.k200_vgpu_service_offering=[]
+             cls.nonvgpu_service_offering=[]
              cls.vm_k1_card=[]
              cls.vm_k2_card=[]
              cls.vm2_k2_card=[]
+             cls.nonvgpu=[]
              cls.vmlifecycletest=0
+             cls.vmsnapwomemory=0
+             cls.vmsnapwithmemory=0
 
              for ghost in hosts :
                  if ghost.hypervisorversion >= "6.2.0":
@@ -194,6 +198,7 @@ class TestvGPUWindowsVm(cloudstackTestCase):
         self.cleanup = []
         return
 
+
     def check_host_vgpu_capacity(self,gpucard,gtype):
         gputhosts = list_hosts(
                self.apiclient,
@@ -532,6 +537,37 @@ class TestvGPUWindowsVm(cloudstackTestCase):
         self.destroy_vm()
         return
 
+
+    @attr(tags = ['advanced', 'basic' , 'vgpu'], required_hardware="true")
+    def vm_snapshot_serviceoffering_upgrade(self,sourcetype,sourcemodel,desttype,destmodel):
+
+        self.sourcevgpuoffering=self.vgpu_serviceoffering_creation(sourcetype,sourcemodel)
+        self.deploy_vGPU_windows_vm(self.sourcevgpuoffering.id,sourcetype)
+        time.sleep(self.testdata["vgpu"]["sleep"])
+
+        vm=self.check_for_vm(sourcetype,self.sourcevgpuoffering.id,self.virtual_machine.id)
+        self.check_for_vGPU_resource(vm.hostid,vm.instancename,vm.serviceofferingid,vm.vgpu)
+
+        self.stop_vm()
+
+        self.destvgpuoffering=self.vgpu_serviceoffering_creation(desttype,destmodel)
+        cmd = changeServiceForVirtualMachine.changeServiceForVirtualMachineCmd()
+        cmd.id = vm.id
+        cmd.serviceofferingid = self.destvgpuoffering.id
+        self.apiclient.changeServiceForVirtualMachine(cmd)
+
+        self.debug("Starting VM - ID: %s" % vm.id)
+        self.start_vm()
+        time.sleep(self.testdata["vgpu"]["sleep"])
+
+            # Ensure that VM is in running state
+        vm=self.check_for_vm(desttype,self.destvgpuoffering.id,vm.id)
+        self.check_for_vGPU_resource(vm.hostid,vm.instancename,vm.serviceofferingid,vm.vgpu)
+        self.delete_vgpu_service_offering(self.destvgpuoffering)
+        self.delete_vgpu_service_offering(self.sourcevgpuoffering)
+        self.destroy_vm()
+        return
+
     @attr(tags = ['advanced', 'basic' , 'vgpu'], required_hardware="true")
     def deploy_vm(self,type,model):
 
@@ -635,9 +671,14 @@ class TestvGPUWindowsVm(cloudstackTestCase):
         win2012templateid=self.new_template_register("Windows Server 2012 (64-bit)")
         win7templateid=self.new_template_register("Windows 7 (64-bit)")
 
+        self.__class__.nonvgpu_service_offering = ServiceOffering.create(
+                                                                    self.apiclient,
+                                                                    self.testdata["vgpu"]["service_offerings"]["nonvgpuoffering"]
+                                                                    )
+
         """
         Create Virtual Machines for Both K1 and K2 cards to be used for VM life cycle tests
-        """
+       """
 
         if(self.k1hosts != 0):
             self.__class__.vm_k1_card = VirtualMachine.create(
@@ -649,6 +690,7 @@ class TestvGPUWindowsVm(cloudstackTestCase):
             serviceofferingid=self.k100_vgpu_service_offering.id,
             templateid=win8templateid
             )
+
         if(self.k2hosts !=0):
             self.__class__.vm_k2_card = VirtualMachine.create(
             self.apiclient,
@@ -669,6 +711,17 @@ class TestvGPUWindowsVm(cloudstackTestCase):
             serviceofferingid=self.k200_vgpu_service_offering.id,
             templateid=win7templateid
             )
+
+        self.__class__.nonvgpu = VirtualMachine.create(
+            self.apiclient,
+            self.testdata["virtual_machine"],
+            accountid=self.account.name,
+            zoneid=self.zone.id,
+            domainid=self.account.domainid,
+            serviceofferingid=self.__class__.nonvgpu_service_offering.id,
+            templateid=win7templateid
+            )
+
         return
 
 
@@ -729,11 +782,11 @@ class TestvGPUWindowsVm(cloudstackTestCase):
 
     def verify_vm(self,vm_gpu_card):
         if(vm_gpu_card):
-          vm_gpu_card.getState(
+           vm_gpu_card.getState(
                                    self.apiclient,
                                    "Running")
-
-          self.check_for_vGPU_resource(vm_gpu_card.hostid,vm_gpu_card.instancename,vm_gpu_card.serviceofferingid,vm_gpu_card.vgpu)
+           time.sleep(self.testdata["vgpu"]["sleep"]*3)
+           self.check_for_vGPU_resource(vm_gpu_card.hostid,vm_gpu_card.instancename,vm_gpu_card.serviceofferingid,vm_gpu_card.vgpu)
 
     def stop_life_cycle_vm (self,vm_gpu_card):
 
@@ -749,6 +802,10 @@ class TestvGPUWindowsVm(cloudstackTestCase):
         if(vm_gpu_card):
           vm_gpu_card.start(self.apiclient)
           time.sleep(self.testdata["vgpu"]["sleep"])
+          vm_gpu_card.getState(
+                                   self.apiclient,
+                                   "Running")
+
 
     def restore_life_cycle_vm(self,vm_gpu_card):
         if(vm_gpu_card):
@@ -796,6 +853,7 @@ class TestvGPUWindowsVm(cloudstackTestCase):
 
         rcapacity=self.check_host_vgpu_remaining_capacity(vm_gpu_card.hostid,vm_gpu_card.vgpu)
         self.stop_life_cycle_vm(vm_gpu_card)
+        time.sleep(self.testdata["vgpu"]["sleep"]*3)
         self.check_gpu_resources_released_vm(vm_gpu_card.hostid,vm_gpu_card.vgpu,rcapacity)
         return
 
@@ -805,6 +863,7 @@ class TestvGPUWindowsVm(cloudstackTestCase):
         hostid=vm_gpu_card.hostid
         vgputype=vm_gpu_card.vgpu
         self.delete_vm_life_cycle_vm(vm_gpu_card)
+        time.sleep(self.testdata["vgpu"]["sleep"]*3)
         self.check_gpu_resources_released_vm(hostid,vgputype,rcapacity)
         return
 
@@ -815,6 +874,285 @@ class TestvGPUWindowsVm(cloudstackTestCase):
         return
 
 
+
+
+    def create_vm_snapshot(self,vmcard):
+
+        self.debug("Check if deployed VMs are in running state?")
+        if(vmcard):
+           vmcard.getState(
+                                   self.apiclient,
+                                   "Running")
+
+        if hasattr(vmcard,"vgpu"):
+           self.check_for_vGPU_resource(vmcard.hostid,vmcard.instancename,vmcard.serviceofferingid,vmcard.vgpu)
+
+        vm_snapshot = VmSnapshot.create(
+            self.apiclient,
+            vmcard.id,
+            "false",
+            "TestSnapshot",
+            "Display Text"
+        )
+
+        list_snapshot_response = VmSnapshot.list(self.apiclient, virtualmachineid=vmcard.id, listall=True)
+
+        self.assertEqual(
+            isinstance(list_snapshot_response, list),
+            True,
+            "Check list response returns a valid list"
+        )
+        self.assertNotEqual(
+            list_snapshot_response,
+            None,
+            "Check if snapshot exists in ListSnapshot"
+        )
+
+        self.assertEqual(
+            list_snapshot_response[0].state,
+            "Ready",
+            "Check the snapshot of vm is ready!"
+        )
+
+        vgpu_host = list_hosts(
+                               self.apiclient,
+                               id=vmcard.hostid
+                               )
+        ssh_client = SshClient(host=vgpu_host[0].ipaddress, port=22, user='root',passwd=self.testdata["host_password"])
+        """
+        Get vGPU type model
+        """
+        vgpu_snapshot = ssh_client.execute("xe snapshot-list name-label=" + list_snapshot_response[0].name + " --minimal")
+        #vgpu_snapshot = ssh_client.execute("xe snapshot-param-get param-name=name-label uuid="+vgpu_snapshot_uuid[0]+ " params=type-model-name --minimal")
+
+#        self.debug("vgpu type model is %s and value is %s and length is %s"%(vgpu_type_model,vgpu_type_model[0],len(vgpu_type_model[0])))
+
+        self.assertNotEqual(
+                            len(vgpu_snapshot[0]),
+                            0,
+                            "VM Snapshot is not created"
+                        )
+        self.__class__.vmsnapwomemory=1
+        return
+
+    def revert_vm_snapshot(self,vmcard):
+
+        self.debug("Check if deployed VMs are in running state?")
+        #if(vmcard):
+         #  vmcard.getState(
+          #                         self.apiclient,
+          #                         "Running")
+        if hasattr(vmcard,"vgpu"):
+           self.check_for_vGPU_resource(vmcard.hostid,vmcard.instancename,vmcard.serviceofferingid,vmcard.vgpu)
+
+        list_snapshot_response = VmSnapshot.list(self.apiclient, virtualmachineid=vmcard.id, listall=True)
+
+        self.assertEqual(
+            isinstance(list_snapshot_response, list),
+            True,
+            "Check list response returns a valid list"
+        )
+        self.assertNotEqual(
+            list_snapshot_response,
+            None,
+            "Check if snapshot exists in ListSnapshot"
+        )
+
+        self.assertEqual(
+            list_snapshot_response[0].state,
+            "Ready",
+            "Check the snapshot of vm is ready!"
+        )
+
+        VmSnapshot.revertToSnapshot(self.apiclient, list_snapshot_response[0].id)
+        time.sleep(self.testdata["vgpu"]["sleep"])
+        list_vm_response = list_virtual_machines(
+            self.apiclient,
+            id=vmcard.id
+        )
+        vm=list_vm_response[0]
+        self.assertEqual(
+            list_vm_response[0].state,
+            "Stopped",
+            "Check the state of vm is Stopped"
+        )
+
+        cmd = startVirtualMachine.startVirtualMachineCmd()
+        cmd.id = vm.id
+        self.apiclient.startVirtualMachine(cmd)
+        time.sleep(self.testdata["vgpu"]["sleep"])
+
+        list_vm_response = list_virtual_machines(
+            self.apiclient,
+            id=vm.id
+        )
+        vm=list_vm_response[0]
+        if vm is None:
+            self.fail("Failed to list VM details after Vm Snapshot")
+        self.assertEqual(
+             vm.state,
+            "Running",
+            "Check the state of vm is Running"
+        )
+
+        if hasattr(vmcard,"vgpu"):
+           self.check_for_vGPU_resource(vmcard.hostid,vmcard.instancename,vmcard.serviceofferingid,vmcard.vgpu)
+
+
+    def delete_vm_snapshot(self,vmcard):
+
+        list_snapshot_response = VmSnapshot.list(self.apiclient, virtualmachineid=vmcard.id, listall=True)
+
+        self.assertEqual(
+            isinstance(list_snapshot_response, list),
+            True,
+            "Check list response returns a valid list"
+        )
+        self.assertNotEqual(
+            list_snapshot_response,
+            None,
+            "Check if snapshot exists in ListSnapshot"
+        )
+        Tobedeletedsnapname=list_snapshot_response[0].name
+        VmSnapshot.deleteVMSnapshot(self.apiclient, list_snapshot_response[0].id)
+
+        time.sleep(self.testdata["vgpu"]["sleep"])
+
+        list_snapshot_response = VmSnapshot.list(self.apiclient, virtualmachineid=vmcard.id, listall=True)
+        self.debug("List Snapshot response after snapshot deletion %s"%list_snapshot_response)
+        self.assertEqual(
+            list_snapshot_response,
+            None,
+            "Check if vm snapshot is deleted"
+        )
+
+        vgpu_host = list_hosts(
+                               self.apiclient,
+                               id=vmcard.hostid
+                               )
+        ssh_client = SshClient(host=vgpu_host[0].ipaddress, port=22, user='root',passwd=self.testdata["host_password"])
+
+        vgpu_snapshot = ssh_client.execute("xe snapshot-list name-label=" +Tobedeletedsnapname + " --minimal")
+        #vgpu_snapshot = ssh_client.execute("xe snapshot-param-get param-name=name-label uuid="+vgpu_snapshot_uuid[0]+ " params=type-model-name --minimal")
+
+#        self.debug("vgpu type model is %s and value is %s and length is %s"%(vgpu_type_model,vgpu_type_model[0],len(vgpu_type_model[0])))
+        self.debug("List Snapshot response after snapshot deletion is %s %s"%(vgpu_snapshot,vgpu_snapshot[0]))
+        self.assertEqual(
+                            len(vgpu_snapshot[0]),
+                            0,
+                            "check if VM Snapshot is not deleted"
+                        )
+
+        return
+
+
+    def create_vm_snapshot_with_memory(self,vmcard):
+
+        self.debug("Check if deployed VMs are in running state?")
+        if(vmcard):
+          vmcard.getState(
+                                   self.apiclient,
+                                   "Running")
+          self.check_for_vGPU_resource(vmcard.hostid,vmcard.instancename,vmcard.serviceofferingid,vmcard.vgpu)
+
+        vm_snapshot = VmSnapshot.create(
+            self.apiclient,
+            vmcard.id,
+            "true",
+            "TestSnapshotwithmemory",
+            "Display Text"
+        )
+
+        time.sleep(self.testdata["vgpu"]["sleep"] * 3)
+
+        list_snapshot_response = VmSnapshot.list(self.apiclient, virtualmachineid=vmcard.id, listall=True)
+
+        self.assertEqual(
+            isinstance(list_snapshot_response, list),
+            True,
+            "Check list response returns a valid list"
+        )
+        self.assertNotEqual(
+            list_snapshot_response,
+            None,
+            "Check if snapshot exists in ListSnapshot"
+        )
+
+        self.assertEqual(
+            list_snapshot_response[0].state,
+            "Ready",
+            "Check the snapshot of vm is ready!"
+        )
+
+        vgpu_host = list_hosts(
+                               self.apiclient,
+                               id=vmcard.hostid
+                               )
+        ssh_client = SshClient(host=vgpu_host[0].ipaddress, port=22, user='root',passwd=self.testdata["host_password"])
+
+        vgpu_snapshot = ssh_client.execute("xe snapshot-list name-label=" + list_snapshot_response[0].name + " --minimal")
+        #vgpu_snapshot = ssh_client.execute("xe snapshot-param-get param-name=name-label uuid="+vgpu_snapshot_uuid[0]+ " params=type-model-name --minimal")
+
+#        self.debug("vgpu type model is %s and value is %s and length is %s"%(vgpu_type_model,vgpu_type_model[0],len(vgpu_type_model[0])))
+
+        self.assertNotEqual(
+                            len(vgpu_snapshot[0]),
+                            0,
+                            "VM Snapshot is not created"
+                        )
+        self.__class__.vmsnapwithmemory=1
+        return
+
+    def revert_vm_snapshot_with_memory(self,vmcard):
+
+        self.debug("Check if deployed VMs are in running state?")
+        if(vmcard):
+          vmcard.getState(
+                                   self.apiclient,
+                                   "Running")
+          self.check_for_vGPU_resource(vmcard.hostid,vmcard.instancename,vmcard.serviceofferingid,vmcard.vgpu)
+
+
+        list_snapshot_response = VmSnapshot.list(self.apiclient, virtualmachineid=vmcard.id, listall=True)
+
+        self.assertEqual(
+            isinstance(list_snapshot_response, list),
+            True,
+            "Check list response returns a valid list"
+        )
+        self.assertNotEqual(
+            list_snapshot_response,
+            None,
+            "Check if snapshot exists in ListSnapshot"
+        )
+
+        self.assertEqual(
+            list_snapshot_response[0].state,
+            "Ready",
+            "Check the snapshot of vm is ready!"
+        )
+
+        VmSnapshot.revertToSnapshot(self.apiclient, list_snapshot_response[0].id)
+
+        list_vm_response = list_virtual_machines(
+            self.apiclient,
+            id=vmcard.id
+        )
+        vm=list_vm_response[0]
+        if vm is None:
+            self.fail("Failed to list VM details after Vm Snapshot")
+        self.assertEqual(
+             vm.state,
+            "Running",
+            "Check the state of vm is Running"
+        )
+
+        self.check_for_vGPU_resource(vmcard.hostid,vmcard.instancename,vmcard.serviceofferingid,vmcard.vgpu)
+
+
+        return
+
+
     def rebootvm(self,vm_vgpu_card):
 
         self.reboot_life_cycle_vm(vm_vgpu_card)
@@ -822,6 +1160,32 @@ class TestvGPUWindowsVm(cloudstackTestCase):
         return
 
 
+    @attr(tags=["advanced", "advancedns", "smoke"], required_hardware="true")
+    def  vm_snapshot_vgpu(self,vmcard,sourcetype,sourcemodel,desttype,destmodel):
+
+        self.create_vm_snapshot(vmcard)
+        self.start_life_cycle_vm(vmcard)
+        self.destvgpuoffering=self.vgpu_serviceoffering_creation(desttype,destmodel)
+        self.stop_life_cycle_vm(vmcard)
+        cmd = changeServiceForVirtualMachine.changeServiceForVirtualMachineCmd()
+        cmd.id = vmcard.id
+        cmd.serviceofferingid = self.destvgpuoffering.id
+        self.apiclient.changeServiceForVirtualMachine(cmd)
+
+        self.debug("Starting VM - ID: %s" % vmcard.id)
+        self.start_life_cycle_vm(vmcard)
+        time.sleep(self.testdata["vgpu"]["sleep"])
+        vm=self.check_for_vm(desttype,self.destvgpuoffering.id,vmcard.id)
+            # Ensure that VM is in running state
+        if destmodel!="None":
+           self.check_for_vGPU_resource(vm.hostid,vm.instancename,vm.serviceofferingid,vm.vgpu)
+
+        self.revert_vm_snapshot(vm)
+
+        self.delete_vm_snapshot(vm)
+
+
+
     def test_01_list_vgpu_host_details(self):
         """   list vGPU host details  """
         hhosts = list_hosts(
@@ -902,7 +1266,7 @@ class TestvGPUWindowsVm(cloudstackTestCase):
            if not k100:
                self.fail("list host details with K100 vgpu are not correct")
         if self.k1passthroughgpuhosts>0:
-           if not k200:
+           if not k1pass:
                self.fail("list host details with K1 Passthrough vgpu are not correct")
 
     @attr(tags = ['advanced', 'basic' , 'vgpu'], required_hardware="true")
@@ -1130,9 +1494,16 @@ class TestvGPUWindowsVm(cloudstackTestCase):
 
         self.debug("Check if deployed VMs are in running state?")
 
-        self.verify_vm(self.__class__.vm_k1_card)
-        self.verify_vm(self.__class__.vm_k2_card)
-        self.verify_vm(self.__class__.vm2_k2_card)
+
+        if self.__class__.vm_k1_card is not None:
+            self.verify_vm(self.__class__.vm_k1_card)
+
+        if self.__class__.vm_k2_card is not None:
+            self.verify_vm(self.__class__.vm_k2_card)
+
+        if self.__class__.vm2_k2_card is not None:
+            self.verify_vm(self.__class__.vm2_k2_card)
+
 
         self.__class__.vmlifecycletest=1
         return
@@ -1144,9 +1515,16 @@ class TestvGPUWindowsVm(cloudstackTestCase):
         if self.__class__.vmlifecycletest==0:
             raise unittest.SkipTest("VM Life Cycle Deploy VM test failed hence skipping")
 
-        self.stopvm(self.__class__.vm_k1_card)
-        self.stopvm(self.__class__.vm_k2_card)
-        self.stopvm(self.__class__.vm2_k2_card)
+
+        if self.__class__.vm_k1_card:
+            self.stopvm(self.__class__.vm_k1_card)
+
+        if self.__class__.vm_k2_card:
+            self.stopvm(self.__class__.vm_k2_card)
+
+        if self.__class__.vm2_k2_card:
+            self.stopvm(self.__class__.vm2_k2_card)
+
 
         return
 
@@ -1157,9 +1535,15 @@ class TestvGPUWindowsVm(cloudstackTestCase):
         if self.__class__.vmlifecycletest==0:
             raise unittest.SkipTest("VM Life Cycle Deploy VM test failed hence skipping")
 
-        self.startvm(self.__class__.vm_k1_card)
-        self.startvm(self.__class__.vm_k2_card)
-        self.startvm(self.__class__.vm2_k2_card)
+
+        if self.__class__.vm_k1_card:
+            self.startvm(self.__class__.vm_k1_card)
+
+        if self.__class__.vm_k2_card:
+            self.startvm(self.__class__.vm_k2_card)
+
+        if self.__class__.vm2_k2_card:
+            self.startvm(self.__class__.vm2_k2_card)
 
         return
 
@@ -1171,9 +1555,14 @@ class TestvGPUWindowsVm(cloudstackTestCase):
         if self.__class__.vmlifecycletest==0:
             raise unittest.SkipTest("VM Life Cycle Deploy VM test failed hence skipping")
 
-        self.restorevm(self.__class__.vm_k1_card)
-        self.restorevm(self.__class__.vm_k2_card)
-        self.restorevm(self.__class__.vm2_k2_card)
+
+        if self.__class__.vm_k1_card:
+            self.restorevm(self.__class__.vm_k1_card)
+        if self.__class__.vm_k2_card:
+            self.restorevm(self.__class__.vm_k2_card)
+        if self.__class__.vm2_k2_card:
+            self.restorevm(self.__class__.vm2_k2_card)
+
 
         return
 
@@ -1185,70 +1574,267 @@ class TestvGPUWindowsVm(cloudstackTestCase):
         if self.__class__.vmlifecycletest==0:
             raise unittest.SkipTest("VM Life Cycle Deploy VM test failed hence skipping")
 
-        self.rebootvm(self.__class__.vm_k1_card)
-        self.rebootvm(self.__class__.vm_k2_card)
-        self.rebootvm(self.__class__.vm2_k2_card)
+
+        if self.__class__.vm_k1_card:
+            self.rebootvm(self.__class__.vm_k1_card)
+        if self.__class__.vm_k2_card:
+            self.rebootvm(self.__class__.vm_k2_card)
+        if self.__class__.vm2_k2_card:
+            self.rebootvm(self.__class__.vm2_k2_card)
+
+        return
+
+    @attr(tags=["advanced", "advancedns", "smoke"], required_hardware="true")
+    def test_17_create_k1_vm_snapshot_wo_memory(self):
+        """Test to create VM snapshots
+        """
+
+        if self.__class__.vmlifecycletest==0:
+            raise unittest.SkipTest("VM Life Cycle Deploy VM test failed hence skipping")
+
+        if not (self.__class__.vm_k1_card):
+            raise unittest.SkipTest(" No VM available.Hence skipping")
+
+        self.create_vm_snapshot(self.__class__.vm_k1_card)
+#        self.create_vm_snapshot(self.__class__.vm_k2_card)
+#        self.create_vm_snapshot(self.__class__.vm_k2_card)
+
+        return
+
+    @attr(tags=["advanced", "advancedns", "smoke"], required_hardware="true")
+    def test_18_revert_k1_vm_snapshot_wo_memory(self):
+        """Test to revert VM snapshots
+        """
+
+        if self.__class__.vmlifecycletest==0:
+            raise unittest.SkipTest("VM Life Cycle Deploy VM test failed hence skipping")
+
+        if self.__class__.vmsnapwomemory==0:
+            raise unittest.SkipTest("VM Snapshot creation test failed hence skipping")
+
+        if not self.__class__.vm_k1_card:
+            raise unittest.SkipTest("No VM available.Hence skipping")
+
+        self.revert_vm_snapshot(self.__class__.vm_k1_card)
+
+        return
+
+
+    @attr(tags=["advanced", "advancedns", "smoke"], required_hardware="true")
+    def test_19_delete_k1_vm_snapshot_wo_memory(self):
+        """Test to delete vm snapshots
+        """
+
+        if self.__class__.vmlifecycletest==0:
+            raise unittest.SkipTest("VM Life Cycle Deploy VM test failed hence skipping")
+
+        if self.__class__.vmsnapwomemory==0:
+            raise unittest.SkipTest("VM Snapshot creation test failed hence skipping")
+
+        if not (self.__class__.vm_k1_card):
+            raise unittest.SkipTest("No VM available.Hence skipping")
+
+        self.delete_vm_snapshot(self.__class__.vm_k1_card)
+
+        return
+
+
+    @attr(tags=["advanced", "advancedns", "smoke"], required_hardware="true")
+    def test_20_create_k2_vm_snapshot_with_memory(self):
+        """Test to create VM snapshots
+        """
+
+        if self.__class__.vmlifecycletest==0:
+            raise unittest.SkipTest("VM Life Cycle Deploy VM test failed hence skipping")
+
+        if not (self.__class__.vm_k2_card):
+            raise unittest.SkipTest("No VM available.Hence skipping")
+
+        self.create_vm_snapshot_with_memory(self.__class__.vm_k2_card)
+
+        return
+
+    @attr(tags=["advanced", "advancedns", "smoke"], required_hardware="true")
+    def test_21_revert_k2_vm_snapshot_with_memory(self):
+        """Test to revert VM snapshots
+        """
+
+
+        if self.__class__.vmlifecycletest==0:
+            raise unittest.SkipTest("VM Life Cycle Deploy VM test failed hence skipping")
+
+
+        if self.__class__.vmsnapwithmemory==0:
+            raise unittest.SkipTest("VM Snapshot creation with memory test failed hence skipping")
+
+
+        if not (self.__class__.vm_k2_card):
+            raise unittest.SkipTest("No VM available.Hence skipping")
+
+
+        self.revert_vm_snapshot_with_memory(self.__class__.vm_k2_card)
+
+        return
+
+
+    @attr(tags=["advanced", "advancedns", "smoke"], required_hardware="true")
+    def test_22_delete_k2_vm_snapshot_with_memory(self):
+        """Test to delete vm snapshots
+        """
+
+
+        if self.__class__.vmlifecycletest==0:
+            raise unittest.SkipTest("VM Life Cycle Deploy VM test failed hence skipping")
+
+        if self.__class__.vmsnapwithmemory==0:
+            raise unittest.SkipTest("VM Snapshot creation with memory test failed hence skipping")
+
+        if not(self.__class__.vm_k2_card):
+            raise unittest.SkipTest("No VM available.Hence skipping")
+
+
+        self.delete_vm_snapshot(self.__class__.vm_k2_card)
 
         return
 
+    @attr(tags=["advanced", "advancedns", "smoke"], required_hardware="true")
+    def test_23_vm_snapshot_without_memory_from_k1_vgpu_nonvgpu_vgpu(self):
+        """Test to verify VM snapshot from vGPU to non vgpu to vGPU snap
+        """
+
+        if self.__class__.vmlifecycletest==0:
+            raise unittest.SkipTest("VM Life Cycle Deploy VM test failed hence skipping")
+
+        k1qcapacity=self.check_host_vgpu_capacity("Group of NVIDIA Corporation GK107GL [GRID K1] GPUs",self.__class__.vm_k1_card.vgpu)
+
+        if (k1qcapacity==0):
+           raise unittest.SkipTest("No XenServer available with K1 vGPU Drivers installed. Skipping ")
+
+        if not(self.__class__.vm_k1_card):
+            raise unittest.SkipTest("No VM available.Hence skipping")
+
+        self.vm_snapshot_vgpu(self.__class__.vm_k1_card,self.__class__.vm_k1_card.vgpu,"Group of NVIDIA Corporation GK107GL [GRID K1] GPUs","nonvgpuoffering","None")
+
+        return
+
+
+
+    @attr(tags=["advanced", "advancedns", "smoke"], required_hardware="true")
+    def test_24_vm_snapshot_without_memory_from_nonvgpu_k1vgpu_nonvgpu(self):
+        """Test to verify VM snapshot from non vGPU snap to vGPU snap to non vGPU snap
+        """
+
+        if self.__class__.vmlifecycletest==0:
+            raise unittest.SkipTest("VM Life Cycle Deploy VM test failed hence skipping")
+
+        k1qcapacity=self.check_host_vgpu_capacity("Group of NVIDIA Corporation GK107GL [GRID K1] GPUs",self.__class__.vm_k1_card.vgpu)
+
+        if (k1qcapacity==0):
+           raise unittest.SkipTest("No XenServer available with vGPU Drivers installed. Skipping ")
+
+        if not(self.__class__.vm_k1_card):
+            raise unittest.SkipTest("No VM available.Hence skipping")
+
+        self.vm_snapshot_vgpu(self.__class__.nonvgpu,"nonvgpuoffering","None",self.__class__.vm_k1_card.vgpu,"Group of NVIDIA Corporation GK107GL [GRID K1] GPUs")
+
+        return
+
+
+    @attr(tags=["advanced", "advancedns", "smoke"], required_hardware="true")
+    def test_25_vm_snapshot_without_memory_from_k2vgpu_k1vgpu_k2vgpu(self):
+        """Test to verify VM snapshot from K2 vGPU snap to K1 vGPU snap to K2 vGPU snap
+        """
+
+        if self.__class__.vmlifecycletest==0:
+            raise unittest.SkipTest("VM Life Cycle Deploy VM test failed hence skipping")
+
+        k1qcapacity=self.check_host_vgpu_capacity("Group of NVIDIA Corporation GK107GL [GRID K1] GPUs",self.__class__.vm_k1_card.vgpu)
+
+        if (k1qcapacity == 0):
+           raise unittest.SkipTest("No XenServer available with vGPU Drivers installed. Skipping ")
+
+        if not(self.__class__.vm_k2_card):
+            raise unittest.SkipTest("No VM available.Hence skipping")
+
+
+        self.vm_snapshot_vgpu(self.__class__.vm_k2_card,self.__class__.vm_k2_card.vgpu,"Group of NVIDIA Corporation GK104GL [GRID K2] GPUs",self.__class__.vm_k1_card.vgpu,"Group of NVIDIA Corporation GK107GL [GRID K1] GPUs")
+
+        return
+
+
     @attr(tags = ['advanced', 'basic' , 'vgpu'], required_hardware="true")
-    def test_17_destroy_vGPU_windows_vm(self):
+    def test_26_destroy_vGPU_windows_vm(self):
         """Test destroy Virtual Machine
         """
 
         if self.__class__.vmlifecycletest==0:
             raise unittest.SkipTest("VM Life Cycle Deploy VM test failed hence skipping")
 
+        if self.__class__.vm_k2_card:
+            self.deletevm(self.__class__.vm_k2_card)
+
+        if self.__class__.vm_k1_card:
+            self.deletevm(self.__class__.vm_k1_card)
 
-        self.deletevm(self.__class__.vm_k1_card)
-        self.deletevm(self.__class__.vm_k2_card)
-        self.deletevm(self.__class__.vm2_k2_card)
+        if self.__class__.vm2_k2_card:
+            self.deletevm(self.__class__.vm2_k2_card)
 
+        if self.__class__.nonvgpu:
+            self.deletevm(self.__class__.nonvgpu)
 
+        self.cleanup.append(self.__class__.nonvgpu_service_offerin)
         self.cleanup.append(self.__class__.k100_vgpu_service_offering)
         self.cleanup.append(self.__class__.k200_vgpu_service_offering)
 
         return
 
     @attr(tags = ['advanced', 'basic' , 'vgpu'], required_hardware="true")
-    def test_18_recover_vGPU_windows_vm(self):
+    def test_27_recover_vGPU_windows_vm(self):
         """Test recover Virtual Machine
         """
 
         if self.__class__.vmlifecycletest==0:
             raise unittest.SkipTest("VM Life Cycle Deploy VM test failed hence skipping")
 
-        self.recovervm(self.__class__.vm_k1_card)
-        self.recovervm(self.__class__.vm_k2_card)
-        self.recovervm(self.__class__.vm2_k2_card)
+        if self.__class__.vm_k2_card is not None:
+            self.recovervm(self.__class__.vm_k2_card)
+
+        if self.__class__.vm_k1_card is not None:
+            self.recovervm(self.__class__.vm_k1_card)
+
+        if self.__class__.vm2_k2_card is not None:
+            self.recovervm(self.__class__.vm2_k2_card)
 
         return
 
-    def test_19_destroy_vGPU_windows_vm_after_recover(self):
+    def test_28_destroy_vGPU_windows_vm_after_recover(self):
         """Test destroy Virtual Machine
         """
 
         if self.__class__.vmlifecycletest==0:
             raise unittest.SkipTest("VM Life Cycle Deploy VM test failed hence skipping")
 
-        if self.check_vm_state(self.__class__.vm_k1_card.id)=="Expunge":
-            raise unittest.SkipTest("VM is already deleted hence skipping")
-        self.deletevm(self.__class__.vm_k1_card)
+        if self.__class__.vm_k1_card:
+            if self.check_vm_state(self.__class__.vm_k1_card.id)=="Expunge":
+                raise unittest.SkipTest("VM is already deleted hence skipping")
+            self.deletevm(self.__class__.vm_k1_card)
 
-        if self.check_vm_state(self.__class__.vm_k2_card.id)=="Expunge":
-            raise unittest.SkipTest("VM is already deleted hence skipping")
-        self.deletevm(self.__class__.vm_k2_card)
+        if self.__class__.vm_k2_card:
+            if self.check_vm_state(self.__class__.vm_k2_card.id)=="Expunge":
+                raise unittest.SkipTest("VM is already deleted hence skipping")
+            self.deletevm(self.__class__.vm_k2_card)
 
-        if self.check_vm_state(self.__class__.vm2_k1_card.id)=="Expunge":
-            raise unittest.SkipTest("VM is already deleted hence skipping")
-        self.deletevm(self.__class__.vm2_k2_card)
+        if self.__class__.vm2_k2_card:
+            if self.check_vm_state(self.__class__.vm2_k2_card.id)=="Expunge":
+                raise unittest.SkipTest("VM is already deleted hence skipping")
+            self.deletevm(self.__class__.vm2_k2_card)
 
         return
 
 
     @attr(tags = ['advanced', 'basic' , 'vgpu'], required_hardware="true")
 
-    def test_20_nonvgpuvm_k2vgpuvm_offline(self):
+    def test_29_nonvgpuvm_k2vgpuvm_offline(self):
         """Test to change service from non vgpu to vgpu K200"""
         k200capacity=self.check_host_vgpu_capacity("Group of NVIDIA Corporation GK104GL [GRID K2] GPUs","GRID K200")
         if (self.k200gpuhosts == 0) or (k200capacity==0):
@@ -1260,7 +1846,7 @@ class TestvGPUWindowsVm(cloudstackTestCase):
 
     @attr(tags = ['advanced', 'basic' , 'vgpu'], required_hardware="true")
 
-    def test_21_K2_vgpuvm_vgpuvm_offline(self):
+    def test_30_K2_vgpuvm_vgpuvm_offline(self):
         """Test to change service from vgpu K200 to vgpu K240Q"""
         k240qcapacity=self.check_host_vgpu_capacity("Group of NVIDIA Corporation GK104GL [GRID K2] GPUs","GRID K240Q")
         k200capacity=self.check_host_vgpu_capacity("Group of NVIDIA Corporation GK104GL [GRID K2] GPUs","GRID K200")
@@ -1275,7 +1861,7 @@ class TestvGPUWindowsVm(cloudstackTestCase):
 
     @attr(tags = ['advanced', 'basic' , 'vgpu'], required_hardware="true")
 
-    def test_22_K1_vgpuvm_vgpuvm_offline(self):
+    def test_31_K1_vgpuvm_vgpuvm_offline(self):
         """Test to change service from K1 vgpu K120Q to K1 vgpu K140Q"""
 
         k140qcapacity=self.check_host_vgpu_capacity("Group of NVIDIA Corporation GK107GL [GRID K1] GPUs","GRID K140Q")
@@ -1290,7 +1876,7 @@ class TestvGPUWindowsVm(cloudstackTestCase):
 
     @attr(tags = ['advanced', 'basic' , 'vgpu'], required_hardware="true")
 
-    def test_23_nonvgpuvm_k1vgpuvm_offline(self):
+    def test_32_nonvgpuvm_k1vgpuvm_offline(self):
         """Test to change service from non vgpu to vgpu K100"""
 
         k100capacity=self.check_host_vgpu_capacity("Group of NVIDIA Corporation GK107GL [GRID K1] GPUs","GRID K100")
@@ -1303,7 +1889,7 @@ class TestvGPUWindowsVm(cloudstackTestCase):
 
     @attr(tags = ['advanced', 'basic' , 'vgpu'], required_hardware="true")
 
-    def test_24_K2_vgpuvm_nonvgpuvm_offline(self):
+    def test_33_K2_vgpuvm_nonvgpuvm_offline(self):
         """Test to change service from non vgpu to vgpu K240Q"""
 
         k240qcapacity=self.check_host_vgpu_capacity("Group of NVIDIA Corporation GK104GL [GRID K2] GPUs","GRID K240Q")
@@ -1316,7 +1902,7 @@ class TestvGPUWindowsVm(cloudstackTestCase):
 
     @attr(tags = ['advanced', 'basic' , 'vgpu'], required_hardware="true")
 
-    def test_25_K1_vgpuvm_nonvgpuvm_offline(self):
+    def test_34_K1_vgpuvm_nonvgpuvm_offline(self):
         """Test to change service from non vgpu to vgpu K140Q"""
 
         k140qcapacity=self.check_host_vgpu_capacity("Group of NVIDIA Corporation GK107GL [GRID K1] GPUs","GRID K140Q")
@@ -1331,7 +1917,7 @@ class TestvGPUWindowsVm(cloudstackTestCase):
 
     @attr(tags = ['advanced', 'basic' , 'vgpu'], required_hardware="true")
 
-    def test_26_K140Q_vgpuvm_K240Q_vgpuvm_offline(self):
+    def test_35_K140Q_vgpuvm_K240Q_vgpuvm_offline(self):
         """Test to change service from K1 vgpu K140Q to K2 vgpu K240Q"""
 
         k140qcapacity=self.check_host_vgpu_capacity("Group of NVIDIA Corporation GK107GL [GRID K1] GPUs","GRID K140Q")
@@ -1345,7 +1931,7 @@ class TestvGPUWindowsVm(cloudstackTestCase):
 
     @attr(tags = ['advanced', 'basic' , 'vgpu'], required_hardware="true")
 
-    def test_27_K240Q_vgpuvm_K140Q_vgpuvm_offline(self):
+    def test_36_K240Q_vgpuvm_K140Q_vgpuvm_offline(self):
         """Test to change service from K2 vgpu K240Q to K1 vgpu K140Q"""
 
         k140qcapacity=self.check_host_vgpu_capacity("Group of NVIDIA Corporation GK107GL [GRID K1] GPUs","GRID K140Q")


[12/50] [abbrv] CLOUDSTACK-7693: Fixing pep8 issues

Posted by ki...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/159a372f/test/integration/component/test_routers.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_routers.py b/test/integration/component/test_routers.py
index 24f44b3..0a74234 100644
--- a/test/integration/component/test_routers.py
+++ b/test/integration/component/test_routers.py
@@ -5,9 +5,9 @@
 # to you under the Apache License, Version 2.0 (the
 # "License"); you may not use this file except in compliance
 # with the License.  You may obtain a copy of the License at
-# 
+#
 #   http://www.apache.org/licenses/LICENSE-2.0
-# 
+#
 # Unless required by applicable law or agreed to in writing,
 # software distributed under the License is distributed on an
 # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -16,81 +16,101 @@
 # under the License.
 """ P1 tests for routers
 """
-#Import Local Modules
-import marvin
+# Import Local Modules
 from nose.plugins.attrib import attr
-from marvin.cloudstackTestCase import *
-from marvin.cloudstackAPI import *
-from marvin.lib.utils import *
-from marvin.lib.base import *
-from marvin.lib.common import *
-
-#Import System modules
+from marvin.cloudstackTestCase import cloudstackTestCase
+from marvin.cloudstackAPI import (stopVirtualMachine,
+                                  stopRouter,
+                                  startRouter)
+from marvin.lib.utils import (cleanup_resources,
+                              get_process_status,
+                              get_host_credentials)
+from marvin.lib.base import (ServiceOffering,
+                             VirtualMachine,
+                             Account,
+                             LoadBalancerRule,
+                             FireWallRule,
+                             NATRule)
+from marvin.lib.common import (get_zone,
+                               get_template,
+                               get_domain,
+                               list_virtual_machines,
+                               list_networks,
+                               list_configurations,
+                               list_routers,
+                               list_nat_rules,
+                               list_publicIP,
+                               list_lb_rules,
+                               list_firewall_rules,
+                               list_hosts)
+
+# Import System modules
 import time
 
 
 class Services:
+
     """Test router Services
     """
 
     def __init__(self):
         self.services = {
-                         "service_offering": {
-                                    "name": "Tiny Instance",
-                                    "displaytext": "Tiny Instance",
-                                    "cpunumber": 1,
-                                    "cpuspeed": 100,    # in MHz
+            "service_offering": {
+                "name": "Tiny Instance",
+                "displaytext": "Tiny Instance",
+                "cpunumber": 1,
+                "cpuspeed": 100,    # in MHz
                                     "memory": 128,       # In MBs
-                                    },
-                        "virtual_machine":
-                                    {
-                                        "displayname": "Test VM",
-                                        "username": "root",
-                                        "password": "password",
-                                        "ssh_port": 22,
-                                        "hypervisor": 'XenServer',
-                                        # Hypervisor type should be same as
-                                        # hypervisor type of cluster
-                                        "privateport": 22,
-                                        "publicport": 22,
-                                        "protocol": 'TCP',
-                                },
-                        "host": {
-                                        "username": "root",
-                                        "password": "password",
-                                        "publicport": 22,
-                            },
-                        "account": {
-                                        "email": "test@test.com",
-                                        "firstname": "Test",
-                                        "lastname": "User",
-                                        "username": "testuser",
-                                        "password": "password",
-                                    },
-                        "natrule":
-                                {
-                                    "privateport": 22,
-                                    "publicport": 22,
-                                    "protocol": "TCP"
-                                },
-                         "lbrule":
-                                {
-                                    "name": "SSH",
-                                    "alg": "roundrobin",
-                                    # Algorithm used for load balancing
-                                    "privateport": 22,
-                                    "publicport": 22,
-                                    "protocol": 'TCP',
-                                },
-                         "fw_rule": {
-                                    "startport": 1,
-                                    "endport": 6000,
-                                    "cidr": '55.55.0.0/11',
-                                    # Any network (For creating FW rule
-                                    },
-                         "ostype": 'CentOS 5.3 (64-bit)',
-                         # Used for Get_Template : CentOS 5.3 (64 bit)
-                        }
+            },
+            "virtual_machine":
+            {
+                "displayname": "Test VM",
+                "username": "root",
+                "password": "password",
+                "ssh_port": 22,
+                "hypervisor": 'XenServer',
+                # Hypervisor type should be same as
+                # hypervisor type of cluster
+                "privateport": 22,
+                "publicport": 22,
+                "protocol": 'TCP',
+            },
+            "host": {
+                "username": "root",
+                "password": "password",
+                "publicport": 22,
+            },
+            "account": {
+                "email": "test@test.com",
+                "firstname": "Test",
+                "lastname": "User",
+                "username": "testuser",
+                "password": "password",
+            },
+            "natrule":
+            {
+                "privateport": 22,
+                "publicport": 22,
+                "protocol": "TCP"
+            },
+            "lbrule":
+            {
+                "name": "SSH",
+                "alg": "roundrobin",
+                # Algorithm used for load balancing
+                "privateport": 22,
+                "publicport": 22,
+                "protocol": 'TCP',
+            },
+            "fw_rule": {
+                "startport": 1,
+                "endport": 6000,
+                "cidr": '55.55.0.0/11',
+                # Any network (For creating FW rule
+            },
+            "ostype": 'CentOS 5.3 (64-bit)',
+            # Used for Get_Template : CentOS 5.3 (64 bit)
+        }
 
 
 class TestRouterServices(cloudstackTestCase):
@@ -107,50 +127,52 @@ class TestRouterServices(cloudstackTestCase):
         cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
         cls.services['mode'] = cls.zone.networktype
         cls.template = get_template(
-                            cls.api_client,
-                            cls.zone.id,
-                            cls.services["ostype"]
-                            )
+            cls.api_client,
+            cls.zone.id,
+            cls.services["ostype"]
+        )
         cls.services["virtual_machine"]["zoneid"] = cls.zone.id
 
-        #Create an account, network, VM and IP addresses
+        # Create an account, network, VM and IP addresses
         cls.account = Account.create(
-                                     cls.api_client,
-                                     cls.services["account"],
-                                     admin=True,
-                                     domainid=cls.domain.id
-                                     )
+            cls.api_client,
+            cls.services["account"],
+            admin=True,
+            domainid=cls.domain.id
+        )
         cls.service_offering = ServiceOffering.create(
-                                            cls.api_client,
-                                            cls.services["service_offering"]
-                                            )
+            cls.api_client,
+            cls.services["service_offering"]
+        )
         cls.vm_1 = 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
-                                    )
+            cls.api_client,
+            cls.services["virtual_machine"],
+            templateid=cls.template.id,
+            accountid=cls.account.name,
+            domainid=cls.account.domainid,
+            serviceofferingid=cls.service_offering.id
+        )
         cls.vm_2 = VirtualMachine.create(
-                                    cls.api_client,
-                                    cls.services["virtual_machine"],
-                                    templateid=cls.template.id,
-                                    accountid=cls.account.name,
-                                    domainid=cls.account.domainid,
-                                    serviceofferingid=cls.service_offering.id
-                                    )
+            cls.api_client,
+            cls.services["virtual_machine"],
+            templateid=cls.template.id,
+            accountid=cls.account.name,
+            domainid=cls.account.domainid,
+            serviceofferingid=cls.service_offering.id
+        )
         cls._cleanup = [
-                       cls.account,
-                       cls.service_offering
-                       ]
+            cls.account,
+            cls.service_offering
+        ]
         return
 
     @classmethod
     def tearDownClass(cls):
         try:
-            cls.api_client = super(TestRouterServices, cls).getClsTestClient().getApiClient()
-            #Clean up, terminate the created templates
+            cls.api_client = super(
+                TestRouterServices,
+                cls).getClsTestClient().getApiClient()
+            # Clean up, terminate the created templates
             cleanup_resources(cls.api_client, cls._cleanup)
 
         except Exception as e:
@@ -184,142 +206,143 @@ class TestRouterServices(cloudstackTestCase):
         #    g. userdata
         # 2. wait for router to start and guest network to be created
         #    a. listRouters account=user, domainid=1 (router state=Running)
-        #    b. listNetworks account=user domainid=1 (network state=Implemented)
+        #    b. listNetworks account=user domainid=1
+        #       (network state=Implemented)
         #    c. listVirtualMachines account=user domainid=1 (VM state=Running)
         # 3. listNetwork
 
         routers = list_routers(
-                               self.apiclient,
-                               account=self.account.name,
-                               domainid=self.account.domainid,
-                               )
+            self.apiclient,
+            account=self.account.name,
+            domainid=self.account.domainid,
+        )
 
         self.assertEqual(
-                        isinstance(routers, list),
-                        True,
-                        "Check for list routers response return valid data"
-                        )
+            isinstance(routers, list),
+            True,
+            "Check for list routers response return valid data"
+        )
         self.assertNotEqual(
-                             len(routers),
-                             0,
-                             "Check list router response"
-                             )
+            len(routers),
+            0,
+            "Check list router response"
+        )
         for router in routers:
             self.debug("Router ID: %s & Router state: %s" % (
-                                                             router.id,
-                                                             router.state
-                                                             ))
+                router.id,
+                router.state
+            ))
             self.assertEqual(
-                        router.state,
-                        'Running',
-                        "Router state is not running but is  %s" % router.state
-                    )
+                router.state,
+                'Running',
+                "Router state is not running but is  %s" % router.state
+            )
 
         # Network state associated with account should be 'Implemented'
         networks = list_networks(
-                                 self.apiclient,
-                                 account=self.account.name,
-                                 domainid=self.account.domainid,
-                                 type = 'Isolated'
-                                 )
+            self.apiclient,
+            account=self.account.name,
+            domainid=self.account.domainid,
+            type='Isolated'
+        )
         self.assertEqual(
-                        isinstance(networks, list),
-                        True,
-                        "Check for list networks response return valid data"
-                        )
+            isinstance(networks, list),
+            True,
+            "Check for list networks response return valid data"
+        )
 
         self.assertNotEqual(
-                             len(networks),
-                             0,
-                             "Check list networks response"
-                             )
+            len(networks),
+            0,
+            "Check list networks response"
+        )
         for network in networks:
             self.debug("Network ID: %s & Network state: %s" % (
-                                                             network.id,
-                                                             network.state
-                                                             ))
+                network.id,
+                network.state
+            ))
             self.assertIn(
-                        network.state,
-                        ['Implemented', 'Allocated'],
-                        "Check list network response for network state"
-                    )
+                network.state,
+                ['Implemented', 'Allocated'],
+                "Check list network response for network state"
+            )
 
         # VM state associated with account should be 'Running'
         virtual_machines = list_virtual_machines(
-                                self.apiclient,
-                                account=self.account.name,
-                                domainid=self.account.domainid
-                                )
+            self.apiclient,
+            account=self.account.name,
+            domainid=self.account.domainid
+        )
 
         self.assertEqual(
-                        isinstance(virtual_machines, list),
-                        True,
-                        "Check for list virtual machines response return valid data"
-                        )
+            isinstance(virtual_machines, list),
+            True,
+            "Check for list virtual machines response return valid data"
+        )
         self.assertNotEqual(
-                             len(virtual_machines),
-                             0,
-                             "Check list virtual machines response"
-                             )
+            len(virtual_machines),
+            0,
+            "Check list virtual machines response"
+        )
         for virtual_machine in virtual_machines:
             self.assertEqual(
-                        virtual_machine.state,
-                        'Running',
-                        "Check list VM response for Running state"
-                    )
+                virtual_machine.state,
+                'Running',
+                "Check list VM response for Running state"
+            )
             self.debug("VM ID: %s & VM state: %s" % (
-                                                     virtual_machine.id,
-                                                     virtual_machine.state
-                                                    ))
+                virtual_machine.id,
+                virtual_machine.state
+            ))
 
         # Check status of DNS, DHCP, FIrewall, LB VPN processes
         networks = list_networks(
-                                 self.apiclient,
-                                 account=self.account.name,
-                                 domainid=self.account.domainid,
-                                 type = 'Isolated'
-                                 )
+            self.apiclient,
+            account=self.account.name,
+            domainid=self.account.domainid,
+            type='Isolated'
+        )
         self.assertEqual(
-                        isinstance(networks, list),
-                        True,
-                        "Check for list networks response return valid data"
-                        )
+            isinstance(networks, list),
+            True,
+            "Check for list networks response return valid data"
+        )
         self.assertNotEqual(
-                             len(networks),
-                             0,
-                             "Check list networks response"
-                             )
+            len(networks),
+            0,
+            "Check list networks response"
+        )
         # Load Balancer, Userdata, VPN, Firewall, Gateway, DNS processes should
         # be running
         for network in networks:
             self.assertEqual(
-                        'Lb' in str(network.service),
-                        True,
-                        "Check Load balancing process in list networks"
-                    )
+                'Lb' in str(network.service),
+                True,
+                "Check Load balancing process in list networks"
+            )
             self.assertEqual(
-                        'UserData' in str(network.service),
-                        True,
-                        "Check UserData service in list networks"
-                    )
+                'UserData' in str(network.service),
+                True,
+                "Check UserData service in list networks"
+            )
             self.assertEqual(
-                        'Vpn' in str(network.service),
-                        True,
-                        "Check Vpn service in list networks"
-                    )
+                'Vpn' in str(network.service),
+                True,
+                "Check Vpn service in list networks"
+            )
             self.assertEqual(
-                        'Firewall' in str(network.service),
-                        True,
-                        "Check Firewall service in list networks"
-                    )
+                'Firewall' in str(network.service),
+                True,
+                "Check Firewall service in list networks"
+            )
             self.assertEqual(
-                        'Dns' in str(network.service),
-                        True,
-                        "Check Dns service in list networks"
-                    )
+                'Dns' in str(network.service),
+                True,
+                "Check Dns service in list networks"
+            )
         return
 
-    @attr(configuration = "network.gc")
+    @attr(configuration="network.gc")
     @attr(tags=["advanced"], required_hardware="false")
     def test_02_NetworkGarbageCollection(self):
         """Test network garbage collection
@@ -336,36 +359,38 @@ class TestRouterServices(cloudstackTestCase):
         # 7. listRouters account=user, domainid=1
 
         routers = list_routers(
-                               self.apiclient,
-                               account=self.account.name,
-                               domainid=self.account.domainid,
-                               )
+            self.apiclient,
+            account=self.account.name,
+            domainid=self.account.domainid,
+        )
 
         self.assertEqual(
-                        isinstance(routers, list),
-                        True,
-                        "Check for list routers response return valid data"
-                        )
+            isinstance(routers, list),
+            True,
+            "Check for list routers response return valid data"
+        )
         self.assertNotEqual(
-                             len(routers),
-                             0,
-                             "Check list router response"
-                             )
+            len(routers),
+            0,
+            "Check list router response"
+        )
         # Router associated with account should be in running state
         timeout = 180
         router = routers[0]
         self.debug("Router ID: %s & Router state: %s" % (
-                                                             router.id,
-                                                             router.state
-                                                             ))
-        self.debug("Wait for %s secs max for router to reach Running state" % timeout)
+            router.id,
+            router.state
+        ))
+        self.debug(
+            "Wait for %s secs max for router to reach Running state" %
+            timeout)
         while timeout:
             time.sleep(60)
             routers = list_routers(
-                               self.apiclient,
-                               account=self.account.name,
-                               domainid=self.account.domainid,
-                               id=router.id)
+                self.apiclient,
+                account=self.account.name,
+                domainid=self.account.domainid,
+                id=router.id)
             router = routers[0]
             if router.state == 'Running':
                 break
@@ -373,67 +398,66 @@ class TestRouterServices(cloudstackTestCase):
             timeout = timeout - 60
             if timeout == 0:
                 self.assertEqual(
-                        router.state,
-                        'Running',
-                        "Router not in Running state")
-
+                    router.state,
+                    'Running',
+                    "Router not in Running state")
 
         # Network state associated with account should be 'Implemented'
         networks = list_networks(
-                                 self.apiclient,
-                                 account=self.account.name,
-                                 domainid=self.account.domainid,
-                                 type = 'Isolated'
-                                 )
+            self.apiclient,
+            account=self.account.name,
+            domainid=self.account.domainid,
+            type='Isolated'
+        )
         self.assertEqual(
-                        isinstance(networks, list),
-                        True,
-                        "Check for list networks response return valid data"
-                        )
+            isinstance(networks, list),
+            True,
+            "Check for list networks response return valid data"
+        )
         self.assertNotEqual(
-                             len(networks),
-                             0,
-                             "Check list networks response"
-                             )
+            len(networks),
+            0,
+            "Check list networks response"
+        )
         # Check if network in 'Implemented' state
         for network in networks:
             self.debug("Network ID: %s & Network state: %s" % (
-                                                             network.id,
-                                                             network.state
-                                                             ))
+                network.id,
+                network.state
+            ))
             self.assertIn(
-                        network.state,
-                        ['Implemented', 'Allocated'],
-                        "Check list network response for network state"
-                    )
+                network.state,
+                ['Implemented', 'Allocated'],
+                "Check list network response for network state"
+            )
 
         # VM state associated with account should be 'Running'
         virtual_machines = list_virtual_machines(
-                                self.apiclient,
-                                account=self.account.name,
-                                domainid=self.account.domainid,
-                                )
+            self.apiclient,
+            account=self.account.name,
+            domainid=self.account.domainid,
+        )
 
         self.assertEqual(
-                        isinstance(virtual_machines, list),
-                        True,
-                        "Check for list virtual machines response return valid data"
-                        )
+            isinstance(virtual_machines, list),
+            True,
+            "Check for list virtual machines response return valid data"
+        )
         self.assertNotEqual(
-                             len(virtual_machines),
-                             0,
-                             "Check list virtual machines response"
-                             )
+            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
-                                                    ))
+                virtual_machine.id,
+                virtual_machine.state
+            ))
             self.assertEqual(
-                        virtual_machine.state,
-                        'Running',
-                        "Check list VM response for Running state"
-                    )
+                virtual_machine.state,
+                'Running',
+                "Check list VM response for Running state"
+            )
 
             # Stop virtual machine
             cmd = stopVirtualMachine.stopVirtualMachineCmd()
@@ -441,58 +465,59 @@ class TestRouterServices(cloudstackTestCase):
             self.apiclient.stopVirtualMachine(cmd)
 
         gcinterval = list_configurations(
-                                    self.apiclient,
-                                    name='network.gc.interval'
-                                    )
+            self.apiclient,
+            name='network.gc.interval'
+        )
         self.assertEqual(
-                        isinstance(gcinterval, list),
-                        True,
-                        "Check for list intervals response return valid data"
-                        )
+            isinstance(gcinterval, list),
+            True,
+            "Check for list intervals response return valid data"
+        )
         self.debug("network.gc.interval: %s" % gcinterval[0].value)
 
         gcwait = list_configurations(
-                                    self.apiclient,
-                                    name='network.gc.wait'
-                                    )
+            self.apiclient,
+            name='network.gc.wait'
+        )
         self.assertEqual(
-                        isinstance(gcwait, list),
-                        True,
-                        "Check for list intervals response return valid data"
-                        )
+            isinstance(gcwait, list),
+            True,
+            "Check for list intervals response return valid data"
+        )
         self.debug("network.gc.wait: %s" % gcwait[0].value)
 
         total_wait = int(gcinterval[0].value) + int(gcwait[0].value)
         # Router is stopped after (network.gc.interval *2) time. Wait for
-        # (network.gc.interval+network.gc.wait) * 2 for moving router to 'Stopped'
+        # (network.gc.interval+network.gc.wait) * 2 for moving
+        # router to 'Stopped'
         time.sleep(total_wait * 2)
 
         routers = list_routers(
-                               self.apiclient,
-                               account=self.account.name,
-                               domainid=self.account.domainid,
-                               )
+            self.apiclient,
+            account=self.account.name,
+            domainid=self.account.domainid,
+        )
 
         self.assertEqual(
-                        isinstance(routers, list),
-                        True,
-                        "Check for list routers response return valid data"
-                        )
+            isinstance(routers, list),
+            True,
+            "Check for list routers response return valid data"
+        )
         self.assertNotEqual(
-                             len(routers),
-                             0,
-                             "Check list router response"
-                             )
+            len(routers),
+            0,
+            "Check list router response"
+        )
         for router in routers:
             self.debug("Router ID: %s & Router state: %s" % (
-                                                             router.id,
-                                                             router.state
-                                                             ))
+                router.id,
+                router.state
+            ))
             self.assertEqual(
-                        router.state,
-                        'Stopped',
-                        "Check list router response for router state"
-                    )
+                router.state,
+                'Stopped',
+                "Check list router response for router state"
+            )
 
         # Cleanup Vm_2 - Not required for further tests
         self.cleanup.append(self.vm_2)
@@ -506,32 +531,32 @@ class TestRouterServices(cloudstackTestCase):
         # 1. deployVirtualMachine in the account
         # 2. listVirtualMachines account=user, domainid=1
         # 3. when listVirtualMachines reports the userVM to be in state=Running
-        # 4. listRouters should report router to have come back to "Running" state
+        # 4. listRouters should report router to have come back to "Running"
+        #    state
         # 5. All other VMs in the account should remain in "Stopped" state
 
-
-        #stop all pre-existing virtual machines if they are in 'Running' state
+        # stop all pre-existing virtual machines if they are in 'Running' state
         virtual_machines = list_virtual_machines(
-                                self.apiclient,
-                                account=self.account.name,
-                                domainid=self.account.domainid,
-                                )
+            self.apiclient,
+            account=self.account.name,
+            domainid=self.account.domainid,
+        )
 
         self.assertEqual(
-                        isinstance(virtual_machines, list),
-                        True,
-                        "Check for list virtual machines response return valid data"
-                        )
+            isinstance(virtual_machines, list),
+            True,
+            "Check for list virtual machines response return valid data"
+        )
         self.assertNotEqual(
-                             len(virtual_machines),
-                             0,
-                             "Check list virtual machines response"
-                             )
+            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
-                                                    ))
+                virtual_machine.id,
+                virtual_machine.state
+            ))
             if virtual_machine.state == 'Running':
                 # Stop virtual machine
                 cmd = stopVirtualMachine.stopVirtualMachineCmd()
@@ -539,101 +564,100 @@ class TestRouterServices(cloudstackTestCase):
                 self.apiclient.stopVirtualMachine(cmd)
 
         vm = 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
-                                    )
+            self.apiclient,
+            self.services["virtual_machine"],
+            templateid=self.template.id,
+            accountid=self.account.name,
+            domainid=self.account.domainid,
+            serviceofferingid=self.service_offering.id
+        )
         self.debug("Deployed a VM with ID: %s" % vm.id)
 
         virtual_machines = list_virtual_machines(
-                                self.apiclient,
-                                id=vm.id,
-                                account=self.account.name,
-                                domainid=self.account.domainid,
-                                )
+            self.apiclient,
+            id=vm.id,
+            account=self.account.name,
+            domainid=self.account.domainid,
+        )
 
         self.assertEqual(
-                        isinstance(virtual_machines, list),
-                        True,
-                        "Check for list virtual machines response return valid data"
-                        )
+            isinstance(virtual_machines, list),
+            True,
+            "Check for list virtual machines response return valid data"
+        )
 
         self.assertNotEqual(
-                             len(virtual_machines),
-                             0,
-                             "Check list virtual machines response"
-                             )
+            len(virtual_machines),
+            0,
+            "Check list virtual machines response"
+        )
         # VM state should be 'Running'
         for virtual_machine in virtual_machines:
             self.assertEqual(
-                        virtual_machine.state,
-                        'Running',
-                        "Check list VM response for Running state"
-                    )
+                virtual_machine.state,
+                'Running',
+                "Check list VM response for Running state"
+            )
 
         routers = list_routers(
-                               self.apiclient,
-                               account=self.account.name,
-                               domainid=self.account.domainid,
-                               )
+            self.apiclient,
+            account=self.account.name,
+            domainid=self.account.domainid,
+        )
 
         self.assertEqual(
-                        isinstance(routers, list),
-                        True,
-                        "Check for list routers response return valid data"
-                        )
+            isinstance(routers, list),
+            True,
+            "Check for list routers response return valid data"
+        )
 
         self.assertNotEqual(
-                             len(routers),
-                             0,
-                             "Check list router response"
-                             )
+            len(routers),
+            0,
+            "Check list router response"
+        )
         # Routers associated with account should be 'Running' after deployment
         # of VM
         for router in routers:
             self.debug("Router ID: %s & Router state: %s" % (
-                                                             router.id,
-                                                             router.state
-                                                             ))
+                router.id,
+                router.state
+            ))
             self.assertEqual(
-                        router.state,
-                        'Running',
-                        "Check list router response for router state"
-                    )
-
+                router.state,
+                'Running',
+                "Check list router response for router state"
+            )
 
         # All other VMs (VM_1) should be in 'Stopped'
         virtual_machines = list_virtual_machines(
-                                self.apiclient,
-                                id=self.vm_1.id,
-                                account=self.account.name,
-                                domainid=self.account.domainid,
-                                )
+            self.apiclient,
+            id=self.vm_1.id,
+            account=self.account.name,
+            domainid=self.account.domainid,
+        )
 
         self.assertEqual(
-                        isinstance(virtual_machines, list),
-                        True,
-                        "Check for list VMs response return valid data"
-                        )
+            isinstance(virtual_machines, list),
+            True,
+            "Check for list VMs response return valid data"
+        )
 
         self.assertNotEqual(
-                             len(virtual_machines),
-                             0,
-                             "Check list virtual machines response"
-                             )
+            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
-                                                    ))
+                virtual_machine.id,
+                virtual_machine.state
+            ))
             self.assertEqual(
-                        virtual_machine.state,
-                        'Stopped',
-                        "Check list VM response for Stopped state"
-                    )
+                virtual_machine.state,
+                'Stopped',
+                "Check list VM response for Stopped state"
+            )
 
         return
 
@@ -652,41 +676,43 @@ class TestRouterStopCreatePF(cloudstackTestCase):
         cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
         cls.services['mode'] = cls.zone.networktype
         template = get_template(
-                            cls.api_client,
-                            cls.zone.id,
-                            cls.services["ostype"]
-                            )
+            cls.api_client,
+            cls.zone.id,
+            cls.services["ostype"]
+        )
         cls.services["virtual_machine"]["zoneid"] = cls.zone.id
 
-        #Create an account, network, VM and IP addresses
+        # Create an account, network, VM and IP addresses
         cls.account = Account.create(
-                                     cls.api_client,
-                                     cls.services["account"],
-                                     admin=True,
-                                     domainid=cls.domain.id
-                                     )
+            cls.api_client,
+            cls.services["account"],
+            admin=True,
+            domainid=cls.domain.id
+        )
         cls.service_offering = ServiceOffering.create(
-                                            cls.api_client,
-                                            cls.services["service_offering"]
-                                            )
+            cls.api_client,
+            cls.services["service_offering"]
+        )
         cls.vm_1 = VirtualMachine.create(
-                                    cls.api_client,
-                                    cls.services["virtual_machine"],
-                                    templateid=template.id,
-                                    accountid=cls.account.name,
-                                    domainid=cls.account.domainid,
-                                    serviceofferingid=cls.service_offering.id
-                                    )
+            cls.api_client,
+            cls.services["virtual_machine"],
+            templateid=template.id,
+            accountid=cls.account.name,
+            domainid=cls.account.domainid,
+            serviceofferingid=cls.service_offering.id
+        )
         cls._cleanup = [
-                       cls.account,
-                       cls.service_offering
-                       ]
+            cls.account,
+            cls.service_offering
+        ]
         return
 
     @classmethod
     def tearDownClass(cls):
         try:
-            cls.api_client = super(TestRouterStopCreatePF, cls).getClsTestClient().getApiClient()
+            cls.api_client = super(
+                TestRouterStopCreatePF,
+                cls).getClsTestClient().getApiClient()
             # Clean up, terminate the created resources
             cleanup_resources(cls.api_client, cls._cleanup)
 
@@ -725,130 +751,132 @@ class TestRouterStopCreatePF(cloudstackTestCase):
 
         # Get router details associated for that account
         routers = list_routers(
-                               self.apiclient,
-                               account=self.account.name,
-                               domainid=self.account.domainid,
-                               )
+            self.apiclient,
+            account=self.account.name,
+            domainid=self.account.domainid,
+        )
 
         self.assertEqual(
-                        isinstance(routers, list),
-                        True,
-                        "Check for list routers response return valid data"
-                        )
+            isinstance(routers, list),
+            True,
+            "Check for list routers response return valid data"
+        )
         self.assertNotEqual(
-                             len(routers),
-                             0,
-                             "Check list router response"
-                             )
+            len(routers),
+            0,
+            "Check list router response"
+        )
         router = routers[0]
 
         self.debug("Stopping router ID: %s" % router.id)
 
-        #Stop the router
+        # Stop the router
         cmd = stopRouter.stopRouterCmd()
         cmd.id = router.id
         self.apiclient.stopRouter(cmd)
 
         routers = list_routers(
-                               self.apiclient,
-                               account=self.account.name,
-                               domainid=self.account.domainid,
-                               )
+            self.apiclient,
+            account=self.account.name,
+            domainid=self.account.domainid,
+        )
         self.assertEqual(
-                        isinstance(routers, list),
-                        True,
-                        "Check for list routers response return valid data"
-                        )
+            isinstance(routers, list),
+            True,
+            "Check for list routers response return valid data"
+        )
         router = routers[0]
 
         self.assertEqual(
-                    router.state,
-                    'Stopped',
-                    "Check list router response for router state"
-                    )
+            router.state,
+            'Stopped',
+            "Check list router response for router state"
+        )
 
         public_ips = list_publicIP(
-                                   self.apiclient,
-                                   account=self.account.name,
-                                   domainid=self.account.domainid,
-                                   zoneid=self.zone.id
-                                   )
+            self.apiclient,
+            account=self.account.name,
+            domainid=self.account.domainid,
+            zoneid=self.zone.id
+        )
         self.assertEqual(
-                        isinstance(public_ips, list),
-                        True,
-                        "Check for list public IPs response return valid data"
-                        )
+            isinstance(public_ips, list),
+            True,
+            "Check for list public IPs response return valid data"
+        )
 
         public_ip = public_ips[0]
 
         # Open up firewall port for SSH
-        fw_rule = FireWallRule.create(
-                            self.apiclient,
-                            ipaddressid=public_ip.id,
-                            protocol=self.services["natrule"]["protocol"],
-                            cidrlist=['0.0.0.0/0'],
-                            startport=self.services["natrule"]["publicport"],
-                            endport=self.services["natrule"]["publicport"]
-                            )
+        FireWallRule.create(
+            self.apiclient,
+            ipaddressid=public_ip.id,
+            protocol=self.services["natrule"]["protocol"],
+            cidrlist=['0.0.0.0/0'],
+            startport=self.services["natrule"]["publicport"],
+            endport=self.services["natrule"]["publicport"]
+        )
 
         self.debug("Creating NAT rule for VM ID: %s" % self.vm_1.id)
-        #Create NAT rule
+        # Create NAT rule
         nat_rule = NATRule.create(
-                        self.apiclient,
-                        self.vm_1,
-                        self.services["natrule"],
-                        public_ip.id
-                        )
+            self.apiclient,
+            self.vm_1,
+            self.services["natrule"],
+            public_ip.id
+        )
 
         self.debug("Starting router ID: %s" % router.id)
-        #Start the router
+        # Start the router
         cmd = startRouter.startRouterCmd()
         cmd.id = router.id
         self.apiclient.startRouter(cmd)
 
         routers = list_routers(
-                               self.apiclient,
-                               account=self.account.name,
-                               domainid=self.account.domainid,
-                               zoneid=self.zone.id
-                               )
+            self.apiclient,
+            account=self.account.name,
+            domainid=self.account.domainid,
+            zoneid=self.zone.id
+        )
         self.assertEqual(
-                        isinstance(routers, list),
-                        True,
-                        "Check for list routers response return valid data"
-                        )
+            isinstance(routers, list),
+            True,
+            "Check for list routers response return valid data"
+        )
         router = routers[0]
 
         self.assertEqual(
-                    router.state,
-                    'Running',
-                    "Check list router response for router state"
-                    )
+            router.state,
+            'Running',
+            "Check list router response for router state"
+        )
         # NAT Rule should be in Active state after router start
         nat_rules = list_nat_rules(
-                                   self.apiclient,
-                                   id=nat_rule.id
-                                   )
+            self.apiclient,
+            id=nat_rule.id
+        )
         self.assertEqual(
-                        isinstance(nat_rules, list),
-                        True,
-                        "Check for list NAT rules response return valid data"
-                        )
+            isinstance(nat_rules, list),
+            True,
+            "Check for list NAT rules response return valid data"
+        )
         self.assertEqual(
-                    nat_rules[0].state,
-                    'Active',
-                    "Check list port forwarding rules"
-                    )
+            nat_rules[0].state,
+            'Active',
+            "Check list port forwarding rules"
+        )
         try:
 
             self.debug("SSH into VM with ID: %s" % nat_rule.ipaddress)
 
-            self.vm_1.get_ssh_client(ipaddress=nat_rule.ipaddress, port=self.services["natrule"]["publicport"])
+            self.vm_1.get_ssh_client(
+                ipaddress=nat_rule.ipaddress,
+                port=self.services["natrule"]["publicport"])
         except Exception as e:
             self.fail(
-                      "SSH Access failed for %s: %s" % \
-                      (nat_rule.ipaddress, e)
-                      )
+                "SSH Access failed for %s: %s" %
+                (nat_rule.ipaddress, e)
+            )
         return
 
 
@@ -866,42 +894,44 @@ class TestRouterStopCreateLB(cloudstackTestCase):
         cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
         cls.services['mode'] = cls.zone.networktype
         template = get_template(
-                            cls.api_client,
-                            cls.zone.id,
-                            cls.services["ostype"]
-                            )
+            cls.api_client,
+            cls.zone.id,
+            cls.services["ostype"]
+        )
         cls.services["virtual_machine"]["zoneid"] = cls.zone.id
 
-        #Create an account, network, VM and IP addresses
+        # Create an account, network, VM and IP addresses
         cls.account = Account.create(
-                                     cls.api_client,
-                                     cls.services["account"],
-                                     admin=True,
-                                     domainid=cls.domain.id
-                                     )
+            cls.api_client,
+            cls.services["account"],
+            admin=True,
+            domainid=cls.domain.id
+        )
         cls.service_offering = ServiceOffering.create(
-                                            cls.api_client,
-                                            cls.services["service_offering"]
-                                            )
+            cls.api_client,
+            cls.services["service_offering"]
+        )
         cls.vm_1 = VirtualMachine.create(
-                                    cls.api_client,
-                                    cls.services["virtual_machine"],
-                                    templateid=template.id,
-                                    accountid=cls.account.name,
-                                    domainid=cls.account.domainid,
-                                    serviceofferingid=cls.service_offering.id
-                                    )
+            cls.api_client,
+            cls.services["virtual_machine"],
+            templateid=template.id,
+            accountid=cls.account.name,
+            domainid=cls.account.domainid,
+            serviceofferingid=cls.service_offering.id
+        )
         cls._cleanup = [
-                       cls.account,
-                       cls.service_offering
-                       ]
+            cls.account,
+            cls.service_offering
+        ]
         return
 
     @classmethod
     def tearDownClass(cls):
         try:
-            cls.api_client = super(TestRouterStopCreateLB, cls).getClsTestClient().getApiClient()
-            #Clean up, terminate the created resources
+            cls.api_client = super(
+                TestRouterStopCreateLB,
+                cls).getClsTestClient().getApiClient()
+            # Clean up, terminate the created resources
             cleanup_resources(cls.api_client, cls._cleanup)
 
         except Exception as e:
@@ -933,126 +963,126 @@ class TestRouterStopCreateLB(cloudstackTestCase):
 
         # Get router details associated for that account
         routers = list_routers(
-                               self.apiclient,
-                               account=self.account.name,
-                               domainid=self.account.domainid,
-                               )
+            self.apiclient,
+            account=self.account.name,
+            domainid=self.account.domainid,
+        )
 
         self.assertEqual(
-                        isinstance(routers, list),
-                        True,
-                        "Check for list routers response return valid data"
-                        )
+            isinstance(routers, list),
+            True,
+            "Check for list routers response return valid data"
+        )
 
         self.assertNotEqual(
-                             len(routers),
-                             0,
-                             "Check list router response"
-                             )
+            len(routers),
+            0,
+            "Check list router response"
+        )
 
         router = routers[0]
 
         self.debug("Stopping router with ID: %s" % router.id)
-        #Stop the router
+        # Stop the router
         cmd = stopRouter.stopRouterCmd()
         cmd.id = router.id
         self.apiclient.stopRouter(cmd)
 
         routers = list_routers(
-                               self.apiclient,
-                               account=self.account.name,
-                               domainid=self.account.domainid,
-                               )
+            self.apiclient,
+            account=self.account.name,
+            domainid=self.account.domainid,
+        )
         self.assertEqual(
-                        isinstance(routers, list),
-                        True,
-                        "Check for list routers response return valid data"
-                        )
+            isinstance(routers, list),
+            True,
+            "Check for list routers response return valid data"
+        )
         router = routers[0]
 
         self.assertEqual(
-                    router.state,
-                    'Stopped',
-                    "Check list router response for router state"
-                    )
+            router.state,
+            'Stopped',
+            "Check list router response for router state"
+        )
 
         public_ips = list_publicIP(
-                                   self.apiclient,
-                                   account=self.account.name,
-                                   domainid=self.account.domainid
-                                   )
+            self.apiclient,
+            account=self.account.name,
+            domainid=self.account.domainid
+        )
         self.assertEqual(
-                        isinstance(public_ips, list),
-                        True,
-                        "Check for list public IPs response return valid data"
-                        )
+            isinstance(public_ips, list),
+            True,
+            "Check for list public IPs response return valid data"
+        )
         public_ip = public_ips[0]
 
         # Open up firewall port for SSH
-        fw_rule = FireWallRule.create(
-                            self.apiclient,
-                            ipaddressid=public_ip.id,
-                            protocol=self.services["lbrule"]["protocol"],
-                            cidrlist=['0.0.0.0/0'],
-                            startport=self.services["lbrule"]["publicport"],
-                            endport=self.services["lbrule"]["publicport"]
-                            )
+        FireWallRule.create(
+            self.apiclient,
+            ipaddressid=public_ip.id,
+            protocol=self.services["lbrule"]["protocol"],
+            cidrlist=['0.0.0.0/0'],
+            startport=self.services["lbrule"]["publicport"],
+            endport=self.services["lbrule"]["publicport"]
+        )
         self.debug("Creating LB rule for public IP: %s" % public_ip.id)
-        #Create Load Balancer rule and assign VMs to rule
+        # Create Load Balancer rule and assign VMs to rule
         lb_rule = LoadBalancerRule.create(
-                                          self.apiclient,
-                                          self.services["lbrule"],
-                                          public_ip.id,
-                                          accountid=self.account.name
-                                          )
+            self.apiclient,
+            self.services["lbrule"],
+            public_ip.id,
+            accountid=self.account.name
+        )
         self.debug("Assigning VM %s to LB rule: %s" % (
-                                                       self.vm_1.id,
-                                                       lb_rule.id
-                                                       ))
+            self.vm_1.id,
+            lb_rule.id
+        ))
         lb_rule.assign(self.apiclient, [self.vm_1])
 
-        #Start the router
+        # Start the router
         cmd = startRouter.startRouterCmd()
         cmd.id = router.id
         self.apiclient.startRouter(cmd)
 
         routers = list_routers(
-                               self.apiclient,
-                               account=self.account.name,
-                               domainid=self.account.domainid,
-                               )
+            self.apiclient,
+            account=self.account.name,
+            domainid=self.account.domainid,
+        )
         self.assertEqual(
-                        isinstance(routers, list),
-                        True,
-                        "Check for list routers response return valid data"
-                        )
+            isinstance(routers, list),
+            True,
+            "Check for list routers response return valid data"
+        )
         router = routers[0]
 
         self.assertEqual(
-                    router.state,
-                    'Running',
-                    "Check list router response for router state"
-                    )
+            router.state,
+            'Running',
+            "Check list router response for router state"
+        )
         # After router start, LB RUle should be in Active state
         lb_rules = list_lb_rules(
-                                   self.apiclient,
-                                   id=lb_rule.id
-                                   )
+            self.apiclient,
+            id=lb_rule.id
+        )
         self.assertEqual(
-                        isinstance(lb_rules, list),
-                        True,
-                        "Check for list LB rules response return valid data"
-                        )
+            isinstance(lb_rules, list),
+            True,
+            "Check for list LB rules response return valid data"
+        )
         self.assertEqual(
-                    lb_rules[0].state,
-                    'Active',
-                    "Check list load balancing rules"
-                    )
+            lb_rules[0].state,
+            'Active',
+            "Check list load balancing rules"
+        )
         self.assertEqual(
-                    lb_rules[0].publicport,
-                    str(self.services["lbrule"]["publicport"]),
-                    "Check list load balancing rules"
-                    )
+            lb_rules[0].publicport,
+            str(self.services["lbrule"]["publicport"]),
+            "Check list load balancing rules"
+        )
 
         try:
             self.debug("SSH into VM with IP: %s" % public_ip.ipaddress)
@@ -1060,9 +1090,9 @@ class TestRouterStopCreateLB(cloudstackTestCase):
             self.vm_1.get_ssh_client(public_ip.ipaddress)
         except Exception as e:
             self.fail(
-                      "SSH Access failed for %s: %s" % \
-                      (self.vm_1.ipaddress, e)
-                      )
+                "SSH Access failed for %s: %s" %
+                (self.vm_1.ipaddress, e)
+            )
         return
 
 
@@ -1080,41 +1110,43 @@ class TestRouterStopCreateFW(cloudstackTestCase):
         cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
         cls.services['mode'] = cls.zone.networktype
         template = get_template(
-                            cls.api_client,
-                            cls.zone.id,
-                            cls.services["ostype"]
-                            )
+            cls.api_client,
+            cls.zone.id,
+            cls.services["ostype"]
+        )
         cls.services["virtual_machine"]["zoneid"] = cls.zone.id
 
-        #Create an account, network, VM and IP addresses
+        # Create an account, network, VM and IP addresses
         cls.account = Account.create(
-                                     cls.api_client,
-                                     cls.services["account"],
-                                     domainid=cls.domain.id
-                                     )
+            cls.api_client,
+            cls.services["account"],
+            domainid=cls.domain.id
+        )
         cls.service_offering = ServiceOffering.create(
-                                            cls.api_client,
-                                            cls.services["service_offering"]
-                                            )
+            cls.api_client,
+            cls.services["service_offering"]
+        )
         cls.vm_1 = VirtualMachine.create(
-                                    cls.api_client,
-                                    cls.services["virtual_machine"],
-                                    templateid=template.id,
-                                    accountid=cls.account.name,
-                                    domainid=cls.account.domainid,
-                                    serviceofferingid=cls.service_offering.id
-                                    )
+            cls.api_client,
+            cls.services["virtual_machine"],
+            templateid=template.id,
+            accountid=cls.account.name,
+            domainid=cls.account.domainid,
+            serviceofferingid=cls.service_offering.id
+        )
         cls._cleanup = [
-                       cls.account,
-                       cls.service_offering
-                       ]
+            cls.account,
+            cls.service_offering
+        ]
         return
 
     @classmethod
     def tearDownClass(cls):
         try:
-            cls.api_client = super(TestRouterStopCreateFW, cls).getClsTestClient().getApiClient()
-            #Clean up, terminate the created templates
+            cls.api_client = super(
+                TestRouterStopCreateFW,
+                cls).getClsTestClient().getApiClient()
+            # Clean up, terminate the created templates
             cleanup_resources(cls.api_client, cls._cleanup)
 
         except Exception as e:
@@ -1146,147 +1178,148 @@ class TestRouterStopCreateFW(cloudstackTestCase):
 
         # Get the router details associated with account
         routers = list_routers(
-                               self.apiclient,
-                               account=self.account.name,
-                               domainid=self.account.domainid,
-                               )
+            self.apiclient,
+            account=self.account.name,
+            domainid=self.account.domainid,
+        )
 
         self.assertEqual(
-                        isinstance(routers, list),
-                        True,
-                        "Check for list routers response return valid data"
-                        )
+            isinstance(routers, list),
+            True,
+            "Check for list routers response return valid data"
+        )
 
         self.assertNotEqual(
-                             len(routers),
-                             0,
-                             "Check list router response"
-                             )
+            len(routers),
+            0,
+            "Check list router response"
+        )
 
         router = routers[0]
 
         self.debug("Stopping the router: %s" % router.id)
-        #Stop the router
+        # Stop the router
         cmd = stopRouter.stopRouterCmd()
         cmd.id = router.id
         self.apiclient.stopRouter(cmd)
 
         routers = list_routers(
-                               self.apiclient,
-                               account=self.account.name,
-                               domainid=self.account.domainid,
-                               )
+            self.apiclient,
+            account=self.account.name,
+            domainid=self.account.domainid,
+        )
         self.assertEqual(
-                        isinstance(routers, list),
-                        True,
-                        "Check for list routers response return valid data"
-                        )
+            isinstance(routers, list),
+            True,
+            "Check for list routers response return valid data"
+        )
         router = routers[0]
 
         self.assertEqual(
-                    router.state,
-                    'Stopped',
-                    "Check list router response for router state"
-                    )
+            router.state,
+            'Stopped',
+            "Check list router response for router state"
+        )
 
         public_ips = list_publicIP(
-                                   self.apiclient,
-                                   account=self.account.name,
-                                   domainid=self.account.domainid
-                                   )
+            self.apiclient,
+            account=self.account.name,
+            domainid=self.account.domainid
+        )
         self.assertEqual(
-                        isinstance(public_ips, list),
-                        True,
-                        "Check for list public IP response return valid data"
-                        )
+            isinstance(public_ips, list),
+            True,
+            "Check for list public IP response return valid data"
+        )
         public_ip = public_ips[0]
 
-        #Create Firewall rule with configurations from settings file
+        # Create Firewall rule with configurations from settings file
         fw_rule = FireWallRule.create(
-                            self.apiclient,
-                            ipaddressid=public_ip.id,
-                            protocol='TCP',
-                            cidrlist=[self.services["fw_rule"]["cidr"]],
-                            startport=self.services["fw_rule"]["startport"],
-                            endport=self.services["fw_rule"]["endport"]
-                            )
+            self.apiclient,
+            ipaddressid=public_ip.id,
+            protocol='TCP',
+            cidrlist=[self.services["fw_rule"]["cidr"]],
+            startport=self.services["fw_rule"]["startport"],
+            endport=self.services["fw_rule"]["endport"]
+        )
         self.debug("Created firewall rule: %s" % fw_rule.id)
 
         self.debug("Starting the router: %s" % router.id)
-        #Start the router
+        # Start the router
         cmd = startRouter.startRouterCmd()
         cmd.id = router.id
         self.apiclient.startRouter(cmd)
 
         routers = list_routers(
-                               self.apiclient,
-                               account=self.account.name,
-                               domainid=self.account.domainid,
-                               )
+            self.apiclient,
+            account=self.account.name,
+            domainid=self.account.domainid,
+        )
         self.assertEqual(
-                        isinstance(routers, list),
-                        True,
-                        "Check for list routers response return valid data"
-                        )
+            isinstance(routers, list),
+            True,
+            "Check for list routers response return valid data"
+        )
 
         router = routers[0]
 
         self.assertEqual(
-                    router.state,
-                    'Running',
-                    "Check list router response for router state"
-                    )
+            router.state,
+            'Running',
+            "Check list router response for router state"
+        )
         # After Router start, FW rule should be in Active state
         fw_rules = list_firewall_rules(
-                                   self.apiclient,
-                                   id=fw_rule.id,
-                                   )
+            self.apiclient,
+            id=fw_rule.id,
+        )
         self.assertEqual(
-                        isinstance(fw_rules, list),
-                        True,
-                        "Check for list FW rules response return valid data"
-                        )
+            isinstance(fw_rules, list),
+            True,
+            "Check for list FW rules response return valid data"
+        )
 
         self.assertEqual(
-                    fw_rules[0].state,
-                    'Active',
-                    "Check list load balancing rules"
-                    )
+            fw_rules[0].state,
+            'Active',
+            "Check list load balancing rules"
+        )
         self.assertEqual(
-                    fw_rules[0].startport,
-                    str(self.services["fw_rule"]["startport"]),
-                    "Check start port of firewall rule"
-                    )
+            fw_rules[0].startport,
+            str(self.services["fw_rule"]["startport"]),
+            "Check start port of firewall rule"
+        )
 
         self.assertEqual(
-                    fw_rules[0].endport,
-                    str(self.services["fw_rule"]["endport"]),
-                    "Check end port of firewall rule"
-                    )
+            fw_rules[0].endport,
+            str(self.services["fw_rule"]["endport"]),
+            "Check end port of firewall rule"
+        )
         # For DNS and DHCP check 'dnsmasq' process status
         if (self.hypervisor.lower() == 'vmware'
-                         or self.hypervisor.lower() == 'hyperv'):
+                or self.hypervisor.lower() == 'hyperv'):
             result = get_process_status(
-                               self.apiclient.connection.mgtSvr,
-                               22,
-                               self.apiclient.connection.user,
-                               self.apiclient.connection.passwd,
-                               router.linklocalip,
-                               'iptables -t nat -L',
-                                hypervisor=self.hypervisor
-                               )
+                self.apiclient.connection.mgtSvr,
+                22,
+                self.apiclient.connection.user,
+                self.apiclient.connection.passwd,
+                router.linklocalip,
+                'iptables -t nat -L',
+                hypervisor=self.hypervisor
+            )
         else:
             hosts = list_hosts(
-                        self.apiclient,
-                        id=router.hostid,
-                        )
+                self.apiclient,
+                id=router.hostid,
+            )
             self.assertEqual(
-                        isinstance(hosts, list),
-                        True,
-                        "Check for list hosts response return valid data"
-                        )
+                isinstance(hosts, list),
+                True,
+                "Check for list hosts response return valid data"
+            )
             host = hosts[0]
-            host.user, host.passwd = get_host_credentials(self.config, host.ipaddress)
+            host.user, host.passwd = get_host_credentials(
+                self.config, host.ipaddress)
             try:
                 result = get_process_status(
                     host.ipaddress,
@@ -1297,7 +1330,10 @@ class TestRouterStopCreateFW(cloudstackTestCase):
                     'iptables -t nat -L'
                 )
             except KeyError:
-                self.skipTest("Provide a marvin config file with host credentials to run %s" % self._testMethodName)
+                self.skipTest(
+                    "Provide a marvin config file with host\
+                            credentials to run %s" %
+                    self._testMethodName)
 
         self.debug("iptables -t nat -L: %s" % result)
         self.debug("Public IP: %s" % public_ip.ipaddress)
@@ -1306,6 +1342,6 @@ class TestRouterStopCreateFW(cloudstackTestCase):
             res.count(str(public_ip.ipaddress)),
             1,
             "Check public IP address"
-            )
+        )
 
         return


[05/50] [abbrv] git commit: updated refs/heads/baremetal-systemvm to 23482b1

Posted by ki...@apache.org.
CLOUDSTACK-7723: UI > Storage > detail view > add Disk Offering field.


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

Branch: refs/heads/baremetal-systemvm
Commit: 340bcc60c0142e5c7f026dec78ca393278d4b60f
Parents: 35a8b70
Author: Jessica Wang <je...@apache.org>
Authored: Tue Oct 14 14:02:18 2014 -0700
Committer: Jessica Wang <je...@apache.org>
Committed: Tue Oct 14 14:02:29 2014 -0700

----------------------------------------------------------------------
 ui/scripts/storage.js | 3 +++
 1 file changed, 3 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/340bcc60/ui/scripts/storage.js
----------------------------------------------------------------------
diff --git a/ui/scripts/storage.js b/ui/scripts/storage.js
index 97b3b8f..ee8fa9d 100644
--- a/ui/scripts/storage.js
+++ b/ui/scripts/storage.js
@@ -1458,6 +1458,9 @@
                                     status: {
                                         label: 'label.status'
                                     },
+                                    diskofferingdisplaytext: {
+                                    	label: 'Disk Offering'
+                                    },
                                     type: {
                                         label: 'label.type'
                                     },


[23/50] [abbrv] git commit: updated refs/heads/baremetal-systemvm to 23482b1

Posted by ki...@apache.org.
CLOUDSTACK-7536 user vm can get a gateway ip when gateway ip is a part of the guest ip range.

Signed-off-by: Jayapal <ja...@apache.org>


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

Branch: refs/heads/baremetal-systemvm
Commit: 080bc2e2e936453078c33341453db99e62fb131f
Parents: 42f628c
Author: Bharat Kumar <bh...@citrix.com>
Authored: Wed Sep 24 15:01:13 2014 +0530
Committer: Jayapal <ja...@apache.org>
Committed: Thu Oct 16 09:38:21 2014 +0530

----------------------------------------------------------------------
 .../src/com/cloud/configuration/ConfigurationManagerImpl.java   | 5 +++++
 1 file changed, 5 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/080bc2e2/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
index eca9080..7dac143 100755
--- a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
+++ b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
@@ -3442,6 +3442,11 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
         if (endIP != null && !NetUtils.sameSubnet(endIP, vlanGateway, vlanNetmask)) {
             throw new InvalidParameterValueException("Please ensure that your end IP is in the same subnet as your IP range's gateway, as per the IP range's netmask.");
         }
+        // check if the gatewayip is the part of the ip range being added.
+        if (NetUtils.ipRangesOverlap(startIP, endIP, vlanGateway, vlanGateway)) {
+            throw new InvalidParameterValueException(
+                    "The gateway ip should not be the part of the ip range being added.");
+        }
     }
 
     private void checkConflictsWithPortableIpRange(long zoneId, String vlanId, String vlanGateway, String vlanNetmask, String startIP, String endIP) {


[45/50] [abbrv] git commit: updated refs/heads/baremetal-systemvm to 23482b1

Posted by ki...@apache.org.
Adding new test which would verify the fix for issue "The ISO/Template is automatically deleted after URL expires"

Signed-off-by: sanjeev <sa...@apache.org>


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

Branch: refs/heads/baremetal-systemvm
Commit: a1b913db2a35086964f78234cb982d3efceab957
Parents: 622041b
Author: sanjeev <sa...@apache.org>
Authored: Thu Sep 25 15:31:54 2014 +0530
Committer: sanjeev <sa...@apache.org>
Committed: Fri Oct 17 18:04:35 2014 +0530

----------------------------------------------------------------------
 .../smoke/misc/test_escalations_templates.py    | 211 +++++++++++++++++++
 1 file changed, 211 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a1b913db/test/integration/smoke/misc/test_escalations_templates.py
----------------------------------------------------------------------
diff --git a/test/integration/smoke/misc/test_escalations_templates.py b/test/integration/smoke/misc/test_escalations_templates.py
new file mode 100644
index 0000000..40a983b
--- /dev/null
+++ b/test/integration/smoke/misc/test_escalations_templates.py
@@ -0,0 +1,211 @@
+# 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 from the Marvin - Testing in Python wiki
+
+#All tests inherit from cloudstackTestCase
+from marvin.cloudstackTestCase import cloudstackTestCase
+
+#Import Integration Libraries
+
+#base - contains all resources as entities and defines create, delete, list operations on them
+from marvin.lib.base import (
+                             Account,
+                             VirtualMachine,
+                             Volume,
+                             ServiceOffering,
+                             Configurations,
+                             DiskOffering,
+                             Template)
+
+#utils - utility classes for common cleanup, external library wrappers etc
+from marvin.lib.utils import cleanup_resources, validateList
+
+#common - commonly used methods for all tests are listed here
+from marvin.lib.common import get_zone, get_domain, get_template
+from marvin.codes import PASS
+
+from nose.plugins.attrib import attr
+import time
+
+
+class TestTemplates(cloudstackTestCase):
+
+    @classmethod
+    def setUpClass(cls):
+        try:
+            cls._cleanup = []
+            cls.testClient = super(TestTemplates, cls).getClsTestClient()
+            cls.api_client = cls.testClient.getApiClient()
+            cls.services = cls.testClient.getParsedTestDataConfig()
+            # Get Domain, Zone, Template
+            cls.domain = get_domain(cls.api_client)
+            cls.zone = get_zone(
+                cls.api_client,
+                cls.testClient.getZoneForTests())
+            cls.template = get_template(
+                cls.api_client,
+                cls.zone.id,
+                cls.services["ostype"]
+            )
+            cls.services["template"]["ostypeid"] = cls.template.ostypeid
+            cls.services["template"]["isextractable"] = 'True'
+            if cls.zone.localstorageenabled:
+                cls.storagetype = 'local'
+                cls.services["service_offerings"][
+                    "tiny"]["storagetype"] = 'local'
+                cls.services["disk_offering"]["storagetype"] = 'local'
+            else:
+                cls.storagetype = 'shared'
+                cls.services["service_offerings"][
+                    "tiny"]["storagetype"] = 'shared'
+                cls.services["disk_offering"]["storagetype"] = 'shared'
+
+            cls.services['mode'] = cls.zone.networktype
+            cls.services["virtual_machine"][
+                "hypervisor"] = cls.testClient.getHypervisorInfo()
+            cls.services["virtual_machine"]["zoneid"] = cls.zone.id
+            cls.services["virtual_machine"]["template"] = cls.template.id
+            cls.services["custom_volume"]["zoneid"] = cls.zone.id
+            # Creating Disk offering, Service Offering and Account
+            cls.disk_offering = DiskOffering.create(
+                cls.api_client,
+                cls.services["disk_offering"]
+            )
+            cls.service_offering = ServiceOffering.create(
+                cls.api_client,
+                cls.services["service_offerings"]["tiny"]
+            )
+            cls.account = Account.create(
+                cls.api_client,
+                cls.services["account"],
+                domainid=cls.domain.id
+            )
+            # Getting authentication for user in newly created Account
+            cls.user = cls.account.user[0]
+            cls.userapiclient = cls.testClient.getUserApiClient(cls.user.username, cls.domain.name)
+            cls._cleanup.append(cls.disk_offering)
+            cls._cleanup.append(cls.service_offering)
+            cls._cleanup.append(cls.account)
+        except Exception as e:
+            cls.tearDownClass()
+            raise Exception("Warning: Exception in setup : %s" % e)
+        return
+
+    @classmethod
+    def tearDownClass(cls):
+        try:
+            cleanup_resources(cls.api_client, cls._cleanup)
+        except Exception as e:
+            raise Exception("Warning: Exception during cleanup : %s" % e)
+
+    def setUp(self):
+        self.apiClient = self.testClient.getApiClient()
+        self.cleanup = []
+        return
+
+    def tearDown(self):
+        #Clean up, terminate the created volumes
+        cleanup_resources(self.apiClient, self.cleanup)
+        return
+
+    @attr(tags=["advanced", "advancedsg", "sg"], required_hardware='true')
+    def test01_template_download_URL_expire(self):
+        """
+        @Desc:Template files are deleted from secondary storage after download URL expires
+        Step1:Deploy vm with default cent os template
+        Step2:Stop the vm
+        Step3:Create template from the vm's root volume
+        Step4:Extract Template and wait for the download url to expire
+        Step5:Deploy another vm with the template created at Step3
+        Step6:Verify that vm deployment succeeds
+        """
+        params = ['extract.url.expiration.interval', 'extract.url.cleanup.interval']
+        wait_time = 0
+        for param in params:
+            config = Configurations.list(
+                self.apiClient,
+                name=param,
+                )
+            self.assertEqual(validateList(config)[0], PASS, "Config list returned invalid response")
+            wait_time = wait_time+int(config[0].value)
+        self.debug("Total wait time for url expiry: %s" % wait_time)
+        # Creating Virtual Machine
+        self.virtual_machine = VirtualMachine.create(
+            self.userapiclient,
+            self.services["virtual_machine"],
+            accountid=self.account.name,
+            domainid=self.account.domainid,
+            serviceofferingid=self.service_offering.id,
+            )
+        self.assertIsNotNone(self.virtual_machine, "Virtual Machine creation failed")
+        self.cleanup.append(self.virtual_machine)
+        #Stop virtual machine
+        self.virtual_machine.stop(self.userapiclient)
+        list_volume = Volume.list(
+            self.userapiclient,
+            virtualmachineid=self.virtual_machine.id,
+            type='ROOT',
+            listall=True
+        )
+        self.assertEqual(validateList(list_volume)[0],
+                         PASS,
+                         "list volumes with type ROOT returned invalid list"
+        )
+        self.volume = list_volume[0]
+        self.create_template = Template.create(
+            self.userapiclient,
+            self.services["template"],
+            volumeid=self.volume.id,
+            account=self.account.name,
+            domainid=self.account.domainid
+        )
+        self.assertIsNotNone(self.create_template, "Failed to create template from root volume")
+        self.cleanup.append(self.create_template)
+        """
+        Extract template
+        """
+        try:
+            Template.extract(
+                self.userapiclient,
+                self.create_template.id,
+                'HTTP_DOWNLOAD',
+                self.zone.id
+            )
+        except Exception as e:
+            self.fail("Extract template failed with error %s" % e)
+        self.debug("Waiting for %s seconds for url to expire" % repr(wait_time+20))
+        time.sleep(wait_time+20)
+        self.debug("Waited for %s seconds for url to expire" % repr(wait_time+20))
+        """
+        Deploy vm with the template created from the volume. After url expiration interval only
+        url should be deleted not the template. To validate this deploy vm with the template
+        """
+        try:
+            self.vm = VirtualMachine.create(
+                self.userapiclient,
+                self.services["virtual_machine"],
+                accountid=self.account.name,
+                domainid=self.account.domainid,
+                serviceofferingid=self.service_offering.id,
+                templateid=self.create_template.id
+            )
+            self.cleanup.append(self.vm)
+        except Exception as e:
+            self.fail("Template is automatically deleted after URL expired.\
+                      So vm deployment failed with error: %s" % e)
+        return


[14/50] [abbrv] git commit: updated refs/heads/baremetal-systemvm to 23482b1

Posted by ki...@apache.org.
CLOUDSTACK-7690: Added missing unittest import to test_escalations_volumes.py

fixed pep8 issues

Signed-off-by: SrikanteswaraRao Talluri <ta...@apache.org>


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

Branch: refs/heads/baremetal-systemvm
Commit: ac820a3230cc8a7358a4d9d27039d69f230734ea
Parents: 159a372
Author: Gaurav Aradhye <ga...@clogeny.com>
Authored: Thu Oct 9 12:58:27 2014 +0530
Committer: SrikanteswaraRao Talluri <ta...@apache.org>
Committed: Wed Oct 15 11:01:39 2014 +0530

----------------------------------------------------------------------
 .../component/test_escalations_volumes.py       | 77 +++++++++++++-------
 1 file changed, 52 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ac820a32/test/integration/component/test_escalations_volumes.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_escalations_volumes.py b/test/integration/component/test_escalations_volumes.py
index bf5e37c..7290325 100644
--- a/test/integration/component/test_escalations_volumes.py
+++ b/test/integration/component/test_escalations_volumes.py
@@ -16,10 +16,10 @@
 # under the License.
 
 # Import Local Modules
-from marvin.cloudstackTestCase import cloudstackTestCase
+from marvin.cloudstackTestCase import cloudstackTestCase, unittest
 from marvin.cloudstackAPI import createVolume, createTemplate
 from marvin.lib.utils import (cleanup_resources,
-                              random_gen,validateList)
+                              random_gen, validateList)
 from marvin.lib.base import (Account,
                              VirtualMachine,
                              ServiceOffering,
@@ -34,6 +34,7 @@ from marvin.lib.common import (get_domain,
 from nose.plugins.attrib import attr
 from marvin.codes import PASS
 
+
 class TestVolumes(cloudstackTestCase):
 
     @classmethod
@@ -208,7 +209,7 @@ class TestVolumes(cloudstackTestCase):
                 volume_created.name,
                 "Newly created volume name and the test data\
                 volume name are not matching"
-                )
+            )
 
         # Listing all the volumes again after creation of volumes
         list_volumes_after = Volume.list(
@@ -239,7 +240,7 @@ class TestVolumes(cloudstackTestCase):
             self.services["pagesize"],
             "List Volume response is not matching with\
             the page size length for page 1"
-            )
+        )
 
         # Listing all the volumes in page2
         list_volumes_page2 = Volume.list(
@@ -335,7 +336,7 @@ class TestVolumes(cloudstackTestCase):
             volume_created.name,
             "Newly created volume name and\
             the test data volume name are not matching"
-            )
+        )
         # Listing all the volumes for a user after creating a data volume
         list_volumes_after = Volume.list(
             self.userapiclient,
@@ -464,7 +465,9 @@ class TestVolumes(cloudstackTestCase):
         Step6: Resizing data volume
         """
         if self.hypervisor.lower() in ['hyperv']:
-            raise unittest.SkipTest("This featureis not supported on existing hypervisor. Hence, skipping the test")
+            raise unittest.SkipTest(
+                "This featureis not supported on existing\
+                        hypervisor. Hence, skipping the test")
         # Listing volumes for a user before creating a volume
         list_volumes_before = Volume.list(
             self.userapiclient,
@@ -585,7 +588,9 @@ class TestVolumes(cloudstackTestCase):
         Step6: Resizing custom volume
         """
         if self.hypervisor.lower() in ['hyperv']:
-            raise unittest.SkipTest("This featureis not supported on existing hypervisor. Hence, skipping the test")
+            raise unittest.SkipTest(
+                "This featureis not supported on existing\
+                        hypervisor. Hence, skipping the test")
         # Listing all the disk offerings
         list_disk_offerings = DiskOffering.list(self.apiClient)
 
@@ -710,7 +715,9 @@ class TestVolumes(cloudstackTestCase):
         Step5: Creating Template from Snapshot
         """
         if self.hypervisor.lower() in ['hyperv']:
-            raise unittest.SkipTest("This featureis not supported on existing hypervisor. Hence, skipping the test")
+            raise unittest.SkipTest(
+                "This featureis not supported on existing\
+                        hypervisor. Hence, skipping the test")
         list_volumes_before = Volume.list(
             self.userapiclient,
             listall=self.services["listall"])
@@ -1473,7 +1480,9 @@ class TestVolumes(cloudstackTestCase):
                 list returns none
         """
         if self.hypervisor.lower() in ['hyperv']:
-            raise unittest.SkipTest("This featureis not supported on existing hypervisor. Hence, skipping the test")
+            raise unittest.SkipTest(
+                "This featureis not supported on existing\
+                        hypervisor. Hence, skipping the test")
         list_volumes_before = Volume.list(
             self.userapiclient,
             listall=self.services["listall"])
@@ -1803,7 +1812,7 @@ class TestVolumes(cloudstackTestCase):
         )
         return
 
-    @attr(tags=["advanced","basic","sg"], required_hardware="true")
+    @attr(tags=["advanced", "basic", "sg"], required_hardware="true")
     def test_13_volume_custom_disk_size(self):
         """
         @Desc:Create volume from custom disk offering does not work as expected
@@ -1811,18 +1820,23 @@ class TestVolumes(cloudstackTestCase):
         Step2:Create Volume with size x
         Step3:Attach that volume to a vm
         Step4:Create another volume with size y
-        Step5:Verify that the new volume is created with size Y but not with size X
+        Step5:Verify that the new volume is created with size Y
+              but not with size X
         """
         if self.hypervisor.lower() in ['hyperv']:
-            raise unittest.SkipTest("This featureis not supported on existing hypervisor. Hence, skipping the test")
+            raise unittest.SkipTest(
+                "This featureis not supported on existing\
+                        hypervisor. Hence, skipping the test")
         disk_offering = DiskOffering.create(
             self.api_client,
             self.services["disk_offering"],
             custom=True
         )
-        self.assertIsNotNone(disk_offering,"Failed to create custom disk offering")
+        self.assertIsNotNone(
+            disk_offering,
+            "Failed to create custom disk offering")
         self.cleanup.append(disk_offering)
-        self.services["custom_volume"]["customdisksize"]=2
+        self.services["custom_volume"]["customdisksize"] = 2
         vol1 = Volume.create_custom_disk(
             self.userapiclient,
             self.services["custom_volume"],
@@ -1830,19 +1844,26 @@ class TestVolumes(cloudstackTestCase):
             domainid=self.domain.id,
             diskofferingid=disk_offering.id
         )
-        self.assertIsNotNone(vol1,"Volume creation failed with custom disk size")
+        self.assertIsNotNone(
+            vol1,
+            "Volume creation failed with custom disk size")
         vol1_res = Volume.list(
             self.userapiclient,
             id=vol1.id
         )
-        self.assertEqual(validateList(vol1_res)[0],PASS,"Volume list returned invalid response")
+        self.assertEqual(
+            validateList(vol1_res)[0],
+            PASS,
+            "Volume list returned invalid response")
         self.cleanup.append(vol1)
         vol1_size = vol1_res[0].size
         try:
-            self.virtual_machine.attach_volume(self.userapiclient,vol1)
+            self.virtual_machine.attach_volume(self.userapiclient, vol1)
         except Exception as e:
-            self.fail("Attaching custom data disk to vm failed with error{}".format(e))
-        self.services["custom_volume"]["customdisksize"]=3
+            self.fail(
+                "Attaching custom data disk to vm failed\
+                        with error{}".format(e))
+        self.services["custom_volume"]["customdisksize"] = 3
         vol2 = Volume.create_custom_disk(
             self.userapiclient,
             self.services["custom_volume"],
@@ -1850,22 +1871,28 @@ class TestVolumes(cloudstackTestCase):
             domainid=self.domain.id,
             diskofferingid=disk_offering.id
         )
-        self.assertIsNotNone(vol2,"Failed to create custom data disk with size %s" %
-                             self.services["custom_volume"]["customdisksize"])
+        self.assertIsNotNone(
+            vol2,
+            "Failed to create custom data disk with size %s" %
+            self.services["custom_volume"]["customdisksize"])
         self.cleanup.append(vol2)
         vol2_res = Volume.list(
             self.userapiclient,
             id=vol2.id
         )
-        self.assertEqual(validateList(vol2_res)[0],PASS,"Volume list returned invalid response")
-        vol2_size=vol2_res[0].size
+        self.assertEqual(
+            validateList(vol2_res)[0],
+            PASS,
+            "Volume list returned invalid response")
+        vol2_size = vol2_res[0].size
         self.assertNotEqual(
             vol1_size,
             vol2_size,
-            "Creating volume from custom disk offering does not work as expected"
+            "Creating volume from custom disk offering does not work\
+                    as expected"
         )
         try:
-            self.virtual_machine.detach_volume(self.userapiclient,vol1)
+            self.virtual_machine.detach_volume(self.userapiclient, vol1)
         except Exception as e:
             self.fail("Detaching volume failed with error %s" % e)
         return


[07/50] [abbrv] git commit: updated refs/heads/baremetal-systemvm to 23482b1

Posted by ki...@apache.org.
Fixing possible formatting issue with license header, causing builds to fail. Works well locally


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

Branch: refs/heads/baremetal-systemvm
Commit: 71c9804165cec1dce304e1c19a233f03d895acb1
Parents: 26f3e849
Author: amoghvk <am...@citrix.com>
Authored: Tue Oct 14 14:37:38 2014 -0700
Committer: amoghvk <am...@citrix.com>
Committed: Tue Oct 14 14:37:38 2014 -0700

----------------------------------------------------------------------
 .../agent/api/baremetal/PrepareKickstartPxeServerCommand.java     | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/71c98041/core/src/com/cloud/agent/api/baremetal/PrepareKickstartPxeServerCommand.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/agent/api/baremetal/PrepareKickstartPxeServerCommand.java b/core/src/com/cloud/agent/api/baremetal/PrepareKickstartPxeServerCommand.java
index 6f7ddad..b8fb5d0 100755
--- a/core/src/com/cloud/agent/api/baremetal/PrepareKickstartPxeServerCommand.java
+++ b/core/src/com/cloud/agent/api/baremetal/PrepareKickstartPxeServerCommand.java
@@ -1,3 +1,4 @@
+//
 // 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
@@ -15,7 +16,7 @@
 // specific language governing permissions and limitations
 // under the License.
 //
-// Automatically generated by addcopyright.py at 01/29/2013
+
 package com.cloud.agent.api.baremetal;
 
 import com.cloud.agent.api.Command;


[20/50] [abbrv] git commit: updated refs/heads/baremetal-systemvm to 23482b1

Posted by ki...@apache.org.
CLOUDSTACK-7728: Fixed adding iptables rules for egress allow on VR reboot


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

Branch: refs/heads/baremetal-systemvm
Commit: 55e11cddca1f9db3a3fe29404b4eff634da60bcb
Parents: 7cd3438
Author: Jayapal <ja...@apache.org>
Authored: Wed Oct 15 17:26:51 2014 +0530
Committer: Jayapal <ja...@apache.org>
Committed: Thu Oct 16 09:37:43 2014 +0530

----------------------------------------------------------------------
 .../VirtualNetworkApplianceManagerImpl.java     | 30 ++++++++++++++++++++
 1 file changed, 30 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/55e11cdd/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
index 29576bc..315bdde 100644
--- a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
+++ b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
@@ -174,10 +174,12 @@ import com.cloud.network.rules.RulesManager;
 import com.cloud.network.rules.StaticNat;
 import com.cloud.network.rules.StaticNatImpl;
 import com.cloud.network.rules.StaticNatRule;
+import com.cloud.network.rules.FirewallRuleVO;
 import com.cloud.network.rules.dao.PortForwardingRulesDao;
 import com.cloud.network.vpn.Site2SiteVpnManager;
 import com.cloud.offering.NetworkOffering;
 import com.cloud.offering.ServiceOffering;
+import com.cloud.offerings.NetworkOfferingVO;
 import com.cloud.offerings.dao.NetworkOfferingDao;
 import com.cloud.resource.ResourceManager;
 import com.cloud.server.ConfigurationServer;
@@ -1780,6 +1782,10 @@ Configurable, StateListener<State, VirtualMachine.Event, VirtualMachine> {
         // Fetch firewall Egress rules.
         if (_networkModel.isProviderSupportServiceInNetwork(guestNetworkId, Service.Firewall, provider)) {
             firewallRulesEgress.addAll(_rulesDao.listByNetworkPurposeTrafficType(guestNetworkId, Purpose.Firewall, FirewallRule.TrafficType.Egress));
+            if (firewallRulesEgress.isEmpty()) {
+                //create egress default rule for VR
+                createDefaultEgressFirewallRule(firewallRulesEgress, guestNetworkId);
+            }
         }
 
         // Re-apply firewall Egress rules
@@ -1904,6 +1910,30 @@ Configurable, StateListener<State, VirtualMachine.Event, VirtualMachine> {
         }
     }
 
+    private void createDefaultEgressFirewallRule(List<FirewallRule> rules, long networkId) {
+        String systemRule = null;
+
+        Boolean defaultEgressPolicy = false;
+        NetworkVO network = _networkDao.findById(networkId);
+        NetworkOfferingVO offering = _networkOfferingDao.findById(network.getNetworkOfferingId());
+        defaultEgressPolicy = offering.getEgressDefaultPolicy();
+
+
+        // construct rule when egress policy is true. In true case for VR we default allow rule need to be added
+        if (defaultEgressPolicy) {
+            systemRule = String.valueOf(FirewallRule.FirewallRuleType.System);
+
+            List<String> sourceCidr = new ArrayList<String>();
+
+            sourceCidr.add(NetUtils.ALL_CIDRS);
+            FirewallRule rule = new FirewallRuleVO(null, null, null, null, "all", networkId, network.getAccountId(), network.getDomainId(), Purpose.Firewall, sourceCidr,
+                    null, null, null, FirewallRule.TrafficType.Egress, FirewallRule.FirewallRuleType.System);
+
+            rules.add(rule);
+        }
+    }
+
+
     private void removeRevokedIpAliasFromDb(final List<NicIpAliasVO> revokedIpAliasVOs) {
         for (final NicIpAliasVO ipalias : revokedIpAliasVOs) {
             _nicIpAliasDao.expunge(ipalias.getId());


[25/50] [abbrv] git commit: updated refs/heads/baremetal-systemvm to 23482b1

Posted by ki...@apache.org.
 CLOUDSTACK-7728: Removed duplicate import


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

Branch: refs/heads/baremetal-systemvm
Commit: 53ee4cd794eb18458ee77b49f15af8277e777a42
Parents: e257c13
Author: Jayapal <ja...@apache.org>
Authored: Thu Oct 16 10:05:06 2014 +0530
Committer: Jayapal <ja...@apache.org>
Committed: Thu Oct 16 10:05:06 2014 +0530

----------------------------------------------------------------------
 .../cloud/network/router/VirtualNetworkApplianceManagerImpl.java   | 2 --
 1 file changed, 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/53ee4cd7/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
index b67f667..cc9ced4 100755
--- a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
+++ b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
@@ -170,13 +170,11 @@ import com.cloud.network.rules.RulesManager;
 import com.cloud.network.rules.StaticNat;
 import com.cloud.network.rules.StaticNatImpl;
 import com.cloud.network.rules.StaticNatRule;
-import com.cloud.network.rules.FirewallRuleVO;
 import com.cloud.network.rules.dao.PortForwardingRulesDao;
 import com.cloud.network.vpn.Site2SiteVpnManager;
 import com.cloud.offering.NetworkOffering;
 import com.cloud.offering.ServiceOffering;
 import com.cloud.offerings.NetworkOfferingVO;
-import com.cloud.offerings.NetworkOfferingVO;
 import com.cloud.offerings.dao.NetworkOfferingDao;
 import com.cloud.resource.ResourceManager;
 import com.cloud.server.ConfigurationServer;


[35/50] [abbrv] git commit: updated refs/heads/baremetal-systemvm to 23482b1

Posted by ki...@apache.org.
CLOUDSTACK-7727 Skip various BVT tests on LXC

A number of BVT tests are not valid for LXC (e.g. migrating a VM), so this patch
ensures they skip if LXC is in use.

Signed-off-by: SrikanteswaraRao Talluri <ta...@apache.org>


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

Branch: refs/heads/baremetal-systemvm
Commit: 20d3cf1acc535c3380e52e92a4108444a0b593e3
Parents: 1f8cf0b
Author: Alex Brett <al...@citrix.com>
Authored: Wed Oct 15 18:50:57 2014 +0100
Committer: SrikanteswaraRao Talluri <ta...@apache.org>
Committed: Thu Oct 16 17:23:04 2014 +0530

----------------------------------------------------------------------
 test/integration/smoke/test_primary_storage.py |  4 ++--
 test/integration/smoke/test_scale_vm.py        |  4 ++--
 test/integration/smoke/test_snapshots.py       |  4 ++--
 test/integration/smoke/test_templates.py       |  6 ++++++
 test/integration/smoke/test_vm_life_cycle.py   | 14 +++++++++-----
 test/integration/smoke/test_vm_snapshots.py    |  4 ++--
 6 files changed, 23 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/20d3cf1a/test/integration/smoke/test_primary_storage.py
----------------------------------------------------------------------
diff --git a/test/integration/smoke/test_primary_storage.py b/test/integration/smoke/test_primary_storage.py
index 0813d28..310afca 100644
--- a/test/integration/smoke/test_primary_storage.py
+++ b/test/integration/smoke/test_primary_storage.py
@@ -154,8 +154,8 @@ class TestPrimaryStorageServices(cloudstackTestCase):
         """Test primary storage pools - XEN. Not Supported for kvm,hyperv,vmware
         """
 
-        if self.hypervisor.lower() in ["kvm","hyperv", "vmware"]:
-            raise self.skipTest("iscsi primary storage not supported on kvm, VMWare or Hyper-V")
+        if self.hypervisor.lower() in ["kvm","hyperv", "vmware", "lxc"]:
+            raise self.skipTest("iscsi primary storage not supported on kvm, VMWare, Hyper-V, or LXC")
 
         # Validate the following:
         # 1. List Clusters

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/20d3cf1a/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 0b770c4..3a2983e 100644
--- a/test/integration/smoke/test_scale_vm.py
+++ b/test/integration/smoke/test_scale_vm.py
@@ -35,8 +35,8 @@ class TestScaleVm(cloudstackTestCase):
         cls.apiclient = testClient.getApiClient()
         cls.services = testClient.getParsedTestDataConfig()
         cls.hypervisor = cls.testClient.getHypervisorInfo()
-        if cls.hypervisor.lower() in ('kvm', 'hyperv'):
-            raise unittest.SkipTest("ScaleVM is not supported on KVM or Hyper-V. Hence, skipping the test")
+        if cls.hypervisor.lower() in ('kvm', 'hyperv', 'lxc'):
+            raise unittest.SkipTest("ScaleVM is not supported on KVM, Hyper-V or LXC. Hence, skipping the test")
 
         # Get Zone, Domain and templates
         domain = get_domain(cls.apiclient)

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/20d3cf1a/test/integration/smoke/test_snapshots.py
----------------------------------------------------------------------
diff --git a/test/integration/smoke/test_snapshots.py b/test/integration/smoke/test_snapshots.py
index 5db3e40..2df1778 100644
--- a/test/integration/smoke/test_snapshots.py
+++ b/test/integration/smoke/test_snapshots.py
@@ -37,8 +37,8 @@ class TestSnapshotRootDisk(cloudstackTestCase):
         cls.services['mode'] = cls.zone.networktype
 
         cls.hypervisor = cls.testClient.getHypervisorInfo()
-        if cls.hypervisor.lower() == 'hyperv':
-            raise unittest.SkipTest("Snapshots not supported on Hyper-V")
+        if cls.hypervisor.lower() in ['hyperv', 'lxc']:
+            raise unittest.SkipTest("Snapshots not supported on Hyper-V or LXC")
 
         template = get_template(
                             cls.apiclient,

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/20d3cf1a/test/integration/smoke/test_templates.py
----------------------------------------------------------------------
diff --git a/test/integration/smoke/test_templates.py b/test/integration/smoke/test_templates.py
index db938d9..4153ca3 100644
--- a/test/integration/smoke/test_templates.py
+++ b/test/integration/smoke/test_templates.py
@@ -60,6 +60,9 @@ class TestCreateTemplate(cloudstackTestCase):
         testClient = super(TestCreateTemplate, cls).getClsTestClient()
         cls.apiclient = testClient.getApiClient()
         cls.services = testClient.getParsedTestDataConfig()
+        cls.hypervisor = testClient.getHypervisorInfo()
+        if cls.hypervisor.lower() in ['lxc']:
+            raise unittest.SkipTest("Template creation from root volume is not supported in LXC")
 
         # Get Zone, Domain and templates
         cls.domain = get_domain(cls.apiclient)
@@ -208,6 +211,9 @@ class TestTemplates(cloudstackTestCase):
         testClient = super(TestTemplates, cls).getClsTestClient()
         cls.apiclient = testClient.getApiClient()
         cls.services = testClient.getParsedTestDataConfig()
+        cls.hypervisor = testClient.getHypervisorInfo()
+        if cls.hypervisor.lower() in ['lxc']:
+            raise unittest.SkipTest("Template creation from root volume is not supported in LXC")
 
         # Get Zone, Domain and templates
         cls.domain = get_domain(cls.apiclient)

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/20d3cf1a/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 0be518d..294dc79 100644
--- a/test/integration/smoke/test_vm_life_cycle.py
+++ b/test/integration/smoke/test_vm_life_cycle.py
@@ -23,8 +23,7 @@ from marvin.cloudstackAPI import (recoverVirtualMachine,
                                   attachIso,
                                   detachIso)
 from marvin.lib.utils import (cleanup_resources,
-                              validateList,
-                              get_hypervisor_type)
+                              validateList)
 from marvin.lib.base import (Account,
                              ServiceOffering,
                              VirtualMachine,
@@ -261,6 +260,7 @@ class TestVMLifeCycle(cloudstackTestCase):
         testClient = super(TestVMLifeCycle, cls).getClsTestClient()
         cls.apiclient = testClient.getApiClient()
         cls.services = testClient.getParsedTestDataConfig()
+        cls.hypervisor = testClient.getHypervisorInfo()
 
         # Get Zone, Domain and templates
         domain = get_domain(cls.apiclient)
@@ -548,20 +548,21 @@ class TestVMLifeCycle(cloudstackTestCase):
         if len(hosts) < 2:
             self.skipTest("At least two hosts should be present in the zone for migration")
 
-        hypervisor = str(get_hypervisor_type(self.apiclient)).lower()
+        if self.hypervisor.lower() in ["lxc"]:
+            self.skipTest("Migration is not supported on LXC")
 
         # For KVM, two hosts used for migration should  be present in same cluster
         # For XenServer and VMware, migration is possible between hosts belonging to different clusters
         # with the help of XenMotion and Vmotion respectively.
 
-        if hypervisor.lower() in ["kvm","simulator"]:
+        if self.hypervisor.lower() in ["kvm","simulator"]:
             #identify suitable host
             clusters = [h.clusterid for h in hosts]
             #find hosts withe same clusterid
             clusters = [cluster for index, cluster in enumerate(clusters) if clusters.count(cluster) > 1]
 
             if len(clusters) <= 1:
-                self.skipTest("In " + hypervisor.lower() + " Live Migration needs two hosts within same cluster")
+                self.skipTest("In " + self.hypervisor.lower() + " Live Migration needs two hosts within same cluster")
 
             suitable_hosts = [host for host in hosts if host.clusterid == clusters[0]]
         else:
@@ -661,6 +662,9 @@ class TestVMLifeCycle(cloudstackTestCase):
         # 5. Detach ISO
         # 6. Check the device is properly detached by logging into VM
 
+        if self.hypervisor.lower() in ["lxc"]:
+            self.skipTest("ISOs are not supported on LXC")
+
         iso = Iso.create(
                          self.apiclient,
                          self.services["iso1"],

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/20d3cf1a/test/integration/smoke/test_vm_snapshots.py
----------------------------------------------------------------------
diff --git a/test/integration/smoke/test_vm_snapshots.py b/test/integration/smoke/test_vm_snapshots.py
index dae945c..131da99 100644
--- a/test/integration/smoke/test_vm_snapshots.py
+++ b/test/integration/smoke/test_vm_snapshots.py
@@ -38,8 +38,8 @@ class TestVmSnapshot(cloudstackTestCase):
         testClient = super(TestVmSnapshot, cls).getClsTestClient()
 
         hypervisor = testClient.getHypervisorInfo()
-        if hypervisor.lower() in (KVM.lower(), "hyperv"):
-            raise unittest.SkipTest("VM snapshot feature is not supported on KVM or Hyper-V")
+        if hypervisor.lower() in (KVM.lower(), "hyperv", "lxc"):
+            raise unittest.SkipTest("VM snapshot feature is not supported on KVM, Hyper-V or LXC")
 
         cls.apiclient = testClient.getApiClient()
         cls.services = testClient.getParsedTestDataConfig()


[27/50] [abbrv] Fixed coverity and other resource leak issues

Posted by ki...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/efe1e0a5/engine/schema/src/com/cloud/upgrade/dao/Upgrade410to420.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/upgrade/dao/Upgrade410to420.java b/engine/schema/src/com/cloud/upgrade/dao/Upgrade410to420.java
index dab2b46..b32947a 100755
--- a/engine/schema/src/com/cloud/upgrade/dao/Upgrade410to420.java
+++ b/engine/schema/src/com/cloud/upgrade/dao/Upgrade410to420.java
@@ -117,75 +117,47 @@ public class Upgrade410to420 implements DbUpgrade {
     }
 
     private void createFullCloneFlag(Connection conn) {
-        ResultSet rs = null;
-        PreparedStatement delete = null;
-        PreparedStatement query = null;
-        PreparedStatement update = null;
+        String update_sql;
         int numRows = 0;
-        try {
-            delete = conn.prepareStatement("delete from `cloud`.`configuration` where name='vmware.create.full.clone';");
+        try (PreparedStatement delete = conn.prepareStatement("delete from `cloud`.`configuration` where name='vmware.create.full.clone';");)
+        {
             delete.executeUpdate();
-            query = conn.prepareStatement("select count(*) from `cloud`.`data_center`");
-            rs = query.executeQuery();
-            if (rs.next()) {
-                numRows = rs.getInt(1);
-            }
-            if (numRows > 0) {
-                update =
-                        conn.prepareStatement("insert into `cloud`.`configuration` (`category`, `instance`, `component`, `name`, `value`, `description`) VALUES ('Advanced', 'DEFAULT', 'UserVmManager', 'vmware.create.full.clone' , 'false', 'If set to true, creates VMs as full clones on ESX hypervisor');");
-            } else {
-                update =
-                        conn.prepareStatement("insert into `cloud`.`configuration` (`category`, `instance`, `component`, `name`, `value`, `description`) VALUES ('Advanced', 'DEFAULT', 'UserVmManager', 'vmware.create.full.clone' , 'true', 'If set to true, creates VMs as full clones on ESX hypervisor');");
+            try(PreparedStatement query = conn.prepareStatement("select count(*) from `cloud`.`data_center`");)
+            {
+                try(ResultSet rs = query.executeQuery();) {
+                    if (rs.next()) {
+                        numRows = rs.getInt(1);
+                    }
+                    if (numRows > 0) {
+                        update_sql = "insert into `cloud`.`configuration` (`category`, `instance`, `component`, `name`, `value`, `description`) VALUES ('Advanced', 'DEFAULT', 'UserVmManager', 'vmware.create.full.clone' , 'false', 'If set to true, creates VMs as full clones on ESX hypervisor');";
+                    } else {
+                        update_sql = "insert into `cloud`.`configuration` (`category`, `instance`, `component`, `name`, `value`, `description`) VALUES ('Advanced', 'DEFAULT', 'UserVmManager', 'vmware.create.full.clone' , 'true', 'If set to true, creates VMs as full clones on ESX hypervisor');";
+                    }
+                    try(PreparedStatement update_pstmt =  conn.prepareStatement(update_sql);) {
+                        update_pstmt.executeUpdate();
+                    }catch (SQLException e) {
+                        throw new CloudRuntimeException("Failed to set global flag vmware.create.full.clone: ", e);
+                    }
+                }catch (SQLException e) {
+                    throw new CloudRuntimeException("Failed to set global flag vmware.create.full.clone: ", e);
+                }
+            }catch (SQLException e) {
+                 throw new CloudRuntimeException("Failed to set global flag vmware.create.full.clone: ", e);
             }
-            update.executeUpdate();
         } catch (SQLException e) {
             throw new CloudRuntimeException("Failed to set global flag vmware.create.full.clone: ", e);
-        } finally {
-            if (update != null) {
-                try {
-                    update.close();
-                } catch (SQLException e) {
-
-                }
-            }
-            if (query != null) {
-                try {
-                    query.close();
-                } catch (SQLException e) {
-
-                }
-            }
-            if (delete != null) {
-                try {
-                    delete.close();
-                } catch (SQLException e) {
-
-                }
-            }
         }
     }
 
     private void migrateVolumeOnSecondaryStorage(Connection conn) {
-        PreparedStatement sql = null;
-        try {
-            sql = conn.prepareStatement("update `cloud`.`volumes` set state='Uploaded' where state='UploadOp'");
+        try (PreparedStatement sql = conn.prepareStatement("update `cloud`.`volumes` set state='Uploaded' where state='UploadOp'");){
             sql.executeUpdate();
         } catch (SQLException e) {
             throw new CloudRuntimeException("Failed to upgrade volume state: ", e);
-        } finally {
-            if (sql != null) {
-                try {
-                    sql.close();
-                } catch (SQLException e) {
-
-                }
-            }
         }
     }
 
     private void persistVswitchConfiguration(Connection conn) {
-        PreparedStatement clustersQuery = null;
-        ResultSet clusters = null;
         Long clusterId;
         String clusterHypervisorType;
         final String NEXUS_GLOBAL_CONFIG_PARAM_NAME = "vmware.use.nexus.vswitch";
@@ -200,36 +172,39 @@ public class Upgrade410to420 implements DbUpgrade {
         String guestVswitchType = VMWARE_STANDARD_VSWITCH;
         Map<Long, List<Pair<String, String>>> detailsMap = new HashMap<Long, List<Pair<String, String>>>();
         List<Pair<String, String>> detailsList;
-
-        try {
-            clustersQuery = conn.prepareStatement("select id, hypervisor_type from `cloud`.`cluster` where removed is NULL");
-            clusters = clustersQuery.executeQuery();
-            while (clusters.next()) {
-                clusterHypervisorType = clusters.getString("hypervisor_type");
-                clusterId = clusters.getLong("id");
-                if (clusterHypervisorType.equalsIgnoreCase("VMware")) {
-                    if (!readGlobalConfigParam) {
-                        paramValStr = getConfigurationParameter(conn, VSWITCH_GLOBAL_CONFIG_PARAM_CATEGORY, NEXUS_GLOBAL_CONFIG_PARAM_NAME);
-                        if (paramValStr.equalsIgnoreCase("true")) {
-                            nexusEnabled = true;
+        try (PreparedStatement clustersQuery = conn.prepareStatement("select id, hypervisor_type from `cloud`.`cluster` where removed is NULL");){
+            try(ResultSet clusters = clustersQuery.executeQuery();) {
+                while (clusters.next()) {
+                    clusterHypervisorType = clusters.getString("hypervisor_type");
+                    clusterId = clusters.getLong("id");
+                    if (clusterHypervisorType.equalsIgnoreCase("VMware")) {
+                        if (!readGlobalConfigParam) {
+                            paramValStr = getConfigurationParameter(conn, VSWITCH_GLOBAL_CONFIG_PARAM_CATEGORY, NEXUS_GLOBAL_CONFIG_PARAM_NAME);
+                            if (paramValStr.equalsIgnoreCase("true")) {
+                                nexusEnabled = true;
+                            }
                         }
-                    }
-                    if (nexusEnabled) {
-                        publicVswitchType = NEXUS_1000V_DVSWITCH;
-                        guestVswitchType = NEXUS_1000V_DVSWITCH;
-                    }
-                    detailsList = new ArrayList<Pair<String, String>>();
-                    detailsList.add(new Pair<String, String>(ApiConstants.VSWITCH_TYPE_GUEST_TRAFFIC, guestVswitchType));
-                    detailsList.add(new Pair<String, String>(ApiConstants.VSWITCH_TYPE_PUBLIC_TRAFFIC, publicVswitchType));
-                    detailsMap.put(clusterId, detailsList);
+                        if (nexusEnabled) {
+                            publicVswitchType = NEXUS_1000V_DVSWITCH;
+                            guestVswitchType = NEXUS_1000V_DVSWITCH;
+                        }
+                        detailsList = new ArrayList<Pair<String, String>>();
+                        detailsList.add(new Pair<String, String>(ApiConstants.VSWITCH_TYPE_GUEST_TRAFFIC, guestVswitchType));
+                        detailsList.add(new Pair<String, String>(ApiConstants.VSWITCH_TYPE_PUBLIC_TRAFFIC, publicVswitchType));
+                        detailsMap.put(clusterId, detailsList);
 
-                    updateClusterDetails(conn, detailsMap);
-                    s_logger.debug("Persist vSwitch Configuration: Successfully persisted vswitch configuration for cluster " + clusterId);
-                } else {
-                    s_logger.debug("Persist vSwitch Configuration: Ignoring cluster " + clusterId + " with hypervisor type " + clusterHypervisorType);
-                    continue;
-                }
-            } // End cluster iteration
+                        updateClusterDetails(conn, detailsMap);
+                        s_logger.debug("Persist vSwitch Configuration: Successfully persisted vswitch configuration for cluster " + clusterId);
+                    } else {
+                        s_logger.debug("Persist vSwitch Configuration: Ignoring cluster " + clusterId + " with hypervisor type " + clusterHypervisorType);
+                        continue;
+                    }
+                } // End cluster iteration
+            }catch (SQLException e) {
+                String msg = "Unable to persist vswitch configuration of VMware clusters." + e.getMessage();
+                s_logger.error(msg);
+                throw new CloudRuntimeException(msg, e);
+            }
 
             if (nexusEnabled) {
                 // If Nexus global parameter is true, then set DVS configuration parameter to true. TODOS: Document that this mandates that MS need to be restarted.
@@ -239,21 +214,10 @@ public class Upgrade410to420 implements DbUpgrade {
             String msg = "Unable to persist vswitch configuration of VMware clusters." + e.getMessage();
             s_logger.error(msg);
             throw new CloudRuntimeException(msg, e);
-        } finally {
-            try {
-                if (clusters != null) {
-                    clusters.close();
-                }
-                if (clustersQuery != null) {
-                    clustersQuery.close();
-                }
-            } catch (SQLException e) {
-            }
         }
     }
 
     private void updateClusterDetails(Connection conn, Map<Long, List<Pair<String, String>>> detailsMap) {
-        PreparedStatement clusterDetailsInsert = null;
         // Insert cluster details into cloud.cluster_details table for existing VMware clusters
         // Input parameter detailMap is a map of clusterId and list of key value pairs for that cluster
         Long clusterId;
@@ -265,204 +229,148 @@ public class Upgrade410to420 implements DbUpgrade {
             while (clusterIt.hasNext()) {
                 clusterId = clusterIt.next();
                 keyValues = detailsMap.get(clusterId);
-                clusterDetailsInsert = conn.prepareStatement("INSERT INTO `cloud`.`cluster_details` (cluster_id, name, value) VALUES (?, ?, ?)");
-                for (Pair<String, String> keyValuePair : keyValues) {
-                    key = keyValuePair.first();
-                    val = keyValuePair.second();
-                    clusterDetailsInsert.setLong(1, clusterId);
-                    clusterDetailsInsert.setString(2, key);
-                    clusterDetailsInsert.setString(3, val);
-                    clusterDetailsInsert.executeUpdate();
+                try( PreparedStatement clusterDetailsInsert = conn.prepareStatement("INSERT INTO `cloud`.`cluster_details` (cluster_id, name, value) VALUES (?, ?, ?)");) {
+                    for (Pair<String, String> keyValuePair : keyValues) {
+                        key = keyValuePair.first();
+                        val = keyValuePair.second();
+                        clusterDetailsInsert.setLong(1, clusterId);
+                        clusterDetailsInsert.setString(2, key);
+                        clusterDetailsInsert.setString(3, val);
+                        clusterDetailsInsert.executeUpdate();
+                    }
+                    s_logger.debug("Inserted vswitch configuration details into cloud.cluster_details for cluster with id " + clusterId + ".");
+                }catch (SQLException e) {
+                    throw new CloudRuntimeException("Unable insert cluster details into cloud.cluster_details table.", e);
                 }
-                s_logger.debug("Inserted vswitch configuration details into cloud.cluster_details for cluster with id " + clusterId + ".");
             }
-        } catch (SQLException e) {
+        } catch (RuntimeException e) {
             throw new CloudRuntimeException("Unable insert cluster details into cloud.cluster_details table.", e);
-        } finally {
-            try {
-                if (clusterDetailsInsert != null) {
-                    clusterDetailsInsert.close();
-                }
-            } catch (SQLException e) {
-            }
         }
     }
 
     private String getConfigurationParameter(Connection conn, String category, String paramName) {
-        ResultSet rs = null;
-        PreparedStatement pstmt = null;
-        try {
-            pstmt =
-                    conn.prepareStatement("select value from `cloud`.`configuration` where category='" + category + "' and value is not NULL and name = '" + paramName + "';");
-            rs = pstmt.executeQuery();
-            while (rs.next()) {
-                return rs.getString("value");
+        try (PreparedStatement pstmt =
+                     conn.prepareStatement("select value from `cloud`.`configuration` where category='" + category + "' and value is not NULL and name = '" + paramName + "';");)
+        {
+            try(ResultSet rs = pstmt.executeQuery();) {
+                while (rs.next()) {
+                    return rs.getString("value");
+                }
+            }catch (SQLException e) {
+                throw new CloudRuntimeException("Unable read global configuration parameter " + paramName + ". ", e);
             }
         } catch (SQLException e) {
             throw new CloudRuntimeException("Unable read global configuration parameter " + paramName + ". ", e);
-        } finally {
-            try {
-                if (rs != null) {
-                    rs.close();
-                }
-                if (pstmt != null) {
-                    pstmt.close();
-                }
-            } catch (SQLException e) {
-            }
         }
         return "false";
     }
 
     private void setConfigurationParameter(Connection conn, String category, String paramName, String paramVal) {
-        PreparedStatement pstmt = null;
-        try {
-            pstmt = conn.prepareStatement("UPDATE `cloud`.`configuration` SET value = '" + paramVal + "' WHERE name = '" + paramName + "';");
+        try (PreparedStatement pstmt = conn.prepareStatement("UPDATE `cloud`.`configuration` SET value = '" + paramVal + "' WHERE name = '" + paramName + "';");)
+        {
             s_logger.debug("Updating global configuration parameter " + paramName + " with value " + paramVal + ". Update SQL statement is " + pstmt);
             pstmt.executeUpdate();
         } catch (SQLException e) {
             throw new CloudRuntimeException("Unable to set global configuration parameter " + paramName + " to " + paramVal + ". ", e);
-        } finally {
-            try {
-                if (pstmt != null) {
-                    pstmt.close();
-                }
-            } catch (SQLException e) {
-            }
         }
     }
 
     private void movePrivateZoneToDedicatedResource(Connection conn) {
-
-        PreparedStatement pstmt = null;
-        ResultSet rs = null;
-        PreparedStatement pstmtUpdate = null;
-        PreparedStatement pstmt3 = null;
-        ResultSet rs3 = null;
-
-        try {
-
-            pstmt3 = conn.prepareStatement("SELECT distinct(`domain_id`) FROM `cloud`.`data_center` WHERE `domain_id` IS NOT NULL AND removed IS NULL");
-            rs3 = pstmt3.executeQuery();
-
-            while (rs3.next()) {
-                long domainId = rs3.getLong(1);
-                long affinityGroupId = 0;
-
-                // create or find an affinity group for this domain of type
-                // 'ExplicitDedication'
-                PreparedStatement pstmt2 = null;
-                ResultSet rs2 = null;
-                pstmt2 =
-                        conn.prepareStatement("SELECT affinity_group.id FROM `cloud`.`affinity_group` INNER JOIN `cloud`.`affinity_group_domain_map` ON affinity_group.id=affinity_group_domain_map.affinity_group_id WHERE affinity_group.type = 'ExplicitDedication' AND affinity_group.acl_type = 'Domain'  AND  (affinity_group_domain_map.domain_id = ?)");
-                pstmt2.setLong(1, domainId);
-                rs2 = pstmt2.executeQuery();
-                if (rs2.next()) {
-                    // group exists, use it
-                    affinityGroupId = rs2.getLong(1);
-                } else {
-                    // create new group
-                    rs2.close();
-                    pstmt2.close();
-
-                    pstmt2 = conn.prepareStatement("SELECT name FROM `cloud`.`domain` where id = ?");
-                    pstmt2.setLong(1, domainId);
-                    rs2 = pstmt2.executeQuery();
-                    String domainName = "";
-                    if (rs2.next()) {
-                        domainName = rs2.getString(1);
+        String domainName = "";
+        try (PreparedStatement sel_dc_dom_id = conn.prepareStatement("SELECT distinct(`domain_id`) FROM `cloud`.`data_center` WHERE `domain_id` IS NOT NULL AND removed IS NULL");) {
+            try (ResultSet rs3 = sel_dc_dom_id.executeQuery();) {
+                while (rs3.next()) {
+                    long domainId = rs3.getLong(1);
+                    long affinityGroupId = 0;
+                    // create or find an affinity group for this domain of type
+                    // 'ExplicitDedication'
+                    try (PreparedStatement sel_aff_grp_pstmt =
+                                 conn.prepareStatement("SELECT affinity_group.id FROM `cloud`.`affinity_group` INNER JOIN `cloud`.`affinity_group_domain_map` ON affinity_group.id=affinity_group_domain_map.affinity_group_id WHERE affinity_group.type = 'ExplicitDedication' AND affinity_group.acl_type = 'Domain'  AND  (affinity_group_domain_map.domain_id = ?)");) {
+                        sel_aff_grp_pstmt.setLong(1, domainId);
+                        try (ResultSet rs2 = sel_aff_grp_pstmt.executeQuery();) {
+                            if (rs2.next()) {
+                                // group exists, use it
+                                affinityGroupId = rs2.getLong(1);
+                            } else {
+                                // create new group
+                                try (PreparedStatement sel_dom_id_pstmt = conn.prepareStatement("SELECT name FROM `cloud`.`domain` where id = ?");) {
+                                    sel_dom_id_pstmt.setLong(1, domainId);
+                                    try (ResultSet sel_dom_id_res = sel_dom_id_pstmt.executeQuery();) {
+                                        if (sel_dom_id_res.next()) {
+                                            domainName = sel_dom_id_res.getString(1);
+                                        }
+                                    }
+                                } catch (SQLException e) {
+                                    throw new CloudRuntimeException("Exception while Moving private zone information to dedicated resources", e);
+                                }
+                                // create new domain level group for this domain
+                                String type = "ExplicitDedication";
+                                String uuid = UUID.randomUUID().toString();
+                                String groupName = "DedicatedGrp-domain-" + domainName;
+                                s_logger.debug("Adding AffinityGroup of type " + type + " for domain id " + domainId);
+                                String sql =
+                                        "INSERT INTO `cloud`.`affinity_group` (`name`, `type`, `uuid`, `description`, `domain_id`, `account_id`, `acl_type`) VALUES (?, ?, ?, ?, 1, 1, 'Domain')";
+                                try (PreparedStatement insert_pstmt = conn.prepareStatement(sql);) {
+                                    insert_pstmt.setString(1, groupName);
+                                    insert_pstmt.setString(2, type);
+                                    insert_pstmt.setString(3, uuid);
+                                    insert_pstmt.setString(4, "dedicated resources group");
+                                    insert_pstmt.executeUpdate();
+                                    try (PreparedStatement sel_aff_pstmt = conn.prepareStatement("SELECT affinity_group.id FROM `cloud`.`affinity_group` where uuid = ?");) {
+                                        sel_aff_pstmt.setString(1, uuid);
+                                        try (ResultSet sel_aff_res = sel_aff_pstmt.executeQuery();) {
+                                            if (sel_aff_res.next()) {
+                                                affinityGroupId = sel_aff_res.getLong(1);
+                                            }
+                                        } catch (SQLException e) {
+                                            throw new CloudRuntimeException("Exception while Moving private zone information to dedicated resources", e);
+                                        }
+                                    } catch (SQLException e) {
+                                        throw new CloudRuntimeException("Exception while Moving private zone information to dedicated resources", e);
+                                    }
+                                } catch (SQLException e) {
+                                    throw new CloudRuntimeException("Exception while Moving private zone information to dedicated resources", e);
+                                }
+                                // add the domain map
+                                String sqlMap = "INSERT INTO `cloud`.`affinity_group_domain_map` (`domain_id`, `affinity_group_id`) VALUES (?, ?)";
+                                try (PreparedStatement pstmtUpdate = conn.prepareStatement(sqlMap);) {
+                                    pstmtUpdate.setLong(1, domainId);
+                                    pstmtUpdate.setLong(2, affinityGroupId);
+                                    pstmtUpdate.executeUpdate();
+                                } catch (SQLException e) {
+                                    throw new CloudRuntimeException("Exception while Moving private zone information to dedicated resources", e);
+                                }
+                            }
+                        } catch (SQLException e) {
+                            throw new CloudRuntimeException("Exception while Moving private zone information to dedicated resources", e);
+                        }
+                    } catch (SQLException e) {
+                        throw new CloudRuntimeException("Exception while Moving private zone information to dedicated resources", e);
                     }
-                    rs2.close();
-                    pstmt2.close();
-                    // create new domain level group for this domain
-                    String type = "ExplicitDedication";
-                    String uuid = UUID.randomUUID().toString();
-                    String groupName = "DedicatedGrp-domain-" + domainName;
-                    s_logger.debug("Adding AffinityGroup of type " + type + " for domain id " + domainId);
-
-                    String sql =
-                            "INSERT INTO `cloud`.`affinity_group` (`name`, `type`, `uuid`, `description`, `domain_id`, `account_id`, `acl_type`) VALUES (?, ?, ?, ?, 1, 1, 'Domain')";
-                    pstmtUpdate = conn.prepareStatement(sql);
-                    pstmtUpdate.setString(1, groupName);
-                    pstmtUpdate.setString(2, type);
-                    pstmtUpdate.setString(3, uuid);
-                    pstmtUpdate.setString(4, "dedicated resources group");
-                    pstmtUpdate.executeUpdate();
-                    pstmtUpdate.close();
-
-                    pstmt2 = conn.prepareStatement("SELECT affinity_group.id FROM `cloud`.`affinity_group` where uuid = ?");
-                    pstmt2.setString(1, uuid);
-                    rs2 = pstmt2.executeQuery();
-                    if (rs2.next()) {
-                        affinityGroupId = rs2.getLong(1);
+                    try (PreparedStatement sel_pstmt = conn.prepareStatement("SELECT `id` FROM `cloud`.`data_center` WHERE `domain_id` = ? AND removed IS NULL");) {
+                        sel_pstmt.setLong(1, domainId);
+                        try (ResultSet sel_pstmt_rs = sel_pstmt.executeQuery();) {
+                            while (sel_pstmt_rs.next()) {
+                                long zoneId = sel_pstmt_rs.getLong(1);
+                                dedicateZone(conn, zoneId, domainId, affinityGroupId);
+                            }
+                        } catch (SQLException e) {
+                            throw new CloudRuntimeException("Exception while Moving private zone information to dedicated resources", e);
+                        }
+                    } catch (SQLException e) {
+                        throw new CloudRuntimeException("Exception while Moving private zone information to dedicated resources", e);
                     }
-
-                    // add the domain map
-                    String sqlMap = "INSERT INTO `cloud`.`affinity_group_domain_map` (`domain_id`, `affinity_group_id`) VALUES (?, ?)";
-                    pstmtUpdate = conn.prepareStatement(sqlMap);
-                    pstmtUpdate.setLong(1, domainId);
-                    pstmtUpdate.setLong(2, affinityGroupId);
-                    pstmtUpdate.executeUpdate();
-                    pstmtUpdate.close();
-
-                }
-
-                rs2.close();
-                pstmt2.close();
-
-                pstmt = conn.prepareStatement("SELECT `id` FROM `cloud`.`data_center` WHERE `domain_id` = ? AND removed IS NULL");
-                pstmt.setLong(1, domainId);
-                rs = pstmt.executeQuery();
-
-                while (rs.next()) {
-                    long zoneId = rs.getLong(1);
-                    dedicateZone(conn, zoneId, domainId, affinityGroupId);
                 }
+            } catch (SQLException e) {
+                throw new CloudRuntimeException("Exception while Moving private zone information to dedicated resources", e);
             }
-
-        } catch (SQLException e) {
+        }catch (SQLException e) {
             throw new CloudRuntimeException("Exception while Moving private zone information to dedicated resources", e);
-        } finally {
-            if (pstmtUpdate != null) {
-                try {
-                    pstmtUpdate.close();
-                } catch (SQLException e) {
-                }
-            }
-            if (rs != null) {
-                try {
-                    rs.close();
-                } catch (SQLException e) {
-                }
-            }
-            if (pstmt != null) {
-                try {
-                    pstmt.close();
-                } catch (SQLException e) {
-                }
-            }
-            if (rs3 != null) {
-                try {
-                    rs3.close();
-                } catch (SQLException e) {
-                }
-            }
-            if (pstmt3 != null) {
-                try {
-                    pstmt3.close();
-                } catch (SQLException e) {
-                }
-            }
-
         }
     }
-
     private void dedicateZone(Connection conn, long zoneId, long domainId, long affinityGroupId) {
-        PreparedStatement pstmtUpdate2 = null;
-        try {
+        try( PreparedStatement pstmtUpdate2 = conn.prepareStatement("INSERT INTO `cloud`.`dedicated_resources` (`uuid`,`data_center_id`, `domain_id`, `affinity_group_id`) VALUES (?, ?, ?, ?)");) {
             // create the dedicated resources entry
-            String sql = "INSERT INTO `cloud`.`dedicated_resources` (`uuid`,`data_center_id`, `domain_id`, `affinity_group_id`) VALUES (?, ?, ?, ?)";
-            pstmtUpdate2 = conn.prepareStatement(sql);
             pstmtUpdate2.setString(1, UUID.randomUUID().toString());
             pstmtUpdate2.setLong(2, zoneId);
             pstmtUpdate2.setLong(3, domainId);
@@ -471,13 +379,6 @@ public class Upgrade410to420 implements DbUpgrade {
             pstmtUpdate2.close();
         } catch (SQLException e) {
             throw new CloudRuntimeException("Exception while saving zone to dedicated resources", e);
-        } finally {
-            if (pstmtUpdate2 != null) {
-                try {
-                    pstmtUpdate2.close();
-                } catch (SQLException e) {
-                }
-            }
         }
     }
 
@@ -494,39 +395,43 @@ public class Upgrade410to420 implements DbUpgrade {
         keys.add("fk_external_pxe_devices_physical_network_id");
         DbUpgradeUtils.dropKeysIfExist(conn, "baremetal_pxe_devices", keys, true);
 
-        PreparedStatement pstmt = null;
-        try {
-            pstmt =
-                    conn.prepareStatement("ALTER TABLE `cloud`.`baremetal_dhcp_devices` ADD CONSTRAINT `fk_external_dhcp_devices_nsp_id` FOREIGN KEY (`nsp_id`) REFERENCES `physical_network_service_providers` (`id`) ON DELETE CASCADE");
-            pstmt.executeUpdate();
-            pstmt.close();
-            pstmt =
-                    conn.prepareStatement("ALTER TABLE `cloud`.`baremetal_dhcp_devices` ADD CONSTRAINT `fk_external_dhcp_devices_host_id` FOREIGN KEY (`host_id`) REFERENCES `host`(`id`) ON DELETE CASCADE");
-            pstmt.executeUpdate();
-            pstmt.close();
-            pstmt.close();
-            pstmt =
-                    conn.prepareStatement("ALTER TABLE `cloud`.`baremetal_dhcp_devices` ADD CONSTRAINT `fk_external_dhcp_devices_physical_network_id` FOREIGN KEY (`physical_network_id`) REFERENCES `physical_network`(`id`) ON DELETE CASCADE");
-            pstmt.executeUpdate();
-            pstmt.close();
+        try (PreparedStatement alter_pstmt = conn.prepareStatement("ALTER TABLE `cloud`.`baremetal_dhcp_devices` ADD CONSTRAINT `fk_external_dhcp_devices_nsp_id` FOREIGN KEY (`nsp_id`) REFERENCES `physical_network_service_providers` (`id`) ON DELETE CASCADE");)
+        {
+            alter_pstmt.executeUpdate();
+            try(PreparedStatement  alter_pstmt_id =
+                        conn.prepareStatement("ALTER TABLE `cloud`.`baremetal_dhcp_devices` ADD CONSTRAINT `fk_external_dhcp_devices_host_id` FOREIGN KEY (`host_id`) REFERENCES `host`(`id`) ON DELETE CASCADE");
+            ) {
+                alter_pstmt_id.executeUpdate();
+                try(PreparedStatement alter_pstmt_phy_net =
+                        conn.prepareStatement("ALTER TABLE `cloud`.`baremetal_dhcp_devices` ADD CONSTRAINT `fk_external_dhcp_devices_physical_network_id` FOREIGN KEY (`physical_network_id`) REFERENCES `physical_network`(`id`) ON DELETE CASCADE");)
+                {
+                    alter_pstmt_phy_net.executeUpdate();
+                }catch (SQLException e) {
+                    throw new CloudRuntimeException("Unable to add foreign keys to baremetal_dhcp_devices table", e);
+                }
+            }catch (SQLException e) {
+                throw new CloudRuntimeException("Unable to add foreign keys to baremetal_dhcp_devices table", e);
+            }
             s_logger.debug("Added foreign keys for table baremetal_dhcp_devices");
         } catch (SQLException e) {
             throw new CloudRuntimeException("Unable to add foreign keys to baremetal_dhcp_devices table", e);
         }
-
-        try {
-            pstmt =
-                    conn.prepareStatement("ALTER TABLE `cloud`.`baremetal_pxe_devices` ADD CONSTRAINT `fk_external_pxe_devices_nsp_id` FOREIGN KEY (`nsp_id`) REFERENCES `physical_network_service_providers` (`id`) ON DELETE CASCADE");
-            pstmt.executeUpdate();
-            pstmt.close();
-            pstmt =
-                    conn.prepareStatement("ALTER TABLE `cloud`.`baremetal_pxe_devices` ADD CONSTRAINT `fk_external_pxe_devices_host_id` FOREIGN KEY (`host_id`) REFERENCES `host`(`id`) ON DELETE CASCADE");
-            pstmt.executeUpdate();
-            pstmt.close();
-            pstmt =
-                    conn.prepareStatement("ALTER TABLE `cloud`.`baremetal_pxe_devices` ADD CONSTRAINT `fk_external_pxe_devices_physical_network_id` FOREIGN KEY (`physical_network_id`) REFERENCES `physical_network`(`id`) ON DELETE CASCADE");
-            pstmt.executeUpdate();
-            pstmt.close();
+        try (PreparedStatement alter_pxe_pstmt =
+                     conn.prepareStatement("ALTER TABLE `cloud`.`baremetal_pxe_devices` ADD CONSTRAINT `fk_external_pxe_devices_nsp_id` FOREIGN KEY (`nsp_id`) REFERENCES `physical_network_service_providers` (`id`) ON DELETE CASCADE");)
+        {
+            alter_pxe_pstmt.executeUpdate();
+            try(PreparedStatement alter_pxe_id_pstmt =
+                    conn.prepareStatement("ALTER TABLE `cloud`.`baremetal_pxe_devices` ADD CONSTRAINT `fk_external_pxe_devices_host_id` FOREIGN KEY (`host_id`) REFERENCES `host`(`id`) ON DELETE CASCADE");) {
+                alter_pxe_id_pstmt.executeUpdate();
+                try(PreparedStatement alter_pxe_phy_net_pstmt =
+                        conn.prepareStatement("ALTER TABLE `cloud`.`baremetal_pxe_devices` ADD CONSTRAINT `fk_external_pxe_devices_physical_network_id` FOREIGN KEY (`physical_network_id`) REFERENCES `physical_network`(`id`) ON DELETE CASCADE");) {
+                    alter_pxe_phy_net_pstmt.executeUpdate();
+                }catch (SQLException e) {
+                    throw new CloudRuntimeException("Unable to add foreign keys to baremetal_pxe_devices table", e);
+                }
+            }catch (SQLException e) {
+                throw new CloudRuntimeException("Unable to add foreign keys to baremetal_pxe_devices table", e);
+            }
             s_logger.debug("Added foreign keys for table baremetal_pxe_devices");
         } catch (SQLException e) {
             throw new CloudRuntimeException("Unable to add foreign keys to baremetal_pxe_devices table", e);
@@ -534,169 +439,121 @@ public class Upgrade410to420 implements DbUpgrade {
     }
 
     private void addIndexForAlert(Connection conn) {
-
         //First drop if it exists. (Due to patches shipped to customers some will have the index and some wont.)
         List<String> indexList = new ArrayList<String>();
         s_logger.debug("Dropping index i_alert__last_sent if it exists");
         indexList.add("last_sent"); // in 4.1, we created this index that is not in convention.
         indexList.add("i_alert__last_sent");
         DbUpgradeUtils.dropKeysIfExist(conn, "alert", indexList, false);
-
         //Now add index.
-        PreparedStatement pstmt = null;
-        try {
-            pstmt = conn.prepareStatement("ALTER TABLE `cloud`.`alert` ADD INDEX `i_alert__last_sent`(`last_sent`)");
+        try(PreparedStatement pstmt = conn.prepareStatement("ALTER TABLE `cloud`.`alert` ADD INDEX `i_alert__last_sent`(`last_sent`)");)
+        {
             pstmt.executeUpdate();
             s_logger.debug("Added index i_alert__last_sent for table alert");
         } catch (SQLException e) {
             throw new CloudRuntimeException("Unable to add index i_alert__last_sent to alert table for the column last_sent", e);
-        } finally {
-            try {
-                if (pstmt != null) {
-                    pstmt.close();
-                }
-            } catch (SQLException e) {
-            }
         }
-
     }
 
     private void dropUploadTable(Connection conn) {
-
-        PreparedStatement pstmt0 = null;
-        PreparedStatement pstmt1 = null;
-        PreparedStatement pstmt2 = null;
-        PreparedStatement pstmt3 = null;
-
-        ResultSet rs0 = null;
-        ResultSet rs2 = null;
-
-        try {
+        try(PreparedStatement  pstmt0 = conn.prepareStatement("SELECT url, created, type_id, host_id from upload where type=?");) {
             // Read upload table - Templates
             s_logger.debug("Populating template_store_ref table");
-            pstmt0 = conn.prepareStatement("SELECT url, created, type_id, host_id from upload where type=?");
             pstmt0.setString(1, "TEMPLATE");
-            rs0 = pstmt0.executeQuery();
-            pstmt1 = conn.prepareStatement("UPDATE template_store_ref SET download_url=?, download_url_created=? where template_id=? and store_id=?");
-
-            //Update template_store_ref
-            while (rs0.next()) {
-                pstmt1.setString(1, rs0.getString("url"));
-                pstmt1.setDate(2, rs0.getDate("created"));
-                pstmt1.setLong(3, rs0.getLong("type_id"));
-                pstmt1.setLong(4, rs0.getLong("host_id"));
-                pstmt1.executeUpdate();
-            }
-
-            // Read upload table - Volumes
-            s_logger.debug("Populating volume store ref table");
-            pstmt2 = conn.prepareStatement("SELECT url, created, type_id, host_id, install_path from upload where type=?");
-            pstmt2.setString(1, "VOLUME");
-            rs2 = pstmt2.executeQuery();
-
-            pstmt3 =
-                    conn.prepareStatement("INSERT IGNORE INTO volume_store_ref (volume_id, store_id, zone_id, created, state, download_url, download_url_created, install_path) VALUES (?,?,?,?,?,?,?,?)");
-            //insert into template_store_ref
-            while (rs2.next()) {
-                pstmt3.setLong(1, rs2.getLong("type_id"));
-                pstmt3.setLong(2, rs2.getLong("host_id"));
-                pstmt3.setLong(3, 1l);// ???
-                pstmt3.setDate(4, rs2.getDate("created"));
-                pstmt3.setString(5, "Ready");
-                pstmt3.setString(6, rs2.getString("url"));
-                pstmt3.setDate(7, rs2.getDate("created"));
-                pstmt3.setString(8, rs2.getString("install_path"));
-                pstmt3.executeUpdate();
+            try(ResultSet rs0 = pstmt0.executeQuery();)
+            {
+                try(PreparedStatement pstmt1 = conn.prepareStatement("UPDATE template_store_ref SET download_url=?, download_url_created=? where template_id=? and store_id=?");) {
+                    //Update template_store_ref
+                    while (rs0.next()) {
+                        pstmt1.setString(1, rs0.getString("url"));
+                        pstmt1.setDate(2, rs0.getDate("created"));
+                        pstmt1.setLong(3, rs0.getLong("type_id"));
+                        pstmt1.setLong(4, rs0.getLong("host_id"));
+                        pstmt1.executeUpdate();
+                    }
+                    // Read upload table - Volumes
+                    s_logger.debug("Populating volume store ref table");
+                    try(PreparedStatement pstmt2 = conn.prepareStatement("SELECT url, created, type_id, host_id, install_path from upload where type=?");) {
+                        pstmt2.setString(1, "VOLUME");
+                            try(ResultSet rs2 = pstmt2.executeQuery();) {
+
+                                try(PreparedStatement pstmt3 =
+                                        conn.prepareStatement("INSERT IGNORE INTO volume_store_ref (volume_id, store_id, zone_id, created, state, download_url, download_url_created, install_path) VALUES (?,?,?,?,?,?,?,?)");) {
+                                    //insert into template_store_ref
+                                    while (rs2.next()) {
+                                        pstmt3.setLong(1, rs2.getLong("type_id"));
+                                        pstmt3.setLong(2, rs2.getLong("host_id"));
+                                        pstmt3.setLong(3, 1l);// ???
+                                        pstmt3.setDate(4, rs2.getDate("created"));
+                                        pstmt3.setString(5, "Ready");
+                                        pstmt3.setString(6, rs2.getString("url"));
+                                        pstmt3.setDate(7, rs2.getDate("created"));
+                                        pstmt3.setString(8, rs2.getString("install_path"));
+                                        pstmt3.executeUpdate();
+                                    }
+                                }catch (SQLException e) {
+                                    throw new CloudRuntimeException("Unable add date into template/volume store ref from upload table.", e);
+                                }
+                            }catch (SQLException e) {
+                                throw new CloudRuntimeException("Unable add date into template/volume store ref from upload table.", e);
+                            }
+                    }catch (SQLException e) {
+                        throw new CloudRuntimeException("Unable add date into template/volume store ref from upload table.", e);
+                    }
+                }catch (SQLException e) {
+                    throw new CloudRuntimeException("Unable add date into template/volume store ref from upload table.", e);
+                }
+            }catch (SQLException e) {
+                throw new CloudRuntimeException("Unable add date into template/volume store ref from upload table.", e);
             }
 
         } catch (SQLException e) {
             throw new CloudRuntimeException("Unable add date into template/volume store ref from upload table.", e);
-        } finally {
-            try {
-                if (pstmt0 != null) {
-                    pstmt0.close();
-                }
-                if (pstmt1 != null) {
-                    pstmt1.close();
-                }
-                if (pstmt2 != null) {
-                    pstmt2.close();
-                }
-                if (pstmt3 != null) {
-                    pstmt3.close();
-                }
-            } catch (SQLException e) {
-            }
         }
-
     }
 
     //KVM snapshot flag: only turn on if Customers is using snapshot;
     private void setKVMSnapshotFlag(Connection conn) {
         s_logger.debug("Verify and set the KVM snapshot flag if snapshot was used. ");
-        PreparedStatement pstmt = null;
-        ResultSet rs = null;
-        try {
+        try(PreparedStatement pstmt = conn.prepareStatement("select count(*) from `cloud`.`snapshots` where hypervisor_type = 'KVM'");)
+        {
             int numRows = 0;
-            pstmt = conn.prepareStatement("select count(*) from `cloud`.`snapshots` where hypervisor_type = 'KVM'");
-            rs = pstmt.executeQuery();
-            if (rs.next()) {
-                numRows = rs.getInt(1);
-            }
-            rs.close();
-            pstmt.close();
-            if (numRows > 0) {
-                //Add the configuration flag
-                pstmt = conn.prepareStatement("UPDATE `cloud`.`configuration` SET value = ? WHERE name = 'kvm.snapshot.enabled'");
-                pstmt.setString(1, "true");
-                pstmt.executeUpdate();
-            }
-        } catch (SQLException e) {
-            throw new CloudRuntimeException("Failed to read the snapshot table for KVM upgrade. ", e);
-        } finally {
-            try {
-                if (rs != null) {
-                    rs.close();
+            try(ResultSet rs = pstmt.executeQuery();) {
+                if (rs.next()) {
+                    numRows = rs.getInt(1);
                 }
-
-                if (pstmt != null) {
-                    pstmt.close();
+                if (numRows > 0) {
+                    //Add the configuration flag
+                    try(PreparedStatement update_pstmt = conn.prepareStatement("UPDATE `cloud`.`configuration` SET value = ? WHERE name = 'kvm.snapshot.enabled'");) {
+                        update_pstmt.setString(1, "true");
+                        update_pstmt.executeUpdate();
+                    }catch (SQLException e) {
+                        throw new CloudRuntimeException("Failed to read the snapshot table for KVM upgrade. ", e);
+                    }
                 }
-            } catch (SQLException e) {
+            }catch (SQLException e) {
+                throw new CloudRuntimeException("Failed to read the snapshot table for KVM upgrade. ", e);
             }
+        } catch (SQLException e) {
+            throw new CloudRuntimeException("Failed to read the snapshot table for KVM upgrade. ", e);
         }
         s_logger.debug("Done set KVM snapshot flag. ");
     }
 
     private void updatePrimaryStore(Connection conn) {
-        PreparedStatement sql = null;
-        PreparedStatement sql2 = null;
-        try {
-            sql = conn.prepareStatement("update storage_pool set storage_provider_name = ? , scope = ? where pool_type = 'Filesystem' or pool_type = 'LVM'");
+        try(PreparedStatement sql = conn.prepareStatement("update storage_pool set storage_provider_name = ? , scope = ? where pool_type = 'Filesystem' or pool_type = 'LVM'");) {
             sql.setString(1, DataStoreProvider.DEFAULT_PRIMARY);
             sql.setString(2, "HOST");
             sql.executeUpdate();
-
-            sql2 = conn.prepareStatement("update storage_pool set storage_provider_name = ? , scope = ? where pool_type != 'Filesystem' and pool_type != 'LVM'");
-            sql2.setString(1, DataStoreProvider.DEFAULT_PRIMARY);
-            sql2.setString(2, "CLUSTER");
-            sql2.executeUpdate();
+            try(PreparedStatement sql2 = conn.prepareStatement("update storage_pool set storage_provider_name = ? , scope = ? where pool_type != 'Filesystem' and pool_type != 'LVM'");) {
+                sql2.setString(1, DataStoreProvider.DEFAULT_PRIMARY);
+                sql2.setString(2, "CLUSTER");
+                sql2.executeUpdate();
+            }catch (SQLException e) {
+                throw new CloudRuntimeException("Failed to upgrade vm template data store uuid: " + e.toString());
+            }
         } catch (SQLException e) {
             throw new CloudRuntimeException("Failed to upgrade vm template data store uuid: " + e.toString());
-        } finally {
-            if (sql != null) {
-                try {
-                    sql.close();
-                } catch (SQLException e) {
-                }
-            }
-
-            if (sql2 != null) {
-                try {
-                    sql2.close();
-                } catch (SQLException e) {
-                }
-            }
         }
     }
 
@@ -789,7 +646,7 @@ public class Upgrade410to420 implements DbUpgrade {
         String newGuestLabel = oldParamValue;
         try {
             // No need to iterate because the global param setting applies to all physical networks irrespective of traffic type
-            if (rs.next()) {
+            if ((rs != null) && (rs.next())) {
                 oldGuestLabel = rs.getString("vmware_network_label");
                 // guestLabel is in format [[<VSWITCHNAME>],VLANID]
                 separatorIndex = oldGuestLabel.indexOf(",");
@@ -799,65 +656,57 @@ public class Upgrade410to420 implements DbUpgrade {
             }
         } catch (SQLException e) {
             s_logger.error(new CloudRuntimeException("Failed to read vmware_network_label : " + e));
-        } finally {
-            try {
-                if (rs != null) {
-                    rs.close();
-                }
-            } catch (SQLException e) {
-            }
         }
         return newGuestLabel;
     }
 
     private void upgradeVmwareLabels(Connection conn) {
-        PreparedStatement pstmt = null;
-        ResultSet rsParams = null;
-        ResultSet rsLabel = null;
         String newLabel;
         String trafficType = null;
         String trafficTypeVswitchParam;
         String trafficTypeVswitchParamValue;
 
-        try {
+        try (PreparedStatement pstmt =
+                     conn.prepareStatement("select name,value from `cloud`.`configuration` where category='Hidden' and value is not NULL and name REGEXP 'vmware*.vswitch';");)
+        {
             // update the existing vmware traffic labels
-            pstmt =
-                    conn.prepareStatement("select name,value from `cloud`.`configuration` where category='Hidden' and value is not NULL and name REGEXP 'vmware*.vswitch';");
-            rsParams = pstmt.executeQuery();
-            while (rsParams.next()) {
-                trafficTypeVswitchParam = rsParams.getString("name");
-                trafficTypeVswitchParamValue = rsParams.getString("value");
-                // When upgraded from 4.0 to 4.1 update physical network traffic label with trafficTypeVswitchParam
-                if (trafficTypeVswitchParam.equals("vmware.private.vswitch")) {
-                    trafficType = "Management"; //TODO(sateesh): Ignore storage traffic, as required physical network already implemented, anything else tobe done?
-                } else if (trafficTypeVswitchParam.equals("vmware.public.vswitch")) {
-                    trafficType = "Public";
-                } else if (trafficTypeVswitchParam.equals("vmware.guest.vswitch")) {
-                    trafficType = "Guest";
+            try(ResultSet rsParams = pstmt.executeQuery();) {
+                while (rsParams.next()) {
+                    trafficTypeVswitchParam = rsParams.getString("name");
+                    trafficTypeVswitchParamValue = rsParams.getString("value");
+                    // When upgraded from 4.0 to 4.1 update physical network traffic label with trafficTypeVswitchParam
+                    if (trafficTypeVswitchParam.equals("vmware.private.vswitch")) {
+                        trafficType = "Management"; //TODO(sateesh): Ignore storage traffic, as required physical network already implemented, anything else tobe done?
+                    } else if (trafficTypeVswitchParam.equals("vmware.public.vswitch")) {
+                        trafficType = "Public";
+                    } else if (trafficTypeVswitchParam.equals("vmware.guest.vswitch")) {
+                        trafficType = "Guest";
+                    }
+                    try(PreparedStatement sel_pstmt =
+                            conn.prepareStatement("select physical_network_id, traffic_type, vmware_network_label from physical_network_traffic_types where vmware_network_label is not NULL and traffic_type='" +
+                                    trafficType + "';");) {
+                        try(ResultSet rsLabel = sel_pstmt.executeQuery();) {
+                            newLabel = getNewLabel(rsLabel, trafficTypeVswitchParamValue);
+                            try(PreparedStatement update_pstmt =
+                                    conn.prepareStatement("update physical_network_traffic_types set vmware_network_label = " + newLabel + " where traffic_type = '" + trafficType +
+                                            "' and vmware_network_label is not NULL;");) {
+                                s_logger.debug("Updating vmware label for " + trafficType + " traffic. Update SQL statement is " + pstmt);
+                                update_pstmt.executeUpdate();
+                            }catch (SQLException e) {
+                                throw new CloudRuntimeException("Unable to set vmware traffic labels ", e);
+                            }
+                        }catch (SQLException e) {
+                            throw new CloudRuntimeException("Unable to set vmware traffic labels ", e);
+                        }
+                    }catch (SQLException e) {
+                        throw new CloudRuntimeException("Unable to set vmware traffic labels ", e);
+                    }
                 }
-                pstmt =
-                        conn.prepareStatement("select physical_network_id, traffic_type, vmware_network_label from physical_network_traffic_types where vmware_network_label is not NULL and traffic_type='" +
-                                trafficType + "';");
-                rsLabel = pstmt.executeQuery();
-                newLabel = getNewLabel(rsLabel, trafficTypeVswitchParamValue);
-                pstmt =
-                        conn.prepareStatement("update physical_network_traffic_types set vmware_network_label = " + newLabel + " where traffic_type = '" + trafficType +
-                                "' and vmware_network_label is not NULL;");
-                s_logger.debug("Updating vmware label for " + trafficType + " traffic. Update SQL statement is " + pstmt);
-                pstmt.executeUpdate();
+            }catch (SQLException e) {
+                throw new CloudRuntimeException("Unable to set vmware traffic labels ", e);
             }
         } catch (SQLException e) {
             throw new CloudRuntimeException("Unable to set vmware traffic labels ", e);
-        } finally {
-            try {
-                if (rsParams != null) {
-                    rsParams.close();
-                }
-                if (pstmt != null) {
-                    pstmt.close();
-                }
-            } catch (SQLException e) {
-            }
         }
     }
 
@@ -865,14 +714,10 @@ public class Upgrade410to420 implements DbUpgrade {
         List<Long> listOfLegacyZones = new ArrayList<Long>();
         List<Long> listOfNonLegacyZones = new ArrayList<Long>();
         Map<String, ArrayList<Long>> dcToZoneMap = new HashMap<String, ArrayList<Long>>();
-        PreparedStatement pstmt = null;
-        PreparedStatement clustersQuery = null;
-        PreparedStatement clusterDetailsQuery = null;
-        ResultSet rs = null;
         ResultSet clusters = null;
-        ResultSet clusterDetails = null;
         Long zoneId;
         Long clusterId;
+        ArrayList<String> dcList = null;
         String clusterHypervisorType;
         boolean legacyZone;
         boolean ignoreZone;
@@ -884,121 +729,107 @@ public class Upgrade410to420 implements DbUpgrade {
         String vc = "";
         String dcName = "";
 
-        try {
-            pstmt = conn.prepareStatement("select id from `cloud`.`data_center` where removed is NULL");
-            rs = pstmt.executeQuery();
-
-            while (rs.next()) {
-                zoneId = rs.getLong("id");
-                clustersQuery = conn.prepareStatement("select id, hypervisor_type from `cloud`.`cluster` where removed is NULL AND data_center_id=?");
-                clustersQuery.setLong(1, zoneId);
-                legacyZone = false;
-                ignoreZone = true;
-                ArrayList<String> dcList = new ArrayList<String>();
-                count = 0L;
-                // Legacy zone term is meant only for VMware
-                // Legacy zone is a zone with atleast 2 clusters & with multiple DCs or VCs
-                clusters = clustersQuery.executeQuery();
-                if (!clusters.next()) {
-                    continue; // Ignore the zone without any clusters
-                } else {
-                    dcOfPreviousCluster = null;
-                    dcOfCurrentCluster = null;
-                    do {
-                        clusterHypervisorType = clusters.getString("hypervisor_type");
-                        clusterId = clusters.getLong("id");
-                        if (clusterHypervisorType.equalsIgnoreCase("VMware")) {
-                            ignoreZone = false;
-                            clusterDetailsQuery = conn.prepareStatement("select value from `cloud`.`cluster_details` where name='url' and cluster_id=?");
-                            clusterDetailsQuery.setLong(1, clusterId);
-                            clusterDetails = clusterDetailsQuery.executeQuery();
-                            clusterDetails.next();
-                            url = clusterDetails.getString("value");
-                            tokens = url.split("/"); // url format - http://vcenter/dc/cluster
-                            vc = tokens[2];
-                            dcName = tokens[3];
-                            dcOfPreviousCluster = dcOfCurrentCluster;
-                            dcOfCurrentCluster = dcName + "@" + vc;
-                            if (!dcList.contains(dcOfCurrentCluster)) {
-                                dcList.add(dcOfCurrentCluster);
-                            }
-                            if (count > 0) {
-                                if (!dcOfPreviousCluster.equalsIgnoreCase(dcOfCurrentCluster)) {
-                                    legacyZone = true;
-                                    s_logger.debug("Marking the zone " + zoneId + " as legacy zone.");
+        try(PreparedStatement pstmt = conn.prepareStatement("select id from `cloud`.`data_center` where removed is NULL");) {
+            try (ResultSet rs = pstmt.executeQuery();) {
+                while (rs.next()) {
+                    zoneId = rs.getLong("id");
+                    try(PreparedStatement clustersQuery = conn.prepareStatement("select id, hypervisor_type from `cloud`.`cluster` where removed is NULL AND data_center_id=?");) {
+                        clustersQuery.setLong(1, zoneId);
+                        legacyZone = false;
+                        ignoreZone = true;
+                        dcList = new ArrayList<String>();
+                        count = 0L;
+                        // Legacy zone term is meant only for VMware
+                        // Legacy zone is a zone with atleast 2 clusters & with multiple DCs or VCs
+                        clusters = clustersQuery.executeQuery();
+                    }catch (SQLException e) {
+                        throw new CloudRuntimeException("persistLegacyZones:Exception:"+e.getMessage(), e);
+                    }
+                    if (!clusters.next()) {
+                        continue; // Ignore the zone without any clusters
+                    } else {
+                        dcOfPreviousCluster = null;
+                        dcOfCurrentCluster = null;
+                        do {
+                            clusterHypervisorType = clusters.getString("hypervisor_type");
+                            clusterId = clusters.getLong("id");
+                            if (clusterHypervisorType.equalsIgnoreCase("VMware")) {
+                                ignoreZone = false;
+                                try (PreparedStatement clusterDetailsQuery = conn.prepareStatement("select value from `cloud`.`cluster_details` where name='url' and cluster_id=?");) {
+                                    clusterDetailsQuery.setLong(1, clusterId);
+                                    try (ResultSet clusterDetails = clusterDetailsQuery.executeQuery();) {
+                                        clusterDetails.next();
+                                        url = clusterDetails.getString("value");
+                                        tokens = url.split("/"); // url format - http://vcenter/dc/cluster
+                                        vc = tokens[2];
+                                        dcName = tokens[3];
+                                        dcOfPreviousCluster = dcOfCurrentCluster;
+                                        dcOfCurrentCluster = dcName + "@" + vc;
+                                        if (!dcList.contains(dcOfCurrentCluster)) {
+                                            dcList.add(dcOfCurrentCluster);
+                                        }
+                                        if (count > 0) {
+                                            if (!dcOfPreviousCluster.equalsIgnoreCase(dcOfCurrentCluster)) {
+                                                legacyZone = true;
+                                                s_logger.debug("Marking the zone " + zoneId + " as legacy zone.");
+                                            }
+                                        }
+                                    } catch (SQLException e) {
+                                        throw new CloudRuntimeException("Unable add zones to cloud.legacyzones table.", e);
+                                    }
+                                } catch (SQLException e) {
+                                    throw new CloudRuntimeException("Unable add zones to cloud.legacyzones table.", e);
                                 }
+                            } else {
+                                s_logger.debug("Ignoring zone " + zoneId + " with hypervisor type " + clusterHypervisorType);
+                                break;
                             }
-                        } else {
-                            s_logger.debug("Ignoring zone " + zoneId + " with hypervisor type " + clusterHypervisorType);
-                            break;
+                            count++;
+                        } while (clusters.next());
+                        if (ignoreZone) {
+                            continue; // Ignore the zone with hypervisors other than VMware
                         }
-                        count++;
-                    } while (clusters.next());
-                    if (ignoreZone) {
-                        continue; // Ignore the zone with hypervisors other than VMware
                     }
-                }
-                if (legacyZone) {
-                    listOfLegacyZones.add(zoneId);
-                } else {
-                    listOfNonLegacyZones.add(zoneId);
-                }
-                for (String dc : dcList) {
-                    ArrayList<Long> dcZones = new ArrayList<Long>();
-                    if (dcToZoneMap.get(dc) != null) {
-                        dcZones = dcToZoneMap.get(dc);
+                    if (legacyZone) {
+                        listOfLegacyZones.add(zoneId);
+                    } else {
+                        listOfNonLegacyZones.add(zoneId);
                     }
-                    dcZones.add(zoneId);
-                    dcToZoneMap.put(dc, dcZones);
-                }
-            }
-            // If a VMware datacenter in a vCenter maps to more than 1 CloudStack zone, mark all the zones it is mapped to as legacy
-            for (Map.Entry<String, ArrayList<Long>> entry : dcToZoneMap.entrySet()) {
-                if (entry.getValue().size() > 1) {
-                    for (Long newLegacyZone : entry.getValue()) {
-                        if (listOfNonLegacyZones.contains(newLegacyZone)) {
-                            listOfNonLegacyZones.remove(newLegacyZone);
-                            listOfLegacyZones.add(newLegacyZone);
+                    for (String dc : dcList) {
+                        ArrayList<Long> dcZones = new ArrayList<Long>();
+                        if (dcToZoneMap.get(dc) != null) {
+                            dcZones = dcToZoneMap.get(dc);
                         }
+                        dcZones.add(zoneId);
+                        dcToZoneMap.put(dc, dcZones);
                     }
                 }
-            }
-            updateLegacyZones(conn, listOfLegacyZones);
-            updateNonLegacyZones(conn, listOfNonLegacyZones);
-        } catch (SQLException e) {
-            String msg = "Unable to discover legacy zones." + e.getMessage();
-            s_logger.error(msg);
-            throw new CloudRuntimeException(msg, e);
-        } finally {
-            try {
-                if (rs != null) {
-                    rs.close();
-                }
-                if (pstmt != null) {
-                    pstmt.close();
-                }
-                if (clusters != null) {
-                    clusters.close();
-                }
-                if (clusterDetails != null) {
-                    clusterDetails.close();
-                }
-                if (clustersQuery != null) {
-                    clustersQuery.close();
-                }
-                if (clusterDetailsQuery != null) {
-                    clusterDetailsQuery.close();
+                // If a VMware datacenter in a vCenter maps to more than 1 CloudStack zone, mark all the zones it is mapped to as legacy
+                for (Map.Entry<String, ArrayList<Long>> entry : dcToZoneMap.entrySet()) {
+                    if (entry.getValue().size() > 1) {
+                        for (Long newLegacyZone : entry.getValue()) {
+                            if (listOfNonLegacyZones.contains(newLegacyZone)) {
+                                listOfNonLegacyZones.remove(newLegacyZone);
+                                listOfLegacyZones.add(newLegacyZone);
+                            }
+                        }
+                    }
                 }
+                updateLegacyZones(conn, listOfLegacyZones);
+                updateNonLegacyZones(conn, listOfNonLegacyZones);
             } catch (SQLException e) {
+                s_logger.error("Unable to discover legacy zones." + e.getMessage(),e);
+                throw new CloudRuntimeException("Unable to discover legacy zones." + e.getMessage(), e);
             }
+        }catch (SQLException e) {
+            s_logger.error("Unable to discover legacy zones." + e.getMessage(),e);
+            throw new CloudRuntimeException("Unable to discover legacy zones." + e.getMessage(), e);
         }
     }
 
     private void updateLegacyZones(Connection conn, List<Long> zones) {
-        PreparedStatement legacyZonesQuery = null;
         //Insert legacy zones into table for legacy zones.
-        try {
-            legacyZonesQuery = conn.prepareStatement("INSERT INTO `cloud`.`legacy_zones` (zone_id) VALUES (?)");
+        try (PreparedStatement legacyZonesQuery = conn.prepareStatement("INSERT INTO `cloud`.`legacy_zones` (zone_id) VALUES (?)");){
             for (Long zoneId : zones) {
                 legacyZonesQuery.setLong(1, zoneId);
                 legacyZonesQuery.executeUpdate();
@@ -1006,13 +837,6 @@ public class Upgrade410to420 implements DbUpgrade {
             }
         } catch (SQLException e) {
             throw new CloudRuntimeException("Unable add zones to cloud.legacyzones table.", e);
-        } finally {
-            try {
-                if (legacyZonesQuery != null) {
-                    legacyZonesQuery.close();
-                }
-            } catch (SQLException e) {
-            }
         }
     }
 
@@ -1109,157 +933,141 @@ public class Upgrade410to420 implements DbUpgrade {
     }
 
     private void createPlaceHolderNics(Connection conn) {
-        PreparedStatement pstmt = null;
-        ResultSet rs = null;
-
-        try {
-            pstmt =
-                    conn.prepareStatement("SELECT network_id, gateway, ip4_address FROM `cloud`.`nics` WHERE reserver_name IN ('DirectNetworkGuru','DirectPodBasedNetworkGuru') and vm_type='DomainRouter' AND removed IS null");
-            rs = pstmt.executeQuery();
-            while (rs.next()) {
-                Long networkId = rs.getLong(1);
-                String gateway = rs.getString(2);
-                String ip = rs.getString(3);
-                String uuid = UUID.randomUUID().toString();
-                //Insert placeholder nic for each Domain router nic in Shared network
-                pstmt =
-                        conn.prepareStatement("INSERT INTO `cloud`.`nics` (uuid, ip4_address, gateway, network_id, state, strategy, vm_type, default_nic, created) VALUES (?, ?, ?, ?, 'Reserved', 'PlaceHolder', 'DomainRouter', 0, now())");
-                pstmt.setString(1, uuid);
-                pstmt.setString(2, ip);
-                pstmt.setString(3, gateway);
-                pstmt.setLong(4, networkId);
-                pstmt.executeUpdate();
-                s_logger.debug("Created placeholder nic for the ipAddress " + ip + " and network " + networkId);
-
+        try (PreparedStatement pstmt =
+                     conn.prepareStatement("SELECT network_id, gateway, ip4_address FROM `cloud`.`nics` WHERE reserver_name IN ('DirectNetworkGuru','DirectPodBasedNetworkGuru') and vm_type='DomainRouter' AND removed IS null");)
+        {
+            try(ResultSet rs = pstmt.executeQuery();) {
+                while (rs.next()) {
+                    Long networkId = rs.getLong(1);
+                    String gateway = rs.getString(2);
+                    String ip = rs.getString(3);
+                    String uuid = UUID.randomUUID().toString();
+                    //Insert placeholder nic for each Domain router nic in Shared network
+                    try(PreparedStatement insert_pstmt =
+                            conn.prepareStatement("INSERT INTO `cloud`.`nics` (uuid, ip4_address, gateway, network_id, state, strategy, vm_type, default_nic, created) VALUES (?, ?, ?, ?, 'Reserved', 'PlaceHolder', 'DomainRouter', 0, now())");) {
+                        insert_pstmt.setString(1, uuid);
+                        insert_pstmt.setString(2, ip);
+                        insert_pstmt.setString(3, gateway);
+                        insert_pstmt.setLong(4, networkId);
+                        insert_pstmt.executeUpdate();
+                    }catch (SQLException e) {
+                        throw new CloudRuntimeException("Unable to create placeholder nics", e);
+                    }
+                    s_logger.debug("Created placeholder nic for the ipAddress " + ip + " and network " + networkId);
+                }
+            }catch (SQLException e) {
+                throw new CloudRuntimeException("Unable to create placeholder nics", e);
             }
         } catch (SQLException e) {
             throw new CloudRuntimeException("Unable to create placeholder nics", e);
-        } finally {
-            try {
-                if (rs != null) {
-                    rs.close();
-                }
-                if (pstmt != null) {
-                    pstmt.close();
-                }
-            } catch (SQLException e) {
-            }
         }
     }
 
     private void updateRemoteAccessVpn(Connection conn) {
-        PreparedStatement pstmt = null;
-        ResultSet rs = null;
-
-        try {
-            pstmt = conn.prepareStatement("SELECT vpn_server_addr_id FROM `cloud`.`remote_access_vpn`");
-            rs = pstmt.executeQuery();
-            long id = 1;
-            while (rs.next()) {
-                String uuid = UUID.randomUUID().toString();
-                Long ipId = rs.getLong(1);
-                pstmt = conn.prepareStatement("UPDATE `cloud`.`remote_access_vpn` set uuid=?, id=? where vpn_server_addr_id=?");
-                pstmt.setString(1, uuid);
-                pstmt.setLong(2, id);
-                pstmt.setLong(3, ipId);
-                pstmt.executeUpdate();
-                id++;
+        try(PreparedStatement pstmt = conn.prepareStatement("SELECT vpn_server_addr_id FROM `cloud`.`remote_access_vpn`");) {
+            try(ResultSet rs = pstmt.executeQuery();) {
+                long id = 1;
+                while (rs.next()) {
+                    String uuid = UUID.randomUUID().toString();
+                    Long ipId = rs.getLong(1);
+                    try(PreparedStatement update_pstmt = conn.prepareStatement("UPDATE `cloud`.`remote_access_vpn` set uuid=?, id=? where vpn_server_addr_id=?");) {
+                        update_pstmt.setString(1, uuid);
+                        update_pstmt.setLong(2, id);
+                        update_pstmt.setLong(3, ipId);
+                        update_pstmt.executeUpdate();
+                        id++;
+                    }catch (SQLException e) {
+                        throw new CloudRuntimeException("Unable to update id/uuid of remote_access_vpn table", e);
+                    }
+                }
+            }catch (SQLException e) {
+                throw new CloudRuntimeException("Unable to update id/uuid of remote_access_vpn table", e);
             }
         } catch (SQLException e) {
             throw new CloudRuntimeException("Unable to update id/uuid of remote_access_vpn table", e);
-        } finally {
-            try {
-                if (rs != null) {
-                    rs.close();
-                }
-                if (pstmt != null) {
-                    pstmt.close();
-                }
-            } catch (SQLException e) {
-            }
         }
     }
 
     private void addEgressFwRulesForSRXGuestNw(Connection conn) {
-        PreparedStatement pstmt = null;
         ResultSet rs = null;
-        ResultSet rsId = null;
-        ResultSet rsNw = null;
-        try {
-            pstmt = conn.prepareStatement("select network_id FROM `cloud`.`ntwk_service_map` where service='Firewall' and provider='JuniperSRX' ");
+        try(PreparedStatement pstmt = conn.prepareStatement("select network_id FROM `cloud`.`ntwk_service_map` where service='Firewall' and provider='JuniperSRX' ");) {
             rs = pstmt.executeQuery();
             while (rs.next()) {
                 long netId = rs.getLong(1);
                 //checking for Isolated OR Virtual
-                pstmt =
-                        conn.prepareStatement("select account_id, domain_id FROM `cloud`.`networks` where (guest_type='Isolated' OR guest_type='Virtual') and traffic_type='Guest' and vpc_id is NULL and (state='implemented' OR state='Shutdown') and id=? ");
-                pstmt.setLong(1, netId);
-                s_logger.debug("Getting account_id, domain_id from networks table: " + pstmt);
-                rsNw = pstmt.executeQuery();
-
-                if (rsNw.next()) {
-                    long accountId = rsNw.getLong(1);
-                    long domainId = rsNw.getLong(2);
-
-                    //Add new rule for the existing networks
-                    s_logger.debug("Adding default egress firewall rule for network " + netId);
-                    pstmt =
-                            conn.prepareStatement("INSERT INTO firewall_rules (uuid, state, protocol, purpose, account_id, domain_id, network_id, xid, created,  traffic_type) VALUES (?, 'Active', 'all', 'Firewall', ?, ?, ?, ?, now(), 'Egress')");
-                    pstmt.setString(1, UUID.randomUUID().toString());
-                    pstmt.setLong(2, accountId);
-                    pstmt.setLong(3, domainId);
-                    pstmt.setLong(4, netId);
-                    pstmt.setString(5, UUID.randomUUID().toString());
-                    s_logger.debug("Inserting default egress firewall rule " + pstmt);
-                    pstmt.executeUpdate();
-
-                    pstmt = conn.prepareStatement("select id from firewall_rules where protocol='all' and network_id=?");
-                    pstmt.setLong(1, netId);
-                    rsId = pstmt.executeQuery();
-
-                    long firewallRuleId;
-                    if (rsId.next()) {
-                        firewallRuleId = rsId.getLong(1);
-                        pstmt = conn.prepareStatement("insert into firewall_rules_cidrs (firewall_rule_id,source_cidr) values (?, '0.0.0.0/0')");
-                        pstmt.setLong(1, firewallRuleId);
-                        s_logger.debug("Inserting rule for cidr 0.0.0.0/0 for the new Firewall rule id=" + firewallRuleId + " with statement " + pstmt);
-                        pstmt.executeUpdate();
+                try(PreparedStatement sel_net_pstmt =
+                        conn.prepareStatement("select account_id, domain_id FROM `cloud`.`networks` where (guest_type='Isolated' OR guest_type='Virtual') and traffic_type='Guest' and vpc_id is NULL and (state='implemented' OR state='Shutdown') and id=? ");) {
+                    sel_net_pstmt.setLong(1, netId);
+                    s_logger.debug("Getting account_id, domain_id from networks table: ");
+                    try(ResultSet rsNw = pstmt.executeQuery();)
+                    {
+                        if (rsNw.next()) {
+                            long accountId = rsNw.getLong(1);
+                            long domainId = rsNw.getLong(2);
+
+                            //Add new rule for the existing networks
+                            s_logger.debug("Adding default egress firewall rule for network " + netId);
+                            try (PreparedStatement insert_pstmt =
+                                         conn.prepareStatement("INSERT INTO firewall_rules (uuid, state, protocol, purpose, account_id, domain_id, network_id, xid, created,  traffic_type) VALUES (?, 'Active', 'all', 'Firewall', ?, ?, ?, ?, now(), 'Egress')");) {
+                                insert_pstmt.setString(1, UUID.randomUUID().toString());
+                                insert_pstmt.setLong(2, accountId);
+                                insert_pstmt.setLong(3, domainId);
+                                insert_pstmt.setLong(4, netId);
+                                insert_pstmt.setString(5, UUID.randomUUID().toString());
+                                s_logger.debug("Inserting default egress firewall rule " + insert_pstmt);
+                                insert_pstmt.executeUpdate();
+                            } catch (SQLException e) {
+                                throw new CloudRuntimeException("Unable to set egress firewall rules ", e);
+                            }
+                            try (PreparedStatement sel_firewall_pstmt = conn.prepareStatement("select id from firewall_rules where protocol='all' and network_id=?");) {
+                                sel_firewall_pstmt.setLong(1, netId);
+                                try (ResultSet rsId = sel_firewall_pstmt.executeQuery();) {
+                                    long firewallRuleId;
+                                    if (rsId.next()) {
+                                        firewallRuleId = rsId.getLong(1);
+                                        try (PreparedStatement insert_pstmt = conn.prepareStatement("insert into firewall_rules_cidrs (firewall_rule_id,source_cidr) values (?, '0.0.0.0/0')");) {
+                                            insert_pstmt.setLong(1, firewallRuleId);
+                                            s_logger.debug("Inserting rule for cidr 0.0.0.0/0 for the new Firewall rule id=" + firewallRuleId + " with statement " + insert_pstmt);
+                                            insert_pstmt.executeUpdate();
+                                        } catch (SQLException e) {
+                                            throw new CloudRuntimeException("Unable to set egress firewall rules ", e);
+                                        }
+                                    }
+                                } catch (SQLException e) {
+                                    throw new CloudRuntimeException("Unable to set egress firewall rules ", e);
+                                }
+                            } catch (SQLException e) {
+                                throw new CloudRuntimeException("Unable to set egress firewall rules ", e);
+                            }
+                        }
                     }
                 }
             }
         } catch (SQLException e) {
             throw new CloudRuntimeException("Unable to set egress firewall rules ", e);
-        } finally {
-            try {
-                if (rs != null) {
-                    rs.close();
-                }
-                if (pstmt != null) {
-                    pstmt.close();
-                }
-            } catch (SQLException e) {
-            }
         }
     }
 
     private void upgradeEIPNetworkOfferings(Connection conn) {
-
-        PreparedStatement pstmt = null;
-        ResultSet rs = null;
-
-        try {
-            pstmt = conn.prepareStatement("select id, elastic_ip_service from `cloud`.`network_offerings` where traffic_type='Guest'");
-            rs = pstmt.executeQuery();
-            while (rs.next()) {
-                long id = rs.getLong(1);
-                // check if elastic IP service is enabled for network offering
-                if (rs.getLong(2) != 0) {
-                    //update network offering with eip_associate_public_ip set to true
-                    pstmt = conn.prepareStatement("UPDATE `cloud`.`network_offerings` set eip_associate_public_ip=? where id=?");
-                    pstmt.setBoolean(1, true);
-                    pstmt.setLong(2, id);
-                    pstmt.executeUpdate();
+        try (PreparedStatement pstmt = conn.prepareStatement("select id, elastic_ip_service from `cloud`.`network_offerings` where traffic_type='Guest'");)
+        {
+            try(ResultSet rs = pstmt.executeQuery();) {
+                while (rs.next()) {
+                    long id = rs.getLong(1);
+                    // check if elastic IP service is enabled for network offering
+                    if (rs.getLong(2) != 0) {
+                        //update network offering with eip_associate_public_ip set to true
+                        try(PreparedStatement update_pstmt = conn.prepareStatement("UPDATE `cloud`.`network_offerings` set eip_associate_public_ip=? where id=?");) {
+                            update_pstmt.setBoolean(1, true);
+                            update_pstmt.setLong(2, id);
+                            update_pstmt.executeUpdate();
+                        }catch (SQLException e) {
+                            throw new CloudRuntimeException("Unable to set elastic_ip_service for network offerings with EIP service enabled.", e);
+                        }
+                    }
                 }
+            }catch (SQLException e) {
+                throw new CloudRuntimeException("Unable to set elastic_ip_service for network offerings with EIP service enabled.", e);
             }
         } catch (SQLException e) {
             throw new CloudRuntimeException("Unable to set elastic_ip_service for network offerings with EIP service enabled.", e);
@@ -1399,106 +1207,29 @@ public class Upgrade410to420 implements DbUpgrade {
                 }
                 if (!hasAcls) {
                     //no network ACls for this network.
-                    // Assign default Deny ACL
-                    aclId = NetworkACL.DEFAULT_DENY;
-                }
-                //Assign acl to network
-                pstmt = conn.prepareStatement("UPDATE `cloud`.`networks` set network_acl_id=? where id=?");
-                pstmt.setLong(1, aclId);
-                pstmt.setLong(2, networkId);
-                pstmt.executeUpdate();
-            }
-            s_logger.debug("Done updating network ACLs ");
-        } catch (SQLException e) {
-            throw new CloudRuntimeException("Unable to move network acls from firewall rules table to network_acl_item table", e);
-        } finally {
-            try {
-                if (rs != null) {
-                    rs.close();
-                }
-                if (rsAcls != null) {
-                    rsAcls.close();
-                }
-                if (rsCidr != null) {
-                    rsCidr.close();
-                }
-                if (pstmt != null) {
-                    pstmt.close();
-                }
-            } catch (SQLException e) {
-            }
-        }
-    }
-
-    private void updateGlobalDeploymentPlanner(Connection conn) {
-        PreparedStatement pstmt = null;
-        ResultSet rs = null;
-
-        try {
-            pstmt = conn.prepareStatement("select value from `cloud`.`configuration` where name = 'vm.allocation.algorithm'");
-            rs = pstmt.executeQuery();
-            while (rs.next()) {
-                String globalValue = rs.getString(1);
-                String plannerName = "FirstFitPlanner";
-
-                if (globalValue != null) {
-                    if (globalValue.equals(DeploymentPlanner.AllocationAlgorithm.random.toString())) {
-                        plannerName = "FirstFitPlanner";
-                    } else if (globalValue.equals(DeploymentPlanner.AllocationAlgorithm.firstfit.toString())) {
-                        plannerName = "FirstFitPlanner";
-                    } else if (globalValue.equals(DeploymentPlanner.AllocationAlgorithm.userconcentratedpod_firstfit.toString())) {
-                        plannerName = "UserConcentratedPodPlanner";
-                    } else if (globalValue.equals(DeploymentPlanner.AllocationAlgorithm.userconcentratedpod_random.toString())) {
-                        plannerName = "UserConcentratedPodPlanner";
-                    } else if (globalValue.equals(DeploymentPlanner.AllocationAlgorithm.userdispersing.toString())) {
-                        plannerName = "UserDispersingPlanner";
-                    }
-                }
-                // update vm.deployment.planner global config
-                pstmt = conn.prepareStatement("UPDATE `cloud`.`configuration` set value=? where name = 'vm.deployment.planner'");
-                pstmt.setString(1, plannerName);
-                pstmt.executeUpdate();
-            }
-        } catch (SQLException e) {
-            throw new CloudRuntimeException("Unable to set vm.deployment.planner global config", e);
-        } finally {
-            try {
-                if (rs != null) {
-                    rs.close();
-                }
-                if (pstmt != null) {
-                    pstmt.close();
-                }
-            } catch (SQLException e) {
-            }
-        }
-    }
-
-    private void upgradeDefaultVpcOffering(Connection conn) {
-        PreparedStatement pstmt = null;
-        ResultSet rs = null;
-
-        try {
-            pstmt =
-                    conn.prepareStatement("select distinct map.vpc_offering_id from `cloud`.`vpc_offering_service_map` map, `cloud`.`vpc_offerings` off where off.id=map.vpc_offering_id AND service='Lb'");
-            rs = pstmt.executeQuery();
-            while (rs.next()) {
-                long id = rs.getLong(1);
-                //Add internal LB vm as a supported provider for the load balancer service
-                pstmt = conn.prepareStatement("INSERT INTO `cloud`.`vpc_offering_service_map` (vpc_offering_id, service, provider) VALUES (?,?,?)");
-                pstmt.setLong(1, id);
-                pstmt.setString(2, "Lb");
-                pstmt.setString(3, "InternalLbVm");
+                    // Assign default Deny ACL
+                    aclId = NetworkACL.DEFAULT_DENY;
+                }
+                //Assign acl to network
+                pstmt = conn.prepareStatement("UPDATE `cloud`.`networks` set network_acl_id=? where id=?");
+                pstmt.setLong(1, aclId);
+                pstmt.setLong(2, networkId);
                 pstmt.executeUpdate();
             }
-
+            s_logger.debug("Done updating network ACLs ");
         } catch (SQLException e) {
-            throw new CloudRuntimeException("Unable update the default VPC offering with the internal lb service", e);
+            throw new CloudRuntimeException("Unable to move network acls from firewall rules table to network_acl_item table", e);
         } finally {
             try {
                 if (rs != null) {
                     rs.close();
                 }
+                if (rsAcls != null) {
+                    rsAcls.close();
+                }
+                if (rsCidr != null) {
+                    rsCidr.close();
+                }
                 if (pstmt != null) {
                     pstmt.close();
                 }
@@ -1507,106 +1238,156 @@ public class Upgrade410to420 implements DbUpgrade {
         }
     }
 
-    private void upgradePhysicalNtwksWithInternalLbProvider(Connection conn) {
-
-        PreparedStatement pstmt = null;
-        ResultSet rs = null;
-
-        try {
-            pstmt = conn.prepareStatement("SELECT id FROM `cloud`.`physical_network` where removed is null");
-            rs = pstmt.executeQuery();
-            while (rs.next()) {
-                long pNtwkId = rs.getLong(1);
-                String uuid = UUID.randomUUID().toString();
-                //Add internal LB VM to the list of physical network service providers
-                pstmt =
-                        conn.prepareStatement("INSERT INTO `cloud`.`physical_network_service_providers` "
-                                + "(uuid, physical_network_id, provider_name, state, load_balance_service_provided, destination_physical_network_id)"
-                                + " VALUES (?, ?, 'InternalLbVm', 'Enabled', 1, 0)");
-                pstmt.setString(1, uuid);
-                pstmt.setLong(2, pNtwkId);
-           

<TRUNCATED>

[49/50] [abbrv] git commit: updated refs/heads/baremetal-systemvm to 23482b1

Posted by ki...@apache.org.
CLOUDSTACK-7660: Enhance system vm template to support baremetal Installed Package flask and merged the disk partition


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

Branch: refs/heads/baremetal-systemvm
Commit: 14c820ae02dceb94b6c61deb79694be77253b52a
Parents: a72580d
Author: Harikrishna Patnala <ha...@citrix.com>
Authored: Tue Oct 21 18:31:48 2014 +0530
Committer: Kishan Kavala <ki...@apache.org>
Committed: Tue Oct 21 20:06:34 2014 +0530

----------------------------------------------------------------------
 systemvm/patches/debian/buildsystemvm.sh        |  5 +++
 .../definitions/systemvmtemplate/preseed.cfg    | 41 --------------------
 2 files changed, 5 insertions(+), 41 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/14c820ae/systemvm/patches/debian/buildsystemvm.sh
----------------------------------------------------------------------
diff --git a/systemvm/patches/debian/buildsystemvm.sh b/systemvm/patches/debian/buildsystemvm.sh
index 7f6188a..f56ca1e 100755
--- a/systemvm/patches/debian/buildsystemvm.sh
+++ b/systemvm/patches/debian/buildsystemvm.sh
@@ -382,6 +382,11 @@ packages() {
 
   echo "***** getting jre 7 *********"
   chroot .  apt-get --no-install-recommends -q -y install openjdk-7-jre-headless
+
+  chroot . apt-get --no-install-recommends -q -y install python-dev python-pip libpcre3-dev
+
+  # Baremetal tools
+  chroot . pip install flask
 }
 
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/14c820ae/tools/appliance/definitions/systemvmtemplate/preseed.cfg
----------------------------------------------------------------------
diff --git a/tools/appliance/definitions/systemvmtemplate/preseed.cfg b/tools/appliance/definitions/systemvmtemplate/preseed.cfg
index 0d2f70b..832a296 100644
--- a/tools/appliance/definitions/systemvmtemplate/preseed.cfg
+++ b/tools/appliance/definitions/systemvmtemplate/preseed.cfg
@@ -42,47 +42,6 @@ d-i clock-setup/ntp boolean true
 d-i partman-auto/disk string /dev/sda
 d-i partman-auto/method string regular
 d-i partman-auto/choose_recipe select atomic
-d-i partman-auto/expert_recipe string                         \
-      boot-root ::                                            \
-              30 50 100 ext4                                  \
-                      $primary{ } $bootable{ }                \
-                      method{ format } format{ }              \
-                      use_filesystem{ } filesystem{ ext4 }    \
-                      mountpoint{ /boot }                     \
-              .                                               \
-              400 40 500 ext4                                 \
-                      method{ format } format{ }              \
-                      use_filesystem{ } filesystem{ ext4 }    \
-                      mountpoint{ / }                         \
-              .                                               \
-              50 100 200 ext4                                 \
-                      method{ format } format{ }              \
-                      use_filesystem{ } filesystem{ ext4 }    \
-                      mountpoint{ /home }                     \
-              .                                               \
-              700 70 1100 ext4                                \
-                      method{ format } format{ }              \
-                      use_filesystem{ } filesystem{ ext4 }    \
-                      mountpoint{ /usr }                      \
-              .                                               \
-              400 40 500 ext4                                 \
-                      method{ format } format{ }              \
-                      use_filesystem{ } filesystem{ ext4 }    \
-                      mountpoint{ /opt }                      \
-              .                                               \
-              450 70 1000 ext4                                \
-                      method{ format } format{ }              \
-                      use_filesystem{ } filesystem{ ext4 }    \
-                      mountpoint{ /var }                      \
-              .                                               \
-              50 60 100 ext4                                  \
-                      method{ format } format{ }              \
-                      use_filesystem{ } filesystem{ ext4 }    \
-                      mountpoint{ /tmp }                      \
-              .                                               \
-              70 100 256 linux-swap                           \
-                      method{ swap } format{ }                \
-              .
 d-i partman/confirm_write_new_label boolean true
 d-i partman/choose_partition select finish
 d-i partman/confirm boolean true


[42/50] [abbrv] git commit: updated refs/heads/baremetal-systemvm to 23482b1

Posted by ki...@apache.org.
CLOUDSTACK-7744: UI > Instances > detailView > Change Service Offering > show generic notification.


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

Branch: refs/heads/baremetal-systemvm
Commit: c10f8a10efdbf479f2b8c9784d4976e3100b3cde
Parents: 6239447
Author: Jessica Wang <je...@apache.org>
Authored: Thu Oct 16 14:47:24 2014 -0700
Committer: Jessica Wang <je...@apache.org>
Committed: Thu Oct 16 14:50:04 2014 -0700

----------------------------------------------------------------------
 ui/scripts/instances.js | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c10f8a10/ui/scripts/instances.js
----------------------------------------------------------------------
diff --git a/ui/scripts/instances.js b/ui/scripts/instances.js
index 7653a18..e95ce12 100644
--- a/ui/scripts/instances.js
+++ b/ui/scripts/instances.js
@@ -1580,11 +1580,8 @@
                             });
                         },
                         messages: {
-                            confirm: function(args) {
-                                return 'message.instance.scaled.up.confirm';
-                            },
                             notification: function(args) {
-                                return 'label.instance.scaled.up';
+                                return 'label.change.service.offering';  //CLOUDSTACK-7744
                             }
                         },
                         notification: {


[38/50] [abbrv] git commit: updated refs/heads/baremetal-systemvm to 23482b1

Posted by ki...@apache.org.
CLOUDSTACK-7731: UI > Infrastructure > Virtual Routers > group by account view > listView > detailView > add View All link (i.e. "View all Virtual Routers").


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

Branch: refs/heads/baremetal-systemvm
Commit: 8fb7cfae0ce3d4908ad1d1da9072a2ed6585e68f
Parents: 314a7fe
Author: Jessica Wang <je...@apache.org>
Authored: Wed Oct 15 16:12:52 2014 -0700
Committer: Jessica Wang <je...@apache.org>
Committed: Thu Oct 16 12:33:49 2014 -0700

----------------------------------------------------------------------
 ui/scripts/system.js | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8fb7cfae/ui/scripts/system.js
----------------------------------------------------------------------
diff --git a/ui/scripts/system.js b/ui/scripts/system.js
index fbd2f2b..f87de62 100644
--- a/ui/scripts/system.js
+++ b/ui/scripts/system.js
@@ -9484,7 +9484,18 @@
                                  * Therefore, we only call the second listRouters API(with projectid=-1) in non-project view.
                                  */   
                                 if (cloudStack.context && cloudStack.context.projects == null) { //non-project view
-                                        $.ajax({
+                                    /* 
+                                     * account parameter(account+domainid) and project parameter(projectid) are not allowed to be passed together to listXXXXXXX API. 
+                                     * So, remove account parameter(account+domainid) from data2
+                                     */                                    	
+                                	if ("account" in data2) {
+                                		delete data2.account;
+                                	}
+                                	if ("domainid" in data2) {
+                                		delete data2.domainid;
+                                	}                                	
+                                	
+                                	$.ajax({
                                             url: createURL("listRouters&listAll=true&page=" + args.page + "&pagesize=" + pageSize + array1.join("") + "&projectid=-1"),
                                             data: data2,
 	                                    async: false,
@@ -10565,13 +10576,11 @@
                                 });
                             },
                             detailView: {
-                                name: 'label.virtual.routers.group.account',
-                                /*
+                                name: 'label.virtual.routers.group.account',                                
                                 viewAll: {
                                     path: '_zone.virtualRouters',
                                     label: 'label.virtual.appliances'
-                                },
-                                */
+                                },                               
                                 actions: {
                                     upgradeRouterToUseNewerTemplate: {
                                         label: 'label.upgrade.router.newer.template',


[04/50] [abbrv] git commit: updated refs/heads/baremetal-systemvm to 23482b1

Posted by ki...@apache.org.
Adding a snapshot strategy for systems that want to take snapshots that reside on their own system (as opposed to the default approach of taking a hypervisor snapshot and then copying it to secondary storage)


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

Branch: refs/heads/baremetal-systemvm
Commit: 35a8b70799129f483fc4f3cdc76cb6e055cee90e
Parents: 4b8bfe2
Author: Mike Tutkowski <mi...@solidfire.com>
Authored: Mon Oct 13 15:48:08 2014 -0600
Committer: Mike Tutkowski <mi...@solidfire.com>
Committed: Tue Oct 14 12:26:40 2014 -0600

----------------------------------------------------------------------
 .../api/storage/DataStoreCapabilities.java      |   3 +-
 ...-engine-storage-snapshot-storage-context.xml |   3 +
 .../snapshot/StorageSystemSnapshotStrategy.java | 208 +++++++++++++++++++
 .../driver/SolidFirePrimaryDataStoreDriver.java |  35 ++--
 .../storage/snapshot/SnapshotManagerImpl.java   |  24 ++-
 5 files changed, 248 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/35a8b707/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataStoreCapabilities.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataStoreCapabilities.java b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataStoreCapabilities.java
index 25c66cd..09883c6 100644
--- a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataStoreCapabilities.java
+++ b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/DataStoreCapabilities.java
@@ -19,5 +19,6 @@
 package org.apache.cloudstack.engine.subsystem.api.storage;
 
 public enum DataStoreCapabilities {
-    VOLUME_SNAPSHOT_QUIESCEVM
+    VOLUME_SNAPSHOT_QUIESCEVM,
+    STORAGE_SYSTEM_SNAPSHOT // indicates to the StorageSystemSnapshotStrategy that this driver takes snapshots on its own system
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/35a8b707/engine/storage/snapshot/resources/META-INF/cloudstack/storage/spring-engine-storage-snapshot-storage-context.xml
----------------------------------------------------------------------
diff --git a/engine/storage/snapshot/resources/META-INF/cloudstack/storage/spring-engine-storage-snapshot-storage-context.xml b/engine/storage/snapshot/resources/META-INF/cloudstack/storage/spring-engine-storage-snapshot-storage-context.xml
index 7299750..de8d11e 100644
--- a/engine/storage/snapshot/resources/META-INF/cloudstack/storage/spring-engine-storage-snapshot-storage-context.xml
+++ b/engine/storage/snapshot/resources/META-INF/cloudstack/storage/spring-engine-storage-snapshot-storage-context.xml
@@ -30,6 +30,9 @@
     <bean id="xenserverSnapshotStrategy"
         class="org.apache.cloudstack.storage.snapshot.XenserverSnapshotStrategy" />
 
+    <bean id="storageSystemSnapshotStrategy"
+        class="org.apache.cloudstack.storage.snapshot.StorageSystemSnapshotStrategy" />
+
     <bean id="DefaultVMSnapshotStrategy"
         class="org.apache.cloudstack.storage.vmsnapshot.DefaultVMSnapshotStrategy" />
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/35a8b707/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/StorageSystemSnapshotStrategy.java
----------------------------------------------------------------------
diff --git a/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/StorageSystemSnapshotStrategy.java b/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/StorageSystemSnapshotStrategy.java
new file mode 100644
index 0000000..894aa5a
--- /dev/null
+++ b/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/StorageSystemSnapshotStrategy.java
@@ -0,0 +1,208 @@
+// 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.
+package org.apache.cloudstack.storage.snapshot;
+
+import java.util.Map;
+
+import javax.inject.Inject;
+
+import org.apache.log4j.Logger;
+import org.springframework.stereotype.Component;
+import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
+import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreCapabilities;
+import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager;
+import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotDataFactory;
+import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotInfo;
+import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotResult;
+import org.apache.cloudstack.engine.subsystem.api.storage.StrategyPriority;
+import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
+import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
+import org.apache.cloudstack.storage.datastore.db.SnapshotDataStoreDao;
+
+import com.cloud.exception.InvalidParameterValueException;
+import com.cloud.storage.DataStoreRole;
+import com.cloud.storage.Snapshot;
+import com.cloud.storage.SnapshotVO;
+import com.cloud.storage.Volume;
+import com.cloud.storage.VolumeVO;
+import com.cloud.storage.dao.SnapshotDao;
+import com.cloud.storage.dao.VolumeDao;
+import com.cloud.utils.db.DB;
+import com.cloud.utils.exception.CloudRuntimeException;
+import com.cloud.utils.fsm.NoTransitionException;
+
+@Component
+public class StorageSystemSnapshotStrategy extends SnapshotStrategyBase {
+    private static final Logger s_logger = Logger.getLogger(StorageSystemSnapshotStrategy.class);
+
+    @Inject private DataStoreManager _dataStoreMgr;
+    @Inject private SnapshotDao _snapshotDao;
+    @Inject private SnapshotDataFactory _snapshotDataFactory;
+    @Inject private SnapshotDataStoreDao _snapshotStoreDao;
+    @Inject private PrimaryDataStoreDao _storagePoolDao;
+    @Inject private VolumeDao _volumeDao;
+
+    @Override
+    public SnapshotInfo backupSnapshot(SnapshotInfo snapshotInfo) {
+        return snapshotInfo;
+    }
+
+    @Override
+    public boolean deleteSnapshot(Long snapshotId) {
+        SnapshotVO snapshotVO = _snapshotDao.findById(snapshotId);
+
+        if (Snapshot.State.Destroyed.equals(snapshotVO.getState())) {
+            return true;
+        }
+
+        if (Snapshot.State.Error.equals(snapshotVO.getState())) {
+            _snapshotDao.remove(snapshotId);
+
+            return true;
+        }
+
+        if (!Snapshot.State.BackedUp.equals(snapshotVO.getState())) {
+            throw new InvalidParameterValueException("Unable to delete snapshotshot " + snapshotId + " because it is in the following state: " + snapshotVO.getState());
+        }
+
+        SnapshotObject snapshotObj = (SnapshotObject)_snapshotDataFactory.getSnapshot(snapshotId, DataStoreRole.Primary);
+
+        if (snapshotObj == null) {
+            s_logger.debug("Can't find snapshot; deleting it in DB");
+
+            _snapshotDao.remove(snapshotId);
+
+            return true;
+        }
+
+        try {
+            snapshotObj.processEvent(Snapshot.Event.DestroyRequested);
+        }
+        catch (NoTransitionException e) {
+            s_logger.debug("Failed to set the state to destroying: ", e);
+
+            return false;
+        }
+
+        try {
+            snapshotSvr.deleteSnapshot(snapshotObj);
+
+            snapshotObj.processEvent(Snapshot.Event.OperationSucceeded);
+        }
+        catch (Exception e) {
+            s_logger.debug("Failed to delete snapshot: ", e);
+
+            try {
+                snapshotObj.processEvent(Snapshot.Event.OperationFailed);
+            }
+            catch (NoTransitionException e1) {
+                s_logger.debug("Failed to change snapshot state: " + e.toString());
+            }
+
+            return false;
+        }
+
+        return true;
+    }
+
+    @Override
+    public boolean revertSnapshot(Long snapshotId) {
+        return true;
+    }
+
+    @Override
+    @DB
+    public SnapshotInfo takeSnapshot(SnapshotInfo snapshotInfo) {
+        SnapshotVO snapshotVO = _snapshotDao.acquireInLockTable(snapshotInfo.getId());
+
+        if (snapshotVO == null) {
+            throw new CloudRuntimeException("Failed to acquire lock on the following snapshot: " + snapshotInfo.getId());
+        }
+
+        try {
+            VolumeInfo volumeInfo = snapshotInfo.getBaseVolume();
+
+            volumeInfo.stateTransit(Volume.Event.SnapshotRequested);
+
+            SnapshotResult result = null;
+
+            try {
+                result = snapshotSvr.takeSnapshot(snapshotInfo);
+
+                if (result.isFailed()) {
+                    s_logger.debug("Failed to take the following snapshot: " + result.getResult());
+
+                    throw new CloudRuntimeException(result.getResult());
+                }
+
+                markAsBackedUp((SnapshotObject)result.getSnashot());
+            }
+            finally {
+                if (result != null && result.isSuccess()) {
+                    volumeInfo.stateTransit(Volume.Event.OperationSucceeded);
+                }
+                else {
+                    volumeInfo.stateTransit(Volume.Event.OperationFailed);
+                }
+            }
+        }
+        finally {
+            if (snapshotVO != null) {
+                _snapshotDao.releaseFromLockTable(snapshotInfo.getId());
+            }
+        }
+
+        return snapshotInfo;
+    }
+
+    private void markAsBackedUp(SnapshotObject snapshotObj) {
+        try {
+            snapshotObj.processEvent(Snapshot.Event.BackupToSecondary);
+            snapshotObj.processEvent(Snapshot.Event.OperationSucceeded);
+        }
+        catch (NoTransitionException ex) {
+            s_logger.debug("Failed to change state: " + ex.toString());
+
+            try {
+                snapshotObj.processEvent(Snapshot.Event.OperationFailed);
+            }
+            catch (NoTransitionException ex2) {
+                s_logger.debug("Failed to change state: " + ex2.toString());
+            }
+        }
+    }
+
+    @Override
+    public StrategyPriority canHandle(Snapshot snapshot, SnapshotOperation op) {
+        long volumeId = snapshot.getVolumeId();
+        VolumeVO volume = _volumeDao.findById(volumeId);
+
+        long storagePoolId = volume.getPoolId();
+        DataStore dataStore = _dataStoreMgr.getDataStore(storagePoolId, DataStoreRole.Primary);
+
+        Map<String, String> mapCapabilities = dataStore.getDriver().getCapabilities();
+
+        String value = mapCapabilities.get(DataStoreCapabilities.STORAGE_SYSTEM_SNAPSHOT.toString());
+        Boolean supportsStorageSystemSnapshots = new Boolean(value);
+
+        if (supportsStorageSystemSnapshots) {
+            return StrategyPriority.HIGHEST;
+        }
+
+        return StrategyPriority.CANT_HANDLE;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/35a8b707/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/driver/SolidFirePrimaryDataStoreDriver.java
----------------------------------------------------------------------
diff --git a/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/driver/SolidFirePrimaryDataStoreDriver.java b/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/driver/SolidFirePrimaryDataStoreDriver.java
index e966cf6..946dd18 100644
--- a/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/driver/SolidFirePrimaryDataStoreDriver.java
+++ b/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/driver/SolidFirePrimaryDataStoreDriver.java
@@ -17,6 +17,7 @@
 package org.apache.cloudstack.storage.datastore.driver;
 
 import java.text.NumberFormat;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
@@ -25,6 +26,7 @@ import javax.inject.Inject;
 import org.apache.cloudstack.engine.subsystem.api.storage.ChapInfo;
 import org.apache.cloudstack.engine.subsystem.api.storage.CopyCommandResult;
 import org.apache.cloudstack.engine.subsystem.api.storage.CreateCmdResult;
+import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreCapabilities;
 import org.apache.cloudstack.engine.subsystem.api.storage.DataObject;
 import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
 import org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreDriver;
@@ -32,7 +34,6 @@ import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotInfo;
 import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
 import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
 import org.apache.cloudstack.storage.command.CommandResult;
-import org.apache.cloudstack.storage.command.CopyCmdAnswer;
 import org.apache.cloudstack.storage.command.CreateObjectAnswer;
 import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
 import org.apache.cloudstack.storage.datastore.db.StoragePoolDetailVO;
@@ -90,7 +91,11 @@ public class SolidFirePrimaryDataStoreDriver implements PrimaryDataStoreDriver {
 
     @Override
     public Map<String, String> getCapabilities() {
-        return null;
+        Map<String, String> mapCapabilities = new HashMap<String, String>();
+
+        mapCapabilities.put(DataStoreCapabilities.STORAGE_SYSTEM_SNAPSHOT.toString(), Boolean.TRUE.toString());
+
+        return mapCapabilities;
     }
 
     @Override
@@ -473,28 +478,11 @@ public class SolidFirePrimaryDataStoreDriver implements PrimaryDataStoreDriver {
 
     @Override
     public void copyAsync(DataObject srcData, DataObject destData, AsyncCompletionCallback<CopyCommandResult> callback) {
-        if (srcData.getType() == DataObjectType.SNAPSHOT && destData.getType() == DataObjectType.SNAPSHOT) {
-            // in this situation, we don't want to copy the snapshot anywhere
-
-            CopyCmdAnswer copyCmdAnswer = new CopyCmdAnswer(destData.getTO());
-            CopyCommandResult result = new CopyCommandResult(null, copyCmdAnswer);
-
-            result.setResult(null);
-
-            callback.complete(result);
-
-            return;
-        }
-
         throw new UnsupportedOperationException();
     }
 
     @Override
     public boolean canCopy(DataObject srcData, DataObject destData) {
-        if (srcData.getType() == DataObjectType.SNAPSHOT && destData.getType() == DataObjectType.SNAPSHOT) {
-            return true;
-        }
-
         return false;
     }
 
@@ -595,6 +583,15 @@ public class SolidFirePrimaryDataStoreDriver implements PrimaryDataStoreDriver {
             SolidFireUtil.deleteSolidFireSnapshot(sfConnection, getSolidFireSnapshotId(snapshotInfo.getId()));
 
             _snapshotDetailsDao.removeDetails(snapshotInfo.getId());
+
+            StoragePoolVO storagePool = _storagePoolDao.findById(storagePoolId);
+
+            // getUsedBytes(StoragePool) will not include the snapshot to delete because it has already been deleted by this point
+            long usedBytes = getUsedBytes(storagePool);
+
+            storagePool.setUsedBytes(usedBytes < 0 ? 0 : usedBytes);
+
+            _storagePoolDao.update(storagePoolId, storagePool);
         }
         catch (Exception ex) {
             s_logger.debug(SolidFireUtil.LOG_PREFIX + "Failed to delete SolidFire snapshot: " + snapshotInfo.getId(), ex);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/35a8b707/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java b/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java
index 76ab370..f2126ef 100755
--- a/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java
+++ b/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java
@@ -412,33 +412,47 @@ public class SnapshotManagerImpl extends ManagerBase implements SnapshotManager,
 
         // Verify parameters
         SnapshotVO snapshotCheck = _snapshotDao.findById(snapshotId);
+
         if (snapshotCheck == null) {
             throw new InvalidParameterValueException("unable to find a snapshot with id " + snapshotId);
         }
 
         _accountMgr.checkAccess(caller, null, true, snapshotCheck);
+
         SnapshotStrategy snapshotStrategy = _storageStrategyFactory.getSnapshotStrategy(snapshotCheck, SnapshotOperation.DELETE);
+
         if (snapshotStrategy == null) {
             s_logger.error("Unable to find snaphot strategy to handle snapshot with id '" + snapshotId + "'");
+
             return false;
         }
-        SnapshotDataStoreVO snapshotStoreRef = _snapshotStoreDao.findBySnapshot(snapshotId, DataStoreRole.Image);
 
         try {
             boolean result = snapshotStrategy.deleteSnapshot(snapshotId);
+
             if (result) {
                 if (snapshotCheck.getState() == Snapshot.State.BackedUp) {
                     UsageEventUtils.publishUsageEvent(EventTypes.EVENT_SNAPSHOT_DELETE, snapshotCheck.getAccountId(), snapshotCheck.getDataCenterId(), snapshotId,
                         snapshotCheck.getName(), null, null, 0L, snapshotCheck.getClass().getName(), snapshotCheck.getUuid());
                 }
-                if (snapshotCheck.getState() != Snapshot.State.Error && snapshotCheck.getState() != Snapshot.State.Destroyed)
-                _resourceLimitMgr.decrementResourceCount(snapshotCheck.getAccountId(), ResourceType.snapshot);
-                if (snapshotCheck.getState() == Snapshot.State.BackedUp)
-                    _resourceLimitMgr.decrementResourceCount(snapshotCheck.getAccountId(), ResourceType.secondary_storage, new Long(snapshotStoreRef.getSize()));
+
+                if (snapshotCheck.getState() != Snapshot.State.Error && snapshotCheck.getState() != Snapshot.State.Destroyed) {
+                    _resourceLimitMgr.decrementResourceCount(snapshotCheck.getAccountId(), ResourceType.snapshot);
+                }
+
+                if (snapshotCheck.getState() == Snapshot.State.BackedUp) {
+                    SnapshotDataStoreVO snapshotStoreRef = _snapshotStoreDao.findBySnapshot(snapshotId, DataStoreRole.Image);
+
+                    if (snapshotStoreRef != null) {
+                        _resourceLimitMgr.decrementResourceCount(snapshotCheck.getAccountId(), ResourceType.secondary_storage, new Long(snapshotStoreRef.getSize()));
+                    }
+                }
             }
+
             return result;
         } catch (Exception e) {
             s_logger.debug("Failed to delete snapshot: " + snapshotCheck.getId() + ":" + e.toString());
+
             throw new CloudRuntimeException("Failed to delete snapshot:" + e.toString());
         }
     }


[36/50] [abbrv] git commit: updated refs/heads/baremetal-systemvm to 23482b1

Posted by ki...@apache.org.
PR: #23 Merge 4.5 back into master from 'DaanHoogland/merge-master'

Fixes #23

Signed-off-by: Rohit Yadav <ro...@shapeblue.com>


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

Branch: refs/heads/baremetal-systemvm
Commit: 7072d8d701ceca04857962d3af0a954bdaf7f205
Parents: 20d3cf1 148efbb
Author: Rohit Yadav <ro...@shapeblue.com>
Authored: Thu Oct 16 18:52:11 2014 +0530
Committer: Rohit Yadav <ro...@shapeblue.com>
Committed: Thu Oct 16 18:54:06 2014 +0530

----------------------------------------------------------------------
 api/src/com/cloud/event/EventTypes.java         |   1 -
 .../PrepareKickstartPxeServerCommand.java       |  84 ++++++
 .../core/spring-baremetal-core-context.xml      |   8 +-
 .../baremetal/manager/BaremetalManager.java     |   3 -
 .../baremetal/manager/BaremetalManagerImpl.java |   3 -
 .../baremetal/manager/BaremetalVlanManager.java |   1 -
 .../manager/BaremetalVlanManagerImpl.java       |   7 +-
 .../networkservice/BareMetalResourceBase.java   |  47 +--
 .../BaremetalKickStartPxeResource.java          |   1 +
 .../BaremetalKickStartServiceImpl.java          |  12 +-
 .../networkservice/BaremetalPxeElement.java     |   5 +-
 .../Force10BaremetalSwitchBackend.java          | 116 ++------
 .../PrepareKickstartPxeServerCommand.java       |  83 ------
 .../BaremetalProvisionDoneNotificationCmd.java  |  87 ------
 server/src/com/cloud/configuration/Config.java  |  36 +--
 .../deploy/DeploymentPlanningManagerImpl.java   |  11 +-
 .../VirtualNetworkApplianceManagerImpl.java     |   2 -
 .../com/cloud/resource/ResourceManagerImpl.java |  15 +
 .../com/cloud/storage/VolumeApiServiceImpl.java |  12 +-
 .../cloud/storage/VolumeApiServiceImplTest.java |  24 +-
 .../patches/debian/config/etc/dnsmasq.conf.tmpl |   6 +-
 .../config/opt/cloud/bin/baremetal_snat.sh      |  21 +-
 .../debian/config/opt/cloud/bin/prepare_pxe.sh  |  28 +-
 .../component/test_deploy_vgpu_vm.py            | 291 ++++++++++++++++++-
 .../com/cloud/utils/xmlobject/XmlObject.java    |  15 +-
 .../cloud/utils/xmlobject/XmlObjectParser.java  |  22 +-
 .../cloud/utils/xmlobject/TestXmlObject.java    |   5 -
 27 files changed, 486 insertions(+), 460 deletions(-)
----------------------------------------------------------------------



[03/50] [abbrv] git commit: updated refs/heads/baremetal-systemvm to 23482b1

Posted by ki...@apache.org.
CLOUDSTACK-7563: Fix potential NPE from FingBugs.


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

Branch: refs/heads/baremetal-systemvm
Commit: e7fa3a29594eb748b201865dac3a85f8da024075
Parents: 176e0d4
Author: Min Chen <mi...@citrix.com>
Authored: Tue Oct 14 10:35:29 2014 -0700
Committer: Min Chen <mi...@citrix.com>
Committed: Tue Oct 14 11:21:01 2014 -0700

----------------------------------------------------------------------
 .../src/com/cloud/vm/VirtualMachineManagerImpl.java  | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e7fa3a29/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java b/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java
index fdf5665..0eafe13 100755
--- a/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java
+++ b/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java
@@ -1871,7 +1871,8 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
         try {
             pfma = _agentMgr.send(dstHostId, pfmc);
             if (pfma == null || !pfma.getResult()) {
-                String msg = "Unable to prepare for migration due to " + pfma.getDetails();
+                String details = (pfma != null) ? pfma.getDetails() : "null answer returned";
+                String msg = "Unable to prepare for migration due to " + details;
                 pfma = null;
                 throw new AgentUnavailableException(msg, dstHostId);
             }
@@ -1907,7 +1908,8 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
             try {
                 Answer ma = _agentMgr.send(vm.getLastHostId(), mc);
                 if (ma == null || !ma.getResult()) {
-                    throw new CloudRuntimeException("Unable to migrate due to " + ma.getDetails());
+                    String details = (ma != null) ? ma.getDetails() : "null answer returned";
+                    throw new CloudRuntimeException("Unable to migrate due to " + details);
                 }
             } catch (OperationTimedoutException e) {
                 if (e.isActive()) {
@@ -3261,7 +3263,8 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
         try {
             pfma = _agentMgr.send(dstHostId, pfmc);
             if (pfma == null || !pfma.getResult()) {
-                String msg = "Unable to prepare for migration due to " + pfma.getDetails();
+                String details = (pfma != null) ? pfma.getDetails() : "null answer returned";
+                String msg = "Unable to prepare for migration due to " + details;
                 pfma = null;
                 throw new AgentUnavailableException(msg, dstHostId);
             }
@@ -3294,8 +3297,10 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
             try {
                 Answer ma = _agentMgr.send(vm.getLastHostId(), mc);
                 if (ma == null || !ma.getResult()) {
-                    s_logger.error("Unable to migrate due to " + ma.getDetails());
-                    throw new CloudRuntimeException("Unable to migrate due to " + ma.getDetails());
+                    String details = (ma != null) ? ma.getDetails() : "null answer returned";
+                    String msg = "Unable to migrate due to " + details;
+                    s_logger.error(msg);
+                    throw new CloudRuntimeException(msg);
                 }
             } catch (OperationTimedoutException e) {
                 if (e.isActive()) {


[21/50] [abbrv] git commit: updated refs/heads/baremetal-systemvm to 23482b1

Posted by ki...@apache.org.
CLOUDSTACK-7728: Fixed adding iptables rules for egress allow on VR reboot


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

Branch: refs/heads/baremetal-systemvm
Commit: e257c13f167791c17967ad0d37a545ccbd145efd
Parents: f488a8f
Author: Jayapal <ja...@apache.org>
Authored: Wed Oct 15 17:38:53 2014 +0530
Committer: Jayapal <ja...@apache.org>
Committed: Thu Oct 16 09:38:21 2014 +0530

----------------------------------------------------------------------
 .../VirtualNetworkApplianceManagerImpl.java     | 30 ++++++++++++++++++++
 1 file changed, 30 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e257c13f/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
index 987a556..b67f667 100755
--- a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
+++ b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
@@ -170,11 +170,13 @@ import com.cloud.network.rules.RulesManager;
 import com.cloud.network.rules.StaticNat;
 import com.cloud.network.rules.StaticNatImpl;
 import com.cloud.network.rules.StaticNatRule;
+import com.cloud.network.rules.FirewallRuleVO;
 import com.cloud.network.rules.dao.PortForwardingRulesDao;
 import com.cloud.network.vpn.Site2SiteVpnManager;
 import com.cloud.offering.NetworkOffering;
 import com.cloud.offering.ServiceOffering;
 import com.cloud.offerings.NetworkOfferingVO;
+import com.cloud.offerings.NetworkOfferingVO;
 import com.cloud.offerings.dao.NetworkOfferingDao;
 import com.cloud.resource.ResourceManager;
 import com.cloud.server.ConfigurationServer;
@@ -2651,6 +2653,10 @@ VirtualMachineGuru, Listener, Configurable, StateListener<State, VirtualMachine.
         //  Fetch firewall Egress rules.
         if (_networkModel.isProviderSupportServiceInNetwork(guestNetworkId, Service.Firewall, provider)) {
             firewallRulesEgress.addAll(_rulesDao.listByNetworkPurposeTrafficType(guestNetworkId, Purpose.Firewall, FirewallRule.TrafficType.Egress));
+            if (firewallRulesEgress.isEmpty()) {
+                //create egress default rule for VR
+                createDefaultEgressFirewallRule(firewallRulesEgress, guestNetworkId);
+            }
         }
 
         // Re-apply firewall Egress rules
@@ -2774,6 +2780,30 @@ VirtualMachineGuru, Listener, Configurable, StateListener<State, VirtualMachine.
         }
     }
 
+    private void createDefaultEgressFirewallRule(List<FirewallRule> rules, long networkId) {
+        String systemRule = null;
+
+        Boolean defaultEgressPolicy = false;
+        NetworkVO network = _networkDao.findById(networkId);
+        NetworkOfferingVO offering = _networkOfferingDao.findById(network.getNetworkOfferingId());
+        defaultEgressPolicy = offering.getEgressDefaultPolicy();
+
+
+        // construct rule when egress policy is true. In true case for VR we default allow rule need to be added
+        if (defaultEgressPolicy) {
+            systemRule = String.valueOf(FirewallRule.FirewallRuleType.System);
+
+            List<String> sourceCidr = new ArrayList<String>();
+
+            sourceCidr.add(NetUtils.ALL_CIDRS);
+            FirewallRule rule = new FirewallRuleVO(null, null, null, null, "all", networkId, network.getAccountId(), network.getDomainId(), Purpose.Firewall, sourceCidr,
+                    null, null, null, FirewallRule.TrafficType.Egress, FirewallRule.FirewallRuleType.System);
+
+            rules.add(rule);
+        }
+    }
+
+
     private void removeRevokedIpAliasFromDb(final List<NicIpAliasVO> revokedIpAliasVOs) {
         for (final NicIpAliasVO ipalias : revokedIpAliasVOs) {
             _nicIpAliasDao.expunge(ipalias.getId());


[17/50] [abbrv] git commit: updated refs/heads/baremetal-systemvm to 23482b1

Posted by ki...@apache.org.
CLOUDSTACK-7532: Template status is not shown in UI/API response for non-default account users. Show it if the owner of the template is the caller
(cherry picked from commit 42f628c61c4070f891b16c1a81d2985bcf8b9281)


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

Branch: refs/heads/baremetal-systemvm
Commit: 3b442acdd7977d09de60dfe61eaf6f148df1af4b
Parents: bd9d57e
Author: Nitin Mehta <ni...@citrix.com>
Authored: Wed Oct 15 13:47:08 2014 -0700
Committer: Nitin Mehta <ni...@citrix.com>
Committed: Wed Oct 15 13:58:22 2014 -0700

----------------------------------------------------------------------
 server/src/com/cloud/api/query/dao/TemplateJoinDaoImpl.java | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3b442acd/server/src/com/cloud/api/query/dao/TemplateJoinDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/query/dao/TemplateJoinDaoImpl.java b/server/src/com/cloud/api/query/dao/TemplateJoinDaoImpl.java
index d3e1253..4e33728 100644
--- a/server/src/com/cloud/api/query/dao/TemplateJoinDaoImpl.java
+++ b/server/src/com/cloud/api/query/dao/TemplateJoinDaoImpl.java
@@ -156,8 +156,8 @@ public class TemplateJoinDaoImpl extends GenericDaoBase<TemplateJoinVO, Long> im
         templateResponse.setDomainId(template.getDomainUuid());
         templateResponse.setDomainName(template.getDomainName());
 
-        // If the user is an Admin, add the template download status
-        if (view == ResponseView.Full) {
+        // If the user is an 'Admin' or 'the owner of template', add the template download status
+        if (view == ResponseView.Full ||  template.getAccountId() == CallContext.current().getCallingAccount().getId() ) {
             String templateStatus = getTemplateStatus(template);
             if (templateStatus != null) {
                 templateResponse.setStatus(templateStatus);


[08/50] [abbrv] git commit: updated refs/heads/baremetal-systemvm to 23482b1

Posted by ki...@apache.org.
Implementing snapshot-strategy support for reverting a volume to a snapshot


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

Branch: refs/heads/baremetal-systemvm
Commit: e70dde09c919b4c64566dd84484b67208b2fd321
Parents: 340bcc6
Author: Mike Tutkowski <mi...@solidfire.com>
Authored: Tue Oct 14 17:04:35 2014 -0600
Committer: Mike Tutkowski <mi...@solidfire.com>
Committed: Tue Oct 14 22:04:18 2014 -0600

----------------------------------------------------------------------
 api/src/com/cloud/storage/Volume.java           |  5 ++
 .../snapshot/StorageSystemSnapshotStrategy.java | 85 +++++++++++++++++++-
 .../driver/SolidFirePrimaryDataStoreDriver.java | 27 ++++++-
 .../storage/datastore/util/SolidFireUtil.java   | 43 ++++++++++
 server/src/com/cloud/api/ApiResponseHelper.java | 38 ++++++++-
 5 files changed, 190 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e70dde09/api/src/com/cloud/storage/Volume.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/storage/Volume.java b/api/src/com/cloud/storage/Volume.java
index b67a395..48145a7 100755
--- a/api/src/com/cloud/storage/Volume.java
+++ b/api/src/com/cloud/storage/Volume.java
@@ -38,6 +38,7 @@ public interface Volume extends ControlledEntity, Identity, InternalIdentity, Ba
         Ready("The volume is ready to be used."),
         Migrating("The volume is migrating to other storage pool"),
         Snapshotting("There is a snapshot created on this volume, not backed up to secondary storage yet"),
+        Reverting("Replace the existing volume on a storage system with a snapshot of it"),
         Resizing("The volume is being resized"),
         Expunging("The volume is being expunging"),
         Expunged("The volume is being expunging"),
@@ -85,8 +86,11 @@ public interface Volume extends ControlledEntity, Identity, InternalIdentity, Ba
             s_fsm.addTransition(Expunging, Event.OperationSucceeded, Expunged);
             s_fsm.addTransition(Expunging, Event.OperationFailed, Destroy);
             s_fsm.addTransition(Ready, Event.SnapshotRequested, Snapshotting);
+            s_fsm.addTransition(Ready, Event.RevertRequested, Reverting);
             s_fsm.addTransition(Snapshotting, Event.OperationSucceeded, Ready);
             s_fsm.addTransition(Snapshotting, Event.OperationFailed, Ready);
+            s_fsm.addTransition(Reverting, Event.OperationSucceeded, Ready);
+            s_fsm.addTransition(Reverting, Event.OperationFailed, Ready);
             s_fsm.addTransition(Ready, Event.MigrationRequested, Migrating);
             s_fsm.addTransition(Migrating, Event.OperationSucceeded, Ready);
             s_fsm.addTransition(Migrating, Event.OperationFailed, Ready);
@@ -111,6 +115,7 @@ public interface Volume extends ControlledEntity, Identity, InternalIdentity, Ba
         UploadRequested,
         MigrationRequested,
         SnapshotRequested,
+        RevertRequested,
         DestroyRequested,
         ExpungingRequested,
         ResizeRequested;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e70dde09/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/StorageSystemSnapshotStrategy.java
----------------------------------------------------------------------
diff --git a/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/StorageSystemSnapshotStrategy.java b/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/StorageSystemSnapshotStrategy.java
index 894aa5a..dc43d7d 100644
--- a/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/StorageSystemSnapshotStrategy.java
+++ b/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/StorageSystemSnapshotStrategy.java
@@ -33,23 +33,35 @@ import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
 import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
 import org.apache.cloudstack.storage.datastore.db.SnapshotDataStoreDao;
 
+import com.cloud.dc.ClusterVO;
+import com.cloud.dc.dao.ClusterDao;
 import com.cloud.exception.InvalidParameterValueException;
+import com.cloud.host.HostVO;
+import com.cloud.host.dao.HostDao;
+import com.cloud.hypervisor.Hypervisor.HypervisorType;
 import com.cloud.storage.DataStoreRole;
 import com.cloud.storage.Snapshot;
 import com.cloud.storage.SnapshotVO;
 import com.cloud.storage.Volume;
+import com.cloud.storage.Volume.Type;
 import com.cloud.storage.VolumeVO;
 import com.cloud.storage.dao.SnapshotDao;
 import com.cloud.storage.dao.VolumeDao;
+import com.cloud.uservm.UserVm;
 import com.cloud.utils.db.DB;
+import com.cloud.utils.db.EntityManager;
 import com.cloud.utils.exception.CloudRuntimeException;
 import com.cloud.utils.fsm.NoTransitionException;
+import com.cloud.vm.VirtualMachine.State;
 
 @Component
 public class StorageSystemSnapshotStrategy extends SnapshotStrategyBase {
     private static final Logger s_logger = Logger.getLogger(StorageSystemSnapshotStrategy.class);
 
+    @Inject private ClusterDao _clusterDao;
     @Inject private DataStoreManager _dataStoreMgr;
+    @Inject private EntityManager _entityMgr;
+    @Inject private HostDao _hostDao;
     @Inject private SnapshotDao _snapshotDao;
     @Inject private SnapshotDataFactory _snapshotDataFactory;
     @Inject private SnapshotDataStoreDao _snapshotStoreDao;
@@ -121,6 +133,75 @@ public class StorageSystemSnapshotStrategy extends SnapshotStrategyBase {
 
     @Override
     public boolean revertSnapshot(Long snapshotId) {
+        // verify the following:
+        //  if root disk, the VM cannot be running (don't allow this at all for ESX)
+        //  if data disk, the disk cannot be in the attached state
+
+        SnapshotInfo snapshotInfo = _snapshotDataFactory.getSnapshot(snapshotId, DataStoreRole.Primary);
+        VolumeInfo volumeInfo = snapshotInfo.getBaseVolume();
+        VolumeVO volume = _volumeDao.findById(volumeInfo.getId());
+
+        if (volume.getVolumeType() == Type.DATADISK) {
+            if (volume.getAttached() != null) {
+                throw new CloudRuntimeException("A data disk must be in the detached state in order to perform a revert.");
+            }
+        }
+        else if (volume.getVolumeType() == Type.ROOT) {
+            Long instanceId = volume.getInstanceId();
+            UserVm vm = _entityMgr.findById(UserVm.class, instanceId);
+
+            Long hostId = vm.getHostId();
+            HostVO hostVO = _hostDao.findById(hostId);
+            Long clusterId = hostVO.getClusterId();
+            ClusterVO clusterVO = _clusterDao.findById(clusterId);
+
+            if (clusterVO.getHypervisorType() != HypervisorType.XenServer && clusterVO.getHypervisorType() !=  HypervisorType.KVM) {
+                throw new CloudRuntimeException("Unsupported hypervisor type for root disk revert. Create a template from this disk and use it instead.");
+            }
+
+            if (vm.getState() != State.Stopped) {
+                throw new CloudRuntimeException("A root disk cannot be reverted unless the VM it's attached to is in the stopped state.");
+            }
+        }
+        else {
+            throw new CloudRuntimeException("Unsupported volume type");
+        }
+
+        SnapshotVO snapshotVO = _snapshotDao.acquireInLockTable(snapshotId);
+
+        if (snapshotVO == null) {
+            throw new CloudRuntimeException("Failed to acquire lock on the following snapshot: " + snapshotId);
+        }
+
+        try {
+            volumeInfo.stateTransit(Volume.Event.RevertRequested);
+
+            boolean result = false;
+
+            try {
+                result = snapshotSvr.revertSnapshot(snapshotId);
+            }
+            finally {
+                if (result) {
+                    volumeInfo.stateTransit(Volume.Event.OperationSucceeded);
+                }
+                else {
+                    String msg = "Failed to revert the volume to a snapshot";
+
+                    s_logger.debug(msg);
+
+                    volumeInfo.stateTransit(Volume.Event.OperationFailed);
+
+                    throw new CloudRuntimeException("Failed to revert the volume to a snapshot");
+                }
+            }
+        }
+        finally {
+            if (snapshotVO != null) {
+                _snapshotDao.releaseFromLockTable(snapshotId);
+            }
+        }
+
         return true;
     }
 
@@ -189,9 +270,9 @@ public class StorageSystemSnapshotStrategy extends SnapshotStrategyBase {
     @Override
     public StrategyPriority canHandle(Snapshot snapshot, SnapshotOperation op) {
         long volumeId = snapshot.getVolumeId();
-        VolumeVO volume = _volumeDao.findById(volumeId);
+        VolumeVO volumeVO = _volumeDao.findById(volumeId);
 
-        long storagePoolId = volume.getPoolId();
+        long storagePoolId = volumeVO.getPoolId();
         DataStore dataStore = _dataStoreMgr.getDataStore(storagePoolId, DataStoreRole.Primary);
 
         Map<String, String> mapCapabilities = dataStore.getDriver().getCapabilities();

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e70dde09/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/driver/SolidFirePrimaryDataStoreDriver.java
----------------------------------------------------------------------
diff --git a/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/driver/SolidFirePrimaryDataStoreDriver.java b/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/driver/SolidFirePrimaryDataStoreDriver.java
index 946dd18..04970b7 100644
--- a/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/driver/SolidFirePrimaryDataStoreDriver.java
+++ b/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/driver/SolidFirePrimaryDataStoreDriver.java
@@ -609,8 +609,31 @@ public class SolidFirePrimaryDataStoreDriver implements PrimaryDataStoreDriver {
     }
 
     @Override
-    public void revertSnapshot(SnapshotInfo snapshot, AsyncCompletionCallback<CommandResult> callback) {
-        throw new UnsupportedOperationException();
+    public void revertSnapshot(SnapshotInfo snapshotInfo, AsyncCompletionCallback<CommandResult> callback) {
+        String errMsg = null;
+
+        try {
+            VolumeInfo volumeInfo = snapshotInfo.getBaseVolume();
+
+            long storagePoolId = volumeInfo.getPoolId();
+            long sfVolumeId = Long.parseLong(volumeInfo.getFolder());
+            long sfSnapshotId = getSolidFireSnapshotId(snapshotInfo.getId());
+
+            SolidFireUtil.SolidFireConnection sfConnection = SolidFireUtil.getSolidFireConnection(storagePoolId, _storagePoolDetailsDao);
+
+            SolidFireUtil.rollBackVolumeToSnapshot(sfConnection, sfVolumeId, sfSnapshotId);
+        }
+        catch (Exception ex) {
+            s_logger.debug(SolidFireUtil.LOG_PREFIX + "Failed to take CloudStack snapshot: " + snapshotInfo.getId(), ex);
+
+            errMsg = ex.getMessage();
+        }
+
+        CommandResult result = new CommandResult();
+
+        result.setResult(errMsg);
+
+        callback.complete(result);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e70dde09/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/util/SolidFireUtil.java
----------------------------------------------------------------------
diff --git a/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/util/SolidFireUtil.java b/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/util/SolidFireUtil.java
index 65f3554..786f227 100644
--- a/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/util/SolidFireUtil.java
+++ b/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/util/SolidFireUtil.java
@@ -689,6 +689,20 @@ public class SolidFireUtil {
         executeJsonRpc(sfConnection, strSnapshotToDeleteJson);
     }
 
+    public static void rollBackVolumeToSnapshot(SolidFireConnection sfConnection, long volumeId, long snapshotId) {
+        final Gson gson = new GsonBuilder().create();
+
+        RollbackToInitiate rollbackToInitiate = new RollbackToInitiate(volumeId, snapshotId);
+
+        String strRollbackToInitiateJson = gson.toJson(rollbackToInitiate);
+
+        String strRollbackInitiatedResultJson = executeJsonRpc(sfConnection, strRollbackToInitiateJson);
+
+        RollbackInitiatedResult rollbackInitiatedResult = gson.fromJson(strRollbackInitiatedResultJson, RollbackInitiatedResult.class);
+
+        verifyResult(rollbackInitiatedResult.result, strRollbackInitiatedResultJson, gson);
+    }
+
     public static long createSolidFireClone(SolidFireConnection sfConnection, long lVolumeId, String cloneName) {
         final Gson gson = new GsonBuilder().create();
 
@@ -1294,6 +1308,26 @@ public class SolidFireUtil {
     }
 
     @SuppressWarnings("unused")
+    private static final class RollbackToInitiate {
+        private final String method = "RollbackToSnapshot";
+        private final RollbackToInitiateParams params;
+
+        private RollbackToInitiate(final long lVolumeId, final long lSnapshotId) {
+            params = new RollbackToInitiateParams(lVolumeId, lSnapshotId);
+        }
+
+        private static final class RollbackToInitiateParams {
+            private long volumeID;
+            private long snapshotID;
+
+            private RollbackToInitiateParams(final long lVolumeId, final long lSnapshotId) {
+                volumeID = lVolumeId;
+                snapshotID = lSnapshotId;
+            }
+        }
+    }
+
+    @SuppressWarnings("unused")
     private static final class CloneToCreate {
         private final String method = "CloneVolume";
         private final CloneToCreateParams params;
@@ -1539,6 +1573,15 @@ public class SolidFireUtil {
         }
     }
 
+    @SuppressWarnings("unused")
+    private static final class RollbackInitiatedResult {
+        private Result result;
+
+        private static final class Result {
+            private long snapshotID;
+        }
+    }
+
     private static final class CloneCreateResult {
         private Result result;
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/e70dde09/server/src/com/cloud/api/ApiResponseHelper.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/ApiResponseHelper.java b/server/src/com/cloud/api/ApiResponseHelper.java
index f4d0293..50376d2 100755
--- a/server/src/com/cloud/api/ApiResponseHelper.java
+++ b/server/src/com/cloud/api/ApiResponseHelper.java
@@ -138,6 +138,9 @@ import org.apache.cloudstack.api.response.VpnUsersResponse;
 import org.apache.cloudstack.api.response.ZoneResponse;
 import org.apache.cloudstack.config.Configuration;
 import org.apache.cloudstack.context.CallContext;
+import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
+import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreCapabilities;
+import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager;
 import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotDataFactory;
 import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotInfo;
 import org.apache.cloudstack.framework.jobs.AsyncJob;
@@ -278,6 +281,7 @@ import com.cloud.storage.UploadVO;
 import com.cloud.storage.VMTemplateVO;
 import com.cloud.storage.Volume;
 import com.cloud.storage.VolumeVO;
+import com.cloud.storage.dao.VolumeDao;
 import com.cloud.storage.snapshot.SnapshotPolicy;
 import com.cloud.storage.snapshot.SnapshotSchedule;
 import com.cloud.template.VirtualMachineTemplate;
@@ -307,13 +311,13 @@ public class ApiResponseHelper implements ResponseGenerator {
 
     private static final Logger s_logger = Logger.getLogger(ApiResponseHelper.class);
     private static final DecimalFormat s_percentFormat = new DecimalFormat("##.##");
+
     @Inject
     private EntityManager _entityMgr;
     @Inject
     private UsageService _usageSvc;
     @Inject
     NetworkModel _ntwkModel;
-
     @Inject
     protected AccountManager _accountMgr;
     @Inject
@@ -322,6 +326,10 @@ public class ApiResponseHelper implements ResponseGenerator {
     ConfigurationManager _configMgr;
     @Inject
     SnapshotDataFactory snapshotfactory;
+    @Inject
+    private VolumeDao _volumeDao;
+    @Inject
+    private DataStoreManager _dataStoreMgr;
 
     @Override
     public UserResponse createUserResponse(User user) {
@@ -459,10 +467,13 @@ public class ApiResponseHelper implements ResponseGenerator {
         snapshotResponse.setState(snapshot.getState());
 
         SnapshotInfo snapshotInfo = null;
-        if (!(snapshot instanceof SnapshotInfo)) {
-            snapshotInfo = snapshotfactory.getSnapshot(snapshot.getId(), DataStoreRole.Image);
-        } else {
+
+        if (snapshot instanceof SnapshotInfo) {
             snapshotInfo = (SnapshotInfo)snapshot;
+        } else {
+            DataStoreRole dataStoreRole = getDataStoreRole(snapshot);
+
+            snapshotInfo = snapshotfactory.getSnapshot(snapshot.getId(), dataStoreRole);
         }
 
         if (snapshotInfo == null) {
@@ -485,6 +496,25 @@ public class ApiResponseHelper implements ResponseGenerator {
         return snapshotResponse;
     }
 
+    private DataStoreRole getDataStoreRole(Snapshot snapshot) {
+        long volumeId = snapshot.getVolumeId();
+        VolumeVO volumeVO = _volumeDao.findById(volumeId);
+
+        long storagePoolId = volumeVO.getPoolId();
+        DataStore dataStore = _dataStoreMgr.getDataStore(storagePoolId, DataStoreRole.Primary);
+
+        Map<String, String> mapCapabilities = dataStore.getDriver().getCapabilities();
+
+        String value = mapCapabilities.get(DataStoreCapabilities.STORAGE_SYSTEM_SNAPSHOT.toString());
+        Boolean supportsStorageSystemSnapshots = new Boolean(value);
+
+        if (supportsStorageSystemSnapshots) {
+            return DataStoreRole.Primary;
+        }
+
+        return DataStoreRole.Image;
+    }
+
     @Override
     public VMSnapshotResponse createVMSnapshotResponse(VMSnapshot vmSnapshot) {
         VMSnapshotResponse vmSnapshotResponse = new VMSnapshotResponse();


[16/50] [abbrv] git commit: updated refs/heads/baremetal-systemvm to 23482b1

Posted by ki...@apache.org.
CLOUDSTACK-7532: Template status is not shown in UI/API response for non-default account users. Show it if the owner of the template is the caller


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

Branch: refs/heads/baremetal-systemvm
Commit: 42f628c61c4070f891b16c1a81d2985bcf8b9281
Parents: ac820a3
Author: Nitin Mehta <ni...@citrix.com>
Authored: Wed Oct 15 13:47:08 2014 -0700
Committer: Nitin Mehta <ni...@citrix.com>
Committed: Wed Oct 15 13:53:39 2014 -0700

----------------------------------------------------------------------
 server/src/com/cloud/api/query/dao/TemplateJoinDaoImpl.java | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/42f628c6/server/src/com/cloud/api/query/dao/TemplateJoinDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/query/dao/TemplateJoinDaoImpl.java b/server/src/com/cloud/api/query/dao/TemplateJoinDaoImpl.java
index d3e1253..4e33728 100644
--- a/server/src/com/cloud/api/query/dao/TemplateJoinDaoImpl.java
+++ b/server/src/com/cloud/api/query/dao/TemplateJoinDaoImpl.java
@@ -156,8 +156,8 @@ public class TemplateJoinDaoImpl extends GenericDaoBase<TemplateJoinVO, Long> im
         templateResponse.setDomainId(template.getDomainUuid());
         templateResponse.setDomainName(template.getDomainName());
 
-        // If the user is an Admin, add the template download status
-        if (view == ResponseView.Full) {
+        // If the user is an 'Admin' or 'the owner of template', add the template download status
+        if (view == ResponseView.Full ||  template.getAccountId() == CallContext.current().getCallingAccount().getId() ) {
             String templateStatus = getTemplateStatus(template);
             if (templateStatus != null) {
                 templateResponse.setStatus(templateStatus);


[06/50] [abbrv] git commit: updated refs/heads/baremetal-systemvm to 23482b1

Posted by ki...@apache.org.
CLOUDSTACK-7723: UI > Storage > detail view > add Disk Offering field.


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

Branch: refs/heads/baremetal-systemvm
Commit: 26f3e8499a6889e00b6e2ea63a0a9425c1b2647e
Parents: e7fa3a2
Author: Jessica Wang <je...@apache.org>
Authored: Tue Oct 14 14:17:39 2014 -0700
Committer: Jessica Wang <je...@apache.org>
Committed: Tue Oct 14 14:17:39 2014 -0700

----------------------------------------------------------------------
 ui/scripts/storage.js | 3 +++
 1 file changed, 3 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/26f3e849/ui/scripts/storage.js
----------------------------------------------------------------------
diff --git a/ui/scripts/storage.js b/ui/scripts/storage.js
index 97b3b8f..ee8fa9d 100644
--- a/ui/scripts/storage.js
+++ b/ui/scripts/storage.js
@@ -1458,6 +1458,9 @@
                                     status: {
                                         label: 'label.status'
                                     },
+                                    diskofferingdisplaytext: {
+                                    	label: 'Disk Offering'
+                                    },
                                     type: {
                                         label: 'label.type'
                                     },


[50/50] [abbrv] git commit: updated refs/heads/baremetal-systemvm to 23482b1

Posted by ki...@apache.org.
Merge branch 'master' into baremetal-systemvm

Conflicts:
	tools/appliance/definitions/systemvmtemplate/preseed.cfg


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

Branch: refs/heads/baremetal-systemvm
Commit: 23482b142019eb9b13427bd9bf4201adc750d337
Parents: c1aa35f 14c820a
Author: Kishan Kavala <ki...@apache.org>
Authored: Tue Oct 21 20:18:40 2014 +0530
Committer: Kishan Kavala <ki...@apache.org>
Committed: Tue Oct 21 20:18:40 2014 +0530

----------------------------------------------------------------------
 agent/src/com/cloud/agent/Agent.java            |    4 +-
 .../com/cloud/hypervisor/HypervisorGuru.java    |    4 +
 api/src/com/cloud/storage/Volume.java           |    5 +
 api/src/com/cloud/vm/VirtualMachine.java        |  109 +-
 .../admin/network/UpdatePhysicalNetworkCmd.java |    8 +-
 .../user/firewall/DeleteFirewallRuleCmd.java    |    5 +-
 .../command/user/vpn/UpdateVpnGatewayCmd.java   |    6 +-
 .../api/response/VMSnapshotResponse.java        |   10 +-
 .../classes/resources/messages.properties       |   10 +-
 .../cloud/agent/api/StartupRoutingCommand.java  |   11 +
 .../api/storage/DataStoreCapabilities.java      |    3 +-
 .../subsystem/api/storage/EndPointSelector.java |    2 +
 .../com/cloud/network/NetworkStateListener.java |   12 +-
 .../manager/ClusteredAgentManagerImpl.java      |   43 +-
 .../com/cloud/vm/VirtualMachineManagerImpl.java |   28 +-
 .../schema/src/com/cloud/host/dao/HostDao.java  |    2 +
 .../src/com/cloud/host/dao/HostDaoImpl.java     |   13 +
 .../src/com/cloud/host/dao/HostTagsDao.java     |    2 +
 .../src/com/cloud/host/dao/HostTagsDaoImpl.java |   17 +
 .../com/cloud/upgrade/dao/Upgrade410to420.java  | 2831 ++++++++--------
 .../com/cloud/upgrade/dao/Upgrade441to450.java  |  169 +-
 .../datastore/db/TemplateDataStoreDao.java      |    2 +
 .../datastore/db/VolumeDataStoreDao.java        |    2 +
 ...-engine-storage-snapshot-storage-context.xml |    3 +
 .../snapshot/StorageSystemSnapshotStrategy.java |  289 ++
 .../allocator/AbstractStoragePoolAllocator.java |   30 +-
 .../endpoint/DefaultEndPointSelector.java       |   29 +
 .../image/db/TemplateDataStoreDaoImpl.java      |   20 +
 .../image/db/VolumeDataStoreDaoImpl.java        |   21 +
 .../storage/volume/VolumeServiceImpl.java       |    1 +
 .../src/com/cloud/utils/db/GenericDaoBase.java  |  122 +-
 .../db/test/com/cloud/utils/db/DbTestUtils.java |   39 +-
 .../framework/rpc/RpcServerCallImpl.java        |    2 +-
 .../jobs/dao/SyncQueueItemDaoImpl.java          |    2 +-
 .../jobs/impl/AsyncJobManagerImpl.java          |   57 +-
 packaging/centos63/cloud.spec                   |   23 +-
 packaging/centos63/default/macros.spec          |    4 +-
 packaging/centos63/package.sh                   |   26 +-
 .../centos63/rhel7/cloudstack-management.conf   |   18 -
 packaging/centos63/rhel7/macros.spec            |    4 +-
 .../cloudstack/discovery/ApiDiscoveryTest.java  |   24 +-
 .../implicitplanner/ImplicitPlannerTest.java    |   12 +
 .../baremetal/manager/BaremetalManagerImpl.java |   53 +-
 .../baremetal/manager/BaremetalVlanManager.java |    2 +-
 .../manager/BaremetalVlanManagerImpl.java       |   10 +-
 .../Force10BaremetalSwitchBackend.java          |  176 +-
 .../BaremetalProvisionDoneNotificationCmd.java  |  174 +-
 .../kvm/resource/BridgeVifDriver.java           |   21 +-
 .../kvm/resource/LibvirtComputingResource.java  |    3 +-
 .../kvm/storage/LibvirtStorageAdaptor.java      |   15 +-
 .../src/com/cloud/ovm/object/Connection.java    |    4 +-
 .../com/cloud/hypervisor/guru/VMwareGuru.java   |    7 +
 .../vmware/manager/VmwareManagerImpl.java       |    2 +-
 .../vmware/resource/VmwareResource.java         |   25 +-
 .../resource/VmwareStorageProcessor.java        |   24 +-
 .../src/com/cloud/hypervisor/XenServerGuru.java |    5 +
 .../xenserver/resource/CitrixResourceBase.java  |   18 +-
 .../resource/XenServer620SP1Resource.java       |    3 +
 .../network/resource/NetscalerResource.java     |    8 +-
 .../cloud/network/element/NuageVspElement.java  |    6 +-
 .../com/cloud/network/element/OvsElement.java   |  139 +-
 .../cloud/network/ovs/OvsTunnelManagerImpl.java |   36 +-
 .../driver/CloudStackImageStoreDriverImpl.java  |    7 +-
 .../datastore/util/NexentaNmsClient.java        |   11 +-
 .../driver/SolidFirePrimaryDataStoreDriver.java |   62 +-
 .../storage/datastore/util/SolidFireUtil.java   |   56 +-
 .../spring-server-core-managers-context.xml     |   33 +-
 .../impl/UserConcentratedAllocator.java         |    2 +-
 server/src/com/cloud/api/ApiResponseHelper.java |   42 +-
 .../src/com/cloud/api/doc/ApiXmlDocWriter.java  |    6 +-
 .../api/query/dao/TemplateJoinDaoImpl.java      |    4 +-
 .../com/cloud/capacity/CapacityManagerImpl.java |  124 +-
 server/src/com/cloud/configuration/Config.java  |    8 +
 .../configuration/ConfigurationManagerImpl.java |   14 +-
 .../deploy/DeploymentPlanningManagerImpl.java   |   25 +-
 .../src/com/cloud/deploy/FirstFitPlanner.java   |   55 +-
 .../cloud/ha/HighAvailabilityManagerImpl.java   |    2 +-
 .../ExternalLoadBalancerDeviceManagerImpl.java  |    8 +-
 .../network/element/VirtualRouterElement.java   |  423 ++-
 .../element/VpcVirtualRouterElement.java        |  162 +-
 .../network/firewall/FirewallManagerImpl.java   |    2 +-
 .../network/router/CommandSetupHelper.java      | 1029 ++++++
 .../com/cloud/network/router/NetworkHelper.java |   81 +
 .../cloud/network/router/NetworkHelperImpl.java |  757 +++++
 .../cloud/network/router/NicProfileHelper.java  |   31 +
 .../network/router/NicProfileHelperImpl.java    |  110 +
 .../network/router/RouterControlHelper.java     |   70 +
 .../router/VirtualNetworkApplianceManager.java  |   66 +-
 .../VirtualNetworkApplianceManagerImpl.java     | 3012 ++++--------------
 .../network/router/VpcNetworkHelperImpl.java    |  154 +
 .../VpcVirtualNetworkApplianceManager.java      |   63 +-
 .../VpcVirtualNetworkApplianceManagerImpl.java  |  972 +-----
 .../cloud/network/rules/AdvancedVpnRules.java   |   60 +
 .../com/cloud/network/rules/BasicVpnRules.java  |   48 +
 .../com/cloud/network/rules/DhcpEntryRules.java |   80 +
 .../com/cloud/network/rules/DhcpPvlanRules.java |   67 +
 .../cloud/network/rules/DhcpSubNetRules.java    |  174 +
 .../com/cloud/network/rules/FirewallRules.java  |   94 +
 .../cloud/network/rules/IpAssociationRules.java |   48 +
 .../cloud/network/rules/LoadBalancingRules.java |   79 +
 .../cloud/network/rules/NetworkAclsRules.java   |   54 +
 .../cloud/network/rules/NicPlugInOutRules.java  |  218 ++
 .../network/rules/PasswordToRouterRules.java    |   66 +
 .../network/rules/PrivateGatewayRules.java      |  150 +
 .../com/cloud/network/rules/RuleApplier.java    |   45 +
 .../cloud/network/rules/RuleApplierWrapper.java |   32 +
 .../network/rules/SshKeyToRouterRules.java      |   89 +
 .../com/cloud/network/rules/StaticNatRules.java |   46 +
 .../cloud/network/rules/StaticRoutesRules.java  |   47 +
 .../cloud/network/rules/UserdataPwdRules.java   |   80 +
 .../network/rules/UserdataToRouterRules.java    |   69 +
 .../rules/VirtualNetworkApplianceFactory.java   |  177 +
 .../network/rules/VpcIpAssociationRules.java    |   92 +
 .../security/SecurityGroupManagerImpl.java      |   46 +-
 .../com/cloud/network/vpc/VpcManagerImpl.java   |   23 +-
 .../com/cloud/resource/ResourceManagerImpl.java |   16 +
 .../storage/listener/SnapshotStateListener.java |    9 +-
 .../storage/listener/VolumeStateListener.java   |    9 +-
 .../storage/snapshot/SnapshotManagerImpl.java   |   24 +-
 .../com/cloud/template/TemplateManagerImpl.java |    5 +-
 .../src/com/cloud/usage/UsageServiceImpl.java   |    2 +-
 .../src/com/cloud/vm/UserVmStateListener.java   |   57 +-
 .../vm/snapshot/VMSnapshotManagerImpl.java      |    8 +
 .../affinity/AffinityGroupServiceImpl.java      | 1024 +++---
 .../topology/AdvancedNetworkTopology.java       |  231 ++
 .../topology/AdvancedNetworkVisitor.java        |  215 ++
 .../network/topology/BasicNetworkTopology.java  |  440 +++
 .../network/topology/BasicNetworkVisitor.java   |  319 ++
 .../network/topology/NetworkTopology.java       |   90 +
 .../topology/NetworkTopologyContext.java        |   52 +
 .../topology/NetworkTopologyVisitor.java        |   63 +
 .../cloudstack/region/RegionsApiUtil.java       |   16 +-
 .../deployment/RouterDeploymentDefinition.java  |  457 +++
 .../RouterDeploymentDefinitionBuilder.java      |  217 ++
 .../VpcRouterDeploymentDefinition.java          |  182 ++
 .../element/VirtualRouterElementTest.java       |   10 +-
 .../network/router/NetworkHelperImplTest.java   |  172 +
 .../network/router/RouterControlHelperTest.java |  121 +
 .../VirtualNetworkApplianceManagerImplTest.java |  267 +-
 .../vm/DeploymentPlanningManagerImplTest.java   |   12 +
 .../test/com/cloud/vm/FirstFitPlannerTest.java  |  387 +++
 .../vm/snapshot/VMSnapshotManagerTest.java      |    5 +
 .../MockVpcVirtualNetworkApplianceManager.java  |  229 +-
 .../RouterDeploymentDefinitionTest.java         |  941 ++++++
 .../RouterDeploymentDefinitionTestBase.java     |  134 +
 .../VpcRouterDeploymentDefinitionTest.java      |  230 ++
 .../SecondaryStorageManagerImpl.java            |    7 +-
 .../resource/NfsSecondaryStorageResource.java   |   50 +-
 .../LocalNfsSecondaryStorageResourceTest.java   |    4 +-
 .../NfsSecondaryStorageResourceTest.java        |    6 +-
 setup/db/db/schema-441to450.sql                 |    6 +-
 .../component/test_deploy_vgpu_vm.py            |  684 +++-
 .../component/test_escalations_volumes.py       |   77 +-
 .../component/test_lb_secondary_ip.py           | 1022 +++---
 test/integration/component/test_nuage_vsp.py    |  312 --
 .../component/test_persistent_networks.py       | 2748 +++++++++++-----
 .../component/test_recurring_snapshots.py       |  497 +--
 test/integration/component/test_routers.py      | 1422 +++++----
 .../smoke/misc/test_escalations_templates.py    |  211 ++
 test/integration/smoke/test_nuage_vsp.py        |  301 ++
 test/integration/smoke/test_primary_storage.py  |    4 +-
 test/integration/smoke/test_scale_vm.py         |    4 +-
 test/integration/smoke/test_snapshots.py        |    4 +-
 test/integration/smoke/test_templates.py        |    6 +
 test/integration/smoke/test_vm_life_cycle.py    |   14 +-
 test/integration/smoke/test_vm_snapshots.py     |    4 +-
 .../testpaths/testpath_volumelifecycle.py       |  567 ++++
 .../definitions/systemvmtemplate/preseed.cfg    |   11 -
 tools/marvin/marvin/lib/base.py                 |    3 +-
 ui/index.jsp                                    |   20 +-
 ui/scripts/configuration.js                     |   16 +-
 ui/scripts/instanceWizard.js                    |    9 +-
 ui/scripts/instances.js                         |   32 +-
 ui/scripts/network.js                           |   17 +-
 ui/scripts/sharedFunctions.js                   |    2 +-
 ui/scripts/storage.js                           |    3 +
 ui/scripts/system.js                            |   97 +-
 ui/scripts/ui/widgets/listView.js               |    2 +-
 ui/scripts/zoneWizard.js                        |    4 +
 .../src/com/cloud/utils/fsm/StateListener.java  |   17 +-
 .../src/com/cloud/utils/fsm/StateMachine2.java  |  142 +-
 utils/src/com/cloud/utils/script/Script.java    |   24 +-
 .../hypervisor/vmware/util/VmwareHelper.java    |    2 +-
 183 files changed, 18601 insertions(+), 9724 deletions(-)
----------------------------------------------------------------------



[37/50] [abbrv] git commit: updated refs/heads/baremetal-systemvm to 23482b1

Posted by ki...@apache.org.
CLOUDSTACK-7731: UI > Infrastructure > Virtual Routers > group by zone/pod/cluster view > listView > detailView > add View All link (i.e. "View all Virtual Routers").


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

Branch: refs/heads/baremetal-systemvm
Commit: 314a7fe62b626d79f612d70ccf56d692a92f5774
Parents: 7072d8d
Author: Jessica Wang <je...@apache.org>
Authored: Thu Oct 16 12:06:59 2014 -0700
Committer: Jessica Wang <je...@apache.org>
Committed: Thu Oct 16 12:33:08 2014 -0700

----------------------------------------------------------------------
 ui/scripts/system.js | 45 ++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 42 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/314a7fe6/ui/scripts/system.js
----------------------------------------------------------------------
diff --git a/ui/scripts/system.js b/ui/scripts/system.js
index 1a14e31..fbd2f2b 100644
--- a/ui/scripts/system.js
+++ b/ui/scripts/system.js
@@ -9445,6 +9445,27 @@
                                     // forvpc: false
                                 };
                                 
+                                if (args.context != undefined) {
+	                                if ("routerGroupByZone" in args.context) {
+	                                    $.extend(data2, {
+	                                        zoneid: args.context.routerGroupByZone[0].id
+	                                    })
+	                                } else if ("routerGroupByPod" in args.context) {
+	                                    $.extend(data2, {
+	                                        podid: args.context.routerGroupByPod[0].id
+	                                    })
+	                                } else if ("routerGroupByCluster" in args.context) {
+	                                    $.extend(data2, {
+	                                        clusterid: args.context.routerGroupByCluster[0].id
+	                                    })
+	                                } else if ("routerGroupByAccount" in args.context) {
+	                                    $.extend(data2, {
+	                                    	 account: args.context.routerGroupByAccount[0].name,
+	                                         domainid: args.context.routerGroupByAccount[0].domainid
+	                                    })
+	                                }
+                                }                               
+                                
                                 var routers =[];
                                 $.ajax({
                                     url: createURL("listRouters&listAll=true&page=" + args.page + "&pagesize=" + pageSize + array1.join("")),
@@ -10078,7 +10099,11 @@
                                 });
                             },
                             detailView: {
-                                name: 'label.virtual.routers.group.zone',
+                                name: 'label.virtual.routers.group.zone',                                
+                                viewAll: {
+                                    path: '_zone.virtualRouters',
+                                    label: 'label.virtual.appliances'
+                                },                                
                                 actions: {
                                     upgradeRouterToUseNewerTemplate: {
                                         label: 'label.upgrade.router.newer.template',
@@ -10205,7 +10230,11 @@
                                 });
                             },
                             detailView: {
-                                name: 'label.virtual.routers.group.pod',
+                                name: 'label.virtual.routers.group.pod',                                
+                                viewAll: {
+                                    path: '_zone.virtualRouters',
+                                    label: 'label.virtual.appliances'
+                                },                               
                                 actions: {
                                     upgradeRouterToUseNewerTemplate: {
                                         label: 'label.upgrade.router.newer.template',
@@ -10335,7 +10364,11 @@
                                 });
                             },
                             detailView: {
-                                name: 'label.virtual.routers.group.cluster',
+                                name: 'label.virtual.routers.group.cluster',                               
+                                viewAll: {
+                                    path: '_zone.virtualRouters',
+                                    label: 'label.virtual.appliances'
+                                },                               
                                 actions: {
                                     upgradeRouterToUseNewerTemplate: {
                                         label: 'label.upgrade.router.newer.template',
@@ -10533,6 +10566,12 @@
                             },
                             detailView: {
                                 name: 'label.virtual.routers.group.account',
+                                /*
+                                viewAll: {
+                                    path: '_zone.virtualRouters',
+                                    label: 'label.virtual.appliances'
+                                },
+                                */
                                 actions: {
                                     upgradeRouterToUseNewerTemplate: {
                                         label: 'label.upgrade.router.newer.template',


[32/50] [abbrv] git commit: updated refs/heads/baremetal-systemvm to 23482b1

Posted by ki...@apache.org.
Config value having different category in SQL and Config.java.


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

Branch: refs/heads/baremetal-systemvm
Commit: ec6a666855883f0c02727d8094a3658eaed459c2
Parents: efe1e0a
Author: Sanjay Tripathi <sa...@citrix.com>
Authored: Wed Oct 15 14:55:04 2014 +0530
Committer: Sanjay Tripathi <sa...@citrix.com>
Committed: Thu Oct 16 14:38:23 2014 +0530

----------------------------------------------------------------------
 server/src/com/cloud/configuration/Config.java | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ec6a6668/server/src/com/cloud/configuration/Config.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/configuration/Config.java b/server/src/com/cloud/configuration/Config.java
index a462348..3710e0a 100755
--- a/server/src/com/cloud/configuration/Config.java
+++ b/server/src/com/cloud/configuration/Config.java
@@ -1360,14 +1360,6 @@ public enum Config {
             "false",
             "Deploys a VM per zone to manage secondary storage if true, otherwise secondary storage is mounted on management server",
             null),
-    ImplicitHostTags(
-            "Hidden",
-            ManagementServer.class,
-            String.class,
-            "implicit.host.tags",
-            "GPU",
-            "Tag hosts at the time of host disovery based on the host properties/capabilities",
-            null),
     CreatePoolsInPod(
             "Hidden",
             ManagementServer.class,
@@ -1821,6 +1813,14 @@ public enum Config {
             "Service offering used by secondary storage; if NULL - system offering will be used",
             null),
     HaTag("Advanced", ManagementServer.class, String.class, "ha.tag", null, "HA tag defining that the host marked with this tag can be used for HA purposes only", null),
+    ImplicitHostTags(
+            "Advanced",
+            ManagementServer.class,
+            String.class,
+            "implicit.host.tags",
+            "GPU",
+            "Tag hosts at the time of host disovery based on the host properties/capabilities",
+            null),
     VpcCleanupInterval(
             "Advanced",
             ManagementServer.class,


[02/50] [abbrv] git commit: updated refs/heads/baremetal-systemvm to 23482b1

Posted by ki...@apache.org.
CLOUDSTACK-7563: Fix potential NPE from FingBugs.


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

Branch: refs/heads/baremetal-systemvm
Commit: 4b8bfe26275f7eb6e98abe77849153eaa93e8205
Parents: 771d052
Author: Min Chen <mi...@citrix.com>
Authored: Tue Oct 14 10:35:29 2014 -0700
Committer: Min Chen <mi...@citrix.com>
Committed: Tue Oct 14 11:19:39 2014 -0700

----------------------------------------------------------------------
 .../src/com/cloud/vm/VirtualMachineManagerImpl.java  | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4b8bfe26/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java b/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java
index d458950..de2fd28 100755
--- a/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java
+++ b/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java
@@ -1873,7 +1873,8 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
         try {
             pfma = _agentMgr.send(dstHostId, pfmc);
             if (pfma == null || !pfma.getResult()) {
-                String msg = "Unable to prepare for migration due to " + pfma.getDetails();
+                String details = (pfma != null) ? pfma.getDetails() : "null answer returned";
+                String msg = "Unable to prepare for migration due to " + details;
                 pfma = null;
                 throw new AgentUnavailableException(msg, dstHostId);
             }
@@ -1909,7 +1910,8 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
             try {
                 Answer ma = _agentMgr.send(vm.getLastHostId(), mc);
                 if (ma == null || !ma.getResult()) {
-                    throw new CloudRuntimeException("Unable to migrate due to " + ma.getDetails());
+                    String details = (ma != null) ? ma.getDetails() : "null answer returned";
+                    throw new CloudRuntimeException("Unable to migrate due to " + details);
                 }
             } catch (OperationTimedoutException e) {
                 if (e.isActive()) {
@@ -3263,7 +3265,8 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
         try {
             pfma = _agentMgr.send(dstHostId, pfmc);
             if (pfma == null || !pfma.getResult()) {
-                String msg = "Unable to prepare for migration due to " + pfma.getDetails();
+                String details = (pfma != null) ? pfma.getDetails() : "null answer returned";
+                String msg = "Unable to prepare for migration due to " + details;
                 pfma = null;
                 throw new AgentUnavailableException(msg, dstHostId);
             }
@@ -3296,8 +3299,10 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
             try {
                 Answer ma = _agentMgr.send(vm.getLastHostId(), mc);
                 if (ma == null || !ma.getResult()) {
-                    s_logger.error("Unable to migrate due to " + ma.getDetails());
-                    throw new CloudRuntimeException("Unable to migrate due to " + ma.getDetails());
+                    String details = (ma != null) ? ma.getDetails() : "null answer returned";
+                    String msg = "Unable to migrate due to " + details;
+                    s_logger.error(msg);
+                    throw new CloudRuntimeException(msg);
                 }
             } catch (OperationTimedoutException e) {
                 if (e.isActive()) {


[30/50] [abbrv] git commit: updated refs/heads/baremetal-systemvm to 23482b1

Posted by ki...@apache.org.
Config value having different category in SQL and Config.java.


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

Branch: refs/heads/baremetal-systemvm
Commit: 5025071954b8ad9c7b79cff208ff7483b81051b2
Parents: 80e0c99
Author: Sanjay Tripathi <sa...@citrix.com>
Authored: Wed Oct 15 14:55:04 2014 +0530
Committer: Sanjay Tripathi <sa...@citrix.com>
Committed: Thu Oct 16 14:01:23 2014 +0530

----------------------------------------------------------------------
 server/src/com/cloud/configuration/Config.java | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/50250719/server/src/com/cloud/configuration/Config.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/configuration/Config.java b/server/src/com/cloud/configuration/Config.java
index 2fc5356..71f5c5b 100755
--- a/server/src/com/cloud/configuration/Config.java
+++ b/server/src/com/cloud/configuration/Config.java
@@ -1360,14 +1360,6 @@ public enum Config {
             "false",
             "Deploys a VM per zone to manage secondary storage if true, otherwise secondary storage is mounted on management server",
             null),
-    ImplicitHostTags(
-            "Hidden",
-            ManagementServer.class,
-            String.class,
-            "implicit.host.tags",
-            "GPU",
-            "Tag hosts at the time of host disovery based on the host properties/capabilities",
-            null),
     CreatePoolsInPod(
             "Hidden",
             ManagementServer.class,
@@ -1821,6 +1813,14 @@ public enum Config {
             "Service offering used by secondary storage; if NULL - system offering will be used",
             null),
     HaTag("Advanced", ManagementServer.class, String.class, "ha.tag", null, "HA tag defining that the host marked with this tag can be used for HA purposes only", null),
+    ImplicitHostTags(
+            "Advanced",
+            ManagementServer.class,
+            String.class,
+            "implicit.host.tags",
+            "GPU",
+            "Tag hosts at the time of host disovery based on the host properties/capabilities",
+            null),
     VpcCleanupInterval(
             "Advanced",
             ManagementServer.class,


[43/50] [abbrv] git commit: updated refs/heads/baremetal-systemvm to 23482b1

Posted by ki...@apache.org.
restore barematel work after merge


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

Branch: refs/heads/baremetal-systemvm
Commit: 1de0cb709483090926cbef48d1d677f618f9c17f
Parents: c10f8a1
Author: Daan Hoogland <da...@onecht.net>
Authored: Fri Oct 17 10:24:01 2014 +0200
Committer: Daan Hoogland <da...@onecht.net>
Committed: Fri Oct 17 10:24:01 2014 +0200

----------------------------------------------------------------------
 api/src/com/cloud/event/EventTypes.java         |   1 +
 .../PrepareKickstartPxeServerCommand.java       |  84 ------
 .../core/spring-baremetal-core-context.xml      |   8 +-
 .../baremetal/manager/BaremetalManager.java     |   3 +
 .../baremetal/manager/BaremetalManagerImpl.java |   3 +
 .../baremetal/manager/BaremetalVlanManager.java |   1 +
 .../manager/BaremetalVlanManagerImpl.java       |   7 +-
 .../networkservice/BareMetalResourceBase.java   |  47 ++-
 .../BaremetalKickStartPxeResource.java          |   1 -
 .../BaremetalKickStartServiceImpl.java          |  12 +-
 .../networkservice/BaremetalPxeElement.java     |   5 +-
 .../Force10BaremetalSwitchBackend.java          | 120 ++++++--
 .../PrepareKickstartPxeServerCommand.java       |  83 ++++++
 .../BaremetalProvisionDoneNotificationCmd.java  |  87 ++++++
 server/src/com/cloud/configuration/Config.java  |  36 ++-
 .../deploy/DeploymentPlanningManagerImpl.java   |  11 +-
 .../VirtualNetworkApplianceManagerImpl.java     |   2 +
 .../com/cloud/resource/ResourceManagerImpl.java |  15 -
 .../com/cloud/storage/VolumeApiServiceImpl.java |  12 +-
 .../cloud/storage/VolumeApiServiceImplTest.java |  24 +-
 .../patches/debian/config/etc/dnsmasq.conf.tmpl |   6 +-
 .../config/opt/cloud/bin/baremetal_snat.sh      |  21 +-
 .../debian/config/opt/cloud/bin/prepare_pxe.sh  |  28 +-
 .../component/test_deploy_vgpu_vm.py            | 291 +------------------
 .../com/cloud/utils/xmlobject/XmlObject.java    |  15 +-
 .../cloud/utils/xmlobject/XmlObjectParser.java  |  22 +-
 .../cloud/utils/xmlobject/TestXmlObject.java    |   5 +
 27 files changed, 462 insertions(+), 488 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1de0cb70/api/src/com/cloud/event/EventTypes.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/event/EventTypes.java b/api/src/com/cloud/event/EventTypes.java
index 7477152..3a1d58a 100755
--- a/api/src/com/cloud/event/EventTypes.java
+++ b/api/src/com/cloud/event/EventTypes.java
@@ -454,6 +454,7 @@ public class EventTypes {
     public static final String EVENT_BAREMETAL_PXE_SERVER_ADD = "PHYSICAL.PXE.ADD";
     public static final String EVENT_BAREMETAL_PXE_SERVER_DELETE = "PHYSICAL.PXE.DELETE";
     public static final String EVENT_BAREMETAL_RCT_ADD = "BAREMETAL.RCT.ADD";
+    public static final String EVENT_BAREMETAL_PROVISION_DONE = "BAREMETAL.PROVISION.DONE";
 
     public static final String EVENT_AFFINITY_GROUP_CREATE = "AG.CREATE";
     public static final String EVENT_AFFINITY_GROUP_DELETE = "AG.DELETE";

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1de0cb70/core/src/com/cloud/agent/api/baremetal/PrepareKickstartPxeServerCommand.java
----------------------------------------------------------------------
diff --git a/core/src/com/cloud/agent/api/baremetal/PrepareKickstartPxeServerCommand.java b/core/src/com/cloud/agent/api/baremetal/PrepareKickstartPxeServerCommand.java
deleted file mode 100755
index b8fb5d0..0000000
--- a/core/src/com/cloud/agent/api/baremetal/PrepareKickstartPxeServerCommand.java
+++ /dev/null
@@ -1,84 +0,0 @@
-//
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-//
-
-package com.cloud.agent.api.baremetal;
-
-import com.cloud.agent.api.Command;
-
-public class PrepareKickstartPxeServerCommand extends Command {
-    private String ksFile;
-    private String templateUuid;
-    private String mac;
-    private String ksDevice;
-    private String kernel;
-    private String initrd;
-
-    @Override
-    public boolean executeInSequence() {
-        return true;
-    }
-
-    public String getKsFile() {
-        return ksFile;
-    }
-
-    public void setKsFile(String ksFile) {
-        this.ksFile = ksFile;
-    }
-
-    public String getKernel() {
-        return kernel;
-    }
-
-    public void setKernel(String kernel) {
-        this.kernel = kernel;
-    }
-
-    public String getInitrd() {
-        return initrd;
-    }
-
-    public void setInitrd(String initrd) {
-        this.initrd = initrd;
-    }
-
-    public String getTemplateUuid() {
-        return templateUuid;
-    }
-
-    public void setTemplateUuid(String templateUuid) {
-        this.templateUuid = templateUuid;
-    }
-
-    public String getMac() {
-        return mac;
-    }
-
-    public void setMac(String mac) {
-        this.mac = mac;
-    }
-
-    public String getKsDevice() {
-        return ksDevice;
-    }
-
-    public void setKsDevice(String ksDevice) {
-        this.ksDevice = ksDevice;
-    }
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1de0cb70/plugins/hypervisors/baremetal/resources/META-INF/cloudstack/core/spring-baremetal-core-context.xml
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/baremetal/resources/META-INF/cloudstack/core/spring-baremetal-core-context.xml b/plugins/hypervisors/baremetal/resources/META-INF/cloudstack/core/spring-baremetal-core-context.xml
index ae28efa..a153e7f 100755
--- a/plugins/hypervisors/baremetal/resources/META-INF/cloudstack/core/spring-baremetal-core-context.xml
+++ b/plugins/hypervisors/baremetal/resources/META-INF/cloudstack/core/spring-baremetal-core-context.xml
@@ -28,7 +28,13 @@
                       >
 
     <bean id="BaremetalManager" class="com.cloud.baremetal.manager.BaremetalManagerImpl" />
-    <bean id="BaremetalVlanManager" class="com.cloud.baremetal.manager.BaremetalVlanManagerImpl" />
+    <bean id="BaremetalVlanManager" class="com.cloud.baremetal.manager.BaremetalVlanManagerImpl" >
+       <property name="backends">
+           <map>
+               <entry key="Force10" value-ref="Force10BaremetalSwitchBackend"/>
+           </map>
+       </property>
+    </bean>
     <bean id="Force10BaremetalSwitchBackend" class="com.cloud.baremetal.networkservice.Force10BaremetalSwitchBackend" />
 
     <bean id="BaremetalKickStartPxeService"

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1de0cb70/plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/BaremetalManager.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/BaremetalManager.java b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/BaremetalManager.java
index 5db29d2..629153a 100755
--- a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/BaremetalManager.java
+++ b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/BaremetalManager.java
@@ -20,9 +20,12 @@ package com.cloud.baremetal.manager;
 
 import com.cloud.utils.component.Manager;
 import com.cloud.utils.component.PluggableService;
+import org.apache.cloudstack.api.BaremetalProvisionDoneNotificationCmd;
 
 public interface BaremetalManager extends Manager, PluggableService {
     public static final String EchoSecurityGroupAgent = "EchoSecurityGroupAgent";
     public static final String ExternalBaremetalSystemUrl = "ExternalBaremetalSystemUrl";
     public static final String DO_PXE = "doPxe";
+
+    void notifyProvisionDone(BaremetalProvisionDoneNotificationCmd cmd);
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1de0cb70/plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/BaremetalManagerImpl.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/BaremetalManagerImpl.java b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/BaremetalManagerImpl.java
index 076a1bc..f826ae9 100755
--- a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/BaremetalManagerImpl.java
+++ b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/BaremetalManagerImpl.java
@@ -52,6 +52,8 @@ public class BaremetalManagerImpl extends ManagerBase implements BaremetalManage
 
     @Inject
     protected HostDao _hostDao;
+    @Inject
+    protected VMInstanceDao vmDao;
 
     @Override
     public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
@@ -116,6 +118,7 @@ public class BaremetalManagerImpl extends ManagerBase implements BaremetalManage
     public List<Class<?>> getCommands() {
         List<Class<?>> cmds = new ArrayList<Class<?>>();
         cmds.add(AddBaremetalHostCmd.class);
+        cmds.add(BaremetalProvisionDoneNotificationCmd.class);
         return cmds;
     }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1de0cb70/plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/BaremetalVlanManager.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/BaremetalVlanManager.java b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/BaremetalVlanManager.java
index 09215ea..b2a1be9 100755
--- a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/BaremetalVlanManager.java
+++ b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/BaremetalVlanManager.java
@@ -18,6 +18,7 @@
 package com.cloud.baremetal.manager;
 
 import com.cloud.baremetal.networkservice.BaremetalRctResponse;
+import com.cloud.baremetal.networkservice.BaremetalSwitchBackend;
 import com.cloud.deploy.DeployDestination;
 import com.cloud.network.Network;
 import com.cloud.utils.component.Manager;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1de0cb70/plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/BaremetalVlanManagerImpl.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/BaremetalVlanManagerImpl.java b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/BaremetalVlanManagerImpl.java
index 3728a31..c8473b6 100755
--- a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/BaremetalVlanManagerImpl.java
+++ b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/manager/BaremetalVlanManagerImpl.java
@@ -48,7 +48,6 @@ import javax.inject.Inject;
 import java.net.MalformedURLException;
 import java.net.URL;
 import java.util.ArrayList;
-import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.UUID;
@@ -70,13 +69,17 @@ public class BaremetalVlanManagerImpl extends ManagerBase implements BaremetalVl
     @Inject
     private AccountManager acntMgr;
 
-    private Map<String, BaremetalSwitchBackend> backends = new HashMap<>();
+    private Map<String, BaremetalSwitchBackend> backends;
 
     private class RackPair {
         BaremetalRct.Rack rack;
         BaremetalRct.HostEntry host;
     }
 
+    public void setBackends(Map<String, BaremetalSwitchBackend> backends) {
+        this.backends = backends;
+    }
+
     @Override
     public BaremetalRctResponse addRct(AddBaremetalRctCmd cmd) {
         try {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1de0cb70/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BareMetalResourceBase.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BareMetalResourceBase.java b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BareMetalResourceBase.java
index 8ed50ef..ab863dc 100755
--- a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BareMetalResourceBase.java
+++ b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BareMetalResourceBase.java
@@ -59,12 +59,15 @@ import com.cloud.host.Host.Type;
 import com.cloud.hypervisor.Hypervisor;
 import com.cloud.resource.ServerResource;
 import com.cloud.utils.component.ManagerBase;
+import com.cloud.utils.db.QueryBuilder;
+import com.cloud.utils.db.SearchCriteria;
 import com.cloud.utils.exception.CloudRuntimeException;
 import com.cloud.utils.script.OutputInterpreter;
 import com.cloud.utils.script.Script;
 import com.cloud.utils.script.Script2;
 import com.cloud.utils.script.Script2.ParamType;
 import com.cloud.vm.VMInstanceVO;
+import com.cloud.vm.VirtualMachine;
 import com.cloud.vm.VirtualMachine.PowerState;
 import com.cloud.vm.dao.VMInstanceDao;
 import org.apache.cloudstack.api.ApiConstants;
@@ -107,6 +110,8 @@ public class BareMetalResourceBase extends ManagerBase implements ServerResource
     protected Script2 _bootOrRebootCommand;
     protected String _vmName;
     protected int ipmiRetryTimes = 5;
+    protected boolean provisionDoneNotificationOn = false;
+    protected int isProvisionDoneNotificationTimeout = 1800;
 
     protected ConfigurationDao configDao;
     protected VMInstanceDao vmDao;
@@ -181,6 +186,13 @@ public class BareMetalResourceBase extends ManagerBase implements ServerResource
             s_logger.debug(e.getMessage(), e);
         }
 
+        try {
+            provisionDoneNotificationOn = Boolean.valueOf(configDao.getValue(Config.BaremetalProvisionDoneNotificationEnabled.key()));
+            isProvisionDoneNotificationTimeout = Integer.valueOf(configDao.getValue(Config.BaremetalProvisionDoneNotificationTimeout.key()));
+        } catch (Exception e) {
+            s_logger.debug(e.getMessage(), e);
+        }
+
         String injectScript = "scripts/util/ipmi.py";
         String scriptPath = Script.findScript("", injectScript);
         if (scriptPath == null) {
@@ -392,7 +404,7 @@ public class BareMetalResourceBase extends ManagerBase implements ServerResource
                 VMInstanceVO vm = vms.get(0);
                 SecurityGroupHttpClient client = new SecurityGroupHttpClient();
                 HashMap<String, Pair<Long, Long>> nwGrpStates = client.sync(vm.getInstanceName(), vm.getId(), vm.getPrivateIpAddress());
-                return new PingRoutingWithNwGroupsCommand(getType(), id, getHostVmStateReport(), nwGrpStates);
+                return new PingRoutingWithNwGroupsCommand(getType(), id, null, nwGrpStates);
             }
         } else {
             return new PingRoutingCommand(getType(), id, null);
@@ -581,6 +593,39 @@ public class BareMetalResourceBase extends ManagerBase implements ServerResource
             }
         }
 
+        if (provisionDoneNotificationOn) {
+            QueryBuilder<VMInstanceVO> q = QueryBuilder.create(VMInstanceVO.class);
+            q.and(q.entity().getInstanceName(), SearchCriteria.Op.EQ, vm.getName());
+            VMInstanceVO vmvo = q.find();
+
+            if (vmvo.getLastHostId() == null) {
+                // this is new created vm
+                long timeout = System.currentTimeMillis() + TimeUnit.SECONDS.toMillis(isProvisionDoneNotificationTimeout);
+                while (timeout > System.currentTimeMillis()) {
+                    try {
+                        TimeUnit.SECONDS.sleep(5);
+                    } catch (InterruptedException e) {
+                        s_logger.warn(e.getMessage(), e);
+                    }
+
+                    q = QueryBuilder.create(VMInstanceVO.class);
+                    q.and(q.entity().getInstanceName(), SearchCriteria.Op.EQ, vm.getName());
+                    vmvo = q.find();
+                    if (vmvo == null) {
+                        return new StartAnswer(cmd, String.format("cannot find vm[name:%s] while waiting for baremtal provision done notification", vm.getName()));
+                    }
+
+                    if (VirtualMachine.State.Running == vmvo.getState()) {
+                        return new StartAnswer(cmd);
+                    }
+
+                    s_logger.debug(String.format("still wait for baremetal provision done notification for vm[name:%s], current vm state is %s", vmvo.getInstanceName(), vmvo.getState()));
+                }
+
+                return new StartAnswer(cmd, String.format("timeout after %s seconds, no baremetal provision done notification received. vm[name:%s] failed to start", isProvisionDoneNotificationTimeout, vm.getName()));
+            }
+        }
+
         s_logger.debug("Start bare metal vm " + vm.getName() + "successfully");
         _vmName = vm.getName();
         return new StartAnswer(cmd);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1de0cb70/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalKickStartPxeResource.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalKickStartPxeResource.java b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalKickStartPxeResource.java
index 75be597..260f4f1 100755
--- a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalKickStartPxeResource.java
+++ b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalKickStartPxeResource.java
@@ -34,7 +34,6 @@ import com.cloud.agent.api.Command;
 import com.cloud.agent.api.HostVmStateReportEntry;
 import com.cloud.agent.api.PingCommand;
 import com.cloud.agent.api.PingRoutingCommand;
-import com.cloud.agent.api.baremetal.PrepareKickstartPxeServerCommand;
 import com.cloud.agent.api.routing.VmDataCommand;
 import com.cloud.utils.exception.CloudRuntimeException;
 import com.cloud.utils.script.Script;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1de0cb70/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalKickStartServiceImpl.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalKickStartServiceImpl.java b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalKickStartServiceImpl.java
index f668155..7f6b0bf 100755
--- a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalKickStartServiceImpl.java
+++ b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalKickStartServiceImpl.java
@@ -30,16 +30,17 @@ import java.util.Map;
 import javax.ejb.Local;
 import javax.inject.Inject;
 
+import com.cloud.configuration.Config;
+import org.apache.log4j.Logger;
+
 import org.apache.cloudstack.api.AddBaremetalKickStartPxeCmd;
 import org.apache.cloudstack.api.AddBaremetalPxeCmd;
 import org.apache.cloudstack.api.ListBaremetalPxeServersCmd;
 import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
-import org.apache.log4j.Logger;
 
 import com.cloud.agent.api.Answer;
 import com.cloud.agent.api.baremetal.IpmISetBootDevCommand;
 import com.cloud.agent.api.baremetal.IpmISetBootDevCommand.BootDev;
-import com.cloud.agent.api.baremetal.PrepareKickstartPxeServerCommand;
 import com.cloud.baremetal.database.BaremetalPxeDao;
 import com.cloud.baremetal.database.BaremetalPxeVO;
 import com.cloud.baremetal.networkservice.BaremetalPxeManager.BaremetalPxeType;
@@ -223,6 +224,11 @@ public class BaremetalKickStartServiceImpl extends BareMetalPxeServiceBase imple
             throw new CloudRuntimeException(String.format("cannot find management nic on virtual router[id:%s]", vr.getId()));
         }
 
+        String internalServerIp = _configDao.getValue(Config.BaremetalInternalStorageServer.key());
+        if (internalServerIp == null) {
+            throw new CloudRuntimeException(String.format("please specify 'baremetal.internal.storage.server.ip', which is the http server/nfs server storing kickstart files and ISO files, in global setting"));
+        }
+
         List<String> tuple =  parseKickstartUrl(profile);
         String cmd =  String.format("/opt/cloud/bin/prepare_pxe.sh %s %s %s %s %s %s", tuple.get(1), tuple.get(2), profile.getTemplate().getUuid(),
                 String.format("01-%s", nic.getMacAddress().replaceAll(":", "-")).toLowerCase(), tuple.get(0), nic.getMacAddress().toLowerCase());
@@ -232,7 +238,7 @@ public class BaremetalKickStartServiceImpl extends BareMetalPxeServiceBase imple
             throw new CloudRuntimeException(String.format("failed preparing PXE in virtual router[id:%s], because %s", vr.getId(), ret.second()));
         }
 
-        String internalServerIp = "10.223.110.231";
+        //String internalServerIp = "10.223.110.231";
         cmd = String.format("/opt/cloud/bin/baremetal_snat.sh %s %s %s", mgmtNic.getIp4Address(), internalServerIp, mgmtNic.getGateway());
         s_logger.debug(String.format("prepare SNAT on virtual router[ip:%s], cmd: %s", mgmtNic.getIp4Address(), cmd));
         ret = SshHelper.sshExecute(mgmtNic.getIp4Address(), 3922, "root", getSystemVMKeyFile(), null, cmd);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1de0cb70/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalPxeElement.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalPxeElement.java b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalPxeElement.java
index 5d20d31..10b81c2 100755
--- a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalPxeElement.java
+++ b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalPxeElement.java
@@ -21,6 +21,7 @@ package com.cloud.baremetal.networkservice;
 import com.cloud.baremetal.database.BaremetalPxeVO;
 import com.cloud.baremetal.manager.BaremetalVlanManager;
 import com.cloud.dc.DataCenter;
+import com.cloud.dc.DataCenterVO;
 import com.cloud.dc.Pod;
 import com.cloud.dc.dao.DataCenterDao;
 import com.cloud.deploy.DeployDestination;
@@ -139,11 +140,9 @@ public class BaremetalPxeElement extends AdapterBase implements NetworkElement {
             }
         }
 
-        /*
         if (dest.getDataCenter().getNetworkType() == DataCenter.NetworkType.Advanced){
             prepareVlan(network, dest);
         }
-        */
 
         return true;
     }
@@ -159,12 +158,10 @@ public class BaremetalPxeElement extends AdapterBase implements NetworkElement {
             return false;
         }
 
-        /*
         DataCenterVO dc = zoneDao.findById(vm.getVirtualMachine().getDataCenterId());
         if (dc.getNetworkType() == DataCenter.NetworkType.Advanced) {
             releaseVlan(network, vm);
         }
-        */
         return true;
     }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1de0cb70/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/Force10BaremetalSwitchBackend.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/Force10BaremetalSwitchBackend.java b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/Force10BaremetalSwitchBackend.java
old mode 100644
new mode 100755
index 9009b02..c34a6cd
--- a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/Force10BaremetalSwitchBackend.java
+++ b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/Force10BaremetalSwitchBackend.java
@@ -32,11 +32,16 @@ import org.springframework.http.HttpEntity;
 import org.springframework.http.HttpHeaders;
 import org.springframework.http.HttpMethod;
 import org.springframework.http.HttpStatus;
+import org.springframework.http.MediaType;
 import org.springframework.http.ResponseEntity;
+import org.springframework.http.client.ClientHttpResponse;
+import org.springframework.web.client.ResponseErrorHandler;
 import org.springframework.web.client.RestTemplate;
 import org.springframework.web.util.UriComponentsBuilder;
 
+import java.io.IOException;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
 
 /**
@@ -46,17 +51,38 @@ public class Force10BaremetalSwitchBackend implements BaremetalSwitchBackend {
     private Logger logger = Logger.getLogger(Force10BaremetalSwitchBackend.class);
     public static final String TYPE = "Force10";
 
+    private static List<HttpStatus> successHttpStatusCode = new ArrayList<>();
+    {
+        successHttpStatusCode.add(HttpStatus.OK);
+        successHttpStatusCode.add(HttpStatus.ACCEPTED);
+        successHttpStatusCode.add(HttpStatus.CREATED);
+        successHttpStatusCode.add(HttpStatus.NO_CONTENT);
+        successHttpStatusCode.add(HttpStatus.PARTIAL_CONTENT);
+        successHttpStatusCode.add(HttpStatus.RESET_CONTENT);
+        successHttpStatusCode.add(HttpStatus.ALREADY_REPORTED);
+    }
+
     RestTemplate rest = new RestTemplate();
-
-    private String buildLink(String switchIp, Integer vlan) {
+    {
+        // fake error handler, we handle error in business logic code
+        rest.setErrorHandler(new ResponseErrorHandler() {
+            @Override
+            public boolean hasError(ClientHttpResponse clientHttpResponse) throws IOException {
+                return false;
+            }
+
+            @Override
+            public void handleError(ClientHttpResponse clientHttpResponse) throws IOException {
+            }
+        });
+    }
+
+    private String buildLink(String switchIp, String path) {
         UriComponentsBuilder builder = UriComponentsBuilder.newInstance();
         builder.scheme("http");
         builder.host(switchIp);
         builder.port(8008);
-        builder.path("/api/running/ftos/interface/vlan");
-        if (vlan != null) {
-            builder.path(vlan.toString());
-        }
+        builder.path(path);
         return builder.build().toUriString();
     }
 
@@ -67,29 +93,36 @@ public class Force10BaremetalSwitchBackend implements BaremetalSwitchBackend {
 
     @Override
     public void prepareVlan(BaremetalVlanStruct struct) {
-        String link = buildLink(struct.getSwitchIp(), struct.getVlan());
+        String link = buildLink(struct.getSwitchIp(), String.format("/api/running/ftos/interface/vlan/%s", struct.getVlan()));
         HttpHeaders headers = createBasicAuthenticationHeader(struct);
         HttpEntity<String> request = new HttpEntity<>(headers);
         ResponseEntity rsp = rest.exchange(link, HttpMethod.GET, request, String.class);
+        logger.debug(String.format("http get: %s", link));
 
         if (rsp.getStatusCode() == HttpStatus.NOT_FOUND) {
             PortInfo port = new PortInfo(struct);
-            XmlObject xml = new XmlObject("vlan").putElement("vlan-id", String.valueOf(struct.getVlan())).putElement("tagged",
-                    new XmlObject(port.interfaceType).putElement("name", port.port)
-            ).putElement("shutdown", "false");
-            request = new HttpEntity<>(xml.toString(), headers);
-            link = buildLink(struct.getSwitchIp(), null);
-            rsp = rest.exchange(link, HttpMethod.GET, request, String.class);
-            if (rsp.getStatusCode() != HttpStatus.OK) {
+            XmlObject xml = new XmlObject("vlan").putElement("vlan-id",
+                    new XmlObject("vlan-id").setText(String.valueOf(struct.getVlan()))).putElement("untagged",
+                    new XmlObject("untagged").putElement(port.interfaceType, new XmlObject(port.interfaceType)
+                            .putElement("name", new XmlObject("name").setText(port.port)))
+            ).putElement("shutdown", new XmlObject("shutdown").setText("false"));
+            request = new HttpEntity<>(xml.dump(), headers);
+            link = buildLink(struct.getSwitchIp(), String.format("/api/running/ftos/interface/"));
+            logger.debug(String.format("http get: %s, body: %s", link, request));
+            rsp = rest.exchange(link, HttpMethod.POST, request, String.class);
+            if (!successHttpStatusCode.contains(rsp.getStatusCode())) {
                 throw new CloudRuntimeException(String.format("unable to create vlan[%s] on force10 switch[ip:%s]. HTTP status code:%s, body dump:%s",
-                        struct.getVlan(), rsp.getStatusCode(), struct.getSwitchIp(), rsp.getBody()));
+                        struct.getVlan(), struct.getSwitchIp(),rsp.getStatusCode(), rsp.getBody()));
+            } else {
+                logger.debug(String.format("successfully programmed vlan[%s] on Force10[ip:%s, port:%s]. http response[status code:%s, body:%s]",
+                        struct.getVlan(), struct.getSwitchIp(), struct.getPort(), rsp.getStatusCode(), rsp.getBody()));
             }
-        } else if (rsp.getStatusCode() == HttpStatus.OK) {
+        } else if (successHttpStatusCode.contains(rsp.getStatusCode())) {
             PortInfo port = new PortInfo(struct);
             XmlObject xml = XmlObjectParser.parseFromString((String)rsp.getBody());
-            List<XmlObject> ports = xml.getAsList("tagged.tengigabitethernet");
-            ports.addAll(xml.<XmlObject>getAsList("tagged.gigabitethernet"));
-            ports.addAll(xml.<XmlObject>getAsList("tagged.fortyGigE"));
+            List<XmlObject> ports = xml.getAsList("untagged.tengigabitethernet");
+            ports.addAll(xml.<XmlObject>getAsList("untagged.gigabitethernet"));
+            ports.addAll(xml.<XmlObject>getAsList("untagged.fortyGigE"));
             for (XmlObject pxml : ports) {
                 XmlObject name = pxml.get("name");
                 if (port.port.equals(name.getText())) {
@@ -98,14 +131,26 @@ public class Force10BaremetalSwitchBackend implements BaremetalSwitchBackend {
                 }
             }
 
-            XmlObject tag = xml.get("tagged");
-            tag.putElement(port.interfaceType, new XmlObject("name").setText(port.port));
-            request = new HttpEntity<>(xml.toString(), headers);
-            link = buildLink(struct.getSwitchIp(), struct.getVlan());
+            xml.removeElement("mtu");
+            xml.setText(null);
+            XmlObject tag = xml.get("untagged");
+            if (tag == null) {
+                tag = new XmlObject("untagged");
+                xml.putElement("untagged", tag);
+            }
+
+            tag.putElement(port.interfaceType, new XmlObject(port.interfaceType)
+                    .putElement("name", new XmlObject("name").setText(port.port)));
+            request = new HttpEntity<>(xml.dump(), headers);
+            link = buildLink(struct.getSwitchIp(), String.format("/api/running/ftos/interface/vlan/%s", struct.getVlan()));
+            logger.debug(String.format("http get: %s, body: %s", link, request));
             rsp = rest.exchange(link, HttpMethod.PUT, request, String.class);
-            if (rsp.getStatusCode() != HttpStatus.NO_CONTENT) {
+            if (!successHttpStatusCode.contains(rsp.getStatusCode())) {
                 throw new CloudRuntimeException(String.format("failed to program vlan[%s] for port[%s] on force10[ip:%s]. http status:%s, body dump:%s",
                         struct.getVlan(), struct.getPort(), struct.getSwitchIp(), rsp.getStatusCode(), rsp.getBody()));
+            } else {
+                logger.debug(String.format("successfully join port[%s] into vlan[%s] on Force10[ip:%s]. http response[status code:%s, body:%s]",
+                        struct.getPort(), struct.getVlan(), struct.getSwitchIp(), rsp.getStatusCode(), rsp.getBody()));
             }
         } else {
             throw new CloudRuntimeException(String.format("force10[ip:%s] returns unexpected error[%s] when http getting %s, body dump:%s",
@@ -115,18 +160,19 @@ public class Force10BaremetalSwitchBackend implements BaremetalSwitchBackend {
 
     @Override
     public void removePortFromVlan(BaremetalVlanStruct struct) {
-        String link = buildLink(struct.getSwitchIp(), struct.getVlan());
+        String link = buildLink(struct.getSwitchIp(), String.format("/api/running/ftos/interface/vlan/%s", struct.getVlan()));
         HttpHeaders headers = createBasicAuthenticationHeader(struct);
         HttpEntity<String> request = new HttpEntity<>(headers);
+        logger.debug(String.format("http get: %s, body: %s", link, request));
         ResponseEntity rsp = rest.exchange(link, HttpMethod.GET, request, String.class);
         if (rsp.getStatusCode() == HttpStatus.NOT_FOUND) {
             logger.debug(String.format("vlan[%s] has been deleted on force10[ip:%s], no need to remove the port[%s] anymore", struct.getVlan(), struct.getSwitchIp(), struct.getPort()));
         } else if (rsp.getStatusCode() == HttpStatus.OK) {
             PortInfo port = new PortInfo(struct);
             XmlObject xml = XmlObjectParser.parseFromString((String)rsp.getBody());
-            List<XmlObject> ports = xml.getAsList("tagged.tengigabitethernet");
-            ports.addAll(xml.<XmlObject>getAsList("tagged.gigabitethernet"));
-            ports.addAll(xml.<XmlObject>getAsList("tagged.fortyGigE"));
+            List<XmlObject> ports = xml.getAsList("untagged.tengigabitethernet");
+            ports.addAll(xml.<XmlObject>getAsList("untagged.gigabitethernet"));
+            ports.addAll(xml.<XmlObject>getAsList("untagged.fortyGigE"));
             List<XmlObject> newPorts = new ArrayList<>();
             boolean needRemove = false;
             for (XmlObject pxml : ports) {
@@ -143,11 +189,19 @@ public class Force10BaremetalSwitchBackend implements BaremetalSwitchBackend {
                 return;
             }
 
-            xml.putElement("tagged", newPorts);
-
-            request = new HttpEntity<>(xml.toString(), headers);
+            xml.setText(null);
+            xml.removeElement("mtu");
+            XmlObject tagged = xml.get("untagged");
+            tagged.removeAllChildren();
+            for (XmlObject p : newPorts) {
+                tagged.putElement(p.getTag(), p);
+            }
+
+
+            request = new HttpEntity<>(xml.dump(), headers);
+            logger.debug(String.format("http get: %s, body: %s", link, request));
             rsp = rest.exchange(link, HttpMethod.PUT, request, String.class);
-            if (rsp.getStatusCode() != HttpStatus.NO_CONTENT) {
+            if (!successHttpStatusCode.contains(rsp.getStatusCode())) {
                 throw new CloudRuntimeException(String.format("failed to program vlan[%s] for port[%s] on force10[ip:%s]. http status:%s, body dump:%s",
                         struct.getVlan(), struct.getPort(), struct.getSwitchIp(), rsp.getStatusCode(), rsp.getBody()));
             } else {
@@ -166,6 +220,8 @@ public class Force10BaremetalSwitchBackend implements BaremetalSwitchBackend {
         String base64Creds = new String(base64CredsBytes);
         HttpHeaders headers = new HttpHeaders();
         headers.add("Authorization", "Basic " + base64Creds);
+        headers.setAccept(Arrays.asList(MediaType.ALL));
+        headers.setContentType(MediaType.valueOf("application/vnd.yang.data+xml"));
         return  headers;
     }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1de0cb70/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/PrepareKickstartPxeServerCommand.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/PrepareKickstartPxeServerCommand.java b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/PrepareKickstartPxeServerCommand.java
new file mode 100755
index 0000000..4f59a83
--- /dev/null
+++ b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/PrepareKickstartPxeServerCommand.java
@@ -0,0 +1,83 @@
+// 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.
+//
+// Automatically generated by addcopyright.py at 01/29/2013
+package com.cloud.baremetal.networkservice;
+
+import com.cloud.agent.api.Command;
+
+public class PrepareKickstartPxeServerCommand extends Command {
+    private String ksFile;
+    private String templateUuid;
+    private String mac;
+    private String ksDevice;
+    private String kernel;
+    private String initrd;
+
+    @Override
+    public boolean executeInSequence() {
+        return true;
+    }
+
+    public String getKsFile() {
+        return ksFile;
+    }
+
+    public void setKsFile(String ksFile) {
+        this.ksFile = ksFile;
+    }
+
+    public String getKernel() {
+        return kernel;
+    }
+
+    public void setKernel(String kernel) {
+        this.kernel = kernel;
+    }
+
+    public String getInitrd() {
+        return initrd;
+    }
+
+    public void setInitrd(String initrd) {
+        this.initrd = initrd;
+    }
+
+    public String getTemplateUuid() {
+        return templateUuid;
+    }
+
+    public void setTemplateUuid(String templateUuid) {
+        this.templateUuid = templateUuid;
+    }
+
+    public String getMac() {
+        return mac;
+    }
+
+    public void setMac(String mac) {
+        this.mac = mac;
+    }
+
+    public String getKsDevice() {
+        return ksDevice;
+    }
+
+    public void setKsDevice(String ksDevice) {
+        this.ksDevice = ksDevice;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1de0cb70/plugins/hypervisors/baremetal/src/org/apache/cloudstack/api/BaremetalProvisionDoneNotificationCmd.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/baremetal/src/org/apache/cloudstack/api/BaremetalProvisionDoneNotificationCmd.java b/plugins/hypervisors/baremetal/src/org/apache/cloudstack/api/BaremetalProvisionDoneNotificationCmd.java
new file mode 100755
index 0000000..a5248aa
--- /dev/null
+++ b/plugins/hypervisors/baremetal/src/org/apache/cloudstack/api/BaremetalProvisionDoneNotificationCmd.java
@@ -0,0 +1,87 @@
+// 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.
+//
+package org.apache.cloudstack.api;
+
+import com.cloud.baremetal.manager.BaremetalManager;
+import com.cloud.event.EventTypes;
+import com.cloud.exception.ConcurrentOperationException;
+import com.cloud.exception.InsufficientCapacityException;
+import com.cloud.exception.NetworkRuleConflictException;
+import com.cloud.exception.ResourceAllocationException;
+import com.cloud.exception.ResourceUnavailableException;
+import org.apache.cloudstack.acl.RoleType;
+import org.apache.cloudstack.api.response.SuccessResponse;
+import org.apache.cloudstack.context.CallContext;
+
+import javax.inject.Inject;
+import org.apache.log4j.Logger;
+
+/**
+ * Created by frank on 9/17/14.
+ */
+@APICommand(name = "notifyBaremetalProvisionDone", description = "Notify provision has been done on a host. This api is for baremetal virtual router service, not for end user", responseObject = SuccessResponse.class,
+        requestHasSensitiveInfo = false, responseHasSensitiveInfo = false, authorized = {RoleType.User})
+public class BaremetalProvisionDoneNotificationCmd extends BaseAsyncCmd {
+    public static final Logger s_logger = Logger.getLogger(BaremetalProvisionDoneNotificationCmd.class);
+    private static final String s_name = "baremetalprovisiondone";
+
+    @Inject
+    private BaremetalManager bmMgr;
+
+    @Parameter(name="mac", required = true, description = "mac of the nic used for provision")
+    private String mac;
+
+    @Override
+    public String getEventType() {
+        return EventTypes.EVENT_BAREMETAL_PROVISION_DONE;
+    }
+
+    @Override
+    public String getEventDescription() {
+        return "notify management server that baremetal provision has been done on a host";
+    }
+
+    @Override
+    public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException, NetworkRuleConflictException {
+        try {
+            bmMgr.notifyProvisionDone(this);
+            this.setResponseObject(new SuccessResponse(getCommandName()));
+        } catch (Exception e) {
+            s_logger.warn(String.format("unable to notify baremetal provision done[mac:%s]", mac), e);
+            throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, e.getMessage());
+        }
+    }
+
+    public String getMac() {
+        return mac;
+    }
+
+    public void setMac(String mac) {
+        this.mac = mac;
+    }
+
+    @Override
+    public String getCommandName() {
+        return s_name;
+    }
+
+    @Override
+    public long getEntityOwnerId() {
+        return CallContext.current().getCallingAccount().getId();
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1de0cb70/server/src/com/cloud/configuration/Config.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/configuration/Config.java b/server/src/com/cloud/configuration/Config.java
index 71f5c5b..3710e0a 100755
--- a/server/src/com/cloud/configuration/Config.java
+++ b/server/src/com/cloud/configuration/Config.java
@@ -1848,29 +1848,37 @@ public enum Config {
             "The maximum number of retrying times to search for an available IPv6 address in the table",
             null),
 
-    BaremetalEnableCompleteNotification(
+    BaremetalInternalStorageServer(
+            "Advanced",
+            ManagementServer.class,
+            String.class,
+            "baremetal.internal.storage.server.ip",
+            null,
+            "the ip address of server that stores kickstart file, kernel, initrd, ISO for advanced networking baremetal provisioning",
+            null),
+    BaremetalProvisionDoneNotificationEnabled(
             "Advanced",
             ManagementServer.class,
             Boolean.class,
-            "baremetal.provision.done.notification",
-            "false",
-            "Enable provision done notification through virtual router",
+            "baremetal.provision.done.notification.enabled",
+            "true",
+            "whether to enable baremetal provison done notification",
             null),
-    BaremetalPeerHypervisorType(
+    BaremetalProvisionDoneNotificationTimeout(
             "Advanced",
             ManagementServer.class,
-            String.class,
-            "baremetal.peer.hypervisor.type",
-            "Vmware",
-            "Hypervisor[Xenserver/KVM/VMWare] used to spring up virtual router for baremetal instances. The cluster having this hypervisor type must be in the same zone with baremetal cluster",
+            Integer.class,
+            "baremetal.provision.done.notification.timeout",
+            "1800",
+            "the max time to wait before treating a baremetal provision as failure if no provision done notification is not received, in secs",
             null),
-    BaremetalInternalStorageServer(
+    BaremetalProvisionDoneNotificationPort(
             "Advanced",
             ManagementServer.class,
-            String.class,
-            "baremetal.internal.storage.server.ip",
-            null,
-            "the ip address of server that stores kickstart file, kernel, initrd, ISO for advanced networking baremetal provisioning",
+            Integer.class,
+            "baremetal.provision.done.notification.port",
+            "8080",
+            "the port that listens baremetal provision done notification. Should be the same to port management server listening on for now. Please change it to management server port if it's not default 8080",
             null),
     ExternalBaremetalSystemUrl(
             "Advanced",

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1de0cb70/server/src/com/cloud/deploy/DeploymentPlanningManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/deploy/DeploymentPlanningManagerImpl.java b/server/src/com/cloud/deploy/DeploymentPlanningManagerImpl.java
index 3329ff2..bfb33b0 100755
--- a/server/src/com/cloud/deploy/DeploymentPlanningManagerImpl.java
+++ b/server/src/com/cloud/deploy/DeploymentPlanningManagerImpl.java
@@ -404,6 +404,15 @@ StateListener<State, VirtualMachine.Event, VirtualMachine> {
                             s_logger.debug("The last host of this VM is UP and has enough capacity");
                             s_logger.debug("Now checking for suitable pools under zone: " + host.getDataCenterId()
                                     + ", pod: " + host.getPodId() + ", cluster: " + host.getClusterId());
+
+                            Pod pod = _podDao.findById(host.getPodId());
+                            Cluster cluster = _clusterDao.findById(host.getClusterId());
+                            if (vm.getHypervisorType() == HypervisorType.BareMetal) {
+                                DeployDestination dest = new DeployDestination(dc, pod, cluster, host, new HashMap<Volume, StoragePool>());
+                                s_logger.debug("Returning Deployment Destination: " + dest);
+                                return dest;
+                            }
+
                             // search for storage under the zone, pod, cluster
                             // of
                             // the last host.
@@ -423,8 +432,6 @@ StateListener<State, VirtualMachine.Event, VirtualMachine> {
                                         suitableHosts, suitableVolumeStoragePools, avoids,
                                         getPlannerUsage(planner, vmProfile, plan, avoids), readyAndReusedVolumes);
                                 if (potentialResources != null) {
-                                    Pod pod = _podDao.findById(host.getPodId());
-                                    Cluster cluster = _clusterDao.findById(host.getClusterId());
                                     Map<Volume, StoragePool> storageVolMap = potentialResources.second();
                                     // remove the reused vol<->pool from
                                     // destination, since we don't have to

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1de0cb70/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
index be7cb37..315bdde 100644
--- a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
+++ b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
@@ -1506,6 +1506,8 @@ Configurable, StateListener<State, VirtualMachine.Event, VirtualMachine> {
             } else {
                 buf.append(String.format(" baremetalnotificationsecuritykey=%s", user.getSecretKey()));
                 buf.append(String.format(" baremetalnotificationapikey=%s", user.getApiKey()));
+                buf.append(" host=").append(ApiServiceConfiguration.ManagementHostIPAdr.value());
+                buf.append(" port=").append(_configDao.getValue(Config.BaremetalProvisionDoneNotificationPort.key()));
             }
         }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1de0cb70/server/src/com/cloud/resource/ResourceManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/resource/ResourceManagerImpl.java b/server/src/com/cloud/resource/ResourceManagerImpl.java
index cdad91e..c7ba80a 100755
--- a/server/src/com/cloud/resource/ResourceManagerImpl.java
+++ b/server/src/com/cloud/resource/ResourceManagerImpl.java
@@ -1631,21 +1631,6 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager,
                 clusterId = c.getId();
             }
         }
-        if (startup instanceof StartupRoutingCommand) {
-            StartupRoutingCommand ssCmd = ((StartupRoutingCommand)startup);
-            List<String> implicitHostTags = ssCmd.getHostTags();
-            if (!implicitHostTags.isEmpty()) {
-                if (hostTags == null) {
-                    hostTags = _hostTagsDao.gethostTags(host.getId());
-                }
-                if (hostTags != null) {
-                    implicitHostTags.removeAll(hostTags);
-                    hostTags.addAll(implicitHostTags);
-                } else {
-                    hostTags = implicitHostTags;
-                }
-            }
-        }
 
         if (startup instanceof StartupRoutingCommand) {
             StartupRoutingCommand ssCmd = ((StartupRoutingCommand)startup);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1de0cb70/server/src/com/cloud/storage/VolumeApiServiceImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/VolumeApiServiceImpl.java b/server/src/com/cloud/storage/VolumeApiServiceImpl.java
index 9f132c3..e089b77 100644
--- a/server/src/com/cloud/storage/VolumeApiServiceImpl.java
+++ b/server/src/com/cloud/storage/VolumeApiServiceImpl.java
@@ -1230,10 +1230,9 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
 
         // Check that the volume ID is valid
         VolumeInfo volumeToAttach = volFactory.getVolume(volumeId);
-
         // Check that the volume is a data volume
-        if (volumeToAttach == null || !(volumeToAttach.getVolumeType() == Volume.Type.DATADISK)) {
-            throw new InvalidParameterValueException("Please specify a volume with the valid type: " + Volume.Type.DATADISK.toString());
+        if (volumeToAttach == null || !(volumeToAttach.getVolumeType() == Volume.Type.DATADISK || volumeToAttach.getVolumeType() == Volume.Type.ROOT)) {
+            throw new InvalidParameterValueException("Please specify a volume with the valid type: " + Volume.Type.ROOT.toString() + " or " + Volume.Type.DATADISK.toString());
         }
 
         // Check that the volume is not currently attached to any VM
@@ -1516,10 +1515,9 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
             throw new InvalidParameterValueException("Please specify a VM that is either running or stopped.");
         }
 
-        // Check that the volume is a data volume.
-        // TODO - Disabling root volume detach for now, enable it back in 4.6
-        if (volume.getVolumeType() != Volume.Type.DATADISK) {
-            throw new InvalidParameterValueException("Please specify volume of type " + Volume.Type.DATADISK.toString());
+        // Check that the volume is a data/root volume
+        if (!(volume.getVolumeType() == Volume.Type.ROOT || volume.getVolumeType() == Volume.Type.DATADISK)) {
+            throw new InvalidParameterValueException("Please specify volume of type " + Volume.Type.DATADISK.toString() + " or " + Volume.Type.ROOT.toString());
         }
 
         // Root volume detach is allowed for following hypervisors: Xen/KVM/VmWare

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1de0cb70/server/test/com/cloud/storage/VolumeApiServiceImplTest.java
----------------------------------------------------------------------
diff --git a/server/test/com/cloud/storage/VolumeApiServiceImplTest.java b/server/test/com/cloud/storage/VolumeApiServiceImplTest.java
index 3d2de4e..c60aa50 100644
--- a/server/test/com/cloud/storage/VolumeApiServiceImplTest.java
+++ b/server/test/com/cloud/storage/VolumeApiServiceImplTest.java
@@ -30,6 +30,7 @@ import javax.inject.Inject;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Rule;
+import org.junit.Test;
 import org.junit.rules.ExpectedException;
 import org.mockito.Mock;
 import org.mockito.Mockito;
@@ -48,6 +49,7 @@ import org.apache.cloudstack.framework.jobs.impl.AsyncJobVO;
 import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
 import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
 
+import com.cloud.exception.InvalidParameterValueException;
 import com.cloud.hypervisor.Hypervisor.HypervisorType;
 import com.cloud.storage.dao.VolumeDao;
 import com.cloud.user.Account;
@@ -241,7 +243,7 @@ public class VolumeApiServiceImplTest {
      * @throws Exception
      */
 
-    //@Test(expected = InvalidParameterValueException.class)
+    @Test(expected = InvalidParameterValueException.class)
     public void testDetachVolumeFromRunningVm() throws NoSuchFieldException, IllegalAccessException {
         Field dedicateIdField = _detachCmdClass.getDeclaredField("id");
         dedicateIdField.setAccessible(true);
@@ -249,7 +251,7 @@ public class VolumeApiServiceImplTest {
         _svc.detachVolumeFromVM(detachCmd);
     }
 
-    //@Test(expected = InvalidParameterValueException.class)
+    @Test(expected = InvalidParameterValueException.class)
     public void testDetachVolumeFromStoppedHyperVVm() throws NoSuchFieldException, IllegalAccessException {
         Field dedicateIdField = _detachCmdClass.getDeclaredField("id");
         dedicateIdField.setAccessible(true);
@@ -257,7 +259,7 @@ public class VolumeApiServiceImplTest {
         _svc.detachVolumeFromVM(detachCmd);
     }
 
-    //@Test(expected = InvalidParameterValueException.class)
+    @Test(expected = InvalidParameterValueException.class)
     public void testDetachVolumeOfManagedDataStore() throws NoSuchFieldException, IllegalAccessException {
         Field dedicateIdField = _detachCmdClass.getDeclaredField("id");
         dedicateIdField.setAccessible(true);
@@ -268,7 +270,7 @@ public class VolumeApiServiceImplTest {
     @Rule
     public ExpectedException thrown = ExpectedException.none();
 
-    //@Test
+    @Test
     public void testDetachVolumeFromStoppedXenVm() throws NoSuchFieldException, IllegalAccessException {
         thrown.expect(NullPointerException.class);
         Field dedicateIdField = _detachCmdClass.getDeclaredField("id");
@@ -282,43 +284,43 @@ public class VolumeApiServiceImplTest {
      */
 
     // Negative test - try to attach non-root non-datadisk volume
-    //@Test(expected = InvalidParameterValueException.class)
+    @Test(expected = InvalidParameterValueException.class)
     public void attachIncorrectDiskType() throws NoSuchFieldException, IllegalAccessException {
         _svc.attachVolumeToVM(1L, 5L, 0L);
     }
 
     // Negative test - attach root volume to running vm
-    //@Test(expected = InvalidParameterValueException.class)
+    @Test(expected = InvalidParameterValueException.class)
     public void attachRootDiskToRunningVm() throws NoSuchFieldException, IllegalAccessException {
         _svc.attachVolumeToVM(1L, 6L, 0L);
     }
 
     // Negative test - attach root volume to non-xen vm
-    //@Test(expected = InvalidParameterValueException.class)
+    @Test(expected = InvalidParameterValueException.class)
     public void attachRootDiskToHyperVm() throws NoSuchFieldException, IllegalAccessException {
         _svc.attachVolumeToVM(3L, 6L, 0L);
     }
 
     // Negative test - attach root volume from the managed data store
-    //@Test(expected = InvalidParameterValueException.class)
+    @Test(expected = InvalidParameterValueException.class)
     public void attachRootDiskOfManagedDataStore() throws NoSuchFieldException, IllegalAccessException {
         _svc.attachVolumeToVM(2L, 7L, 0L);
     }
 
     // Negative test - root volume can't be attached to the vm already having a root volume attached
-    //@Test(expected = InvalidParameterValueException.class)
+    @Test(expected = InvalidParameterValueException.class)
     public void attachRootDiskToVmHavingRootDisk() throws NoSuchFieldException, IllegalAccessException {
         _svc.attachVolumeToVM(4L, 6L, 0L);
     }
 
     // Negative test - root volume in uploaded state can't be attached
-    //@Test(expected = InvalidParameterValueException.class)
+    @Test(expected = InvalidParameterValueException.class)
     public void attachRootInUploadedState() throws NoSuchFieldException, IllegalAccessException {
         _svc.attachVolumeToVM(2L, 8L, 0L);
     }
 
     // Positive test - attach ROOT volume in correct state, to the vm not having root volume attached
-    //@Test
+    @Test
     public void attachRootVolumePositive() throws NoSuchFieldException, IllegalAccessException {
         thrown.expect(NullPointerException.class);
         _svc.attachVolumeToVM(2L, 6L, 0L);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1de0cb70/systemvm/patches/debian/config/etc/dnsmasq.conf.tmpl
----------------------------------------------------------------------
diff --git a/systemvm/patches/debian/config/etc/dnsmasq.conf.tmpl b/systemvm/patches/debian/config/etc/dnsmasq.conf.tmpl
index 447e748..28b598c 100644
--- a/systemvm/patches/debian/config/etc/dnsmasq.conf.tmpl
+++ b/systemvm/patches/debian/config/etc/dnsmasq.conf.tmpl
@@ -415,7 +415,7 @@ dhcp-option=vendor:MSFT,2,1i
 # this is you want to boot machines over the network and you will need
 # a TFTP server; either dnsmasq's built in TFTP server or an
 # external one. (See below for how to enable the TFTP server.)
-#dhcp-boot=pxelinux.0
+dhcp-boot=pxelinux.0
 
 # The same as above, but use custom tftp-server instead machine running dnsmasq
 #dhcp-boot=pxelinux,server.name,192.168.1.100
@@ -472,10 +472,10 @@ dhcp-option=vendor:MSFT,2,1i
 
 
 # Enable dnsmasq's built-in TFTP server
-#enable-tftp
+enable-tftp
 
 # Set the root directory for files available via FTP.
-#tftp-root=/var/ftpd
+tftp-root=/opt/tftpboot
 
 # Make the TFTP server more secure: with this set, only files owned by
 # the user dnsmasq is running as will be send over the net.

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1de0cb70/systemvm/patches/debian/config/opt/cloud/bin/baremetal_snat.sh
----------------------------------------------------------------------
diff --git a/systemvm/patches/debian/config/opt/cloud/bin/baremetal_snat.sh b/systemvm/patches/debian/config/opt/cloud/bin/baremetal_snat.sh
index f35a16f..22e5669 100755
--- a/systemvm/patches/debian/config/opt/cloud/bin/baremetal_snat.sh
+++ b/systemvm/patches/debian/config/opt/cloud/bin/baremetal_snat.sh
@@ -21,11 +21,12 @@ set +u
 
 mgmt_nic_ip=$1
 internal_server_ip=$2
+gateway_ip=$3
 
 ip route | grep "$internal_server_ip" > /dev/null
 
 if [ $? -ne 0 ]; then
-    ip route add $internal_server_ip via $mgmt_nic_ip
+    ip route add $internal_server_ip via $gateway_ip
 fi
 
 iptables-save | grep -- "-A POSTROUTING -d $internal_server_ip" > /dev/null
@@ -33,3 +34,21 @@ iptables-save | grep -- "-A POSTROUTING -d $internal_server_ip" > /dev/null
 if [ $? -ne 0 ]; then
     iptables -t nat -A POSTROUTING -d $internal_server_ip -j SNAT --to-source $mgmt_nic_ip
 fi
+
+
+iptables-save | grep -- "-A INPUT -i eth0 -p udp -m udp --dport 69 -j ACCEPT" > /dev/null
+if [ $? -ne 0 ]; then
+    iptables -I INPUT -i eth0 -p udp -m udp --dport 69 -j ACCEPT
+fi
+
+iptables-save | grep -- "-A FORWARD -i eth1 -o eth0 -j ACCEPT" > /dev/null
+if [ $? -ne 0 ]; then
+    iptables -A FORWARD -i eth1 -o eth0 -j ACCEPT
+fi
+
+rule="-A FORWARD -d $internal_server_ip/32 -i eth0 -o eth1 -j ACCEPT"
+iptables-save | grep -- "$rule" > /dev/null
+if [ $? -ne 0 ]; then 
+    iptables -I FORWARD -d $internal_server_ip/32 -i eth0 -o eth1 -j ACCEPT
+fi
+

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1de0cb70/systemvm/patches/debian/config/opt/cloud/bin/prepare_pxe.sh
----------------------------------------------------------------------
diff --git a/systemvm/patches/debian/config/opt/cloud/bin/prepare_pxe.sh b/systemvm/patches/debian/config/opt/cloud/bin/prepare_pxe.sh
index bd9ece6..5bc1a93 100755
--- a/systemvm/patches/debian/config/opt/cloud/bin/prepare_pxe.sh
+++ b/systemvm/patches/debian/config/opt/cloud/bin/prepare_pxe.sh
@@ -40,6 +40,20 @@ tmpt_uuid=$3
 pxe_cfg_filename=$4
 ks_file=$5
 
+kernel_path=$tmpt_uuid/$kernel_file_name
+initrd_path=$tmpt_uuid/$initrd_file_name
+
+cat > $PXELINUX_CFG_DIR/$pxe_cfg_filename <<EOF
+DEFAULT default
+PROMPT 1
+TIMEOUT 26
+DISPLAY boot.msg
+LABEL default
+KERNEL $kernel_path
+APPEND ramdisk_size=66000 initrd=$initrd_path ks=$ks_file
+
+EOF
+
 tmpt_dir=$TFTP_ROOT/$tmpt_uuid
 if [ -d $tmpt_dir ]; then
     success
@@ -47,9 +61,6 @@ fi
 
 mkdir -p $tmpt_dir
 
-kernel_path=$tmpt_uuid/$kernel_file_name
-initrd_path=$tmpt_uuid/$initrd_file_name
-
 mnt_path=/tmp/$(uuid)
 
 mkdir -p $mnt_path
@@ -61,17 +72,6 @@ mount `dirname $initrd_nfs_path` $mnt_path
 cp -f $mnt_path/$initrd_file_name $tmpt_dir/$initrd_file_name
 umount $mnt_path
 
-cat > $PXELINUX_CFG_DIR/$pxe_cfg_filename <<EOF
-DEFAULT default
-PROMPT 1
-TIMEOUT 26
-DISPLAY boot.msg
-LABEL default
-KERNEL $kernel_path
-APPEND ramdisk_size=66000 initrd=$initrd_path ks=$ks_file
-
-EOF
-
 success
 
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1de0cb70/test/integration/component/test_deploy_vgpu_vm.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_deploy_vgpu_vm.py b/test/integration/component/test_deploy_vgpu_vm.py
index 6cd6c2c..0284eab 100644
--- a/test/integration/component/test_deploy_vgpu_vm.py
+++ b/test/integration/component/test_deploy_vgpu_vm.py
@@ -1186,282 +1186,6 @@ class TestvGPUWindowsVm(cloudstackTestCase):
 
 
 
-    def new_template_register(self,guestostype):
-
-        template1 = get_windows_template(self.apiclient, self.zone.id ,ostype_desc=guestostype)
-
-        if  template1 == FAILED:
-            if "http://pleaseupdateURL/dummy.vhd" in cls.testdata["vgpu"] [guestostype]["url"]:
-                raise unittest.SkipTest("Check Test Data file if it has the valid template URL")
-            template1 = Template.register(
-                   self.apiclient,
-                   self.testdata["vgpu"] [guestostype],
-                   hypervisor = "XenServer",
-                   zoneid=cls.zone.id,
-                   domainid=cls.account.domainid,
-                   account=cls.account.name
-                   )
-            timeout = self.testdata["vgpu"]["timeout"]
-
-            while True:
-                  time.sleep(self.testdata["vgpu"]["sleep"])
-                  list_template_response = Template.list(
-                       self.apiclient,
-                       templatefilter=\
-                       self.testdata["templatefilter"],
-                       id=template1.id
-                        )
-                  if (isinstance(list_template_response, list)) is not True:
-                      raise unittest.SkipTest("Check list template api response returns a valid list")
-
-                  if len(list_template_response) is None :
-                      raise unittest.SkipTest("Check template registered is in List Templates")
-
-                  template_response = list_template_response[0]
-                  if template_response.isready == True:
-                      break
-                  if timeout == 0:
-                      raise unittest.SkipTest("Failed to download template(ID: %s)" % template_response.id)
-
-                  timeout = timeout - 1
-        return(template1.id)
-
-    def deploy_vm_lifecycle(self):
-        """
-        Create Service Offerings for Both K1 and K2 cards to be used for VM life cycle tests
-        """
-
-        if(self.k1hosts != 0):
-            if(self.k140qgpuhosts != 0):
-                gtype = "GRID K140Q"
-            elif(self.k120qgpuhosts != 0):
-                gtype = "GRID K120Q"
-            elif(self.k100gpuhosts !=0):
-                gtype = "GRID K100"
-            else:
-                gtype = "passthrough"
-
-            self.testdata["vgpu"]["service_offerings"][gtype]["serviceofferingdetails"] = [{'pciDevice':'Group of NVIDIA Corporation GK107GL [GRID K1] GPUs'},
-                                                                                       {'vgpuType':gtype}]
-            try:
-               self.__class__.k100_vgpu_service_offering = ServiceOffering.create(
-                                                                    self.apiclient,
-                                                                    self.testdata["vgpu"]["service_offerings"][gtype]
-                                                                    )
-            except Exception as e:
-               self.fail("Failed to create the service offering, %s" % e)
-
-        if(self.k2hosts != 0):
-            if(self.k240qgpuhosts != 0):
-                gtype = "GRID K240Q"
-            elif(cls.k220qgpuhosts != 0):
-                gtype = "GRID K220Q"
-            elif(self.k200gpuhosts !=0):
-                gtype = "GRID K200"
-            else:
-                gtype = "passthrough"
-
-            self.testdata["vgpu"]["service_offerings"][gtype]["serviceofferingdetails"] = [{'pciDevice': 'Group of NVIDIA Corporation GK104GL [GRID K2] GPUs'},
-                                                                                       {'vgpuType':gtype}]
-            try:
-               self.__class__.k200_vgpu_service_offering = ServiceOffering.create(
-                                                                    self.apiclient,
-                                                                    self.testdata["vgpu"]["service_offerings"][gtype]
-                                                                    )
-            except Exception as e:
-              self.fail("Failed to create the service offering, %s" % e)
-
-        win8templateid=self.new_template_register("Windows 8 (64-bit)")
-        win2012templateid=self.new_template_register("Windows Server 2012 (64-bit)")
-        win7templateid=self.new_template_register("Windows 7 (64-bit)")
-
-        """
-        Create Virtual Machines for Both K1 and K2 cards to be used for VM life cycle tests
-        """
-
-        if(self.k1hosts != 0):
-            self.__class__.vm_k1_card = VirtualMachine.create(
-            self.apiclient,
-            self.testdata["virtual_machine"],
-            accountid=self.account.name,
-            zoneid=self.zone.id,
-            domainid=self.account.domainid,
-            serviceofferingid=self.k100_vgpu_service_offering.id,
-            templateid=win8templateid
-            )
-        if(self.k2hosts !=0):
-            self.__class__.vm_k2_card = VirtualMachine.create(
-            self.apiclient,
-            self.testdata["virtual_machine"],
-            accountid=self.account.name,
-            zoneid=self.zone.id,
-            domainid=self.account.domainid,
-            serviceofferingid=self.k200_vgpu_service_offering.id,
-            templateid=win2012templateid
-            )
-        if(self.k2hosts !=0):
-            self.__class__.vm2_k2_card = VirtualMachine.create(
-            self.apiclient,
-            self.testdata["virtual_machine"],
-            accountid=self.account.name,
-            zoneid=self.zone.id,
-            domainid=self.account.domainid,
-            serviceofferingid=self.k200_vgpu_service_offering.id,
-            templateid=win7templateid
-            )
-        return
-
-
-    def check_gpu_resources_released_vm(self,gpuhostid,vm_vgpu_type,rcapacity):
-        hhosts = list_hosts(
-               self.apiclient,
-               hypervisor="XenServer",
-               id=gpuhostid
-               )
-        self.assertEqual(
-                            isinstance(hhosts, list),
-                            True,
-                            "Check list hosts response returns a valid list"
-                        )
-
-        self.assertNotEqual(
-                            len(hhosts),
-                            0,
-                            "Check Host details are available in List Hosts"
-                        )
-        for ggroup in hhosts:
-               if ggroup.ipaddress not in self.nongpuhosts:
-                  for gp in ggroup.gpugroup:
-                      #if gp.gpugroupname == "Group of NVIDIA Corporation GK104GL [GRID K2] GPUs":
-                         for gptype in gp.vgpu:
-                             if gptype.vgputype==vm_vgpu_type:
-                                self.debug("Latest remainingcapacity is %s and before remainingcapacity is %s"%(gptype.remainingcapacity,rcapacity))
-                                if gptype.remainingcapacity != rcapacity+1:
-                                   self.fail("Host capacity is not updated .GPU resources should be released when VM is stopped/Destroyed ")
-        return
-
-    def check_vm_state(self,vmid):
-        list_vm_response = list_virtual_machines(
-                                                     self.apiclient,
-                                                     id=vmid
-                                                     )
-
-        if list_vm_response is None:
-            return("Expunge")
-        return(list_vm_response[0].state)
-
-    def check_host_vgpu_remaining_capacity(self,gpuhostid,gtype):
-        gputhosts = list_hosts(
-               self.apiclient,
-               hypervisor="XenServer",
-               id=gpuhostid
-               )
-        vgpucapacity=0
-        for ghost in gputhosts:
-            if ghost.gpugroup is not None:
-                        for gp in ghost.gpugroup:
-                            #if gp.gpugroupname == gpucard:
-                               for gptype in gp.vgpu:
-                                   if gptype.vgputype == gtype:
-                                      vgpucapacity=vgpucapacity+gptype.remainingcapacity
-
-        return(vgpucapacity)
-
-    def verify_vm(self,vm_gpu_card):
-        if(vm_gpu_card):
-          vm_gpu_card.getState(
-                                   self.apiclient,
-                                   "Running")
-
-          self.check_for_vGPU_resource(vm_gpu_card.hostid,vm_gpu_card.instancename,vm_gpu_card.serviceofferingid,vm_gpu_card.vgpu)
-
-    def stop_life_cycle_vm (self,vm_gpu_card):
-
-        if(vm_gpu_card):
-          vm_gpu_card.stop(self.apiclient)
-          time.sleep(self.testdata["vgpu"]["sleep"])
-          vm_gpu_card.getState(
-                                   self.apiclient,
-                                   "Stopped")
-
-    def start_life_cycle_vm(self,vm_gpu_card):
-
-        if(vm_gpu_card):
-          vm_gpu_card.start(self.apiclient)
-          time.sleep(self.testdata["vgpu"]["sleep"])
-
-    def restore_life_cycle_vm(self,vm_gpu_card):
-        if(vm_gpu_card):
-          vm_gpu_card.restore(self.apiclient)
-          time.sleep(self.testdata["vgpu"]["sleep"])
-
-    def reboot_life_cycle_vm(self,vm_gpu_card):
-
-        if(vm_gpu_card):
-          vm_gpu_card.reboot(self.apiclient)
-          time.sleep(self.testdata["vgpu"]["sleep"])
-
-    def delete_vm_life_cycle_vm(self,vm_gpu_card):
-        if(vm_gpu_card):
-          vm_gpu_card.delete(self.apiclient)
-          time.sleep(self.testdata["vgpu"]["sleep"])
-          vm_gpu_card.getState(
-                                   self.apiclient,
-                                   "Destroyed")
-
-    def recover_vm_life_cycle_vm(self,vm_gpu_card):
-        if(vm_gpu_card):
-          vm_gpu_card.recover(self.apiclient)
-          vm_gpu_card.getState(
-                                   self.apiclient,
-                                   "Stopped")
-
-
-    def recovervm(self,vm_gpu_card):
-        if self.check_vm_state(vm_gpu_card.id)=="Expunge":
-            raise unittest.SkipTest("VM is already deleted hence skipping")
-        self.recover_vm_life_cycle_vm(vm_gpu_card)
-        self.start_life_cycle_vm(vm_gpu_card)
-        self.verify_vm(vm_gpu_card)
-        return
-
-
-    def startvm(self,vm_gpu_card):
-
-        self.start_life_cycle_vm(vm_gpu_card)
-        self.verify_vm(vm_gpu_card)
-        return
-
-    def stopvm(self,vm_gpu_card):
-
-        rcapacity=self.check_host_vgpu_remaining_capacity(vm_gpu_card.hostid,vm_gpu_card.vgpu)
-        self.stop_life_cycle_vm(vm_gpu_card)
-        self.check_gpu_resources_released_vm(vm_gpu_card.hostid,vm_gpu_card.vgpu,rcapacity)
-        return
-
-    def deletevm(self,vm_gpu_card):
-
-        rcapacity=self.check_host_vgpu_remaining_capacity(vm_gpu_card.hostid,vm_gpu_card.vgpu)
-        hostid=vm_gpu_card.hostid
-        vgputype=vm_gpu_card.vgpu
-        self.delete_vm_life_cycle_vm(vm_gpu_card)
-        self.check_gpu_resources_released_vm(hostid,vgputype,rcapacity)
-        return
-
-    def restorevm(self,vm_gpu_card):
-
-        self.restore_life_cycle_vm(vm_gpu_card)
-        self.verify_vm(vm_gpu_card)
-        return
-
-
-    def rebootvm(self,vm_vgpu_card):
-
-        self.reboot_life_cycle_vm(vm_vgpu_card)
-        self.verify_vm(vm_vgpu_card)
-        return
-
-
     def test_01_list_vgpu_host_details(self):
         """   list vGPU host details  """
         hhosts = list_hosts(
@@ -1770,6 +1494,7 @@ class TestvGPUWindowsVm(cloudstackTestCase):
 
         self.debug("Check if deployed VMs are in running state?")
 
+
         if self.__class__.vm_k1_card is not None:
             self.verify_vm(self.__class__.vm_k1_card)
 
@@ -1779,6 +1504,7 @@ class TestvGPUWindowsVm(cloudstackTestCase):
         if self.__class__.vm2_k2_card is not None:
             self.verify_vm(self.__class__.vm2_k2_card)
 
+
         self.__class__.vmlifecycletest=1
         return
 
@@ -1789,6 +1515,7 @@ class TestvGPUWindowsVm(cloudstackTestCase):
         if self.__class__.vmlifecycletest==0:
             raise unittest.SkipTest("VM Life Cycle Deploy VM test failed hence skipping")
 
+
         if self.__class__.vm_k1_card:
             self.stopvm(self.__class__.vm_k1_card)
 
@@ -1798,6 +1525,7 @@ class TestvGPUWindowsVm(cloudstackTestCase):
         if self.__class__.vm2_k2_card:
             self.stopvm(self.__class__.vm2_k2_card)
 
+
         return
 
     @attr(tags = ['advanced', 'basic' , 'vgpu'], required_hardware="true")
@@ -1807,6 +1535,7 @@ class TestvGPUWindowsVm(cloudstackTestCase):
         if self.__class__.vmlifecycletest==0:
             raise unittest.SkipTest("VM Life Cycle Deploy VM test failed hence skipping")
 
+
         if self.__class__.vm_k1_card:
             self.startvm(self.__class__.vm_k1_card)
 
@@ -1826,6 +1555,7 @@ class TestvGPUWindowsVm(cloudstackTestCase):
         if self.__class__.vmlifecycletest==0:
             raise unittest.SkipTest("VM Life Cycle Deploy VM test failed hence skipping")
 
+
         if self.__class__.vm_k1_card:
             self.restorevm(self.__class__.vm_k1_card)
         if self.__class__.vm_k2_card:
@@ -1833,6 +1563,7 @@ class TestvGPUWindowsVm(cloudstackTestCase):
         if self.__class__.vm2_k2_card:
             self.restorevm(self.__class__.vm2_k2_card)
 
+
         return
 
     @attr(tags = ['advanced', 'basic' , 'vgpu'], required_hardware="true")
@@ -2052,11 +1783,6 @@ class TestvGPUWindowsVm(cloudstackTestCase):
             self.deletevm(self.__class__.nonvgpu)
 
         self.cleanup.append(self.__class__.nonvgpu_service_offerin)
-
-        self.deletevm(self.__class__.vm_k1_card)
-        self.deletevm(self.__class__.vm_k2_card)
-        self.deletevm(self.__class__.vm2_k2_card)
-
         self.cleanup.append(self.__class__.k100_vgpu_service_offering)
         self.cleanup.append(self.__class__.k200_vgpu_service_offering)
 
@@ -2233,3 +1959,6 @@ class TestvGPUWindowsVm(cloudstackTestCase):
         except Exception as e:
             self.debug("Warning! Exception in tearDown: %s" % e)
 
+
+
+

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1de0cb70/utils/src/com/cloud/utils/xmlobject/XmlObject.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/xmlobject/XmlObject.java b/utils/src/com/cloud/utils/xmlobject/XmlObject.java
index e4e4363..42af945 100755
--- a/utils/src/com/cloud/utils/xmlobject/XmlObject.java
+++ b/utils/src/com/cloud/utils/xmlobject/XmlObject.java
@@ -27,10 +27,12 @@ import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
+import java.util.logging.Logger;
 
 import com.cloud.utils.exception.CloudRuntimeException;
 
 public class XmlObject {
+    private final Logger logger = Logger.getLogger(XmlObject.class.getName());
     private final Map<String, Object> elements = new HashMap<String, Object>();
     private String text;
     private String tag;
@@ -38,6 +40,10 @@ public class XmlObject {
     XmlObject() {
     }
 
+    public void removeAllChildren() {
+        elements.clear();
+    }
+
     public XmlObject(String tag) {
         this.tag = tag;
     }
@@ -99,8 +105,12 @@ public class XmlObject {
         if (e instanceof List) {
             return (List<T>)e;
         }
+
         List lst = new ArrayList(1);
-        lst.add(e);
+        if (e != null) {
+            lst.add(e);
+        }
+
         return lst;
     }
 
@@ -142,7 +152,8 @@ public class XmlObject {
         }
 
         if (!children.isEmpty() && text != null) {
-            throw new CloudRuntimeException(String.format("element %s cannot have both text[%s] and child elements", tag, text));
+            logger.info(String.format("element %s cannot have both text[%s] and child elements, set text to null", tag, text));
+            text = null;
         }
 
         if (!children.isEmpty()) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1de0cb70/utils/src/com/cloud/utils/xmlobject/XmlObjectParser.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/xmlobject/XmlObjectParser.java b/utils/src/com/cloud/utils/xmlobject/XmlObjectParser.java
old mode 100644
new mode 100755
index 321af0c..f0e8ce3
--- a/utils/src/com/cloud/utils/xmlobject/XmlObjectParser.java
+++ b/utils/src/com/cloud/utils/xmlobject/XmlObjectParser.java
@@ -19,6 +19,13 @@
 
 package com.cloud.utils.xmlobject;
 
+import com.cloud.utils.exception.CloudRuntimeException;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.DefaultHandler;
+
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
 import java.io.ByteArrayInputStream;
 import java.io.File;
 import java.io.FileInputStream;
@@ -26,15 +33,6 @@ import java.io.FileNotFoundException;
 import java.io.InputStream;
 import java.util.Stack;
 
-import javax.xml.parsers.SAXParser;
-import javax.xml.parsers.SAXParserFactory;
-
-import org.xml.sax.Attributes;
-import org.xml.sax.SAXException;
-import org.xml.sax.helpers.DefaultHandler;
-
-import com.cloud.utils.exception.CloudRuntimeException;
-
 public class XmlObjectParser {
     final private InputStream is;
 
@@ -109,7 +107,11 @@ public class XmlObjectParser {
     public static XmlObject parseFromString(String xmlString) {
         InputStream stream = new ByteArrayInputStream(xmlString.getBytes());
         XmlObjectParser p = new XmlObjectParser(stream);
-        return p.parse();
+        XmlObject obj = p.parse();
+        if (obj.getText() != null && obj.getText().replaceAll("\\n", "").replaceAll("\\r", "").replaceAll(" ", "").isEmpty()) {
+            obj.setText(null);
+        }
+        return obj;
     }
 
     private XmlObject parse() {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1de0cb70/utils/test/com/cloud/utils/xmlobject/TestXmlObject.java
----------------------------------------------------------------------
diff --git a/utils/test/com/cloud/utils/xmlobject/TestXmlObject.java b/utils/test/com/cloud/utils/xmlobject/TestXmlObject.java
old mode 100644
new mode 100755
index cbd24b0..faaf980
--- a/utils/test/com/cloud/utils/xmlobject/TestXmlObject.java
+++ b/utils/test/com/cloud/utils/xmlobject/TestXmlObject.java
@@ -43,6 +43,11 @@ public class TestXmlObject {
                 }
             }
             */
+
+        XmlObject xml = new XmlObject("vlan").putElement("vlan-id", String.valueOf(19)).putElement("tagged",
+                new XmlObject("teng").putElement("name", "0/0")
+        ).putElement("shutdown", "false");
+        System.out.println(xml.toString());
     }
 
 }


[48/50] [abbrv] git commit: updated refs/heads/baremetal-systemvm to 23482b1

Posted by ki...@apache.org.
CLOUDSTACK-7754: Templates source_template_id is null when it is created from Snapshot with its corresponding volume removed. Fix it by searching for volumes including removed.
(cherry picked from commit 287ff83552081cd91c68af6214016ca4cc4cc040)


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

Branch: refs/heads/baremetal-systemvm
Commit: a72580def0b555f479fbaa093cf4f8d95a8ea756
Parents: 3db112f
Author: Nitin Mehta <ni...@citrix.com>
Authored: Mon Oct 20 16:49:48 2014 -0700
Committer: Nitin Mehta <ni...@citrix.com>
Committed: Mon Oct 20 16:50:22 2014 -0700

----------------------------------------------------------------------
 server/src/com/cloud/template/TemplateManagerImpl.java | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a72580de/server/src/com/cloud/template/TemplateManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/template/TemplateManagerImpl.java b/server/src/com/cloud/template/TemplateManagerImpl.java
index a1ca344..615dcb9 100755
--- a/server/src/com/cloud/template/TemplateManagerImpl.java
+++ b/server/src/com/cloud/template/TemplateManagerImpl.java
@@ -1410,9 +1410,10 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager,
 
                 privateTemplate = _tmpltDao.findById(templateId);
                 if (snapshotId != null) {
-                    //getting the prent volume
+                    //getting the parent volume
                     long parentVolumeId = _snapshotDao.findById(snapshotId).getVolumeId();
-                    VolumeVO parentVolume = _volumeDao.findById(parentVolumeId);
+                    //Volume can be removed
+                    VolumeVO parentVolume = _volumeDao.findByIdIncludingRemoved(parentVolumeId);
 
                     if (parentVolume != null && parentVolume.getIsoId() != null && parentVolume.getIsoId() != 0) {
                         privateTemplate.setSourceTemplateId(parentVolume.getIsoId());


[28/50] [abbrv] git commit: updated refs/heads/baremetal-systemvm to 23482b1

Posted by ki...@apache.org.
Fixed coverity and other resource leak issues

Signed-off-by: Santhosh Edukulla <sa...@gmail.com>


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

Branch: refs/heads/baremetal-systemvm
Commit: efe1e0a54440feeb7708b3a6c98897fa5d6909a0
Parents: 7fe3c45
Author: Santhosh Edukulla <sa...@gmail.com>
Authored: Thu Oct 16 12:17:23 2014 +0530
Committer: Santhosh Edukulla <sa...@gmail.com>
Committed: Thu Oct 16 12:19:51 2014 +0530

----------------------------------------------------------------------
 .../com/cloud/upgrade/dao/Upgrade410to420.java  | 2831 ++++++++----------
 .../src/com/cloud/api/doc/ApiXmlDocWriter.java  |    6 +-
 .../resource/NfsSecondaryStorageResource.java   |   43 +-
 3 files changed, 1301 insertions(+), 1579 deletions(-)
----------------------------------------------------------------------



[24/50] [abbrv] git commit: updated refs/heads/baremetal-systemvm to 23482b1

Posted by ki...@apache.org.
CLOUDSTACK-7729: listVMSnapshot API not returning parent id in response


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

Branch: refs/heads/baremetal-systemvm
Commit: 7fe3c45142172e003fda340f779567f73525ffd8
Parents: 55e11cd
Author: Damodar <da...@citrix.com>
Authored: Wed Oct 15 16:53:26 2014 +0530
Committer: Kishan Kavala <ki...@apache.org>
Committed: Thu Oct 16 09:43:04 2014 +0530

----------------------------------------------------------------------
 .../cloudstack/api/response/VMSnapshotResponse.java       | 10 +++++++++-
 server/src/com/cloud/api/ApiResponseHelper.java           |  4 +++-
 2 files changed, 12 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7fe3c451/api/src/org/apache/cloudstack/api/response/VMSnapshotResponse.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/response/VMSnapshotResponse.java b/api/src/org/apache/cloudstack/api/response/VMSnapshotResponse.java
index 168c548..29d06b9 100644
--- a/api/src/org/apache/cloudstack/api/response/VMSnapshotResponse.java
+++ b/api/src/org/apache/cloudstack/api/response/VMSnapshotResponse.java
@@ -184,7 +184,15 @@ public class VMSnapshotResponse extends BaseResponse implements ControlledEntity
         return parentName;
     }
 
-    public String getType() {
+    public String getParent() {
+      return parent;
+    }
+
+    public void setParent(String parent) {
+      this.parent = parent;
+    }
+
+  public String getType() {
         return type;
     }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7fe3c451/server/src/com/cloud/api/ApiResponseHelper.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/ApiResponseHelper.java b/server/src/com/cloud/api/ApiResponseHelper.java
index 50376d2..38784ae 100755
--- a/server/src/com/cloud/api/ApiResponseHelper.java
+++ b/server/src/com/cloud/api/ApiResponseHelper.java
@@ -529,7 +529,9 @@ public class ApiResponseHelper implements ResponseGenerator {
             vmSnapshotResponse.setVirtualMachineid(vm.getUuid());
         }
         if (vmSnapshot.getParent() != null) {
-            vmSnapshotResponse.setParentName(ApiDBUtils.getVMSnapshotById(vmSnapshot.getParent()).getDisplayName());
+            VMSnapshot vmSnapshotParent = ApiDBUtils.getVMSnapshotById(vmSnapshot.getParent());
+            vmSnapshotResponse.setParent(vmSnapshotParent.getUuid());
+            vmSnapshotResponse.setParentName(vmSnapshotParent.getDisplayName());
         }
         vmSnapshotResponse.setCurrent(vmSnapshot.getCurrent());
         vmSnapshotResponse.setType(vmSnapshot.getType().toString());


[18/50] [abbrv] git commit: updated refs/heads/baremetal-systemvm to 23482b1

Posted by ki...@apache.org.
CLOUDSTACK-7536 user vm can get a gateway ip when gateway ip is a part of the guest ip range.

Signed-off-by: Jayapal <ja...@apache.org>


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

Branch: refs/heads/baremetal-systemvm
Commit: 6967c6c229d0153bae6fd87e0d87d6669518df29
Parents: 3b442ac
Author: Bharat Kumar <bh...@citrix.com>
Authored: Wed Sep 24 15:01:13 2014 +0530
Committer: Jayapal <ja...@apache.org>
Committed: Thu Oct 16 09:37:42 2014 +0530

----------------------------------------------------------------------
 .../src/com/cloud/configuration/ConfigurationManagerImpl.java   | 5 +++++
 1 file changed, 5 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/6967c6c2/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
index eca9080..7dac143 100755
--- a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
+++ b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
@@ -3442,6 +3442,11 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
         if (endIP != null && !NetUtils.sameSubnet(endIP, vlanGateway, vlanNetmask)) {
             throw new InvalidParameterValueException("Please ensure that your end IP is in the same subnet as your IP range's gateway, as per the IP range's netmask.");
         }
+        // check if the gatewayip is the part of the ip range being added.
+        if (NetUtils.ipRangesOverlap(startIP, endIP, vlanGateway, vlanGateway)) {
+            throw new InvalidParameterValueException(
+                    "The gateway ip should not be the part of the ip range being added.");
+        }
     }
 
     private void checkConflictsWithPortableIpRange(long zoneId, String vlanId, String vlanGateway, String vlanNetmask, String startIP, String endIP) {


[10/50] [abbrv] CLOUDSTACK-7693: Fixing pep8 issues

Posted by ki...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/35e05a69/test/integration/component/test_routers.py
----------------------------------------------------------------------
diff --git a/test/integration/component/test_routers.py b/test/integration/component/test_routers.py
index 24f44b3..0a74234 100644
--- a/test/integration/component/test_routers.py
+++ b/test/integration/component/test_routers.py
@@ -5,9 +5,9 @@
 # to you under the Apache License, Version 2.0 (the
 # "License"); you may not use this file except in compliance
 # with the License.  You may obtain a copy of the License at
-# 
+#
 #   http://www.apache.org/licenses/LICENSE-2.0
-# 
+#
 # Unless required by applicable law or agreed to in writing,
 # software distributed under the License is distributed on an
 # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -16,81 +16,101 @@
 # under the License.
 """ P1 tests for routers
 """
-#Import Local Modules
-import marvin
+# Import Local Modules
 from nose.plugins.attrib import attr
-from marvin.cloudstackTestCase import *
-from marvin.cloudstackAPI import *
-from marvin.lib.utils import *
-from marvin.lib.base import *
-from marvin.lib.common import *
-
-#Import System modules
+from marvin.cloudstackTestCase import cloudstackTestCase
+from marvin.cloudstackAPI import (stopVirtualMachine,
+                                  stopRouter,
+                                  startRouter)
+from marvin.lib.utils import (cleanup_resources,
+                              get_process_status,
+                              get_host_credentials)
+from marvin.lib.base import (ServiceOffering,
+                             VirtualMachine,
+                             Account,
+                             LoadBalancerRule,
+                             FireWallRule,
+                             NATRule)
+from marvin.lib.common import (get_zone,
+                               get_template,
+                               get_domain,
+                               list_virtual_machines,
+                               list_networks,
+                               list_configurations,
+                               list_routers,
+                               list_nat_rules,
+                               list_publicIP,
+                               list_lb_rules,
+                               list_firewall_rules,
+                               list_hosts)
+
+# Import System modules
 import time
 
 
 class Services:
+
     """Test router Services
     """
 
     def __init__(self):
         self.services = {
-                         "service_offering": {
-                                    "name": "Tiny Instance",
-                                    "displaytext": "Tiny Instance",
-                                    "cpunumber": 1,
-                                    "cpuspeed": 100,    # in MHz
+            "service_offering": {
+                "name": "Tiny Instance",
+                "displaytext": "Tiny Instance",
+                "cpunumber": 1,
+                "cpuspeed": 100,    # in MHz
                                     "memory": 128,       # In MBs
-                                    },
-                        "virtual_machine":
-                                    {
-                                        "displayname": "Test VM",
-                                        "username": "root",
-                                        "password": "password",
-                                        "ssh_port": 22,
-                                        "hypervisor": 'XenServer',
-                                        # Hypervisor type should be same as
-                                        # hypervisor type of cluster
-                                        "privateport": 22,
-                                        "publicport": 22,
-                                        "protocol": 'TCP',
-                                },
-                        "host": {
-                                        "username": "root",
-                                        "password": "password",
-                                        "publicport": 22,
-                            },
-                        "account": {
-                                        "email": "test@test.com",
-                                        "firstname": "Test",
-                                        "lastname": "User",
-                                        "username": "testuser",
-                                        "password": "password",
-                                    },
-                        "natrule":
-                                {
-                                    "privateport": 22,
-                                    "publicport": 22,
-                                    "protocol": "TCP"
-                                },
-                         "lbrule":
-                                {
-                                    "name": "SSH",
-                                    "alg": "roundrobin",
-                                    # Algorithm used for load balancing
-                                    "privateport": 22,
-                                    "publicport": 22,
-                                    "protocol": 'TCP',
-                                },
-                         "fw_rule": {
-                                    "startport": 1,
-                                    "endport": 6000,
-                                    "cidr": '55.55.0.0/11',
-                                    # Any network (For creating FW rule
-                                    },
-                         "ostype": 'CentOS 5.3 (64-bit)',
-                         # Used for Get_Template : CentOS 5.3 (64 bit)
-                        }
+            },
+            "virtual_machine":
+            {
+                "displayname": "Test VM",
+                "username": "root",
+                "password": "password",
+                "ssh_port": 22,
+                "hypervisor": 'XenServer',
+                # Hypervisor type should be same as
+                # hypervisor type of cluster
+                "privateport": 22,
+                "publicport": 22,
+                "protocol": 'TCP',
+            },
+            "host": {
+                "username": "root",
+                "password": "password",
+                "publicport": 22,
+            },
+            "account": {
+                "email": "test@test.com",
+                "firstname": "Test",
+                "lastname": "User",
+                "username": "testuser",
+                "password": "password",
+            },
+            "natrule":
+            {
+                "privateport": 22,
+                "publicport": 22,
+                "protocol": "TCP"
+            },
+            "lbrule":
+            {
+                "name": "SSH",
+                "alg": "roundrobin",
+                # Algorithm used for load balancing
+                "privateport": 22,
+                "publicport": 22,
+                "protocol": 'TCP',
+            },
+            "fw_rule": {
+                "startport": 1,
+                "endport": 6000,
+                "cidr": '55.55.0.0/11',
+                # Any network (For creating FW rule
+            },
+            "ostype": 'CentOS 5.3 (64-bit)',
+            # Used for Get_Template : CentOS 5.3 (64 bit)
+        }
 
 
 class TestRouterServices(cloudstackTestCase):
@@ -107,50 +127,52 @@ class TestRouterServices(cloudstackTestCase):
         cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
         cls.services['mode'] = cls.zone.networktype
         cls.template = get_template(
-                            cls.api_client,
-                            cls.zone.id,
-                            cls.services["ostype"]
-                            )
+            cls.api_client,
+            cls.zone.id,
+            cls.services["ostype"]
+        )
         cls.services["virtual_machine"]["zoneid"] = cls.zone.id
 
-        #Create an account, network, VM and IP addresses
+        # Create an account, network, VM and IP addresses
         cls.account = Account.create(
-                                     cls.api_client,
-                                     cls.services["account"],
-                                     admin=True,
-                                     domainid=cls.domain.id
-                                     )
+            cls.api_client,
+            cls.services["account"],
+            admin=True,
+            domainid=cls.domain.id
+        )
         cls.service_offering = ServiceOffering.create(
-                                            cls.api_client,
-                                            cls.services["service_offering"]
-                                            )
+            cls.api_client,
+            cls.services["service_offering"]
+        )
         cls.vm_1 = 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
-                                    )
+            cls.api_client,
+            cls.services["virtual_machine"],
+            templateid=cls.template.id,
+            accountid=cls.account.name,
+            domainid=cls.account.domainid,
+            serviceofferingid=cls.service_offering.id
+        )
         cls.vm_2 = VirtualMachine.create(
-                                    cls.api_client,
-                                    cls.services["virtual_machine"],
-                                    templateid=cls.template.id,
-                                    accountid=cls.account.name,
-                                    domainid=cls.account.domainid,
-                                    serviceofferingid=cls.service_offering.id
-                                    )
+            cls.api_client,
+            cls.services["virtual_machine"],
+            templateid=cls.template.id,
+            accountid=cls.account.name,
+            domainid=cls.account.domainid,
+            serviceofferingid=cls.service_offering.id
+        )
         cls._cleanup = [
-                       cls.account,
-                       cls.service_offering
-                       ]
+            cls.account,
+            cls.service_offering
+        ]
         return
 
     @classmethod
     def tearDownClass(cls):
         try:
-            cls.api_client = super(TestRouterServices, cls).getClsTestClient().getApiClient()
-            #Clean up, terminate the created templates
+            cls.api_client = super(
+                TestRouterServices,
+                cls).getClsTestClient().getApiClient()
+            # Clean up, terminate the created templates
             cleanup_resources(cls.api_client, cls._cleanup)
 
         except Exception as e:
@@ -184,142 +206,143 @@ class TestRouterServices(cloudstackTestCase):
         #    g. userdata
         # 2. wait for router to start and guest network to be created
         #    a. listRouters account=user, domainid=1 (router state=Running)
-        #    b. listNetworks account=user domainid=1 (network state=Implemented)
+        #    b. listNetworks account=user domainid=1
+        #       (network state=Implemented)
         #    c. listVirtualMachines account=user domainid=1 (VM state=Running)
         # 3. listNetwork
 
         routers = list_routers(
-                               self.apiclient,
-                               account=self.account.name,
-                               domainid=self.account.domainid,
-                               )
+            self.apiclient,
+            account=self.account.name,
+            domainid=self.account.domainid,
+        )
 
         self.assertEqual(
-                        isinstance(routers, list),
-                        True,
-                        "Check for list routers response return valid data"
-                        )
+            isinstance(routers, list),
+            True,
+            "Check for list routers response return valid data"
+        )
         self.assertNotEqual(
-                             len(routers),
-                             0,
-                             "Check list router response"
-                             )
+            len(routers),
+            0,
+            "Check list router response"
+        )
         for router in routers:
             self.debug("Router ID: %s & Router state: %s" % (
-                                                             router.id,
-                                                             router.state
-                                                             ))
+                router.id,
+                router.state
+            ))
             self.assertEqual(
-                        router.state,
-                        'Running',
-                        "Router state is not running but is  %s" % router.state
-                    )
+                router.state,
+                'Running',
+                "Router state is not running but is  %s" % router.state
+            )
 
         # Network state associated with account should be 'Implemented'
         networks = list_networks(
-                                 self.apiclient,
-                                 account=self.account.name,
-                                 domainid=self.account.domainid,
-                                 type = 'Isolated'
-                                 )
+            self.apiclient,
+            account=self.account.name,
+            domainid=self.account.domainid,
+            type='Isolated'
+        )
         self.assertEqual(
-                        isinstance(networks, list),
-                        True,
-                        "Check for list networks response return valid data"
-                        )
+            isinstance(networks, list),
+            True,
+            "Check for list networks response return valid data"
+        )
 
         self.assertNotEqual(
-                             len(networks),
-                             0,
-                             "Check list networks response"
-                             )
+            len(networks),
+            0,
+            "Check list networks response"
+        )
         for network in networks:
             self.debug("Network ID: %s & Network state: %s" % (
-                                                             network.id,
-                                                             network.state
-                                                             ))
+                network.id,
+                network.state
+            ))
             self.assertIn(
-                        network.state,
-                        ['Implemented', 'Allocated'],
-                        "Check list network response for network state"
-                    )
+                network.state,
+                ['Implemented', 'Allocated'],
+                "Check list network response for network state"
+            )
 
         # VM state associated with account should be 'Running'
         virtual_machines = list_virtual_machines(
-                                self.apiclient,
-                                account=self.account.name,
-                                domainid=self.account.domainid
-                                )
+            self.apiclient,
+            account=self.account.name,
+            domainid=self.account.domainid
+        )
 
         self.assertEqual(
-                        isinstance(virtual_machines, list),
-                        True,
-                        "Check for list virtual machines response return valid data"
-                        )
+            isinstance(virtual_machines, list),
+            True,
+            "Check for list virtual machines response return valid data"
+        )
         self.assertNotEqual(
-                             len(virtual_machines),
-                             0,
-                             "Check list virtual machines response"
-                             )
+            len(virtual_machines),
+            0,
+            "Check list virtual machines response"
+        )
         for virtual_machine in virtual_machines:
             self.assertEqual(
-                        virtual_machine.state,
-                        'Running',
-                        "Check list VM response for Running state"
-                    )
+                virtual_machine.state,
+                'Running',
+                "Check list VM response for Running state"
+            )
             self.debug("VM ID: %s & VM state: %s" % (
-                                                     virtual_machine.id,
-                                                     virtual_machine.state
-                                                    ))
+                virtual_machine.id,
+                virtual_machine.state
+            ))
 
         # Check status of DNS, DHCP, FIrewall, LB VPN processes
         networks = list_networks(
-                                 self.apiclient,
-                                 account=self.account.name,
-                                 domainid=self.account.domainid,
-                                 type = 'Isolated'
-                                 )
+            self.apiclient,
+            account=self.account.name,
+            domainid=self.account.domainid,
+            type='Isolated'
+        )
         self.assertEqual(
-                        isinstance(networks, list),
-                        True,
-                        "Check for list networks response return valid data"
-                        )
+            isinstance(networks, list),
+            True,
+            "Check for list networks response return valid data"
+        )
         self.assertNotEqual(
-                             len(networks),
-                             0,
-                             "Check list networks response"
-                             )
+            len(networks),
+            0,
+            "Check list networks response"
+        )
         # Load Balancer, Userdata, VPN, Firewall, Gateway, DNS processes should
         # be running
         for network in networks:
             self.assertEqual(
-                        'Lb' in str(network.service),
-                        True,
-                        "Check Load balancing process in list networks"
-                    )
+                'Lb' in str(network.service),
+                True,
+                "Check Load balancing process in list networks"
+            )
             self.assertEqual(
-                        'UserData' in str(network.service),
-                        True,
-                        "Check UserData service in list networks"
-                    )
+                'UserData' in str(network.service),
+                True,
+                "Check UserData service in list networks"
+            )
             self.assertEqual(
-                        'Vpn' in str(network.service),
-                        True,
-                        "Check Vpn service in list networks"
-                    )
+                'Vpn' in str(network.service),
+                True,
+                "Check Vpn service in list networks"
+            )
             self.assertEqual(
-                        'Firewall' in str(network.service),
-                        True,
-                        "Check Firewall service in list networks"
-                    )
+                'Firewall' in str(network.service),
+                True,
+                "Check Firewall service in list networks"
+            )
             self.assertEqual(
-                        'Dns' in str(network.service),
-                        True,
-                        "Check Dns service in list networks"
-                    )
+                'Dns' in str(network.service),
+                True,
+                "Check Dns service in list networks"
+            )
         return
 
-    @attr(configuration = "network.gc")
+    @attr(configuration="network.gc")
     @attr(tags=["advanced"], required_hardware="false")
     def test_02_NetworkGarbageCollection(self):
         """Test network garbage collection
@@ -336,36 +359,38 @@ class TestRouterServices(cloudstackTestCase):
         # 7. listRouters account=user, domainid=1
 
         routers = list_routers(
-                               self.apiclient,
-                               account=self.account.name,
-                               domainid=self.account.domainid,
-                               )
+            self.apiclient,
+            account=self.account.name,
+            domainid=self.account.domainid,
+        )
 
         self.assertEqual(
-                        isinstance(routers, list),
-                        True,
-                        "Check for list routers response return valid data"
-                        )
+            isinstance(routers, list),
+            True,
+            "Check for list routers response return valid data"
+        )
         self.assertNotEqual(
-                             len(routers),
-                             0,
-                             "Check list router response"
-                             )
+            len(routers),
+            0,
+            "Check list router response"
+        )
         # Router associated with account should be in running state
         timeout = 180
         router = routers[0]
         self.debug("Router ID: %s & Router state: %s" % (
-                                                             router.id,
-                                                             router.state
-                                                             ))
-        self.debug("Wait for %s secs max for router to reach Running state" % timeout)
+            router.id,
+            router.state
+        ))
+        self.debug(
+            "Wait for %s secs max for router to reach Running state" %
+            timeout)
         while timeout:
             time.sleep(60)
             routers = list_routers(
-                               self.apiclient,
-                               account=self.account.name,
-                               domainid=self.account.domainid,
-                               id=router.id)
+                self.apiclient,
+                account=self.account.name,
+                domainid=self.account.domainid,
+                id=router.id)
             router = routers[0]
             if router.state == 'Running':
                 break
@@ -373,67 +398,66 @@ class TestRouterServices(cloudstackTestCase):
             timeout = timeout - 60
             if timeout == 0:
                 self.assertEqual(
-                        router.state,
-                        'Running',
-                        "Router not in Running state")
-
+                    router.state,
+                    'Running',
+                    "Router not in Running state")
 
         # Network state associated with account should be 'Implemented'
         networks = list_networks(
-                                 self.apiclient,
-                                 account=self.account.name,
-                                 domainid=self.account.domainid,
-                                 type = 'Isolated'
-                                 )
+            self.apiclient,
+            account=self.account.name,
+            domainid=self.account.domainid,
+            type='Isolated'
+        )
         self.assertEqual(
-                        isinstance(networks, list),
-                        True,
-                        "Check for list networks response return valid data"
-                        )
+            isinstance(networks, list),
+            True,
+            "Check for list networks response return valid data"
+        )
         self.assertNotEqual(
-                             len(networks),
-                             0,
-                             "Check list networks response"
-                             )
+            len(networks),
+            0,
+            "Check list networks response"
+        )
         # Check if network in 'Implemented' state
         for network in networks:
             self.debug("Network ID: %s & Network state: %s" % (
-                                                             network.id,
-                                                             network.state
-                                                             ))
+                network.id,
+                network.state
+            ))
             self.assertIn(
-                        network.state,
-                        ['Implemented', 'Allocated'],
-                        "Check list network response for network state"
-                    )
+                network.state,
+                ['Implemented', 'Allocated'],
+                "Check list network response for network state"
+            )
 
         # VM state associated with account should be 'Running'
         virtual_machines = list_virtual_machines(
-                                self.apiclient,
-                                account=self.account.name,
-                                domainid=self.account.domainid,
-                                )
+            self.apiclient,
+            account=self.account.name,
+            domainid=self.account.domainid,
+        )
 
         self.assertEqual(
-                        isinstance(virtual_machines, list),
-                        True,
-                        "Check for list virtual machines response return valid data"
-                        )
+            isinstance(virtual_machines, list),
+            True,
+            "Check for list virtual machines response return valid data"
+        )
         self.assertNotEqual(
-                             len(virtual_machines),
-                             0,
-                             "Check list virtual machines response"
-                             )
+            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
-                                                    ))
+                virtual_machine.id,
+                virtual_machine.state
+            ))
             self.assertEqual(
-                        virtual_machine.state,
-                        'Running',
-                        "Check list VM response for Running state"
-                    )
+                virtual_machine.state,
+                'Running',
+                "Check list VM response for Running state"
+            )
 
             # Stop virtual machine
             cmd = stopVirtualMachine.stopVirtualMachineCmd()
@@ -441,58 +465,59 @@ class TestRouterServices(cloudstackTestCase):
             self.apiclient.stopVirtualMachine(cmd)
 
         gcinterval = list_configurations(
-                                    self.apiclient,
-                                    name='network.gc.interval'
-                                    )
+            self.apiclient,
+            name='network.gc.interval'
+        )
         self.assertEqual(
-                        isinstance(gcinterval, list),
-                        True,
-                        "Check for list intervals response return valid data"
-                        )
+            isinstance(gcinterval, list),
+            True,
+            "Check for list intervals response return valid data"
+        )
         self.debug("network.gc.interval: %s" % gcinterval[0].value)
 
         gcwait = list_configurations(
-                                    self.apiclient,
-                                    name='network.gc.wait'
-                                    )
+            self.apiclient,
+            name='network.gc.wait'
+        )
         self.assertEqual(
-                        isinstance(gcwait, list),
-                        True,
-                        "Check for list intervals response return valid data"
-                        )
+            isinstance(gcwait, list),
+            True,
+            "Check for list intervals response return valid data"
+        )
         self.debug("network.gc.wait: %s" % gcwait[0].value)
 
         total_wait = int(gcinterval[0].value) + int(gcwait[0].value)
         # Router is stopped after (network.gc.interval *2) time. Wait for
-        # (network.gc.interval+network.gc.wait) * 2 for moving router to 'Stopped'
+        # (network.gc.interval+network.gc.wait) * 2 for moving
+        # router to 'Stopped'
         time.sleep(total_wait * 2)
 
         routers = list_routers(
-                               self.apiclient,
-                               account=self.account.name,
-                               domainid=self.account.domainid,
-                               )
+            self.apiclient,
+            account=self.account.name,
+            domainid=self.account.domainid,
+        )
 
         self.assertEqual(
-                        isinstance(routers, list),
-                        True,
-                        "Check for list routers response return valid data"
-                        )
+            isinstance(routers, list),
+            True,
+            "Check for list routers response return valid data"
+        )
         self.assertNotEqual(
-                             len(routers),
-                             0,
-                             "Check list router response"
-                             )
+            len(routers),
+            0,
+            "Check list router response"
+        )
         for router in routers:
             self.debug("Router ID: %s & Router state: %s" % (
-                                                             router.id,
-                                                             router.state
-                                                             ))
+                router.id,
+                router.state
+            ))
             self.assertEqual(
-                        router.state,
-                        'Stopped',
-                        "Check list router response for router state"
-                    )
+                router.state,
+                'Stopped',
+                "Check list router response for router state"
+            )
 
         # Cleanup Vm_2 - Not required for further tests
         self.cleanup.append(self.vm_2)
@@ -506,32 +531,32 @@ class TestRouterServices(cloudstackTestCase):
         # 1. deployVirtualMachine in the account
         # 2. listVirtualMachines account=user, domainid=1
         # 3. when listVirtualMachines reports the userVM to be in state=Running
-        # 4. listRouters should report router to have come back to "Running" state
+        # 4. listRouters should report router to have come back to "Running"
+        #    state
         # 5. All other VMs in the account should remain in "Stopped" state
 
-
-        #stop all pre-existing virtual machines if they are in 'Running' state
+        # stop all pre-existing virtual machines if they are in 'Running' state
         virtual_machines = list_virtual_machines(
-                                self.apiclient,
-                                account=self.account.name,
-                                domainid=self.account.domainid,
-                                )
+            self.apiclient,
+            account=self.account.name,
+            domainid=self.account.domainid,
+        )
 
         self.assertEqual(
-                        isinstance(virtual_machines, list),
-                        True,
-                        "Check for list virtual machines response return valid data"
-                        )
+            isinstance(virtual_machines, list),
+            True,
+            "Check for list virtual machines response return valid data"
+        )
         self.assertNotEqual(
-                             len(virtual_machines),
-                             0,
-                             "Check list virtual machines response"
-                             )
+            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
-                                                    ))
+                virtual_machine.id,
+                virtual_machine.state
+            ))
             if virtual_machine.state == 'Running':
                 # Stop virtual machine
                 cmd = stopVirtualMachine.stopVirtualMachineCmd()
@@ -539,101 +564,100 @@ class TestRouterServices(cloudstackTestCase):
                 self.apiclient.stopVirtualMachine(cmd)
 
         vm = 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
-                                    )
+            self.apiclient,
+            self.services["virtual_machine"],
+            templateid=self.template.id,
+            accountid=self.account.name,
+            domainid=self.account.domainid,
+            serviceofferingid=self.service_offering.id
+        )
         self.debug("Deployed a VM with ID: %s" % vm.id)
 
         virtual_machines = list_virtual_machines(
-                                self.apiclient,
-                                id=vm.id,
-                                account=self.account.name,
-                                domainid=self.account.domainid,
-                                )
+            self.apiclient,
+            id=vm.id,
+            account=self.account.name,
+            domainid=self.account.domainid,
+        )
 
         self.assertEqual(
-                        isinstance(virtual_machines, list),
-                        True,
-                        "Check for list virtual machines response return valid data"
-                        )
+            isinstance(virtual_machines, list),
+            True,
+            "Check for list virtual machines response return valid data"
+        )
 
         self.assertNotEqual(
-                             len(virtual_machines),
-                             0,
-                             "Check list virtual machines response"
-                             )
+            len(virtual_machines),
+            0,
+            "Check list virtual machines response"
+        )
         # VM state should be 'Running'
         for virtual_machine in virtual_machines:
             self.assertEqual(
-                        virtual_machine.state,
-                        'Running',
-                        "Check list VM response for Running state"
-                    )
+                virtual_machine.state,
+                'Running',
+                "Check list VM response for Running state"
+            )
 
         routers = list_routers(
-                               self.apiclient,
-                               account=self.account.name,
-                               domainid=self.account.domainid,
-                               )
+            self.apiclient,
+            account=self.account.name,
+            domainid=self.account.domainid,
+        )
 
         self.assertEqual(
-                        isinstance(routers, list),
-                        True,
-                        "Check for list routers response return valid data"
-                        )
+            isinstance(routers, list),
+            True,
+            "Check for list routers response return valid data"
+        )
 
         self.assertNotEqual(
-                             len(routers),
-                             0,
-                             "Check list router response"
-                             )
+            len(routers),
+            0,
+            "Check list router response"
+        )
         # Routers associated with account should be 'Running' after deployment
         # of VM
         for router in routers:
             self.debug("Router ID: %s & Router state: %s" % (
-                                                             router.id,
-                                                             router.state
-                                                             ))
+                router.id,
+                router.state
+            ))
             self.assertEqual(
-                        router.state,
-                        'Running',
-                        "Check list router response for router state"
-                    )
-
+                router.state,
+                'Running',
+                "Check list router response for router state"
+            )
 
         # All other VMs (VM_1) should be in 'Stopped'
         virtual_machines = list_virtual_machines(
-                                self.apiclient,
-                                id=self.vm_1.id,
-                                account=self.account.name,
-                                domainid=self.account.domainid,
-                                )
+            self.apiclient,
+            id=self.vm_1.id,
+            account=self.account.name,
+            domainid=self.account.domainid,
+        )
 
         self.assertEqual(
-                        isinstance(virtual_machines, list),
-                        True,
-                        "Check for list VMs response return valid data"
-                        )
+            isinstance(virtual_machines, list),
+            True,
+            "Check for list VMs response return valid data"
+        )
 
         self.assertNotEqual(
-                             len(virtual_machines),
-                             0,
-                             "Check list virtual machines response"
-                             )
+            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
-                                                    ))
+                virtual_machine.id,
+                virtual_machine.state
+            ))
             self.assertEqual(
-                        virtual_machine.state,
-                        'Stopped',
-                        "Check list VM response for Stopped state"
-                    )
+                virtual_machine.state,
+                'Stopped',
+                "Check list VM response for Stopped state"
+            )
 
         return
 
@@ -652,41 +676,43 @@ class TestRouterStopCreatePF(cloudstackTestCase):
         cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
         cls.services['mode'] = cls.zone.networktype
         template = get_template(
-                            cls.api_client,
-                            cls.zone.id,
-                            cls.services["ostype"]
-                            )
+            cls.api_client,
+            cls.zone.id,
+            cls.services["ostype"]
+        )
         cls.services["virtual_machine"]["zoneid"] = cls.zone.id
 
-        #Create an account, network, VM and IP addresses
+        # Create an account, network, VM and IP addresses
         cls.account = Account.create(
-                                     cls.api_client,
-                                     cls.services["account"],
-                                     admin=True,
-                                     domainid=cls.domain.id
-                                     )
+            cls.api_client,
+            cls.services["account"],
+            admin=True,
+            domainid=cls.domain.id
+        )
         cls.service_offering = ServiceOffering.create(
-                                            cls.api_client,
-                                            cls.services["service_offering"]
-                                            )
+            cls.api_client,
+            cls.services["service_offering"]
+        )
         cls.vm_1 = VirtualMachine.create(
-                                    cls.api_client,
-                                    cls.services["virtual_machine"],
-                                    templateid=template.id,
-                                    accountid=cls.account.name,
-                                    domainid=cls.account.domainid,
-                                    serviceofferingid=cls.service_offering.id
-                                    )
+            cls.api_client,
+            cls.services["virtual_machine"],
+            templateid=template.id,
+            accountid=cls.account.name,
+            domainid=cls.account.domainid,
+            serviceofferingid=cls.service_offering.id
+        )
         cls._cleanup = [
-                       cls.account,
-                       cls.service_offering
-                       ]
+            cls.account,
+            cls.service_offering
+        ]
         return
 
     @classmethod
     def tearDownClass(cls):
         try:
-            cls.api_client = super(TestRouterStopCreatePF, cls).getClsTestClient().getApiClient()
+            cls.api_client = super(
+                TestRouterStopCreatePF,
+                cls).getClsTestClient().getApiClient()
             # Clean up, terminate the created resources
             cleanup_resources(cls.api_client, cls._cleanup)
 
@@ -725,130 +751,132 @@ class TestRouterStopCreatePF(cloudstackTestCase):
 
         # Get router details associated for that account
         routers = list_routers(
-                               self.apiclient,
-                               account=self.account.name,
-                               domainid=self.account.domainid,
-                               )
+            self.apiclient,
+            account=self.account.name,
+            domainid=self.account.domainid,
+        )
 
         self.assertEqual(
-                        isinstance(routers, list),
-                        True,
-                        "Check for list routers response return valid data"
-                        )
+            isinstance(routers, list),
+            True,
+            "Check for list routers response return valid data"
+        )
         self.assertNotEqual(
-                             len(routers),
-                             0,
-                             "Check list router response"
-                             )
+            len(routers),
+            0,
+            "Check list router response"
+        )
         router = routers[0]
 
         self.debug("Stopping router ID: %s" % router.id)
 
-        #Stop the router
+        # Stop the router
         cmd = stopRouter.stopRouterCmd()
         cmd.id = router.id
         self.apiclient.stopRouter(cmd)
 
         routers = list_routers(
-                               self.apiclient,
-                               account=self.account.name,
-                               domainid=self.account.domainid,
-                               )
+            self.apiclient,
+            account=self.account.name,
+            domainid=self.account.domainid,
+        )
         self.assertEqual(
-                        isinstance(routers, list),
-                        True,
-                        "Check for list routers response return valid data"
-                        )
+            isinstance(routers, list),
+            True,
+            "Check for list routers response return valid data"
+        )
         router = routers[0]
 
         self.assertEqual(
-                    router.state,
-                    'Stopped',
-                    "Check list router response for router state"
-                    )
+            router.state,
+            'Stopped',
+            "Check list router response for router state"
+        )
 
         public_ips = list_publicIP(
-                                   self.apiclient,
-                                   account=self.account.name,
-                                   domainid=self.account.domainid,
-                                   zoneid=self.zone.id
-                                   )
+            self.apiclient,
+            account=self.account.name,
+            domainid=self.account.domainid,
+            zoneid=self.zone.id
+        )
         self.assertEqual(
-                        isinstance(public_ips, list),
-                        True,
-                        "Check for list public IPs response return valid data"
-                        )
+            isinstance(public_ips, list),
+            True,
+            "Check for list public IPs response return valid data"
+        )
 
         public_ip = public_ips[0]
 
         # Open up firewall port for SSH
-        fw_rule = FireWallRule.create(
-                            self.apiclient,
-                            ipaddressid=public_ip.id,
-                            protocol=self.services["natrule"]["protocol"],
-                            cidrlist=['0.0.0.0/0'],
-                            startport=self.services["natrule"]["publicport"],
-                            endport=self.services["natrule"]["publicport"]
-                            )
+        FireWallRule.create(
+            self.apiclient,
+            ipaddressid=public_ip.id,
+            protocol=self.services["natrule"]["protocol"],
+            cidrlist=['0.0.0.0/0'],
+            startport=self.services["natrule"]["publicport"],
+            endport=self.services["natrule"]["publicport"]
+        )
 
         self.debug("Creating NAT rule for VM ID: %s" % self.vm_1.id)
-        #Create NAT rule
+        # Create NAT rule
         nat_rule = NATRule.create(
-                        self.apiclient,
-                        self.vm_1,
-                        self.services["natrule"],
-                        public_ip.id
-                        )
+            self.apiclient,
+            self.vm_1,
+            self.services["natrule"],
+            public_ip.id
+        )
 
         self.debug("Starting router ID: %s" % router.id)
-        #Start the router
+        # Start the router
         cmd = startRouter.startRouterCmd()
         cmd.id = router.id
         self.apiclient.startRouter(cmd)
 
         routers = list_routers(
-                               self.apiclient,
-                               account=self.account.name,
-                               domainid=self.account.domainid,
-                               zoneid=self.zone.id
-                               )
+            self.apiclient,
+            account=self.account.name,
+            domainid=self.account.domainid,
+            zoneid=self.zone.id
+        )
         self.assertEqual(
-                        isinstance(routers, list),
-                        True,
-                        "Check for list routers response return valid data"
-                        )
+            isinstance(routers, list),
+            True,
+            "Check for list routers response return valid data"
+        )
         router = routers[0]
 
         self.assertEqual(
-                    router.state,
-                    'Running',
-                    "Check list router response for router state"
-                    )
+            router.state,
+            'Running',
+            "Check list router response for router state"
+        )
         # NAT Rule should be in Active state after router start
         nat_rules = list_nat_rules(
-                                   self.apiclient,
-                                   id=nat_rule.id
-                                   )
+            self.apiclient,
+            id=nat_rule.id
+        )
         self.assertEqual(
-                        isinstance(nat_rules, list),
-                        True,
-                        "Check for list NAT rules response return valid data"
-                        )
+            isinstance(nat_rules, list),
+            True,
+            "Check for list NAT rules response return valid data"
+        )
         self.assertEqual(
-                    nat_rules[0].state,
-                    'Active',
-                    "Check list port forwarding rules"
-                    )
+            nat_rules[0].state,
+            'Active',
+            "Check list port forwarding rules"
+        )
         try:
 
             self.debug("SSH into VM with ID: %s" % nat_rule.ipaddress)
 
-            self.vm_1.get_ssh_client(ipaddress=nat_rule.ipaddress, port=self.services["natrule"]["publicport"])
+            self.vm_1.get_ssh_client(
+                ipaddress=nat_rule.ipaddress,
+                port=self.services["natrule"]["publicport"])
         except Exception as e:
             self.fail(
-                      "SSH Access failed for %s: %s" % \
-                      (nat_rule.ipaddress, e)
-                      )
+                "SSH Access failed for %s: %s" %
+                (nat_rule.ipaddress, e)
+            )
         return
 
 
@@ -866,42 +894,44 @@ class TestRouterStopCreateLB(cloudstackTestCase):
         cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
         cls.services['mode'] = cls.zone.networktype
         template = get_template(
-                            cls.api_client,
-                            cls.zone.id,
-                            cls.services["ostype"]
-                            )
+            cls.api_client,
+            cls.zone.id,
+            cls.services["ostype"]
+        )
         cls.services["virtual_machine"]["zoneid"] = cls.zone.id
 
-        #Create an account, network, VM and IP addresses
+        # Create an account, network, VM and IP addresses
         cls.account = Account.create(
-                                     cls.api_client,
-                                     cls.services["account"],
-                                     admin=True,
-                                     domainid=cls.domain.id
-                                     )
+            cls.api_client,
+            cls.services["account"],
+            admin=True,
+            domainid=cls.domain.id
+        )
         cls.service_offering = ServiceOffering.create(
-                                            cls.api_client,
-                                            cls.services["service_offering"]
-                                            )
+            cls.api_client,
+            cls.services["service_offering"]
+        )
         cls.vm_1 = VirtualMachine.create(
-                                    cls.api_client,
-                                    cls.services["virtual_machine"],
-                                    templateid=template.id,
-                                    accountid=cls.account.name,
-                                    domainid=cls.account.domainid,
-                                    serviceofferingid=cls.service_offering.id
-                                    )
+            cls.api_client,
+            cls.services["virtual_machine"],
+            templateid=template.id,
+            accountid=cls.account.name,
+            domainid=cls.account.domainid,
+            serviceofferingid=cls.service_offering.id
+        )
         cls._cleanup = [
-                       cls.account,
-                       cls.service_offering
-                       ]
+            cls.account,
+            cls.service_offering
+        ]
         return
 
     @classmethod
     def tearDownClass(cls):
         try:
-            cls.api_client = super(TestRouterStopCreateLB, cls).getClsTestClient().getApiClient()
-            #Clean up, terminate the created resources
+            cls.api_client = super(
+                TestRouterStopCreateLB,
+                cls).getClsTestClient().getApiClient()
+            # Clean up, terminate the created resources
             cleanup_resources(cls.api_client, cls._cleanup)
 
         except Exception as e:
@@ -933,126 +963,126 @@ class TestRouterStopCreateLB(cloudstackTestCase):
 
         # Get router details associated for that account
         routers = list_routers(
-                               self.apiclient,
-                               account=self.account.name,
-                               domainid=self.account.domainid,
-                               )
+            self.apiclient,
+            account=self.account.name,
+            domainid=self.account.domainid,
+        )
 
         self.assertEqual(
-                        isinstance(routers, list),
-                        True,
-                        "Check for list routers response return valid data"
-                        )
+            isinstance(routers, list),
+            True,
+            "Check for list routers response return valid data"
+        )
 
         self.assertNotEqual(
-                             len(routers),
-                             0,
-                             "Check list router response"
-                             )
+            len(routers),
+            0,
+            "Check list router response"
+        )
 
         router = routers[0]
 
         self.debug("Stopping router with ID: %s" % router.id)
-        #Stop the router
+        # Stop the router
         cmd = stopRouter.stopRouterCmd()
         cmd.id = router.id
         self.apiclient.stopRouter(cmd)
 
         routers = list_routers(
-                               self.apiclient,
-                               account=self.account.name,
-                               domainid=self.account.domainid,
-                               )
+            self.apiclient,
+            account=self.account.name,
+            domainid=self.account.domainid,
+        )
         self.assertEqual(
-                        isinstance(routers, list),
-                        True,
-                        "Check for list routers response return valid data"
-                        )
+            isinstance(routers, list),
+            True,
+            "Check for list routers response return valid data"
+        )
         router = routers[0]
 
         self.assertEqual(
-                    router.state,
-                    'Stopped',
-                    "Check list router response for router state"
-                    )
+            router.state,
+            'Stopped',
+            "Check list router response for router state"
+        )
 
         public_ips = list_publicIP(
-                                   self.apiclient,
-                                   account=self.account.name,
-                                   domainid=self.account.domainid
-                                   )
+            self.apiclient,
+            account=self.account.name,
+            domainid=self.account.domainid
+        )
         self.assertEqual(
-                        isinstance(public_ips, list),
-                        True,
-                        "Check for list public IPs response return valid data"
-                        )
+            isinstance(public_ips, list),
+            True,
+            "Check for list public IPs response return valid data"
+        )
         public_ip = public_ips[0]
 
         # Open up firewall port for SSH
-        fw_rule = FireWallRule.create(
-                            self.apiclient,
-                            ipaddressid=public_ip.id,
-                            protocol=self.services["lbrule"]["protocol"],
-                            cidrlist=['0.0.0.0/0'],
-                            startport=self.services["lbrule"]["publicport"],
-                            endport=self.services["lbrule"]["publicport"]
-                            )
+        FireWallRule.create(
+            self.apiclient,
+            ipaddressid=public_ip.id,
+            protocol=self.services["lbrule"]["protocol"],
+            cidrlist=['0.0.0.0/0'],
+            startport=self.services["lbrule"]["publicport"],
+            endport=self.services["lbrule"]["publicport"]
+        )
         self.debug("Creating LB rule for public IP: %s" % public_ip.id)
-        #Create Load Balancer rule and assign VMs to rule
+        # Create Load Balancer rule and assign VMs to rule
         lb_rule = LoadBalancerRule.create(
-                                          self.apiclient,
-                                          self.services["lbrule"],
-                                          public_ip.id,
-                                          accountid=self.account.name
-                                          )
+            self.apiclient,
+            self.services["lbrule"],
+            public_ip.id,
+            accountid=self.account.name
+        )
         self.debug("Assigning VM %s to LB rule: %s" % (
-                                                       self.vm_1.id,
-                                                       lb_rule.id
-                                                       ))
+            self.vm_1.id,
+            lb_rule.id
+        ))
         lb_rule.assign(self.apiclient, [self.vm_1])
 
-        #Start the router
+        # Start the router
         cmd = startRouter.startRouterCmd()
         cmd.id = router.id
         self.apiclient.startRouter(cmd)
 
         routers = list_routers(
-                               self.apiclient,
-                               account=self.account.name,
-                               domainid=self.account.domainid,
-                               )
+            self.apiclient,
+            account=self.account.name,
+            domainid=self.account.domainid,
+        )
         self.assertEqual(
-                        isinstance(routers, list),
-                        True,
-                        "Check for list routers response return valid data"
-                        )
+            isinstance(routers, list),
+            True,
+            "Check for list routers response return valid data"
+        )
         router = routers[0]
 
         self.assertEqual(
-                    router.state,
-                    'Running',
-                    "Check list router response for router state"
-                    )
+            router.state,
+            'Running',
+            "Check list router response for router state"
+        )
         # After router start, LB RUle should be in Active state
         lb_rules = list_lb_rules(
-                                   self.apiclient,
-                                   id=lb_rule.id
-                                   )
+            self.apiclient,
+            id=lb_rule.id
+        )
         self.assertEqual(
-                        isinstance(lb_rules, list),
-                        True,
-                        "Check for list LB rules response return valid data"
-                        )
+            isinstance(lb_rules, list),
+            True,
+            "Check for list LB rules response return valid data"
+        )
         self.assertEqual(
-                    lb_rules[0].state,
-                    'Active',
-                    "Check list load balancing rules"
-                    )
+            lb_rules[0].state,
+            'Active',
+            "Check list load balancing rules"
+        )
         self.assertEqual(
-                    lb_rules[0].publicport,
-                    str(self.services["lbrule"]["publicport"]),
-                    "Check list load balancing rules"
-                    )
+            lb_rules[0].publicport,
+            str(self.services["lbrule"]["publicport"]),
+            "Check list load balancing rules"
+        )
 
         try:
             self.debug("SSH into VM with IP: %s" % public_ip.ipaddress)
@@ -1060,9 +1090,9 @@ class TestRouterStopCreateLB(cloudstackTestCase):
             self.vm_1.get_ssh_client(public_ip.ipaddress)
         except Exception as e:
             self.fail(
-                      "SSH Access failed for %s: %s" % \
-                      (self.vm_1.ipaddress, e)
-                      )
+                "SSH Access failed for %s: %s" %
+                (self.vm_1.ipaddress, e)
+            )
         return
 
 
@@ -1080,41 +1110,43 @@ class TestRouterStopCreateFW(cloudstackTestCase):
         cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
         cls.services['mode'] = cls.zone.networktype
         template = get_template(
-                            cls.api_client,
-                            cls.zone.id,
-                            cls.services["ostype"]
-                            )
+            cls.api_client,
+            cls.zone.id,
+            cls.services["ostype"]
+        )
         cls.services["virtual_machine"]["zoneid"] = cls.zone.id
 
-        #Create an account, network, VM and IP addresses
+        # Create an account, network, VM and IP addresses
         cls.account = Account.create(
-                                     cls.api_client,
-                                     cls.services["account"],
-                                     domainid=cls.domain.id
-                                     )
+            cls.api_client,
+            cls.services["account"],
+            domainid=cls.domain.id
+        )
         cls.service_offering = ServiceOffering.create(
-                                            cls.api_client,
-                                            cls.services["service_offering"]
-                                            )
+            cls.api_client,
+            cls.services["service_offering"]
+        )
         cls.vm_1 = VirtualMachine.create(
-                                    cls.api_client,
-                                    cls.services["virtual_machine"],
-                                    templateid=template.id,
-                                    accountid=cls.account.name,
-                                    domainid=cls.account.domainid,
-                                    serviceofferingid=cls.service_offering.id
-                                    )
+            cls.api_client,
+            cls.services["virtual_machine"],
+            templateid=template.id,
+            accountid=cls.account.name,
+            domainid=cls.account.domainid,
+            serviceofferingid=cls.service_offering.id
+        )
         cls._cleanup = [
-                       cls.account,
-                       cls.service_offering
-                       ]
+            cls.account,
+            cls.service_offering
+        ]
         return
 
     @classmethod
     def tearDownClass(cls):
         try:
-            cls.api_client = super(TestRouterStopCreateFW, cls).getClsTestClient().getApiClient()
-            #Clean up, terminate the created templates
+            cls.api_client = super(
+                TestRouterStopCreateFW,
+                cls).getClsTestClient().getApiClient()
+            # Clean up, terminate the created templates
             cleanup_resources(cls.api_client, cls._cleanup)
 
         except Exception as e:
@@ -1146,147 +1178,148 @@ class TestRouterStopCreateFW(cloudstackTestCase):
 
         # Get the router details associated with account
         routers = list_routers(
-                               self.apiclient,
-                               account=self.account.name,
-                               domainid=self.account.domainid,
-                               )
+            self.apiclient,
+            account=self.account.name,
+            domainid=self.account.domainid,
+        )
 
         self.assertEqual(
-                        isinstance(routers, list),
-                        True,
-                        "Check for list routers response return valid data"
-                        )
+            isinstance(routers, list),
+            True,
+            "Check for list routers response return valid data"
+        )
 
         self.assertNotEqual(
-                             len(routers),
-                             0,
-                             "Check list router response"
-                             )
+            len(routers),
+            0,
+            "Check list router response"
+        )
 
         router = routers[0]
 
         self.debug("Stopping the router: %s" % router.id)
-        #Stop the router
+        # Stop the router
         cmd = stopRouter.stopRouterCmd()
         cmd.id = router.id
         self.apiclient.stopRouter(cmd)
 
         routers = list_routers(
-                               self.apiclient,
-                               account=self.account.name,
-                               domainid=self.account.domainid,
-                               )
+            self.apiclient,
+            account=self.account.name,
+            domainid=self.account.domainid,
+        )
         self.assertEqual(
-                        isinstance(routers, list),
-                        True,
-                        "Check for list routers response return valid data"
-                        )
+            isinstance(routers, list),
+            True,
+            "Check for list routers response return valid data"
+        )
         router = routers[0]
 
         self.assertEqual(
-                    router.state,
-                    'Stopped',
-                    "Check list router response for router state"
-                    )
+            router.state,
+            'Stopped',
+            "Check list router response for router state"
+        )
 
         public_ips = list_publicIP(
-                                   self.apiclient,
-                                   account=self.account.name,
-                                   domainid=self.account.domainid
-                                   )
+            self.apiclient,
+            account=self.account.name,
+            domainid=self.account.domainid
+        )
         self.assertEqual(
-                        isinstance(public_ips, list),
-                        True,
-                        "Check for list public IP response return valid data"
-                        )
+            isinstance(public_ips, list),
+            True,
+            "Check for list public IP response return valid data"
+        )
         public_ip = public_ips[0]
 
-        #Create Firewall rule with configurations from settings file
+        # Create Firewall rule with configurations from settings file
         fw_rule = FireWallRule.create(
-                            self.apiclient,
-                            ipaddressid=public_ip.id,
-                            protocol='TCP',
-                            cidrlist=[self.services["fw_rule"]["cidr"]],
-                            startport=self.services["fw_rule"]["startport"],
-                            endport=self.services["fw_rule"]["endport"]
-                            )
+            self.apiclient,
+            ipaddressid=public_ip.id,
+            protocol='TCP',
+            cidrlist=[self.services["fw_rule"]["cidr"]],
+            startport=self.services["fw_rule"]["startport"],
+            endport=self.services["fw_rule"]["endport"]
+        )
         self.debug("Created firewall rule: %s" % fw_rule.id)
 
         self.debug("Starting the router: %s" % router.id)
-        #Start the router
+        # Start the router
         cmd = startRouter.startRouterCmd()
         cmd.id = router.id
         self.apiclient.startRouter(cmd)
 
         routers = list_routers(
-                               self.apiclient,
-                               account=self.account.name,
-                               domainid=self.account.domainid,
-                               )
+            self.apiclient,
+            account=self.account.name,
+            domainid=self.account.domainid,
+        )
         self.assertEqual(
-                        isinstance(routers, list),
-                        True,
-                        "Check for list routers response return valid data"
-                        )
+            isinstance(routers, list),
+            True,
+            "Check for list routers response return valid data"
+        )
 
         router = routers[0]
 
         self.assertEqual(
-                    router.state,
-                    'Running',
-                    "Check list router response for router state"
-                    )
+            router.state,
+            'Running',
+            "Check list router response for router state"
+        )
         # After Router start, FW rule should be in Active state
         fw_rules = list_firewall_rules(
-                                   self.apiclient,
-                                   id=fw_rule.id,
-                                   )
+            self.apiclient,
+            id=fw_rule.id,
+        )
         self.assertEqual(
-                        isinstance(fw_rules, list),
-                        True,
-                        "Check for list FW rules response return valid data"
-                        )
+            isinstance(fw_rules, list),
+            True,
+            "Check for list FW rules response return valid data"
+        )
 
         self.assertEqual(
-                    fw_rules[0].state,
-                    'Active',
-                    "Check list load balancing rules"
-                    )
+            fw_rules[0].state,
+            'Active',
+            "Check list load balancing rules"
+        )
         self.assertEqual(
-                    fw_rules[0].startport,
-                    str(self.services["fw_rule"]["startport"]),
-                    "Check start port of firewall rule"
-                    )
+            fw_rules[0].startport,
+            str(self.services["fw_rule"]["startport"]),
+            "Check start port of firewall rule"
+        )
 
         self.assertEqual(
-                    fw_rules[0].endport,
-                    str(self.services["fw_rule"]["endport"]),
-                    "Check end port of firewall rule"
-                    )
+            fw_rules[0].endport,
+            str(self.services["fw_rule"]["endport"]),
+            "Check end port of firewall rule"
+        )
         # For DNS and DHCP check 'dnsmasq' process status
         if (self.hypervisor.lower() == 'vmware'
-                         or self.hypervisor.lower() == 'hyperv'):
+                or self.hypervisor.lower() == 'hyperv'):
             result = get_process_status(
-                               self.apiclient.connection.mgtSvr,
-                               22,
-                               self.apiclient.connection.user,
-                               self.apiclient.connection.passwd,
-                               router.linklocalip,
-                               'iptables -t nat -L',
-                                hypervisor=self.hypervisor
-                               )
+                self.apiclient.connection.mgtSvr,
+                22,
+                self.apiclient.connection.user,
+                self.apiclient.connection.passwd,
+                router.linklocalip,
+                'iptables -t nat -L',
+                hypervisor=self.hypervisor
+            )
         else:
             hosts = list_hosts(
-                        self.apiclient,
-                        id=router.hostid,
-                        )
+                self.apiclient,
+                id=router.hostid,
+            )
             self.assertEqual(
-                        isinstance(hosts, list),
-                        True,
-                        "Check for list hosts response return valid data"
-                        )
+                isinstance(hosts, list),
+                True,
+                "Check for list hosts response return valid data"
+            )
             host = hosts[0]
-            host.user, host.passwd = get_host_credentials(self.config, host.ipaddress)
+            host.user, host.passwd = get_host_credentials(
+                self.config, host.ipaddress)
             try:
                 result = get_process_status(
                     host.ipaddress,
@@ -1297,7 +1330,10 @@ class TestRouterStopCreateFW(cloudstackTestCase):
                     'iptables -t nat -L'
                 )
             except KeyError:
-                self.skipTest("Provide a marvin config file with host credentials to run %s" % self._testMethodName)
+                self.skipTest(
+                    "Provide a marvin config file with host\
+                            credentials to run %s" %
+                    self._testMethodName)
 
         self.debug("iptables -t nat -L: %s" % result)
         self.debug("Public IP: %s" % public_ip.ipaddress)
@@ -1306,6 +1342,6 @@ class TestRouterStopCreateFW(cloudstackTestCase):
             res.count(str(public_ip.ipaddress)),
             1,
             "Check public IP address"
-            )
+        )
 
         return


[44/50] [abbrv] git commit: updated refs/heads/baremetal-systemvm to 23482b1

Posted by ki...@apache.org.
rats

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

Branch: refs/heads/baremetal-systemvm
Commit: 622041b513906c5a5f68b42194721e21ff641871
Parents: 1de0cb7
Author: Daan Hoogland <da...@onecht.net>
Authored: Fri Oct 17 11:56:07 2014 +0200
Committer: Daan Hoogland <da...@onecht.net>
Committed: Fri Oct 17 11:56:07 2014 +0200

----------------------------------------------------------------------
 .../cloud/network/router/NetworkHelperImplTest.java | 16 ++++++++++++++++
 .../network/router/RouterControlHelperTest.java     | 16 ++++++++++++++++
 .../VirtualNetworkApplianceManagerImplTest.java     | 16 ++++++++++++++++
 3 files changed, 48 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/622041b5/server/test/com/cloud/network/router/NetworkHelperImplTest.java
----------------------------------------------------------------------
diff --git a/server/test/com/cloud/network/router/NetworkHelperImplTest.java b/server/test/com/cloud/network/router/NetworkHelperImplTest.java
index 04c5067..74a0a60 100644
--- a/server/test/com/cloud/network/router/NetworkHelperImplTest.java
+++ b/server/test/com/cloud/network/router/NetworkHelperImplTest.java
@@ -1,3 +1,19 @@
+// 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.
 package com.cloud.network.router;
 
 import static org.junit.Assert.assertFalse;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/622041b5/server/test/com/cloud/network/router/RouterControlHelperTest.java
----------------------------------------------------------------------
diff --git a/server/test/com/cloud/network/router/RouterControlHelperTest.java b/server/test/com/cloud/network/router/RouterControlHelperTest.java
index 46d0fb2..4117ce0 100644
--- a/server/test/com/cloud/network/router/RouterControlHelperTest.java
+++ b/server/test/com/cloud/network/router/RouterControlHelperTest.java
@@ -1,3 +1,19 @@
+// 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.
 package com.cloud.network.router;
 
 import static org.junit.Assert.assertEquals;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/622041b5/server/test/com/cloud/network/router/VirtualNetworkApplianceManagerImplTest.java
----------------------------------------------------------------------
diff --git a/server/test/com/cloud/network/router/VirtualNetworkApplianceManagerImplTest.java b/server/test/com/cloud/network/router/VirtualNetworkApplianceManagerImplTest.java
index a7fa5f0..f358a36 100644
--- a/server/test/com/cloud/network/router/VirtualNetworkApplianceManagerImplTest.java
+++ b/server/test/com/cloud/network/router/VirtualNetworkApplianceManagerImplTest.java
@@ -1,3 +1,19 @@
+// 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.
 package com.cloud.network.router;
 
 import org.apache.cloudstack.framework.config.dao.ConfigurationDao;


[22/50] [abbrv] git commit: updated refs/heads/baremetal-systemvm to 23482b1

Posted by ki...@apache.org.
CLOUDSTACK-7728: Fixed adding icmp rules with different types and codes


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

Branch: refs/heads/baremetal-systemvm
Commit: f488a8f72cfa60ed9f6540f1d6ec1cb3b44579fa
Parents: 080bc2e
Author: Jayapal <ja...@apache.org>
Authored: Wed Oct 15 17:08:59 2014 +0530
Committer: Jayapal <ja...@apache.org>
Committed: Thu Oct 16 09:38:21 2014 +0530

----------------------------------------------------------------------
 server/src/com/cloud/network/firewall/FirewallManagerImpl.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/f488a8f7/server/src/com/cloud/network/firewall/FirewallManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/firewall/FirewallManagerImpl.java b/server/src/com/cloud/network/firewall/FirewallManagerImpl.java
index ddc2f73..0537a27 100644
--- a/server/src/com/cloud/network/firewall/FirewallManagerImpl.java
+++ b/server/src/com/cloud/network/firewall/FirewallManagerImpl.java
@@ -406,7 +406,7 @@ public class FirewallManagerImpl extends ManagerBase implements FirewallService,
                 (newRule.getSourcePortStart() != null && newRule.getSourcePortEnd() != null && rule.getSourcePortStart() != null && rule.getSourcePortEnd() != null);
             boolean nullPorts =
                 (newRule.getSourcePortStart() == null && newRule.getSourcePortEnd() == null && rule.getSourcePortStart() == null && rule.getSourcePortEnd() == null);
-            if(nullPorts && duplicatedCidrs && (rule.getProtocol().equalsIgnoreCase(newRule.getProtocol())))
+            if(nullPorts && duplicatedCidrs && (rule.getProtocol().equalsIgnoreCase(newRule.getProtocol())) && !newRule.getProtocol().equalsIgnoreCase(NetUtils.ICMP_PROTO))
             {
                 throw new NetworkRuleConflictException("There is already a firewall rule specified with protocol = " +newRule.getProtocol()+ " and no ports");
             }


[29/50] [abbrv] git commit: updated refs/heads/baremetal-systemvm to 23482b1

Posted by ki...@apache.org.
Removed duplicate code and unused imports which was causing build failure.


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

Branch: refs/heads/baremetal-systemvm
Commit: 80e0c99189c825989124d19e338346ab65738703
Parents: 53ee4cd
Author: Sanjay Tripathi <sa...@citrix.com>
Authored: Thu Oct 16 13:53:32 2014 +0530
Committer: Sanjay Tripathi <sa...@citrix.com>
Committed: Thu Oct 16 13:53:32 2014 +0530

----------------------------------------------------------------------
 .../networkservice/BaremetalKickStartServiceImpl.java |  7 ++-----
 .../src/com/cloud/resource/ResourceManagerImpl.java   | 14 --------------
 2 files changed, 2 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/80e0c991/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalKickStartServiceImpl.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalKickStartServiceImpl.java b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalKickStartServiceImpl.java
index df06650..2786e13 100755
--- a/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalKickStartServiceImpl.java
+++ b/plugins/hypervisors/baremetal/src/com/cloud/baremetal/networkservice/BaremetalKickStartServiceImpl.java
@@ -30,19 +30,16 @@ import java.util.Map;
 import javax.ejb.Local;
 import javax.inject.Inject;
 
-import com.cloud.configuration.Config;
-
-import org.apache.log4j.Logger;
-
 import org.apache.cloudstack.api.AddBaremetalKickStartPxeCmd;
 import org.apache.cloudstack.api.AddBaremetalPxeCmd;
 import org.apache.cloudstack.api.ListBaremetalPxeServersCmd;
 import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
+import org.apache.log4j.Logger;
 
 import com.cloud.agent.api.Answer;
 import com.cloud.agent.api.baremetal.IpmISetBootDevCommand;
-import com.cloud.agent.api.baremetal.PrepareKickstartPxeServerCommand;
 import com.cloud.agent.api.baremetal.IpmISetBootDevCommand.BootDev;
+import com.cloud.agent.api.baremetal.PrepareKickstartPxeServerCommand;
 import com.cloud.baremetal.database.BaremetalPxeDao;
 import com.cloud.baremetal.database.BaremetalPxeVO;
 import com.cloud.baremetal.networkservice.BaremetalPxeManager.BaremetalPxeType;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/80e0c991/server/src/com/cloud/resource/ResourceManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/resource/ResourceManagerImpl.java b/server/src/com/cloud/resource/ResourceManagerImpl.java
index 9594770..a0a3adf 100755
--- a/server/src/com/cloud/resource/ResourceManagerImpl.java
+++ b/server/src/com/cloud/resource/ResourceManagerImpl.java
@@ -1631,20 +1631,6 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager,
                 clusterId = c.getId();
             }
         }
-        StartupRoutingCommand ssCmd = (StartupRoutingCommand)startup;
-        List<String> implicitHostTags = ssCmd.getHostTags();
-        if (!implicitHostTags.isEmpty()) {
-            if (hostTags == null) {
-                hostTags = _hostTagsDao.gethostTags(host.getId());
-            }
-            if (hostTags != null) {
-                implicitHostTags.removeAll(hostTags);
-                hostTags.addAll(implicitHostTags);
-            } else {
-                hostTags = implicitHostTags;
-            }
-        }
-
         if (startup instanceof StartupRoutingCommand) {
             StartupRoutingCommand ssCmd = ((StartupRoutingCommand)startup);
             List<String> implicitHostTags = ssCmd.getHostTags();


[19/50] [abbrv] git commit: updated refs/heads/baremetal-systemvm to 23482b1

Posted by ki...@apache.org.
CLOUDSTACK-7728: Fixed adding icmp rules with different types and codes


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

Branch: refs/heads/baremetal-systemvm
Commit: 7cd34385801514b8c0ce51bc0d2ea036713c285c
Parents: 6967c6c
Author: Jayapal <ja...@apache.org>
Authored: Wed Oct 15 17:08:59 2014 +0530
Committer: Jayapal <ja...@apache.org>
Committed: Thu Oct 16 09:37:42 2014 +0530

----------------------------------------------------------------------
 server/src/com/cloud/network/firewall/FirewallManagerImpl.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/7cd34385/server/src/com/cloud/network/firewall/FirewallManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/firewall/FirewallManagerImpl.java b/server/src/com/cloud/network/firewall/FirewallManagerImpl.java
index ddc2f73..0537a27 100644
--- a/server/src/com/cloud/network/firewall/FirewallManagerImpl.java
+++ b/server/src/com/cloud/network/firewall/FirewallManagerImpl.java
@@ -406,7 +406,7 @@ public class FirewallManagerImpl extends ManagerBase implements FirewallService,
                 (newRule.getSourcePortStart() != null && newRule.getSourcePortEnd() != null && rule.getSourcePortStart() != null && rule.getSourcePortEnd() != null);
             boolean nullPorts =
                 (newRule.getSourcePortStart() == null && newRule.getSourcePortEnd() == null && rule.getSourcePortStart() == null && rule.getSourcePortEnd() == null);
-            if(nullPorts && duplicatedCidrs && (rule.getProtocol().equalsIgnoreCase(newRule.getProtocol())))
+            if(nullPorts && duplicatedCidrs && (rule.getProtocol().equalsIgnoreCase(newRule.getProtocol())) && !newRule.getProtocol().equalsIgnoreCase(NetUtils.ICMP_PROTO))
             {
                 throw new NetworkRuleConflictException("There is already a firewall rule specified with protocol = " +newRule.getProtocol()+ " and no ports");
             }


[47/50] [abbrv] git commit: updated refs/heads/baremetal-systemvm to 23482b1

Posted by ki...@apache.org.
CLOUDSTACK-5576: UI > IP Address > EnableVPN, DisableVPN: change label.


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

Branch: refs/heads/baremetal-systemvm
Commit: 3db112f75c3e2391bce896c868095f3444e43451
Parents: 248e4fb
Author: Jessica Wang <je...@apache.org>
Authored: Fri Oct 17 14:46:23 2014 -0700
Committer: Jessica Wang <je...@apache.org>
Committed: Fri Oct 17 14:58:51 2014 -0700

----------------------------------------------------------------------
 client/WEB-INF/classes/resources/messages.properties | 10 +++++-----
 ui/scripts/network.js                                |  2 +-
 2 files changed, 6 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3db112f7/client/WEB-INF/classes/resources/messages.properties
----------------------------------------------------------------------
diff --git a/client/WEB-INF/classes/resources/messages.properties b/client/WEB-INF/classes/resources/messages.properties
index a76855f..fb506d4 100644
--- a/client/WEB-INF/classes/resources/messages.properties
+++ b/client/WEB-INF/classes/resources/messages.properties
@@ -532,7 +532,7 @@ label.DHCP.server.type=DHCP Server Type
 label.dhcp=DHCP
 label.direct.ips=Shared Network IPs
 label.disable.provider=Disable provider
-label.disable.vpn=Disable VPN
+label.disable.vpn=Disable Remote Access VPN
 label.disabled=Disabled
 label.disabling.vpn.access=Disabling VPN Access
 label.disk.allocated=Disk Allocated
@@ -583,7 +583,7 @@ label.email=Email
 label.enable.provider=Enable provider
 label.enable.s3=Enable S3-backed Secondary Storage
 label.enable.swift=Enable Swift
-label.enable.vpn=Enable VPN
+label.enable.vpn=Enable Remote Access VPN
 label.enabling.vpn.access=Enabling VPN Access
 label.enabling.vpn=Enabling VPN
 label.end.IP=End IP
@@ -1780,7 +1780,7 @@ message.detach.iso.confirm=Please confirm that you want to detach the ISO from t
 message.disable.account=Please confirm that you want to disable this account.  By disabling the account, all users for this account will no longer have access to their cloud resources.  All running virtual machines will be immediately shut down.
 message.disable.snapshot.policy=You have successfully disabled your current snapshot policy.
 message.disable.user=Please confirm that you would like to disable this user.
-message.disable.vpn.access=Please confirm that you want to disable VPN Access.
+message.disable.vpn.access=Please confirm that you want to disable Remote Access VPN.
 message.disable.vpn=Are you sure you want to disable VPN?
 message.download.ISO=Please click <a href\="\#">00000</a> to download ISO
 message.download.template=Please click <a href\="\#">00000</a> to download template
@@ -1793,9 +1793,9 @@ message.edit.traffic.type=Please specify the traffic label you want associated w
 message.enable.account=Please confirm that you want to enable this account.
 message.enable.user=Please confirm that you would like to enable this user.
 message.enable.vpn.access=VPN is currently disabled for this IP Address.  Would you like to enable VPN access?
-message.enable.vpn=Please confirm that you want VPN access enabled for this IP address.
+message.enable.vpn=Please confirm that you want Remote Access VPN enabled for this IP address.
 message.enabled.vpn.ip.sec=Your IPSec pre-shared key is
-message.enabled.vpn=Your VPN access is currently enabled and can be accessed via the IP
+message.enabled.vpn=Your Remote Access VPN is currently enabled and can be accessed via the IP
 message.enabling.security.group.provider=Enabling Security Group provider
 message.enabling.zone=Enabling zone
 message.enter.token=Please enter the token that you were given in your invite e-mail.

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/3db112f7/ui/scripts/network.js
----------------------------------------------------------------------
diff --git a/ui/scripts/network.js b/ui/scripts/network.js
index 9d79d3f..d011083 100755
--- a/ui/scripts/network.js
+++ b/ui/scripts/network.js
@@ -2396,7 +2396,7 @@
                                     	if (args.vpn.state == "Running") {
                                     	    msg = _l('message.enabled.vpn') + ' ' + args.vpn.publicip + '.' + '<br/>' + _l('message.enabled.vpn.ip.sec') + '<br/>' + args.vpn.presharedkey;                                	
                                     	} else {
-                                    		msg = "VPN configuration has been generated, but it failed to apply. Please check connectivity of the network element, then re-try.";
+                                    		msg = "Remote Access VPN configuration has been generated, but it failed to apply. Please check connectivity of the network element, then re-try.";
                                     	}   
                                         return msg;
                                     }


[26/50] [abbrv] Fixed coverity and other resource leak issues

Posted by ki...@apache.org.
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/efe1e0a5/server/src/com/cloud/api/doc/ApiXmlDocWriter.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/doc/ApiXmlDocWriter.java b/server/src/com/cloud/api/doc/ApiXmlDocWriter.java
index 54fdfbe..2d2cada 100644
--- a/server/src/com/cloud/api/doc/ApiXmlDocWriter.java
+++ b/server/src/com/cloud/api/doc/ApiXmlDocWriter.java
@@ -492,8 +492,10 @@ public class ApiXmlDocWriter {
     private static void deleteDir(File dir) {
         if (dir.isDirectory()) {
             String[] children = dir.list();
-            for (int i = 0; i < children.length; i++) {
-                deleteDir(new File(dir, children[i]));
+            if (children != null) {
+                for (int i = 0; i < children.length; i++) {
+                    deleteDir(new File(dir, children[i]));
+                }
             }
         }
         dir.delete();

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/efe1e0a5/services/secondary-storage/server/src/org/apache/cloudstack/storage/resource/NfsSecondaryStorageResource.java
----------------------------------------------------------------------
diff --git a/services/secondary-storage/server/src/org/apache/cloudstack/storage/resource/NfsSecondaryStorageResource.java b/services/secondary-storage/server/src/org/apache/cloudstack/storage/resource/NfsSecondaryStorageResource.java
index 230ef84..55f80e1 100755
--- a/services/secondary-storage/server/src/org/apache/cloudstack/storage/resource/NfsSecondaryStorageResource.java
+++ b/services/secondary-storage/server/src/org/apache/cloudstack/storage/resource/NfsSecondaryStorageResource.java
@@ -962,11 +962,14 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S
         List<String> files = new ArrayList<String>();
         if (lFilename.equals("*")) {
             File dir = new File(lDir);
-            for (String file : dir.list()) {
-                if (file.startsWith(".")) {
-                    continue;
+            String [] dir_lst = dir.list();
+            if(dir_lst != null) {
+                for (String file : dir_lst) {
+                    if (file.startsWith(".")) {
+                        continue;
+                    }
+                    files.add(file);
                 }
-                files.add(file);
             }
         } else {
             files.add(lFilename);
@@ -1203,33 +1206,41 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S
             try {
                 File prvKeyFile = File.createTempFile("prvkey", null);
                 String prvkeyPath = prvKeyFile.getAbsolutePath();
-                BufferedWriter out = new BufferedWriter(new FileWriter(prvKeyFile));
-                out.write(prvKey);
-                out.close();
+                try(BufferedWriter prvt_key_file = new BufferedWriter(new FileWriter(prvKeyFile));) {
+                    prvt_key_file.write(prvKey);
+                }catch (IOException e) {
+                    s_logger.debug("Failed to config ssl: " + e.toString());
+                }
 
                 File pubCertFile = File.createTempFile("pubcert", null);
                 String pubCertFilePath = pubCertFile.getAbsolutePath();
 
-                out = new BufferedWriter(new FileWriter(pubCertFile));
-                out.write(pubCert);
-                out.close();
+                try(BufferedWriter pub_cert_file = new BufferedWriter(new FileWriter(pubCertFile));) {
+                    pub_cert_file.write(pubCert);
+                }catch (IOException e) {
+                    s_logger.debug("Failed to config ssl: " + e.toString());
+                }
 
                 String certChainFilePath = null, rootCACertFilePath = null;
                 File certChainFile = null, rootCACertFile = null;
                 if(certChain != null){
                     certChainFile = File.createTempFile("certchain", null);
                     certChainFilePath = certChainFile.getAbsolutePath();
-                    out = new BufferedWriter(new FileWriter(certChainFile));
-                    out.write(certChain);
-                    out.close();
+                    try(BufferedWriter cert_chain_out = new BufferedWriter(new FileWriter(certChainFile));) {
+                        cert_chain_out.write(certChain);
+                    }catch (IOException e) {
+                        s_logger.debug("Failed to config ssl: " + e.toString());
+                    }
                 }
 
                 if(rootCACert != null){
                     rootCACertFile = File.createTempFile("rootcert", null);
                     rootCACertFilePath = rootCACertFile.getAbsolutePath();
-                    out = new BufferedWriter(new FileWriter(rootCACertFile));
-                    out.write(rootCACert);
-                    out.close();
+                    try(BufferedWriter root_ca_cert_file = new BufferedWriter(new FileWriter(rootCACertFile));) {
+                        root_ca_cert_file.write(rootCACert);
+                    }catch (IOException e) {
+                        s_logger.debug("Failed to config ssl: " + e.toString());
+                    }
                 }
 
                 configureSSL(prvkeyPath, pubCertFilePath, certChainFilePath, rootCACertFilePath);