-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
73 lines (63 loc) · 2.99 KB
/
main.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
// Copyright 2020 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 main
import (
"github.com/lexis-project/yorc-heappe-plugin/job"
"github.com/ystia/yorc/v4/log"
"github.com/ystia/yorc/v4/plugin"
"github.com/ystia/yorc/v4/prov"
)
func main() {
// Create configuration that defines the type of plugins to be served.
// In servConfig can be set :
// - TOSCA definitions for an extended Yorc
// - A DelegateExecutor for some TOSCA component types
// - An OperationExecutor for some TOSCA artifacts types
// - An InfrastructureUsageCollector for specific infrastructures to be monitored
servConfig := new(plugin.ServeOpts)
// Add TOSCA Definitions contained in the def variable.
// These defintions are provided in a yaml file heappe-types.yaml
// bundled in this binary (see Makefile)
// The heappe-types.yaml key can be then by used (imported) by applications
// deployed to the extended Yorc, as the example tosca/topology.yaml is doing
var err error
servConfig.Definitions, err = getToscaResources()
if err != nil {
log.Printf("Error getting bundle TOSCA resources: %+v\n", err)
return
}
// Set DelegateFunc that implements a DelegateExecutor for the TOSCA component types specified in DelegateSupportedTypes
// The delegateExecutor is defined in delegate.go
servConfig.DelegateSupportedTypes = []string{`org\.heappe\.nodes\..*`}
servConfig.DelegateFunc = func() prov.DelegateExecutor {
return new(delegateExecutor)
}
// Set OperationFunc that implements an OperationExecutor for the TOSCA artifacts specified in OperationSupportedArtifactTypes
// Temporarily using an artifact existing in Alien4Cloud until the A4C yorc provider
// is able to be extended to support new artifact types
servConfig.OperationSupportedArtifactTypes = []string{"tosca.artifacts.Deployment.Image.Container.Docker"}
servConfig.OperationFunc = func() prov.OperationExecutor {
return new(operationExecutor)
}
// Set ActionFunc that implements an ActionOperator for HEAppE jobs
servConfig.ActionTypes = []string{"heappe-job-monitoring", "heappe-job-urgent-computing-monitoring", "heappe-filecontent-monitoring"}
servConfig.ActionFunc = func() prov.ActionOperator {
return new(job.ActionOperator)
}
servConfig.InfraUsageCollectorSupportedInfras = []string{heappeInfrastructureType}
servConfig.InfraUsageCollectorFunc = func() prov.InfraUsageCollector {
return newInfraUsageCollector()
}
plugin.Serve(servConfig)
}