summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--catalog/packages/nf_package.py3
-rw-r--r--catalog/packages/ns_package.py2
-rw-r--r--catalog/pub/utils/toscaparser/basemodel.py17
-rw-r--r--catalog/pub/utils/toscaparser/nsdmodel.py12
-rw-r--r--catalog/pub/utils/toscaparser/vnfdmodel.py5
-rw-r--r--tox.ini2
6 files changed, 18 insertions, 23 deletions
diff --git a/catalog/packages/nf_package.py b/catalog/packages/nf_package.py
index b6524c8e..20ad9b8f 100644
--- a/catalog/packages/nf_package.py
+++ b/catalog/packages/nf_package.py
@@ -58,7 +58,7 @@ def nf_get_csar(csar_id):
def parse_vnfd(csar_id, inputs):
- ret= None
+ ret = None
try:
nf_pkg = VnfPackageModel.objects.filter(vnfPackageId=csar_id)
if not nf_pkg:
@@ -141,7 +141,6 @@ class NfDistributeThread(threading.Thread):
JobUtil.add_job_status(self.job_id, 100, "CSAR(%s) distribute successfully." % self.csar_id)
-
def rollback_distribute(self):
try:
VnfPackageModel.objects.filter(vnfPackageId=self.csar_id).delete()
diff --git a/catalog/packages/ns_package.py b/catalog/packages/ns_package.py
index 32de239d..d22f0a5f 100644
--- a/catalog/packages/ns_package.py
+++ b/catalog/packages/ns_package.py
@@ -86,7 +86,7 @@ def ns_get_csar(csar_id):
def parse_nsd(csar_id, inputs):
- ret= None
+ ret = None
try:
ns_pkg = NSPackageModel.objects.filter(nsPackageId=csar_id)
if not ns_pkg:
diff --git a/catalog/pub/utils/toscaparser/basemodel.py b/catalog/pub/utils/toscaparser/basemodel.py
index 7a453ecd..83938a40 100644
--- a/catalog/pub/utils/toscaparser/basemodel.py
+++ b/catalog/pub/utils/toscaparser/basemodel.py
@@ -39,7 +39,7 @@ class BaseInfoModel(object):
valid_params = self._validate_input_params(file_name, params)
return self._create_tosca_template(file_name, valid_params)
finally:
- if file_name != None and file_name != path and os.path.exists(file_name):
+ if file_name is not None and file_name != path and os.path.exists(file_name):
try:
os.remove(file_name)
except Exception as e:
@@ -66,7 +66,7 @@ class BaseInfoModel(object):
print "-----------------------------"
return tosca_tpl
finally:
- if tosca_tpl != None and hasattr(tosca_tpl, "temp_dir") and os.path.exists(tosca_tpl.temp_dir):
+ if tosca_tpl is not None and hasattr(tosca_tpl, "temp_dir") and os.path.exists(tosca_tpl.temp_dir):
try:
shutil.rmtree(tosca_tpl.temp_dir)
except Exception as e:
@@ -129,10 +129,9 @@ class BaseInfoModel(object):
sftp = paramiko.SFTPClient.from_transport(t)
sftp.get(remoteFileName, localFileName)
finally:
- if t != None:
+ if t is not None:
t.close()
-
def ftp_get(self, userName, userPwd, hostIp, hostPort, remoteFileName, localFileName):
f = None
try:
@@ -143,7 +142,7 @@ class BaseInfoModel(object):
ftp.retrbinary('RETR ' + remoteFileName, f.write, 1024)
f.close()
finally:
- if f != None:
+ if f is not None:
f.close()
def buidMetadata(self, tosca):
@@ -167,7 +166,6 @@ class BaseInfoModel(object):
properties[k] = str(item)
return properties
-
def verify_properties(self, props, inputs, parsed_params):
ret_props = {}
if (props and len(props) > 0):
@@ -199,7 +197,7 @@ class BaseInfoModel(object):
capabilities = json.dumps(nodeTemplate.entity_tpl.get('capabilities', None))
match = re.findall(r'\{"get_input":\s*"([\w|\-]+)"\}',capabilities)
for m in match:
- aa= [input_def for input_def in inputs
+ aa = [input_def for input_def in inputs
if m == input_def.name][0]
capabilities = re.sub(r'\{"get_input":\s*"([\w|\-]+)"\}', json.dumps(aa.default), capabilities,1)
if capabilities != 'null':
@@ -209,7 +207,7 @@ class BaseInfoModel(object):
artifacts = json.dumps(nodeTemplate.entity_tpl.get('artifacts', None))
match = re.findall(r'\{"get_input":\s*"([\w|\-]+)"\}',artifacts)
for m in match:
- aa= [input_def for input_def in inputs
+ aa = [input_def for input_def in inputs
if m == input_def.name][0]
artifacts = re.sub(r'\{"get_input":\s*"([\w|\-]+)"\}', json.dumps(aa.default), artifacts,1)
if artifacts != 'null':
@@ -256,7 +254,6 @@ class BaseInfoModel(object):
def getVirtualbindings(self, node):
return self.getRequirementByName(node, 'virtualbinding')
-
def getRequirementByName(self, node, requirementName):
requirements = []
if 'requirements' in node:
@@ -271,7 +268,7 @@ class BaseInfoModel(object):
if 'requirements' in node:
for item in node['requirements']:
for key, value in item.items():
- if key.upper().find('VIRTUALLINK') >=0:
+ if key.upper().find('VIRTUALLINK') >= 0:
rets.append({"key_name":key, "vl_id":self.get_requirement_node_name(value)})
return rets
diff --git a/catalog/pub/utils/toscaparser/nsdmodel.py b/catalog/pub/utils/toscaparser/nsdmodel.py
index 1080c6c3..6c12ad64 100644
--- a/catalog/pub/utils/toscaparser/nsdmodel.py
+++ b/catalog/pub/utils/toscaparser/nsdmodel.py
@@ -44,7 +44,6 @@ class EtsiNsdInfoModel(BaseInfoModel):
self.ns_flavours = self.get_all_flavour(tosca.topology_template.groups)
self.nested_ns = self.get_all_nested_ns(nodeTemplates)
-
def buildInputs(self, top_inputs):
ret = {}
for tmpinput in top_inputs:
@@ -57,7 +56,7 @@ class EtsiNsdInfoModel(BaseInfoModel):
return ret
def buildNode(self, nodeTemplate, inputs, parsed_params):
- ret ={}
+ ret = {}
ret['name'] = nodeTemplate.name
ret['nodeType'] = nodeTemplate.type
if 'description' in nodeTemplate.entity_tpl:
@@ -70,7 +69,8 @@ class EtsiNsdInfoModel(BaseInfoModel):
self.buildCapabilities(nodeTemplate, inputs, ret)
self.buildArtifacts(nodeTemplate, inputs, ret)
interfaces = self.build_interfaces(nodeTemplate)
- if interfaces: ret['interfaces'] = interfaces
+ if interfaces:
+ ret['interfaces'] = interfaces
return ret
def _get_all_vnf(self, nodeTemplates):
@@ -111,7 +111,7 @@ class EtsiNsdInfoModel(BaseInfoModel):
for key, value in item.items():
if key.upper().startswith('VIRTUALBINDING'):
req_node_name = self.get_requirement_node_name(value)
- if req_node_name != None and req_node_name == node['name']:
+ if req_node_name is not None and req_node_name == node['name']:
cps.append(tmpnode)
return cps
@@ -171,9 +171,9 @@ class EtsiNsdInfoModel(BaseInfoModel):
cp_vl = {}
cp_vl['vl_id'] = self.get_prop_from_obj(req, 'node')
relationship = self.get_prop_from_obj(req, 'relationship')
- if relationship != None:
+ if relationship is not None:
properties = self.get_prop_from_obj(relationship, 'properties')
- if properties != None and isinstance(properties, dict):
+ if properties is not None and isinstance(properties, dict):
for key, value in properties.items():
cp_vl[key] = value
return cp_vl
diff --git a/catalog/pub/utils/toscaparser/vnfdmodel.py b/catalog/pub/utils/toscaparser/vnfdmodel.py
index b4463486..c4d37172 100644
--- a/catalog/pub/utils/toscaparser/vnfdmodel.py
+++ b/catalog/pub/utils/toscaparser/vnfdmodel.py
@@ -47,7 +47,6 @@ class EtsiVnfdInfoModel(EtsiNsdInfoModel):
self.vnf_exposed = self.get_all_endpoint_exposed(tosca.topology_template)
self.vnf_flavours = self.get_all_flavour(tosca.topology_template.groups)
-
def _get_all_services(self, nodeTemplates):
ret = []
for node in nodeTemplates:
@@ -177,13 +176,13 @@ class EtsiVnfdInfoModel(EtsiNsdInfoModel):
ret['dependencies'] = map(lambda x: self.get_requirement_node_name(x), self.getNodeDependencys(node))
nfv_compute = self.getCapabilityByName(node, 'nfv_compute')
- if nfv_compute != None and 'properties' in nfv_compute:
+ if nfv_compute is not None and 'properties' in nfv_compute:
ret['nfv_compute'] = nfv_compute['properties']
ret['vls'] = self.get_linked_vl_ids(node, nodeTemplates)
scalable = self.getCapabilityByName(node, 'scalable')
- if scalable != None and 'properties' in scalable:
+ if scalable is not None and 'properties' in scalable:
ret['scalable'] = scalable['properties']
ret['cps'] = self.getVirtalBindingCpIds(node, nodeTemplates)
diff --git a/tox.ini b/tox.ini
index da52a38b..0bae5c08 100644
--- a/tox.ini
+++ b/tox.ini
@@ -6,7 +6,7 @@ skipsdist = true
downloadcache = ~/cache/pip
[flake8]
-ignore = E501,E231,E128,W291,W293,E711,E303,E701,E225,E303
+ignore = E501,E231,E128,W291,W293
exclude = ./venv-tox,./.tox
[testenv]