Run codecheck script on FUNCovsdbtest
Change-Id: Ieb09ac40b7fae0a569a5bb362e55a23b400e1e7e
diff --git a/TestON/tests/FUNC/FUNCovsdbtest/FUNCovsdbtest.py b/TestON/tests/FUNC/FUNCovsdbtest/FUNCovsdbtest.py
index 3563efb..3f1f91d 100644
--- a/TestON/tests/FUNC/FUNCovsdbtest/FUNCovsdbtest.py
+++ b/TestON/tests/FUNC/FUNCovsdbtest/FUNCovsdbtest.py
@@ -14,6 +14,7 @@
"""
import os
+
class FUNCovsdbtest:
def __init__( self ):
@@ -46,8 +47,8 @@
gitBranch = main.params[ 'GIT' ][ 'branch' ]
cellName = main.params[ 'ENV' ][ 'cellName' ]
ipList = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
- main.startUpSleep = int( main.params['SLEEP']['startup'] )
- cellAppString = main.params['ENV']['cellApps']
+ main.startUpSleep = int( main.params[ 'SLEEP' ][ 'startup' ] )
+ cellAppString = main.params[ 'ENV' ][ 'cellApps' ]
if gitPull == 'True':
main.step( "Building ONOS in " + gitBranch + "branch" )
@@ -56,10 +57,10 @@
utilities.assert_equals( expect=main.TRUE,
actual=stepResult,
onpass="Successfully compiled latest ONOS",
- onfail="Failed to compile latest ONOS")
+ onfail="Failed to compile latest ONOS" )
else:
main.log.warn( "Did not pull new code so skipping mvn " +
- "clean install" )
+ "clean install" )
main.ONOSbench.getVersion( report=True )
main.log.info( "Safety check, killing all ONOS processes" +
@@ -70,7 +71,7 @@
main.CLIs = []
main.nodes = []
- main.numCtrls= 1
+ main.numCtrls = 1
for i in range( 1, main.numCtrls + 1 ):
try:
@@ -115,7 +116,6 @@
onpass="Successfully applied cell to environment",
onfail="Failed to apply cell to environment" )
-
main.step( "Creating ONOS package" )
packageResult = main.ONOSbench.buckBuild()
utilities.assert_equals( expect=main.TRUE,
@@ -125,7 +125,7 @@
time.sleep( main.startUpSleep )
main.step( "Installing ONOS package" )
- onosInstallResult = main.ONOSbench.onosInstall( options="-f", node=main.nodes[0].ip_address )
+ onosInstallResult = main.ONOSbench.onosInstall( options="-f", node=main.nodes[ 0 ].ip_address )
utilities.assert_equals( expect=main.TRUE, actual=onosInstallResult,
onpass="Successfully installed ONOS package",
onfail="Failed to install ONOS package" )
@@ -139,7 +139,7 @@
onfail="Test step FAIL" )
time.sleep( main.startUpSleep )
- main.step("Starting ONOS service")
+ main.step( "Starting ONOS service" )
stopResult = main.TRUE
startResult = main.TRUE
onos1Isup = main.TRUE
@@ -150,7 +150,7 @@
main.log.report( "ONOS instance {0} is up and ready".format( i + 1 ) )
else:
main.log.report( "ONOS instance {0} may not be up, stop and ".format( i + 1 ) +
- "start ONOS again" )
+ "start ONOS again" )
stopResult = stopResult and main.ONOSbench.onosStop( main.ONOSip[ i ] )
startResult = startResult and main.ONOSbench.onosStart( main.ONOSip[ i ] )
if not startResult or stopResult:
@@ -195,7 +195,6 @@
onfail="Install onos-app-vtn failed" )
def CASE2( self, main ):
-
"""
Test ovsdb connection and teardown
"""
@@ -226,7 +225,7 @@
stepResult = main.FALSE
utilities.assert_equals( expect=main.TRUE,
actual=stepResult,
- onpass="Check ovsdb node manager is " + str( response ) ,
+ onpass="Check ovsdb node manager is " + str( response ),
onfail="Check ovsdb node manager failed" )
main.step( "Delete ovsdb node manager" )
@@ -249,7 +248,6 @@
onfail="Check ovsdb node delete manager failed" )
def CASE3( self, main ):
-
"""
Test default br-int configuration and vxlan port
"""
@@ -263,17 +261,17 @@
ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
ovsdbport = main.params[ 'CTRL' ][ 'ovsdbport' ]
delaytime = main.params[ 'TIMER' ][ 'delaytime' ]
- OVSDB1Ip = os.getenv( main.params['OVSDB']['ip1'] )
- OVSDB2Ip = os.getenv( main.params['OVSDB']['ip2'] )
+ OVSDB1Ip = os.getenv( main.params[ 'OVSDB' ][ 'ip1' ] )
+ OVSDB2Ip = os.getenv( main.params[ 'OVSDB' ][ 'ip2' ] )
main.step( "ovsdb node 1 set ovs manager to " + str( ctrlip ) )
assignResult = main.OVSDB1.setManager( ip=ctrlip, port=ovsdbport, delaytime=delaytime )
stepResult = assignResult
utilities.assert_equals( expect=main.TRUE,
actual=stepResult,
- onpass="ovsdb node 1 set ovs manager to to " +\
+ onpass="ovsdb node 1 set ovs manager to to " +
str( ctrlip ) + " sucess",
- onfail="ovsdb node 1 set ovs manager to to " +\
+ onfail="ovsdb node 1 set ovs manager to to " +
str( ctrlip ) + " failed" )
main.step( "ovsdb node 2 set ovs manager to " + str( ctrlip ) )
@@ -281,9 +279,9 @@
stepResult = assignResult
utilities.assert_equals( expect=main.TRUE,
actual=stepResult,
- onpass="ovsdb node 2 set ovs manager to to " +\
+ onpass="ovsdb node 2 set ovs manager to to " +
str( ctrlip ) + " sucess",
- onfail="ovsdb node 2 set ovs manager to to " +\
+ onfail="ovsdb node 2 set ovs manager to to " +
str( ctrlip ) + " failed" )
main.step( "Check ovsdb node 1 manager is " + str( ctrlip ) )
@@ -294,7 +292,7 @@
stepResult = main.FALSE
utilities.assert_equals( expect=main.TRUE,
actual=stepResult,
- onpass="ovsdb node 1 manager is " + str( response ) ,
+ onpass="ovsdb node 1 manager is " + str( response ),
onfail="ovsdb node 1 manager check failed" )
main.step( "Check ovsdb node 2 manager is " + str( ctrlip ) )
@@ -305,7 +303,7 @@
stepResult = main.FALSE
utilities.assert_equals( expect=main.TRUE,
actual=stepResult,
- onpass="ovsdb node 2 manager is " + str( response ) ,
+ onpass="ovsdb node 2 manager is " + str( response ),
onfail="ovsdb node 2 manager check failed" )
main.step( "Check default br-int bridge on ovsdb node " + str( OVSDB1Ip ) )
@@ -353,7 +351,6 @@
onfail="onos add default vxlan port on the node 2 failed" )
def CASE4( self, main ):
-
"""
Test default openflow configuration
"""
@@ -369,9 +366,9 @@
stepResult = assignResult
utilities.assert_equals( expect=main.TRUE,
actual=stepResult,
- onpass="ovsdb node 1 set ovs manager to to " +\
+ onpass="ovsdb node 1 set ovs manager to to " +
str( ctrlip ) + " sucess",
- onfail="ovsdb node 1 set ovs manager to to " +\
+ onfail="ovsdb node 1 set ovs manager to to " +
str( ctrlip ) + " failed" )
main.step( "ovsdb node 2 set ovs manager to " + str( ctrlip ) )
@@ -379,9 +376,9 @@
stepResult = assignResult
utilities.assert_equals( expect=main.TRUE,
actual=stepResult,
- onpass="ovsdb node 2 set ovs manager to to " +\
+ onpass="ovsdb node 2 set ovs manager to to " +
str( ctrlip ) + " sucess",
- onfail="ovsdb node 2 set ovs manager to to " +\
+ onfail="ovsdb node 2 set ovs manager to to " +
str( ctrlip ) + " failed" )
main.step( "Check ovsdb node 1 manager is " + str( ctrlip ) )
@@ -392,8 +389,8 @@
stepResult = main.FALSE
utilities.assert_equals( expect=main.TRUE,
actual=stepResult,
- onpass="ovsdb node 1 manager is " + str( response ) ,
- onfail="ovsdb node 1 manager check failed\n" +\
+ onpass="ovsdb node 1 manager is " + str( response ),
+ onfail="ovsdb node 1 manager check failed\n" +
str( main.OVSDB1.show() ) )
main.step( "Check ovsdb node 2 manager is " + str( ctrlip ) )
@@ -404,8 +401,8 @@
stepResult = main.FALSE
utilities.assert_equals( expect=main.TRUE,
actual=stepResult,
- onpass="ovsdb node 2 manager is " + str( response ) ,
- onfail="ovsdb node 2 manager check failed\n" +\
+ onpass="ovsdb node 2 manager is " + str( response ),
+ onfail="ovsdb node 2 manager check failed\n" +
str( main.OVSDB2.show() ) )
main.step( "Check ovsdb node 1 bridge br-int controller set to " + str( ctrlip ) )
@@ -416,9 +413,9 @@
stepResult = main.FALSE
utilities.assert_equals( expect=main.TRUE,
actual=stepResult,
- onpass="Check ovsdb node 1 bridge br-int controller set to " +\
+ onpass="Check ovsdb node 1 bridge br-int controller set to " +
str( ctrlip ) + " sucess",
- onfail="Check ovsdb node 1 bridge br-int controller set to " +\
+ onfail="Check ovsdb node 1 bridge br-int controller set to " +
str( ctrlip ) + " failed\n" + str( main.OVSDB1.show() ) )
main.step( "Check ovsdb node 2 bridge br-int controller set to " + str( ctrlip ) )
@@ -429,10 +426,10 @@
stepResult = main.FALSE
utilities.assert_equals( expect=main.TRUE,
actual=stepResult,
- onpass="Check ovsdb node 2 bridge br-int controller set to " +\
+ onpass="Check ovsdb node 2 bridge br-int controller set to " +
str( ctrlip ) + " sucess",
- onfail="Check ovsdb node 2 bridge br-int controller set to " +\
- str( ctrlip ) + " failed\n" + str( main.OVSDB2.show()) )
+ onfail="Check ovsdb node 2 bridge br-int controller set to " +
+ str( ctrlip ) + " failed\n" + str( main.OVSDB2.show() ) )
main.step( "Check onoscli devices have ovs " + str( OVSDB1Ip ) )
response = main.ONOScli1.devices()
@@ -457,7 +454,6 @@
onfail="Check onoscli devices have ovs " + str( OVSDB2Ip ) + " failed" )
def CASE5( self, main ):
-
"""
Test default flows
"""
@@ -473,9 +469,9 @@
stepResult = assignResult
utilities.assert_equals( expect=main.TRUE,
actual=stepResult,
- onpass="ovsdb node 1 set ovs manager to to " +\
+ onpass="ovsdb node 1 set ovs manager to to " +
str( ctrlip ) + " sucess",
- onfail="ovsdb node 1 set ovs manager to to " +\
+ onfail="ovsdb node 1 set ovs manager to to " +
str( ctrlip ) + " failed" )
main.step( "Check ovsdb node 1 manager is " + str( ctrlip ) )
@@ -486,7 +482,7 @@
stepResult = main.FALSE
utilities.assert_equals( expect=main.TRUE,
actual=stepResult,
- onpass="ovsdb node 1 manager is " + str( response ) ,
+ onpass="ovsdb node 1 manager is " + str( response ),
onfail="ovsdb node 1 manager check failed" )
main.step( "Check ovsdb node 1 bridge br-int default flows on " + str( OVSDB1Ip ) )
@@ -497,7 +493,7 @@
stepResult = main.FALSE
utilities.assert_equals( expect=main.TRUE,
actual=stepResult,
- onpass="Successfully set default flows " + str( ctrlip ) ,
+ onpass="Successfully set default flows " + str( ctrlip ),
onfail="Failed to set default flows " + str( ctrlip ) )
def CASE6( self, main ):
@@ -521,9 +517,9 @@
main.caseExplanation = "Configure Network Subnet Port " +\
"Verify post is OK"
- ctrlip = os.getenv( main.params['CTRL']['ip1'] )
- httpport = main.params['HTTP']['port']
- path = main.params['HTTP']['path']
+ ctrlip = os.getenv( main.params[ 'CTRL' ][ 'ip1' ] )
+ httpport = main.params[ 'HTTP' ][ 'port' ]
+ path = main.params[ 'HTTP' ][ 'path' ]
main.step( "Generate Post Data" )
network = NetworkData()
@@ -593,7 +589,6 @@
onfail="Post Port Failed " + str( Poststatus ) + "," + str( result ) )
def CASE7( self, main ):
-
"""
Test host go online and ping each other
"""
@@ -609,9 +604,9 @@
stepResult = assignResult
utilities.assert_equals( expect=main.TRUE,
actual=stepResult,
- onpass="ovsdb node 1 set ovs manager to to " +\
+ onpass="ovsdb node 1 set ovs manager to to " +
str( ctrlip ) + " sucess",
- onfail="ovsdb node 1 set ovs manager to to " +\
+ onfail="ovsdb node 1 set ovs manager to to " +
str( ctrlip ) + " failed" )
main.step( "ovsdb node 2 set ovs manager to " + str( ctrlip ) )
@@ -619,9 +614,9 @@
stepResult = assignResult
utilities.assert_equals( expect=main.TRUE,
actual=stepResult,
- onpass="ovsdb node 2 set ovs manager to " +\
+ onpass="ovsdb node 2 set ovs manager to " +
str( ctrlip ) + " sucess",
- onfail="ovsdb node 2 set ovs manager to " +\
+ onfail="ovsdb node 2 set ovs manager to " +
str( ctrlip ) + " failed" )
main.step( "Create host1 on node 1 " + str( OVSDB1Ip ) )
@@ -638,38 +633,38 @@
onpass="Create host2 on node 2 " + str( OVSDB2Ip ) + " sucess",
onfail="Create host2 on node 2 " + str( OVSDB2Ip ) + " failed" )
- main.step( "Create port on host1 on the node " + str ( OVSDB1Ip ) )
+ main.step( "Create port on host1 on the node " + str( OVSDB1Ip ) )
stepResult = main.OVSDB1.createHostport( hostname="host1", hostport="host1-eth0", hostportmac="000000000001" )
utilities.assert_equals( expect=main.TRUE,
actual=stepResult,
onpass="Create port on host1 on the node " + str( OVSDB1Ip ) + " sucess",
onfail="Create port on host1 on the node " + str( OVSDB1Ip ) + " failed" )
- main.step( "Create port on host2 on the node " + str ( OVSDB2Ip ) )
+ main.step( "Create port on host2 on the node " + str( OVSDB2Ip ) )
stepResult = main.OVSDB2.createHostport( hostname="host2", hostport="host2-eth0", hostportmac="000000000002" )
utilities.assert_equals( expect=main.TRUE,
actual=stepResult,
onpass="Create port on host1 on the node " + str( OVSDB2Ip ) + " sucess",
onfail="Create port on host1 on the node " + str( OVSDB2Ip ) + " failed" )
- main.step( "Add port to ovs br-int and host go-online on the node " + str ( OVSDB1Ip ) )
+ main.step( "Add port to ovs br-int and host go-online on the node " + str( OVSDB1Ip ) )
stepResult = main.OVSDB1.addPortToOvs( ovsname="br-int", ifaceId="00000000-0000-0000-0000-000000000001",
attachedMac="00:00:00:00:00:01", vmuuid="10000000-0000-0000-0000-000000000001" )
utilities.assert_equals( expect=main.TRUE,
actual=stepResult,
- onpass="Add port to ovs br-int and host go-online on the node " +\
+ onpass="Add port to ovs br-int and host go-online on the node " +
str( OVSDB1Ip ) + " sucess",
- onfail="Add port to ovs br-int and host go-online on the node " +\
+ onfail="Add port to ovs br-int and host go-online on the node " +
str( OVSDB1Ip ) + " failed" )
- main.step( "Add port to ovs br-int and host go-online on the node " + str ( OVSDB2Ip ) )
+ main.step( "Add port to ovs br-int and host go-online on the node " + str( OVSDB2Ip ) )
stepResult = main.OVSDB2.addPortToOvs( ovsname="br-int", ifaceId="00000000-0000-0000-0000-000000000002",
attachedMac="00:00:00:00:00:02", vmuuid="10000000-0000-0000-0000-000000000001" )
utilities.assert_equals( expect=main.TRUE,
actual=stepResult,
- onpass="Add port to ovs br-int and host go-online on the node " +\
+ onpass="Add port to ovs br-int and host go-online on the node " +
str( OVSDB2Ip ) + " sucess",
- onfail="Add port to ovs br-int and host go-online on the node " +\
+ onfail="Add port to ovs br-int and host go-online on the node " +
str( OVSDB2Ip ) + " failed" )
main.step( "Check onos set host flows on the node " + str( OVSDB1Ip ) )
@@ -680,9 +675,9 @@
stepResult = main.FALSE
utilities.assert_equals( expect=main.TRUE,
actual=stepResult,
- onpass="Check onos set host flows on the node " +\
+ onpass="Check onos set host flows on the node " +
str( OVSDB1Ip ) + " sucess",
- onfail="Check onos set host flows on the node " +\
+ onfail="Check onos set host flows on the node " +
str( OVSDB1Ip ) + " failed" )
main.step( "Check onos set host flows on the node " + str( OVSDB2Ip ) )
@@ -693,9 +688,9 @@
stepResult = main.FALSE
utilities.assert_equals( expect=main.TRUE,
actual=stepResult,
- onpass="Check onos set host flows on the node " +\
+ onpass="Check onos set host flows on the node " +
str( OVSDB2Ip ) + " sucess",
- onfail="Check onos set host flows on the node " +\
+ onfail="Check onos set host flows on the node " +
str( OVSDB2Ip ) + " failed" )
main.step( "Check hosts can ping each other" )
@@ -706,13 +701,12 @@
stepResult = pingResult1 and pingResult2
utilities.assert_equals( expect=main.TRUE,
actual=stepResult,
- onpass="Successfully host go online and ping each other,controller is " +\
+ onpass="Successfully host go online and ping each other,controller is " +
str( ctrlip ),
- onfail="Failed to host go online and ping each other,controller is " +\
+ onfail="Failed to host go online and ping each other,controller is " +
str( ctrlip ) )
def CASE8( self, main ):
-
"""
Clear ovs configuration and host configuration
"""
diff --git a/TestON/tests/FUNC/FUNCovsdbtest/dependencies/Nbdata.py b/TestON/tests/FUNC/FUNCovsdbtest/dependencies/Nbdata.py
index 3fde20d..6c8725e 100644
--- a/TestON/tests/FUNC/FUNCovsdbtest/dependencies/Nbdata.py
+++ b/TestON/tests/FUNC/FUNCovsdbtest/dependencies/Nbdata.py
@@ -4,9 +4,10 @@
"""
import json
+
class NetworkData:
- def __init__(self):
+ def __init__( self ):
self.id = ''
self.state = 'ACTIVE'
self.name = 'onosfw-1'
@@ -14,76 +15,77 @@
self.admin_state_up = True
self.tenant_id = ''
self.routerExternal = False
- self.type ='LOCAL'
+ self.type = 'LOCAL'
self.segmentationID = '6'
self.shared = False
- def DictoJson(self):
+ def DictoJson( self ):
- if self.id =='' or self.tenant_id == '':
+ if self.id == '' or self.tenant_id == '':
print 'Id and tenant id is necessary!'
Dicdata = {}
- if self.id !='':
- Dicdata['id'] = self.id
+ if self.id != '':
+ Dicdata[ 'id' ] = self.id
if self.state != '':
- Dicdata['status'] = self.state
- if self.name !='':
- Dicdata['name'] = self.name
- if self.physicalNetwork !='':
- Dicdata['provider:physical_network'] = self.physicalNetwork
- if self.admin_state_up !='':
- Dicdata['admin_state_up'] = self.admin_state_up
- if self.tenant_id !='':
- Dicdata['tenant_id'] = self.tenant_id
- if self.routerExternal !='':
- Dicdata['router:external'] = self.routerExternal
- if self.type !='':
- Dicdata['provider:network_type'] = self.type
- if self.segmentationID !='':
- Dicdata['provider:segmentation_id'] = self.segmentationID
- if self.shared !='':
- Dicdata['shared'] = self.shared
+ Dicdata[ 'status' ] = self.state
+ if self.name != '':
+ Dicdata[ 'name' ] = self.name
+ if self.physicalNetwork != '':
+ Dicdata[ 'provider:physical_network' ] = self.physicalNetwork
+ if self.admin_state_up != '':
+ Dicdata[ 'admin_state_up' ] = self.admin_state_up
+ if self.tenant_id != '':
+ Dicdata[ 'tenant_id' ] = self.tenant_id
+ if self.routerExternal != '':
+ Dicdata[ 'router:external' ] = self.routerExternal
+ if self.type != '':
+ Dicdata[ 'provider:network_type' ] = self.type
+ if self.segmentationID != '':
+ Dicdata[ 'provider:segmentation_id' ] = self.segmentationID
+ if self.shared != '':
+ Dicdata[ 'shared' ] = self.shared
- Dicdata = {'network': Dicdata}
+ Dicdata = { 'network': Dicdata }
- return json.dumps(Dicdata,indent=4)
+ return json.dumps( Dicdata, indent=4 )
- def Ordered(self,obj):
+ def Ordered( self, obj ):
- if isinstance(obj, dict):
- return sorted((k,self.Ordered(v)) for k, v in obj.items())
- if isinstance(obj, list):
- return sorted(self.Ordered(x) for x in obj )
+ if isinstance( obj, dict ):
+ return sorted( ( k, self.Ordered( v ) ) for k, v in obj.items() )
+ if isinstance( obj, list ):
+ return sorted( self.Ordered( x ) for x in obj )
else:
return obj
- def JsonCompare(self,SourceData,DestiData,FirstPara,SecondPara):
+ def JsonCompare( self, SourceData, DestiData, FirstPara, SecondPara ):
try:
- SourceCompareDataDic = json.loads(SourceData)
- DestiCompareDataDic = json.loads(DestiData)
+ SourceCompareDataDic = json.loads( SourceData )
+ DestiCompareDataDic = json.loads( DestiData )
except ValueError:
print "SourceData or DestData is not JSON Type!"
return False
try:
- Socom = SourceCompareDataDic[FirstPara][SecondPara]
- Decom = DestiCompareDataDic[FirstPara][SecondPara]
- except KeyError,error:
- print "Key error ,This key is not found:%s"%error
+ Socom = SourceCompareDataDic[ FirstPara ][ SecondPara ]
+ Decom = DestiCompareDataDic[ FirstPara ][ SecondPara ]
+ except KeyError as error:
+ print "Key error ,This key is not found:%s" % error
return False
- if str(Socom).lower()== str(Decom).lower():
+ if str( Socom ).lower() == str( Decom ).lower():
return True
else:
- print "Source Compare data:"+FirstPara+"."+SecondPara+"="+str(Socom)
- print "Dest Compare data: "+FirstPara+"."+SecondPara+"="+str(Decom)
+ print "Source Compare data:" + FirstPara + "." + SecondPara + "=" + str( Socom )
+ print "Dest Compare data: " + FirstPara + "." + SecondPara + "=" + str( Decom )
return False
-class SubnetData(NetworkData):
- def __init__(self):
+class SubnetData( NetworkData ):
+
+ def __init__( self ):
self.id = ''
self.tenant_id = ''
self.network_id = ''
@@ -101,59 +103,60 @@
self.shared = False
self.name = 'demo-subnet'
- def DictoJson(self):
- if self.id =='' or self.tenant_id == '':
+ def DictoJson( self ):
+ if self.id == '' or self.tenant_id == '':
print 'Id and tenant id is necessary!'
Dicdata = {}
host_routesdata = []
- host_routesdata.append({'nexthop': self.nexthop,'destination': self.destination})
+ host_routesdata.append( { 'nexthop': self.nexthop, 'destination': self.destination } )
allocation_pools = []
- allocation_pools.append({'start': self.start,'end':self.end})
+ allocation_pools.append( { 'start': self.start, 'end': self.end } )
if self.id != '':
- Dicdata['id'] = self.id
+ Dicdata[ 'id' ] = self.id
if self.network_id != '':
- Dicdata['network_id'] = self.network_id
+ Dicdata[ 'network_id' ] = self.network_id
if self.name != '':
- Dicdata['name'] = self.name
+ Dicdata[ 'name' ] = self.name
if self.nexthop != '':
- Dicdata['host_routes'] = host_routesdata
+ Dicdata[ 'host_routes' ] = host_routesdata
if self.tenant_id != '':
- Dicdata['tenant_id'] = self.tenant_id
+ Dicdata[ 'tenant_id' ] = self.tenant_id
if self.start != '':
- Dicdata['allocation_pools'] = allocation_pools
+ Dicdata[ 'allocation_pools' ] = allocation_pools
if self.shared != '':
- Dicdata['shared'] = self.shared
+ Dicdata[ 'shared' ] = self.shared
if self.ipv6_address_mode != '':
- Dicdata['ipv6_address_mode'] = self.ipv6_address_mode
+ Dicdata[ 'ipv6_address_mode' ] = self.ipv6_address_mode
if self.ipv6_ra_mode != '':
- Dicdata['ipv6_ra_mode'] = self.ipv6_ra_mode
+ Dicdata[ 'ipv6_ra_mode' ] = self.ipv6_ra_mode
if self.cidr != '':
- Dicdata['cidr'] = self.cidr
+ Dicdata[ 'cidr' ] = self.cidr
if self.enable_dhcp != '':
- Dicdata['enable_dhcp'] = self.enable_dhcp
+ Dicdata[ 'enable_dhcp' ] = self.enable_dhcp
if self.dns_nameservers != '':
- Dicdata['dns_nameservers'] = self.dns_nameservers
+ Dicdata[ 'dns_nameservers' ] = self.dns_nameservers
if self.gateway_ip != '':
- Dicdata['gateway_ip'] = self.gateway_ip
+ Dicdata[ 'gateway_ip' ] = self.gateway_ip
if self.ip_version != '':
- Dicdata['ip_version'] = self.ip_version
+ Dicdata[ 'ip_version' ] = self.ip_version
- Dicdata = {'subnet': Dicdata}
+ Dicdata = { 'subnet': Dicdata }
- return json.dumps(Dicdata,indent=4)
+ return json.dumps( Dicdata, indent=4 )
-class VirtualPortData(NetworkData):
- def __init__(self):
+class VirtualPortData( NetworkData ):
+
+ def __init__( self ):
self.id = ''
self.state = 'ACTIVE'
self.bindingHostId = 'fa:16:3e:76:8e:88'
- self.allowedAddressPairs = [{'mac_address':'fa:16:3e:76:8e:88','ip_address':'192.168.1.1'}]
+ self.allowedAddressPairs = [ { 'mac_address': 'fa:16:3e:76:8e:88', 'ip_address': '192.168.1.1' } ]
self.deviceOwner = 'none'
self.fixedIp = []
- self.securityGroups = [{'securityGroup':'asd'}]
+ self.securityGroups = [ { 'securityGroup': 'asd' } ]
self.adminStateUp = True
self.network_id = ''
self.tenant_id = ''
@@ -165,48 +168,48 @@
self.deviceId = 'a08aa'
self.name = 'u'
- def DictoJson(self):
+ def DictoJson( self ):
if self.id == '' or self.tenant_id == ' ' or \
self.network_id == '' or self.subnet_id == '':
print 'Id/tenant id/networkid/subnetId is necessary!'
Dicdata = {}
- fixedIp =[]
- fixedIp.append({'subnet_id':self.subnet_id,'ip_address':'192.168.1.4'})
+ fixedIp = []
+ fixedIp.append( { 'subnet_id': self.subnet_id, 'ip_address': '192.168.1.4' } )
allocation_pools = []
if self.id != '':
- Dicdata['id'] = self.id
+ Dicdata[ 'id' ] = self.id
if self.state != '':
- Dicdata['status'] = self.state
+ Dicdata[ 'status' ] = self.state
if self.bindingHostId != '':
- Dicdata['binding:host_id'] = self.bindingHostId
+ Dicdata[ 'binding:host_id' ] = self.bindingHostId
if self.allowedAddressPairs != '':
- Dicdata['allowed_address_pairs'] = self.allowedAddressPairs
+ Dicdata[ 'allowed_address_pairs' ] = self.allowedAddressPairs
if self.deviceOwner != '':
- Dicdata['device_owner'] = self.deviceOwner
+ Dicdata[ 'device_owner' ] = self.deviceOwner
if self.securityGroups != '':
- Dicdata['security_groups'] = self.securityGroups
+ Dicdata[ 'security_groups' ] = self.securityGroups
if self.adminStateUp != '':
- Dicdata['admin_state_up'] = self.adminStateUp
+ Dicdata[ 'admin_state_up' ] = self.adminStateUp
if self.network_id != '':
- Dicdata['network_id'] = self.network_id
+ Dicdata[ 'network_id' ] = self.network_id
if self.tenant_id != '':
- Dicdata['tenant_id'] = self.tenant_id
+ Dicdata[ 'tenant_id' ] = self.tenant_id
if self.bindingvifDetails != '':
- Dicdata['binding:vif_details'] = self.bindingvifDetails
+ Dicdata[ 'binding:vif_details' ] = self.bindingvifDetails
if self.bindingvnicType != '':
- Dicdata['binding:vnic_type'] = self.bindingvnicType
+ Dicdata[ 'binding:vnic_type' ] = self.bindingvnicType
if self.bindingvifType != '':
- Dicdata['binding:vif_type'] = self.bindingvifType
+ Dicdata[ 'binding:vif_type' ] = self.bindingvifType
if self.macAddress != '':
- Dicdata['mac_address'] = self.macAddress
+ Dicdata[ 'mac_address' ] = self.macAddress
if self.deviceId != '':
- Dicdata['device_id'] = self.deviceId
+ Dicdata[ 'device_id' ] = self.deviceId
if self.name != '':
- Dicdata['name'] = self.name
+ Dicdata[ 'name' ] = self.name
- Dicdata['fixed_ips'] = fixedIp
- Dicdata = {'port': Dicdata}
+ Dicdata[ 'fixed_ips' ] = fixedIp
+ Dicdata = { 'port': Dicdata }
- return json.dumps(Dicdata,indent=4)
+ return json.dumps( Dicdata, indent=4 )