コード例 #1
0
 def take_action(self, parsed_args):
     client = self.app.client_manager.network
     obj = client.find_subnet(parsed_args.subnet, ignore_missing=False)
     attrs = _get_attrs(self.app.client_manager,
                        parsed_args,
                        is_create=False)
     if 'dns_nameservers' in attrs:
         if not parsed_args.no_dns_nameservers:
             attrs['dns_nameservers'] += obj.dns_nameservers
     elif parsed_args.no_dns_nameservers:
         attrs['dns_nameservers'] = []
     if 'host_routes' in attrs:
         if not parsed_args.no_host_route:
             attrs['host_routes'] += obj.host_routes
     elif parsed_args.no_host_route:
         attrs['host_routes'] = []
     if 'allocation_pools' in attrs:
         if not parsed_args.no_allocation_pool:
             attrs['allocation_pools'] += obj.allocation_pools
     elif parsed_args.no_allocation_pool:
         attrs['allocation_pools'] = []
     if 'service_types' in attrs:
         attrs['service_types'] += obj.service_types
     if attrs:
         client.update_subnet(obj, **attrs)
     # tags is a subresource and it needs to be updated separately.
     _tag.update_tags_for_set(client, obj, parsed_args)
     return
コード例 #2
0
    def take_action_network(self, client, parsed_args):
        # Build the create attributes.
        attrs = {}
        attrs['name'] = parsed_args.name
        attrs['description'] = self._get_description(parsed_args)
        if parsed_args.project is not None:
            identity_client = self.app.client_manager.identity
            project_id = identity_common.find_project(
                identity_client,
                parsed_args.project,
                parsed_args.project_domain,
            ).id
            attrs['tenant_id'] = project_id

        # Create the security group and display the results.
        obj = client.create_security_group(**attrs)
        # tags cannot be set when created, so tags need to be set later.
        _tag.update_tags_for_set(client, obj, parsed_args)
        display_columns, property_columns = _get_columns(obj)
        data = utils.get_item_properties(
            obj,
            property_columns,
            formatters=_formatters_network
        )
        return (display_columns, data)
コード例 #3
0
    def take_action(self, parsed_args):
        client = self.app.client_manager.network

        _prepare_fixed_ips(self.app.client_manager, parsed_args)
        obj = client.find_port(parsed_args.port, ignore_missing=False)
        attrs = _get_attrs(self.app.client_manager, parsed_args)

        if parsed_args.no_binding_profile:
            attrs['binding:profile'] = {}
        if parsed_args.binding_profile:
            if 'binding:profile' not in attrs:
                attrs['binding:profile'] = copy.deepcopy(obj.binding_profile)
            attrs['binding:profile'].update(parsed_args.binding_profile)

        if parsed_args.no_fixed_ip:
            attrs['fixed_ips'] = []
        if parsed_args.fixed_ip:
            if 'fixed_ips' not in attrs:
                # obj.fixed_ips = [{}] if no fixed IPs are set.
                # Only append this to attrs['fixed_ips'] if actual fixed
                # IPs are present to avoid adding an empty dict.
                attrs['fixed_ips'] = [ip for ip in obj.fixed_ips if ip]
            attrs['fixed_ips'].extend(parsed_args.fixed_ip)

        if parsed_args.no_security_group:
            attrs['security_group_ids'] = []
        if parsed_args.security_group:
            if 'security_group_ids' not in attrs:
                # NOTE(dtroyer): Get existing security groups, iterate the
                #                list to force a new list object to be
                #                created and make sure the SDK Resource
                #                marks the attribute 'dirty'.
                attrs['security_group_ids'] = [
                    id for id in obj.security_group_ids
                ]
            attrs['security_group_ids'].extend(
                client.find_security_group(sg, ignore_missing=False).id
                for sg in parsed_args.security_group
            )

        if parsed_args.no_allowed_address_pair:
            attrs['allowed_address_pairs'] = []
        if parsed_args.allowed_address_pairs:
            if 'allowed_address_pairs' not in attrs:
                attrs['allowed_address_pairs'] = (
                    [addr for addr in obj.allowed_address_pairs if addr]
                )
            attrs['allowed_address_pairs'].extend(
                _convert_address_pairs(parsed_args)
            )
        if parsed_args.data_plane_status:
            attrs['data_plane_status'] = parsed_args.data_plane_status

        if attrs:
            with common.check_missing_extension_if_error(
                    self.app.client_manager.network, attrs):
                client.update_port(obj, **attrs)

        # tags is a subresource and it needs to be updated separately.
        _tag.update_tags_for_set(client, obj, parsed_args)
