def _nova_client(self, token=None): auth = ks_auth.load_from_conf_options(cfg.CONF, SERVICEVM_NOVA_CONF_SECTION) endpoint_override = None if not auth: LOG.warning(_LW('Authenticating to nova using nova_admin_* options' ' is deprecated. This should be done using' ' an auth plugin, like password')) if cfg.CONF.nova_admin_tenant_id: endpoint_override = "%s/%s" % (cfg.CONF.nova_url, cfg.CONF.nova_admin_tenant_id) auth = DefaultAuthPlugin( auth_url=cfg.CONF.nova_admin_auth_url, username=cfg.CONF.nova_admin_username, password=cfg.CONF.nova_admin_password, tenant_id=cfg.CONF.nova_admin_tenant_id, tenant_name=cfg.CONF.nova_admin_tenant_name, endpoint_override=endpoint_override) session = ks_session.Session.load_from_conf_options( cfg.CONF, SERVICEVM_NOVA_CONF_SECTION, auth=auth) novaclient_cls = self._novaclient.get_client_class(NOVA_API_VERSION) return novaclient_cls(session=session, region_name=cfg.CONF.servicevm_nova.region_name)
def _nova_client(self, token=None): auth = ks_auth.load_from_conf_options(cfg.CONF, TACKER_NOVA_CONF_SECTION) endpoint_override = None if not auth: LOG.warning( _LW('Authenticating to nova using nova_admin_* options' ' is deprecated. This should be done using' ' an auth plugin, like password')) if cfg.CONF.nova_admin_tenant_id: endpoint_override = "%s/%s" % (cfg.CONF.nova_url, cfg.CONF.nova_admin_tenant_id) auth = DefaultAuthPlugin( auth_url=cfg.CONF.nova_admin_auth_url, username=cfg.CONF.nova_admin_username, password=cfg.CONF.nova_admin_password, tenant_id=cfg.CONF.nova_admin_tenant_id, tenant_name=cfg.CONF.nova_admin_tenant_name, endpoint_override=endpoint_override) session = ks_session.Session.load_from_conf_options( cfg.CONF, TACKER_NOVA_CONF_SECTION, auth=auth) novaclient_cls = self._novaclient.get_client_class(NOVA_API_VERSION) return novaclient_cls(session=session, region_name=cfg.CONF.tacker_nova.region_name)
def vim_status(self, auth_url): """Checks the VIM health status""" vim_ip = auth_url.split("//")[-1].split(":")[0].split("/")[0] ping_cmd = ['ping', '-c', cfg.CONF.vim_monitor.count, '-W', cfg.CONF.vim_monitor.timeout, '-i', cfg.CONF.vim_monitor.interval, vim_ip] try: linux_utils.execute(ping_cmd, check_exit_code=True) return True except RuntimeError: LOG.warning(_LW("Cannot ping ip address: %s"), vim_ip) return False
def vim_status(self, auth_url): """Checks the VIM health status""" vim_ip = auth_url.split("//")[-1].split(":")[0].split("/")[0] ping_cmd = [ 'ping', '-c', cfg.CONF.vim_monitor.count, '-W', cfg.CONF.vim_monitor.timeout, '-i', cfg.CONF.vim_monitor.interval, vim_ip ] try: linux_utils.execute(ping_cmd, check_exit_code=True) return True except RuntimeError: LOG.warning(_LW("Cannot ping ip address: %s"), vim_ip) return False
def _is_pingable(self, mgmt_ip='', retry=5, timeout=5, port=80, **kwargs): """Checks whether the server is reachable by using urllib. Waits for connectivity for `timeout` seconds, and if connection refused, it will retry `retry` times. :param mgmt_ip: IP to check :param retry: times to reconnect if connection refused :param timeout: seconds to wait for connection :param port: port number to check connectivity :return: bool - True or False depending on pingability. """ url = 'http://' + mgmt_ip + ':' + str(port) for retry_index in range(int(retry)): try: urlreq.urlopen(url, timeout=timeout) return True except urlerr.URLError: LOG.warning(_LW('Unable to reach to the url %s'), url) return 'failure'
def _is_pingable(ip): """Checks whether an IP address is reachable by pinging. Use linux utils to execute the ping (ICMP ECHO) command. Sends 5 packets with an interval of 0.2 seconds and timeout of 1 seconds. Runtime error implies unreachability else IP is pingable. :param ip: IP to check :return: bool - True or False depending on pingability. """ ping_cmd = ['ping', '-c', '5', '-W', '1', '-i', '0.2', ip] try: linux_utils.execute(ping_cmd, check_exit_code=True) return True except RuntimeError: LOG.warning(_LW("Cannot ping ip address: %s"), ip) return False
def _is_pingable(self, mgmt_ip="", count=5, timeout=1, interval='0.2', **kwargs): """Checks whether an IP address is reachable by pinging. Use linux utils to execute the ping (ICMP ECHO) command. Sends 5 packets with an interval of 0.2 seconds and timeout of 1 seconds. Runtime error implies unreachability else IP is pingable. :param ip: IP to check :return: bool - True or string 'failure' depending on pingability. """ ping_cmd = ['ping', '-c', count, '-W', timeout, '-i', interval, mgmt_ip] try: linux_utils.execute(ping_cmd, check_exit_code=True) return True except RuntimeError: LOG.warning(_LW("Cannot ping ip address: %s"), mgmt_ip) return 'failure'