cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject [2/3] git commit: updated refs/heads/4.4 to ee9613b
Date Mon, 28 Jul 2014 21:11:31 GMT
CLOUDSTACK-5674:Fixed pep8 errors in python files in marvin folder
Signed-off-by: SrikanteswaraRao Talluri <talluri@apache.org>

(cherry picked from commit 4f1f182cba5579da2fc7ce1f02019a0afa00efeb)

Conflicts:
	tools/marvin/marvin/lib/base.py


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

Branch: refs/heads/4.4
Commit: 4a99cf851966512ae90633b7ed7d7954b6d0ac9a
Parents: e33d4a5
Author: SrikanteswaraRao Talluri <talluri@apache.org>
Authored: Mon Apr 28 17:54:15 2014 +0530
Committer: Daan Hoogland <daan@onecht.net>
Committed: Mon Jul 28 23:10:31 2014 +0200

----------------------------------------------------------------------
 tools/marvin/marvin/cloudstackConnection.py |   2 +-
 tools/marvin/marvin/codegenerator.py        |  19 +-
 tools/marvin/marvin/codes.py                |   4 +-
 tools/marvin/marvin/configGenerator.py      |  10 +-
 tools/marvin/marvin/deployAndRun.py         |   4 +-
 tools/marvin/marvin/lib/__init__.py         |   4 +-
 tools/marvin/marvin/lib/base.py             | 504 +++++++++++++++--------
 tools/marvin/marvin/lib/common.py           | 176 +++++---
 tools/marvin/marvin/lib/utils.py            | 206 +++++----
 tools/marvin/marvin/marvinInit.py           |  13 +-
 tools/marvin/marvin/marvinPlugin.py         |   2 +-
 tools/marvin/marvin/sshClient.py            |   6 +-
 12 files changed, 594 insertions(+), 356 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4a99cf85/tools/marvin/marvin/cloudstackConnection.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/cloudstackConnection.py b/tools/marvin/marvin/cloudstackConnection.py
