Add support for load balancer manager

This commit is contained in:
Alexandru Coman 2017-02-13 21:54:13 +02:00
parent c90d01e72e
commit ac3d2c1edc
No known key found for this signature in database
GPG Key ID: A7B6A9021F704507
4 changed files with 78 additions and 0 deletions

View File

@ -2900,3 +2900,53 @@ class BGPRouters(_BaseHNVModel):
properties["bgpPeers"] = bgp_peers
return super(BGPRouters, cls).from_raw_data(raw_data)
class LoadBalancerManager(_BaseHNVModel):
"""Model for load balancer manager.
The LoadBalancerManager resource is a singleton resource that configures
the load balancing service of the Network Controller.
"""
_endpoint = "/networking/v1/loadBalancerManager/config"
manager_ip_address = model.Field(
name="manager_ip_address", key="loadBalancerManagerIPAddress",
is_property=True, is_required=True, is_read_only=False)
"""The IP address of the load balancer service. This is part of one of
the FrontendIPPools as specified in the FrontendIPPool element in this
resource."""
outbound_nat_ip = model.Field(
name="outbound_nat_ip", key="outboundNatIPExemptions",
is_property=True, is_required=True, is_read_only=False)
"""An array of v4 or v6 subnets masks with prefixes that will not have
the source IP and Port changed by being NAT-ed. This is typically used
for datacenter services that will communicated with other services within
the same datacenter or cluster. Array of strings in the following format:
0.0.0.0/0.
NOTE: There is no validation that these IP addresses are known by the
Network Controller."""
vip_ip_pools = model.Field(
name="vip_ip_pools", key="vipIpPools",
is_property=True, is_required=True, is_read_only=False)
"""An array of references to ipPool resource that will be used for the
frontend IP Addresses.
"""
@classmethod
def from_raw_data(cls, raw_data):
"""Create a new model using raw API response."""
properties = raw_data.get("properties", {})
vip_ip_pools = []
for raw_content in properties.get("vipIpPools", []):
resource = Resource.from_raw_data(raw_content)
vip_ip_pools.append(resource)
properties["vipIpPools"] = vip_ip_pools
return super(LoadBalancerManager, cls).from_raw_data(raw_data)

View File

@ -125,3 +125,7 @@ class FakeResponse(object):
def bgp_routers(self):
"""Fake GET(all) response for BGP routers."""
return self._load_resource("bgp_routers.json")
def load_balancer_manager(self):
"""Fake GET response for load balancer manager."""
return self._load_resource("load_balancer_manager.json")

View File

@ -0,0 +1,19 @@
{
"resourceRef": "/loadBalancerManager/config",
"resourceId": "config",
"etag": "W/\"ea4ce83a-3b5c-4b92-90b4-f1a69aa5935f\"",
"instanceId": "6a42e935-92bb-4081-a1a7-bac1d772671f",
"properties": {
"provisioningState": "Succeeded",
"loadBalancerManagerIPAddress": "21.0.0.21",
"outboundNatIPExemptions": [],
"vipIpPools": [
{
"resourceRef": "/logicalnetworks/ccb732ec-a3b5-4755-99ff-\nfddb91d50884/subnets/262b479f-0952-49b9-ad20-3d6732729389/ipPools/968917ad-8122-447d-90f7-\nbee2f95828c8"
},
{
"resourceRef": "/logicalnetworks/9c1b2b61-dec2-49e3-b573-\nc2ecff57893d/subnets/a4f7c90b-6056-4dff-97fb-f46211ecdc10/ipPools/6b7c0255-c68d-4b2f-9870-\n9757255b55de"
}
]
}
}

View File

@ -384,3 +384,8 @@ class TestClient(unittest.TestCase):
raw_data["parentResourceID"] = "fake-parent-id"
self._test_get_resource(model=client.BGPRouters,
raw_data=raw_data)
def test_load_balancer_manager(self):
raw_data = self._response.load_balancer_manager()
self._test_get_resource(model=client.LoadBalancerManager,
raw_data=raw_data)