Merge "Allow subcloud to use central-cloud's local registry"

This commit is contained in:
Zuul 2019-10-30 17:22:36 +00:00 committed by Gerrit Code Review
commit 7fb781c7b5
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) 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): def create_route(self, interface_uuid, network, prefix, gateway, metric):
"""Create a static route on an interface.""" """Create a static route on an interface."""

View File

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