def load(self, need_details=False): try: if 'source' in self.config: yaml_config = YamlConfig(source=self.config['source'], app_name=self.name, path=self.config['path'], env=self.get_env()) elif 'path' in self.config: yaml_config = YamlConfig(file=os.path.join( self.config['path'], 'mcloud.yml'), app_name=self.name, path=self.config['path']) else: self.error = {'msg': 'Can not parse config'} defer.returnValue(None) deployment = yield self.get_deployment() if not deployment: self.error = {'msg': 'No deployment found'} else: client = deployment.get_client() yield yaml_config.load(client=client) yield defer.gatherResults([ service.inspect() for service in yaml_config.get_services().values() ]) if need_details: defer.returnValue(self._details(yaml_config, deployment)) else: defer.returnValue(yaml_config) except (ValueError, DeploymentDoesNotExist) as e: config_ = { 'name': self.name, 'config': self.config, 'services': [], 'running': False, 'status': 'error', 'message': '%s When loading config: %s' % (e.message, self.config) } defer.returnValue(config_)
def load(self, need_details=False): try: if 'source' in self.config: yaml_config = YamlConfig(source=self.config['source'], app_name=self.name, path=self.config['path'], env=self.get_env()) elif 'path' in self.config: yaml_config = YamlConfig(file=os.path.join(self.config['path'], 'mcloud.yml'), app_name=self.name, path=self.config['path']) else: self.error = { 'msg': 'Can not parse config' } defer.returnValue(None) deployment = yield self.get_deployment() if not deployment: self.error = { 'msg': 'No deployment found' } else: client = deployment.get_client() yield yaml_config.load(client=client) yield defer.gatherResults([service.inspect() for service in yaml_config.get_services().values()]) if need_details: defer.returnValue(self._details(yaml_config, deployment)) else: defer.returnValue(yaml_config) except (ValueError, DeploymentDoesNotExist) as e: config_ = {'name': self.name, 'config': self.config, 'services': [], 'running': False, 'status': 'error', 'message': '%s When loading config: %s' % (e.message, self.config)} defer.returnValue(config_)