X-Git-Url: https://osm.etsi.org/gitweb/?p=osm%2FN2VC.git;a=blobdiff_plain;f=n2vc%2Fk8s_conn.py;h=b1f3230c07ba36724bd6aa236679105f32362454;hp=4fdaee8df0686052ecd882ed2d738cf56245bdb2;hb=fc796cc98009d16e124dd47c0596c5541dc10f4d;hpb=54771fa2e857c92aa8454e80389ee7461e4a9773 diff --git a/n2vc/k8s_conn.py b/n2vc/k8s_conn.py index 4fdaee8..b1f3230 100644 --- a/n2vc/k8s_conn.py +++ b/n2vc/k8s_conn.py @@ -50,13 +50,13 @@ class K8sConnector(abc.ABC, Loggable): # parent class Loggable.__init__(self, log=log, log_to_console=True, prefix='\nK8S') - self.info('Initializing generic K8S connector') + # self.log.info('Initializing generic K8S connector') # the database and update callback self.db = db self.on_update_db = on_update_db - self.info('K8S generic connector initialized') + # self.log.info('K8S generic connector initialized') @abc.abstractmethod async def init_env( @@ -122,6 +122,20 @@ class K8sConnector(abc.ABC, Loggable): :return: True if successful """ + @abc.abstractmethod + async def synchronize_repos( + self, + cluster_uuid: str, + name: str + ): + """ + Synchronizes the list of repositories created in the cluster with + the repositories added by the NBI + + :param cluster_uuid: the cluster + :return: List of repositories deleted from the cluster and dictionary with repos added + """ + @abc.abstractmethod async def reset( self, @@ -147,7 +161,9 @@ class K8sConnector(abc.ABC, Loggable): atomic: bool = True, timeout: float = 300, params: dict = None, - db_dict: dict = None + db_dict: dict = None, + kdu_name: str = None, + namespace: str = None ): """ Deploys of a new KDU instance. It would implicitly rely on the `install` call to deploy the Chart/Bundle @@ -167,6 +183,8 @@ class K8sConnector(abc.ABC, Loggable): :param dict db_dict: where to write into database when the status changes. It contains a dict with {collection: , filter: {}, path: }, e.g. {collection: "nsrs", filter: {_id: , path: "_admin.deployed.K8S.3"} + :param kdu_name: Name of the KDU instance to be installed + :param namespace: K8s namespace to use for the KDU instance :return: True if successful """ @@ -235,6 +253,28 @@ class K8sConnector(abc.ABC, Loggable): :return: True if successful """ + @abc.abstractmethod + async def exec_primitive( + self, + cluster_uuid: str = None, + kdu_instance: str = None, + primitive_name: str = None, + timeout: float = 300, + params: dict = None, + db_dict: dict = None, + ) -> str: + """Exec primitive (Juju action) + + :param cluster_uuid str: The UUID of the cluster + :param kdu_instance str: The unique name of the KDU instance + :param primitive_name: Name of action that will be executed + :param timeout: Timeout for action execution + :param params: Dictionary of all the parameters needed for the action + :db_dict: Dictionary for any additional data + + :return: Returns the output of the action + """ + @abc.abstractmethod async def inspect_kdu( self, @@ -317,7 +357,7 @@ class K8sConnector(abc.ABC, Loggable): self.warning('No db_dict => No database write') return False - self.debug('status={}'.format(status)) + self.log.debug('status={}'.format(status)) try: @@ -350,5 +390,5 @@ class K8sConnector(abc.ABC, Loggable): return True except Exception as e: - self.info('Exception writing status to database: {}'.format(e)) + self.log.info('Exception writing status to database: {}'.format(e)) return False