9ca484f4338bff2e93f7fed90b39fd160c1144b8
[certmaster.git] / certmaster / minion / modules / certmaster.py
1 ## -*- coding: utf-8 -*-
2 ##
3 ## Process lister (control TBA)
4 ##
5 ## Copyright 2008, Red Hat, Inc
6 ## Michael DeHaan <mdehaan@redhat.com>
7 ##
8 ## This software may be freely redistributed under the terms of the GNU
9 ## general public license.
10 ##
11 ## You should have received a copy of the GNU General Public License
12 ## along with this program; if not, write to the Free Software
13 ## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
14 ##
15
16 # other modules
17 import sub_process
18 import codes
19
20 # our modules
21 import func_module
22 from func import certmaster as certmaster
23
24 # =================================
25
26 class CertMasterModule(func_module.FuncModule):
27
28 version = "0.0.1"
29 api_version = "0.0.1"
30 description = "Administers certs on an overlord."
31
32 def get_hosts_to_sign(self, list_of_hosts):
33 """
34 ...
35 """
36 list_of_hosts = self.__listify(list_of_hosts)
37 cm = certmaster.CertMaster()
38 return cm.get_csrs_waiting()
39
40 def sign_hosts(self, list_of_hosts):
41 """
42 ...
43 """
44 list_of_hosts = self.__listify(list_of_hosts)
45 cm = certmaster.CertMaster()
46 for x in list_of_hosts:
47 cm.sign_this_csr(x)
48 return True
49
50 def cleanup_hosts(self, list_of_hosts):
51 """
52 ...
53 """
54 list_of_hosts = self.__listify(list_of_hosts)
55 cm = certmaster.CertMaster()
56 for x in list_of_hosts:
57 cm.remove_this_cert(x)
58 return True
59
60 def __listify(self, list_of_hosts):
61 if type(list_of_hosts) is type([]):
62 return list_of_hosts
63 else:
64 return [ list_of_hosts ]
65