You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Create (boot) server call fails due to default parameters in create request.
Ex:
ServerCreate sc = Builders.server()
.name(serverName)
.flavor(flavorId)
.image(imageId)
.addSecurityGroup(securityGroup)
.keypairName(keyPair)
.build();
Server server = os.compute().servers().boot(sc);
Exception:
ClientResponseException{message=Invalid input for field/attribute server. Value: {u'name': u'redistest', u'imageRef': u'd12f9de0-5bec-4e58-bb8b-9d5d7396e131', u'key_name': u'cloudkey', u'flavorRef': u'8', u'diskConfig': u'MANUAL', u'block_device_mapping_v2': [], u'security_groups': [{u'name': u'SecGroup_Redis'}], u'metadata': {}}. Additional properties are not allowed (u'diskConfig' was unexpected), status=400, status-code=BAD_REQUEST}
This is due to the fact of passing default value of 'MANUAL' for 'diskConfig', empty default list for 'block_device_mapping_v2' and empty default object for 'metadata' attributes in the request.
I was able to make it work after overriding the way ServerCreate object was created as below:
@SuppressWarnings("serial")
@JsonRootName("server")
final class NovaServerCreateOverride extends NovaServerCreate {
public DiskConfig getDiskConfig() {
return null;
}
@SuppressWarnings("unused")
public List<BlockDeviceMappingCreate> getBlockDeviceMapping() {
return null;
}
@SuppressWarnings("unused")
public Map<String, String> getMetadata() {
return null;
}
}
ServerCreate tc = new NovaServerCreateOverride();
ServerCreate sc = Builders.server()
.from(tc)
.name(serverName)
.flavor(flavorId)
.image(imageId)
.addSecurityGroup(securityGroup)
.keypairName(keyPair)
.build();
Server server = os.compute().servers().boot(sc);
We need a way to suppress these empty/default values for optional attributes in the JSON payload. With the current design, the support from ServerCreateConcreteBuilder is pretty limited for such operations because there is no way to override these values to null/empty through builder.
The text was updated successfully, but these errors were encountered:
jagathvijayan
changed the title
Create (boot) server fails against DevStack due to optional parameters in JSON payload in the request
Create (boot) server call fails against DevStack due to optional parameters in JSON payload in the request
Oct 9, 2015
Environment
Latest DevStack on VirtualBox
openstack4j - 2.0.6
Create (boot) server call fails due to default parameters in create request.
Ex:
Exception:
This is due to the fact of passing default value of 'MANUAL' for 'diskConfig', empty default list for 'block_device_mapping_v2' and empty default object for 'metadata' attributes in the request.
I was able to make it work after overriding the way ServerCreate object was created as below:
We need a way to suppress these empty/default values for optional attributes in the JSON payload. With the current design, the support from ServerCreateConcreteBuilder is pretty limited for such operations because there is no way to override these values to null/empty through builder.
The text was updated successfully, but these errors were encountered: