def _run_task(self, task, nodes): ips = nodes.get_ips() if not ips: raise error.ServiceError('Node collection is empty') results = self.cloud_management.execute_on_cloud(ips, task) err = False for result in results: if result.status != executor.STATUS_OK: LOG.error('Task {} failed on node {}'.format( task, result.host)) err = True if err: raise error.ServiceError('Task failed on some nodes') return results
def _run_task(self, nodes, task, message): nodes = nodes if nodes is not None else self.get_nodes() if len(nodes) == 0: raise error.ServiceError( 'Service %s is not found on any nodes' % self.service_name) LOG.info('%s service %s on nodes: %s', message, self.service_name, nodes.get_ips()) return self.cloud_management.execute_on_cloud(nodes.hosts, task)
def get_service(self, name): """Get service with specified name :param name: name of the serives :return: Service """ if name in self.SERVICE_NAME_TO_CLASS: klazz = self.SERVICE_NAME_TO_CLASS[name] return klazz(node_cls=self.NODE_CLS, cloud_management=self, power_management=self.power_management) raise error.ServiceError( '{} driver does not support {!r} service'.format( self.NAME.title(), name))
def get_service(self, name): """Get service with specified name :param name: name of the service :return: Service """ if name not in self.services: raise error.ServiceError( '{} driver does not support {!r} service'.format( self.NAME.title(), name)) config = self.services[name] klazz = registry.get_driver(config["driver"]) return klazz(node_cls=self.NODE_CLS, cloud_management=self, service_name=name, config=config["args"], hosts=config.get('hosts'))
def _run_task(self, task, nodes): if len(nodes) == 0: raise error.ServiceError('Node collection is empty') return self.cloud_management.execute_on_cloud(nodes.hosts, task)