Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Maas integration #738

Draft
wants to merge 26 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions commands/bootstrap/inputs.go
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,8 @@ func initializeInputs(inputFilePath, resourcesPath string, configuration config.
infrastructureType = "aws"
case "HostsPool":
infrastructureType = "hostspool"
case "MAAS":
infrastructureType = "maas"
default:
infrastructureType = ""
}
Expand All @@ -428,7 +430,7 @@ func initializeInputs(inputFilePath, resourcesPath string, configuration config.
fmt.Println("")
prompt := &survey.Select{
Message: "Select an infrastructure type:",
Options: []string{"Google", "AWS", "OpenStack", "HostsPool"},
Options: []string{"Google", "AWS", "OpenStack", "HostsPool", "MAAS"},
}
survey.AskOne(prompt, &infraSelected, nil)
infrastructureType = strings.ToLower(infraSelected)
Expand Down Expand Up @@ -477,8 +479,10 @@ func initializeInputs(inputFilePath, resourcesPath string, configuration config.
case "hostspool":
// No infrastructure defined in case of hosts pool
// Hosts Pool don't have network-reletad on-demand resources
case "maas":
infraNodeType = "org.ystia.yorc.pub.location.MAASConfig"
default:
return fmt.Errorf("Infrastruture type %s is not supported by bootstrap",
return fmt.Errorf("infrastruture type %s is not supported by bootstrap",
infrastructureType)
}

Expand All @@ -491,7 +495,7 @@ func initializeInputs(inputFilePath, resourcesPath string, configuration config.
return err
}
if len(matchingPath) == 0 {
return fmt.Errorf("Found no node types definition file matching pattern %s", nodeTypesFilePathPattern)
return fmt.Errorf("found no node types definition file matching pattern %s", nodeTypesFilePathPattern)
}

data, err := ioutil.ReadFile(matchingPath[0])
Expand Down Expand Up @@ -768,6 +772,8 @@ func initializeInputs(inputFilePath, resourcesPath string, configuration config.
inputValues.Location.Type = "AWS"
case "hostspool":
inputValues.Location.Type = "HostsPool"
case "maas":
inputValues.Location.Type = "maas"
default:
return fmt.Errorf("Bootstrapping on %s not supported yet", infrastructureType)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
resources:
- resourceType: "yorc.nodes.maas.Compute"
resourceName: "Compute"
archiveName: yorc-maas-types
id: "yorc.bootstrap.maas.Compute"
properties: {{formatAsYAML .Compute 8}}
20 changes: 20 additions & 0 deletions commands/bootstrap/resources/topology/topology_compute_maas.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{{ define "Compute" }}
type: yorc.nodes.maas.Compute
properties: {{formatAsYAML .Compute 8}}
capabilities:
endpoint:
properties:
credentials: {{formatAsYAML .Credentials 14}}
secure: true
protocol: tcp
network_name: PRIVATE
initiator: source
os:
properties:
type: linux
scalable:
properties:
min_instances: 1
max_instances: 1
default_instances: 1
{{ end }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{{ define "Infrastructure" }}
type: org.ystia.yorc.location.MAASConfig
properties: {{formatAsYAML .Location.Properties 8}}
location_name: "{{.Location.Name}}"
requirements:
- infraHostedOnYorcServer:
type_requirement: yorc
node: YorcServer
capability: org.ystia.yorc.pub.capabilities.YorcConfigContainer
relationship: org.ystia.yorc.linux.ansible.relationships.YorcConfigMAASHostedOnYorc
{{if not .Insecure}}
- infraSecretsHostedOnVault:
type_requirement: host
node: VaultServer
capability: org.alien4cloud.vault.pub.capabilities.VaultServer
relationship: org.ystia.yorc.linux.ansible.relationships.HostsPoolSecretsOnVault
{{end}}
{{ end }}
Binary file modified commands/bootstrap/resources/topology/tosca_types.zip
Binary file not shown.
45 changes: 45 additions & 0 deletions data/tosca/yorc-maas-types.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
tosca_definitions_version: yorc_tosca_simple_yaml_1_0

metadata:
template_name: yorc-maas-types
template_author: yorc
template_version: 1.0.0

imports:
- yorc: <yorc-types.yml>

node_types:
yorc.nodes.maas.Compute:
derived_from: yorc.nodes.Compute
properties:
distro_series:
type: string
required: false
description: If present, this parameter specifies the OS the machine will use. Else the MASS default OS will be use.
arch :
type: string
required: false
description: Architecture of the returned machine (e.g. 'i386/generic', 'amd64', 'armhf/highbank', etc.).
erase:
type: boolean
required: false
description: Erase the disk when undeploying. if neither secure_erase nor quick_erase are specified, MAAS will overwrite the whole disk with null bytes. This can be very slow.
secure_erase:
type: boolean
required: false
description: Use the drive's secure erase feature if available. In some cases, this can be much faster than overwriting the drive. Some drives implement secure erasure by overwriting themselves so this could still be slow.
quick_erase:
type: boolean
required: false
description: Wipe 2MiB at the start and at the end of the drive to make data recovery inconvenient and unlikely to happen by accident. This is not secure.
tags:
type: string
required: false
description: Comma separated list of tags that the machine must match in order to be acquired. If multiple tag names are specified, the machine must be tagged with all of them.
not_tags:
type: string
required: false
description: Comma separated list of tags that the machine must NOT match. If multiple tag names are specified, the machine must NOT be tagged with ANY of them.
capabilities:
host:
type: tosca.capabilities.Container
6 changes: 6 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,13 @@ require (
github.com/hashicorp/serf v0.8.3 // indirect
github.com/hashicorp/vault v0.9.0
github.com/hinshun/vt10x v0.0.0-20180809195222-d55458df857c
github.com/jarcoal/httpmock v1.0.8
github.com/jefferai/jsonx v1.0.1 // indirect
github.com/juju/collections v0.0.0-20200605021417-0d0ec82b7271 // indirect
github.com/juju/errors v0.0.0-20200330140219-3fe23663418f // indirect
github.com/juju/gomaasapi v0.0.0-20200602032615-aa561369c767
github.com/juju/loggo v0.0.0-20200526014432-9ce3a2e09b5e // indirect
github.com/juju/schema v1.0.0 // indirect
github.com/julienschmidt/httprouter v1.2.0
github.com/justinas/alice v0.0.0-20160512134231-052b8b6c18ed
github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0 // indirect
Expand Down
Loading