def take_action(self, parsed_args): client = self.app.client_manager.network obj = client.find_subnet(parsed_args.subnet, ignore_missing=False) tmp_obj = copy.deepcopy(obj) attrs = {} if parsed_args.dns_nameservers: _update_arguments(tmp_obj.dns_nameservers, parsed_args.dns_nameservers, 'dns-nameserver') attrs['dns_nameservers'] = tmp_obj.dns_nameservers if parsed_args.host_routes: _update_arguments( tmp_obj.host_routes, convert_entries_to_nexthop(parsed_args.host_routes), 'host-route') attrs['host_routes'] = tmp_obj.host_routes if parsed_args.allocation_pools: _update_arguments(tmp_obj.allocation_pools, parsed_args.allocation_pools, 'allocation-pool') attrs['allocation_pools'] = tmp_obj.allocation_pools if parsed_args.service_types: _update_arguments(tmp_obj.service_types, parsed_args.service_types, 'service-type') attrs['service_types'] = tmp_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_unset(client, obj, parsed_args)
def take_action(self, parsed_args): client = self.app.client_manager.network obj = client.find_security_group(parsed_args.group, ignore_missing=False) # tags is a subresource and it needs to be updated separately. _tag.update_tags_for_unset(client, obj, parsed_args)
def take_action(self, parsed_args): client = self.app.client_manager.network obj = client.find_router(parsed_args.router, ignore_missing=False) tmp_routes = copy.deepcopy(obj.routes) tmp_external_gateway_info = copy.deepcopy(obj.external_gateway_info) attrs = {} if parsed_args.routes: try: for route in parsed_args.routes: route['nexthop'] = route.pop('gateway') tmp_routes.remove(route) except ValueError: msg = (_("Router does not contain route %s") % route) raise exceptions.CommandError(msg) attrs['routes'] = tmp_routes if parsed_args.qos_policy: try: if (tmp_external_gateway_info['network_id'] and tmp_external_gateway_info['qos_policy_id']): pass except (KeyError, TypeError): msg = _("Router does not have external network or qos policy") raise exceptions.CommandError(msg) else: attrs['external_gateway_info'] = { 'network_id': tmp_external_gateway_info['network_id'], 'qos_policy_id': None } if parsed_args.external_gateway: attrs['external_gateway_info'] = {} if attrs: client.update_router(obj, **attrs) # tags is a subresource and it needs to be updated separately. _tag.update_tags_for_unset(client, obj, parsed_args)
def take_action(self, parsed_args): client = self.app.client_manager.network obj = client.find_security_group(parsed_args.group, ignore_missing=False) # tags is a subresource and it needs to be updated separately. _tag.update_tags_for_unset(client, obj, parsed_args)
def take_action(self, parsed_args): client = self.app.client_manager.network obj = client.find_router(parsed_args.router, ignore_missing=False) tmp_routes = copy.deepcopy(obj.routes) tmp_external_gateway_info = copy.deepcopy(obj.external_gateway_info) attrs = {} if parsed_args.routes: try: for route in parsed_args.routes: route['nexthop'] = route.pop('gateway') tmp_routes.remove(route) except ValueError: msg = (_("Router does not contain route %s") % route) raise exceptions.CommandError(msg) attrs['routes'] = tmp_routes if parsed_args.qos_policy: try: if (tmp_external_gateway_info['network_id'] and tmp_external_gateway_info['qos_policy_id']): pass except (KeyError, TypeError): msg = _("Router does not have external network or qos policy") raise exceptions.CommandError(msg) else: attrs['external_gateway_info'] = { 'network_id': tmp_external_gateway_info['network_id'], 'qos_policy_id': None } if parsed_args.external_gateway: attrs['external_gateway_info'] = {} if attrs: client.update_router(obj, **attrs) # tags is a subresource and it needs to be updated separately. _tag.update_tags_for_unset(client, obj, parsed_args)
def take_action(self, parsed_args): client = self.app.client_manager.network obj = client.find_network(parsed_args.network, ignore_missing=False) # NOTE: As of now, UnsetNetwork has no attributes which need # to be updated by update_network(). # tags is a subresource and it needs to be updated separately. _tag.update_tags_for_unset(client, obj, parsed_args)
def take_action(self, parsed_args): client = self.app.client_manager.network obj = client.find_port(parsed_args.port, ignore_missing=False) # SDK ignores update() if it receives a modified obj and attrs # To handle the same tmp_obj is created in all take_action of # Unset* classes tmp_fixed_ips = copy.deepcopy(obj.fixed_ips) tmp_binding_profile = copy.deepcopy(obj.binding_profile) tmp_secgroups = copy.deepcopy(obj.security_group_ids) tmp_addr_pairs = copy.deepcopy(obj.allowed_address_pairs) _prepare_fixed_ips(self.app.client_manager, parsed_args) attrs = {} if parsed_args.fixed_ip: try: for ip in parsed_args.fixed_ip: tmp_fixed_ips.remove(ip) except ValueError: msg = _("Port does not contain fixed-ip %s") % ip raise exceptions.CommandError(msg) attrs['fixed_ips'] = tmp_fixed_ips if parsed_args.binding_profile: try: for key in parsed_args.binding_profile: del tmp_binding_profile[key] except KeyError: msg = _("Port does not contain binding-profile %s") % key raise exceptions.CommandError(msg) attrs['binding:profile'] = tmp_binding_profile if parsed_args.security_group_ids: try: for sg in parsed_args.security_group_ids: sg_id = client.find_security_group(sg, ignore_missing=False).id tmp_secgroups.remove(sg_id) except ValueError: msg = _("Port does not contain security group %s") % sg raise exceptions.CommandError(msg) attrs['security_group_ids'] = tmp_secgroups if parsed_args.allowed_address_pairs: try: for addr in _convert_address_pairs(parsed_args): tmp_addr_pairs.remove(addr) except ValueError: msg = _("Port does not contain allowed-address-pair %s") % addr raise exceptions.CommandError(msg) attrs['allowed_address_pairs'] = tmp_addr_pairs if parsed_args.qos_policy: attrs['qos_policy_id'] = None if parsed_args.data_plane_status: attrs['data_plane_status'] = None if attrs: client.update_port(obj, **attrs) # tags is a subresource and it needs to be updated separately. _tag.update_tags_for_unset(client, obj, parsed_args)
def take_action(self, parsed_args): client = self.app.client_manager.network obj = client.find_port(parsed_args.port, ignore_missing=False) # SDK ignores update() if it receives a modified obj and attrs # To handle the same tmp_obj is created in all take_action of # Unset* classes tmp_fixed_ips = copy.deepcopy(obj.fixed_ips) tmp_binding_profile = copy.deepcopy(obj.binding_profile) tmp_secgroups = copy.deepcopy(obj.security_group_ids) tmp_addr_pairs = copy.deepcopy(obj.allowed_address_pairs) _prepare_fixed_ips(self.app.client_manager, parsed_args) attrs = {} if parsed_args.fixed_ip: try: for ip in parsed_args.fixed_ip: tmp_fixed_ips.remove(ip) except ValueError: msg = _("Port does not contain fixed-ip %s") % ip raise exceptions.CommandError(msg) attrs['fixed_ips'] = tmp_fixed_ips if parsed_args.binding_profile: try: for key in parsed_args.binding_profile: del tmp_binding_profile[key] except KeyError: msg = _("Port does not contain binding-profile %s") % key raise exceptions.CommandError(msg) attrs['binding:profile'] = tmp_binding_profile if parsed_args.security_group_ids: try: for sg in parsed_args.security_group_ids: sg_id = client.find_security_group( sg, ignore_missing=False).id tmp_secgroups.remove(sg_id) except ValueError: msg = _("Port does not contain security group %s") % sg raise exceptions.CommandError(msg) attrs['security_group_ids'] = tmp_secgroups if parsed_args.allowed_address_pairs: try: for addr in _convert_address_pairs(parsed_args): tmp_addr_pairs.remove(addr) except ValueError: msg = _("Port does not contain allowed-address-pair %s") % addr raise exceptions.CommandError(msg) attrs['allowed_address_pairs'] = tmp_addr_pairs if parsed_args.qos_policy: attrs['qos_policy_id'] = None if parsed_args.data_plane_status: attrs['data_plane_status'] = None if attrs: client.update_port(obj, **attrs) # tags is a subresource and it needs to be updated separately. _tag.update_tags_for_unset(client, obj, parsed_args)
def take_action(self, parsed_args): client = self.app.client_manager.network obj = client.find_ip( parsed_args.floating_ip, ignore_missing=False, ) attrs = {} if parsed_args.port: attrs['port_id'] = None if parsed_args.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_unset(client, obj, parsed_args)
def take_action(self, parsed_args): client = self.app.client_manager.network obj = client.find_subnet_pool(parsed_args.subnet_pool, ignore_missing=False) tmp_prefixes = copy.deepcopy(obj.prefixes) attrs = {} if parsed_args.prefixes: for prefix in parsed_args.prefixes: try: tmp_prefixes.remove(prefix) except ValueError: msg = _("Subnet pool does not " "contain prefix %s") % prefix raise exceptions.CommandError(msg) attrs['prefixes'] = tmp_prefixes if attrs: client.update_subnet_pool(obj, **attrs) # tags is a subresource and it needs to be updated separately. _tag.update_tags_for_unset(client, obj, parsed_args)
def take_action(self, parsed_args): client = self.app.client_manager.network obj = client.find_router(parsed_args.router, ignore_missing=False) tmp_routes = copy.deepcopy(obj.routes) attrs = {} if parsed_args.routes: try: for route in parsed_args.routes: route['nexthop'] = route.pop('gateway') tmp_routes.remove(route) except ValueError: msg = (_("Router does not contain route %s") % route) raise exceptions.CommandError(msg) attrs['routes'] = tmp_routes if parsed_args.external_gateway: attrs['external_gateway_info'] = {} if attrs: client.update_router(obj, **attrs) # tags is a subresource and it needs to be updated separately. _tag.update_tags_for_unset(client, obj, parsed_args)