Skip to content

Hard coded version and handling of errors gracefully in get_sessionid #10

@surfer190

Description

@surfer190

Should the vcd version rather come from configuration? You get a 406 on a later version of vcd with the below error message when the version is set to 5.1.

message="The request has invalid accept header: . Supported API versions are: [32.0, 31.0, 30.0, 29.0, 28.0 [D], 27.0 [D], 26.0 [D], 25.0 [D], 24.0 [D], 23.0 [D], 22.0 [D], 21.0 [D], 20.0 [D]] ([D] indicates deprecated versions)"

Also is adding @system wise to do here? What if a user sets the config to xxxx@system in the configuration? A warning should perhaps be added to the configuration schema in config.schema.yaml

Also perhaps we should catch anything that isn't a 200 status code here and give a nicer looking error message?


    def get_sessionid(self):
        url = 'https://%s/api/sessions' % self.vcd_host
        headers = {'Accept': 'application/*+xml;version=5.1'}
        p = requests.post(url, headers=headers, auth=(self.vcd_user +  # noqa: W504
                                                      "@SYSTEM", self.vcd_pass),
                          verify=self.vcd_ssl)
        self.vcd_auth = p.headers['x-vcloud-authorization']

        return self.vcd_auth

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions