Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

server create bug #711

Closed
wumingcheng opened this issue Jun 7, 2016 · 4 comments
Closed

server create bug #711

wumingcheng opened this issue Jun 7, 2016 · 4 comments

Comments

@wumingcheng
Copy link

wumingcheng commented Jun 7, 2016

Cannot create a server with "security_groups", because there is a bug about securityGroups of "NovaServerCreate.java"
please change the code
" @JsonProperty("security_groups")
private List<SecurityGroup> securityGroups;"
to
"@JsonProperty("security_groups")
private List<NovaSecurityGroup> securityGroups;"

@wumingcheng wumingcheng changed the title sever create bug server create bug Jun 7, 2016
@vinodborole
Copy link
Contributor

@wumingcheng I just tested it with following code and it works, here is the response

ServerCreate server = Builders.server().name("deleteme").flavor(flavor).networks(networks).image(imageId).addSecurityGroup(name).build();
Server s = client.compute().servers().boot(server);

1 > POST http://10.193.82.103:8774/v2.1/a7bcb49a97784e49bbb09fe8b0f47ad1/servers
1 > Accept: application/json
1 > Content-Type: application/json
1 > User-Agent: OpenStack4j / OpenStack Client
1 > X-Auth-Token: ccb5ad72c0a144f6897f75dd72d203ff
{
"server" : {
"name" : "deleteme",
"imageRef" : "61ac927b-caa9-44da-b6c3-79c61995e69a",
"flavorRef" : "1",
"security_groups" : [ {
"name" : "test"
} ],
"networks" : [ {
"uuid" : "e56e1680-fbd6-4c9f-b590-82615f2f0f61"
} ]
}
}

INFO: 1 * Client response received on thread main
1 < 202
1 < Connection: keep-alive
1 < Content-Length: 441
1 < Content-Type: application/json
1 < Date: Tue, 07 Jun 2016 07:00:53 GMT
1 < Location: http://10.193.82.103:8774/v2.1/a7bcb49a97784e49bbb09fe8b0f47ad1/servers/2c8b4c18-c6ff-4d11-a342-a343c3976baf
1 < Vary: X-OpenStack-Nova-API-Version
1 < X-Compute-Request-Id: req-e679d1ac-279c-4775-9a2c-937a76e8f7ba
1 < X-Openstack-Nova-Api-Version: 2.1
{"server": {"security_groups": [{"name": "test"}], "OS-DCF:diskConfig": "MANUAL", "id": "2c8b4c18-c6ff-4d11-a342-a343c3976baf", "links": [{"href": "http://10.193.82.103:8774/v2.1/a7bcb49a97784e49bbb09fe8b0f47ad1/servers/2c8b4c18-c6ff-4d11-a342-a343c3976baf", "rel": "self"}, {"href": "http://10.193.82.103:8774/a7bcb49a97784e49bbb09fe8b0f47ad1/servers/2c8b4c18-c6ff-4d11-a342-a343c3976baf", "rel": "bookmark"}], "adminPass": "PHC3UsbsHGnX"}}

@wumingcheng
Copy link
Author

@vinodborole The code
" @JsonProperty("security_groups")
private List securityGroups;"
cannot get the security_groups name ,because SecurityGroup is an Interface, it isn't has an attribute :"private String name", it cannot get the JSON
"security_groups" : [ {
"name" : "XXX"
} ]

@vinodborole
Copy link
Contributor

@wumingcheng It uses the SecurityGroupInternal subclass; following is the code from NovaServerCreate.java

@Override public void addSecurityGroup(String name) { if (securityGroups == null) securityGroups = Lists.newArrayList(); securityGroups.add(new SecurityGroupInternal(name)); }

@wumingcheng
Copy link
Author

@vinodborole ok,thx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants