Exemplo n.º 1
0
def create_node_template(service_template,
                         name=NODE_TEMPLATE_NAME,
                         type=models.Type(variant='node',
                                          name='test_node_type'),
                         capability_templates=None,
                         requirement_templates=None,
                         interface_templates=None,
                         default_instances=1,
                         min_instances=1,
                         max_instances=1):
    capability_templates = capability_templates or {}
    requirement_templates = requirement_templates or []
    interface_templates = interface_templates or {}
    node_template = models.NodeTemplate(
        name=name,
        type=type,
        capability_templates=capability_templates,
        requirement_templates=requirement_templates,
        interface_templates=interface_templates,
        default_instances=default_instances,
        min_instances=min_instances,
        max_instances=max_instances,
        service_template=service_template)

    service_template.node_templates[node_template.name] = node_template
    return node_template
    def test_node_instance_operation(self, executor, workflow_context):
        node_template = self._get_node_template(workflow_context)
        node_type = 'aria.plugin.nodes.App'
        node_instance_property = models.Property.wrap('hello', 'world')
        node_template.type = models.Type(variant='variant', name=node_type)
        node = self._get_node(workflow_context)
        node_instance_attribute = models.Attribute.wrap('hello2', 'world2')
        node.attributes[node_instance_attribute.name] = node_instance_attribute
        node.properties[node_instance_property.name] = node_instance_property
        workflow_context.model.node.update(node)
        workflow_context.model.node_template.update(node_template)

        out = self._run(executor, workflow_context,
                        _test_node_instance_operation)

        node_template = self._get_node_template(workflow_context)
        node = self._get_node(workflow_context)
        assert out['type'] == context_adapter.NODE_INSTANCE
        assert out['node']['id'] == node_template.id
        assert out['node']['name'] == node_template.name
        assert out['node']['properties'] == \
               {node_instance_property.name: node_instance_property.value}
        assert out['node']['type'] == node_type
        assert out['node']['type_hierarchy'] == ['cloudify.plugin.nodes.App']
        assert out['instance']['id'] == node.id
        assert out['instance']['runtime_properties'] == \
               {node_instance_attribute.name: node_instance_attribute.value}
        assert not out['source']
        assert not out['target']
Exemplo n.º 3
0
    def test_node_instance_relationships(self, executor, workflow_context):
        relationship_node_template = self._get_dependency_node_template(workflow_context)
        relationship_node_instance = self._get_dependency_node(workflow_context)
        relationship = relationship_node_instance.inbound_relationships[0]
        relationship_type = models.Type(variant='variant', name='test.relationships.Relationship')
        relationship.type = relationship_type
        workflow_context.model.relationship.update(relationship)

        out = self._run(executor, workflow_context, _test_node_instance_relationships)

        assert len(out['instance']['relationships']) == 1
        relationship = out['instance']['relationships'][0]
        assert relationship['type'] == relationship_type.name
        assert relationship['type_hierarchy'] == [relationship_type.name]
        assert relationship['target']['node']['id'] == relationship_node_template.id
        assert relationship['target']['instance']['id'] == relationship_node_instance.id
Exemplo n.º 4
0
def create_service_template(name=SERVICE_TEMPLATE_NAME, description=None, inputs=None):
    now = datetime.now()
    inputs = inputs or {}
    return models.ServiceTemplate(
        name=name,
        description=description,
        inputs=inputs,
        created_at=now,
        updated_at=now,
        main_file_name='main_file_name',
        node_types=models.Type(variant='node', name='test_node_type'),
        group_types=models.Type(variant='group', name='test_group_type'),
        policy_types=models.Type(variant='policy', name='test_policy_type'),
        relationship_types=models.Type(variant='relationship', name='test_relationship_type'),
        capability_types=models.Type(variant='capability', name='test_capability_type'),
        artifact_types=models.Type(variant='artifact', name='test_artifact_type'),
        interface_types=models.Type(variant='interface', name='test_interface_type')
    )