index d006002..caa8609 100644
--- a/tools/marvin/marvin/cloudstackConnection.py
+++ b/tools/marvin/marvin/cloudstackConnection.py
@@ -149,7 +149,7 @@ class CSConnection(object):
                 [str.lower(r[0]),
                  str.lower(
                      urllib.quote_plus(str(r[1]))
-                 ).replace("+", "%20")]
+                ).replace("+", "%20")]
             ) for r in params]
         )
         signature = base64.encodestring(hmac.new(

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4a99cf85/tools/marvin/marvin/codegenerator.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/codegenerator.py b/tools/marvin/marvin/codegenerator.py
index 1e02ddf..e5015c6 100644
--- a/tools/marvin/marvin/codegenerator.py
+++ b/tools/marvin/marvin/codegenerator.py
@@ -343,7 +343,7 @@ class CodeGenerator(object):
             paramProperty.desc = response['description']
         if 'type' in response:
             if response['type'] in ['list', 'map', 'set']:
-            # Here list becomes a subproperty
+                # Here list becomes a subproperty
                 if 'response' in response:
                     for innerResponse in response['response']:
                         subProperty =\
@@ -359,9 +359,9 @@ class CodeGenerator(object):
         jsonOut = apiStream.readlines()
         assert len(jsonOut) > 0
         apiDict = json.loads(jsonOut[0])
-        if not 'listapisresponse' in apiDict:
+        if 'listapisresponse' not in apiDict:
             raise Exception("API discovery plugin response failed")
-        if not 'count' in apiDict['listapisresponse']:
+        if 'count' not in apiDict['listapisresponse']:
             raise Exception("Malformed api response")
 
         apilist = apiDict['listapisresponse']['api']
@@ -397,7 +397,8 @@ class CodeGenerator(object):
                 csCmd.request.append(paramProperty)
 
             for response in cmd['response']:
-            # FIXME: ExtractImage related APIs return empty dicts in response
+                # FIXME: ExtractImage related APIs return empty dicts in
+                # response
                 if len(response) > 0:
                     paramProperty = self.constructResponseFromJSON(response)
                     csCmd.response.append(paramProperty)
@@ -412,11 +413,11 @@ class CodeGenerator(object):
         @return: The classes in cloudstackAPI/ formed from api discovery json
         """
         if endpointUrl.find('response=json') >= 0:
-                apiStream = urllib2.urlopen(endpointUrl)
-                cmds = self.loadCmdFromJSON(apiStream)
-                for cmd in cmds:
-                    self.generate(cmd)
-                self.finalize()
+            apiStream = urllib2.urlopen(endpointUrl)
+            cmds = self.loadCmdFromJSON(apiStream)
+            for cmd in cmds:
+                self.generate(cmd)
+            self.finalize()
 
 
 def getText(elements):

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4a99cf85/tools/marvin/marvin/codes.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/codes.py b/tools/marvin/marvin/codes.py
index 98299fa..ef49c0c 100644
--- a/tools/marvin/marvin/codes.py
+++ b/tools/marvin/marvin/codes.py
@@ -79,5 +79,5 @@ ADMIN = 1
 DOMAIN_ADMIN = 2
 USER = 0
 XEN_SERVER = "XenServer"
-ADMIN_ACCOUNT='ADMIN_ACCOUNT'
-USER_ACCOUNT='USER_ACCOUNT'
+ADMIN_ACCOUNT = 'ADMIN_ACCOUNT'
+USER_ACCOUNT = 'USER_ACCOUNT'

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4a99cf85/tools/marvin/marvin/configGenerator.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/configGenerator.py b/tools/marvin/marvin/configGenerator.py
index bc77153..8556274 100644
--- a/tools/marvin/marvin/configGenerator.py
+++ b/tools/marvin/marvin/configGenerator.py
@@ -47,17 +47,20 @@ class dbServer(object):
 
 
 class configuration(object):
+
     def __init__(self):
         self.name = None
         self.value = None
 
 
 class logger(object):
+
     def __init__(self):
         self.LogFolderPath = None
 
 
 class cloudstackConfiguration(object):
+
     def __init__(self):
         self.zones = []
         self.mgtSvr = []
@@ -68,6 +71,7 @@ class cloudstackConfiguration(object):
 
 
 class zone(object):
+
     def __init__(self):
         self.dns1 = None
         self.internaldns1 = None
@@ -846,8 +850,8 @@ def descSetupInAdvancedsgMode():
                     memory = 8 * 1024 * 1024 * 1024
                     localstorage = 1 * 1024 * 1024 * 1024 * 1024
                     # h.url = "http://sim/%d%d%d%d/cpucore=1&cpuspeed=8000&\
-                        # memory=%d&localstorage=%d" % (l, i, j, k, memory,
-                        # localstorage)
+                    # memory=%d&localstorage=%d" % (l, i, j, k, memory,
+                    # localstorage)
                     h.url = "http://sim/%d%d%d%d" % (l, i, j, k)
                     c.hosts.append(h)
 
@@ -856,8 +860,6 @@ def descSetupInAdvancedsgMode():
                     primary = primaryStorage()
                     primary.name = "primary" + \
                         str(l) + str(i) + str(j) + str(m)
-                    # primary.url = "nfs://localhost/path%s/size=%d" % \
-                        #(str(l) + str(i) + str(j) + str(m), size)
                     primary.url = "nfs://localhost/path%s" % \
                         (str(l) + str(i) + str(j) + str(m))
                     c.primaryStorages.append(primary)

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4a99cf85/tools/marvin/marvin/deployAndRun.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/deployAndRun.py b/tools/marvin/marvin/deployAndRun.py
index d3b6b86..9f392e5 100644
--- a/tools/marvin/marvin/deployAndRun.py
+++ b/tools/marvin/marvin/deployAndRun.py
@@ -97,8 +97,8 @@ def startMarvin(cfg_file, load_flag):
             print "\nMarvin Initialization Failed"
             exit(1)
     except Exception as e:
-            print "\n Exception occurred while starting Marvin %s" % str(e)
-            exit(1)
+        print "\n Exception occurred while starting Marvin %s" % str(e)
+        exit(1)
 
 
 def runTCs(num_iter, inp1, inp2):

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4a99cf85/tools/marvin/marvin/lib/__init__.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/lib/__init__.py b/tools/marvin/marvin/lib/__init__.py
index 978b68a..13a8339 100644
--- a/tools/marvin/marvin/lib/__init__.py
+++ b/tools/marvin/marvin/lib/__init__.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

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4a99cf85/tools/marvin/marvin/lib/base.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/lib/base.py b/tools/marvin/marvin/lib/base.py
index 2cd7009..d2dc1a3 100644
--- a/tools/marvin/marvin/lib/base.py
+++ b/tools/marvin/marvin/lib/base.py
@@ -20,13 +20,12 @@
 """
 
 import marvin
-from utils import is_server_ssh_ready, random_gen
 from marvin.cloudstackAPI import *
 from marvin.codes import (FAILED, FAIL, PASS, RUNNING, STOPPED,
                           STARTING, DESTROYED, EXPUNGING,
                           STOPPING)
 from marvin.cloudstackException import GetDetailExceptionInfo
-from marvin.lib.utils import validateList
+from marvin.lib.utils import validateList, is_server_ssh_ready, random_gen
 # Import System modules
 import time
 import hashlib
@@ -34,7 +33,9 @@ import base64
 
 
 class Domain:
+
     """ Domain Life Cycle """
+
     def __init__(self, items):
         self.__dict__.update(items)
 
@@ -86,7 +87,9 @@ class Domain:
 
 
 class Account:
+
     """ Account Life Cycle """
+
     def __init__(self, items):
         self.__dict__.update(items)
 
@@ -104,16 +107,16 @@ class Account:
 
         cmd.password = services["password"]
 
-        username = "-".join([services["username"], random_gen(id=apiclient.id)])
+        username = "-".join([services["username"],
+                             random_gen(id=apiclient.id)])
         #  Trim username to 99 characters to prevent failure
         cmd.username = username[:99] if len(username) > 99 else username
 
         if "accountUUID" in services:
-            cmd.accountid =  "-".join([services["accountUUID"],random_gen()])
+            cmd.accountid = "-".join([services["accountUUID"], random_gen()])
 
         if "userUUID" in services:
-            cmd.userid = "-".join([services["userUUID"],random_gen()])
-
+            cmd.userid = "-".join([services["userUUID"], random_gen()])
 
         if domainid:
             cmd.domainid = domainid
@@ -145,7 +148,9 @@ class Account:
 
 
 class User:
+
     """ User Life Cycle """
+
     def __init__(self, items):
         self.__dict__.update(items)
 
@@ -161,7 +166,7 @@ class User:
         cmd.lastname = services["lastname"]
 
         if "userUUID" in services:
-            cmd.userid = "-".join([services["userUUID"],random_gen()])
+            cmd.userid = "-".join([services["userUUID"], random_gen()])
 
         cmd.password = services["password"]
         cmd.username = "-".join([services["username"], random_gen()])
@@ -222,6 +227,7 @@ class User:
 
 
 class VirtualMachine:
+
     """Manage virtual machine lifecycle"""
 
     '''Class level variables'''
@@ -255,7 +261,8 @@ class VirtualMachine:
     @classmethod
     def ssh_access_group(cls, apiclient, cmd):
         """
-        Programs the security group with SSH access before deploying virtualmachine
+        Programs the security group with SSH
+         access before deploying virtualmachine
         @return:
         """
         zone_list = Zone.list(
@@ -264,7 +271,7 @@ class VirtualMachine:
             domainid=cmd.domainid if cmd.domainid else None
         )
         zone = zone_list[0]
-        #check if security groups settings is enabled for the zone
+        # check if security groups settings is enabled for the zone
         if zone.securitygroupsenabled:
             list_security_groups = SecurityGroup.list(
                 apiclient,
@@ -287,9 +294,11 @@ class VirtualMachine:
                     "endport": 22,
                     "cidrlist": "0.0.0.0/0"
                 }
-                #Authorize security group for above ingress rule
-                basic_mode_security_group.authorize(apiclient, sec_grp_services, account=cmd.account,
-                    domainid=cmd.domainid)
+                # Authorize security group for above ingress rule
+                basic_mode_security_group.authorize(apiclient,
+                                                    sec_grp_services,
+                                                    account=cmd.account,
+                                                    domainid=cmd.domainid)
             else:
                 basic_mode_security_group = list_security_groups[0]
 
@@ -299,7 +308,8 @@ class VirtualMachine:
                 cmd.securitygroupids = [basic_mode_security_group.id]
 
     @classmethod
-    def access_ssh_over_nat(cls, apiclient, services, virtual_machine, allow_egress=False):
+    def access_ssh_over_nat(
+            cls, apiclient, services, virtual_machine, allow_egress=False):
         """
         Program NAT and PF rules to open up ssh access to deployed guest
         @return:
@@ -337,11 +347,13 @@ class VirtualMachine:
 
     @classmethod
     def create(cls, apiclient, services, templateid=None, accountid=None,
-                    domainid=None, zoneid=None, networkids=None, serviceofferingid=None,
-                    securitygroupids=None, projectid=None, startvm=None,
-                    diskofferingid=None, affinitygroupnames=None, affinitygroupids=None, group=None,
-                    hostid=None, keypair=None, ipaddress=None, mode='default', method='GET',hypervisor=None,
-                    customcpunumber=None, customcpuspeed=None, custommemory=None, rootdisksize=None):
+               domainid=None, zoneid=None, networkids=None,
+               serviceofferingid=None, securitygroupids=None,
+               projectid=None, startvm=None, diskofferingid=None,
+               affinitygroupnames=None, affinitygroupids=None, group=None,
+               hostid=None, keypair=None, ipaddress=None, mode='default',
+               method='GET', hypervisor=None, customcpunumber=None,
+               customcpuspeed=None, custommemory=None, rootdisksize=None):
         """Create the instance"""
 
         cmd = deployVirtualMachine.deployVirtualMachineCmd()
@@ -410,12 +422,12 @@ class VirtualMachine:
             cmd.securitygroupids = [str(sg_id) for sg_id in securitygroupids]
 
         if "affinitygroupnames" in services:
-            cmd.affinitygroupnames  = services["affinitygroupnames"]
+            cmd.affinitygroupnames = services["affinitygroupnames"]
         elif affinitygroupnames:
-            cmd.affinitygroupnames  = affinitygroupnames
+            cmd.affinitygroupnames = affinitygroupnames
 
         if affinitygroupids:
-            cmd.affinitygroupids  = affinitygroupids
+            cmd.affinitygroupids = affinitygroupids
 
         if projectid:
             cmd.projectid = projectid
@@ -446,25 +458,31 @@ class VirtualMachine:
         if group:
             cmd.group = group
 
-        #program default access to ssh
+        # program default access to ssh
         if mode.lower() == 'basic':
             cls.ssh_access_group(apiclient, cmd)
 
         virtual_machine = apiclient.deployVirtualMachine(cmd, method=method)
 
         virtual_machine.ssh_ip = virtual_machine.nic[0].ipaddress
-        if startvm == False:
+        if startvm is False:
             virtual_machine.public_ip = virtual_machine.nic[0].ipaddress
             return VirtualMachine(virtual_machine.__dict__, services)
 
-        #program ssh access over NAT via PF
+        # program ssh access over NAT via PF
         if mode.lower() == 'advanced':
-            cls.access_ssh_over_nat(apiclient, services, virtual_machine, allow_egress=allow_egress)
+            cls.access_ssh_over_nat(
+                apiclient,
+                services,
+                virtual_machine,
+                allow_egress=allow_egress)
         elif mode.lower() == 'basic':
             if virtual_machine.publicip is not None:
-                vm_ssh_ip = virtual_machine.publicip #EIP/ELB (netscaler) enabled zone
+                # EIP/ELB (netscaler) enabled zone
+                vm_ssh_ip = virtual_machine.publicip
             else:
-                vm_ssh_ip = virtual_machine.nic[0].ipaddress #regular basic zone with security group
+                # regular basic zone with security group
+                vm_ssh_ip = virtual_machine.nic[0].ipaddress
             virtual_machine.ssh_ip = vm_ssh_ip
             virtual_machine.public_ip = vm_ssh_ip
 
@@ -512,12 +530,14 @@ class VirtualMachine:
             cmd.templateid = templateid
         return apiclient.restoreVirtualMachine(cmd)
 
-    def get_ssh_client(self, ipaddress=None, reconnect=False, port=None, keyPairFileLocation=None):
+    def get_ssh_client(
+            self, ipaddress=None, reconnect=False, port=None,
+            keyPairFileLocation=None):
         """Get SSH object of VM"""
 
         # If NAT Rules are not created while VM deployment in Advanced mode
         # then, IP address must be passed
-        if ipaddress != None:
+        if ipaddress is not None:
             self.ssh_ip = ipaddress
         if port:
             self.ssh_port = port
@@ -527,19 +547,19 @@ class VirtualMachine:
 
         if reconnect:
             self.ssh_client = is_server_ssh_ready(
-                                                    self.ssh_ip,
-                                                    self.ssh_port,
-                                                    self.username,
-                                                    self.password,
-                                                    keyPairFileLocation=keyPairFileLocation
-                                                )
+                self.ssh_ip,
+                self.ssh_port,
+                self.username,
+                self.password,
+                keyPairFileLocation=keyPairFileLocation
+            )
         self.ssh_client = self.ssh_client or is_server_ssh_ready(
-                                                    self.ssh_ip,
-                                                    self.ssh_port,
-                                                    self.username,
-                                                    self.password,
-                                                    keyPairFileLocation=keyPairFileLocation
-                                                )
+            self.ssh_ip,
+            self.ssh_port,
+            self.username,
+            self.password,
+            keyPairFileLocation=keyPairFileLocation
+        )
         return self.ssh_client
 
     def getState(self, apiclient, state, timeout=600):
@@ -636,7 +656,8 @@ class VirtualMachine:
 
     def update_default_nic(self, apiclient, nicId):
         """Set a NIC to be the default network adapter for a VM"""
-        cmd = updateDefaultNicForVirtualMachine.updateDefaultNicForVirtualMachineCmd()
+        cmd = updateDefaultNicForVirtualMachine.\
+            updateDefaultNicForVirtualMachineCmd()
         cmd.nicid = nicId
         cmd.virtualmachineid = self.id
         return apiclient.updateDefaultNicForVirtualMachine(cmd)
@@ -653,7 +674,7 @@ class VirtualMachine:
         cmd = detachIso.detachIsoCmd()
         cmd.virtualmachineid = self.id
         return apiclient.detachIso(cmd)
-    
+
     def scale_virtualmachine(self, apiclient, serviceOfferingId):
         """ Scale up of service offering for the Instance"""
         cmd = scaleVirtualMachine.scaleVirtualMachineCmd()
@@ -663,7 +684,8 @@ class VirtualMachine:
 
     def change_service_offering(self, apiclient, serviceOfferingId):
         """Change service offering of the instance"""
-        cmd = changeServiceForVirtualMachine.changeServiceForVirtualMachineCmd()
+        cmd = changeServiceForVirtualMachine.\
+            changeServiceForVirtualMachineCmd()
         cmd.id = self.id
         cmd.serviceofferingid = serviceOfferingId
         return apiclient.changeServiceForVirtualMachine(cmd)
@@ -679,7 +701,8 @@ class VirtualMachine:
     def resetPassword(self, apiclient):
         """Resets VM password if VM created using password enabled template"""
 
-        cmd = resetPasswordForVirtualMachine.resetPasswordForVirtualMachineCmd()
+        cmd = resetPasswordForVirtualMachine.\
+            resetPasswordForVirtualMachineCmd()
         cmd.id = self.id
         try:
             response = apiclient.resetPasswordForVirtualMachine(cmd)
@@ -691,15 +714,15 @@ class VirtualMachine:
     def assign_virtual_machine(self, apiclient, account, domainid):
         """Move a user VM to another user under same domain."""
 
-        cmd                  = assignVirtualMachine.assignVirtualMachineCmd()
+        cmd = assignVirtualMachine.assignVirtualMachineCmd()
         cmd.virtualmachineid = self.id
-        cmd.account          = account
-        cmd.domainid         = domainid
+        cmd.account = account
+        cmd.domainid = domainid
         try:
             response = apiclient.assignVirtualMachine(cmd)
             return response
         except Exception as e:
-            raise Exception("assignVirtualMachine failed - %s" %e)
+            raise Exception("assignVirtualMachine failed - %s" % e)
 
     def update_affinity_group(self, apiclient, affinitygroupids=None,
                               affinitygroupnames=None):
@@ -716,12 +739,12 @@ class VirtualMachine:
         return apiclient.updateVMAffinityGroup(cmd)
 
     def scale(self, apiclient, serviceOfferingId,
-            customcpunumber=None, customcpuspeed=None, custommemory=None):
+              customcpunumber=None, customcpuspeed=None, custommemory=None):
         """Change service offering of the instance"""
         cmd = scaleVirtualMachine.scaleVirtualMachineCmd()
         cmd.id = self.id
         cmd.serviceofferingid = serviceOfferingId
-        cmd.details = [{"cpuNumber": "","cpuSpeed":"","memory":""}]
+        cmd.details = [{"cpuNumber": "", "cpuSpeed": "", "memory": ""}]
         if customcpunumber:
             cmd.details[0]["cpuNumber"] = customcpunumber
         if customcpuspeed:
@@ -732,8 +755,10 @@ class VirtualMachine:
 
 
 class Volume:
+
     """Manage Volume Life cycle
     """
+
     def __init__(self, items):
         self.__dict__.update(items)
 
@@ -770,7 +795,7 @@ class Volume:
 
     @classmethod
     def create_custom_disk(cls, apiclient, services, account=None,
-                                    domainid=None, diskofferingid=None):
+                           domainid=None, diskofferingid=None):
         """Create Volume from Custom disk offering"""
         cmd = createVolume.createVolumeCmd()
         cmd.name = services["diskname"]
@@ -836,7 +861,8 @@ class Volume:
         return(apiclient.resizeVolume(cmd))
 
     @classmethod
-    def upload(cls, apiclient, services, zoneid=None, account=None, domainid=None, url=None):
+    def upload(cls, apiclient, services, zoneid=None,
+               account=None, domainid=None, url=None):
         """Uploads the volume to specified account"""
 
         cmd = uploadVolume.uploadVolumeCmd()
@@ -861,10 +887,10 @@ class Volume:
 
         while True:
             volume_response = Volume.list(
-                                    apiclient,
-                                    id=self.id,
-                                    zoneid=self.zoneid,
-                                    )
+                apiclient,
+                id=self.id,
+                zoneid=self.zoneid,
+            )
             if isinstance(volume_response, list):
 
                 volume = volume_response[0]
@@ -879,7 +905,7 @@ class Volume:
                 elif 'Installing' not in volume.state:
                     raise Exception(
                         "Error in uploading volume: status - %s" %
-                                                            volume.state)
+                        volume.state)
             elif timeout == 0:
                 break
 
@@ -891,7 +917,7 @@ class Volume:
     @classmethod
     def extract(cls, apiclient, volume_id, zoneid, mode):
         """Extracts the volume"""
-        
+
         cmd = extractVolume.extractVolumeCmd()
         cmd.id = volume_id
         cmd.zoneid = zoneid
@@ -905,15 +931,18 @@ class Volume:
         [setattr(cmd, k, v) for k, v in kwargs.items()]
         return(apiclient.migrateVolume(cmd))
 
+
 class Snapshot:
+
     """Manage Snapshot Lifecycle
     """
+
     def __init__(self, items):
         self.__dict__.update(items)
 
     @classmethod
     def create(cls, apiclient, volume_id, account=None,
-                                            domainid=None, projectid=None):
+               domainid=None, projectid=None):
         """Create Snapshot"""
         cmd = createSnapshot.createSnapshotCmd()
         cmd.volumeid = volume_id
@@ -941,6 +970,7 @@ class Snapshot:
 
 
 class Template:
+
     """Manage template life cycle"""
 
     def __init__(self, items):
@@ -965,16 +995,20 @@ class Template:
             if not isinstance(ostypes, list):
                 raise Exception(
                     "Unable to find Ostype id with desc: %s" %
-                                                services["ostype"])
+                    services["ostype"])
             cmd.ostypeid = ostypes[0].id
         else:
             raise Exception(
-                    "Unable to find Ostype is required for creating template")
+                "Unable to find Ostype is required for creating template")
 
-        cmd.isfeatured = services["isfeatured"] if "isfeatured" in services else False
-        cmd.ispublic = services["ispublic"] if "ispublic" in services else False
-        cmd.isextractable = services["isextractable"] if "isextractable" in services else False
-        cmd.passwordenabled = services["passwordenabled"] if "passwordenabled" in services else False
+        cmd.isfeatured = services[
+            "isfeatured"] if "isfeatured" in services else False
+        cmd.ispublic = services[
+            "ispublic"] if "ispublic" in services else False
+        cmd.isextractable = services[
+            "isextractable"] if "isextractable" in services else False
+        cmd.passwordenabled = services[
+            "passwordenabled"] if "passwordenabled" in services else False
 
         if volumeid:
             cmd.volumeid = volumeid
@@ -991,7 +1025,7 @@ class Template:
 
     @classmethod
     def register(cls, apiclient, services, zoneid=None,
-                                                account=None, domainid=None, hypervisor=None):
+                 account=None, domainid=None, hypervisor=None):
         """Create template from URL"""
 
         # Create template from Virtual machine and Volume ID
@@ -999,7 +1033,7 @@ class Template:
         cmd.displaytext = services["displaytext"]
         cmd.name = "-".join([services["name"], random_gen()])
         cmd.format = services["format"]
-        cmd.hypervisor = hypervisor 
+        cmd.hypervisor = hypervisor
 
         if "ostypeid" in services:
             cmd.ostypeid = services["ostypeid"]
@@ -1012,11 +1046,11 @@ class Template:
             if not isinstance(ostypes, list):
                 raise Exception(
                     "Unable to find Ostype id with desc: %s" %
-                                                services["ostype"])
+                    services["ostype"])
             cmd.ostypeid = ostypes[0].id
         else:
             raise Exception(
-                    "Unable to find Ostype is required for registering template")
+                "Unable to find Ostype is required for registering template")
 
         cmd.url = services["url"]
 
@@ -1025,10 +1059,14 @@ class Template:
         else:
             cmd.zoneid = services["zoneid"]
 
-        cmd.isfeatured = services["isfeatured"] if "isfeatured" in services else False
-        cmd.ispublic = services["ispublic"] if "ispublic" in services else False
-        cmd.isextractable = services["isextractable"] if "isextractable" in services else False
-        cmd.passwordenabled = services["passwordenabled"] if "passwordenabled" in services else False
+        cmd.isfeatured = services[
+            "isfeatured"] if "isfeatured" in services else False
+        cmd.ispublic = services[
+            "ispublic"] if "ispublic" in services else False
+        cmd.isextractable = services[
+            "isextractable"] if "isextractable" in services else False
+        cmd.passwordenabled = services[
+            "passwordenabled"] if "passwordenabled" in services else False
 
         if account:
             cmd.account = account
@@ -1055,15 +1093,15 @@ class Template:
 
     @classmethod
     def create_from_snapshot(cls, apiclient, snapshot, services,
-                                                        random_name=True):
+                             random_name=True):
         """Create Template from snapshot"""
         # Create template from Virtual machine and Snapshot ID
         cmd = createTemplate.createTemplateCmd()
         cmd.displaytext = services["displaytext"]
         cmd.name = "-".join([
-                             services["name"],
-                             random_gen()
-                            ]) if random_name else services["name"]
+            services["name"],
+            random_gen()
+        ]) if random_name else services["name"]
 
         if "ostypeid" in services:
             cmd.ostypeid = services["ostypeid"]
@@ -1076,11 +1114,11 @@ class Template:
             if not isinstance(ostypes, list):
                 raise Exception(
                     "Unable to find Ostype id with desc: %s" %
-                                                services["ostype"])
+                    services["ostype"])
             cmd.ostypeid = ostypes[0].id
         else:
             raise Exception(
-                    "Unable to find Ostype is required for creating template")
+                "Unable to find Ostype is required for creating template")
 
         cmd.snapshotid = snapshot.id
         return Template(apiclient.createTemplate(cmd).__dict__)
@@ -1099,11 +1137,11 @@ class Template:
 
         while True:
             template_response = Template.list(
-                                    apiclient,
-                                    id=self.id,
-                                    zoneid=self.zoneid,
-                                    templatefilter='self'
-                                    )
+                apiclient,
+                id=self.id,
+                zoneid=self.zoneid,
+                templatefilter='self'
+            )
             if isinstance(template_response, list):
 
                 template = template_response[0]
@@ -1120,7 +1158,7 @@ class Template:
                 elif 'Installing' not in template.status:
                     raise Exception(
                         "Error in downloading template: status - %s" %
-                                                            template.status)
+                        template.status)
 
             elif timeout == 0:
                 break
@@ -1167,6 +1205,7 @@ class Template:
 
 
 class Iso:
+
     """Manage ISO life cycle"""
 
     def __init__(self, items):
@@ -1174,7 +1213,7 @@ class Iso:
 
     @classmethod
     def create(cls, apiclient, services, account=None, domainid=None,
-                                                        projectid=None):
+               projectid=None):
         """Create an ISO"""
         # Create ISO from URL
         cmd = registerIso.registerIsoCmd()
@@ -1191,11 +1230,11 @@ class Iso:
             if not isinstance(ostypes, list):
                 raise Exception(
                     "Unable to find Ostype id with desc: %s" %
-                                                services["ostype"])
+                    services["ostype"])
             cmd.ostypeid = ostypes[0].id
         else:
             raise Exception(
-                    "Unable to find Ostype is required for creating ISO")
+                "Unable to find Ostype is required for creating ISO")
 
         cmd.url = services["url"]
         cmd.zoneid = services["zoneid"]
@@ -1245,10 +1284,10 @@ class Iso:
                 if response.status == 'Successfully Installed':
                     return
                 elif 'Downloaded' not in response.status and \
-                    'Installing' not in response.status:
+                        'Installing' not in response.status:
                     raise Exception(
                         "Error In Downloading ISO: ISO Status - %s" %
-                                                            response.status)
+                        response.status)
 
             elif timeout == 0:
                 raise Exception("ISO download Timeout Exception")
@@ -1296,14 +1335,16 @@ class Iso:
 
 
 class PublicIPAddress:
+
     """Manage Public IP Addresses"""
 
     def __init__(self, items):
         self.__dict__.update(items)
 
     @classmethod
-    def create(cls, apiclient, accountid=None, zoneid=None, domainid=None, services=None,
-               networkid=None, projectid=None, vpcid=None, isportable=False):
+    def create(cls, apiclient, accountid=None, zoneid=None, domainid=None,
+               services=None, networkid=None, projectid=None, vpcid=None,
+               isportable=False):
         """Associate Public IP address"""
         cmd = associateIpAddress.associateIpAddressCmd()
 
@@ -1352,6 +1393,7 @@ class PublicIPAddress:
 
 
 class NATRule:
+
     """Manage port forwarding rule"""
 
     def __init__(self, items):
@@ -1412,13 +1454,15 @@ class NATRule:
 
 
 class StaticNATRule:
+
     """Manage Static NAT rule"""
 
     def __init__(self, items):
         self.__dict__.update(items)
 
     @classmethod
-    def create(cls, apiclient, services, ipaddressid=None, networkid=None, vpcid=None):
+    def create(cls, apiclient, services, ipaddressid=None,
+               networkid=None, vpcid=None):
         """Creates static ip forwarding rule"""
 
         cmd = createFirewallRule.createFirewallRuleCmd()
@@ -1460,7 +1504,7 @@ class StaticNATRule:
 
     @classmethod
     def enable(cls, apiclient, ipaddressid, virtualmachineid, networkid=None,
-            vmguestip=None):
+               vmguestip=None):
         """Enables Static NAT rule"""
 
         cmd = enableStaticNat.enableStaticNatCmd()
@@ -1485,6 +1529,7 @@ class StaticNATRule:
 
 
 class EgressFireWallRule:
+
     """Manage Egress Firewall rule"""
 
     def __init__(self, items):
@@ -1504,7 +1549,8 @@ class EgressFireWallRule:
         if endport:
             cmd.endport = endport
 
-        return EgressFireWallRule(apiclient.createEgressFirewallRule(cmd).__dict__)
+        return EgressFireWallRule(
+            apiclient.createEgressFirewallRule(cmd).__dict__)
 
     def delete(self, apiclient):
         """Delete Egress Firewall rule"""
@@ -1522,8 +1568,8 @@ class EgressFireWallRule:
         return(apiclient.listEgressFirewallRules(cmd))
 
 
-
 class FireWallRule:
+
     """Manage Firewall rule"""
 
     def __init__(self, items):
@@ -1568,6 +1614,7 @@ class FireWallRule:
 
 
 class ServiceOffering:
+
     """Manage service offerings cycle"""
 
     def __init__(self, items):
@@ -1601,7 +1648,8 @@ class ServiceOffering:
             cmd.deploymentplanner = services["deploymentplanner"]
 
         if "serviceofferingdetails" in services:
-            cmd.serviceofferingdetails.append({services['serviceofferingdetails']})
+            cmd.serviceofferingdetails.append(
+                {services['serviceofferingdetails']})
 
         if "isvolatile" in services:
             cmd.isvolatile = services["isvolatile"]
@@ -1633,6 +1681,7 @@ class ServiceOffering:
 
 
 class DiskOffering:
+
     """Manage disk offerings cycle"""
 
     def __init__(self, items):
@@ -1674,6 +1723,7 @@ class DiskOffering:
 
 
 class NetworkOffering:
+
     """Manage network offerings cycle"""
 
     def __init__(self, items):
@@ -1698,18 +1748,19 @@ class NetworkOffering:
         if "serviceProviderList" in services:
             for service, provider in services["serviceProviderList"].items():
                 cmd.serviceproviderlist.append({
-                                            'service': service,
-                                            'provider': provider
-                                           })
+                    'service': service,
+                    'provider': provider
+                })
         if "serviceCapabilityList" in services:
             cmd.servicecapabilitylist = []
-            for service, capability in services["serviceCapabilityList"].items():
+            for service, capability in services["serviceCapabilityList"].\
+                                       items():
                 for ctype, value in capability.items():
                     cmd.servicecapabilitylist.append({
-                                            'service': service,
-                                            'capabilitytype': ctype,
-                                            'capabilityvalue': value
-                                           })
+                        'service': service,
+                        'capabilitytype': ctype,
+                        'capabilityvalue': value
+                    })
         if "specifyVlan" in services:
             cmd.specifyVlan = services["specifyVlan"]
         if "specifyIpRanges" in services:
@@ -1750,6 +1801,7 @@ class NetworkOffering:
 
 
 class SnapshotPolicy:
+
     """Manage snapshot policies"""
 
     def __init__(self, items):
@@ -1781,7 +1833,9 @@ class SnapshotPolicy:
         [setattr(cmd, k, v) for k, v in kwargs.items()]
         return(apiclient.listSnapshotPolicies(cmd))
 
+
 class Hypervisor:
+
     """Manage Hypervisor"""
 
     def __init__(self, items):
@@ -1797,6 +1851,7 @@ class Hypervisor:
 
 
 class LoadBalancerRule:
+
     """Manage Load Balancer rule"""
 
     def __init__(self, items):
@@ -1862,7 +1917,8 @@ class LoadBalancerRule:
         apiclient.removeFromLoadBalancerRule(cmd)
         return
 
-    def update(self, apiclient, algorithm=None, description=None, name=None, **kwargs):
+    def update(self, apiclient, algorithm=None,
+               description=None, name=None, **kwargs):
         """Updates the load balancing rule"""
         cmd = updateLoadBalancerRule.updateLoadBalancerRuleCmd()
         cmd.id = self.id
@@ -1876,7 +1932,8 @@ class LoadBalancerRule:
         [setattr(cmd, k, v) for k, v in kwargs.items()]
         return apiclient.updateLoadBalancerRule(cmd)
 
-    def createSticky(self, apiclient, methodname, name, description=None, param=None):
+    def createSticky(
+            self, apiclient, methodname, name, description=None, param=None):
         """Creates a sticky policy for the LB rule"""
 
         cmd = createLBStickinessPolicy.createLBStickinessPolicyCmd()
@@ -1917,13 +1974,15 @@ class LoadBalancerRule:
 
 
 class Cluster:
+
     """Manage Cluster life cycle"""
 
     def __init__(self, items):
         self.__dict__.update(items)
 
     @classmethod
-    def create(cls, apiclient, services, zoneid=None, podid=None, hypervisor=None):
+    def create(cls, apiclient, services, zoneid=None, podid=None,
+               hypervisor=None):
         """Create Cluster"""
         cmd = addCluster.addClusterCmd()
         cmd.clustertype = services["clustertype"]
@@ -1967,13 +2026,15 @@ class Cluster:
 
 
 class Host:
+
     """Manage Host life cycle"""
 
     def __init__(self, items):
         self.__dict__.update(items)
 
     @classmethod
-    def create(cls, apiclient, cluster, services, zoneid=None, podid=None, hypervisor=None):
+    def create(cls, apiclient, cluster, services,
+               zoneid=None, podid=None, hypervisor=None):
         """
         1. Creates the host based upon the information provided.
         2. Verifies the output of the adding host and its state post addition
@@ -2019,12 +2080,14 @@ class Host:
                 while retries:
                     lh_resp = apiclient.listHosts(host[0].id)
                     ret = validateList(lh_resp)
-                    if (ret[0] == PASS) and (str(ret[1].state).lower() == 'up'):
+                    if (ret[0] == PASS) and \
+                            (str(ret[1].state).lower() == 'up'):
                         return Host(host[0].__dict__)
                     retries += -1
             return FAILED
-        except Exception, e:
-            print "Exception Occurred Under Host.create : %s" % GetDetailExceptionInfo(e)
+        except Exception as e:
+            print "Exception Occurred Under Host.create : %s" % \
+                  GetDetailExceptionInfo(e)
             return FAILED
 
     def delete(self, apiclient):
@@ -2096,6 +2159,7 @@ class Host:
 
 
 class StoragePool:
+
     """Manage Storage pools (Primary Storage)"""
 
     def __init__(self, items):
@@ -2103,7 +2167,7 @@ class StoragePool:
 
     @classmethod
     def create(cls, apiclient, services, clusterid=None,
-                                        zoneid=None, podid=None):
+               zoneid=None, podid=None):
         """Create Storage pool (Primary Storage)"""
 
         cmd = createStoragePool.createStoragePoolCmd()
@@ -2163,7 +2227,9 @@ class StoragePool:
         [setattr(cmd, k, v) for k, v in kwargs.items()]
         return(apiclient.findStoragePoolsForMigration(cmd))
 
+
 class Network:
+
     """Manage Network pools"""
 
     def __init__(self, items):
@@ -2255,6 +2321,7 @@ class Network:
 
 
 class NetworkACL:
+
     """Manage Network ACL lifecycle"""
 
     def __init__(self, items):
@@ -2262,7 +2329,8 @@ class NetworkACL:
 
     @classmethod
     def create(cls, apiclient, services, networkid=None, protocol=None,
-               number=None, aclid=None, action='Allow', traffictype=None, cidrlist=[]):
+               number=None, aclid=None, action='Allow',
+               traffictype=None, cidrlist=[]):
         """Create network ACL rules(Ingress/Egress)"""
 
         cmd = createNetworkACL.createNetworkACLCmd()