コード例 #4
0
    def take_action(self, parsed_args):
        client = self.app.client_manager.network
        obj = client.find_router(parsed_args.router, ignore_missing=False)

        # Get the common attributes.
        attrs = _get_attrs(self.app.client_manager, parsed_args)

        # Get the route attributes.
        if parsed_args.ha:
            attrs['ha'] = True
        elif parsed_args.no_ha:
            attrs['ha'] = False
        if parsed_args.clear_routes:
            LOG.warning(_(
                'The --clear-routes option is deprecated, '
                'please use --no-route instead.'
            ))

        if parsed_args.routes is not None:
            for route in parsed_args.routes:
                route['nexthop'] = route.pop('gateway')
            attrs['routes'] = parsed_args.routes
            if not (parsed_args.no_route or parsed_args.clear_routes):
                # Map the route keys and append to the current routes.
                # The REST API will handle route validation and duplicates.
                attrs['routes'] += obj.routes
        elif parsed_args.no_route or parsed_args.clear_routes:
            attrs['routes'] = []
        if (parsed_args.disable_snat or parsed_args.enable_snat or
           parsed_args.fixed_ip) and not parsed_args.external_gateway:
                msg = (_("You must specify '--external-gateway' in order"
                         "to update the SNAT or fixed-ip values"))
                raise exceptions.CommandError(msg)
        if parsed_args.external_gateway:
            gateway_info = {}
            network = client.find_network(
                parsed_args.external_gateway, ignore_missing=False)
            gateway_info['network_id'] = network.id
            if parsed_args.disable_snat:
                gateway_info['enable_snat'] = False
            if parsed_args.enable_snat:
                gateway_info['enable_snat'] = True
            if parsed_args.fixed_ip:
                ips = []
                for ip_spec in parsed_args.fixed_ip:
                    if ip_spec.get('subnet', False):
                        subnet_name_id = ip_spec.pop('subnet')
                        if subnet_name_id:
                            subnet = client.find_subnet(subnet_name_id,
                                                        ignore_missing=False)
                            ip_spec['subnet_id'] = subnet.id
                    if ip_spec.get('ip-address', False):
                        ip_spec['ip_address'] = ip_spec.pop('ip-address')
                    ips.append(ip_spec)
                gateway_info['external_fixed_ips'] = ips
            attrs['external_gateway_info'] = gateway_info
        if attrs:
            client.update_router(obj, **attrs)
        # tags is a subresource and it needs to be updated separately.
        _tag.update_tags_for_set(client, obj, parsed_args)
コード例 #5
0
    def take_action(self, parsed_args):
        client = self.app.client_manager.network
        attrs = {}
        obj = client.find_ip(
            parsed_args.floating_ip,
            ignore_missing=False,
        )
        if parsed_args.port:
            port = client.find_port(parsed_args.port, ignore_missing=False)
            attrs['port_id'] = port.id

        if parsed_args.fixed_ip_address:
            attrs['fixed_ip_address'] = parsed_args.fixed_ip_address

        if parsed_args.qos_policy:
            attrs['qos_policy_id'] = client.find_qos_policy(
                parsed_args.qos_policy, ignore_missing=False).id

        if 'no_qos_policy' in parsed_args and parsed_args.no_qos_policy:
            attrs['qos_policy_id'] = None

        if attrs:
            client.update_ip(obj, **attrs)

        # tags is a subresource and it needs to be updated separately.
        _tag.update_tags_for_set(client, obj, parsed_args)
