Add support for public IP addresses
This commit is contained in:
parent
ac78a59069
commit
e1d00b9ed7
@ -276,11 +276,16 @@ class ResourceMetadata(model.Model):
|
|||||||
Network Controller and the group that the tenant belongs to in the
|
Network Controller and the group that the tenant belongs to in the
|
||||||
client network."""
|
client network."""
|
||||||
|
|
||||||
resource_name = model.Field(name="resource_name", key="name",
|
resource_name = model.Field(name="resource_name", key="resourceName",
|
||||||
is_property=False, is_required=False)
|
is_property=False, is_required=False)
|
||||||
"""Indicates the globally unique name of the resource. If it
|
"""Indicates the globally unique name of the resource. If it
|
||||||
is not assigned a value then it will be blank."""
|
is not assigned a value then it will be blank."""
|
||||||
|
|
||||||
|
name = model.Field(name="name", key="name",
|
||||||
|
is_property=False, is_required=False)
|
||||||
|
"""Indicates the globally unique name of the resource. If it
|
||||||
|
is not assigned a value then it will be blank."""
|
||||||
|
|
||||||
original_href = model.Field(name="original_href", key="originalHref",
|
original_href = model.Field(name="original_href", key="originalHref",
|
||||||
is_property=False, is_required=False)
|
is_property=False, is_required=False)
|
||||||
"""The original URI of the resource if the client uses a URI based
|
"""The original URI of the resource if the client uses a URI based
|
||||||
@ -1667,3 +1672,62 @@ class NetworkConnections(_BaseHNVModel):
|
|||||||
properties["gateway"] = gateway
|
properties["gateway"] = gateway
|
||||||
|
|
||||||
return super(NetworkConnections, cls).from_raw_data(raw_data)
|
return super(NetworkConnections, cls).from_raw_data(raw_data)
|
||||||
|
|
||||||
|
|
||||||
|
class PublicIPAddresses(_BaseHNVModel):
|
||||||
|
|
||||||
|
"""Model for public IP addresses.
|
||||||
|
|
||||||
|
The PublicIPAddresses resource specifies an IP address which is publically
|
||||||
|
available. This PublicIPAddresses resource is used by the VirtualGateways
|
||||||
|
resource and the loadBalancers resource to indicate the IP address that
|
||||||
|
can be used to communicate with the virtual network from outside it.
|
||||||
|
"""
|
||||||
|
|
||||||
|
_endpoint = "/networking/v1/publicIpAddresses/{resource_i}"
|
||||||
|
|
||||||
|
ip_address = model.Field(name="ip_address", key="ipAddress",
|
||||||
|
is_required=False, is_read_only=False)
|
||||||
|
"""IP address which is allocated.
|
||||||
|
|
||||||
|
The caller can pass in a specific public IP address to be allocated or
|
||||||
|
leave it empty.
|
||||||
|
"""
|
||||||
|
|
||||||
|
allocation_method = model.Field(name="allocation_method",
|
||||||
|
key="publicIPAllocationMethod",
|
||||||
|
is_required=False, is_read_only=False)
|
||||||
|
"""`Dynamic` or `Static`
|
||||||
|
|
||||||
|
In case of static publicIpAllocationMethod, ipAddress property
|
||||||
|
needs to be passed indicating the specific public IP address which
|
||||||
|
needs to be allocated.
|
||||||
|
In case of Dynamic publicIpAllocationMethod, the ipAddress
|
||||||
|
property is not meaningful in a PUT (allocation request). In case
|
||||||
|
of Dynamic, any free public IP address will be allocated to the
|
||||||
|
caller.
|
||||||
|
"""
|
||||||
|
|
||||||
|
dns_record = model.Field(name="dns_record", key="dnsRecord",
|
||||||
|
is_required=False, is_read_only=False)
|
||||||
|
"""Properties of a DNS record associated with this public IP address."""
|
||||||
|
|
||||||
|
idle_timeout = model.Field(name="idle_timeout",
|
||||||
|
key="idleTimeoutInMinutes",
|
||||||
|
is_required=False, is_read_only=False)
|
||||||
|
"""Specifies the timeout for the TCP idle connection.
|
||||||
|
|
||||||
|
The value can be set between 4 and 30 minutes. The default is 4
|
||||||
|
minutes. If public IP is used as a frontend IP of a Load Balancer
|
||||||
|
this value is ignored.
|
||||||
|
"""
|
||||||
|
|
||||||
|
ip_configuration = model.Field(name="ip_configuration",
|
||||||
|
key="ipConfiguration",
|
||||||
|
is_required=False, is_read_only=True)
|
||||||
|
"""Reference to an ipConfigurations resource.
|
||||||
|
|
||||||
|
Relative URI of the private IP address with which this public IP is
|
||||||
|
associated. Private ip can be defined on NIC, loadBalancers, or
|
||||||
|
gateways.
|
||||||
|
"""
|
||||||
|
@ -85,3 +85,7 @@ class FakeResponse(object):
|
|||||||
def network_connections(self):
|
def network_connections(self):
|
||||||
"""Fake GET(all) response for network connections."""
|
"""Fake GET(all) response for network connections."""
|
||||||
return self._load_resource("network_connections.json")
|
return self._load_resource("network_connections.json")
|
||||||
|
|
||||||
|
def public_ip_addresses(self):
|
||||||
|
"""Fake GET(all) response for public IP addresses."""
|
||||||
|
return self._load_resource("public_ip_addresses.json")
|
||||||
|
47
hnv/tests/fake/response/public_ip_addresses.json
Normal file
47
hnv/tests/fake/response/public_ip_addresses.json
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
{
|
||||||
|
"value": [
|
||||||
|
{
|
||||||
|
"resourceRef": "/publicIPAddresses/pip1",
|
||||||
|
"resourceId": "pip1",
|
||||||
|
"etag": "W/\"2b2feb9e-9830-42ed-9923-01d6693fb240\"",
|
||||||
|
"instanceId": "b34f7a07-4637-40f2-abc5-075ddfc9b785",
|
||||||
|
"properties": {
|
||||||
|
"provisioningState": "Succeeded",
|
||||||
|
"ipAddress": "12.21.4.5",
|
||||||
|
"publicIPAllocationMethod": "Dynamic",
|
||||||
|
"idleTimeoutInMinutes": 4
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"resourceRef": "/publicIPAddresses/pip2",
|
||||||
|
"resourceId": "pip2",
|
||||||
|
"etag": "W/\"c7a95773-8ad3-44a6-b89c-f4a305569e1d\"",
|
||||||
|
"instanceId": "018a7e31-cf8e-4292-899d-2f3f4b9b96c5",
|
||||||
|
"properties": {
|
||||||
|
"provisioningState": "Succeeded",
|
||||||
|
"ipAddress": "12.21.4.51",
|
||||||
|
"publicIPAllocationMethod": "Static",
|
||||||
|
"idleTimeoutInMinutes": 4
|
||||||
|
},
|
||||||
|
"tags": {
|
||||||
|
"a": "b"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"resourceRef": "/publicIPAddresses/pip2",
|
||||||
|
"resourceId": "pip2",
|
||||||
|
"resourceMetadata": {
|
||||||
|
"resourceName": "outbound1"
|
||||||
|
},
|
||||||
|
"etag": "W/\"90a799f7-549d-44ac-baa9-f7ccf69b1dda\"",
|
||||||
|
"instanceId": "018a7e31-cf8e-4292-899d-2f3f4b9b96c5",
|
||||||
|
"properties": {
|
||||||
|
"provisioningState": "Updating",
|
||||||
|
"ipAddress": "12.21.4.51",
|
||||||
|
"publicIPAllocationMethod": "Static",
|
||||||
|
"idleTimeoutInMinutes": 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"nextLink": ""
|
||||||
|
}
|
@ -294,3 +294,9 @@ class TestClient(unittest.TestCase):
|
|||||||
for raw_data in resources.get("value", []):
|
for raw_data in resources.get("value", []):
|
||||||
self._test_get_resource(model=client.NetworkConnections,
|
self._test_get_resource(model=client.NetworkConnections,
|
||||||
raw_data=raw_data)
|
raw_data=raw_data)
|
||||||
|
|
||||||
|
def test_public_ip_addresses(self):
|
||||||
|
resources = self._response.public_ip_addresses()
|
||||||
|
for raw_data in resources.get("value", []):
|
||||||
|
self._test_get_resource(model=client.PublicIPAddresses,
|
||||||
|
raw_data=raw_data)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user