fix handling of vendor-data and vendor-data-url config options
Also fix the doc to mention Rocky as the turning point, because that's what the code does Change-Id: Ie5fe7e0b023920489182fd060c52b1043bb209a9
This commit is contained in:
parent
684a93515d
commit
48a862175f
@ -257,7 +257,7 @@ options:
|
||||
description: |
|
||||
A JSON-formatted string that will serve as vendor metadata
|
||||
(via "StaticJSON" provider) to all VM's within an OpenStack deployment,
|
||||
regardless of project or domain. For deployments of Queens or later
|
||||
regardless of project or domain. For deployments of Rocky or later
|
||||
this value is ignored. Please set the corresponding value in the
|
||||
nova-cloud-controller charm.
|
||||
vendor-data-url:
|
||||
@ -268,7 +268,7 @@ options:
|
||||
(via "DynamicJSON" provider) to all VM's within an OpenStack deployment,
|
||||
regardless of project or domain.
|
||||
.
|
||||
Only supported in OpenStack Newton and higher. For deployments of Queens or
|
||||
Only supported in OpenStack Newton and higher. For deployments of Rocky or
|
||||
later this value is ignored. Please set the corresponding value in the
|
||||
nova-cloud-controller charm.
|
||||
default-availability-zone:
|
||||
|
@ -172,21 +172,22 @@ class NovaMetadataContext(OSContextGenerator):
|
||||
ctxt = {}
|
||||
cmp_os_release = CompareOpenStackReleases(os_release('neutron-common'))
|
||||
if cmp_os_release < 'rocky':
|
||||
ctxt['vendordata_providers'] = []
|
||||
vdata_providers = []
|
||||
vdata = config('vendor-data')
|
||||
vdata_url = config('vendor-data-url')
|
||||
|
||||
if vdata:
|
||||
ctxt['vendor_data'] = True
|
||||
ctxt['vendordata_providers'].append('StaticJSON')
|
||||
vdata_providers.append('StaticJSON')
|
||||
|
||||
if vdata_url:
|
||||
if cmp_os_release > 'mitaka':
|
||||
ctxt['vendor_data_url'] = vdata_url
|
||||
ctxt['vendordata_providers'].append('DynamicJSON')
|
||||
vdata_providers.append('DynamicJSON')
|
||||
else:
|
||||
log('Dynamic vendor data unsupported'
|
||||
' for {}.'.format(cmp_os_release), level=ERROR)
|
||||
ctxt['vendordata_providers'] = ','.join(vdata_providers)
|
||||
for rid in relation_ids(self.rel_name):
|
||||
for unit in related_units(rid):
|
||||
rdata = relation_get(rid=rid, unit=unit)
|
||||
|
@ -459,7 +459,7 @@ class TestNovaMetadataContext(CharmTestCase):
|
||||
ctxt = neutron_contexts.NovaMetadataContext()()
|
||||
|
||||
self.assertTrue(ctxt['vendor_data'])
|
||||
self.assertEqual(ctxt['vendordata_providers'], ['StaticJSON'])
|
||||
self.assertEqual(ctxt['vendordata_providers'], 'StaticJSON')
|
||||
|
||||
@patch.object(neutron_contexts, 'get_local_ip')
|
||||
@patch.object(neutron_contexts, 'get_shared_secret')
|
||||
@ -476,7 +476,7 @@ class TestNovaMetadataContext(CharmTestCase):
|
||||
ctxt = neutron_contexts.NovaMetadataContext()()
|
||||
|
||||
self.assertEqual(ctxt['vendor_data_url'], _vdata_url)
|
||||
self.assertEqual(ctxt['vendordata_providers'], ['DynamicJSON'])
|
||||
self.assertEqual(ctxt['vendordata_providers'], 'DynamicJSON')
|
||||
|
||||
@patch.object(neutron_contexts, 'get_local_ip')
|
||||
@patch.object(neutron_contexts, 'get_shared_secret')
|
||||
@ -496,8 +496,8 @@ class TestNovaMetadataContext(CharmTestCase):
|
||||
|
||||
self.assertTrue(ctxt['vendor_data'])
|
||||
self.assertEqual(ctxt['vendor_data_url'], _vdata_url)
|
||||
self.assertEqual(ctxt['vendordata_providers'], ['StaticJSON',
|
||||
'DynamicJSON'])
|
||||
self.assertEqual(ctxt['vendordata_providers'],
|
||||
'StaticJSON,DynamicJSON')
|
||||
|
||||
@patch.object(neutron_contexts, 'get_local_ip')
|
||||
@patch.object(neutron_contexts, 'get_shared_secret')
|
||||
@ -519,7 +519,7 @@ class TestNovaMetadataContext(CharmTestCase):
|
||||
'nova_metadata_port': '8775',
|
||||
'nova_metadata_protocol': 'http',
|
||||
'shared_secret': 'asecret',
|
||||
'vendordata_providers': []})
|
||||
'vendordata_providers': ''})
|
||||
|
||||
@patch.object(neutron_contexts, 'relation_get')
|
||||
@patch.object(neutron_contexts, 'related_units')
|
||||
@ -542,7 +542,7 @@ class TestNovaMetadataContext(CharmTestCase):
|
||||
'nova_metadata_port': '8775',
|
||||
'nova_metadata_protocol': 'http',
|
||||
'shared_secret': 'auuid',
|
||||
'vendordata_providers': []})
|
||||
'vendordata_providers': ''})
|
||||
|
||||
@patch.object(neutron_contexts, 'get_local_ip')
|
||||
@patch.object(neutron_contexts, 'get_shared_secret')
|
||||
@ -561,4 +561,4 @@ class TestNovaMetadataContext(CharmTestCase):
|
||||
'nova_metadata_port': '8775',
|
||||
'nova_metadata_protocol': 'http',
|
||||
'shared_secret': 'buuid',
|
||||
'vendordata_providers': []})
|
||||
'vendordata_providers': ''})
|
||||
|
Loading…
Reference in New Issue
Block a user