コード例 #6
0
    def take_action(self, parsed_args):
        client = self.app.client_manager.network

        _prepare_fixed_ips(self.app.client_manager, parsed_args)
        obj = client.find_port(parsed_args.port, ignore_missing=False)
        attrs = _get_attrs(self.app.client_manager, parsed_args)

        if parsed_args.no_binding_profile:
            attrs['binding:profile'] = {}
        if parsed_args.binding_profile:
            if 'binding:profile' not in attrs:
                attrs['binding:profile'] = copy.deepcopy(obj.binding_profile)
            attrs['binding:profile'].update(parsed_args.binding_profile)

        if parsed_args.no_fixed_ip:
            attrs['fixed_ips'] = []
        if parsed_args.fixed_ip:
            if 'fixed_ips' not in attrs:
                # obj.fixed_ips = [{}] if no fixed IPs are set.
                # Only append this to attrs['fixed_ips'] if actual fixed
                # IPs are present to avoid adding an empty dict.
                attrs['fixed_ips'] = [ip for ip in obj.fixed_ips if ip]
            attrs['fixed_ips'].extend(parsed_args.fixed_ip)

        if parsed_args.no_security_group:
            attrs['security_group_ids'] = []
        if parsed_args.security_group:
            if 'security_group_ids' not in attrs:
                # NOTE(dtroyer): Get existing security groups, iterate the
                #                list to force a new list object to be
                #                created and make sure the SDK Resource
                #                marks the attribute 'dirty'.
                attrs['security_group_ids'] = [
                    id for id in obj.security_group_ids
                ]
            attrs['security_group_ids'].extend(
                client.find_security_group(sg, ignore_missing=False).id
                for sg in parsed_args.security_group
            )

        if parsed_args.no_allowed_address_pair:
            attrs['allowed_address_pairs'] = []
        if parsed_args.allowed_address_pairs:
            if 'allowed_address_pairs' not in attrs:
                attrs['allowed_address_pairs'] = (
                    [addr for addr in obj.allowed_address_pairs if addr]
                )
            attrs['allowed_address_pairs'].extend(
                _convert_address_pairs(parsed_args)
            )
        if parsed_args.data_plane_status:
            attrs['data_plane_status'] = parsed_args.data_plane_status

        if attrs:
            with common.check_missing_extension_if_error(
                    self.app.client_manager.network, attrs):
                client.update_port(obj, **attrs)

        # tags is a subresource and it needs to be updated separately.
        _tag.update_tags_for_set(client, obj, parsed_args)
コード例 #7
0
 def take_action_network(self, client, parsed_args):
     attrs = _get_attrs(self.app.client_manager, parsed_args)
     obj = client.create_ip(**attrs)
     # tags cannot be set when created, so tags need to be set later.
     _tag.update_tags_for_set(client, obj, parsed_args)
     display_columns, columns = _get_network_columns(obj)
     data = utils.get_item_properties(obj, columns)
     return (display_columns, data)
コード例 #8
0
    def take_action(self, parsed_args):
        client = self.app.client_manager.network
        obj = client.find_network(parsed_args.network, ignore_missing=False)

        attrs = _get_attrs_network(self.app.client_manager, parsed_args)
        if attrs:
            client.update_network(obj, **attrs)

        # tags is a subresource and it needs to be updated separately.
        _tag.update_tags_for_set(client, obj, parsed_args)
コード例 #9
0
 def take_action(self, parsed_args):
     client = self.app.client_manager.network
     attrs = _get_attrs(self.app.client_manager, parsed_args)
     # NeutronServer expects prefixes to be a List
     if "prefixes" not in attrs:
         attrs['prefixes'] = []
     obj = client.create_subnet_pool(**attrs)
     # tags cannot be set when created, so tags need to be set later.
     _tag.update_tags_for_set(client, obj, parsed_args)
     display_columns, columns = _get_columns(obj)
     data = utils.get_item_properties(obj, columns, formatters=_formatters)
     return (display_columns, data)
コード例 #10
0
    def take_action_network(self, client, parsed_args):
        attrs = _get_attrs_network(self.app.client_manager, parsed_args)
        if parsed_args.transparent_vlan:
            attrs['vlan_transparent'] = True
        if parsed_args.no_transparent_vlan:
            attrs['vlan_transparent'] = False

        obj = client.create_network(**attrs)
        # tags cannot be set when created, so tags need to be set later.
        _tag.update_tags_for_set(client, obj, parsed_args)
        display_columns, columns = _get_columns_network(obj)
        data = utils.get_item_properties(obj, columns, formatters=_formatters)
        return (display_columns, data)
コード例 #11
0
    def take_action(self, parsed_args):
        client = self.app.client_manager.network
        obj = client.find_subnet_pool(parsed_args.subnet_pool,
                                      ignore_missing=False)

        attrs = _get_attrs(self.app.client_manager, parsed_args)

        # Existing prefixes must be a subset of the new prefixes.
        if 'prefixes' in attrs:
            attrs['prefixes'].extend(obj.prefixes)

        if attrs:
            client.update_subnet_pool(obj, **attrs)
        # tags is a subresource and it needs to be updated separately.
        _tag.update_tags_for_set(client, obj, parsed_args)
