示例#1
0
    def take_action(self, args):
        new_sequence = self.client.create(args.release, args.name,
                                          args.graph_types)
        self.app.stdout.write("Sequence was successfully created:\n")
        data = data_utils.get_display_data_single(self.columns, new_sequence)

        return self.columns, data
示例#2
0
 def take_action(self, parsed_args):
     result = self.get_client().get(self.get_url(parsed_args))
     try:
         data = data_utils.get_display_data_single(self.columns, result)
         return self.columns, data
     except fc_error.BadDataException:
         return zip(*result.items())
示例#3
0
 def take_action(self, args):
     serializer = serializers.FileFormatBasedSerializer()
     new_sequence = self.client.upload(args.release,
                                       serializer.read_from_file(args.file))
     self.app.stdout.write("Sequence was successfully created:\n")
     data = data_utils.get_display_data_single(self.columns, new_sequence)
     return self.columns, data
示例#4
0
 def take_action(self, parsed_args):
     result = self.get_client().get(self.get_url(parsed_args))
     try:
         data = data_utils.get_display_data_single(self.columns, result)
         return self.columns, data
     except fc_error.BadDataException:
         return zip(*result.items())
 def take_action(self, parsed_args):
     args = parsed_args.__dict__
     data = APIClient.get_request(API_URI.format(args['node']))
     data['node'] = args['node']
     data['vrouter_cores'] = data.get('vrouter_cores', [])
     data['nova_cores'] = data.get('nova_cores', [])
     data = data_utils.get_display_data_single(self.columns, data)
     return self.columns, data
示例#6
0
    def take_action(self, parsed_args):
        to_update = get_args_for_update(parsed_args)

        network_group = self.client.update(parsed_args.id, **to_update)
        network_group = data_utils.get_display_data_single(
            self.columns, network_group)

        return self.columns, network_group
    def take_action(self, parsed_args):
        to_update = get_args_for_update(parsed_args)

        network_group = self.client.update(parsed_args.id, **to_update)
        network_group = data_utils.get_display_data_single(
            self.columns, network_group)

        return self.columns, network_group
 def take_action(self, parsed_args):
     args = parsed_args.__dict__
     data = APIClient.get_request(API_URI.format(args['node']))
     data['node'] = args['node']
     data['vrouter_cores'] = data.get('vrouter_cores', [])
     data['nova_cores'] = data.get('nova_cores', [])
     data = data_utils.get_display_data_single(self.columns, data)
     return self.columns, data
示例#9
0
    def take_action(self, parsed_args):
        new_env = self.client.create(name=parsed_args.name,
                                     release_id=parsed_args.release,
                                     network_provider=parsed_args.net_provider,
                                     net_segment_type=parsed_args.nst)

        new_env = data_utils.get_display_data_single(self.columns, new_env)

        return (self.columns, new_env)
示例#10
0
    def take_action(self, parsed_args):
        data = self.client.get_by_id(parsed_args.id)

        numa_topology = data['meta'].get('numa_topology', {})
        for key in self.numa_fields:
            data[key] = numa_topology.get(key)

        data = data_utils.get_display_data_single(self.columns, data)
        return self.columns, data
示例#11
0
 def take_action(self, parsed_args):
     # TODO(akscram): While the clone procedure is not a part of
     #                fuelclient.objects.Environment the connection
     #                will be called directly.
     new_env = self.client._entity_wrapper.connection.post_request(
         "clusters/{0}/upgrade/clone".format(parsed_args.id), {
             'name': parsed_args.name,
             'release_id': parsed_args.release,
         })
     new_env = data_utils.get_display_data_single(self.columns, new_env)
     return (self.columns, new_env)
示例#12
0
    def take_action(self, args):
        sequence = self.client.update(args.id,
                                      name=args.name,
                                      graph_types=args.graph_types)

        if sequence:
            self.app.stdout.write("Sequence was successfully updated:\n")
            data = data_utils.get_display_data_single(self.columns, sequence)
            return self.columns, data
        else:
            self.app.stdout.write("Nothing to update.\n")
示例#13
0
    def take_action(self, parsed_args):
        updates = {}
        for attr in self.client._updatable_attributes:
            if getattr(parsed_args, attr, None):
                updates[attr] = getattr(parsed_args, attr)

        updated_node = self.client.update(parsed_args.id, **updates)
        updated_node = data_utils.get_display_data_single(
            self.columns, updated_node)

        return (self.columns, updated_node)
