VPC API

The Virtual Private Cloud Class

The nat high-level interface is available through the vpc member of a Connection object. The vpc member will only be added if the otcextensions.sdk.register_otc_extensions(conn) method is called.

VPC Bandwidth Operations

class otcextensions.sdk.vpc.v1._proxy.Proxy(session, statsd_client=None, statsd_prefix=None, prometheus_counter=None, prometheus_histogram=None, influxdb_config=None, influxdb_client=None, *args, **kwargs)
assign_bandwidth(**attrs)

Assign bandwidth

Parameters:

attrs (dict) – Keyword arguments which will be used to assign a Bandwidth

find_bandwidth(name_or_id, ignore_missing=False)

Find a single bandwidth

Parameters:
  • name_or_id – The name or ID of a bandwidth

  • ignore_missing (bool) – When set to False ResourceNotFound will be raised when the vpc peering does not exist. When set to True, no exception will be set when attempting to delete a nonexistent peering.

Returns:

One Bandwidth

update_bandwidth(bandwidth, **attrs)

Update a vpc peering

Parameters:
  • bandwidth – Either the ID of a vpc bandwidth or a Bandwidth instance.

  • attrs (dict) – The attributes to update on the vpc bandwidth represented by bandwidth.

Returns:

The updated bandwidth

Return type:

Bandwidth

add_eip_to_bandwidth(bandwidth, publicip_info: List[PublicInfo])

Add an EIP to a shared bandwidth.

Parameters:
  • bandwidth – The value can be the ID of a bandwidth or a Bandwidth instance.

  • publicip_info – List of dictionaries in the format {‘publicip_id’: id, ‘publicip_type’: type}

remove_eip_from_bandwidth(bandwidth, **attrs)

Add an EIP to a shared bandwidth.

Parameters:
  • bandwidth – The value can be the ID of a bandwidth or a Bandwidth instance.

  • attrs – Keyword arguments to remove eip: charge_mode, size, publicip_info - array of eip in the format {‘publicip_id’: id}

delete_bandwidth(bandwidth, ignore_missing=True)

Delete a bandwidth

Parameters:
  • bandwidth – key id or an instance of Bandwidth

  • ignore_missing (bool) – When set to False ResourceNotFound will be raised when the vpc peering does not exist. When set to True, no exception will be set when attempting to delete a nonexistent peering.

Returns:

None

VPC Peering Operations

class otcextensions.sdk.vpc.v1._proxy.Proxy(session, statsd_client=None, statsd_prefix=None, prometheus_counter=None, prometheus_histogram=None, influxdb_config=None, influxdb_client=None, *args, **kwargs)
create_peering(**attrs)

Create a new vpc peering from attributes

Parameters:

attrs (dict) – Keyword arguments which will be used to create a Peering

delete_peering(peering, ignore_missing=True)

Delete a vpc peering

Parameters:
  • peering – key id or an instance of Peering

  • ignore_missing (bool) – When set to False ResourceNotFound will be raised when the vpc peering does not exist. When set to True, no exception will be set when attempting to delete a nonexistent peering.

Returns:

None

peerings(**query)

Return a generator of vpc peerings

Parameters:

query (dict) – Optional query parameters to be sent to limit the resources being returned.

Returns:

A generator of vpc peering objects

Return type:

Peering

find_peering(name_or_id, ignore_missing=False)

Find a single vpc peering

Parameters:
  • name_or_id – The name or ID of a zone

  • ignore_missing (bool) – When set to False ResourceNotFound will be raised when the vpc peering does not exist. When set to True, no exception will be set when attempting to delete a nonexistent peering.

Returns:

One Peering

update_peering(peering, **attrs)

Update a vpc peering

Parameters:
  • peering – Either the ID of a vpc peering or a Peering instance.

  • attrs (dict) – The attributes to update on the vpc peering represented by peering.

Returns:

The updated peering

Return type:

Peering

set_peering(peering, set_status)

Accept/Reject a vpc peering connection request

Parameters:
  • peering – Either the ID of a vpc peering or a Peering instance.

  • set_status – The value can been accept or reject

Returns:

The updated peering

Return type:

Peering

VPC Route Operations

