25
25
JUJU_HIERA_PATH = '/var/lib/hiera/'
27
manifest = """{%- if fingerprint -%}
29
key => '{{fingerprint}}',
31
key_content => '{{pgp_block}}',
27
manifest = """{{%- if fingerprint -%}}
29
key => '{{{{fingerprint}}}}',
31
key_content => '{{{{pgp_block}}}}',
36
class {'midonet::repository':}
37
class {'{{component}}':}
36
class {{'midonet::repository':}}
39
39
Apt::Key <| name == 'key' |> -> Apt::Source <| |> ->
40
Class['{{component}}']
44
class InstallCallback(base.ManagerCallback):
44
class PuppetCallback(base.ManagerCallback):
45
45
def __call__(self, manager, service_name, event_name):
46
46
service = manager.get_service(service_name)
48
48
for ctx in service.get('required_data', []):
52
'fingerprint': req_data.get(self._fingerprint_key),
53
'pgp_block': req_data.get(self._content_key)
55
ctxt.update(self._ctxt)
51
57
with tempfile.NamedTemporaryFile(mode='w+t') as tmp:
52
content = jinja2.Environment().from_string(manifest).render(
53
component=self._component,
54
fingerprint=context.get(self._fingerprint_key),
55
pgp_block=context.get(self._content_key))
58
content = jinja2.Environment().from_string(self._manifest).render(
65
def __init__(self, component):
66
self._component = component
69
def __init__(self, actions, ordering, ctxt):
67
70
self._fingerprint_key = 'midonet_key_fingerprint'
68
71
self._content_key = 'midonet_key_content'
72
self._manifest = manifest.format(actions=actions, ordering=ordering)
76
class ExecutPuppetClassCallback(PuppetCallback):
77
execution_template = """class {'{{component}}':}"""
78
ordering_template = """Class['{{component}}']"""
80
def __init__(self, component):
81
super(ExecutPuppetClassCallback, self).__init__(
82
actions=self.execution_template,
83
ordering=self.ordering_template,
84
ctxt={'component': component})
87
class InstallPackagesCallback(PuppetCallback):
88
action_template = """package { %s:
92
def __init__(self, packages=()):
94
for package in packages:
95
actions.append(self.action_template % package)
96
super(InstallPackagesCallback, self).__init__(
97
actions='\n'.join(actions),
98
ordering="""Package<| |>""",
102
InstallCallback = ExecutPuppetClassCallback
71
105
def _apply(path, debug=False):
95
129
subprocess.check_call(cmd)
98
def set_juju_hierarchy(attempts=10, extra_data_dirs=None):
132
def set_juju_hierarchy(attempts=10, extra_data_dirs=None,
133
hiera_path='/etc/puppet/hiera.yaml'):
99
134
"""Sets a puppet datadir lookup to find our customizations.
101
136
Extra data dirs must be relative to /var/lib/hiera