@@ -2329,13 +2397,15 @@ class NetworkACL:
 
 
 class NetworkACLList:
+
     """Manage Network ACL lists lifecycle"""
 
     def __init__(self, items):
         self.__dict__.update(items)
 
     @classmethod
-    def create(cls, apiclient, services, name=None, description=None, vpcid=None):
+    def create(
+            cls, apiclient, services, name=None, description=None, vpcid=None):
         """Create network ACL container list"""
 
         cmd = createNetworkACLList.createNetworkACLListCmd()
@@ -2373,6 +2443,7 @@ class NetworkACLList:
 
 
 class Vpn:
+
     """Manage VPN life cycle"""
 
     def __init__(self, items):
@@ -2380,7 +2451,7 @@ class Vpn:
 
     @classmethod
     def create(cls, apiclient, publicipid, account=None, domainid=None,
-                        projectid=None, networkid=None, vpcid=None):
+               projectid=None, networkid=None, vpcid=None):
         """Create VPN for Public IP address"""
         cmd = createRemoteAccessVpn.createRemoteAccessVpnCmd()
         cmd.publicipid = publicipid
@@ -2413,6 +2484,7 @@ class Vpn:
 
 
 class VpnUser:
+
     """Manage VPN user"""
 
     def __init__(self, items):
