コード例 #1
0
    def __init__(self, template, instance_id):
        self.template = template
        self.topology = None  # Set once we are added to topology.

        # Set attributes that all instances should have
        self.attributes = dict(
            tosca_name=Value(None, True, template.name),
            tosca_id=Value(None, True, instance_id),
            state=Value(None, True, "initial"),
        )

        self.reset_attributes()
コード例 #2
0
    def invoke_trigger(self, verbose: bool, workdir: str, trigger: Trigger,
                       notification_file_contents: Optional[str]):
        for interface_name, operation_name, _ in trigger.action:
            # get node's interface and interface operations that are referenced in a trigger action
            interface = self.template.interfaces.get(interface_name, None)
            operation = interface.operations.get(operation_name, None) if interface else None

            if interface is not None and operation is not None:
                if notification_file_contents:
                    # add notification file contents to operation inputs that are exposed in the executor
                    if "notification" in operation.inputs:
                        raise ToscaDeviationError("The input name: notification within the node: {} cannot be "
                                                  "used. It it reserved and holds the contents of notification "
                                                  "file. Please rename it.".format(self.template.name))

                    notification_value = Value(None, True, notification_file_contents)
                    operation.inputs.update({"notification": notification_value})

                self.run_operation(OperationHost.HOST, interface_name, operation_name, verbose, workdir)
コード例 #3
0
 def get_value(self, typ):
     if "value" in self:
         return self.value.get_value(typ)
     if "default" in self:
         return self.default.get_value(typ)
     return Value(typ, False)
コード例 #4
0
 def get_value(self, typ):
     return Value(typ, True, self.data)
コード例 #5
0
 def get_value(self, typ):
     if "file" in self:
         yaml_data = yaml.safe_load(str(self.file))
         return Value(typ, True, yaml_data)
     return Value(typ, False)