3
# Licensed under the Apache License, Version 2.0 (the "License"); you may
4
# not use this file except in compliance with the License. You may obtain
5
# a copy of the License at
7
# http://www.apache.org/licenses/LICENSE-2.0
9
# Unless required by applicable law or agreed to in writing, software
10
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12
# License for the specific language governing permissions and limitations
15
from heat.common.template_format import yaml
16
from heat.common.template_format import yaml_dumper
17
from heat.engine import properties
18
from heat.engine.resources.software_config import software_config
21
class CloudConfig(software_config.SoftwareConfig):
29
CLOUD_CONFIG: properties.Schema(
30
properties.Schema.MAP,
31
_('Map representing the cloud-config data structure which will '
32
'be formatted as YAML.')
36
def handle_create(self):
37
props = {self.NAME: self.physical_resource_name()}
38
cloud_config = yaml.dump(self.properties.get(
39
self.CLOUD_CONFIG), Dumper=yaml_dumper)
40
props[self.CONFIG] = '#cloud-config\n%s' % cloud_config
41
sc = self.heat().software_configs.create(**props)
42
self.resource_id_set(sc.id)
45
def resource_mapping():
47
'OS::Heat::CloudConfig': CloudConfig,