-
Notifications
You must be signed in to change notification settings - Fork 23
/
provisioner.go
88 lines (78 loc) · 3.45 KB
/
provisioner.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
// Copyright 2018 Bull S.A.S. Atos Technologies - Bull, Rue Jean Jaures, B.P.68, 78340, Les Clayes-sous-Bois, France.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package prov
import (
"context"
"fmt"
"github.com/ystia/yorc/config"
)
// DelegateExecutor is the interface that wraps the ExecDelegate method
//
// ExecDelegate executes the given delegateOperation for given nodeName on the given deploymentID.
// The taskID identifies the task that requested to execute this delegate operation.
// The given ctx may be used to check for cancellation, conf is the server Configuration.
type DelegateExecutor interface {
ExecDelegate(ctx context.Context, conf config.Configuration, taskID, deploymentID, nodeName, delegateOperation string) error
}
// Operation represent a provisioning operation
type Operation struct {
// The operation name
Name string
// Name of the type implementing this operation
ImplementedInType string
// Artifact type of the operation implementation
ImplementationArtifact string
// Additional information for relationship operation
RelOp RelationshipOperation
// Node on which operation should be executed
OperationHost string
// Requirement name in case of relationship
TargetRelationship string
}
// String implements the fmt.Stringer interface
func (o Operation) String() string {
s := fmt.Sprintf("{ Name: %q, Implemented in type: %q, Implementation Artifact: %q", o.Name, o.ImplementedInType, o.ImplementationArtifact)
if o.RelOp.IsRelationshipOperation {
s += ", " + o.RelOp.String()
}
s += " }"
return s
}
// RelationshipOperation provides additional information for relationship operation
type RelationshipOperation struct {
// If this is set to true then other struct fields could be considered.
IsRelationshipOperation bool
// Requirement index of the relationship in the source node
RequirementIndex string
// Name of the target node of the relationship
TargetNodeName string
}
// String implements the fmt.Stringer interface
func (ro RelationshipOperation) String() string {
return fmt.Sprintf("Relationship target node node: %q (Requirement index %q)", ro.TargetNodeName, ro.RequirementIndex)
}
// OperationExecutor is the interface that wraps the ExecOperation method
//
// ExecOperation executes the given TOSCA operation for given nodeName on the given deploymentID.
// The taskID identifies the task that requested to execute this operation.
// The given ctx may be used to check for cancellation, conf is the server Configuration.
type OperationExecutor interface {
ExecOperation(ctx context.Context, conf config.Configuration, taskID, deploymentID, nodeName string, operation Operation) error
}
// InfraUsageCollector is the interface for collecting information about infrastructure usage
//
// GetUsageInfo returns data about infrastructure usage for defined infrastructure
type InfraUsageCollector interface {
GetUsageInfo(ctx context.Context, cfg config.Configuration, taskID, infraName string) (map[string]interface{}, error)
}