- def get_account(token):
- """Return the account corresponding to this token"""
- config = Config()
- astakos = AstakosClient(config.get('user', 'url'), token)
+ def get_clouds():
+ """Returns the list of available clouds"""
+ names = config.keys('cloud')
+
+ clouds = {}
+ for name in names:
+ clouds[name] = config.get('cloud', name)
+
+ return clouds
+
+ @staticmethod
+ def get_cloud_by_name(name):
+ """Returns a dict with cloud info"""
+ return config.get('cloud', name)
+
+ @staticmethod
+ def save_cloud(name, url, token, description=""):
+ """Save a new cloud account"""
+ cloud = {'url': url, 'token': token}
+ if len(description):
+ cloud['description'] = description
+ config.set('cloud', name, cloud)
+
+ # Make the saved cloud the default one
+ config.set('global', 'default_cloud', name)
+ config.write()
+
+ @staticmethod
+ def remove_cloud(name):
+ """Deletes an existing cloud from the Kamaki configuration file"""
+ config.remove_option('cloud', name)
+ config.write()
+
+ @staticmethod
+ def create_account(url, token):
+ """Given a valid (URL, tokens) pair this method returns an Astakos
+ client instance
+ """
+ client = AstakosClient(url, token)