X-Git-Url: https://osm.etsi.org/gitweb/?p=osm%2FN2VC.git;a=blobdiff_plain;f=n2vc%2Flibjuju.py;h=d761adc6bbd48ae1e82d4d073ff68393631487c6;hp=12730fde98bb795d51de9011fde8c066f1062e57;hb=85755d17a807df83d0e472e6e73500a4d743296b;hpb=12b29244e5d333341166ea92760b8eb245c16b27 diff --git a/n2vc/libjuju.py b/n2vc/libjuju.py index 12730fd..d761adc 100644 --- a/n2vc/libjuju.py +++ b/n2vc/libjuju.py @@ -711,6 +711,26 @@ class Libjuju: await self.disconnect_model(model) await self.disconnect_controller(controller) + async def get_metrics(self, model_name: str, application_name: str) -> dict: + """Get the metrics collected by the VCA. + + :param model_name The name or unique id of the network service + :param application_name The name of the application + """ + if not model_name or not application_name: + raise Exception("model_name and application_name must be non-empty strings") + metrics = {} + controller = await self.get_controller() + model = await self.get_model(controller, model_name) + try: + application = self._get_application(model, application_name) + if application is not None: + metrics = await application.get_metrics() + finally: + self.disconnect_model(model) + self.disconnect_controller(controller) + return metrics + async def add_relation( self, model_name: str, endpoint_1: str, endpoint_2: str, ):