示例#14
0
    def take_action(self, parsed_args):
        if parsed_args.nst == 'gre':
            self.app.stdout.write('WARNING: GRE network segmentation type is '
                                  'deprecated since 7.0 release')

        new_env = self.client.create(name=parsed_args.name,
                                     release_id=parsed_args.release,
                                     net_segment_type=parsed_args.nst)

        new_env = data_utils.get_display_data_single(self.columns, new_env)

        return (self.columns, new_env)
    def take_action(self, parsed_args):
        updates = {}
        for attr in self.client._updatable_attributes:
            if getattr(parsed_args, attr, None):
                updates[attr] = getattr(parsed_args, attr)

        updated_env = self.client.update(environment_id=parsed_args.id,
                                         **updates)
        updated_env = data_utils.get_display_data_single(self.columns,
                                                         updated_env)

        return (self.columns, updated_env)
示例#16
0
    def take_action(self, parsed_args):
        if parsed_args.nst == 'gre':
            self.app.stdout.write('WARNING: GRE network segmentation type is '
                                  'deprecated since 7.0 release')

        new_env = self.client.create(name=parsed_args.name,
                                     release_id=parsed_args.release,
                                     net_segment_type=parsed_args.nst)

        new_env = data_utils.get_display_data_single(self.columns, new_env)

        return (self.columns, new_env)
示例#17
0
    def take_action(self, parsed_args):
        data = self.client.get_by_id(parsed_args.id)
        if data['name'] != 'dump':
            msg = "Task with id {0} is not a snapshot generation task"
            raise error.ActionException(msg.format(data['id']))
        if data['status'] != 'ready':
            data['link'] = None
        else:
            data['link'] = self.client.connection.root + data['message']

        data = data_utils.get_display_data_single(self.columns, data)
        return self.columns, data
    def take_action(self, parsed_args):
        if parsed_args.net_provider == 'nova':
            self.app.stdout.write('Warning: nova-network is deprecated '
                                  'since 6.1 release')

        new_env = self.client.create(name=parsed_args.name,
                                     release_id=parsed_args.release,
                                     network_provider=parsed_args.net_provider,
                                     net_segment_type=parsed_args.nst)

        new_env = data_utils.get_display_data_single(self.columns, new_env)

        return (self.columns, new_env)
示例#19
0
 def take_action(self, parsed_args):
     # TODO(akscram): While the clone procedure is not a part of
     #                fuelclient.objects.Environment the connection
     #                will be called directly.
     new_env = self.client._entity_wrapper.connection.post_request(
         "clusters/{0}/upgrade/clone".format(parsed_args.id),
         {
             'name': parsed_args.name,
             'release_id': parsed_args.release,
         }
     )
     new_env = data_utils.get_display_data_single(self.columns, new_env)
     return (self.columns, new_env)
示例#20
0
    def take_action(self, parsed_args):
        updates = {}
        for attr in self.client._updatable_attributes:
            if getattr(parsed_args, attr, None):
                updates[attr] = getattr(parsed_args, attr)

        updated_node = self.client.update(
            parsed_args.id, **updates)
        numa_topology = self.get_numa_topology_info(updated_node)
        updated_node.update(numa_topology)
        updated_node = data_utils.get_display_data_single(
            self.columns, updated_node)

        return self.columns, updated_node
示例#21
0
    def take_action(self, parsed_args):
        meta = None
        if parsed_args.meta:
            serializer = Serializer.from_params(parsed_args)
            meta = serializer.deserialize(parsed_args.meta)

        net_group = self.client.create(name=parsed_args.name,
                                       release=parsed_args.release,
                                       vlan=parsed_args.vlan,
                                       cidr=parsed_args.cidr,
                                       gateway=parsed_args.gateway,
                                       group_id=parsed_args.node_group,
                                       meta=meta)

        net_group = data_utils.get_display_data_single(self.columns, net_group)
        return self.columns, net_group
示例#22
0
    def take_action(self, parsed_args):
        meta = None
        if parsed_args.meta:
            serializer = Serializer.from_params(parsed_args)
            meta = serializer.deserialize(parsed_args.meta)

        net_group = self.client.create(
            name=parsed_args.name,
            release=parsed_args.release,
            vlan=parsed_args.vlan,
            cidr=parsed_args.cidr,
            gateway=parsed_args.gateway,
            group_id=parsed_args.node_group,
            meta=meta)

        net_group = data_utils.get_display_data_single(self.columns, net_group)
        return self.columns, net_group
示例#23
0
 def take_action(self, parsed_args):
     params = {'effective': True}
     if parsed_args.show_lookup:
         params['show_lookup'] = True
     response = self.get_client().get(self.get_resource_url(parsed_args),
                                      params=params)
     key = parsed_args.key
     if key is not None:
         result = {key: response.get(key, {})}
     else:
         result = response
     columns = sorted(result.keys())
     try:
         data = data_utils.get_display_data_single(columns, result)
         return columns, data
     except fc_error.BadDataException:
         return zip(*response.items())
