def describe_security_groups(context, group_name=None, group_id=None, filter=None): default_vpc_id = None default_vpc = ec2utils.check_and_create_default_vpc(context) if default_vpc: default_vpc_id = default_vpc['id'] formatted_security_groups = SecurityGroupDescriber( default_vpc_id).describe(context, group_id, group_name, filter) return {'securityGroupInfo': formatted_security_groups}
def describe_security_groups(context, group_name=None, group_id=None, filter=None): default_vpc_id = None default_vpc = ec2utils.check_and_create_default_vpc(context) if default_vpc: default_vpc_id = default_vpc['id'] formatted_security_groups = SecurityGroupDescriber( default_vpc_id).describe(context, group_id, group_name, filter) return {'securityGroupInfo': formatted_security_groups}
def release_address(self, context, public_ip, allocation_id): neutron = clients.neutron(context) if public_ip: # TODO(ft): implement search in DB layer address = next((addr for addr in db_api.get_items(context, 'eipalloc') if addr['public_ip'] == public_ip), None) if address and _is_address_valid(context, neutron, address): msg = _('You must specify an allocation id when releasing a ' 'VPC elastic IP address') raise exception.InvalidParameterValue(msg) os_floating_ip = self.get_os_floating_ip_by_public_ip(context, public_ip) try: neutron.delete_floatingip(os_floating_ip['id']) except neutron_exception.NotFound: pass return address = ec2utils.get_db_item(context, allocation_id) if not _is_address_valid(context, neutron, address): raise exception.InvalidAllocationIDNotFound( id=allocation_id) if 'network_interface_id' in address: if CONF.disable_ec2_classic: network_interface_id = address['network_interface_id'] network_interface = db_api.get_item_by_id(context, network_interface_id) default_vpc = ec2utils.check_and_create_default_vpc(context) if default_vpc: default_vpc_id = default_vpc['id'] if (network_interface and network_interface['vpc_id'] == default_vpc_id): association_id = ec2utils.change_ec2_id_kind(address['id'], 'eipassoc') self.disassociate_address( context, association_id=association_id) else: raise exception.InvalidIPAddressInUse( ip_address=address['public_ip']) else: raise exception.InvalidIPAddressInUse( ip_address=address['public_ip']) with common.OnCrashCleaner() as cleaner: db_api.delete_item(context, address['id']) cleaner.addCleanup(db_api.restore_item, context, 'eipalloc', address) try: neutron.delete_floatingip(address['os_id']) except neutron_exception.NotFound: pass
def release_address(self, context, public_ip, allocation_id): neutron = clients.neutron(context) if public_ip: # TODO(ft): implement search in DB layer address = next((addr for addr in db_api.get_items(context, 'eipalloc') if addr['public_ip'] == public_ip), None) if address and _is_address_valid(context, neutron, address): msg = _('You must specify an allocation id when releasing a ' 'VPC elastic IP address') raise exception.InvalidParameterValue(msg) os_floating_ip = self.get_os_floating_ip_by_public_ip(context, public_ip) try: neutron.delete_floatingip(os_floating_ip['id']) except neutron_exception.NotFound: pass return address = ec2utils.get_db_item(context, allocation_id) if not _is_address_valid(context, neutron, address): raise exception.InvalidAllocationIDNotFound( id=allocation_id) if 'network_interface_id' in address: if CONF.disable_ec2_classic: network_interface_id = address['network_interface_id'] network_interface = db_api.get_item_by_id(context, network_interface_id) default_vpc = ec2utils.check_and_create_default_vpc(context) if default_vpc: default_vpc_id = default_vpc['id'] if (network_interface and network_interface['vpc_id'] == default_vpc_id): association_id = ec2utils.change_ec2_id_kind(address['id'], 'eipassoc') self.disassociate_address( context, association_id=association_id) else: raise exception.InvalidIPAddressInUse( ip_address=address['public_ip']) else: raise exception.InvalidIPAddressInUse( ip_address=address['public_ip']) with common.OnCrashCleaner() as cleaner: db_api.delete_item(context, address['id']) cleaner.addCleanup(db_api.restore_item, context, 'eipalloc', address) try: neutron.delete_floatingip(address['os_id']) except neutron_exception.NotFound: pass
def get_default_vpc(self, context): if CONF.disable_ec2_classic: default_vpc = ec2utils.check_and_create_default_vpc(context) if default_vpc: return default_vpc['id'] return 'none'
def get_default_vpc(self, context): if CONF.disable_ec2_classic: default_vpc = ec2utils.check_and_create_default_vpc(context) if default_vpc: return default_vpc['id'] return 'none'
def describe_subnets(context, subnet_id=None, filter=None): ec2utils.check_and_create_default_vpc(context) formatted_subnets = SubnetDescriber().describe(context, ids=subnet_id, filter=filter) return {'subnetSet': formatted_subnets}
def describe_internet_gateways(context, internet_gateway_id=None, filter=None): ec2utils.check_and_create_default_vpc(context) formatted_igws = InternetGatewayDescriber().describe( context, ids=internet_gateway_id, filter=filter) return {'internetGatewaySet': formatted_igws}
def describe_route_tables(context, route_table_id=None, filter=None): ec2utils.check_and_create_default_vpc(context) formatted_route_tables = RouteTableDescriber().describe( context, ids=route_table_id, filter=filter) return {'routeTableSet': formatted_route_tables}
def describe_internet_gateways(context, internet_gateway_id=None, filter=None): ec2utils.check_and_create_default_vpc(context) formatted_igws = InternetGatewayDescriber().describe( context, ids=internet_gateway_id, filter=filter) return {'internetGatewaySet': formatted_igws}