Merge "Remove Compass from genesis."
[genesis.git] / opensteak / tools / opensteak / foreman_objects / itemHostsGroup.py
1 #!/usr/bin/python3
2 # -*- coding: utf-8 -*-
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
6 #
7 #      http://www.apache.org/licenses/LICENSE-2.0
8 #
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
13 # under the License.
14 #
15 # Authors:
16 # @author: David Blaisonneau <david.blaisonneau@orange.com>
17 # @author: Arnaud Morin <arnaud1.morin@orange.com>
18
19 from opensteak.foreman_objects.item import ForemanItem
20
21
22 class ItemHostsGroup(ForemanItem):
23     """
24     ItemHostsGroup class
25     Represent the content of a foreman hostgroup as a dict
26     """
27
28     objName = 'hostgroups'
29     payloadObj = 'hostgroup'
30
31     def __init__(self, api, key, *args, **kwargs):
32         """ Function __init__
33         Represent the content of a foreman object as a dict
34
35         @param api: The foreman api
36         @param key: The object Key
37         @param *args, **kwargs: the dict representation
38         @return RETURN: Itself
39         """
40         ForemanItem.__init__(self, api, key,
41                              self.objName, self.payloadObj,
42                              *args, **kwargs)
43         self.update({'puppetclass_ids':
44                      self.api.list('{}/{}/puppetclass_ids'
45                                    .format(self.objName, key))})
46         self.update({'param_ids':
47                      list(self.api.list('{}/{}/parameters'
48                                         .format(self.objName, key),
49                                         only_id=True)
50                           .keys())})