3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain 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,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14 from cmframework.apis import cmerror
17 class CMAnsibleInventoryConfigPlugin(object):
19 def __init__(self, confman, inventory, ownhost):
20 self.confman = confman
21 self.inventory = inventory
22 self.ownhost = ownhost
24 def add_host_var(self, host, name, value):
25 """add a host specific variable
27 host: The name of the host
28 name: The name of the variable.
31 if host not in self.inventory['_meta']['hostvars']:
32 self.inventory['_meta']['hostvars'][host] = {}
33 self.inventory['_meta']['hostvars'][host][name] = value
35 def add_global_var(self, name, value):
36 """add a global variable to the inventory
38 name: The name of the variable
41 self.inventory['all']['vars'][name] = value
43 def add_host_group(self, name, value):
44 self.inventory[name] = value
46 # pylint: disable=no-self-use
47 def handle_bootstrapping(self):
48 """provide inventory extensions
52 CMError is raised in-case of failure
55 raise cmerror.CMError('No implemented')
57 # pylint: disable=no-self-use
58 def handle_provisioning(self):
59 """provide inventory extensions
63 CMError is raised in-case of failure
66 raise cmerror.CMError('No implemented')
68 # pylint: disable=no-self-use
69 def handle_postconfig(self):
70 """provide inventory extensions
74 CMError is raised in-case of failure
77 raise cmerror.CMError('No implemented')
79 # pylint: disable=no-self-use
80 def handle_setup(self):
81 """provide inventory extensions
85 CMError is raised in-case of failure
88 raise cmerror.CMError('No implemented')