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

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

Open
surfer190 opened this issue Feb 10, 2020 · 2 comments
Open

Comments

@surfer190
Copy link
Contributor

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
@nmaludy
Copy link
Contributor

nmaludy commented Feb 10, 2020

@surfer190 Sounds like there are a few things here, let me break them down and let's talk about them one at a time.

  1. Hard coded version number: Yes, it does look like the version is hard coded here https://github.com/StackStorm-Exchange/stackstorm-vcd/blob/master/actions/lib/vcd.py#L53 . Adding the version to the config schema makes sense to me! Would you mind trying to craft a PR for this (i don't have VCD to test with)?

  2. Hard coded domain: Yes, it does look like the domain of @SYSTEM is hard coded here: https://github.com/StackStorm-Exchange/stackstorm-vcd/blob/master/actions/lib/vcd.py#L55 . Similar to the version number, i'm thinking this should probably be part of the config with a default value of SYSTEM and the code can insert the @ itself. Alternatively we could expect the user to be fully qualified and append @system if there is no @ character in the user.

@surfer190
Copy link
Contributor Author

@nmaludy Since the module supports the use of different vcd instances, it would make sense for the api version to be set per instance - so alongside hostname, username and password.

I feel like the solution of appending the @system if no @ is present in the string is a good one.

These changes could break existing workflows and actions, they would need to update their config. Is that acceptable?

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