コード例 #12
0
    def take_action_network(self, client, parsed_args):
        obj = client.find_security_group(parsed_args.group,
                                         ignore_missing=False)
        attrs = {}
        if parsed_args.name is not None:
            attrs['name'] = parsed_args.name
        if parsed_args.description is not None:
            attrs['description'] = parsed_args.description
        # NOTE(rtheis): Previous behavior did not raise a CommandError
        # if there were no updates. Maintain this behavior and issue
        # the update.
        client.update_security_group(obj, **attrs)

        # tags is a subresource and it needs to be updated separately.
        _tag.update_tags_for_set(client, obj, parsed_args)
コード例 #13
0
    def take_action_network(self, client, parsed_args):
        obj = client.find_security_group(parsed_args.group,
                                         ignore_missing=False)
        attrs = {}
        if parsed_args.name is not None:
            attrs['name'] = parsed_args.name
        if parsed_args.description is not None:
            attrs['description'] = parsed_args.description
        # NOTE(rtheis): Previous behavior did not raise a CommandError
        # if there were no updates. Maintain this behavior and issue
        # the update.
        client.update_security_group(obj, **attrs)

        # tags is a subresource and it needs to be updated separately.
        _tag.update_tags_for_set(client, obj, parsed_args)
コード例 #14
0
    def take_action(self, parsed_args):
        client = self.app.client_manager.network

        attrs = _get_attrs(self.app.client_manager, parsed_args)
        if parsed_args.ha:
            attrs['ha'] = True
        if parsed_args.no_ha:
            attrs['ha'] = False
        obj = client.create_router(**attrs)
        # tags cannot be set when created, so tags need to be set later.
        _tag.update_tags_for_set(client, obj, parsed_args)

        display_columns, columns = _get_columns(obj)
        data = utils.get_item_properties(obj, columns, formatters=_formatters)

        return (display_columns, data)
コード例 #15
0
    def take_action(self, parsed_args):
        client = self.app.client_manager.network

        attrs = _get_attrs(self.app.client_manager, parsed_args)
        if parsed_args.ha:
            attrs['ha'] = True
        if parsed_args.no_ha:
            attrs['ha'] = False
        obj = client.create_router(**attrs)
        # tags cannot be set when created, so tags need to be set later.
        _tag.update_tags_for_set(client, obj, parsed_args)

        display_columns, columns = _get_columns(obj)
        data = utils.get_item_properties(obj, columns, formatters=_formatters)

        return (display_columns, data)
コード例 #16
0
    def take_action(self, parsed_args):
        client = self.app.client_manager.network
        _network = client.find_network(parsed_args.network,
                                       ignore_missing=False)
        parsed_args.network = _network.id
        _prepare_fixed_ips(self.app.client_manager, parsed_args)
        attrs = _get_attrs(self.app.client_manager, parsed_args)

        if parsed_args.binding_profile is not None:
            attrs['binding:profile'] = parsed_args.binding_profile

        if parsed_args.fixed_ip:
            attrs['fixed_ips'] = parsed_args.fixed_ip
        elif parsed_args.no_fixed_ip:
            attrs['fixed_ips'] = []

        if parsed_args.security_group:
            attrs['security_group_ids'] = [
                client.find_security_group(sg, ignore_missing=False).id
                for sg in parsed_args.security_group
            ]
        elif parsed_args.no_security_group:
            attrs['security_group_ids'] = []

        if parsed_args.allowed_address_pairs:
            attrs['allowed_address_pairs'] = (
                _convert_address_pairs(parsed_args))

        if parsed_args.extra_dhcp_options:
            attrs["extra_dhcp_opts"] = _convert_extra_dhcp_options(parsed_args)

        if parsed_args.qos_policy:
            attrs['qos_policy_id'] = client.find_qos_policy(
                parsed_args.qos_policy, ignore_missing=False).id
        with common.check_missing_extension_if_error(
                self.app.client_manager.network, attrs):
            obj = client.create_port(**attrs)

        # tags cannot be set when created, so tags need to be set later.
        _tag.update_tags_for_set(client, obj, parsed_args)
        display_columns, columns = _get_columns(obj)
        data = utils.get_item_properties(obj, columns, formatters=_formatters)

        return (display_columns, data)
