diff --git a/commands/bootstrap/inputs.go b/commands/bootstrap/inputs.go index afb51238b..27638b57e 100644 --- a/commands/bootstrap/inputs.go +++ b/commands/bootstrap/inputs.go @@ -403,6 +403,8 @@ func initializeInputs(inputFilePath, resourcesPath string, configuration config. infrastructureType = "aws" case "HostsPool": infrastructureType = "hostspool" + case "MAAS": + infrastructureType = "maas" default: infrastructureType = "" } @@ -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) @@ -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) } @@ -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]) @@ -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) } diff --git a/commands/bootstrap/resources/topology/ondemand_resources_maas.tmpl b/commands/bootstrap/resources/topology/ondemand_resources_maas.tmpl new file mode 100644 index 000000000..8c353b06a --- /dev/null +++ b/commands/bootstrap/resources/topology/ondemand_resources_maas.tmpl @@ -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}} diff --git a/commands/bootstrap/resources/topology/topology_compute_maas.tmpl b/commands/bootstrap/resources/topology/topology_compute_maas.tmpl new file mode 100644 index 000000000..ddaaaf14f --- /dev/null +++ b/commands/bootstrap/resources/topology/topology_compute_maas.tmpl @@ -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 }} diff --git a/commands/bootstrap/resources/topology/topology_infrastructure_maas.tmpl b/commands/bootstrap/resources/topology/topology_infrastructure_maas.tmpl new file mode 100644 index 000000000..739f76a04 --- /dev/null +++ b/commands/bootstrap/resources/topology/topology_infrastructure_maas.tmpl @@ -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 }} diff --git a/commands/bootstrap/resources/topology/tosca_types.zip b/commands/bootstrap/resources/topology/tosca_types.zip index 4f870654e..0eb40418e 100644 Binary files a/commands/bootstrap/resources/topology/tosca_types.zip and b/commands/bootstrap/resources/topology/tosca_types.zip differ diff --git a/data/tosca/yorc-maas-types.yml b/data/tosca/yorc-maas-types.yml new file mode 100644 index 000000000..8f95efd03 --- /dev/null +++ b/data/tosca/yorc-maas-types.yml @@ -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: + +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 \ No newline at end of file diff --git a/go.mod b/go.mod index 9ed093ad2..292ab5183 100644 --- a/go.mod +++ b/go.mod @@ -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 diff --git a/go.sum b/go.sum index 2d73113d6..97e9fce7d 100644 --- a/go.sum +++ b/go.sum @@ -147,7 +147,6 @@ github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LB github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/gocql/gocql v0.0.0-20200228163523-cd4b606dd2fb h1:H3tisfjQwq9FTyWqlKsZpgoYrsvn2pmTWvAiDHa5pho= github.com/gocql/gocql v0.0.0-20200228163523-cd4b606dd2fb/go.mod h1:DL0ekTmBSTdlNF25Orwt/JMzqIq3EJ4MVa/J/uK64OY= -github.com/gogo/protobuf v1.1.1 h1:72R+M5VuhED/KujmZVcIquuo8mBgX4oVda//DQb3PXo= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/gogo/protobuf v1.2.1 h1:/s5zKNz0uPFCZ5hddgPdo2TK2TVrUNMn0OOX8/aZMTE= github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4= @@ -164,13 +163,11 @@ github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5y github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.2 h1:6nsPYzhq5kReh6QImI3k5qWzO4PEbvbIW2cwSfR/6xs= github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/snappy v0.0.0-20170215233205-553a64147049 h1:K9KHZbXKpGydfDN0aZrsoHpLJlZsBrGMFWbgLDGnPZk= github.com/golang/snappy v0.0.0-20170215233205-553a64147049/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/golang/snappy v0.0.1 h1:Qgr9rKW7uDUkrbSmQeiDsGa8SjGyCOGtuasMWwvp2P4= github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/google/addlicense v0.0.0-20190107131845-2e5cf00261bf h1:sY3YFbxQBI/WqUznt+mPxct/yY7FI4NZzQj10oJwYq0= github.com/google/addlicense v0.0.0-20190107131845-2e5cf00261bf/go.mod h1:QtPG26W17m+OIQgE6gQ24gC1M6pUaMBAbFrTIDtwG/E= -github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c h1:964Od4U6p2jUkFxvCydnIczKteheJEzHRToSGK3Bnlw= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/btree v1.0.0 h1:0udJVsspx3VBr5FwtLhQQtuAsVc79tTq0ocGIPAU6qo= github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= @@ -219,7 +216,6 @@ github.com/hashicorp/go-memdb v1.1.0 h1:ClvpUXpBA6UDs5+vc1h3wqe4UJU+rwum7CU219Se github.com/hashicorp/go-memdb v1.1.0/go.mod h1:LWQ8R70vPrS4OEY9k28D2z8/Zzyu34NVzeRibGAzHO0= github.com/hashicorp/go-msgpack v0.5.3 h1:zKjpN5BK/P5lMYrLmBHdBULWbJ0XpYR+7NGzqkZzoD4= github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM= -github.com/hashicorp/go-multierror v1.0.0 h1:iVjPR7a6H0tWELX5NxNe7bYopibicUzc7uPribsnS6o= github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= github.com/hashicorp/go-multierror v1.1.0 h1:B9UzwGQJehnUY1yNrnwREHc3fGbC2xefo8g4TbElacI= github.com/hashicorp/go-multierror v1.1.0/go.mod h1:spPvp8C1qA32ftKqdAHm4hHTbPw+vmowP0z+KUhOZdA= @@ -231,7 +227,6 @@ github.com/hashicorp/go-rootcerts v1.0.0/go.mod h1:K6zTfqpRlCUIjkwsN4Z+hiSfzSTQa github.com/hashicorp/go-sockaddr v1.0.0 h1:GeH6tui99pF4NJgfnhp+L6+FfobzVW3Ah46sLo0ICXs= github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU= github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4= -github.com/hashicorp/go-uuid v1.0.0 h1:RS8zrF7PhGwyNPOtxSClXXj9HA8feRnJzgnI1RJCSnM= github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-uuid v1.0.1 h1:fv1ep09latC32wFoVwnqcnKJGnMSdBanPczbHAYm1BE= github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= @@ -260,6 +255,8 @@ github.com/imdario/mergo v0.3.8 h1:CGgOkSJeqMRmt0D9XLWExdT4m4F1vd3FV3VPt+0VxkQ= github.com/imdario/mergo v0.3.8/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= +github.com/jarcoal/httpmock v1.0.8 h1:8kI16SoO6LQKgPE7PvQuV+YuD/inwHd7fOOe2zMbo4k= +github.com/jarcoal/httpmock v1.0.8/go.mod h1:ATjnClrvW/3tijVmpL/va5Z3aAyGvqU3gCT8nX0Txik= github.com/jefferai/jsonx v1.0.1 h1:GvWkLWihoLqDG0BSP45TUQJH9qsINX50PVrFULgpc/I= github.com/jefferai/jsonx v1.0.1/go.mod h1:yFo3l2fcm7cZVHGq3HKLXE+Pd4RWuRjNBDHksM7XekQ= github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= @@ -267,6 +264,26 @@ github.com/json-iterator/go v0.0.0-20180612202835-f2b4162afba3/go.mod h1:+SdeFBv github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/json-iterator/go v1.1.7 h1:KfgG9LzI+pYjr4xvmz/5H4FXjokeP+rlHLhv3iH62Fo= github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= +github.com/juju/collections v0.0.0-20200605021417-0d0ec82b7271 h1:4R626WTwa7pRYQFiIRLVPepMhm05eZMEx+wIurRnMLc= +github.com/juju/collections v0.0.0-20200605021417-0d0ec82b7271/go.mod h1:5XgO71dV1JClcOJE+4dzdn4HrI5LiyKd7PlVG6eZYhY= +github.com/juju/errors v0.0.0-20150916125642-1b5e39b83d18/go.mod h1:W54LbzXuIE0boCoNJfwqpmkKJ1O4TCTZMetAt6jGk7Q= +github.com/juju/errors v0.0.0-20200330140219-3fe23663418f h1:MCOvExGLpaSIzLYB4iQXEHP4jYVU6vmzLNQPdMVrxnM= +github.com/juju/errors v0.0.0-20200330140219-3fe23663418f/go.mod h1:W54LbzXuIE0boCoNJfwqpmkKJ1O4TCTZMetAt6jGk7Q= +github.com/juju/gomaasapi v0.0.0-20200602032615-aa561369c767 h1:b59sh8vHY7lke8eyoxKbGKmOM78DlyMtwQ7ryE3Tuuo= +github.com/juju/gomaasapi v0.0.0-20200602032615-aa561369c767/go.mod h1:ppx9XlnQMX/+h/kH+cU9kfDUT6GimqGtNRWdobUZVRE= +github.com/juju/loggo v0.0.0-20170605014607-8232ab8918d9/go.mod h1:vgyd7OREkbtVEN/8IXZe5Ooef3LQePvuBm9UWj6ZL8U= +github.com/juju/loggo v0.0.0-20200526014432-9ce3a2e09b5e h1:FdDd7bdI6cjq5vaoYlK1mfQYfF9sF2VZw8VEZMsl5t8= +github.com/juju/loggo v0.0.0-20200526014432-9ce3a2e09b5e/go.mod h1:vgyd7OREkbtVEN/8IXZe5Ooef3LQePvuBm9UWj6ZL8U= +github.com/juju/retry v0.0.0-20151029024821-62c620325291 h1:Rp0pLxDOsLDDwh2S73oHLI2KTFFyrF6oM/DgP0FhhBk= +github.com/juju/retry v0.0.0-20151029024821-62c620325291/go.mod h1:OohPQGsr4pnxwD5YljhQ+TZnuVRYpa5irjugL1Yuif4= +github.com/juju/schema v1.0.0 h1:sZvJ7iQXHhMw/lJ4YfUmq+fe7R2ZSUzZzd/eSokaB3M= +github.com/juju/schema v1.0.0/go.mod h1:Y+ThzXpUJ0E7NYYocAbuvJ7vTivXfrof/IfRPq/0abI= +github.com/juju/testing v0.0.0-20180402130637-44801989f0f7 h1:IOzyKRl+7X8/fDIqNUDQH73yo8bqDrMEh90y9Il158A= +github.com/juju/testing v0.0.0-20180402130637-44801989f0f7/go.mod h1:63prj8cnj0tU0S9OHjGJn+b1h0ZghCndfnbQolrYTwA= +github.com/juju/utils v0.0.0-20180424094159-2000ea4ff043 h1:kjdsJcIYzmK2k4X2yVCi5Nip6sGoAuc7CLbp+qQnQUM= +github.com/juju/utils v0.0.0-20180424094159-2000ea4ff043/go.mod h1:6/KLg8Wz/y2KVGWEpkK9vMNGkOnu4k/cqs8Z1fKjTOk= +github.com/juju/version v0.0.0-20161031051906-1f41e27e54f2 h1:loQDi5MyxxNm7Q42mBGuPD6X+F6zw8j5S9yexLgn/BE= +github.com/juju/version v0.0.0-20161031051906-1f41e27e54f2/go.mod h1:kE8gK5X0CImdr7qpSKl3xB2PmpySSmfj7zVbkZFs81U= github.com/julienschmidt/httprouter v1.2.0 h1:TDTW5Yz1mjftljbcKqRcrYhd4XeOoI98t+9HbQbYf7g= github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= github.com/justinas/alice v0.0.0-20160512134231-052b8b6c18ed h1:Ab4XhecWusSSeIfQ2eySh7kffQ1Wsv6fNSkwefr6AVQ= @@ -286,7 +303,6 @@ github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxv github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= -github.com/kr/pty v1.1.1 h1:VkoXIwSboBpnk99O/KFauAEILuNHv5DVFKZMBN/gUgw= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/pty v1.1.8 h1:AkaSdXYQOWeaO3neb8EM634ahkXXe3jYbVh/F9lq+GI= github.com/kr/pty v1.1.8/go.mod h1:O1sed60cT9XZ5uDucP5qwvh+TE3NnUj51EiZO/lmSfw= @@ -296,7 +312,6 @@ github.com/labstack/gommon v0.3.0 h1:JEeO0bvc78PKdyHxloTKiF8BD5iGrH8T6MSeGvSgob0 github.com/labstack/gommon v0.3.0/go.mod h1:MULnywXg0yavhxWKc+lOruYdAhDwPK9wf0OL7NoOu+k= github.com/lib/pq v1.3.0 h1:/qkRGz8zljWiDcFvgpwUpwIAPu3r07TDvs3Rws+o/pU= github.com/lib/pq v1.3.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= -github.com/magiconair/properties v1.8.0 h1:LLgXmsheXeRoUOBOjtwPQCWIYqM/LU1ayDtDePerRcY= github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= github.com/magiconair/properties v1.8.1 h1:ZC2Vc7/ZFkGmsVC9KvOjumD+G5lXy2RtTKyzRKO2BQ4= github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= @@ -304,14 +319,12 @@ github.com/mailru/easyjson v0.0.0-20160728113105-d5b7844b561a/go.mod h1:C1wdFJiN github.com/matryer/resync v0.0.0-20161211202428-d39c09a11215 h1:hDa3vAq/Zo5gjfJ46XMsGFbH+hTizpR4fUzQCk2nxgk= github.com/matryer/resync v0.0.0-20161211202428-d39c09a11215/go.mod h1:LH+NgPY9AJpDfqAFtzyer01N9MYNsAKUf3DC9DV1xIY= github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= -github.com/mattn/go-colorable v0.1.2 h1:/bC9yWikZXAL9uJdulbSfyVNIR3n3trXl+v8+1sx8mU= github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= github.com/mattn/go-colorable v0.1.4 h1:snbPLB8fVfU9iwbbo30TPtbLRzwWu6aJS6Xh4eaaviA= github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= github.com/mattn/go-isatty v0.0.9/go.mod h1:YNRxwqDuOph6SZLI9vUUz6OYw3QyUt7WiY2yME+cCiQ= -github.com/mattn/go-isatty v0.0.10 h1:qxFzApOv4WsAL965uUPIsXzAKCZxN2p9UqdhFS4ZW10= github.com/mattn/go-isatty v0.0.10/go.mod h1:qgIWMr58cqv1PHHyhnkY9lrL7etaEgOFcMEpPG5Rm84= github.com/mattn/go-isatty v0.0.11 h1:FxPOTFNqGkuDUGi3H/qkUbQO4ZiBa2brKq5r0l8TGeM= github.com/mattn/go-isatty v0.0.11/go.mod h1:PhnuNfih5lzO57/f3n+odYbM4JtupLOxQOAqxQCu2WE= @@ -330,7 +343,6 @@ github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3N github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc= github.com/mitchellh/copystructure v1.0.0 h1:Laisrj+bAB6b/yJwB5Bt3ITZhGJdqmxquMKeZ+mmkFQ= github.com/mitchellh/copystructure v1.0.0/go.mod h1:SNtv71yrdKgLRyLFxmLdkAbkKEFWgYaq1OVrnRcwhnw= -github.com/mitchellh/go-homedir v1.0.0 h1:vKb8ShqSby24Yrqr/yDYkuFz8d0WUjys40rvnGC8aR0= github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= @@ -360,12 +372,10 @@ github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRW github.com/oklog/run v1.0.0 h1:Ru7dDtJNOyC66gQ5dQmaCa0qIsAUFY3sFpK1Xk8igrw= github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA= github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= -github.com/onsi/ginkgo v0.0.0-20170829012221-11459a886d9c h1:Hww8mOyEKTeON4bZn7FrlLismspbPc1teNRUVH7wLQ8= github.com/onsi/ginkgo v0.0.0-20170829012221-11459a886d9c/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.10.1 h1:q/mM8GF/n0shIN8SaAZ0V+jnLPzen6WIVZdiwrRlMlo= github.com/onsi/ginkgo v1.10.1/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -github.com/onsi/gomega v0.0.0-20170829124025-dcabb60a477c h1:eSfnfIuwhxZyULg1NNuZycJcYkjYVGYe7FczwQReM6U= github.com/onsi/gomega v0.0.0-20170829124025-dcabb60a477c/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA= github.com/onsi/gomega v1.7.0 h1:XPnZz8VVBHjVsy1vzJmRwIcSwiUO+JFfrv/xGiigmME= github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= @@ -382,7 +392,6 @@ github.com/pascaldekloe/goe v0.1.0 h1:cBOtyMzM9HTpWjXfbbunk26uA6nG3a8n06Wieeh0Mw github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/patrickmn/go-cache v2.1.0+incompatible h1:HRMgzkcYKYpi3C8ajMPV8OFXaaRUnok+kx1WdO15EQc= github.com/patrickmn/go-cache v2.1.0+incompatible/go.mod h1:3Qf8kWWT7OJRJbdiICTKqZju1ZixQ/KpMGzzAfe6+WQ= -github.com/pelletier/go-toml v1.2.0 h1:T5zMGML61Wp+FlcbWjRDT7yAxhJNAiPPLOFECq181zc= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= github.com/pelletier/go-toml v1.4.0 h1:u3Z1r+oOXJIkxqw34zVhyPgjBsm6X2wn21NWs/HfSeg= github.com/pelletier/go-toml v1.4.0/go.mod h1:PN7xzY2wHTK0K9p34ErDQMlFxa51Fk0OUruD3k1mMwo= @@ -390,7 +399,6 @@ github.com/peterbourgon/diskv v2.0.1+incompatible h1:UBdAOUP5p4RWqPBg048CAvpKN+v github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR/tNboyR3/BZd58JJSHlUSCU= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1-0.20171018195549-f15c970de5b7/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= @@ -418,7 +426,6 @@ github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R github.com/prometheus/procfs v0.0.0-20181204211112-1dc9a6cbc91a/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= -github.com/prometheus/procfs v0.0.5 h1:3+auTFlqw+ZaQYJARz6ArODtkaIwtvBTx3N2NehQlL8= github.com/prometheus/procfs v0.0.5/go.mod h1:4A/X28fw3Fc593LaREMrKMqOKvUAntwMDaekg4FpcdQ= github.com/prometheus/procfs v0.0.8 h1:+fpWZdT24pJBiqJdAwYBjPSk+5YmQzYNPYzQsdzLkt8= github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A= @@ -448,7 +455,6 @@ github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6Mwd github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72 h1:qLC7fQah7D6K1B0ujays3HV9gkFtllcxhzImRR7ArPQ= github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= -github.com/spf13/afero v1.1.2 h1:m8/z1t7/fwjysjQRYbP0RD+bUIF/8tJwPdEZsI83ACI= github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= github.com/spf13/afero v1.2.2 h1:5jhuqJyZCZf2JRofRvN/nIFgIWNzPa3/Vz8mYylgbWc= github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk= @@ -457,13 +463,11 @@ github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkU github.com/spf13/cobra v0.0.2-0.20171109065643-2da4a54c5cee/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= github.com/spf13/cobra v0.0.6 h1:breEStsVwemnKh2/s6gMvSdMEkwW0sK8vGStnlVBMCs= github.com/spf13/cobra v0.0.6/go.mod h1:/6GTrnGXV9HjY+aR4k0oJ5tcvakLuG6EuKReYlHNrgE= -github.com/spf13/jwalterweatherman v1.0.0 h1:XHEdyB+EcvlqZamSM4ZOMGlc93t6AcsBEu9Gc1vn7yk= github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= github.com/spf13/jwalterweatherman v1.1.0 h1:ue6voC5bR5F8YxI5S67j9i582FU4Qvo2bmqnqMYADFk= github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo= github.com/spf13/pflag v0.0.0-20170130214245-9ff6c6923cff/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/spf13/pflag v1.0.1-0.20171106142849-4c012f6dcd95/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= -github.com/spf13/pflag v1.0.3 h1:zPAT6CGy6wXeQ7NtTnaTerfKOsV6V6F8agHXFiazDkg= github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= @@ -475,7 +479,6 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v0.0.0-20151208002404-e3a8ff8ce365/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= -github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= @@ -495,13 +498,11 @@ go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= golang.org/x/crypto v0.0.0-20171113213409-9f005a07e0d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +golang.org/x/crypto v0.0.0-20180214000028-650f4a345ab4/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 h1:VklqNMn3ovrHsnt90PveolxSbWFaJdECFbxSq0Mqo2M= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c h1:Vj5n4GlwjmQteupaxJ9+0FNOmBrHfq7vN4btdGoDZgI= golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550 h1:ObdrDkeb4kJdCP557AjRjq69pTHfNouLtWZG7j9rPN8= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200115085410-6d4e4cb37c7d/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200510223506-06a226fb4e37 h1:cg5LA/zNPRzIXIWSCxQW10Rvpy94aQh3LT/ShoCpkHw= @@ -511,6 +512,7 @@ golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHl golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee h1:WG0RUwxtNT4qqaXX3DPA8zHFNm/D9xaBpxzHt1WcA/E= golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= golang.org/x/net v0.0.0-20170114055629-f2499483f923/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180406214816-61147c48b25b/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -523,9 +525,7 @@ golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73r golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190522155817-f3200d17e092/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= -golang.org/x/net v0.0.0-20190613194153-d28f0bde5980 h1:dfGZHvZk057jK2MCeWus/TowKpJ8y4AmooUzdBSR9GU= golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859 h1:R/3boaszxrf1GEUWTVDzSKVwLmSJpwZ1yqXm8j0v2QI= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200202094626-16171245cfb2 h1:CCH4IOTTfewWjGOlSp+zGcjutRKlBEZQ6wTn8ozI/nI= golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= @@ -556,7 +556,6 @@ golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191010194322-b09406accb47/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191128015809-6d18c012aee9 h1:ZBzSG/7F4eNKz2L3GE9o300RX0Az1Bw5HF7PDraD+qU= golang.org/x/sys v0.0.0-20191128015809-6d18c012aee9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200116001909-b77594299b42 h1:vEOn+mP2zCOVzKckCZy6YsCtDblrpj/w7B9nxGNELpg= golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -570,7 +569,6 @@ golang.org/x/tools v0.0.0-20181011042414-1f849cf54d09/go.mod h1:n7NCudcB/nEzxVGm golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= -golang.org/x/tools v0.0.0-20190624222133-a101b041ded4 h1:1mMox4TgefDwqluYCv677yNXwlfTkija4owZve/jr78= golang.org/x/tools v0.0.0-20190624222133-a101b041ded4/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20200113040837-eac381796e91/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200117170720-ade7f2547e48/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= @@ -583,7 +581,6 @@ google.golang.org/appengine v1.4.0 h1:/wp5JvzpHIxhs/dumFmF7BXTf3Z+dd4uXta4kVyO50 google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8 h1:Nw54tB0rB7hY/N0NQvRW8DG4Yk3Q6T9cu9RcFQDu1tc= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= -google.golang.org/grpc v1.14.0 h1:ArxJuB1NWfPY6r9Gp9gqwplT0Ge7nqv9msgu03lHLmo= google.golang.org/grpc v1.14.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.21.0 h1:G+97AoqBnmZIT91cLG/EkCoK9NSelj64P8bOHHNmGn0= @@ -592,8 +589,8 @@ gopkg.in/AlecAivazis/survey.v1 v1.6.3 h1:5ULq/dOAZJZxz8kPV3sI8HHjluXi3k62fUtkTbB gopkg.in/AlecAivazis/survey.v1 v1.6.3/go.mod h1:2Ehl7OqkBl3Xb8VmC4oFW2bItAhnUfzIjrOzwRxCrOU= gopkg.in/airbrake/gobrake.v2 v2.0.9/go.mod h1:/h5ZAUhDkGaJfjzjKLSjv6zCL6O0LLBxU4K+aSYdM/U= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20160105164936-4f90aeace3a2/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/cookieo9/resources-go.v2 v2.0.0-20150225115733-d27c04069d0d h1:YjTGSRV59gG1DHCq68v2B771I9dGFxvMkugf7OKglpk= @@ -603,6 +600,7 @@ gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMy gopkg.in/gemnasium/logrus-airbrake-hook.v2 v2.1.2/go.mod h1:Xk6kEKp8OKb+X14hQBKWaSkCsqBpgog8nAV2xsGOxlo= gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc= gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= +gopkg.in/mgo.v2 v2.0.0-20160818015218-f2b6f6c918c4/go.mod h1:yeKp02qBN3iKW1OzL3MGk2IdtZzaj7SFntXj72NppTA= gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22 h1:VpOs+IwYnYBaFnrNAeB8UUWtL3vEUnzSCL1nVjPhqrw= gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22/go.mod h1:yeKp02qBN3iKW1OzL3MGk2IdtZzaj7SFntXj72NppTA= gopkg.in/ory-am/dockertest.v3 v3.3.5 h1:bJGdHNsq45hfEN5oNKBEYHeqnch6F7ZgPE8CHjLe8Ic= @@ -610,11 +608,10 @@ gopkg.in/ory-am/dockertest.v3 v3.3.5/go.mod h1:s9mmoLkaGeAh97qygnNj4xWkiN7e1SKek gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= +gopkg.in/yaml.v2 v2.0.0-20170712054546-1be3d31502d6/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74= gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.4 h1:/eiJrUcujPVeJ3xlSWaiNi3uSVmDGBK1pDHUHAnao1I= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.7 h1:VUgggvou5XRW9mHwD/yXxIYSMtY0zoKQf/v226p2nyo= gopkg.in/yaml.v2 v2.2.7/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/prov/maas/all_test.go b/prov/maas/all_test.go new file mode 100644 index 000000000..ab10935aa --- /dev/null +++ b/prov/maas/all_test.go @@ -0,0 +1,152 @@ +// 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 maas + +import ( + "context" + "os" + "path" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/jarcoal/httpmock" + "github.com/ystia/yorc/v4/config" + "github.com/ystia/yorc/v4/deployments" + "github.com/ystia/yorc/v4/locations" + "github.com/ystia/yorc/v4/testutil" +) + +var MAAS_LOCATION_PROPS config.DynamicMap + +// The aim of this function is to run all package tests with consul server dependency with only one consul server start +func TestMainMaas(t *testing.T) { + // Create consul instance + cfg := testutil.SetupTestConfig(t) + srv, _ := testutil.NewTestConsulInstance(t, &cfg) + defer func() { + srv.Stop() + os.RemoveAll(cfg.WorkingDirectory) + }() + + // Create a maas location + locationMgr, err := locations.GetManager(cfg) + require.NoError(t, err, "Error initializing locations") + + MAAS_LOCATION_PROPS = config.DynamicMap{ + "api_url": "10.0.0.0", + "api_key": "jGhsLn7JdVHNn6JhpT:SFtuTJSs2DpFbNGvQd:PJfNarCdtXUAQ8694f529a8fLZPaDBHE", + "delayBetweenStatusCheck": "1ms", + } + err = locationMgr.CreateLocation( + locations.LocationConfiguration{ + Name: "testMaasLocation", + Type: infrastructureType, + Properties: MAAS_LOCATION_PROPS, + }) + require.NoError(t, err, "Failed to create a location") + defer func() { + locationMgr.RemoveLocation(t.Name()) + }() + + t.Run("groupMaas", func(t *testing.T) { + t.Run("testInstallCompute", func(t *testing.T) { + testInstallCompute(t, cfg) + }) + t.Run("testInstallCompute", func(t *testing.T) { + testInstallComputeNoApiResponse(t, cfg) + }) + t.Run("testUninstallCompute", func(t *testing.T) { + testUninstallCompute(t, cfg) + }) + t.Run("testUninstallNoSystemIdErrorCompute", func(t *testing.T) { + testUninstallNoSystemIdErrorCompute(t, cfg) + }) + t.Run("testSimpleMaasCompute", func(t *testing.T) { + testGetComputeFromDeployment(t, cfg) + }) + + }) +} + +func testInstallCompute(t *testing.T, cfg config.Configuration) { + executor := &defaultExecutor{} + ctx := context.Background() + + deploymentID := path.Base(t.Name()) + err := deployments.StoreDeploymentDefinition(context.Background(), deploymentID, "testdata/testSimpleMaasCompute.yaml") + require.Nil(t, err, "Failed to parse testInstallCompute definition") + + httpmock.Activate() + defer httpmock.DeactivateAndReset() + + httpmock.RegisterResponder("POST", "/10.0.0.0/api/2.0/machines/?op=allocate", + httpmock.NewStringResponder(200, allocateResponse)) + + httpmock.RegisterResponder("POST", "/10.0.0.0/api/2.0/machines/tdgqkw/?op=deploy", + httpmock.NewStringResponder(200, deployResponse)) + + httpmock.RegisterResponder("GET", "/10.0.0.0/api/2.0/machines/tdgqkw/", + httpmock.NewStringResponder(200, machineDeployed)) + + err = executor.ExecDelegate(ctx, cfg, "taskID", deploymentID, "Compute", "install") + require.Nil(t, err) +} + +func testInstallComputeNoApiResponse(t *testing.T, cfg config.Configuration) { + executor := &defaultExecutor{} + ctx := context.Background() + + deploymentID := path.Base(t.Name()) + err := deployments.StoreDeploymentDefinition(context.Background(), deploymentID, "testdata/testSimpleMaasCompute.yaml") + require.Nil(t, err, "Failed to parse testInstallComputeNoApiResponse definition") + + err = executor.ExecDelegate(ctx, cfg, "taskID", deploymentID, "Compute", "install") + require.NotNil(t, err) +} + +func testUninstallCompute(t *testing.T, cfg config.Configuration) { + executor := &defaultExecutor{} + ctx := context.Background() + + deploymentID := path.Base(t.Name()) + err := deployments.StoreDeploymentDefinition(context.Background(), deploymentID, "testdata/testSimpleMaasCompute.yaml") + require.Nil(t, err, "Failed to parse testUninstallCompute definition") + + httpmock.Activate() + defer httpmock.DeactivateAndReset() + + httpmock.RegisterResponder("POST", "/10.0.0.0/api/2.0/machines/tdgqkw/?op=release", + httpmock.NewStringResponder(200, deployResponse)) + + err = deployments.SetInstanceAttribute(ctx, deploymentID, "Compute", "0", "system_id", "tdgqkw") + require.Nil(t, err) + + err = executor.ExecDelegate(ctx, cfg, "taskID", deploymentID, "Compute", "uninstall") + require.Nil(t, err) +} + +func testUninstallNoSystemIdErrorCompute(t *testing.T, cfg config.Configuration) { + executor := &defaultExecutor{} + ctx := context.Background() + + deploymentID := path.Base(t.Name()) + err := deployments.StoreDeploymentDefinition(context.Background(), deploymentID, "testdata/testSimpleMaasCompute.yaml") + require.Nil(t, err, "Failed to parse testUninstallNoSystemIdErrorCompute definition") + + err = executor.ExecDelegate(ctx, cfg, "taskID", deploymentID, "Compute", "uninstall") + + require.Contains(t, err.Error(), "can't find instance attribute system id") +} diff --git a/prov/maas/all_test_data.go b/prov/maas/all_test_data.go new file mode 100644 index 000000000..352649936 --- /dev/null +++ b/prov/maas/all_test_data.go @@ -0,0 +1,1583 @@ +// Copyright 2019 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 maas + +var allocateResponse = ` +{ + "hostname": "alert-buck", + "distro_series": "", + "address_ttl": null, + "network_test_status": -1, + "ip_addresses": [], + "other_test_status_name": "Unknown", + "memory_test_status_name": "Unknown", + "cpu_count": 8, + "hwe_kernel": null, + "storage_test_status": 2, + "node_type_name": "Machine", + "commissioning_status": 2, + "virtualmachine_id": null, + "status_action": "", + "bios_boot_method": "pxe", + "netboot": true, + "interface_set": [ + { + "params": "", + "interface_speed": 1000, + "vendor": "Intel Corporation", + "enabled": true, + "id": 16, + "sriov_max_vf": 7, + "effective_mtu": 1500, + "system_id": "tdgqkw", + "type": "physical", + "vlan": { + "vid": 0, + "mtu": 1500, + "dhcp_on": true, + "external_dhcp": null, + "relay_vlan": null, + "secondary_rack": null, + "fabric": "fabric-1", + "fabric_id": 1, + "primary_rack": "67mdw3", + "name": "untagged", + "space": "undefined", + "id": 5002, + "resource_uri": "/MAAS/api/2.0/vlans/5002/" + }, + "product": "82576 Gigabit Network Connection", + "discovered": [], + "links": [ + { + "id": 31, + "mode": "auto", + "subnet": { + "name": "172.20.0.0/24", + "description": "", + "vlan": { + "vid": 0, + "mtu": 1500, + "dhcp_on": true, + "external_dhcp": null, + "relay_vlan": null, + "secondary_rack": null, + "fabric": "fabric-1", + "fabric_id": 1, + "primary_rack": "67mdw3", + "name": "untagged", + "space": "undefined", + "id": 5002, + "resource_uri": "/MAAS/api/2.0/vlans/5002/" + }, + "cidr": "172.20.0.0/24", + "rdns_mode": 2, + "gateway_ip": "172.20.0.1", + "dns_servers": [], + "allow_dns": true, + "allow_proxy": true, + "active_discovery": false, + "managed": true, + "space": "undefined", + "id": 2, + "resource_uri": "/MAAS/api/2.0/subnets/2/" + } + } + ], + "numa_node": 0, + "tags": [ + "sriov" + ], + "name": "enp1s0f0", + "mac_address": "cb:d5:c9:f7:78:04", + "firmware_version": "1.2.3", + "parents": [], + "children": [], + "link_connected": true, + "link_speed": 100, + "resource_uri": "/MAAS/api/2.0/nodes/tdgqkw/interfaces/16/" + }, + { + "params": "", + "interface_speed": 1000, + "vendor": "Intel Corporation", + "enabled": true, + "id": 18, + "sriov_max_vf": 7, + "effective_mtu": 1500, + "system_id": "tdgqkw", + "type": "physical", + "vlan": null, + "product": "82576 Gigabit Network Connection", + "discovered": null, + "links": [], + "numa_node": 0, + "tags": [ + "sriov" + ], + "name": "enp1s0f1", + "mac_address": "cb:d5:c9:f7:78:04", + "firmware_version": "1.2.3", + "parents": [], + "children": [], + "link_connected": true, + "link_speed": 0, + "resource_uri": "/MAAS/api/2.0/nodes/tdgqkw/interfaces/18/" + } + ], + "network_test_status_name": "Unknown", + "pod": null, + "disable_ipv4": false, + "blockdevice_set": [ + { + "id_path": "/dev/disk/by-id/wwn-0x5000c50066898892", + "size": 1000204886016, + "block_size": 512, + "tags": [ + "ssd" + ], + "storage_pool": null, + "id": 11, + "system_id": "tdgqkw", + "used_for": "GPT partitioned with 1 partition", + "model": "ST1000NM0033-9ZM", + "type": "physical", + "filesystem": null, + "numa_node": 0, + "available_size": 0, + "name": "sda", + "uuid": null, + "serial": "Z1W1QQ4T", + "partitions": [ + { + "uuid": "32fc769e-2f84-4db6-8d06-3c0b6ef4282a", + "size": 1000194703360, + "bootable": false, + "tags": [], + "system_id": "tdgqkw", + "device_id": 11, + "used_for": "ext4 formatted filesystem mounted at /", + "type": "partition", + "path": "/dev/disk/by-dname/sda-part2", + "filesystem": { + "fstype": "ext4", + "label": "root", + "uuid": "bc9577af-b6a9-4eb7-95bf-887300365bc9", + "mount_point": "/", + "mount_options": null + }, + "id": 7, + "resource_uri": "/MAAS/api/2.0/nodes/tdgqkw/blockdevices/11/partition/7" + } + ], + "path": "/dev/disk/by-dname/sda", + "used_size": 1000200994816, + "partition_table_type": "GPT", + "resource_uri": "/MAAS/api/2.0/nodes/tdgqkw/blockdevices/11/" + }, + { + "id_path": "/dev/disk/by-id/wwn-0x5000c5006689ae3f", + "size": 1000204886016, + "block_size": 512, + "tags": [ + "ssd" + ], + "storage_pool": null, + "id": 12, + "system_id": "tdgqkw", + "used_for": "Unused", + "model": "ST1000NM0033-9ZM", + "type": "physical", + "filesystem": null, + "numa_node": 0, + "available_size": 1000204886016, + "name": "sdb", + "uuid": null, + "serial": "Z1W1QJMW", + "partitions": [], + "path": "/dev/disk/by-dname/sdb", + "used_size": 0, + "partition_table_type": null, + "resource_uri": "/MAAS/api/2.0/nodes/tdgqkw/blockdevices/12/" + } + ], + "node_type": 0, + "commissioning_status_name": "Passed", + "interface_test_status": -1, + "storage": 2000409.7720320001, + "owner_data": {}, + "owner": "jim", + "system_id": "tdgqkw", + "raids": [], + "min_hwe_kernel": "", + "cpu_speed": 2930, + "locked": false, + "osystem": "", + "physicalblockdevice_set": [ + { + "firmware_version": "SN03", + "storage_pool": null, + "id": 11, + "system_id": "tdgqkw", + "used_for": "GPT partitioned with 1 partition", + "model": "ST1000NM0033-9ZM", + "type": "physical", + "filesystem": null, + "numa_node": 0, + "tags": [ + "ssd" + ], + "available_size": 0, + "size": 1000204886016, + "name": "sda", + "id_path": "/dev/disk/by-id/wwn-0x5000c50066898892", + "uuid": null, + "serial": "Z1W1QQ4T", + "block_size": 512, + "partitions": [ + { + "uuid": "32fc769e-2f84-4db6-8d06-3c0b6ef4282a", + "size": 1000194703360, + "bootable": false, + "tags": [], + "system_id": "tdgqkw", + "device_id": 11, + "used_for": "ext4 formatted filesystem mounted at /", + "type": "partition", + "path": "/dev/disk/by-dname/sda-part2", + "filesystem": { + "fstype": "ext4", + "label": "root", + "uuid": "bc9577af-b6a9-4eb7-95bf-887300365bc9", + "mount_point": "/", + "mount_options": null + }, + "id": 7, + "resource_uri": "/MAAS/api/2.0/nodes/tdgqkw/blockdevices/11/partition/7" + } + ], + "path": "/dev/disk/by-dname/sda", + "used_size": 1000200994816, + "partition_table_type": "GPT", + "resource_uri": "/MAAS/api/2.0/nodes/tdgqkw/blockdevices/11/" + }, + { + "firmware_version": "SN03", + "storage_pool": null, + "id": 12, + "system_id": "tdgqkw", + "used_for": "Unused", + "model": "ST1000NM0033-9ZM", + "type": "physical", + "filesystem": null, + "numa_node": 0, + "tags": [ + "ssd" + ], + "available_size": 1000204886016, + "size": 1000204886016, + "name": "sdb", + "id_path": "/dev/disk/by-id/wwn-0x5000c5006689ae3f", + "uuid": null, + "serial": "Z1W1QJMW", + "block_size": 512, + "partitions": [], + "path": "/dev/disk/by-dname/sdb", + "used_size": 0, + "partition_table_type": null, + "resource_uri": "/MAAS/api/2.0/nodes/tdgqkw/blockdevices/12/" + } + ], + "interface_test_status_name": "Unknown", + "boot_interface": { + "params": "", + "interface_speed": 1000, + "vendor": "Intel Corporation", + "enabled": true, + "id": 16, + "sriov_max_vf": 7, + "effective_mtu": 1500, + "system_id": "tdgqkw", + "type": "physical", + "vlan": { + "vid": 0, + "mtu": 1500, + "dhcp_on": true, + "external_dhcp": null, + "relay_vlan": null, + "secondary_rack": null, + "fabric": "fabric-1", + "fabric_id": 1, + "primary_rack": "67mdw3", + "name": "untagged", + "space": "undefined", + "id": 5002, + "resource_uri": "/MAAS/api/2.0/vlans/5002/" + }, + "product": "82576 Gigabit Network Connection", + "discovered": [], + "links": [ + { + "id": 31, + "mode": "auto", + "subnet": { + "name": "172.20.0.0/24", + "description": "", + "vlan": { + "vid": 0, + "mtu": 1500, + "dhcp_on": true, + "external_dhcp": null, + "relay_vlan": null, + "secondary_rack": null, + "fabric": "fabric-1", + "fabric_id": 1, + "primary_rack": "67mdw3", + "name": "untagged", + "space": "undefined", + "id": 5002, + "resource_uri": "/MAAS/api/2.0/vlans/5002/" + }, + "cidr": "172.20.0.0/24", + "rdns_mode": 2, + "gateway_ip": "172.20.0.1", + "dns_servers": [], + "allow_dns": true, + "allow_proxy": true, + "active_discovery": false, + "managed": true, + "space": "undefined", + "id": 2, + "resource_uri": "/MAAS/api/2.0/subnets/2/" + } + } + ], + "numa_node": 0, + "tags": [ + "sriov" + ], + "name": "enp1s0f0", + "mac_address": "cb:d5:c9:f7:78:04", + "firmware_version": "1.2.3", + "parents": [], + "children": [], + "link_connected": true, + "link_speed": 100, + "resource_uri": "/MAAS/api/2.0/nodes/tdgqkw/interfaces/16/" + }, + "volume_groups": [], + "storage_test_status_name": "Passed", + "tag_names": [ + "yorc" + ], + "status_message": "Released", + "hardware_info": { + "system_vendor": "Bull SAS", + "system_product": "bullx", + "system_family": "Server", + "system_version": "R422-E2", + "system_sku": "R4222X80", + "system_serial": "1234567890", + "cpu_model": "Intel(R) Xeon(R) CPU X5570 ", + "mainboard_vendor": "Supermicro", + "mainboard_product": "X8DTT", + "mainboard_serial": "1234567890", + "mainboard_version": "1.00", + "mainboard_firmware_vendor": "American Megatrends Inc.", + "mainboard_firmware_date": "05/20/2010", + "mainboard_firmware_version": "R4222X80", + "chassis_vendor": "Supermicro", + "chassis_type": "Main Server Chassis", + "chassis_serial": "1234567890.", + "chassis_version": "1234567890" + }, + "special_filesystems": [], + "cpu_test_status_name": "Unknown", + "current_commissioning_result_id": 6, + "constraints_by_type": { + "storage": { + "label": [ + 11 + ] + } + }, + "memory": 12288, + "status": 10, + "virtualblockdevice_set": [], + "hardware_uuid": "1d030221-ce00-d553-d522-003048c6f252", + "pool": { + "name": "default", + "description": "Default pool", + "id": 0, + "resource_uri": "/MAAS/api/2.0/resourcepool/0/" + }, + "architecture": "amd64/generic", + "iscsiblockdevice_set": [], + "current_testing_result_id": 22, + "memory_test_status": -1, + "power_state": "off", + "bcaches": [], + "numanode_set": [ + { + "index": 0, + "memory": 7963, + "cores": [ + 0, + 1, + 2, + 3 + ], + "hugepages_set": [] + }, + { + "index": 1, + "memory": 4028, + "cores": [ + 4, + 5, + 6, + 7 + ], + "hugepages_set": [] + } + ], + "power_type": "ipmi", + "fqdn": "alert-buck.maas", + "cache_sets": [], + "testing_status": 2, + "current_installation_result_id": null, + "default_gateways": { + "ipv4": { + "gateway_ip": "172.20.0.1", + "link_id": null + }, + "ipv6": { + "gateway_ip": null, + "link_id": null + } + }, + "zone": { + "name": "default", + "description": "", + "id": 1, + "resource_uri": "/MAAS/api/2.0/zones/default/" + }, + "boot_disk": { + "firmware_version": "SN03", + "storage_pool": null, + "id": 11, + "system_id": "tdgqkw", + "used_for": "GPT partitioned with 1 partition", + "model": "ST1000NM0033-9ZM", + "type": "physical", + "filesystem": null, + "numa_node": 0, + "tags": [ + "ssd" + ], + "available_size": 0, + "size": 1000204886016, + "name": "sda", + "id_path": "/dev/disk/by-id/wwn-0x5000c50066898892", + "uuid": null, + "serial": "Z1W1QQ4T", + "block_size": 512, + "partitions": [ + { + "uuid": "32fc769e-2f84-4db6-8d06-3c0b6ef4282a", + "size": 1000194703360, + "bootable": false, + "tags": [], + "system_id": "tdgqkw", + "device_id": 11, + "used_for": "ext4 formatted filesystem mounted at /", + "type": "partition", + "path": "/dev/disk/by-dname/sda-part2", + "filesystem": { + "fstype": "ext4", + "label": "root", + "uuid": "bc9577af-b6a9-4eb7-95bf-887300365bc9", + "mount_point": "/", + "mount_options": null + }, + "id": 7, + "resource_uri": "/MAAS/api/2.0/nodes/tdgqkw/blockdevices/11/partition/7" + } + ], + "path": "/dev/disk/by-dname/sda", + "used_size": 1000200994816, + "partition_table_type": "GPT", + "resource_uri": "/MAAS/api/2.0/nodes/tdgqkw/blockdevices/11/" + }, + "status_name": "Allocated", + "domain": { + "authoritative": true, + "ttl": null, + "is_default": true, + "resource_record_count": 3, + "name": "maas", + "id": 0, + "resource_uri": "/MAAS/api/2.0/domains/0/" + }, + "description": "", + "swap_size": null, + "other_test_status": -1, + "testing_status_name": "Passed", + "cpu_test_status": -1, + "resource_uri": "/MAAS/api/2.0/machines/tdgqkw/" +} +` + +var deployResponse = ` +{ + "physicalblockdevice_set": [ + { + "firmware_version": "SN03", + "system_id": "tdgqkw", + "used_for": "GPT partitioned with 1 partition", + "path": "/dev/disk/by-dname/sda", + "available_size": 0, + "type": "physical", + "tags": [ + "ssd" + ], + "partition_table_type": "GPT", + "model": "ST1000NM0033-9ZM", + "name": "sda", + "filesystem": null, + "id_path": "/dev/disk/by-id/wwn-0x5000c50066898892", + "used_size": 1000200994816, + "partitions": [ + { + "uuid": "32fc769e-2f84-4db6-8d06-3c0b6ef4282a", + "size": 1000194703360, + "bootable": false, + "tags": [], + "path": "/dev/disk/by-dname/sda-part2", + "filesystem": { + "fstype": "ext4", + "label": "root", + "uuid": "bc9577af-b6a9-4eb7-95bf-887300365bc9", + "mount_point": "/", + "mount_options": null + }, + "system_id": "tdgqkw", + "type": "partition", + "id": 7, + "device_id": 11, + "used_for": "ext4 formatted filesystem mounted at /", + "resource_uri": "/MAAS/api/2.0/nodes/tdgqkw/blockdevices/11/partition/7" + } + ], + "serial": "Z1W1QQ4T", + "block_size": 512, + "uuid": null, + "size": 1000204886016, + "id": 11, + "numa_node": 0, + "storage_pool": null, + "resource_uri": "/MAAS/api/2.0/nodes/tdgqkw/blockdevices/11/" + }, + { + "firmware_version": "SN03", + "system_id": "tdgqkw", + "used_for": "Unused", + "path": "/dev/disk/by-dname/sdb", + "available_size": 1000204886016, + "type": "physical", + "tags": [ + "ssd" + ], + "partition_table_type": null, + "model": "ST1000NM0033-9ZM", + "name": "sdb", + "filesystem": null, + "id_path": "/dev/disk/by-id/wwn-0x5000c5006689ae3f", + "used_size": 0, + "partitions": [], + "serial": "Z1W1QJMW", + "block_size": 512, + "uuid": null, + "size": 1000204886016, + "id": 12, + "numa_node": 0, + "storage_pool": null, + "resource_uri": "/MAAS/api/2.0/nodes/tdgqkw/blockdevices/12/" + } + ], + "system_id": "tdgqkw", + "other_test_status": -1, + "power_type": "ipmi", + "network_test_status_name": "Unknown", + "memory_test_status_name": "Unknown", + "network_test_status": -1, + "boot_interface": { + "link_connected": true, + "system_id": "tdgqkw", + "params": "", + "links": [ + { + "id": 31, + "mode": "auto", + "subnet": { + "name": "172.20.0.0/24", + "description": "", + "vlan": { + "vid": 0, + "mtu": 1500, + "dhcp_on": true, + "external_dhcp": null, + "relay_vlan": null, + "secondary_rack": null, + "primary_rack": "67mdw3", + "fabric": "fabric-1", + "id": 5002, + "space": "undefined", + "name": "untagged", + "fabric_id": 1, + "resource_uri": "/MAAS/api/2.0/vlans/5002/" + }, + "cidr": "172.20.0.0/24", + "rdns_mode": 2, + "gateway_ip": "172.20.0.1", + "dns_servers": [], + "allow_dns": true, + "allow_proxy": true, + "active_discovery": false, + "managed": true, + "id": 2, + "space": "undefined", + "resource_uri": "/MAAS/api/2.0/subnets/2/" + } + } + ], + "type": "physical", + "mac_address": "cb:d5:c9:f7:78:04", + "sriov_max_vf": 7, + "tags": [ + "sriov" + ], + "children": [], + "firmware_version": "1.2.3", + "name": "enp1s0f0", + "effective_mtu": 1500, + "enabled": true, + "link_speed": 100, + "discovered": [], + "vlan": { + "vid": 0, + "mtu": 1500, + "dhcp_on": true, + "external_dhcp": null, + "relay_vlan": null, + "secondary_rack": null, + "primary_rack": "67mdw3", + "fabric": "fabric-1", + "id": 5002, + "space": "undefined", + "name": "untagged", + "fabric_id": 1, + "resource_uri": "/MAAS/api/2.0/vlans/5002/" + }, + "vendor": "Intel Corporation", + "interface_speed": 1000, + "id": 16, + "parents": [], + "numa_node": 0, + "product": "82576 Gigabit Network Connection", + "resource_uri": "/MAAS/api/2.0/nodes/tdgqkw/interfaces/16/" + }, + "address_ttl": null, + "tag_names": [ + "yorc" + ], + "locked": false, + "memory": 12288, + "current_installation_result_id": 143, + "domain": { + "authoritative": true, + "ttl": null, + "is_default": true, + "id": 0, + "resource_record_count": 3, + "name": "maas", + "resource_uri": "/MAAS/api/2.0/domains/0/" + }, + "virtualmachine_id": null, + "description": "", + "current_testing_result_id": 22, + "storage_test_status_name": "Passed", + "min_hwe_kernel": "", + "bcaches": [], + "memory_test_status": -1, + "architecture": "amd64/generic", + "status": 9, + "pool": { + "name": "default", + "description": "Default pool", + "id": 0, + "resource_uri": "/MAAS/api/2.0/resourcepool/0/" + }, + "iscsiblockdevice_set": [], + "raids": [], + "status_message": "Deploying", + "swap_size": null, + "testing_status": 2, + "storage": 2000409.7720320001, + "osystem": "ubuntu", + "boot_disk": { + "firmware_version": "SN03", + "system_id": "tdgqkw", + "used_for": "GPT partitioned with 1 partition", + "path": "/dev/disk/by-dname/sda", + "available_size": 0, + "type": "physical", + "tags": [ + "ssd" + ], + "partition_table_type": "GPT", + "model": "ST1000NM0033-9ZM", + "name": "sda", + "filesystem": null, + "id_path": "/dev/disk/by-id/wwn-0x5000c50066898892", + "used_size": 1000200994816, + "partitions": [ + { + "uuid": "32fc769e-2f84-4db6-8d06-3c0b6ef4282a", + "size": 1000194703360, + "bootable": false, + "tags": [], + "path": "/dev/disk/by-dname/sda-part2", + "filesystem": { + "fstype": "ext4", + "label": "root", + "uuid": "bc9577af-b6a9-4eb7-95bf-887300365bc9", + "mount_point": "/", + "mount_options": null + }, + "system_id": "tdgqkw", + "type": "partition", + "id": 7, + "device_id": 11, + "used_for": "ext4 formatted filesystem mounted at /", + "resource_uri": "/MAAS/api/2.0/nodes/tdgqkw/blockdevices/11/partition/7" + } + ], + "serial": "Z1W1QQ4T", + "block_size": 512, + "uuid": null, + "size": 1000204886016, + "id": 11, + "numa_node": 0, + "storage_pool": null, + "resource_uri": "/MAAS/api/2.0/nodes/tdgqkw/blockdevices/11/" + }, + "power_state": "off", + "special_filesystems": [], + "volume_groups": [], + "commissioning_status_name": "Passed", + "hwe_kernel": "ga-20.04", + "netboot": true, + "blockdevice_set": [ + { + "id_path": "/dev/disk/by-id/wwn-0x5000c50066898892", + "size": 1000204886016, + "block_size": 512, + "tags": [ + "ssd" + ], + "system_id": "tdgqkw", + "used_for": "GPT partitioned with 1 partition", + "path": "/dev/disk/by-dname/sda", + "available_size": 0, + "type": "physical", + "partition_table_type": "GPT", + "model": "ST1000NM0033-9ZM", + "name": "sda", + "filesystem": null, + "used_size": 1000200994816, + "partitions": [ + { + "uuid": "32fc769e-2f84-4db6-8d06-3c0b6ef4282a", + "size": 1000194703360, + "bootable": false, + "tags": [], + "path": "/dev/disk/by-dname/sda-part2", + "filesystem": { + "fstype": "ext4", + "label": "root", + "uuid": "bc9577af-b6a9-4eb7-95bf-887300365bc9", + "mount_point": "/", + "mount_options": null + }, + "system_id": "tdgqkw", + "type": "partition", + "id": 7, + "device_id": 11, + "used_for": "ext4 formatted filesystem mounted at /", + "resource_uri": "/MAAS/api/2.0/nodes/tdgqkw/blockdevices/11/partition/7" + } + ], + "serial": "Z1W1QQ4T", + "uuid": null, + "id": 11, + "numa_node": 0, + "storage_pool": null, + "resource_uri": "/MAAS/api/2.0/nodes/tdgqkw/blockdevices/11/" + }, + { + "id_path": "/dev/disk/by-id/wwn-0x5000c5006689ae3f", + "size": 1000204886016, + "block_size": 512, + "tags": [ + "ssd" + ], + "system_id": "tdgqkw", + "used_for": "Unused", + "path": "/dev/disk/by-dname/sdb", + "available_size": 1000204886016, + "type": "physical", + "partition_table_type": null, + "model": "ST1000NM0033-9ZM", + "name": "sdb", + "filesystem": null, + "used_size": 0, + "partitions": [], + "serial": "Z1W1QJMW", + "uuid": null, + "id": 12, + "numa_node": 0, + "storage_pool": null, + "resource_uri": "/MAAS/api/2.0/nodes/tdgqkw/blockdevices/12/" + } + ], + "cpu_count": 8, + "pod": null, + "ip_addresses": [], + "node_type": 0, + "distro_series": "focal", + "current_commissioning_result_id": 6, + "fqdn": "alert-buck.maas", + "owner_data": {}, + "virtualblockdevice_set": [], + "default_gateways": { + "ipv4": { + "gateway_ip": "172.20.0.1", + "link_id": null + }, + "ipv6": { + "gateway_ip": null, + "link_id": null + } + }, + "cpu_test_status_name": "Unknown", + "hostname": "alert-buck", + "interface_test_status": -1, + "cpu_speed": 2930, + "status_action": "", + "hardware_info": { + "system_vendor": "Bull SAS", + "system_product": "bullx", + "system_family": "Server", + "system_version": "R422-E2", + "system_sku": "R4222X80", + "system_serial": "1234567890", + "cpu_model": "Intel(R) Xeon(R) CPU X5570 ", + "mainboard_vendor": "Supermicro", + "mainboard_product": "X8DTT", + "mainboard_serial": "1234567890", + "mainboard_version": "1.00", + "mainboard_firmware_vendor": "American Megatrends Inc.", + "mainboard_firmware_date": "05/20/2010", + "mainboard_firmware_version": "R4222X80", + "chassis_vendor": "Supermicro", + "chassis_type": "Main Server Chassis", + "chassis_serial": "1234567890.", + "chassis_version": "1234567890" + }, + "owner": "jim", + "interface_set": [ + { + "link_connected": true, + "system_id": "tdgqkw", + "params": "", + "links": [ + { + "id": 31, + "mode": "auto", + "subnet": { + "name": "172.20.0.0/24", + "description": "", + "vlan": { + "vid": 0, + "mtu": 1500, + "dhcp_on": true, + "external_dhcp": null, + "relay_vlan": null, + "secondary_rack": null, + "primary_rack": "67mdw3", + "fabric": "fabric-1", + "id": 5002, + "space": "undefined", + "name": "untagged", + "fabric_id": 1, + "resource_uri": "/MAAS/api/2.0/vlans/5002/" + }, + "cidr": "172.20.0.0/24", + "rdns_mode": 2, + "gateway_ip": "172.20.0.1", + "dns_servers": [], + "allow_dns": true, + "allow_proxy": true, + "active_discovery": false, + "managed": true, + "id": 2, + "space": "undefined", + "resource_uri": "/MAAS/api/2.0/subnets/2/" + } + } + ], + "type": "physical", + "mac_address": "cb:d5:c9:f7:78:04", + "sriov_max_vf": 7, + "tags": [ + "sriov" + ], + "children": [], + "firmware_version": "1.2.3", + "name": "enp1s0f0", + "effective_mtu": 1500, + "enabled": true, + "link_speed": 100, + "discovered": [], + "vlan": { + "vid": 0, + "mtu": 1500, + "dhcp_on": true, + "external_dhcp": null, + "relay_vlan": null, + "secondary_rack": null, + "primary_rack": "67mdw3", + "fabric": "fabric-1", + "id": 5002, + "space": "undefined", + "name": "untagged", + "fabric_id": 1, + "resource_uri": "/MAAS/api/2.0/vlans/5002/" + }, + "vendor": "Intel Corporation", + "interface_speed": 1000, + "id": 16, + "parents": [], + "numa_node": 0, + "product": "82576 Gigabit Network Connection", + "resource_uri": "/MAAS/api/2.0/nodes/tdgqkw/interfaces/16/" + }, + { + "link_connected": true, + "system_id": "tdgqkw", + "params": "", + "links": [], + "type": "physical", + "mac_address": "cb:d5:c9:f7:78:04", + "sriov_max_vf": 7, + "tags": [ + "sriov" + ], + "children": [], + "firmware_version": "1.2.3", + "name": "enp1s0f1", + "effective_mtu": 1500, + "enabled": true, + "link_speed": 0, + "discovered": null, + "vlan": null, + "vendor": "Intel Corporation", + "interface_speed": 1000, + "id": 18, + "parents": [], + "numa_node": 0, + "product": "82576 Gigabit Network Connection", + "resource_uri": "/MAAS/api/2.0/nodes/tdgqkw/interfaces/18/" + } + ], + "commissioning_status": 2, + "zone": { + "name": "default", + "description": "", + "id": 1, + "resource_uri": "/MAAS/api/2.0/zones/default/" + }, + "node_type_name": "Machine", + "interface_test_status_name": "Unknown", + "bios_boot_method": "pxe", + "status_name": "Deploying", + "cache_sets": [], + "disable_ipv4": false, + "storage_test_status": 2, + "hardware_uuid": "1d030221-ce00-d553-d522-003048c6f252", + "testing_status_name": "Passed", + "cpu_test_status": -1, + "numanode_set": [ + { + "index": 0, + "memory": 7963, + "cores": [ + 0, + 1, + 2, + 3 + ], + "hugepages_set": [] + }, + { + "index": 1, + "memory": 4028, + "cores": [ + 4, + 5, + 6, + 7 + ], + "hugepages_set": [] + } + ], + "other_test_status_name": "Unknown", + "resource_uri": "/MAAS/api/2.0/machines/tdgqkw/" +} +` + +var machineDeployed = ` +{ + "hostname": "alert-buck", + "distro_series": "focal", + "address_ttl": null, + "network_test_status": -1, + "ip_addresses": [ + "172.20.0.114" + ], + "other_test_status_name": "Unknown", + "memory_test_status_name": "Unknown", + "cpu_count": 8, + "hwe_kernel": "ga-20.04", + "storage_test_status": 2, + "node_type_name": "Machine", + "commissioning_status": 2, + "virtualmachine_id": null, + "status_action": "", + "bios_boot_method": "pxe", + "netboot": false, + "interface_set": [ + { + "params": "", + "interface_speed": 1000, + "vendor": "Intel Corporation", + "enabled": true, + "id": 16, + "sriov_max_vf": 7, + "effective_mtu": 1500, + "system_id": "tdgqkw", + "type": "physical", + "vlan": { + "vid": 0, + "mtu": 1500, + "dhcp_on": true, + "external_dhcp": null, + "relay_vlan": null, + "secondary_rack": null, + "fabric": "fabric-1", + "fabric_id": 1, + "primary_rack": "67mdw3", + "name": "untagged", + "space": "undefined", + "id": 5002, + "resource_uri": "/MAAS/api/2.0/vlans/5002/" + }, + "product": "82576 Gigabit Network Connection", + "discovered": [], + "links": [ + { + "id": 31, + "mode": "auto", + "ip_address": "172.20.0.114", + "subnet": { + "name": "172.20.0.0/24", + "description": "", + "vlan": { + "vid": 0, + "mtu": 1500, + "dhcp_on": true, + "external_dhcp": null, + "relay_vlan": null, + "secondary_rack": null, + "fabric": "fabric-1", + "fabric_id": 1, + "primary_rack": "67mdw3", + "name": "untagged", + "space": "undefined", + "id": 5002, + "resource_uri": "/MAAS/api/2.0/vlans/5002/" + }, + "cidr": "172.20.0.0/24", + "rdns_mode": 2, + "gateway_ip": "172.20.0.1", + "dns_servers": [], + "allow_dns": true, + "allow_proxy": true, + "active_discovery": false, + "managed": true, + "space": "undefined", + "id": 2, + "resource_uri": "/MAAS/api/2.0/subnets/2/" + } + } + ], + "numa_node": 0, + "tags": [ + "sriov" + ], + "name": "enp1s0f0", + "mac_address": "cb:d5:c9:f7:78:04", + "firmware_version": "1.2.3", + "parents": [], + "children": [], + "link_connected": true, + "link_speed": 100, + "resource_uri": "/MAAS/api/2.0/nodes/tdgqkw/interfaces/16/" + }, + { + "params": "", + "interface_speed": 1000, + "vendor": "Intel Corporation", + "enabled": true, + "id": 18, + "sriov_max_vf": 7, + "effective_mtu": 1500, + "system_id": "tdgqkw", + "type": "physical", + "vlan": null, + "product": "82576 Gigabit Network Connection", + "discovered": null, + "links": [], + "numa_node": 0, + "tags": [ + "sriov" + ], + "name": "enp1s0f1", + "mac_address": "cb:d5:c9:f7:78:04", + "firmware_version": "1.2.3", + "parents": [], + "children": [], + "link_connected": true, + "link_speed": 0, + "resource_uri": "/MAAS/api/2.0/nodes/tdgqkw/interfaces/18/" + } + ], + "network_test_status_name": "Unknown", + "pod": null, + "disable_ipv4": false, + "blockdevice_set": [ + { + "id_path": "/dev/disk/by-id/wwn-0x5000c50066898892", + "size": 1000204886016, + "block_size": 512, + "tags": [ + "ssd" + ], + "storage_pool": null, + "id": 11, + "system_id": "tdgqkw", + "used_for": "GPT partitioned with 1 partition", + "model": "ST1000NM0033-9ZM", + "type": "physical", + "filesystem": null, + "numa_node": 0, + "available_size": 0, + "name": "sda", + "uuid": null, + "serial": "Z1W1QQ4T", + "partitions": [ + { + "uuid": "32fc769e-2f84-4db6-8d06-3c0b6ef4282a", + "size": 1000194703360, + "bootable": false, + "tags": [], + "system_id": "tdgqkw", + "device_id": 11, + "used_for": "ext4 formatted filesystem mounted at /", + "type": "partition", + "path": "/dev/disk/by-dname/sda-part2", + "filesystem": { + "fstype": "ext4", + "label": "root", + "uuid": "bc9577af-b6a9-4eb7-95bf-887300365bc9", + "mount_point": "/", + "mount_options": null + }, + "id": 7, + "resource_uri": "/MAAS/api/2.0/nodes/tdgqkw/blockdevices/11/partition/7" + } + ], + "path": "/dev/disk/by-dname/sda", + "used_size": 1000200994816, + "partition_table_type": "GPT", + "resource_uri": "/MAAS/api/2.0/nodes/tdgqkw/blockdevices/11/" + }, + { + "id_path": "/dev/disk/by-id/wwn-0x5000c5006689ae3f", + "size": 1000204886016, + "block_size": 512, + "tags": [ + "ssd" + ], + "storage_pool": null, + "id": 12, + "system_id": "tdgqkw", + "used_for": "Unused", + "model": "ST1000NM0033-9ZM", + "type": "physical", + "filesystem": null, + "numa_node": 0, + "available_size": 1000204886016, + "name": "sdb", + "uuid": null, + "serial": "Z1W1QJMW", + "partitions": [], + "path": "/dev/disk/by-dname/sdb", + "used_size": 0, + "partition_table_type": null, + "resource_uri": "/MAAS/api/2.0/nodes/tdgqkw/blockdevices/12/" + } + ], + "node_type": 0, + "commissioning_status_name": "Passed", + "interface_test_status": -1, + "storage": 2000409.7720320001, + "owner_data": {}, + "owner": "jim", + "system_id": "tdgqkw", + "raids": [], + "min_hwe_kernel": "", + "cpu_speed": 2930, + "locked": false, + "osystem": "ubuntu", + "physicalblockdevice_set": [ + { + "firmware_version": "SN03", + "storage_pool": null, + "id": 11, + "system_id": "tdgqkw", + "used_for": "GPT partitioned with 1 partition", + "model": "ST1000NM0033-9ZM", + "type": "physical", + "filesystem": null, + "numa_node": 0, + "tags": [ + "ssd" + ], + "available_size": 0, + "size": 1000204886016, + "name": "sda", + "id_path": "/dev/disk/by-id/wwn-0x5000c50066898892", + "uuid": null, + "serial": "Z1W1QQ4T", + "block_size": 512, + "partitions": [ + { + "uuid": "32fc769e-2f84-4db6-8d06-3c0b6ef4282a", + "size": 1000194703360, + "bootable": false, + "tags": [], + "system_id": "tdgqkw", + "device_id": 11, + "used_for": "ext4 formatted filesystem mounted at /", + "type": "partition", + "path": "/dev/disk/by-dname/sda-part2", + "filesystem": { + "fstype": "ext4", + "label": "root", + "uuid": "bc9577af-b6a9-4eb7-95bf-887300365bc9", + "mount_point": "/", + "mount_options": null + }, + "id": 7, + "resource_uri": "/MAAS/api/2.0/nodes/tdgqkw/blockdevices/11/partition/7" + } + ], + "path": "/dev/disk/by-dname/sda", + "used_size": 1000200994816, + "partition_table_type": "GPT", + "resource_uri": "/MAAS/api/2.0/nodes/tdgqkw/blockdevices/11/" + }, + { + "firmware_version": "SN03", + "storage_pool": null, + "id": 12, + "system_id": "tdgqkw", + "used_for": "Unused", + "model": "ST1000NM0033-9ZM", + "type": "physical", + "filesystem": null, + "numa_node": 0, + "tags": [ + "ssd" + ], + "available_size": 1000204886016, + "size": 1000204886016, + "name": "sdb", + "id_path": "/dev/disk/by-id/wwn-0x5000c5006689ae3f", + "uuid": null, + "serial": "Z1W1QJMW", + "block_size": 512, + "partitions": [], + "path": "/dev/disk/by-dname/sdb", + "used_size": 0, + "partition_table_type": null, + "resource_uri": "/MAAS/api/2.0/nodes/tdgqkw/blockdevices/12/" + } + ], + "interface_test_status_name": "Unknown", + "boot_interface": { + "params": "", + "interface_speed": 1000, + "vendor": "Intel Corporation", + "enabled": true, + "id": 16, + "sriov_max_vf": 7, + "effective_mtu": 1500, + "system_id": "tdgqkw", + "type": "physical", + "vlan": { + "vid": 0, + "mtu": 1500, + "dhcp_on": true, + "external_dhcp": null, + "relay_vlan": null, + "secondary_rack": null, + "fabric": "fabric-1", + "fabric_id": 1, + "primary_rack": "67mdw3", + "name": "untagged", + "space": "undefined", + "id": 5002, + "resource_uri": "/MAAS/api/2.0/vlans/5002/" + }, + "product": "82576 Gigabit Network Connection", + "discovered": [], + "links": [ + { + "id": 31, + "mode": "auto", + "ip_address": "172.20.0.114", + "subnet": { + "name": "172.20.0.0/24", + "description": "", + "vlan": { + "vid": 0, + "mtu": 1500, + "dhcp_on": true, + "external_dhcp": null, + "relay_vlan": null, + "secondary_rack": null, + "fabric": "fabric-1", + "fabric_id": 1, + "primary_rack": "67mdw3", + "name": "untagged", + "space": "undefined", + "id": 5002, + "resource_uri": "/MAAS/api/2.0/vlans/5002/" + }, + "cidr": "172.20.0.0/24", + "rdns_mode": 2, + "gateway_ip": "172.20.0.1", + "dns_servers": [], + "allow_dns": true, + "allow_proxy": true, + "active_discovery": false, + "managed": true, + "space": "undefined", + "id": 2, + "resource_uri": "/MAAS/api/2.0/subnets/2/" + } + } + ], + "numa_node": 0, + "tags": [ + "sriov" + ], + "name": "enp1s0f0", + "mac_address": "cb:d5:c9:f7:78:04", + "firmware_version": "1.2.3", + "parents": [], + "children": [], + "link_connected": true, + "link_speed": 100, + "resource_uri": "/MAAS/api/2.0/nodes/tdgqkw/interfaces/16/" + }, + "volume_groups": [], + "storage_test_status_name": "Passed", + "tag_names": [ + "yorc" + ], + "status_message": "Deployed", + "hardware_info": { + "system_vendor": "Bull SAS", + "system_product": "bullx", + "system_family": "Server", + "system_version": "R422-E2", + "system_sku": "R4222X80", + "system_serial": "1234567890", + "cpu_model": "Intel(R) Xeon(R) CPU X5570 ", + "mainboard_vendor": "Supermicro", + "mainboard_product": "X8DTT", + "mainboard_serial": "1234567890", + "mainboard_version": "1.00", + "mainboard_firmware_vendor": "American Megatrends Inc.", + "mainboard_firmware_date": "05/20/2010", + "mainboard_firmware_version": "R4222X80", + "chassis_vendor": "Supermicro", + "chassis_type": "Main Server Chassis", + "chassis_serial": "1234567890.", + "chassis_version": "1234567890" + }, + "special_filesystems": [], + "cpu_test_status_name": "Unknown", + "current_commissioning_result_id": 6, + "memory": 12288, + "status": 6, + "virtualblockdevice_set": [], + "hardware_uuid": "1d030221-ce00-d553-d522-003048c6f252", + "pool": { + "name": "default", + "description": "Default pool", + "id": 0, + "resource_uri": "/MAAS/api/2.0/resourcepool/0/" + }, + "architecture": "amd64/generic", + "iscsiblockdevice_set": [], + "current_testing_result_id": 22, + "memory_test_status": -1, + "power_state": "on", + "bcaches": [], + "numanode_set": [ + { + "index": 0, + "memory": 7963, + "cores": [ + 0, + 1, + 2, + 3 + ], + "hugepages_set": [] + }, + { + "index": 1, + "memory": 4028, + "cores": [ + 4, + 5, + 6, + 7 + ], + "hugepages_set": [] + } + ], + "power_type": "ipmi", + "fqdn": "alert-buck.maas", + "cache_sets": [], + "testing_status": 2, + "current_installation_result_id": 143, + "default_gateways": { + "ipv4": { + "gateway_ip": "172.20.0.1", + "link_id": null + }, + "ipv6": { + "gateway_ip": null, + "link_id": null + } + }, + "zone": { + "name": "default", + "description": "", + "id": 1, + "resource_uri": "/MAAS/api/2.0/zones/default/" + }, + "boot_disk": { + "firmware_version": "SN03", + "storage_pool": null, + "id": 11, + "system_id": "tdgqkw", + "used_for": "GPT partitioned with 1 partition", + "model": "ST1000NM0033-9ZM", + "type": "physical", + "filesystem": null, + "numa_node": 0, + "tags": [ + "ssd" + ], + "available_size": 0, + "size": 1000204886016, + "name": "sda", + "id_path": "/dev/disk/by-id/wwn-0x5000c50066898892", + "uuid": null, + "serial": "Z1W1QQ4T", + "block_size": 512, + "partitions": [ + { + "uuid": "32fc769e-2f84-4db6-8d06-3c0b6ef4282a", + "size": 1000194703360, + "bootable": false, + "tags": [], + "system_id": "tdgqkw", + "device_id": 11, + "used_for": "ext4 formatted filesystem mounted at /", + "type": "partition", + "path": "/dev/disk/by-dname/sda-part2", + "filesystem": { + "fstype": "ext4", + "label": "root", + "uuid": "bc9577af-b6a9-4eb7-95bf-887300365bc9", + "mount_point": "/", + "mount_options": null + }, + "id": 7, + "resource_uri": "/MAAS/api/2.0/nodes/tdgqkw/blockdevices/11/partition/7" + } + ], + "path": "/dev/disk/by-dname/sda", + "used_size": 1000200994816, + "partition_table_type": "GPT", + "resource_uri": "/MAAS/api/2.0/nodes/tdgqkw/blockdevices/11/" + }, + "status_name": "Deployed", + "domain": { + "authoritative": true, + "ttl": null, + "is_default": true, + "resource_record_count": 3, + "name": "maas", + "id": 0, + "resource_uri": "/MAAS/api/2.0/domains/0/" + }, + "description": "", + "swap_size": null, + "other_test_status": -1, + "testing_status_name": "Passed", + "cpu_test_status": -1, + "resource_uri": "/MAAS/api/2.0/machines/tdgqkw/" +} +` diff --git a/prov/maas/apiCall.go b/prov/maas/apiCall.go new file mode 100644 index 000000000..381af20e7 --- /dev/null +++ b/prov/maas/apiCall.go @@ -0,0 +1,238 @@ +// Copyright 2019 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 maas + +import ( + "fmt" + "log" + "net/url" + "strings" + "time" + + "github.com/juju/gomaasapi" + "github.com/pkg/errors" + "github.com/ystia/yorc/v4/config" +) + +var apiVersion string = "2.0" +var delayBetweenStatusCheck string = "20s" + +type allocateParams struct { + values url.Values +} +type deployParams struct { + values url.Values + system_id string +} + +type releaseParams struct { + values url.Values + system_id string +} + +type deployResults struct { + ips []string + system_id string +} + +func newAllocateParams(num_cpus, RAM, arch, storage, tags, not_tags string) *allocateParams { + values := url.Values{ + "cpu_count": {num_cpus}, + "mem": {RAM}, + "arch": {arch}, + "storage": {storage}, + "tags": {tags}, + "not_tags": {not_tags}, + } + return &allocateParams{ + values: values, + } +} + +func newDeployParams(distro_series string) *deployParams { + values := url.Values{ + "distro_series": {distro_series}, + } + return &deployParams{ + values: values, + } +} + +func newReleaseParams(erase, secure_erase, quick_erase string) *releaseParams { + values := url.Values{ + "erase": {erase}, + "secure_erase": {secure_erase}, + "quick_erase": {quick_erase}, + } + return &releaseParams{ + values: values, + } +} + +func getMaasClient(locationProps config.DynamicMap) (*gomaasapi.MAASObject, error) { + // Check mandatory maas configuration + if err := checkLocationConfig(locationProps); err != nil { + log.Printf("Unable to provide maas client due to:%+v", err) + return nil, err + } + + apiURL := locationProps.GetString("api_url") + apiKey := locationProps.GetString("api_key") + + stringDelay := locationProps.GetString("delayBetweenStatusCheck") + if stringDelay != "" { + delayBetweenStatusCheck = stringDelay + } + + authClient, err := gomaasapi.NewAuthenticatedClient(gomaasapi.AddAPIVersionToURL(apiURL, apiVersion), apiKey) + if err != nil { + return nil, err + } + + maas := gomaasapi.NewMAAS(*authClient) + + return maas, nil +} + +func checkLocationConfig(locationProps config.DynamicMap) error { + if strings.Trim(locationProps.GetString("api_url"), "") == "" { + return errors.New("maas api_url is not set") + } + + if strings.Trim(locationProps.GetString("api_key"), "") == "" { + return errors.New("maas api key is not set") + } + return nil +} + +// func getMachines(maas *gomaasapi.MAASObject) []byte { +// machineListing := maas.GetSubObject("machines") +// machines, err := machineListing.CallGet("", url.Values{}) +// json, err := machines.MarshalJSON() +// return json +// } + +func allocateMachine(maas *gomaasapi.MAASObject, allocateParams *allocateParams) (string, error) { + + machineListing := maas.GetSubObject("machines") + machineJsonObj, err := machineListing.CallPost("allocate", allocateParams.values) + if err != nil { + return "", err + } + + machineMaasObj, err := machineJsonObj.GetMAASObject() + if err != nil { + return "", err + } + + system_id, err := machineMaasObj.GetField("system_id") + if err != nil { + return "", err + } + + return system_id, nil +} + +func deploy(maas *gomaasapi.MAASObject, deployParams *deployParams) (*gomaasapi.JSONObject, error) { + machineListing := maas.GetSubObject("machines/" + deployParams.system_id) + machineJsonObj, err := machineListing.CallPost("deploy", deployParams.values) + + if err != nil { + return nil, err + } + + return &machineJsonObj, nil +} + +func release(maas *gomaasapi.MAASObject, releaseParams *releaseParams) error { + machineListing := maas.GetSubObject("machines/" + releaseParams.system_id) + _, err := machineListing.CallPost("release", releaseParams.values) + if err != nil { + return err + } + + return nil +} + +func getMachineInfo(maas *gomaasapi.MAASObject, systemId string) (*gomaasapi.JSONObject, error) { + machineListing := maas.GetSubObject("machines/" + systemId) + jsonObj, err := machineListing.CallGet("", url.Values{}) + if err != nil { + return nil, err + } + return &jsonObj, nil +} + +func allocateAndDeploy(maas *gomaasapi.MAASObject, allocateParams *allocateParams, deployParams *deployParams) (*deployResults, error) { + system_id, err := allocateMachine(maas, allocateParams) + if err != nil { + return nil, fmt.Errorf("failed to allocate machine: %w", err) + } + deployParams.system_id = system_id + + _, err = deploy(maas, deployParams) + if err != nil { + return nil, err + } + + // Wait for the node to finish deploying + duration, err := time.ParseDuration(delayBetweenStatusCheck) + if err != nil { + return nil, err + } + var deployRes gomaasapi.MAASObject + for { + time.Sleep(duration) + + json, err := getMachineInfo(maas, system_id) + if err != nil { + return nil, err + } + deployRes, err = json.GetMAASObject() + if err != nil { + return nil, err + } + status, err := deployRes.GetField("status_name") + if err != nil { + return nil, err + } + if status != "Deploying" { + break + } + } + + // Get machines ips + test := deployRes.GetMap() + ipaddrObj := test["ip_addresses"] + + ipsAddr, err := ipaddrObj.GetArray() + if err != nil { + return nil, err + } + + var ips []string + for _, ipObj := range ipsAddr { + ipString, err := ipObj.GetString() + if err != nil { + return nil, errors.Wrapf(err, "Failed getting ips from machines with system_id : %s", system_id) + } + ips = append(ips, ipString) + } + + return &deployResults{ + ips: ips, + system_id: system_id, + }, nil +} diff --git a/prov/maas/executor.go b/prov/maas/executor.go new file mode 100644 index 000000000..7e74c9107 --- /dev/null +++ b/prov/maas/executor.go @@ -0,0 +1,177 @@ +// 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 maas + +import ( + "context" + "strings" + + "github.com/pkg/errors" + "github.com/ystia/yorc/v4/config" + "github.com/ystia/yorc/v4/deployments" + "github.com/ystia/yorc/v4/events" + "github.com/ystia/yorc/v4/locations" + "github.com/ystia/yorc/v4/log" + "github.com/ystia/yorc/v4/tasks" + "github.com/ystia/yorc/v4/tosca" + "golang.org/x/sync/errgroup" +) + +const infrastructureType = "maas" + +type defaultExecutor struct { +} + +type operationParameters struct { + locationProps config.DynamicMap + taskID string + deploymentID string + nodeName string + delegateOperation string + instances []string +} + +// ExecDelegate : Get required operation params and call the operation +func (e *defaultExecutor) ExecDelegate(ctx context.Context, cfg config.Configuration, taskID, deploymentID, nodeName, delegateOperation string) error { + // Get locations props + var locationProps config.DynamicMap + locationMgr, err := locations.GetManager(cfg) + if err == nil { + locationProps, err = locationMgr.GetLocationPropertiesForNode(ctx, deploymentID, nodeName, infrastructureType) + } + if err != nil { + return err + } + + // Get instances names + instances, err := tasks.GetInstances(ctx, taskID, deploymentID, nodeName) + if err != nil { + return err + } + + // Apply operation + operationParams := operationParameters{ + locationProps: locationProps, + taskID: taskID, + deploymentID: deploymentID, + nodeName: nodeName, + delegateOperation: delegateOperation, + instances: instances, + } + + operation := strings.ToLower(delegateOperation) + switch { + case operation == "install": + err = e.installNode(ctx, &operationParams) + case operation == "uninstall": + err = e.uninstallNode(ctx, &operationParams) + default: + return errors.Errorf("Unsupported operation %q", delegateOperation) + } + return err +} + +func (e *defaultExecutor) installNode(ctx context.Context, operationParams *operationParameters) error { + log.Debugf("Installing node %s for deployment %s", operationParams.nodeName, operationParams.deploymentID) + + // Verify node Type + nodeType, err := deployments.GetNodeType(ctx, operationParams.deploymentID, operationParams.nodeName) + if err != nil { + return err + } + if nodeType != "yorc.nodes.maas.Compute" { + return errors.Errorf("Unsupported node type '%s' for node '%s' in deployment '%s'", nodeType, operationParams.nodeName, operationParams.deploymentID) + } + + compute, err := getComputeFromDeployment(ctx, operationParams) + + if err != nil { + return errors.Wrapf(err, "Failed to get Compute properties for deploymentID:%q, node name:%s", operationParams.deploymentID, operationParams.nodeName) + } + + var g errgroup.Group + for _, instance := range operationParams.instances { + instanceState, err := deployments.GetInstanceState(ctx, operationParams.deploymentID, operationParams.nodeName, instance) + if err != nil { + return err + } + + // If instance creating or deleting, ignore it + if instanceState == tosca.NodeStateCreating || instanceState == tosca.NodeStateDeleting { + continue + } + + func(ctx context.Context, comp *maasCompute) { + g.Go(func() error { + return compute.deploy(ctx, operationParams, instance) + }) + }(events.AddLogOptionalFields(ctx, events.LogOptionalFields{events.InstanceID: instance}), compute) + } + + if err := g.Wait(); err != nil { + err = errors.Wrapf(err, "Failed install node deploymentID:%q, node name:%s", operationParams.deploymentID, operationParams.nodeName) + log.Debugf("%+v", err) + events.WithContextOptionalFields(ctx).NewLogEntry(events.LogLevelERROR, operationParams.deploymentID).RegisterAsString(err.Error()) + return err + } + + return nil +} + +func (e *defaultExecutor) uninstallNode(ctx context.Context, operationParams *operationParameters) error { + log.Debugf("Uninstalling node %s for deployment %s", operationParams.nodeName, operationParams.deploymentID) + + // Verify node Type + nodeType, err := deployments.GetNodeType(ctx, operationParams.deploymentID, operationParams.nodeName) + if err != nil { + return err + } + if nodeType != "yorc.nodes.maas.Compute" { + return errors.Errorf("Unsupported node type '%s' for node '%s' in deployment '%s'", nodeType, operationParams.nodeName, operationParams.deploymentID) + } + + compute, err := getComputeFromDeployment(ctx, operationParams) + if err != nil { + return errors.Wrapf(err, "Failed to get Compute properties for deploymentID:%q, node name:%s", operationParams.deploymentID, operationParams.nodeName) + } + + var g errgroup.Group + for _, instance := range operationParams.instances { + instanceState, err := deployments.GetInstanceState(ctx, operationParams.deploymentID, operationParams.nodeName, instance) + if err != nil { + return err + } + + // If instance deleting, ignore it + if instanceState == tosca.NodeStateDeleting { + continue + } + + func(ctx context.Context, comp *maasCompute) { + g.Go(func() error { + return compute.undeploy(ctx, operationParams, instance) + }) + }(events.AddLogOptionalFields(ctx, events.LogOptionalFields{events.InstanceID: instance}), compute) + } + + if err := g.Wait(); err != nil { + err = errors.Wrapf(err, "Failed uninstall node deploymentID:%q, node name:%s", operationParams.deploymentID, operationParams.nodeName) + log.Debugf("%+v", err) + events.WithContextOptionalFields(ctx).NewLogEntry(events.LogLevelERROR, operationParams.deploymentID).RegisterAsString(err.Error()) + return err + } + + return nil +} diff --git a/prov/maas/init.go b/prov/maas/init.go new file mode 100644 index 000000000..bdd5d8bf6 --- /dev/null +++ b/prov/maas/init.go @@ -0,0 +1,25 @@ +// 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 maas + +import ( + "github.com/ystia/yorc/v4/registry" +) + +func init() { + reg := registry.GetRegistry() + reg.RegisterDelegates([]string{`yorc\.nodes\.maas\..*`}, &defaultExecutor{}, registry.BuiltinOrigin) + +} diff --git a/prov/maas/maas_compute.go b/prov/maas/maas_compute.go new file mode 100644 index 000000000..a97712b2c --- /dev/null +++ b/prov/maas/maas_compute.go @@ -0,0 +1,294 @@ +// 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 maas + +import ( + "context" + "fmt" + + "github.com/dustin/go-humanize" + "github.com/pkg/errors" + "github.com/ystia/yorc/v4/deployments" + "github.com/ystia/yorc/v4/events" + "github.com/ystia/yorc/v4/tosca" +) + +type maasCompute struct { + distro_series string + arch string + erase string + secure_erase string + quick_erase string + tags string + not_tags string + host hostCapabilities + os osCapabilities +} + +type hostCapabilities struct { + num_cpus string + mem_size string + disk_size string +} + +type osCapabilities struct { + architecture string + distribution string +} + +func (c *maasCompute) deploy(ctx context.Context, operationParams *operationParameters, instance string) error { + deploymentID := operationParams.deploymentID + nodeName := operationParams.nodeName + deployments.SetInstanceStateWithContextualLogs(ctx, deploymentID, nodeName, instance, tosca.NodeStateCreating) + + events.WithContextOptionalFields(ctx).NewLogEntry(events.LogLevelINFO, deploymentID).RegisterAsString(fmt.Sprintf("Creating node allocation for: deploymentID:%q, node name:%q", deploymentID, nodeName)) + + maasClient, err := getMaasClient(operationParams.locationProps) + if err != nil { + return err + } + + allocateParams, err := c.buildAllocateParams() + if err != nil { + return err + } + + deployRes, err := allocateAndDeploy(maasClient, allocateParams, newDeployParams(c.distro_series)) + if err != nil { + return err + } + + err = deployments.SetInstanceAttribute(ctx, deploymentID, nodeName, instance, "system_id", deployRes.system_id) + if err != nil { + return errors.Wrapf(err, "Failed to set instance attribute (system_id) for node name:%q, instance name:%q", nodeName, instance) + } + + err = deployments.SetInstanceAttribute(ctx, deploymentID, nodeName, instance, "ip_address", deployRes.ips[0]) + if err != nil { + return errors.Wrapf(err, "Failed to set instance attribute (ip_address) for node name:%q, instance name:%q", deployRes.ips[0], instance) + } + + err = deployments.SetInstanceAttribute(ctx, deploymentID, nodeName, instance, "private_address", deployRes.ips[0]) + if err != nil { + return errors.Wrapf(err, "Failed to set attribute instance attribute (private_address) for node name:%q, instance name:%q", deployRes.ips[0], instance) + } + + err = deployments.SetInstanceAttribute(ctx, deploymentID, nodeName, instance, "public_address", deployRes.ips[0]) + if err != nil { + return errors.Wrapf(err, "Failed to set attribute instance attribute (public_address) for node name:%q, instance name:%q", deployRes.ips[0], instance) + } + + err = deployments.SetInstanceCapabilityAttribute(ctx, deploymentID, nodeName, instance, "endpoint", "private_address", deployRes.ips[0]) + if err != nil { + return errors.Wrapf(err, "Failed to set instance attribute (private_address) for node name:%s, instance name:%q", nodeName, instance) + } + + err = deployments.SetInstanceCapabilityAttribute(ctx, deploymentID, nodeName, instance, "endpoint", "ip_address", deployRes.ips[0]) + if err != nil { + return errors.Wrapf(err, "Failed to set capability attribute (ip_address) for node name:%s, instance name:%q", nodeName, instance) + } + + err = deployments.SetInstanceCapabilityAttribute(ctx, deploymentID, nodeName, instance, "endpoint", "private_address", deployRes.ips[0]) + if err != nil { + return errors.Wrapf(err, "Failed to set capability attribute (private_address) for node name:%s, instance name:%q", nodeName, instance) + } + + deployments.SetInstanceStateWithContextualLogs(ctx, deploymentID, nodeName, instance, tosca.NodeStateCreated) + return nil +} + +func getComputeFromDeployment(ctx context.Context, operationParams *operationParameters) (*maasCompute, error) { + maasCompute := &maasCompute{} + + err := maasCompute.getAndsetProperties(ctx, operationParams) + if err != nil { + return nil, err + } + + err = maasCompute.getAndsetPropertiesFromHostCapabilities(ctx, operationParams) + if err != nil { + return nil, err + } + + err = maasCompute.getAndsetPropertiesFromOSCapabilities(ctx, operationParams) + if err != nil { + return nil, err + } + + return maasCompute, nil +} + +func (c *maasCompute) undeploy(ctx context.Context, operationParams *operationParameters, instance string) error { + deploymentID := operationParams.deploymentID + nodeName := operationParams.nodeName + deployments.SetInstanceStateWithContextualLogs(ctx, deploymentID, nodeName, instance, tosca.NodeStateDeleting) + + maasClient, err := getMaasClient(operationParams.locationProps) + if err != nil { + return err + } + + system_id, err := deployments.GetInstanceAttributeValue(ctx, deploymentID, nodeName, instance, "system_id") + if err != nil || system_id == nil { + return errors.Errorf("can't find instance attribute system id for nodename:%s deployementId: %s \n Maybe last deployement was not successful", nodeName, deploymentID) + } + + releaseParams := newReleaseParams(c.erase, c.secure_erase, c.quick_erase) + releaseParams.system_id = system_id.RawString() + + err = release(maasClient, releaseParams) + if err != nil { + return errors.Wrapf(err, "Release API call error for nodename:%s deployementId: %s", nodeName, deploymentID) + } + + deployments.SetInstanceStateWithContextualLogs(ctx, deploymentID, nodeName, instance, tosca.NodeStateDeleted) + return nil +} + +func (c *maasCompute) buildAllocateParams() (*allocateParams, error) { + // Convert mem into MB without text + mem := "" + if c.host.mem_size != "" { + memInt, err := humanize.ParseBytes(c.host.mem_size) + if err != nil { + return nil, err + } + memInt = memInt / 1000000 + mem = fmt.Sprint(memInt) + } + + storage := "" + if c.host.disk_size != "" { + storageInt, err := humanize.ParseBytes(c.host.disk_size) + if err != nil { + return nil, err + } + storageInt = storageInt / 1000000000 + storage = "label:" + fmt.Sprint(storageInt) + } + return newAllocateParams(c.host.num_cpus, mem, c.arch, storage, c.tags, c.not_tags), nil +} + +// Set host capabilities using deployments values +func (c *maasCompute) getAndsetProperties(ctx context.Context, operationParams *operationParameters) error { + deploymentID := operationParams.deploymentID + nodeName := operationParams.nodeName + + p, err := deployments.GetStringNodeProperty(ctx, deploymentID, nodeName, "distro_series", false) + if err != nil { + return err + } + if p != "" { + c.distro_series = p + } + + p, err = deployments.GetStringNodeProperty(ctx, deploymentID, nodeName, "arch", false) + if err != nil { + return err + } + if p != "" { + c.arch = p + } + + p, err = deployments.GetStringNodeProperty(ctx, deploymentID, nodeName, "erase", false) + if err != nil { + return err + } + if p != "" { + c.erase = p + } + + p, err = deployments.GetStringNodeProperty(ctx, deploymentID, nodeName, "secure_erase", false) + if err != nil { + return err + } + if p != "" { + c.secure_erase = p + } + + p, err = deployments.GetStringNodeProperty(ctx, deploymentID, nodeName, "quick_erase", false) + if err != nil { + return err + } + if p != "" { + c.quick_erase = p + } + + p, err = deployments.GetStringNodeProperty(ctx, deploymentID, nodeName, "tags", false) + if err != nil { + return err + } + if p != "" { + c.tags = p + } + + p, err = deployments.GetStringNodeProperty(ctx, deploymentID, nodeName, "not_tags", false) + if err != nil { + return err + } + if p != "" { + c.not_tags = p + } + + return nil +} + +// Set host capabilities using deployments values +func (c *maasCompute) getAndsetPropertiesFromHostCapabilities(ctx context.Context, operationParams *operationParameters) error { + deploymentID := operationParams.deploymentID + nodeName := operationParams.nodeName + hostCapabilities := &c.host + + p, err := deployments.GetCapabilityPropertyValue(ctx, deploymentID, nodeName, "host", "num_cpus") + if err != nil { + return err + } + if p != nil && p.RawString() != "" { + hostCapabilities.num_cpus = p.RawString() + } + + p, err = deployments.GetCapabilityPropertyValue(ctx, deploymentID, nodeName, "host", "mem_size") + if err != nil { + return err + } + if p != nil && p.RawString() != "" { + hostCapabilities.mem_size = p.RawString() + } + + p, err = deployments.GetCapabilityPropertyValue(ctx, deploymentID, nodeName, "host", "disk_size") + if err != nil { + return err + } + if p != nil && p.RawString() != "" { + hostCapabilities.disk_size = p.RawString() + } + return nil +} + +// Set os capabilities using deployments values +func (c *maasCompute) getAndsetPropertiesFromOSCapabilities(ctx context.Context, operationParams *operationParameters) error { + deploymentID := operationParams.deploymentID + nodeName := operationParams.nodeName + os := &c.os + + p, err := deployments.GetCapabilityPropertyValue(ctx, deploymentID, nodeName, "os", "distribution") + if err != nil { + return err + } + if p != nil && p.RawString() != "" { + os.distribution = p.RawString() + } + return nil +} diff --git a/prov/maas/maas_compute_test.go b/prov/maas/maas_compute_test.go new file mode 100644 index 000000000..484961ed8 --- /dev/null +++ b/prov/maas/maas_compute_test.go @@ -0,0 +1,57 @@ +// Copyright 2019 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 maas + +import ( + "context" + "path" + "testing" + + "github.com/stretchr/testify/require" + "github.com/ystia/yorc/v4/config" + "github.com/ystia/yorc/v4/deployments" +) + +func testGetComputeFromDeployment(t *testing.T, cfg config.Configuration) { + t.Parallel() + deploymentID := path.Base(t.Name()) + err := deployments.StoreDeploymentDefinition(context.Background(), deploymentID, "testdata/testSimpleMaasCompute.yaml") + require.Nil(t, err, "Failed to parse testInstallCompute definition") + + operationParams := operationParameters{ + locationProps: MAAS_LOCATION_PROPS, + taskID: "0", + deploymentID: deploymentID, + nodeName: "Compute", + delegateOperation: "install", + instances: []string{"instance0"}, + } + + compute, err := getComputeFromDeployment(context.Background(), &operationParams) + require.Nil(t, err) + require.NotNil(t, compute) + + require.Equal(t, "bionic", compute.distro_series) + require.Equal(t, "amd64", compute.arch) + require.Equal(t, "true", compute.erase) + require.Equal(t, "true", compute.quick_erase) + require.Equal(t, "true", compute.secure_erase) + require.Equal(t, "tagTest", compute.tags) + require.Equal(t, "notTagTest", compute.not_tags) + + require.Equal(t, "3", compute.host.num_cpus) + require.Equal(t, "10 GB", compute.host.mem_size) + require.Equal(t, "200 GB", compute.host.disk_size) +} diff --git a/prov/maas/testdata/testSimpleMaasCompute.yaml b/prov/maas/testdata/testSimpleMaasCompute.yaml new file mode 100644 index 000000000..768a2f532 --- /dev/null +++ b/prov/maas/testdata/testSimpleMaasCompute.yaml @@ -0,0 +1,74 @@ +tosca_definitions_version: alien_dsl_3_0_0 + +metadata: + template_name: 1Compute + template_version: 0.1.0-SNAPSHOT + template_author: ${template_author} + +description: "" + +imports: + - + - + - + +topology_template: + node_templates: + Compute: + type: yorc.nodes.maas.Compute + properties: + distro_series: bionic + arch: amd64 + erase: true + quick_erase: true + secure_erase: true + tags: tagTest + not_tags: notTagTest + capabilities: + host: + properties: + num_cpus: 3 + mem_size: "10 GB" + disk_size: "200 GB" + + endpoint: + properties: + credentials: + user: ubuntu + token_type: null + secure: true + protocol: tcp + network_name: PRIVATE + initiator: source + scalable: + properties: + min_instances: 1 + max_instances: 1 + default_instances: 1 + workflows: + install: + steps: + Compute_install: + target: Compute + activities: + - delegate: install + uninstall: + steps: + Compute_uninstall: + target: Compute + activities: + - delegate: uninstall + start: + steps: + Compute_start: + target: Compute + activities: + - delegate: start + stop: + steps: + Compute_stop: + target: Compute + activities: + - delegate: stop + run: + cancel: diff --git a/server/plugins.go b/server/plugins.go index 83bbd544d..3ac2d20e0 100644 --- a/server/plugins.go +++ b/server/plugins.go @@ -30,24 +30,22 @@ import ( _ "github.com/ystia/yorc/v4/prov/slurm" // Registering hosts pool delegate executor in the registry _ "github.com/ystia/yorc/v4/prov/hostspool" + // Registering maas delegate executor in the registry + _ "github.com/ystia/yorc/v4/prov/maas" // Registering builtin Tosca definition files _ "github.com/ystia/yorc/v4/tosca" // Registering builtin HashiCorp Vault Client Builder _ "github.com/ystia/yorc/v4/vault/hashivault" // Registering builtin activity hooks - _ "github.com/ystia/yorc/v4/prov/validation" -) - -import ( "context" "os" "path/filepath" "github.com/ystia/yorc/v4/deployments/store" + _ "github.com/ystia/yorc/v4/prov/validation" gplugin "github.com/hashicorp/go-plugin" "github.com/pkg/errors" - "github.com/ystia/yorc/v4/config" "github.com/ystia/yorc/v4/log" "github.com/ystia/yorc/v4/plugin"