示例#24
0
 def take_action(self, parsed_args):
     params = {'effective': True}
     if parsed_args.show_lookup:
         params['show_lookup'] = True
     if parsed_args.key:
         params['key'] = parsed_args.key
     response = self.get_client().get(
         self.get_resource_url(parsed_args),
         params=params
     )
     if parsed_args.key:
         result = {parsed_args.key: response}
     else:
         result = response
     columns = sorted(result)
     try:
         data = data_utils.get_display_data_single(columns, result)
         return columns, data
     except fc_error.BadDataException:
         return zip(*response.items())
示例#25
0
    def take_action(self, parsed_args):
        data = self.client.get_by_id(parsed_args.id)
        data = data_utils.get_display_data_single(self.columns, data)

        return (self.columns, data)
示例#26
0
    def test_get_display_data_single_empty_val(self):
        test_data = {"a": 1, "b": {}, "c": []}
        fields = ("a", "b", "c")

        result = data_utils.get_display_data_single(fields, test_data)
        self.assertEqual([1, "-", "-"], result)
示例#27
0
    def test_get_display_data_single_list_val(self):
        test_data = {"a": 1, "b": ["2"], "c": ["3", "4"]}
        fields = ("a", "b", "c")

        result = data_utils.get_display_data_single(fields, test_data)
        self.assertEqual([1, "2", "3, 4"], result)
示例#28
0
    def take_action(self, parsed_args):
        data = self.client.action(parsed_args.id, self.action_status)

        data = data_utils.get_display_data_single(self.columns, data)
        return self.columns, data
示例#29
0
 def take_action(self, parsed_args):
     data = self.client.get_by_id(parsed_args.id)
     numa_topology = self.get_numa_topology_info(data)
     data.update(numa_topology)
     data = data_utils.get_display_data_single(self.columns, data)
     return self.columns, data
示例#30
0
    def test_get_display_data_single_list_val(self):
        test_data = {'a': 1, 'b': ['2'], 'c': ['3', '4']}
        fields = ('a', 'b', 'c')

        result = data_utils.get_display_data_single(fields, test_data)
        self.assertEqual([1, '2', '3, 4'], result)
示例#31
0
 def test_get_display_data_bad_key(self):
     test_data = {'a': 1, 'b': 2, 'c': 3}
     fields = ('b', 'bad_key')
     self.assertEqual([2, None],
                      data_utils.get_display_data_single(fields, test_data))
示例#32
0
    def take_action(self, parsed_args):
        data = self.client.get_by_id(parsed_args.id)
        data = data_utils.get_display_data_single(self.columns, data)

        return (self.columns, data)
示例#33
0
    def test_get_display_data_single_empty_val(self):
        test_data = {'a': 1, 'b': {}, 'c': []}
        fields = ('a', 'b', 'c')

        result = data_utils.get_display_data_single(fields, test_data)
        self.assertEqual([1, '-', '-'], result)
示例#34
0
    def test_get_display_data_single(self):
        test_data = {'a': 1, 'b': 2, 'c': 3}
        fields = ('b', 'c')

        result = data_utils.get_display_data_single(fields, test_data)
        self.assertEqual([2, 3], result)
示例#35
0
 def take_action(self, parsed_args):
     data = self.client.get_by_id(parsed_args.id)
     numa_topology = self.get_numa_topology_info(data)
     data.update(numa_topology)
     data = data_utils.get_display_data_single(self.columns, data)
     return self.columns, data
示例#36
0
    def test_get_display_data_single(self):
        test_data = {'a': 1, 'b': 2, 'c': 3}
        fields = ('b', 'c')

        result = data_utils.get_display_data_single(fields, test_data)
        self.assertEqual([2, 3], result)
示例#37
0
    def test_get_display_data_single_empty_val(self):
        test_data = {'a': 1, 'b': {}, 'c': []}
        fields = ('a', 'b', 'c')

        result = data_utils.get_display_data_single(fields, test_data)
        self.assertEqual([1, '-', '-'], result)
示例#38
0
 def take_action(self, parsed_args):
     data = self.client._entity_wrapper.connection.post_request(
         "clusters/{0}/upgrade/clone_release/{1}".format(parsed_args.env_id, parsed_args.release_id)
     )
     data = data_utils.get_display_data_single(self.columns, data)
     return (self.columns, data)
    def test_get_display_data_single(self):
        test_data = {'a': 1, 'b': [], 'c': [1, 2, 3], 'd': 4}
        fields = ('a', 'b', 'c')

        result = data_utils.get_display_data_single(fields, test_data)
        self.assertEqual([1, [], [1, 2, 3]], result)
示例#40
0
    def test_get_display_data_single(self):
        test_data = {"a": 1, "b": 2, "c": 3}
        fields = ("b", "c")

        result = data_utils.get_display_data_single(fields, test_data)
        self.assertEqual([2, 3], result)