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
# 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,
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"])
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"])
application_name=application_name,
model_name=model_name,
machine_id=machine_id,
- db_dict=db_dict,
total_timeout=total_timeout,
)
else:
"""
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
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)