コード例 #17
0
    def take_action(self, parsed_args):
        client = self.app.client_manager.network
        _network = client.find_network(parsed_args.network,
                                       ignore_missing=False)
        parsed_args.network = _network.id
        _prepare_fixed_ips(self.app.client_manager, parsed_args)
        attrs = _get_attrs(self.app.client_manager, parsed_args)

        if parsed_args.binding_profile is not None:
            attrs['binding:profile'] = parsed_args.binding_profile

        if parsed_args.fixed_ip:
            attrs['fixed_ips'] = parsed_args.fixed_ip
        elif parsed_args.no_fixed_ip:
            attrs['fixed_ips'] = []

        if parsed_args.security_group:
            attrs['security_group_ids'] = [client.find_security_group(
                                           sg, ignore_missing=False).id
                                           for sg in
                                           parsed_args.security_group]
        elif parsed_args.no_security_group:
            attrs['security_group_ids'] = []

        if parsed_args.allowed_address_pairs:
            attrs['allowed_address_pairs'] = (
                _convert_address_pairs(parsed_args))

        if parsed_args.qos_policy:
            attrs['qos_policy_id'] = client.find_qos_policy(
                parsed_args.qos_policy, ignore_missing=False).id
        with common.check_missing_extension_if_error(
                self.app.client_manager.network, attrs):
            obj = client.create_port(**attrs)

        # tags cannot be set when created, so tags need to be set later.
        _tag.update_tags_for_set(client, obj, parsed_args)
        display_columns, columns = _get_columns(obj)
        data = utils.get_item_properties(obj, columns, formatters=_formatters)

        return (display_columns, data)
コード例 #18
0
    def take_action_network(self, client, parsed_args):
        # Build the create attributes.
        attrs = {}
        attrs['name'] = parsed_args.name
        attrs['description'] = self._get_description(parsed_args)
        if parsed_args.project is not None:
            identity_client = self.app.client_manager.identity
            project_id = identity_common.find_project(
                identity_client,
                parsed_args.project,
                parsed_args.project_domain,
            ).id
            attrs['tenant_id'] = project_id

        # Create the security group and display the results.
        obj = client.create_security_group(**attrs)
        # tags cannot be set when created, so tags need to be set later.
        _tag.update_tags_for_set(client, obj, parsed_args)
        display_columns, property_columns = _get_columns(obj)
        data = utils.get_item_properties(obj,
                                         property_columns,
                                         formatters=_formatters_network)
        return (display_columns, data)
コード例 #19
0
    def take_action(self, parsed_args):
        client = self.app.client_manager.network
        obj = client.find_router(parsed_args.router, ignore_missing=False)

        # Get the common attributes.
        attrs = _get_attrs(self.app.client_manager, parsed_args)

        # Get the route attributes.
        if parsed_args.ha:
            attrs['ha'] = True
        elif parsed_args.no_ha:
            attrs['ha'] = False
        if parsed_args.clear_routes:
            LOG.warning(_(
                'The --clear-routes option is deprecated, '
                'please use --no-route instead.'
            ))

        if parsed_args.routes is not None:
            for route in parsed_args.routes:
                route['nexthop'] = route.pop('gateway')
            attrs['routes'] = parsed_args.routes
            if not (parsed_args.no_route or parsed_args.clear_routes):
                # Map the route keys and append to the current routes.
                # The REST API will handle route validation and duplicates.
                attrs['routes'] += obj.routes
        elif parsed_args.no_route or parsed_args.clear_routes:
            attrs['routes'] = []
        if (parsed_args.disable_snat or parsed_args.enable_snat or
                parsed_args.fixed_ip) and not parsed_args.external_gateway:
            msg = (_("You must specify '--external-gateway' in order "
                     "to update the SNAT or fixed-ip values"))
            raise exceptions.CommandError(msg)
        if parsed_args.external_gateway:
            gateway_info = {}
            network = client.find_network(
                parsed_args.external_gateway, ignore_missing=False)
            gateway_info['network_id'] = network.id
            if parsed_args.disable_snat:
                gateway_info['enable_snat'] = False
            if parsed_args.enable_snat:
                gateway_info['enable_snat'] = True
            if parsed_args.fixed_ip:
                ips = []
                for ip_spec in parsed_args.fixed_ip:
                    if ip_spec.get('subnet', False):
                        subnet_name_id = ip_spec.pop('subnet')
                        if subnet_name_id:
                            subnet = client.find_subnet(subnet_name_id,
                                                        ignore_missing=False)
                            ip_spec['subnet_id'] = subnet.id
                    if ip_spec.get('ip-address', False):
                        ip_spec['ip_address'] = ip_spec.pop('ip-address')
                    ips.append(ip_spec)
                gateway_info['external_fixed_ips'] = ips
            attrs['external_gateway_info'] = gateway_info

        if ((parsed_args.qos_policy or parsed_args.no_qos_policy) and
                not parsed_args.external_gateway):
            try:
                original_net_id = obj.external_gateway_info['network_id']
            except (KeyError, TypeError):
                msg = (_("You must specify '--external-gateway' or the router "
                         "must already have an external network in order to "
                         "set router gateway IP QoS"))
                raise exceptions.CommandError(msg)
            else:
                if not attrs.get('external_gateway_info'):
                    attrs['external_gateway_info'] = {}
                attrs['external_gateway_info']['network_id'] = original_net_id
        if parsed_args.qos_policy:
            check_qos_id = client.find_qos_policy(
                parsed_args.qos_policy, ignore_missing=False).id
            attrs['external_gateway_info']['qos_policy_id'] = check_qos_id

        if 'no_qos_policy' in parsed_args and parsed_args.no_qos_policy:
            attrs['external_gateway_info']['qos_policy_id'] = None
        if attrs:
            client.update_router(obj, **attrs)
        # tags is a subresource and it needs to be updated separately.
        _tag.update_tags_for_set(client, obj, parsed_args)
