~ubuntu-branches/ubuntu/wily/heat/wily-proposed

« back to all changes in this revision

Viewing changes to heat/engine/resources/software_config/cloud_config.py

  • Committer: Package Import Robot
  • Author(s): James Page, Corey Bryant, James Page
  • Date: 2015-03-30 11:11:18 UTC
  • mfrom: (1.1.23)
  • Revision ID: package-import@ubuntu.com-20150330111118-2qpycylx6swu4yhj
Tags: 2015.1~b3-0ubuntu1
[ Corey Bryant ]
* New upstream milestone release for OpenStack kilo:
  - d/control: Align with upstream dependencies.
  - d/p/sudoers_patch.patch: Rebased.
  - d/p/fix-requirements.patch: Rebased.

[ James Page ]
* d/p/fixup-assert-regex.patch: Tweak test to use assertRegexpMatches.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#
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
5
 
#
6
 
#         http://www.apache.org/licenses/LICENSE-2.0
7
 
#
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
12
 
#    under the License.
13
 
 
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
20
 
 
21
 
 
22
 
class CloudConfig(software_config.SoftwareConfig):
23
 
    '''
24
 
    A configuration resource for representing cloud-init cloud-config.
25
 
 
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.
29
 
 
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.
34
 
    '''
35
 
 
36
 
    support_status = support.SupportStatus(version='2014.1')
37
 
 
38
 
    PROPERTIES = (
39
 
        CLOUD_CONFIG
40
 
    ) = (
41
 
        'cloud_config'
42
 
    )
43
 
 
44
 
    properties_schema = {
45
 
        CLOUD_CONFIG: properties.Schema(
46
 
            properties.Schema.MAP,
47
 
            _('Map representing the cloud-config data structure which will '
48
 
              'be formatted as YAML.')
49
 
        )
50
 
    }
51
 
 
52
 
    def handle_create(self):
53
 
        cloud_config = template_format.yaml.dump(self.properties.get(
54
 
            self.CLOUD_CONFIG), Dumper=template_format.yaml_dumper)
55
 
        props = {
56
 
            self.NAME: self.physical_resource_name(),
57
 
            self.CONFIG: '#cloud-config\n%s' % cloud_config,
58
 
            self.GROUP: 'Heat::Ungrouped'
59
 
        }
60
 
        sc = self.rpc_client().create_software_config(self.context, **props)
61
 
        self.resource_id_set(sc[rpc_api.SOFTWARE_CONFIG_ID])
62
 
 
63
 
 
64
 
def resource_mapping():
65
 
    return {
66
 
        'OS::Heat::CloudConfig': CloudConfig,
67
 
    }