@@ -2457,6 +2529,7 @@ class VpnUser:
 
 
 class Zone:
+
     """Manage Zone"""
 
     def __init__(self, items):
@@ -2507,6 +2580,7 @@ class Zone:
 
 
 class Pod:
+
     """Manage Pod"""
 
     def __init__(self, items):
@@ -2542,6 +2616,7 @@ class Pod:
 
 
 class PublicIpRange:
+
     """Manage VlanIpRange"""
 
     def __init__(self, items):
@@ -2580,7 +2655,8 @@ class PublicIpRange:
         return(apiclient.listVlanIpRanges(cmd))
 
     @classmethod
-    def dedicate(cls, apiclient, id, account=None, domainid=None, projectid=None):
+    def dedicate(
+            cls, apiclient, id, account=None, domainid=None, projectid=None):
         """Dedicate VLAN IP range"""
 
         cmd = dedicatePublicIpRange.dedicatePublicIpRangeCmd()
@@ -2599,6 +2675,7 @@ class PublicIpRange:
 
 
 class PortablePublicIpRange:
+
     """Manage portable public Ip Range"""
 
     def __init__(self, items):
@@ -2618,7 +2695,8 @@ class PortablePublicIpRange:
         if "vlan" in services:
             cmd.vlan = services["vlan"]
 
