projects
/
osm
/
LCM.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Bug 1890: Improve Action Execution
[osm/LCM.git]
/
osm_lcm
/
ns.py
diff --git
a/osm_lcm/ns.py
b/osm_lcm/ns.py
index
ae151db
..
6cb46e1
100644
(file)
--- a/
osm_lcm/ns.py
+++ b/
osm_lcm/ns.py
@@
-30,6
+30,7
@@
from jinja2 import (
TemplateNotFound,
StrictUndefined,
UndefinedError,
TemplateNotFound,
StrictUndefined,
UndefinedError,
+ select_autoescape,
)
from osm_lcm import ROclient
)
from osm_lcm import ROclient
@@
-414,7
+415,10
@@
class NsLcm(LcmBase):
@staticmethod
def _parse_cloud_init(cloud_init_text, additional_params, vnfd_id, vdu_id):
try:
@staticmethod
def _parse_cloud_init(cloud_init_text, additional_params, vnfd_id, vdu_id):
try:
- env = Environment(undefined=StrictUndefined, autoescape=True)
+ env = Environment(
+ undefined=StrictUndefined,
+ autoescape=select_autoescape(default_for_string=True, default=True),
+ )
template = env.from_string(cloud_init_text)
return template.render(additional_params or {})
except UndefinedError as e:
template = env.from_string(cloud_init_text)
return template.render(additional_params or {})
except UndefinedError as e:
@@
-3731,10
+3735,16
@@
class NsLcm(LcmBase):
self.logger.debug(
logging_text + "_deploy_n2vc vnfd_id={}, vdu_id={}".format(vnfd_id, vdu_id)
)
self.logger.debug(
logging_text + "_deploy_n2vc vnfd_id={}, vdu_id={}".format(vnfd_id, vdu_id)
)
+
+ charm_name = ""
+ get_charm_name = False
if "execution-environment-list" in descriptor_config:
ee_list = descriptor_config.get("execution-environment-list", [])
elif "juju" in descriptor_config:
ee_list = [descriptor_config] # ns charms
if "execution-environment-list" in descriptor_config:
ee_list = descriptor_config.get("execution-environment-list", [])
elif "juju" in descriptor_config:
ee_list = [descriptor_config] # ns charms
+ if "execution-environment-list" not in descriptor_config:
+ # charm name is only required for ns charms
+ get_charm_name = True
else: # other types as script are not supported
ee_list = []
else: # other types as script are not supported
ee_list = []
@@
-3748,6
+3758,8
@@
class NsLcm(LcmBase):
ee_descriptor_id = ee_item.get("id")
if ee_item.get("juju"):
vca_name = ee_item["juju"].get("charm")
ee_descriptor_id = ee_item.get("id")
if ee_item.get("juju"):
vca_name = ee_item["juju"].get("charm")
+ if get_charm_name:
+ charm_name = self.find_charm_name(db_nsr, str(vca_name))
vca_type = (
"lxc_proxy_charm"
if ee_item["juju"].get("charm") is not None
vca_type = (
"lxc_proxy_charm"
if ee_item["juju"].get("charm") is not None
@@
-3806,6
+3818,7
@@
class NsLcm(LcmBase):
"vdu_name": vdu_name,
"type": vca_type,
"ee_descriptor_id": ee_descriptor_id,
"vdu_name": vdu_name,
"type": vca_type,
"ee_descriptor_id": ee_descriptor_id,
+ "charm_name": charm_name,
}
vca_index += 1
}
vca_index += 1
@@
-4977,9
+4990,7
@@
class NsLcm(LcmBase):
break
except asyncio.CancelledError:
raise
break
except asyncio.CancelledError:
raise
- except Exception as e: # asyncio.TimeoutError
- if isinstance(e, asyncio.TimeoutError):
- e = "Timeout"
+ except Exception as e:
retries -= 1
if retries >= 0:
self.logger.debug(
retries -= 1
if retries >= 0:
self.logger.debug(
@@
-4990,7
+5001,9
@@
class NsLcm(LcmBase):
# wait and retry
await asyncio.sleep(retries_interval, loop=self.loop)
else:
# wait and retry
await asyncio.sleep(retries_interval, loop=self.loop)
else:
- return "FAILED", str(e)
+ if isinstance(e, asyncio.TimeoutError):
+ e = N2VCException(message="Timed out waiting for action to complete")
+ return "FAILED", getattr(e, 'message', repr(e))
return "COMPLETED", output
return "COMPLETED", output
@@
-5325,7
+5338,7
@@
class NsLcm(LcmBase):
)
self.logger.debug(
logging_text
)
self.logger.debug(
logging_text
- + "
task
Done with result {} {}".format(
+ + "Done with result {} {}".format(
nslcmop_operation_state, detailed_status
)
)
nslcmop_operation_state, detailed_status
)
)
@@
-7828,10
+7841,16
@@
class NsLcm(LcmBase):
self.logger.debug(
logging_text + "_deploy_n2vc vnfd_id={}, vdu_id={}".format(vnfd_id, vdu_id)
)
self.logger.debug(
logging_text + "_deploy_n2vc vnfd_id={}, vdu_id={}".format(vnfd_id, vdu_id)
)
+
+ charm_name = ""
+ get_charm_name = False
if "execution-environment-list" in descriptor_config:
ee_list = descriptor_config.get("execution-environment-list", [])
elif "juju" in descriptor_config:
ee_list = [descriptor_config] # ns charms
if "execution-environment-list" in descriptor_config:
ee_list = descriptor_config.get("execution-environment-list", [])
elif "juju" in descriptor_config:
ee_list = [descriptor_config] # ns charms
+ if "execution-environment-list" not in descriptor_config:
+ # charm name is only required for ns charms
+ get_charm_name = True
else: # other types as script are not supported
ee_list = []
else: # other types as script are not supported
ee_list = []
@@
-7845,6
+7864,8
@@
class NsLcm(LcmBase):
ee_descriptor_id = ee_item.get("id")
if ee_item.get("juju"):
vca_name = ee_item["juju"].get("charm")
ee_descriptor_id = ee_item.get("id")
if ee_item.get("juju"):
vca_name = ee_item["juju"].get("charm")
+ if get_charm_name:
+ charm_name = self.find_charm_name(db_nsr, str(vca_name))
vca_type = (
"lxc_proxy_charm"
if ee_item["juju"].get("charm") is not None
vca_type = (
"lxc_proxy_charm"
if ee_item["juju"].get("charm") is not None
@@
-7903,6
+7924,7
@@
class NsLcm(LcmBase):
"vdu_name": vdu_name,
"type": vca_type,
"ee_descriptor_id": ee_descriptor_id,
"vdu_name": vdu_name,
"type": vca_type,
"ee_descriptor_id": ee_descriptor_id,
+ "charm_name": charm_name,
}
vca_index += 1
}
vca_index += 1