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

Create (boot) server call fails against DevStack due to optional parameters in JSON payload in the request #470

Closed
jagathvijayan opened this issue Oct 9, 2015 · 4 comments
Assignees
Labels
Milestone

Comments

@jagathvijayan
Copy link

Environment

Latest DevStack on VirtualBox
openstack4j - 2.0.6

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.

@jagathvijayan 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
@gondor gondor added the bug label Oct 9, 2015
@gondor
Copy link
Member

gondor commented Oct 9, 2015

@jagathvijayan Thank you for the well written issue. Will look into this

@gondor gondor self-assigned this Oct 9, 2015
@gondor gondor added this to the 2.0.7 Release milestone Oct 10, 2015
gondor added a commit that referenced this issue Oct 13, 2015
@gondor
Copy link
Member

gondor commented Oct 13, 2015

Ok, changes have been made and a new 2.0.7-SNAPSHOT deployed

@jagathvijayan
Copy link
Author

Verified the fix to be working fine against latest 2.0.7-SNAPSHOT. Thanks @gondor !

@gondor
Copy link
Member

gondor commented Oct 13, 2015

Awesome, thanks for verifying so quickly.

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

No branches or pull requests

2 participants