-        return PortablePublicIpRange(apiclient.createPortableIpRange(cmd).__dict__)
+        return PortablePublicIpRange(
+            apiclient.createPortableIpRange(cmd).__dict__)
 
     def delete(self, apiclient):
         """Delete portable IpRange"""
@@ -2635,7 +2713,9 @@ class PortablePublicIpRange:
         [setattr(cmd, k, v) for k, v in kwargs.items()]
         return(apiclient.listPortableIpRanges(cmd))
 
+
 class SecondaryStagingStore:
+
     """Manage Staging Store"""
 
     def __init__(self, items):
@@ -2655,7 +2735,8 @@ class SecondaryStagingStore:
             if "scope" in services:
                 cmd.scope = services["scope"]
 
-        return SecondaryStagingStore(apiclient.createSecondaryStagingStore(cmd).__dict__)
+        return SecondaryStagingStore(
+            apiclient.createSecondaryStagingStore(cmd).__dict__)
 
     def delete(self, apiclient):
         """Delete Staging Storage"""
@@ -2671,6 +2752,7 @@ class SecondaryStagingStore:
 
 
 class ImageStore:
+
     """Manage image stores"""
 
     def __init__(self, items):
@@ -2706,6 +2788,7 @@ class ImageStore:
 
 
 class PhysicalNetwork:
+
     """Manage physical network storage"""
 
     def __init__(self, items):
@@ -2746,7 +2829,8 @@ class PhysicalNetwork:
         return apiclient.addTrafficType(cmd)
 
     @classmethod
-    def dedicate(cls, apiclient, vlanrange, physicalnetworkid, account=None, domainid=None, projectid=None):
+    def dedicate(cls, apiclient, vlanrange, physicalnetworkid,
+                 account=None, domainid=None, projectid=None):
         """Dedicate guest vlan range"""
 
         cmd = dedicateGuestVlanRange.dedicateGuestVlanRangeCmd()
@@ -2760,7 +2844,8 @@ class PhysicalNetwork:
     def release(self, apiclient):
         """Release guest vlan range"""
 
-        cmd = releaseDedicatedGuestVlanRange.releaseDedicatedGuestVlanRangeCmd()
+        cmd = releaseDedicatedGuestVlanRange.\
+            releaseDedicatedGuestVlanRangeCmd()
         cmd.id = self.id
         return apiclient.releaseDedicatedGuestVlanRange(cmd)
 
@@ -2778,10 +2863,12 @@ class PhysicalNetwork:
 
         cmd = listPhysicalNetworks.listPhysicalNetworksCmd()
         [setattr(cmd, k, v) for k, v in kwargs.items()]
-        return map(lambda pn : PhysicalNetwork(pn.__dict__), apiclient.listPhysicalNetworks(cmd))
+        return map(lambda pn: PhysicalNetwork(
+            pn.__dict__), apiclient.listPhysicalNetworks(cmd))
 
 
 class SecurityGroup:
+
     """Manage Security Groups"""
 
     def __init__(self, items):
@@ -2873,9 +2960,9 @@ class SecurityGroup:
         cmd.usersecuritygrouplist = []
         for account, group in user_secgrp_list.items():
             cmd.usersecuritygrouplist.append({
-                                            'account': account,
-                                            'group': group
-                                           })
+                'account': account,
+                'group': group
+            })
 
         return (apiclient.authorizeSecurityGroupEgress(cmd).__dict__)
 
@@ -2896,6 +2983,7 @@ class SecurityGroup:
 
 
 class VpnCustomerGateway:
+
     """Manage VPN Customer Gateway"""
 
     def __init__(self, items):
@@ -2903,7 +2991,7 @@ class VpnCustomerGateway:
 
     @classmethod
     def create(cls, apiclient, services, name, gateway, cidrlist,
-                        account=None, domainid=None):
+               account=None, domainid=None):
         """Create VPN Customer Gateway"""
         cmd = createVpnCustomerGateway.createVpnCustomerGatewayCmd()
         cmd.name = name
@@ -2925,7 +3013,8 @@ class VpnCustomerGateway:
             cmd.account = account
         if domainid:
             cmd.domainid = domainid
-        return VpnCustomerGateway(apiclient.createVpnCustomerGateway(cmd).__dict__)
+        return VpnCustomerGateway(
+            apiclient.createVpnCustomerGateway(cmd).__dict__)
 
     def update(self, apiclient, services, name, gateway, cidrlist):
         """Updates VPN Customer Gateway"""
@@ -2966,6 +3055,7 @@ class VpnCustomerGateway:
 
 
 class Project:
+
     """Manage Project life cycle"""
 
     def __init__(self, items):
@@ -3051,6 +3141,7 @@ class Project:
 
 
 class ProjectInvitation:
+
     """Manage project invitations"""
 
     def __init__(self, items):
@@ -3087,6 +3178,7 @@ class ProjectInvitation:
 
 
 class Configurations:
+
     """Manage Configuration"""
 
     @classmethod
@@ -3108,13 +3200,15 @@ class Configurations:
 
 
 class NetScaler:
+
     """Manage external netscaler device"""
 
     def __init__(self, items):
         self.__dict__.update(items)
 
     @classmethod
-    def add(cls, apiclient, services, physicalnetworkid, username=None, password=None):
+    def add(cls, apiclient, services, physicalnetworkid,
+            username=None, password=None):
         """Add external netscaler device to cloudstack"""
 
         cmd = addNetscalerLoadBalancer.addNetscalerLoadBalancerCmd()
@@ -3134,11 +3228,14 @@ class NetScaler:
         # Generate the URL
         url = 'https://' + str(services["ipaddress"]) + '?'
         url = url + 'publicinterface=' + str(services["publicinterface"]) + '&'
-        url = url + 'privateinterface=' + str(services["privateinterface"]) + '&'
+        url = url + 'privateinterface=' + \
+            str(services["privateinterface"]) + '&'
         url = url + 'numretries=' + str(services["numretries"]) + '&'
 
-        if not services["lbdevicededicated"] and "lbdevicecapacity" in services:
-            url = url + 'lbdevicecapacity=' + str(services["lbdevicecapacity"]) + '&'
+        if not services["lbdevicededicated"] and \
+           "lbdevicecapacity" in services:
+            url = url + 'lbdevicecapacity=' + \
+                str(services["lbdevicecapacity"]) + '&'
 
         url = url + 'lbdevicededicated=' + str(services["lbdevicededicated"])
 
@@ -3156,7 +3253,8 @@ class NetScaler:
     def configure(self, apiclient, **kwargs):
         """List already registered netscaler devices"""
 
-        cmd = configureNetscalerLoadBalancer.configureNetscalerLoadBalancerCmd()
+        cmd = configureNetscalerLoadBalancer.\
+            configureNetscalerLoadBalancerCmd()
         cmd.lbdeviceid = self.lbdeviceid
         [setattr(cmd, k, v) for k, v in kwargs.items()]
         return(apiclient.configureNetscalerLoadBalancer(cmd))
@@ -3171,6 +3269,7 @@ class NetScaler:
 
 
 class NetworkServiceProvider:
+
     """Manage network serivce providers for CloudStack"""
 
     def __init__(self, items):
@@ -3184,7 +3283,8 @@ class NetworkServiceProvider:
         cmd.name = name
         cmd.physicalnetworkid = physicalnetworkid
         cmd.servicelist = servicelist
-        return NetworkServiceProvider(apiclient.addNetworkServiceProvider(cmd).__dict__)
+        return NetworkServiceProvider(
+            apiclient.addNetworkServiceProvider(cmd).__dict__)
 
     def delete(self, apiclient):
         """Deletes network service provider"""
