X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=osm_mon%2Fcollector%2Finfra_collectors%2Fopenstack.py;h=577bf06cdc9c11ce6c1bb99a73664ffac6890724;hb=918706d5a1c39dbb3edaf8e3cb1ef336fdb644dd;hp=5f62edf340f33a7df8d46be8535470da20d826b1;hpb=5ac7c081ca13495185ecf6bdf302c16c25a4b759;p=osm%2FMON.git diff --git a/osm_mon/collector/infra_collectors/openstack.py b/osm_mon/collector/infra_collectors/openstack.py index 5f62edf..577bf06 100644 --- a/osm_mon/collector/infra_collectors/openstack.py +++ b/osm_mon/collector/infra_collectors/openstack.py @@ -19,41 +19,12 @@ # For those usages not covered by the Apache License, Version 2.0 please # contact: bdiaz@whitestack.com or glavado@whitestack.com ## -import logging -from keystoneauth1 import session -from keystoneauth1.identity import v3 -from keystoneclient.v3 import client +from osm_mon.collector.infra_collectors.base_osinfra import BaseOpenStackInfraCollector -from osm_mon.collector.infra_collectors.base_vim import BaseVimInfraCollector -from osm_mon.core.auth import AuthManager from osm_mon.core.config import Config -log = logging.getLogger(__name__) - -class OpenstackInfraCollector(BaseVimInfraCollector): +class OpenstackInfraCollector(BaseOpenStackInfraCollector): def __init__(self, config: Config, vim_account_id: str): - super().__init__(config, vim_account_id) - self.auth_manager = AuthManager(config) - self.keystone_client = self._build_keystone_client(vim_account_id) - - def is_vim_ok(self) -> bool: - try: - self.keystone_client.projects.list() - return True - except Exception: - log.exception("VIM status is not OK!") - return False - - def _build_keystone_client(self, vim_account_id): - creds = self.auth_manager.get_credentials(vim_account_id) - verify_ssl = self.auth_manager.is_verify_ssl(vim_account_id) - auth = v3.Password(auth_url=creds.url, - username=creds.user, - password=creds.password, - project_name=creds.tenant_name, - project_domain_id='default', - user_domain_id='default') - sess = session.Session(auth=auth, verify=verify_ssl) - return client.Client(session=sess) + super(OpenstackInfraCollector, self).__init__(config, vim_account_id)