Address allocation option for cluster-host network
An separate option is added for dynamic address allocation for
cluster-host network. The address is allocated from the cluster-host
pool only if the dynamic address allocation setting is set.
Otherwise, the address must be configured using the api.
Partial-Bug: 1838798
Change-Id: Ie79e90b6e5c54abab993e6267839d26f53e0120d
Signed-off-by: Teresa Ho <teresa.ho@windriver.com>
(cherry picked from commit 8601185c5b
)
This commit is contained in:
parent
cb0edea899
commit
1a41288dfd
|
@ -356,16 +356,20 @@ class AddressController(rest.RestController):
|
||||||
raise exception.DuplicateAddressDetectionRequiredOnIpv6()
|
raise exception.DuplicateAddressDetectionRequiredOnIpv6()
|
||||||
|
|
||||||
def _check_managed_addr(self, host_id, interface_id):
|
def _check_managed_addr(self, host_id, interface_id):
|
||||||
# Check that static address alloc is enabled
|
# Check if any of the networks assigned to the interface configured
|
||||||
|
# with static address allocation
|
||||||
interface = pecan.request.dbapi.iinterface_get(interface_id)
|
interface = pecan.request.dbapi.iinterface_get(interface_id)
|
||||||
if interface['networktypelist']:
|
if not any(nt in [constants.NETWORK_TYPE_MGMT,
|
||||||
for networktype in interface['networktypelist']:
|
constants.NETWORK_TYPE_CLUSTER_HOST,
|
||||||
if networktype not in [constants.NETWORK_TYPE_MGMT,
|
constants.NETWORK_TYPE_OAM]
|
||||||
constants.NETWORK_TYPE_OAM]:
|
for nt in interface['networktypelist']):
|
||||||
continue
|
return
|
||||||
network = pecan.request.dbapi.network_get_by_type(networktype)
|
for networktype in interface['networktypelist']:
|
||||||
if network.dynamic:
|
network = pecan.request.dbapi.network_get_by_type(networktype)
|
||||||
raise exception.StaticAddressNotConfigured()
|
if not network.dynamic:
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
raise exception.StaticAddressNotConfigured()
|
||||||
host = pecan.request.dbapi.ihost_get(host_id)
|
host = pecan.request.dbapi.ihost_get(host_id)
|
||||||
if host['personality'] in [constants.STORAGE]:
|
if host['personality'] in [constants.STORAGE]:
|
||||||
raise exception.ManagedIPAddress()
|
raise exception.ManagedIPAddress()
|
||||||
|
|
|
@ -485,11 +485,12 @@ def _update_host_cluster_address(host, interface):
|
||||||
updates = {'interface_id': interface['id']}
|
updates = {'interface_id': interface['id']}
|
||||||
pecan.request.dbapi.address_update(address.uuid, updates)
|
pecan.request.dbapi.address_update(address.uuid, updates)
|
||||||
except exception.AddressNotFoundByName:
|
except exception.AddressNotFoundByName:
|
||||||
cluster_host_pool_uuid = pecan.request.dbapi.network_get_by_type(
|
cluster_host_network = pecan.request.dbapi.network_get_by_type(
|
||||||
constants.NETWORK_TYPE_CLUSTER_HOST
|
constants.NETWORK_TYPE_CLUSTER_HOST)
|
||||||
).pool_uuid
|
if cluster_host_network.dynamic:
|
||||||
_allocate_pool_address(interface['id'], cluster_host_pool_uuid,
|
_allocate_pool_address(interface['id'],
|
||||||
address_name)
|
cluster_host_network.pool_uuid,
|
||||||
|
address_name)
|
||||||
|
|
||||||
|
|
||||||
def _update_host_ironic_address(host, interface):
|
def _update_host_ironic_address(host, interface):
|
||||||
|
|
Loading…
Reference in New Issue