class otcextensions.sdk.vpc.v1._proxy.Proxy(session, statsd_client=None, statsd_prefix=None, prometheus_counter=None, prometheus_histogram=None, influxdb_config=None, influxdb_client=None, *args, **kwargs)
add_route(**attrs)

Add vpc route

Parameters:

attrs (dict) – Keyword arguments which will be used to create a Route

delete_route(route, ignore_missing=True)

Delete a vpc route

Parameters:
  • route – route id or an instance of Route

  • ignore_missing (bool) – When set to False ResourceNotFound will be raised when the vpc route does not exist. When set to True, no exception will be set when attempting to delete a nonexistent route.

Returns:

None

routes(**query)

Return a generator of vpc routes

Parameters:

query (dict) – Optional query parameters to be sent to limit the resources being returned.

Returns:

A generator of vpc route objects

Return type:

Route

get_route(route)

Get details of a single vpc route

Parameters:

route – The value can be the ID of a vpc route or a Route instance.

Returns:

One Route

Raises:

ResourceNotFound when no resource can be found.

VPC Operations

class otcextensions.sdk.vpc.v1._proxy.Proxy(session, statsd_client=None, statsd_prefix=None, prometheus_counter=None, prometheus_histogram=None, influxdb_config=None, influxdb_client=None, *args, **kwargs)
vpcs(**query)

Return a generator of vpcs

Parameters:

query (dict) – Optional query parameters to be sent to limit the resources being returned.

Returns:

A generator of vpc objects

Return type:

Vpc

create_vpc(**attrs)

Create a new vpc from attributes

Parameters:

attrs (dict) – Keyword arguments which will be used to create a Vpc

delete_vpc(vpc, ignore_missing=True)

Delete a vpc

Parameters:
  • vpc – vpc id or an instance of Vpc

  • ignore_missing (bool) – When set to False ResourceNotFound will be raised when the vpc route does not exist. When set to True, no exception will be set when attempting to delete a nonexistent route.

Returns:

none

get_vpc(vpc)

Get a vpc by id

Parameters:

vpc – vpc id or an instance of Vpc

Returns:

One Vpc

find_vpc(name_or_id, ignore_missing=False)

Find a single vpc

Parameters:
  • name_or_id – The name or ID of a vpc

  • ignore_missing (bool) – When set to False ResourceNotFound will be raised when the vpc does not exist. When set to True, no exception will be set when attempting to delete a nonexistent peering.

Returns:

One Vpc

update_vpc(vpc, **attrs)

Update vpc

Parameters:
  • vpc – vpc id or an instance of Vpc

  • attrs (dict) – The attributes to update on the vpc represented by vpcd.

VPC Subnet Operations

class otcextensions.sdk.vpc.v1._proxy.Proxy(session, statsd_client=None, statsd_prefix=None, prometheus_counter=None, prometheus_histogram=None, influxdb_config=None, influxdb_client=None, *args, **kwargs)
subnets(**query)

Return a generator of subnets

Parameters:

query (dict) – Optional query parameters to be sent to limit the resources being returned.

Returns:

A generator of subnet objects

Return type:

Subnet

create_subnet(**attrs)

Create a new subnet from attributes

Parameters:

attrs (dict) – Keyword arguments which will be used to create a Subnet

get_subnet(subnet)

Get a subnet by id

Parameters:

subnet – subnet id or an instance of Subnet

Returns:

One Subnet

find_subnet(name_or_id, ignore_missing=False)

Find a single subnet

Parameters:
  • name_or_id – The name or ID of a subnet

  • ignore_missing (bool) – When set to False ResourceNotFound will be raised when the subnet does not exist. When set to True, no exception will be set when attempting to delete a nonexistent peering.

Returns:

One Subnet

update_subnet(subnet, **attrs)

Update subnet

Parameters:
  • subnet – subnet id or an instance of Subnet

  • attrs (dict) – The attributes to update on the subnet represented by subnet.

delete_subnet(subnet, vpc_id=None, ignore_missing=True)

Delete a subnet

Parameters:
  • subnet – subnet id or an instance of Subnet

  • vpc_id – VPC id. By default, taken from subnet, if provided.

  • ignore_missing (bool) – When set to False ResourceNotFound will be raised when the subnet route does not exist. When set to True, no exception will be set when attempting to delete a nonexistent route.

Returns:

none