Force config_drive and transport for sw config
Ensure config_drive is enabled automatically if the user data format is SOFTWARE_CONFIG. Also, limit the choices for transport and format to only those supported at Rackspace. Change-Id: Ia8bb09d991843860a8f0cfb73453b789fde28afd
This commit is contained in:
parent
a02d6305fd
commit
845dd17825
@ -60,17 +60,34 @@ class CloudServer(server.Server):
|
||||
{
|
||||
server.Server.USER_DATA_FORMAT: properties.Schema(
|
||||
properties.Schema.STRING,
|
||||
_('How the user_data should be formatted for the server. For '
|
||||
'HEAT_CFNTOOLS, the user_data is bundled as part of the '
|
||||
'heat-cfntools cloud-init boot configuration data. For RAW '
|
||||
'the user_data is passed to Nova unmodified. '
|
||||
_('How the user_data should be formatted for the server. '
|
||||
'For RAW the user_data is passed to Nova unmodified. '
|
||||
'For SOFTWARE_CONFIG user_data is bundled as part of the '
|
||||
'software config data, and metadata is derived from any '
|
||||
'associated SoftwareDeployment resources.'),
|
||||
default=server.Server.RAW,
|
||||
constraints=[
|
||||
constraints.AllowedValues(
|
||||
server.Server._SOFTWARE_CONFIG_FORMATS),
|
||||
constraints.AllowedValues([
|
||||
server.Server.RAW, server.Server.SOFTWARE_CONFIG
|
||||
])
|
||||
]
|
||||
),
|
||||
}
|
||||
)
|
||||
properties_schema.update(
|
||||
{
|
||||
server.Server.SOFTWARE_CONFIG_TRANSPORT: properties.Schema(
|
||||
properties.Schema.STRING,
|
||||
_('How the server should receive the metadata required for '
|
||||
'software configuration. POLL_TEMP_URL is the only '
|
||||
'supported transport on Rackspace Cloud. This property is '
|
||||
'retained for compatability.'),
|
||||
default=server.Server.POLL_TEMP_URL,
|
||||
update_allowed=True,
|
||||
constraints=[
|
||||
constraints.AllowedValues([
|
||||
server.Server.POLL_TEMP_URL
|
||||
])
|
||||
]
|
||||
),
|
||||
}
|
||||
@ -82,9 +99,11 @@ class CloudServer(server.Server):
|
||||
self._rack_connect_started_event_sent = False
|
||||
|
||||
def _config_drive(self):
|
||||
user_data_format = self.properties.get(self.USER_DATA_FORMAT, "")
|
||||
is_sw_config = user_data_format == self.SOFTWARE_CONFIG
|
||||
user_data = self.properties.get(self.USER_DATA)
|
||||
config_drive = self.properties.get(self.CONFIG_DRIVE)
|
||||
if user_data or config_drive:
|
||||
if config_drive or is_sw_config or user_data:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
@ -456,7 +456,8 @@ class CloudServersTest(common.HeatTestCase):
|
||||
'Unknown Rackspace Cloud automation status: FOO',
|
||||
six.text_type(exc))
|
||||
|
||||
def _test_server_config_drive(self, user_data, config_drive, result):
|
||||
def _test_server_config_drive(self, user_data, config_drive, result,
|
||||
ud_format='RAW'):
|
||||
return_server = self.fc.servers.list()[1]
|
||||
return_server.metadata = {'rax_service_level_automation': 'Complete'}
|
||||
stack_name = 'no_user_data'
|
||||
@ -464,11 +465,14 @@ class CloudServersTest(common.HeatTestCase):
|
||||
properties = tmpl.t['Resources']['WebServer']['Properties']
|
||||
properties['user_data'] = user_data
|
||||
properties['config_drive'] = config_drive
|
||||
properties['user_data_format'] = ud_format
|
||||
properties['software_config_transport'] = "POLL_TEMP_URL"
|
||||
resource_defns = tmpl.resource_definitions(stack)
|
||||
server = cloud_server.CloudServer('WebServer',
|
||||
resource_defns['WebServer'], stack)
|
||||
server.metadata = {'rax_service_level_automation': 'Complete'}
|
||||
self.patchobject(server, 'store_external_ports')
|
||||
self.patchobject(server, "_populate_deployments_metadata")
|
||||
mock_servers_create = mock.Mock(return_value=return_server)
|
||||
self.fc.servers.create = mock_servers_create
|
||||
image_id = mock.ANY
|
||||
@ -508,3 +512,7 @@ class CloudServersTest(common.HeatTestCase):
|
||||
|
||||
def test_server_no_user_data_no_config_drive(self):
|
||||
self._test_server_config_drive(None, False, False)
|
||||
|
||||
def test_server_no_user_data_software_config(self):
|
||||
self._test_server_config_drive(None, False, True,
|
||||
ud_format="SOFTWARE_CONFIG")
|
||||
|
Loading…
x
Reference in New Issue
Block a user