@@ -3220,6 +3320,7 @@ class NetworkServiceProvider:
 
 
 class Router:
+
     """Manage router life cycle"""
 
     def __init__(self, items):
@@ -3273,6 +3374,7 @@ class Router:
 
 
 class Tag:
+
     """Manage tags"""
 
     def __init__(self, items):
@@ -3288,9 +3390,9 @@ class Tag:
         cmd.tags = []
         for key, value in tags.items():
             cmd.tags.append({
-                             'key': key,
-                             'value': value
-                            })
+                'key': key,
+                'value': value
+            })
         return Tag(apiclient.createTags(cmd).__dict__)
 
     def delete(self, apiclient, resourceIds, resourceType, tags):
@@ -3302,9 +3404,9 @@ class Tag:
         cmd.tags = []
         for key, value in tags.items():
             cmd.tags.append({
-                             'key': key,
-                             'value': value
-                             })
+                'key': key,
+                'value': value
+            })
         apiclient.deleteTags(cmd)
 
     @classmethod
@@ -3317,6 +3419,7 @@ class Tag:
 
 
 class VpcOffering:
+
     """Manage VPC offerings"""
 
     def __init__(self, items):
@@ -3333,18 +3436,19 @@ class VpcOffering:
         if "serviceProviderList" in services:
             for service, provider in services["serviceProviderList"].items():
                 cmd.serviceproviderlist.append({
-                                            'service': service,
-                                            'provider': provider
-                                           })
+                    'service': service,
+                    'provider': provider
+                })
         if "serviceCapabilityList" in services:
             cmd.servicecapabilitylist = []
-            for service, capability in services["serviceCapabilityList"].items():
+            for service, capability in \
+                services["serviceCapabilityList"].items():
                 for ctype, value in capability.items():
                     cmd.servicecapabilitylist.append({
-                                            'service': service,
-                                            'capabilitytype': ctype,
-                                            'capabilityvalue': value
-                                           })
+                        'service': service,
+                        'capabilitytype': ctype,
+                        'capabilityvalue': value
+                    })
         return VpcOffering(apiclient.createVPCOffering(cmd).__dict__)
 
     def update(self, apiclient, name=None, displaytext=None, state=None):
@@ -3377,6 +3481,7 @@ class VpcOffering:
 
 
 class VPC:
+
     """Manage Virtual Private Connection"""
 
     def __init__(self, items):
@@ -3384,7 +3489,8 @@ class VPC:
 
     @classmethod
     def create(cls, apiclient, services, vpcofferingid,
-                    zoneid, networkDomain=None, account=None, domainid=None, **kwargs):
+               zoneid, networkDomain=None, account=None,
+               domainid=None, **kwargs):
         """Creates the virtual private connection (VPC)"""
 
         cmd = createVPC.createVPCCmd()
@@ -3438,6 +3544,7 @@ class VPC:
 
 
 class PrivateGateway:
+
     """Manage private gateway lifecycle"""
 
     def __init__(self, items):
@@ -3445,7 +3552,7 @@ class PrivateGateway:
 
     @classmethod
     def create(cls, apiclient, gateway, ipaddress, netmask, vlan, vpcid,
-                                                    physicalnetworkid=None):
+               physicalnetworkid=None):
         """Create private gateway"""
 
         cmd = createPrivateGateway.createPrivateGatewayCmd()
@@ -3476,6 +3583,7 @@ class PrivateGateway:
 
 
 class AffinityGroup:
+
     def __init__(self, items):
         self.__dict__.update(items)
 
@@ -3505,8 +3613,11 @@ class AffinityGroup:
         [setattr(cmd, k, v) for k, v in kwargs.items()]
         return apiclient.listAffinityGroups(cmd)
 
+
 class StaticRoute:
+
     """Manage static route lifecycle"""
+
     def __init__(self, items):
         self.__dict__.update(items)
 
@@ -3536,11 +3647,14 @@ class StaticRoute:
 
 
 class VNMC:
+
     """Manage VNMC lifecycle"""
+
     def __init__(self, items):
         self.__dict__.update(items)
 
-    def create(cls, apiclient, hostname, username, password, physicalnetworkid):
+    def create(cls, apiclient, hostname, username, password,
+               physicalnetworkid):
         """Registers VNMC appliance"""
 
         cmd = addCiscoVnmcResource.addCiscoVnmcResourceCmd()
@@ -3567,6 +3681,7 @@ class VNMC:
 
 
 class SSHKeyPair:
+
     """Manage SSH Key pairs"""
 
     def __init__(self, items, services):
@@ -3574,7 +3689,7 @@ class SSHKeyPair:
 
     @classmethod
     def create(cls, apiclient, name=None, account=None,
-                    domainid=None, projectid=None):
+               domainid=None, projectid=None):
         """Creates SSH keypair"""
         cmd = createSSHKeyPair.createSSHKeyPairCmd()
         cmd.name = name
@@ -3609,6 +3724,7 @@ class SSHKeyPair:
 
 
 class Capacities:
+
     """Manage Capacities"""
 
     @classmethod
@@ -3621,6 +3737,7 @@ class Capacities:
 
 
 class Alert:
+
     """Manage alerts"""
 
     @classmethod
@@ -3633,6 +3750,7 @@ class Alert:
 
 
 class InstanceGroup:
+
     """Manage VM instance groups"""
 
     def __init__(self, items):
@@ -3706,7 +3824,8 @@ class InstanceGroup:
     def changeServiceOffering(self, apiclient, serviceOfferingId):
         """Change service offering of the vm tier"""
 
-        cmd = changeServiceForVirtualMachine.changeServiceForVirtualMachineCmd()
+        cmd = changeServiceForVirtualMachine.\
+            changeServiceForVirtualMachineCmd()
         cmd.group = self.id
         cmd.serviceofferingid = serviceOfferingId
         return apiclient.changeServiceForVirtualMachine(cmd)
@@ -3719,8 +3838,10 @@ class InstanceGroup:
 
 
 class ASA1000V:
+
     """Manage ASA 1000v lifecycle"""
-    def create(cls, apiclient, hostname, insideportprofile, clusterid, physicalnetworkid):
+    def create(cls, apiclient, hostname, insideportprofile,
+               clusterid, physicalnetworkid):
         """Registers ASA 1000v appliance"""
 
         cmd = addCiscoAsa1000vResource.addCiscoAsa1000vResourceCmd()
@@ -3745,12 +3866,17 @@ class ASA1000V:
         [setattr(cmd, k, v) for k, v in kwargs.items()]
         return(apiclient.listCiscoAsa1000vResources(cmd))
 
+
 class VmSnapshot:
+
     """Manage VM Snapshot life cycle"""
+
     def __init__(self, items):
         self.__dict__.update(items)
+
     @classmethod
-    def create(cls,apiclient,vmid,snapshotmemory="false",name=None,description=None):
+    def create(cls, apiclient, vmid, snapshotmemory="false",
+               name=None, description=None):
         cmd = createVMSnapshot.createVMSnapshotCmd()
         cmd.virtualmachineid = vmid
 
@@ -3761,29 +3887,32 @@ class VmSnapshot:
         if description:
             cmd.description = description
         return VmSnapshot(apiclient.createVMSnapshot(cmd).__dict__)
-    
+
     @classmethod
     def list(cls, apiclient, **kwargs):
         cmd = listVMSnapshot.listVMSnapshotCmd()
         [setattr(cmd, k, v) for k, v in kwargs.items()]
         return(apiclient.listVMSnapshot(cmd))
-    
+
     @classmethod
-    def revertToSnapshot(cls, apiclient,vmsnapshotid):
+    def revertToSnapshot(cls, apiclient, vmsnapshotid):
         cmd = revertToVMSnapshot.revertToVMSnapshotCmd()
         cmd.vmsnapshotid = vmsnapshotid
-        
+
         return apiclient.revertToVMSnapshot(cmd)
-    
+
     @classmethod
-    def deleteVMSnapshot(cls,apiclient,vmsnapshotid):
+    def deleteVMSnapshot(cls, apiclient, vmsnapshotid):
         cmd = deleteVMSnapshot.deleteVMSnapshotCmd()
         cmd.vmsnapshotid = vmsnapshotid
-        
+
         return apiclient.deleteVMSnapshot(cmd)
 
+
 class Region:
+
     """ Regions related Api """
+
     def __init__(self, items):
         self.__dict__.update(items)
 
@@ -3825,14 +3954,16 @@ class Region:
 
 
 class ApplicationLoadBalancer:
+
     """Manage Application Load Balancers in VPC"""
 
     def __init__(self, items):
         self.__dict__.update(items)
 
     @classmethod
-    def create(cls, apiclient, services, name=None, sourceport=None, instanceport=22,
-               algorithm="roundrobin", scheme="internal", sourcenetworkid=None, networkid=None):
+    def create(cls, apiclient, services, name=None, sourceport=None,
+               instanceport=22, algorithm="roundrobin", scheme="internal",
+               sourcenetworkid=None, networkid=None):
         """Create Application Load Balancer"""
         cmd = createLoadBalancer.createLoadBalancerCmd()
 
@@ -3903,7 +4034,9 @@ class ApplicationLoadBalancer:
         [setattr(cmd, k, v) for k, v in kwargs.items()]
         return(apiclient.listLoadBalancerRules(cmd))
 
+
 class Resources:
+
     """Manage resource limits"""
 
     def __init__(self, items, services):
@@ -3932,9 +4065,12 @@ class Resources:
         cmd = updateResourceCount.updateResourceCountCmd()
         [setattr(cmd, k, v) for k, v in kwargs.items()]
         return(apiclient.updateResourceCount(cmd))
-   
+
+
 class NIC:
+
     """NIC related API"""
+
     def __init__(self, items):
         self.__dict__.update(items)
 
@@ -3948,7 +4084,7 @@ class NIC:
         return(apiclient.addIpToNic(cmd))
 
     @classmethod
