def mock_get_nodes(self): return [ Node({ 'id': 'mock_node', 'type_hierarchy': 'cloudify.nodes.CloudifyManager' }) ]
def list_nodes(**kwargs): node_ids = kwargs.get('id') all_node_instances = _topology_filter(lambda x: True, **kwargs) nodes = {(x['tenant_name'], x['deployment_id'], x['node_id']) for x in all_node_instances} nodes = [Node({'id': c, 'deployment_id': b, 'tenant_name': a}) for (a, b, c) in nodes] return list(filter( lambda x: (node_ids is None) or x['id'] in node_ids, nodes))
def _make_node(self, **kwargs): node = { 'id': 'node1', 'relationships': [], 'operations': {}, 'id': 'node1', 'type_hierarchy': [] } node.update(kwargs) return Node(node)
def _parse_plan(blueprint_path, inputs, ignored_modules): if dsl_parser is None: raise ImportError('cloudify-dsl-parser must be installed to ' 'execute local workflows. ' '(e.g. "pip install cloudify-dsl-parser")') plan = dsl_tasks.prepare_deployment_plan( dsl_parser.parse_from_path(blueprint_path), inputs=inputs) nodes = [Node(node) for node in plan['nodes']] node_instances = [ NodeInstance(instance) for instance in plan['node_instances'] ] _prepare_nodes_and_instances(nodes, node_instances, ignored_modules) return plan, nodes, node_instances
def node_get_mock(): return Node({ 'id': uuid4(), 'deployment_id': 'deployment-id', 'blueprint_id': 'blueprint_id', 'host_id': 'host_id', 'type': 'Compute', 'number_of_instances': '1', 'planned_number_of_instances': '2', 'properties': { 'port': '8080' } })
def load(self, name): self.name = name self._storage_dir = os.path.join(self._root_storage_dir, name) self._instances_dir = os.path.join(self._storage_dir, 'node-instances') self._payload_path = os.path.join(self._storage_dir, 'payload') self._data_path = os.path.join(self._storage_dir, 'data') with open(self._data_path) as f: data = json.loads(f.read()) self.plan = data['plan'] self.resources_root = os.path.join(self._storage_dir, 'resources') self._blueprint_path = os.path.join(self.resources_root, data['blueprint_filename']) nodes = [Node(node) for node in data['nodes']] self._init_locks_and_nodes(nodes)
def node_get_mock(): return Node({ 'id': uuid4(), 'deployment_id': 'deployment-id', 'blueprint_id': 'blueprint_id', 'host_id': 'host_id', 'type': 'Compute', 'number_of_instances': '1', 'planned_number_of_instances': '2', 'properties': { 'port': '8080' }, 'permission': 'creator', 'created_by': 'admin', 'tenant_name': DEFAULT_TENANT_NAME })
def _parse_plan(blueprint_path, inputs, ignored_modules, resolver, validate_version): if dsl_parser is None: raise ImportError('cloudify-dsl-parser must be installed to ' 'execute local workflows. ' '(e.g. "pip install cloudify-dsl-parser") [{0}]' .format(_import_error)) plan = dsl_tasks.prepare_deployment_plan( dsl_parser.parse_from_path( dsl_file_path=blueprint_path, resolver=resolver, validate_version=validate_version), inputs=inputs) nodes = [Node(node) for node in plan['nodes']] node_instances = [NodeInstance(instance) for instance in plan['node_instances']] _prepare_nodes_and_instances(nodes, node_instances, ignored_modules) return plan, nodes, node_instances
def node_get_mock(): return Node({ 'id': uuid4(), 'deployment_id': 'deployment-id', 'blueprint_id': 'blueprint_id', 'host_id': 'host_id', 'type': 'Compute', 'type_hierarchy': ['cloudify.nodes.Root', 'Compute'], 'number_of_instances': '1', 'planned_number_of_instances': '2', 'properties': { 'port': '8080' }, 'operations': {}, 'visibility': 'private', 'created_by': 'admin', 'tenant_name': DEFAULT_TENANT_NAME })
def load(self, name): self.name = name self._storage_dir = os.path.join(self._root_storage_dir, name) self._workdir = os.path.join(self._storage_dir, 'workdir') self._instances_dir = os.path.join(self._storage_dir, 'node-instances') self._payload_path = os.path.join(self._storage_dir, 'payload') self._executions_path = os.path.join(self._storage_dir, 'executions') self._data_path = os.path.join(self._storage_dir, 'data') with open(self._data_path) as f: data = json.loads(f.read(), object_hook=load_datetime) self.plan = data['plan'] self.resources_root = os.path.join(self._storage_dir, 'resources') self._blueprint_path = os.path.join(self.resources_root, data['blueprint_filename']) self._provider_context = data.get('provider_context', {}) self.created_at = data.get('created_at') nodes = [Node(node) for node in data['nodes']] self._init_locks_and_nodes(nodes)
def get_nodes(self, deployment_id): return { node_id: Node(n) for node_id, n in self.get_deployment(deployment_id) ['nodes'].items() }
def load_node(self, deployment_id, node_id): dep = self.get_deployment(deployment_id) return Node(dep['nodes'][node_id])