2
# Licensed under the Apache License, Version 2.0 (the "License"); you may
3
# not use this file except in compliance with the License. You may obtain
4
# a copy of the License at
6
# http://www.apache.org/licenses/LICENSE-2.0
8
# Unless required by applicable law or agreed to in writing, software
9
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
10
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
11
# License for the specific language governing permissions and limitations
14
from heat.common.i18n import _
15
from heat.common import template_format
16
from heat.engine import properties
17
from heat.engine.resources.software_config import software_config
18
from heat.engine import support
19
from heat.rpc import api as rpc_api
22
class CloudConfig(software_config.SoftwareConfig):
24
A configuration resource for representing cloud-init cloud-config.
26
This resource allows cloud-config YAML to be defined and stored by the
27
config API. Any intrinsic functions called in the config will be resolved
28
before storing the result.
30
This resource will generally be referenced by OS::Nova::Server user_data,
31
or OS::Heat::MultipartMime parts config. Since cloud-config is boot-only
32
configuration, any changes to the definition will result in the
33
replacement of all servers which reference it.
36
support_status = support.SupportStatus(version='2014.1')
45
CLOUD_CONFIG: properties.Schema(
46
properties.Schema.MAP,
47
_('Map representing the cloud-config data structure which will '
48
'be formatted as YAML.')
52
def handle_create(self):
53
cloud_config = template_format.yaml.dump(self.properties.get(
54
self.CLOUD_CONFIG), Dumper=template_format.yaml_dumper)
56
self.NAME: self.physical_resource_name(),
57
self.CONFIG: '#cloud-config\n%s' % cloud_config,
58
self.GROUP: 'Heat::Ungrouped'
60
sc = self.rpc_client().create_software_config(self.context, **props)
61
self.resource_id_set(sc[rpc_api.SOFTWARE_CONFIG_ID])
64
def resource_mapping():
66
'OS::Heat::CloudConfig': CloudConfig,