-    def removeIp(cls,apiclient,ipaddressid):
+    def removeIp(cls, apiclient, ipaddressid):
         """Remove secondary Ip from NIC"""
         cmd = removeIpFromNic.removeIpFromNicCmd()
         cmd.id = ipaddressid
@@ -3961,8 +4097,10 @@ class NIC:
         cmd = listNics.listNicsCmd()
         [setattr(cmd, k, v) for k, v in kwargs.items()]
         return(apiclient.listNics(cmd))
-        
+
+
 class IAMGroup:
+
     def __init__(self, items):
         self.__dict__.update(items)
 
@@ -3989,8 +4127,8 @@ class IAMGroup:
     def list(cls, apiclient, **kwargs):
         cmd = listIAMGroups.listIAMGroupsCmd()
         [setattr(cmd, k, v) for k, v in kwargs.items()]
-        return apiclient.listIAMGroupsCmd(cmd)  
-    
+        return apiclient.listIAMGroupsCmd(cmd)
+
     def addAccount(self, apiclient, accts):
         """Add accounts to iam group"""
         cmd = addAccountToIAMGroup.addAccountToIAMGroupCmd()
@@ -4023,7 +4161,9 @@ class IAMGroup:
         apiclient.removeIAMPolicyFromIAMGroup(cmd)
         return
 
+
 class IAMPolicy:
+
     def __init__(self, items):
         self.__dict__.update(items)
 
@@ -4050,7 +4190,7 @@ class IAMPolicy:
     def list(cls, apiclient, **kwargs):
         cmd = listIAMPolicies.listIAMPoliciesCmd()
         [setattr(cmd, k, v) for k, v in kwargs.items()]
-        return apiclient.listIAMPoliciesCmd(cmd)  
+        return apiclient.listIAMPoliciesCmd(cmd)
 
     def addPermission(self, apiclient, permission):
         """Add permission to iam policy"""
@@ -4065,7 +4205,8 @@ class IAMPolicy:
 
     def removePermission(self, apiclient, permission):
         """Remove permission from iam policy"""
-        cmd = removeIAMPermissionFromIAMPolicy.removeIAMPermissionFromIAMPolicyCmd()
+        cmd = removeIAMPermissionFromIAMPolicy.\
+            removeIAMPermissionFromIAMPolicyCmd()
         cmd.id = self.id
         cmd.action = permission['action']
         cmd.entitytype = permission['entitytype']
@@ -4090,15 +4231,20 @@ class IAMPolicy:
         apiclient.removeIAMPolicyFromAccount(cmd)
         return
 
+
 class SimulatorMock:
+
     """Manage simulator mock lifecycle"""
+
     def __init__(self, items):
         self.__dict__.update(items)
-    
+
     @classmethod
-    def create(cls, apiclient, command, zoneid=None, podid=None, clusterid=None, hostid=None, value="result:fail", count=None, jsonresponse=None):
+    def create(cls, apiclient, command, zoneid=None, podid=None,
+               clusterid=None, hostid=None, value="result:fail",
+               count=None, jsonresponse=None):
         """Creates simulator mock"""
-        
+
         cmd = configureSimulator.configureSimulatorCmd()
         cmd.zoneid = zoneid
         cmd.podid = podid
@@ -4114,17 +4260,17 @@ class SimulatorMock:
                 return SimulatorMock(simulatormock.__dict__)
         except Exception as e:
             raise e
-    
+
     def delete(self, apiclient):
         """Removes simulator mock"""
-        
+
         cmd = cleanupSimulatorMock.cleanupSimulatorMockCmd()
         cmd.id = self.id
         return apiclient.cleanupSimulatorMock(cmd)
-    
+
     def query(self, apiclient):
         """Queries simulator mock"""
-        
+
         cmd = querySimulatorMock.querySimulatorMockCmd()
         cmd.id = self.id
         try:
@@ -4133,5 +4279,3 @@ class SimulatorMock:
                 return SimulatorMock(simulatormock.__dict__)
         except Exception as e:
             raise e
-
-

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4a99cf85/tools/marvin/marvin/lib/common.py
----------------------------------------------------------------------
diff --git a/tools/marvin/marvin/lib/common.py b/tools/marvin/marvin/lib/common.py
index 8868d2d..0a82f93 100644
--- a/tools/marvin/marvin/lib/common.py
+++ b/tools/marvin/marvin/lib/common.py
@@ -59,8 +59,6 @@ from marvin.cloudstackAPI import (listConfigurations,
                                   listVPCOfferings)
 
 
-
-
 from marvin.sshClient import SshClient
 from marvin.codes import (PASS, ISOLATED_NETWORK, VPC_NETWORK,
                           BASIC_ZONE, FAIL, NAT_RULE, STATIC_NAT_RULE)
@@ -76,7 +74,8 @@ import time
 
 def is_config_suitable(apiclient, name, value):
     """
-    Ensure if the deployment has the expected `value` for the global setting `name'
+    Ensure if the deployment has the expected
+    `value` for the global setting `name'
     @return: true if value is set, else false
     """
     configs = Configurations.list(apiclient, name=name)
@@ -151,7 +150,8 @@ def add_netscaler(apiclient, zoneid, NSservice):
 def get_region(apiclient, region_id=None, region_name=None):
     '''
     @name : get_region
-    @Desc : Returns the Region Information for a given region  id or region name
+    @Desc : Returns the Region Information for a given
+    region  id or region name
     @Input : region_name: Name of the Region
              region_id : Id of the region
     @Output : 1. Region  Information for the passed inputs else first Region
@@ -237,10 +237,12 @@ def get_pod(apiclient, zone_id=None, pod_id=None, pod_name=None):
     if validateList(cmd_out)[0] != PASS:
         return FAILED
     return cmd_out[0]
+
+
 def get_template(
-        apiclient, zone_id=None, ostype_desc=None, template_filter="featured", template_type='BUILTIN',
-        template_id=None, template_name=None, account=None, domain_id=None, project_id=None,
-        hypervisor=None):
+        apiclient, zone_id=None, ostype_desc=None, template_filter="featured",
+        template_type='BUILTIN', template_id=None, template_name=None,
+        account=None, domain_id=None, project_id=None, hypervisor=None):
     '''
     @Name : get_template
     @Desc : Retrieves the template Information based upon inputs provided
@@ -759,20 +761,24 @@ def update_resource_count(apiclient, domainid, accountid=None,
                           )
     return
 
+
 def findSuitableHostForMigration(apiclient, vmid):
     """Returns a suitable host for VM migration"""
     suitableHost = None
     try:
         hosts = Host.listForMigration(apiclient, virtualmachineid=vmid,
-                )
+                                      )
     except Exception as e:
-        raise Exception("Exception while getting hosts list suitable for migration: %s" % e)
+        raise Exception(
+            "Exception while getting hosts list suitable for migration: %s" %
+            e)
 
     suitablehosts = []
     if isinstance(hosts, list) and len(hosts) > 0:
-        suitablehosts = [host for host in hosts if (str(host.resourcestate).lower() == "enabled"\
-                and str(host.state).lower() == "up")]
-        if len(suitablehosts)>0:
+        suitablehosts = [host for host in hosts
+                         if (str(host.resourcestate).lower() == "enabled"
+                             and str(host.state).lower() == "up")]
+        if len(suitablehosts) > 0:
             suitableHost = suitablehosts[0]
 
     return suitableHost
@@ -798,10 +804,10 @@ def get_resource_type(resource_id):
     return lookup[resource_id]
 
 
-
 def get_free_vlan(apiclient, zoneid):
     """
-    Find an unallocated VLAN outside the range allocated to the physical network.
+    Find an unallocated VLAN outside the range
+    allocated to the physical network.
 
     @note: This does not guarantee that the VLAN is available for use in
     the deployment's network gear
@@ -813,7 +819,8 @@ def get_free_vlan(apiclient, zoneid):
     )
     assert isinstance(list_physical_networks_response, list)
     assert len(
-        list_physical_networks_response) > 0, "No physical networks found in zone %s" % zoneid
+        list_physical_networks_response) > 0,\
+        "No physical networks found in zone %s" % zoneid
 
     physical_network = list_physical_networks_response[0]
 
@@ -836,7 +843,8 @@ def get_free_vlan(apiclient, zoneid):
 
         assert len(vlans) > 0
         assert int(vlans[0]) < int(
-            vlans[-1]), "VLAN range  %s was improperly split" % physical_network.vlan
+            vlans[-1]), "VLAN range  %s was improperly split"\
+                        % physical_network.vlan
 
         # Assuming random function will give different integer each time
         retriesCount = 20
@@ -864,7 +872,8 @@ def get_free_vlan(apiclient, zoneid):
 
 def setNonContiguousVlanIds(apiclient, zoneid):
     """
