projects
/
osm
/
N2VC.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix bug 2018: Skip exception if model has been removed
[osm/N2VC.git]
/
n2vc
/
n2vc_juju_conn.py
diff --git
a/n2vc/n2vc_juju_conn.py
b/n2vc/n2vc_juju_conn.py
index
2c94328
..
3f6a501
100644
(file)
--- a/
n2vc/n2vc_juju_conn.py
+++ b/
n2vc/n2vc_juju_conn.py
@@
-38,6
+38,7
@@
from n2vc.n2vc_conn import N2VCConnector
from n2vc.n2vc_conn import obj_to_dict, obj_to_yaml
from n2vc.libjuju import Libjuju
from n2vc.store import MotorStore
from n2vc.n2vc_conn import obj_to_dict, obj_to_yaml
from n2vc.libjuju import Libjuju
from n2vc.store import MotorStore
+from n2vc.utils import generate_random_alfanum_string
from n2vc.vca.connection import get_connection
from retrying_async import retry
from n2vc.vca.connection import get_connection
from retrying_async import retry
@@
-369,7
+370,7
@@
class N2VCJujuConnector(N2VCConnector):
# In case of native_charm is being deployed, if JujuApplicationExists error happens
# it will try to add_unit
# In case of native_charm is being deployed, if JujuApplicationExists error happens
# it will try to add_unit
- @retry(attempts=3, delay=5, retry_exceptions=(N2VCApplicationExists,))
+ @retry(attempts=3, delay=5, retry_exceptions=(N2VCApplicationExists,)
, timeout=None
)
async def install_configuration_sw(
self,
ee_id: str,
async def install_configuration_sw(
self,
ee_id: str,
@@
-453,7
+454,7
@@
class N2VCJujuConnector(N2VCConnector):
artifact_path = artifact_path.replace("//", "/")
# check charm path
artifact_path = artifact_path.replace("//", "/")
# check charm path
- if not self.fs.file_exists(artifact_path
, mode="dir"
):
+ if not self.fs.file_exists(artifact_path):
msg = "artifact path does not exist: {}".format(artifact_path)
raise N2VCBadArgumentsException(message=msg, bad_args=["artifact_path"])
msg = "artifact path does not exist: {}".format(artifact_path)
raise N2VCBadArgumentsException(message=msg, bad_args=["artifact_path"])
@@
-550,7
+551,7
@@
class N2VCJujuConnector(N2VCConnector):
artifact_path = artifact_path.replace("//", "/")
# check charm path
artifact_path = artifact_path.replace("//", "/")
# check charm path
- if not self.fs.file_exists(artifact_path
, mode="dir"
):
+ if not self.fs.file_exists(artifact_path):
msg = "artifact path does not exist: {}".format(artifact_path)
raise N2VCBadArgumentsException(message=msg, bad_args=["artifact_path"])
msg = "artifact path does not exist: {}".format(artifact_path)
raise N2VCBadArgumentsException(message=msg, bad_args=["artifact_path"])
@@
-886,7
+887,6
@@
class N2VCJujuConnector(N2VCConnector):
application_name=application_name,
model_name=model_name,
machine_id=machine_id,
application_name=application_name,
model_name=model_name,
machine_id=machine_id,
- db_dict=db_dict,
total_timeout=total_timeout,
)
else:
total_timeout=total_timeout,
)
else:
@@
-1168,7
+1168,7
@@
class N2VCJujuConnector(N2VCConnector):
"""
Build application name from namespace
:param namespace:
"""
Build application name from namespace
:param namespace:
- :return: app-vnf-<vnf id>-vdu-<vdu-id>-cnt-<vdu-count>
+ :return: app-vnf-<vnf id>-vdu-<vdu-id>-cnt-<vdu-count>
-<random_value>
"""
# TODO: Enforce the Juju 50-character application limit
"""
# TODO: Enforce the Juju 50-character application limit
@@
-1195,7
+1195,12
@@
class N2VCJujuConnector(N2VCConnector):
else:
vdu_count = "-cnt-" + vdu_count
else:
vdu_count = "-cnt-" + vdu_count
- application_name = "app-{}{}{}".format(vnf_id, vdu_id, vdu_count)
+ # Generate a random suffix with 5 characters (the default size used by K8s)
+ random_suffix = generate_random_alfanum_string(size=5)
+
+ application_name = "app-{}{}{}-{}".format(
+ vnf_id, vdu_id, vdu_count, random_suffix
+ )
return N2VCJujuConnector._format_app_name(application_name)
return N2VCJujuConnector._format_app_name(application_name)