Ejemplo n.º 1
0
 def get_working_cloud_name(self):
     '''
     get the name of a cloud to work on, if CLOUD not given, the function
     will pick the selected or default cloud
     '''
     cloudname = None
     cloudobj = CloudManage()
     mongo = cm_mongo()
     if self.arguments['--cloud']:
         cloud = cloudobj.get_clouds(
             self.username, getone=True, cloudname=self.arguments['--cloud'])
         if cloud is None:
             Console.error(
                 "could not find cloud '{0}'".format(self.arguments['--cloud']))
             return False
         else:
             cloudname = self.arguments['--cloud']
     else:
         cloudname = cloudobj.get_selected_cloud(self.username)
     if cloudname not in mongo.active_clouds(self.username):
         Console.warning(
             "cloud '{0}' is not active, to activate a cloud: cloud on [CLOUD]".format(cloudname))
         return False
     else:
         return cloudname