-    Form the non contiguous ranges based on currently assigned range in physical network
+    Form the non contiguous ranges based on currently
+     assigned range in physical network
     """
 
     NonContigVlanIdsAcquired = False
@@ -875,7 +884,8 @@ def setNonContiguousVlanIds(apiclient, zoneid):
     )
     assert isinstance(list_physical_networks_response, list)
     assert len(
-        list_physical_networks_response) > 0, "No physical networks found in zone %s" % zoneid
+        list_physical_networks_response) > 0, \
+        "No physical networks found in zone %s" % zoneid
 
     for physical_network in list_physical_networks_response:
 
@@ -883,26 +893,30 @@ def setNonContiguousVlanIds(apiclient, zoneid):
 
         assert len(vlans) > 0
         assert int(vlans[0]) < int(
-            vlans[-1]), "VLAN range  %s was improperly split" % physical_network.vlan
+            vlans[-1]), "VLAN range  %s was improperly split"\
+                        % physical_network.vlan
 
-        # Keep some gap between existing vlan and the new vlans which we are going to add
+        # Keep some gap between existing vlan and the new vlans
+        # which we are going to add
         # So that they are non contiguous
 
         non_contig_end_vlan_id = int(vlans[-1]) + 6
         non_contig_start_vlan_id = int(vlans[0]) - 6
 
-        # Form ranges which are consecutive to existing ranges but not immediately contiguous
-        # There should be gap in between existing range and new non contiguous
-        # ranage
-
-        # If you can't add range after existing range, because it's crossing 4095, then
-        # select VLAN ids before the existing range such that they are greater than 0, and
+        # Form ranges which are consecutive to existing ranges but
+        # not immediately contiguous
+        # There should be gap in between existing range
+        # and new non contiguous range
+        # If you can't add range after existing range,
+        # because it's crossing 4095, then select VLAN ids before
+        # the existing range such that they are greater than 0, and
         # then add this non contiguoud range
         vlan = {"partial_range": ["", ""], "full_range": ""}
 
         if non_contig_end_vlan_id < 4095:
             vlan["partial_range"][0] = str(
-                non_contig_end_vlan_id - 4) + '-' + str(non_contig_end_vlan_id - 3)
+                non_contig_end_vlan_id - 4) + '-' + str(non_contig_end_vlan_id
+                                                        - 3)
             vlan["partial_range"][1] = str(
                 non_contig_end_vlan_id - 1) + '-' + str(non_contig_end_vlan_id)
             vlan["full_range"] = str(
@@ -910,12 +924,15 @@ def setNonContiguousVlanIds(apiclient, zoneid):
             NonContigVlanIdsAcquired = True
 
         elif non_contig_start_vlan_id > 0:
-            vlan["partial_range"][0] = str(
-                non_contig_start_vlan_id) + '-' + str(non_contig_start_vlan_id + 1)
-            vlan["partial_range"][1] = str(
-                non_contig_start_vlan_id + 3) + '-' + str(non_contig_start_vlan_id + 4)
-            vlan["full_range"] = str(
-                non_contig_start_vlan_id) + '-' + str(non_contig_start_vlan_id + 4)
+            vlan["partial_range"][0] = \
+                str(non_contig_start_vlan_id) \
+                + '-' + str(non_contig_start_vlan_id + 1)
+            vlan["partial_range"][1] = \
+                str(non_contig_start_vlan_id + 3) \
+                + '-' + str(non_contig_start_vlan_id + 4)
+            vlan["full_range"] = \
+                str(non_contig_start_vlan_id) \
+                + '-' + str(non_contig_start_vlan_id + 4)
             NonContigVlanIdsAcquired = True
 
         else:
@@ -930,7 +947,8 @@ def setNonContiguousVlanIds(apiclient, zoneid):
         else:
             break
 
-    # If even through looping from all existing physical networks, failed to get relevant non
+    # If even through looping from all existing physical networks,
+    # failed to get relevant non
     # contiguous vlan ids, then fail the test case
 
     if not NonContigVlanIdsAcquired:
@@ -938,84 +956,111 @@ def setNonContiguousVlanIds(apiclient, zoneid):
 
     return physical_network, vlan
 
+
 def is_public_ip_in_correct_state(apiclient, ipaddressid, state):
     """ Check if the given IP is in the correct state (given)
     and return True/False accordingly"""
     retriesCount = 10
     while True:
         portableips = PublicIPAddress.list(apiclient, id=ipaddressid)
-        assert validateList(portableips)[0] == PASS, "IPs list validation failed"
+        assert validateList(
+            portableips)[0] == PASS, "IPs list validation failed"
         if str(portableips[0].state).lower() == state:
             break
         elif retriesCount == 0:
-           return False
+            return False
         else:
             retriesCount -= 1
             time.sleep(60)
             continue
     return True
 
+
 def setSharedNetworkParams(networkServices, range=20):
-    """Fill up the services dictionary for shared network using random subnet"""
+    """Fill up the services dictionary for shared network
+    using random subnet
+    """
 
-    # @range: range decides the endip. Pass the range as "x" if you want the difference between the startip
+    # @range: range decides the endip. Pass the range as "x"
+    # if you want the difference between the startip
     # and endip as "x"
     # Set the subnet number of shared networks randomly prior to execution
     # of each test case to avoid overlapping of ip addresses
-    shared_network_subnet_number = random.randrange(1,254)
-
-    networkServices["gateway"] = "172.16."+str(shared_network_subnet_number)+".1"
-    networkServices["startip"] = "172.16."+str(shared_network_subnet_number)+".2"
-    networkServices["endip"] = "172.16."+str(shared_network_subnet_number)+"."+str(range+1)
+    shared_network_subnet_number = random.randrange(1, 254)
+
+    networkServices["gateway"] = "172.16." + \
+        str(shared_network_subnet_number) + ".1"
+    networkServices["startip"] = "172.16." + \
+        str(shared_network_subnet_number) + ".2"
+    networkServices["endip"] = "172.16." + \
+        str(shared_network_subnet_number) + "." + str(range + 1)
     networkServices["netmask"] = "255.255.255.0"
     return networkServices
 
+
 def createEnabledNetworkOffering(apiclient, networkServices):
     """Create and enable network offering according to the type
 
        @output: List, containing [ Result,Network Offering,Reason ]
-                 Ist Argument('Result') : FAIL : If exception or assertion error occurs
+                 Ist Argument('Result') : FAIL : If exception or assertion
+                                          error occurs
                                           PASS : If network offering
                                           is created and enabled successfully
                  IInd Argument(Net Off) : Enabled network offering
                                                 In case of exception or
-                                                assertion error, it will be None
+                                                assertion error, it will be
+                                                None
                  IIIrd Argument(Reason) :  Reason for failure,
                                               default to None
     """
     try:
         resultSet = [FAIL, None, None]
         # Create network offering
-        network_offering = NetworkOffering.create(apiclient, networkServices, conservemode=False)
+        network_offering = NetworkOffering.create(
+            apiclient,
+            networkServices,
+            conservemode=False)
 
         # Update network offering state from disabled to enabled.
-        NetworkOffering.update(network_offering, apiclient, id=network_offering.id,
+        NetworkOffering.update(network_offering,
+                               apiclient, id=network_offering.id,
                                state="enabled")
     except Exception as e:
         resultSet[2] = e
         return resultSet
     return [PASS, network_offering, None]
 
+
 def shouldTestBeSkipped(networkType, zoneType):
     """Decide which test to skip, according to type of network and zone type"""
 
-    # If network type is isolated or vpc and zone type is basic, then test should be skipped
+    # If network type is isolated or vpc and zone type is basic, then test
+    # should be skipped
     skipIt = False
-    if ((networkType.lower() == str(ISOLATED_NETWORK).lower() or networkType.lower() == str(VPC_NETWORK).lower())
-            and (zoneType.lower() == BASIC_ZONE)):
+    if (networkType.lower() == str(ISOLATED_NETWORK).lower() or
+        networkType.lower() == str(VPC_NETWORK).lower()) and\
+        (zoneType.lower() == BASIC_ZONE):
         skipIt = True
     return skipIt
 
+
 def verifyNetworkState(apiclient, networkid, state):
     """List networks and check if the network state matches the given state"""
     try:
         networks = Network.list(apiclient, id=networkid)
     except Exception as e:
-        raise Exception("Failed while fetching network list with error: %s" % e)
-    assert validateList(networks)[0] == PASS, "Networks list validation failed, list is %s" % networks
-    assert str(networks[0].state).lower() == state, "network state should be %s, it is %s" % (state, networks[0].state)
+        raise Exception(
+            "Failed while fetching network list with error: %s" %
+            e)
+    assert validateList(
+        networks)[0] == PASS, "Networks list validation failed, list is %s"\
+                              % networks
+    assert str(networks[0].state).lower(
+    ) == state, "network state should be %s, it is %s" \
+                % (state, networks[0].state)
     return
 
+
 def verifyComputeOfferingCreation(apiclient, computeofferingid):
     """List Compute offerings by ID and verify that the offering exists"""
 
@@ -1025,11 +1070,12 @@ def verifyComputeOfferingCreation(apiclient, computeofferingid):
     try:
         serviceOfferings = apiclient.listServiceOfferings(cmd)
     except Exception:
-       return FAIL
+        return FAIL
     if not (isinstance(serviceOfferings, list) and len(serviceOfferings) > 0):
-       return FAIL
+        return FAIL
     return PASS
 
+
 def createNetworkRulesForVM(apiclient, virtualmachine, ruletype,
                             account, networkruledata):
     """Acquire IP, create Firewall and NAT/StaticNAT rule
@@ -1037,26 +1083,28 @@ def createNetworkRulesForVM(apiclient, virtualmachine, ruletype,
 
     try:
         public_ip = PublicIPAddress.create(
-                apiclient,accountid=account.name,
-                zoneid=virtualmachine.zoneid,domainid=account.domainid,
-                networkid=virtualmachine.nic[0].networkid)
+            apiclient, accountid=account.name,
+            zoneid=virtualmachine.zoneid, domainid=account.domainid,
+            networkid=virtualmachine.nic[0].networkid)
 
         FireWallRule.create(
-            apiclient,ipaddressid=public_ip.ipaddress.id,
+            apiclient, ipaddressid=public_ip.ipaddress.id,
             protocol='TCP', cidrlist=[networkruledata["fwrule"]["cidr"]],
             startport=networkruledata["fwrule"]["startport"],
             endport=networkruledata["fwrule"]["endport"]
-            )
+        )
 
         if ruletype == NAT_RULE:
             # Create NAT rule
             NATRule.create(apiclient, virtualmachine,
-                                 networkruledata["natrule"],ipaddressid=public_ip.ipaddress.id,
-                                 networkid=virtualmachine.nic[0].networkid)
+                           networkruledata[
+                               "natrule"], ipaddressid=public_ip.ipaddress.id,
+                           networkid=virtualmachine.nic[0].networkid)
         elif ruletype == STATIC_NAT_RULE:
             # Enable Static NAT for VM
-            StaticNATRule.enable(apiclient,public_ip.ipaddress.id,
-                                     virtualmachine.id, networkid=virtualmachine.nic[0].networkid)
+            StaticNATRule.enable(apiclient, public_ip.ipaddress.id,
+                                 virtualmachine.id,
+                                 networkid=virtualmachine.nic[0].networkid)
     except Exception as e:
         [FAIL, e]
     return [PASS, public_ip]


Mime
View raw message