Allow subcloud to use central-cloud's local registry

To address a requirement change that exposes the 'registry.central'
on the OAM interface, it must add the system controller OAM
subnet to the subcloud override file in the dcmanager.

Depends-On: https://review.opendev.org/#/c/690082/
Change-Id: I9ee6f0f99a940d5d2cc2f245977ffb9f207916c5
Partial-Bug: 1846799
Signed-off-by: Tao Liu <tao.liu@windriver.com>
This commit is contained in:
Tao Liu 2019-10-25 10:50:35 -04:00
parent b020fc86c8
commit 20a06bded7
2 changed files with 25 additions and 5 deletions

View File

@ -87,6 +87,19 @@ class SysinvClient(base.DriverBase):
return self.sysinv_client.address_pool.get(address_pool_uuid)
def get_oam_address_pool(self):
"""Get the oam address pool for a host."""
networks = self.sysinv_client.network.list()
for network in networks:
if network.type == sysinv_constants.NETWORK_TYPE_OAM:
address_pool_uuid = network.pool_uuid
break
else:
LOG.error("OAM address pool not found")
raise exceptions.InternalError()
return self.sysinv_client.address_pool.get(address_pool_uuid)
def create_route(self, interface_uuid, network, prefix, gateway, metric):
"""Create a static route on an interface."""

View File

@ -393,17 +393,24 @@ class SubcloudManager(manager.Manager):
context.auth_token, context.project)
sysinv_client = SysinvClient(consts.DEFAULT_REGION_NAME, session)
pool = sysinv_client.get_management_address_pool()
floating_ip = pool.floating_address
subnet = "%s/%d" % (pool.network, pool.prefix)
mgmt_pool = sysinv_client.get_management_address_pool()
mgmt_floating_ip = mgmt_pool.floating_address
mgmt_subnet = "%s/%d" % (mgmt_pool.network, mgmt_pool.prefix)
oam_pool = sysinv_client.get_oam_address_pool()
oam_floating_ip = oam_pool.floating_address
oam_subnet = "%s/%d" % (oam_pool.network, oam_pool.prefix)
with open(overrides_file, 'w') as f_out_overrides_file:
f_out_overrides_file.write(
'---'
'\nregion_config: yes'
'\ndistributed_cloud_role: subcloud'
'\nsystem_controller_subnet: ' + subnet +
'\nsystem_controller_floating_address: ' + floating_ip + '\n'
'\nsystem_controller_subnet: ' + mgmt_subnet +
'\nsystem_controller_floating_address: ' + mgmt_floating_ip +
'\nsystem_controller_oam_subnet: ' + oam_subnet +
'\nsystem_controller_oam_floating_address: ' + oam_floating_ip
+ '\n'
)
for k, v in payload.items():