Improve the structure of IPConfiguration model
This commit is contained in:
parent
fb31fb7c6c
commit
0a901e394c
@ -332,7 +332,8 @@ class Resource(model.Model):
|
|||||||
# we will force the regexp to match the entire resource
|
# we will force the regexp to match the entire resource
|
||||||
# reference.
|
# reference.
|
||||||
regexp = "^{regexp}$".format(regexp=regexp)
|
regexp = "^{regexp}$".format(regexp=regexp)
|
||||||
self._regexp[model_cls] = re.compile(regexp)
|
self._regexp[model_cls] = re.compile(regexp,
|
||||||
|
flags=re.IGNORECASE)
|
||||||
|
|
||||||
def get_resource(self):
|
def get_resource(self):
|
||||||
"""Return the associated resource."""
|
"""Return the associated resource."""
|
||||||
@ -634,7 +635,7 @@ class IPConfiguration(_BaseHNVModel):
|
|||||||
"""Indicates the allocation method (Static or Dynamic)."""
|
"""Indicates the allocation method (Static or Dynamic)."""
|
||||||
|
|
||||||
public_ip_address = model.Field(
|
public_ip_address = model.Field(
|
||||||
name="public_ip_address", key="publicIpAddress",
|
name="public_ip_address", key="publicIPAddress",
|
||||||
is_required=False)
|
is_required=False)
|
||||||
"""Indicates the public IP address of the IP Configuration."""
|
"""Indicates the public IP address of the IP Configuration."""
|
||||||
|
|
||||||
@ -648,6 +649,40 @@ class IPConfiguration(_BaseHNVModel):
|
|||||||
"""Indicates a reference to the subnet resource that the IP Configuration
|
"""Indicates a reference to the subnet resource that the IP Configuration
|
||||||
is connected to."""
|
is connected to."""
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def from_raw_data(cls, raw_data):
|
||||||
|
"""Create a new model using raw API response."""
|
||||||
|
properties = raw_data["properties"]
|
||||||
|
|
||||||
|
address_pools = []
|
||||||
|
for content in properties.get("loadBalancerBackendAddressPools", []):
|
||||||
|
resource = Resource.from_raw_data(content)
|
||||||
|
address_pools.append(resource)
|
||||||
|
properties["loadBalancerBackendAddressPools"] = address_pools
|
||||||
|
|
||||||
|
nat_rules = []
|
||||||
|
for content in properties.get("loadBalancerInboundNatRules", None):
|
||||||
|
resource = Resource.from_raw_data(content)
|
||||||
|
nat_rules.append(resource)
|
||||||
|
properties["loadBalancerInboundNatRules"] = nat_rules
|
||||||
|
|
||||||
|
raw_content = properties.get("publicIPAddress", None)
|
||||||
|
if raw_content is not None:
|
||||||
|
resource = Resource.from_raw_data(raw_content)
|
||||||
|
properties["publicIPAddress"] = resource
|
||||||
|
|
||||||
|
raw_content = properties.get("serviceInsertion", None)
|
||||||
|
if raw_content is not None:
|
||||||
|
resource = Resource.from_raw_data(raw_content)
|
||||||
|
properties["serviceInsertion"] = resource
|
||||||
|
|
||||||
|
raw_content = properties.get("subnet", None)
|
||||||
|
if raw_content is not None:
|
||||||
|
resource = Resource.from_raw_data(raw_content)
|
||||||
|
properties["subnet"] = resource
|
||||||
|
|
||||||
|
return super(IPConfiguration, cls).from_raw_data(raw_data)
|
||||||
|
|
||||||
|
|
||||||
class DNSSettings(model.Model):
|
class DNSSettings(model.Model):
|
||||||
|
|
||||||
@ -1844,7 +1879,7 @@ class PublicIPAddresses(_BaseHNVModel):
|
|||||||
can be used to communicate with the virtual network from outside it.
|
can be used to communicate with the virtual network from outside it.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
_endpoint = "/networking/v1/publicIpAddresses/{resource_id}"
|
_endpoint = "/networking/v1/publicIPAddresses/{resource_id}"
|
||||||
|
|
||||||
ip_address = model.Field(name="ip_address", key="ipAddress",
|
ip_address = model.Field(name="ip_address", key="ipAddress",
|
||||||
is_required=False, is_read_only=False)
|
is_required=False, is_read_only=False)
|
||||||
|
@ -18,6 +18,29 @@
|
|||||||
"loadBalancerBackendAddressPools": [],
|
"loadBalancerBackendAddressPools": [],
|
||||||
"loadBalancerInboundNatRules": []
|
"loadBalancerInboundNatRules": []
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"resourceRef": "/networkInterfaces/ec3ac77e-64be-4bc1-a2e3- 7cd6170a4752/ipConfigurations/cbcab016-6c87-4a32-8158-08e0db71635a",
|
||||||
|
"resourceId": "cbcab016-6c87-4a32-8158-08e0db71635a",
|
||||||
|
"etag": "W/\"5e2e060a-2103-4022-87ee-bf1667bd18eb\"",
|
||||||
|
"instanceId": "83283a7e-4885-468a-9a2a-c7c568efd290",
|
||||||
|
"properties": {
|
||||||
|
"provisioningState": "Succeeded",
|
||||||
|
"privateIPAddress": "13.168.101.21",
|
||||||
|
"privateIPAllocationMethod": "Static",
|
||||||
|
"subnet": {
|
||||||
|
"resourceRef": "/virtualNetworks/740f3670-de42-4345-aaa7-6bb8d423c5df/subnets/da459373- 42ee-43d3-b094-6e2176406e4a"
|
||||||
|
},
|
||||||
|
"accessControlList": {
|
||||||
|
"resourceRef": "/accessControlLists/4561e835-128c-44cd-b55f-98bca0d34aba"
|
||||||
|
},
|
||||||
|
"loadBalancerBackendAddressPools": [
|
||||||
|
{
|
||||||
|
"resourceRef": "/loadBalancers/2ea43ab6-cb92-4ad3-854f- bc62092cf4b0/backendAddressPools/1cd5d838-b574-4bcb-b6ac-9db3fc5e5f4d"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"loadBalancerInboundNatRules": []
|
||||||
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"nextLink": ""
|
"nextLink": ""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user