Skip to content

Commit

Permalink
container name convention added to API (#6634)
Browse files Browse the repository at this point in the history
  • Loading branch information
AngieCris authored and zjs committed Nov 20, 2017
1 parent 54582a9 commit c3db32a
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 1 deletion.
4 changes: 4 additions & 0 deletions lib/apiservers/service/restapi/handlers/vch_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,10 @@ func buildCreate(op trace.Operation, d *data.Data, finder *find.Finder, vch *mod
return nil, util.NewError(http.StatusBadRequest, fmt.Sprintf("Error processing syslog server address: %s", err))
}
}

if vch.Container != nil && vch.Container.NameConvention != "" {
c.ContainerNameConvention = vch.Container.NameConvention
}
}

return c, nil
Expand Down
5 changes: 5 additions & 0 deletions lib/apiservers/service/restapi/handlers/vch_get.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,11 @@ func vchToModel(op trace.Operation, vch *vm.VirtualMachine, d *data.Data, execut
model.SyslogAddr = strfmt.URI(syslogConfig.Network + "://" + syslogConfig.RAddr)
}

model.Container = &models.VCHContainer{}
if vchConfig.ContainerNameConvention != "" {
model.Container.NameConvention = vchConfig.ContainerNameConvention
}

return model, nil
}

Expand Down
9 changes: 9 additions & 0 deletions lib/apiservers/service/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -819,6 +819,15 @@
"type": "string",
"format": "uri",
"pattern": "^(tc|ud)p:\/\/.*"
},
"container": {
"type": "object",
"properties": {
"name_convention": {
"type": "string",
"pattern": "^.*(\\{id\\}|\\{name\\}).*"
}
}
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ Create minimal VCH within datacenter


Create complex VCH
Create VCH '{"name":"%{VCH-NAME}-api-test-complex","debug":3,"compute":{"cpu":{"limit":{"units":"MHz","value":2345},"reservation":{"units":"GHz","value":2},"shares":{"level":"high"}},"memory":{"limit":{"units":"MiB","value":1200},"reservation":{"units":"MiB","value":501},"shares":{"number":81910}},"resource":{"name":"%{TEST_RESOURCE}"}},"endpoint":{"cpu":{"sockets":2},"memory":{"units":"MiB","value":3072}},"storage":{"image_stores":["ds://%{TEST_DATASTORE}"],"volume_stores":[{"datastore":"ds://%{TEST_DATASTORE}/test-volumes/foo","label":"foo"}],"base_image_size":{"units":"B","value":16000000}},"network":{"bridge":{"ip_range":"172.16.0.0/12","port_group":{"name":"%{BRIDGE_NETWORK}"}},"public":{"port_group":{"name":"${PUBLIC_NETWORK}"}}},"registry":{"image_fetch_proxy":{"http":"http://example.com","https":"https://example.com"},"insecure":["https://insecure.example.com"],"whitelist":["10.0.0.0/8"]},"auth":{"server":{"generate":{"cname":"vch.example.com","organization":["VMware, Inc."],"size":{"value":2048,"units":"bits"}}},"client":{"no_tls_verify": true}},"syslog_addr":"tcp://syslog.example.com:4444"}'
Create VCH '{"name":"%{VCH-NAME}-api-test-complex","debug":3,"compute":{"cpu":{"limit":{"units":"MHz","value":2345},"reservation":{"units":"GHz","value":2},"shares":{"level":"high"}},"memory":{"limit":{"units":"MiB","value":1200},"reservation":{"units":"MiB","value":501},"shares":{"number":81910}},"resource":{"name":"%{TEST_RESOURCE}"}},"endpoint":{"cpu":{"sockets":2},"memory":{"units":"MiB","value":3072}},"storage":{"image_stores":["ds://%{TEST_DATASTORE}"],"volume_stores":[{"datastore":"ds://%{TEST_DATASTORE}/test-volumes/foo","label":"foo"}],"base_image_size":{"units":"B","value":16000000}},"network":{"bridge":{"ip_range":"172.16.0.0/12","port_group":{"name":"%{BRIDGE_NETWORK}"}},"public":{"port_group":{"name":"${PUBLIC_NETWORK}"}}},"registry":{"image_fetch_proxy":{"http":"http://example.com","https":"https://example.com"},"insecure":["https://insecure.example.com"],"whitelist":["10.0.0.0/8"]},"auth":{"server":{"generate":{"cname":"vch.example.com","organization":["VMware, Inc."],"size":{"value":2048,"units":"bits"}}},"client":{"no_tls_verify": true}},"syslog_addr":"tcp://syslog.example.com:4444", "container": {"name_convention": "container-{id}"}}'

Verify Return Code
Verify Status Created
Expand Down Expand Up @@ -201,6 +201,8 @@ Create complex VCH
Property Should Be Equal .runtime.power_state poweredOn
Property Should Be Equal .runtime.upgrade_status Up to date

Property Should Be Equal .container.name_convention container-{id}

[Teardown] Run Secret VIC Machine Delete Command %{VCH-NAME}-api-test-complex


Expand Down

0 comments on commit c3db32a

Please sign in to comment.