コード例 #20
0
    def take_action(self, parsed_args):
        client = self.app.client_manager.network
        obj = client.find_router(parsed_args.router, ignore_missing=False)

        # Get the common attributes.
        attrs = _get_attrs(self.app.client_manager, parsed_args)

        # Get the route attributes.
        if parsed_args.ha:
            attrs['ha'] = True
        elif parsed_args.no_ha:
            attrs['ha'] = False

        if parsed_args.routes is not None:
            for route in parsed_args.routes:
                route['nexthop'] = route.pop('gateway')
            attrs['routes'] = parsed_args.routes
            if not parsed_args.no_route:
                # Map the route keys and append to the current routes.
                # The REST API will handle route validation and duplicates.
                attrs['routes'] += obj.routes
        elif parsed_args.no_route:
            attrs['routes'] = []
        if (parsed_args.disable_snat or parsed_args.enable_snat
                or parsed_args.fixed_ip) and not parsed_args.external_gateway:
            msg = (_("You must specify '--external-gateway' in order "
                     "to update the SNAT or fixed-ip values"))
            raise exceptions.CommandError(msg)
        if parsed_args.external_gateway:
            gateway_info = {}
            network = client.find_network(parsed_args.external_gateway,
                                          ignore_missing=False)
            gateway_info['network_id'] = network.id
            if parsed_args.disable_snat:
                gateway_info['enable_snat'] = False
            if parsed_args.enable_snat:
                gateway_info['enable_snat'] = True
            if parsed_args.fixed_ip:
                ips = []
                for ip_spec in parsed_args.fixed_ip:
                    if ip_spec.get('subnet', False):
                        subnet_name_id = ip_spec.pop('subnet')
                        if subnet_name_id:
                            subnet = client.find_subnet(subnet_name_id,
                                                        ignore_missing=False)
                            ip_spec['subnet_id'] = subnet.id
                    if ip_spec.get('ip-address', False):
                        ip_spec['ip_address'] = ip_spec.pop('ip-address')
                    ips.append(ip_spec)
                gateway_info['external_fixed_ips'] = ips
            attrs['external_gateway_info'] = gateway_info

        if ((parsed_args.qos_policy or parsed_args.no_qos_policy)
                and not parsed_args.external_gateway):
            try:
                original_net_id = obj.external_gateway_info['network_id']
            except (KeyError, TypeError):
                msg = (_("You must specify '--external-gateway' or the router "
                         "must already have an external network in order to "
                         "set router gateway IP QoS"))
                raise exceptions.CommandError(msg)
            else:
                if not attrs.get('external_gateway_info'):
                    attrs['external_gateway_info'] = {}
                attrs['external_gateway_info']['network_id'] = original_net_id
        if parsed_args.qos_policy:
            check_qos_id = client.find_qos_policy(parsed_args.qos_policy,
                                                  ignore_missing=False).id
            attrs['external_gateway_info']['qos_policy_id'] = check_qos_id

        if 'no_qos_policy' in parsed_args and parsed_args.no_qos_policy:
            attrs['external_gateway_info']['qos_policy_id'] = None
        if attrs:
            client.update_router(obj, **attrs)
        # tags is a subresource and it needs to be updated separately.
        _tag.update_tags_for_set(client, obj, parsed_args)