def _get_runtime_properties(self): client = utils.get_rest_client(rest_host=self.rest_host, rest_port=self.rest_port, rest_token=self._rest_token, rest_tenant=self._rest_tenant, ssl_cert_path=self.local_rest_cert_file) node_instances = client.node_instances.list( deployment_id=self.deployment_id) def match_ip(node_instance): host_id = node_instance.host_id if host_id == node_instance.id: # compute node instance return self.host == node_instance.runtime_properties['ip'] return False matched = filter(match_ip, node_instances) if len(matched) > 1: raise exceptions.DaemonConfigurationError( 'Found multiple node instances with ip {0}: {1}'.format( self.host, ','.join(matched))) if len(matched) == 0: raise exceptions.DaemonConfigurationError( 'No node instances with ip {0} were found'.format(self.host)) self._runtime_properties = matched[0].runtime_propreties
def distro(self): if not self._distro: if self._runner.run('which dpkg', exit_on_failure=False).return_code == 0: self._distro = 'debian' elif self._runner.run('which rpm', exit_on_failure=False).return_code == 0: self._distro = 'rpm' else: raise exceptions.DaemonConfigurationError( "Cannot create a start-on-boot entry. Unknown " "distribution base. Supported distributions bases are " "debian and RPM") return self._distro
def _get_runtime_properties(self): client = utils.get_rest_client(rest_host=self.rest_host, rest_port=self.rest_port, rest_token=self._rest_token, rest_tenant=self._rest_tenant, ssl_cert_path=self.local_rest_cert_file) node_instances = client.node_instances.list( deployment_id=self.deployment_id, _get_all_results=True) matched = [ ni for ni in node_instances if ni.host_id == ni.id and self.host == ni.runtime_properties['ip'] ] if len(matched) > 1: raise exceptions.DaemonConfigurationError( 'Found multiple node instances with ip {0}: {1}'.format( self.host, ','.join(matched))) if len(matched) == 0: raise exceptions.DaemonConfigurationError( 'No node instances with ip {0} were found'.format(self.host)) self._runtime_properties = matched[0].runtime_propreties