"""
Return the file content of a vnfd or nsd
:param session: contains the used login username and working project
- :param _id: Identity of the vnfd, ndsd
+ :param _id: Identity of the vnfd, nsd
:param path: artifact path or "$DESCRIPTOR" or None
:param accept_header: Content of Accept header. Must contain applition/zip or/and text/plain
- :return: opened file or raises an exception
+ :return: opened file plus Accept format or raises an exception
"""
accept_text = accept_zip = False
if accept_header:
if 'text/plain' in accept_header or '*/*' in accept_header:
accept_text = True
if 'application/zip' in accept_header or '*/*' in accept_header:
- accept_zip = True
+ accept_zip = 'application/zip'
+ elif 'application/gzip' in accept_header:
+ accept_zip = 'application/gzip'
+
if not accept_text and not accept_zip:
raise EngineException("provide request header 'Accept' with 'application/zip' or 'text/plain'",
http_code=HTTPStatus.NOT_ACCEPTABLE)
# TODO generate zipfile if not present
raise EngineException("Only allowed 'text/plain' Accept header for this descriptor. To be solved in "
"future versions", http_code=HTTPStatus.NOT_ACCEPTABLE)
- return self.fs.file_open((storage['folder'], storage['zipfile']), "rb"), "application/zip"
+ return self.fs.file_open((storage['folder'], storage['zipfile']), "rb"), accept_zip
class VnfdTopic(DescriptorTopic):
raise EngineException("Unknown topic {}!!!".format(topic), HTTPStatus.INTERNAL_SERVER_ERROR)
return self.map_topic[topic].show(session, _id)
+ def get_file(self, session, topic, _id, path=None, accept_header=None):
+ """
+ Get descriptor package or artifact file content
+ :param session: contains the used login username and working project
+ :param topic: it can be: users, projects, vnfds, nsds,
+ :param _id: server id of the item
+ :param path: artifact path or "$DESCRIPTOR" or None
+ :param accept_header: Content of Accept header. Must contain applition/zip or/and text/plain
+ :return: opened file plus Accept format or raises an exception
+ """
+ if topic not in self.map_topic:
+ raise EngineException("Unknown topic {}!!!".format(topic), HTTPStatus.INTERNAL_SERVER_ERROR)
+ return self.map_topic[topic].get_file(session, _id, path, accept_header)
+
def del_item_list(self, session, topic, _filter=None):
"""
Delete a list of items
-0.1.21
-2018-10-09
+0.1.22
+2018-10-24
print("RX {}: {}".format(r.status_code, r.text))
if "id" in response:
print("---\nid: {}".format(response["id"]))
- except Exception as e:
+ except Exception:
raise
# Basis schemas
patern_name = "^[ -~]+$"
-nameshort_schema = {"type": "string", "minLength": 1, "maxLength": 60, "pattern": "^[^,;()\.\$'\"]+$"}
+nameshort_schema = {"type": "string", "minLength": 1, "maxLength": 60, "pattern": "^[^,;()\\.\\$'\"]+$"}
passwd_schema = {"type": "string", "minLength": 1, "maxLength": 60}
name_schema = {"type": "string", "minLength": 1, "maxLength": 255, "pattern": "^[^,;()'\"]+$"}
string_schema = {"type": "string", "minLength": 1, "maxLength": 255}
# "pattern": "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$"
id_schema = {"type": "string", "pattern": "^[a-fA-F0-9]{8}(-[a-fA-F0-9]{4}){3}-[a-fA-F0-9]{12}$"}
time_schema = {"type": "string", "pattern": "^[0-9]{4}-[0-1][0-9]-[0-3][0-9]T[0-2][0-9]([0-5]:){2}"}
-pci_schema = {"type": "string", "pattern": "^[0-9a-fA-F]{4}(:[0-9a-fA-F]{2}){2}\.[0-9a-fA-F]$"}
+pci_schema = {"type": "string", "pattern": "^[0-9a-fA-F]{4}(:[0-9a-fA-F]{2}){2}\\.[0-9a-fA-F]$"}
http_schema = {"type": "string", "pattern": "^https?://[^'\"=]+$"}
bandwidth_schema = {"type": "string", "pattern": "^[0-9]+ *([MG]bps)?$"}
memory_schema = {"type": "string", "pattern": "^[0-9]+ *([MG]i?[Bb])?$"}
integer0_schema = {"type": "integer", "minimum": 0}
integer1_schema = {"type": "integer", "minimum": 1}
-path_schema = {"type": "string", "pattern": "^(\.){0,2}(/[^/\"':{}\(\)]+)+$"}
+path_schema = {"type": "string", "pattern": "^(\\.){0,2}(/[^/\"':{}\\(\\)]+)+$"}
vlan_schema = {"type": "integer", "minimum": 1, "maximum": 4095}
vlan1000_schema = {"type": "integer", "minimum": 1000, "maximum": 4095}
mac_schema = {"type": "string",
dpid_Schema = {"type": "string", "pattern": "^[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){7}$"}
# mac_schema={"type":"string", "pattern":"^([0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2}$"}
ip_schema = {"type": "string",
- "pattern": "^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$"}
+ "pattern": "^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$"}
ip_prefix_schema = {"type": "string",
- "pattern": "^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}"
+ "pattern": "^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}"
"(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)/(30|[12]?[0-9])$"}
port_schema = {"type": "integer", "minimum": 1, "maximum": 65534}
object_schema = {"type": "object"}
array_edition_schema = {
"type": "object",
"patternProperties": {
- "^\$": "Any"
+ "^\\$": "Any"
},
"additionalProperties": False,
"minProperties": 1,
basepython = python3
deps = flake8
commands = flake8 osm_nbi/ setup.py --max-line-length 120 \
- --exclude .svn,CVS,.gz,.git,__pycache__,.tox,local,temp,vnfd_catalog.py,nsd_catalog.py --ignore W291,W293,E226,E402
+ --exclude .svn,CVS,.gz,.git,__pycache__,.tox,local,temp,vnfd_catalog.py,nsd_catalog.py --ignore W291,W293,E226,E402,W504
[testenv:build]
basepython = python3