-
Notifications
You must be signed in to change notification settings - Fork 17
Please allow configuration via python #207
Comments
When importing the entire library via #!/usr/bin/env python import csv from mixcoatl import resource_utils, utils from mixcoatl.infrastructure.server import Server from mixcoatl.settings.load_settings import settings as mixcoatl_settings with open('creds.csv', 'rb') as f: reader = csv.reader(f) cred_list = list(reader) for line in cred_list: mixcoatl_settings.set_access_key(line[0]) mixcoatl_settings.set_secret_key(line[1]) mixcoatl_settings.set_endpoint(line[2]) print "Results with ACCESS KEY #",line[0] print utils.print_format(Server.all(), 'json') By only importing mixcoatl.settings.load_settings you can manually set these variables on the fly without the exceptions. I also added some quick (mostly untested) logic for reading through a CSV file of credentials and then making a list server call against each discovered endpoint. Sample creds.csv format: ACCESS_KEY,SECRET_KEY,ENDPOINT_URL Let me know if this works or not and we can continue to troubleshoot. |
Hi Brian, I'm not interested in work-arounds and hacks and this doesn't address the problem of multiple DCM accounts being used in one process. |
Hi Devin, Thanks for using mixcoatl! We're happy to have you in the cloud! We hope you like working with clouds and DCM as much as we do. Sorry we couldn't answer your question with a quick solution. Mixcoatl is open-source and community driven, please fork the mixcoatl repository and make a PR if you have a solution you'd like to contribute. We'll keep this issue open and we appreciate your using DCM and mixcoatl! zomgreg |
Hi zomGreg, that might be possible, but before spending time on it I would like to know that the general design is acceptable. Our goal is:
To achieve this, I would add a config parameter to Server, Resource and other places where it is needed. And it would be passed around as necessary. For backwards compatibility, it could default to the global, automatically initialised config object. Would that be accepted? |
Hi Devin, I not sure I'm able to comment intelligently on your design proposal, so let me take a step back for a moment to try to understand the bigger picture. It sounds to me like you're trying to work with multiple DCM accounts. This is something that the DCM API, and by extension, mixcoatl, allows natively. For example, with a single set of DCM user API credentials, I can do something like this, listing all the DCM cloud accounts to which my user has access.
From there, I can, for example, list all regions in account 201:
and then I can list all servers in region 16
mixcoatl can also facilitate "generic" REST calls like:
which is useful for passing arbitrary data. Please see our most recent wiki entry Importing mixcoatl libraries for DCM server, account, and other objects is a feature we're constantly working to improve. For example, you can see account module information here And there are pages that are created for each mixcoatl module. Making mixcoal have more of an SDK feel is something that's on our project roadmap, but it will take time. Cheers, |
Hi Greg, in your post I think you are mixing up DCM accounts and cloud accounts. We need to support multiple DCM accounts with different DCM API endpoints. And we don't want to use mixcoatl-specific ways of importing or mocking - it should just work like any other library. I'm offering to make a pull request that gives mixcoatl that API-feel, but it's only worth the effort if the design is acceptable to the owners. Is that the case? |
The limiting of mixcoatl API queries to a single DCM account has been a known limitation with no great workaround, as you saw above. I for one would like to see the PR as you've described. It definitely sounds like a viable candidate for inclusion. |
I would like to throw in with akvadrako. I need such a feature as well. The proposal sounds reasonable to me and I do not think it would be too hairy either. The idea here is that you may want to have a single long running python program that interacts with DCM on behalf of many different DCM users at the same time and in overlapping requests. Keeping account information in global state will not work for this (even if you change the global state you quickly run into a case where 2 accounts are trying to set/use it at the same time). Associating a config object with each request has my +1. |
Add an Endpoint class as a part of the resource module. An Endpoint can be optionally passed to any of of the resource objects to allow them to access a different DCM endpoint then the one specified either by environement variables or in configuration files as loaded by the config class. - Issue QSFT#210 heavily inspired this feature, thanks @thijs-creemers - Fixes Issue QSFT#207
Add an Endpoint class as a part of the resource module. An Endpoint can be optionally passed to any of of the resource objects to allow them to access a different DCM endpoint then the one specified either by environement variables or in configuration files as loaded by the config class. - Issue QSFT#210 heavily inspired this feature, thanks @thijs-creemers - Fixes Issue QSFT#207
Add an Endpoint class as a part of the resource module. An Endpoint can be optionally passed to any of of the resource objects to allow them to access a different DCM endpoint then the one specified either by environement variables or in configuration files as loaded by the config class. - Issue QSFT#210 heavily inspired this feature, thanks @thijs-creemers - Fixes Issue QSFT#207
Add an Endpoint class as a part of the resource module. An Endpoint can be optionally passed to any of of the resource objects to allow them to access a different DCM endpoint then the one specified either by environment variables or in configuration files as loaded by the config class. - Issue QSFT#210 heavily inspired this feature, thanks @thijs-creemers - Fixes Issue QSFT#207
Add an Endpoint class as a part of the resource module. An Endpoint can be optionally passed to any of of the resource objects to allow them to access a different DCM endpoint then the one specified either by environment variables or in configuration files as loaded by the config class. - Issue QSFT#210 heavily inspired this feature, thanks @thijs-creemers - Fixes Issue QSFT#207
Add an Endpoint class as a part of the resource module. An Endpoint can be optionally passed to any of of the resource objects to allow them to access a different DCM endpoint then the one specified either by environment variables or in configuration files as loaded by the config class. - Issue QSFT#210 heavily inspired this feature, thanks @thijs-creemers - Fixes Issue QSFT#207
This was closed with release 1.0.1, take a look at the release notes for details on how to do this. |
I also want to draw @akvadrako attention to this now being fixed. |
Using mixcoatl as a library isn't very elegant, because we have to set environmental variables before all import statements. Also, we need to interact with more than one DCM account in the same app. So the logic is like:
It would be nice to have a more conventional API.
The text was updated successfully, but these errors were encountered: