示例#1
0
 def _default_list_refresh(self):
     if self.arguments['--on']:
         self._start_cm_user()
         defaults_data = self.user_obj.info(self.username)['defaults']
         defaults_data["shell_command_list_refresh_default_setting"] = True
         self.user_obj.set_defaults(self.username, defaults_data)
     elif self.arguments['--off']:
         self._start_cm_user()
         defaults_data = self.user_obj.info(self.username)['defaults']
         defaults_data["shell_command_list_refresh_default_setting"] = False
         self.user_obj.set_defaults(self.username, defaults_data)
     else:
         print("refresh as default: ", get_command_list_refresh_default_setting(self.username))
示例#2
0
 def _default_list_refresh(self):
     if self.arguments['--on']:
         self._start_cm_user()
         defaults_data = self.user_obj.info(self.username)['defaults']
         defaults_data["shell_command_list_refresh_default_setting"] = True
         self.user_obj.set_defaults(self.username, defaults_data)
     elif self.arguments['--off']:
         self._start_cm_user()
         defaults_data = self.user_obj.info(self.username)['defaults']
         defaults_data["shell_command_list_refresh_default_setting"] = False
         self.user_obj.set_defaults(self.username, defaults_data)
     else:
         print("refresh as default: ",
               get_command_list_refresh_default_setting(self.username))
示例#3
0
    def __init__(self, arguments):
        self.cloudmanage = CloudManage()
        try:
            self.config = cm_config()
        except:
            Console.error("There is a problem with the configuration yaml files")

        self.username = self.config['cloudmesh']['profile']['username']

        self.arguments = arguments
        
        # pprint(self.arguments)
        
        self.cloudmanage = CloudManage()
        try:
            self.config = cm_config()
        except:
            Console.error("There is a problem with the configuration yaml files")
    
        self.username = self.config['cloudmesh']['profile']['username']
        self.refresh_default_setting = get_command_list_refresh_default_setting(self.username)
示例#4
0
    def __init__(self, arguments):
        self.cloudmanage = CloudManage()
        try:
            self.config = cm_config()
        except:
            Console.error(
                "There is a problem with the configuration yaml files")

        self.username = self.config['cloudmesh']['profile']['username']

        self.arguments = arguments

        # pprint(self.arguments)

        self.cloudmanage = CloudManage()
        try:
            self.config = cm_config()
        except:
            Console.error(
                "There is a problem with the configuration yaml files")

        self.username = self.config['cloudmesh']['profile']['username']
        self.refresh_default_setting = get_command_list_refresh_default_setting(
            self.username)
示例#5
0
    def _show_ip(self):
        '''
        list the ips of VMs
        '''
        mongo = cm_mongo()
        cloudname = self.get_working_cloud_name()
        if not cloudname:
            return
        if get_command_list_refresh_default_setting(self.username) or self.arguments['--refresh']:
            mongo.activate(cm_user_id=self.username, names=[cloudname])
            mongo.refresh(cm_user_id=self.username,
                          names=[cloudname],
                          types=['servers'])

        servers_dict = mongo.servers(
            clouds=[cloudname], cm_user_id=self.username)[cloudname]

        AllCloudVMs = False
        if (self.arguments['--cloud'] and
                    self.arguments['NAME'] is None and
                    self.arguments['--id'] is None and
                    self.arguments['--group'] is None and
                    self.arguments['--prefix'] is None and
                    self.arguments['--names'] is None):
            AllCloudVMs = True

        server_id_list = get_vms_look_for(self.username,
                                          cloudname,
                                          servername=self.arguments['NAME'],
                                          serverid=self.arguments['--id'],
                                          groupname=self.arguments['--group'],
                                          prefix=self.arguments['--prefix'],
                                          hostls=self.arguments['--names'],
                                          getAll=AllCloudVMs,
                                          refresh=False)
        if not server_id_list:
            return
        if server_id_list == []:
            Console.warning("no vm meets the condition")
            return

        res = {}
        for item in server_id_list:
            temp = servers_dict[item]['addresses']
            temp_val = temp.keys()[0]
            temp = temp[temp_val]
            fixed = ""
            floating = ""
            for item0 in temp:
                if item0['OS-EXT-IPS:type'] == 'fixed':
                    fixed = fixed + item0['addr'] + ", "
                elif item0['OS-EXT-IPS:type'] == 'floating':
                    floating = floating + item0['addr'] + ", "
            if fixed != "":
                fixed = fixed[:-2]
            if floating != "":
                floating = floating[:-2]
            temp0 = {}
            temp0['name'] = servers_dict[item]['name']
            temp0['fixed'] = fixed
            temp0['floating'] = floating
            res[item] = temp0

        if self.arguments['--format']:
            if self.arguments['--format'] not in ['table', 'json', 'csv']:
                Console.error("please select printing format among table, json and csv")
                return
            else:
                p_format = self.arguments['--format']
        else:
            p_format = None

        header = ['name', 'fixed', 'floating']

        shell_commands_dict_output(self.username,
                                   res,
                                   print_format=p_format,
                                   firstheader="id",
                                   header=header)