Beispiel #1
0
 def _backend_servers_stats(self, *args, **kwargs):
     verb = kwargs.get('verb', None)
     if verb is not None:
         try:
             params = web.input()
             backend_id = params.get('backend_id', None)
             if backend_id is not None:
                 backend = backends.backend_get({'_id': backend_id})
                 if backend is not None:
                     transport = get_xmlrpc_transport(
                         backend['backend_url'],
                         backend['is_kerberos'])
                     s = Servers(transport)
                     count_servers = s.count()
                     result = self._prepare_output(result={
                         'backend_id': backend_id,
                         'server_count': count_servers})
                     return result
         except KerberosError as e:
             (first, last) = e.message
             (message, error_no) = last
             result = self._prepare_output(result={
                 'backend_id': backend_id,
                 'error': True,
                 'error_type': 'Kerberos',
                 'error_msg': message,
                 'error_no': error_no})
             return result
         result = self._prepare_output(result={
             'backend_id': backend_id,
             'server_count': 0})
         return result
Beispiel #2
0
 def _backend_mac_delete(self, *args, **kwargs):
     verb = kwargs.get('verb', None)
     if verb is not None:
         try:
             params = web.input()
             backend_id = params.get('backend_id', None)
             mac_id = params.get('mac_id', None)
             if backend_id is not None and mac_id is not None:
                 backend = backends.backend_get({'_id': backend_id})
                 transport = get_xmlrpc_transport(backend['backend_url'],
                                                  backend['is_kerberos'])
                 s = Macs(transport)
                 mac = s.get(id=mac_id)
                 if mac is not None:
                     result = s.delete(id=mac_id)
                     result = self._prepare_output(result={
                         'backend_id': backend_id,
                         'entry_type': 'boolean',
                         'entry': True})
                     return result
         except KerberosError as e:
             (first, last) = e.message
             (message, error_no) = last
             result = self._prepare_output(result={'backend_id': backend_id,
                                                   'error': True,
                                                   'error_type': 'Kerberos',
                                                   'error_msg': message,
                                                   'error_no': error_no})
             return result
         result = self._prepare_output(result={'backend_id': backend_id,
                                               'entry_type': 'boolean',
                                               'entry': False})
         return result
Beispiel #3
0
 def _backend_host_list(self, *args, **kwargs):
     verb = kwargs.get('verb', None)
     if verb is not None:
         try:
             params = web.input()
             backend_id = params.get('backend_id', None)
             if backend_id is not None:
                 backend = backends.backend_get({'_id': backend_id})
                 transport = get_xmlrpc_transport(backend['backend_url'],
                                                  backend['is_kerberos'])
                 s = Hosts(transport)
                 hostlist = s.list()
                 result = self._prepare_output(
                     result={'backend_id': backend_id,
                             'datalist': hostlist})
                 return result
         except KerberosError as e:
             (first, last) = e.message
             (message, error_no) = last
             result = self._prepare_output(result={'backend_id': backend_id,
                                                   'error': True,
                                                   'error_type': 'Kerberos',
                                                   'error_msg': message,
                                                   'error_no': error_no})
             return result
     result = self._prepare_output(result={'backend_id': backend_id,
                                           'datalist': []})
     return result
Beispiel #4
0
 def _backend_deployment_stats(self, *args, **kwargs):
     verb = kwargs.get('verb', None)
     if verb is not None:
         try:
             params = web.input()
             backend_id = params.get('backend_id', None)
             what = params.get('status', None)
             if backend_id is not None:
                 backend = backends.backend_get({'_id': backend_id})
                 if backend is not None:
                     transport = get_xmlrpc_transport(
                         backend['backend_url'],
                         backend['is_kerberos'])
                     s = InstallState(transport)
                     if what is not None and what == 'all':
                         count_deploy = s.count('deploy')
                         count_localboot = s.count('localboot')
                         result = self._prepare_output(result={
                             'backend_id': backend_id,
                             'status': 'all',
                             'count_localboot': count_localboot,
                             'count_deploy': count_deploy})
                     elif (what is not None and
                             what in ('deploy', 'localboot')):
                         count = s.count(what)
                         result = self._prepare_output(result={
                             'backend_id': backend_id,
                             'status': what,
                             'count': count})
                     return result
         except KerberosError as e:
             (first, last) = e.message
             (message, error_no) = last
             result = self._prepare_output(result={
                 'backend_id': backend_id,
                 'error': True,
                 'error_type': 'Kerberos',
                 'error_msg': message,
                 'error_no': error_no})
             return result
         if what is None:
             result = self._prepare_output(result={
                 'backend_id': backend_id,
                 'status': 'all',
                 'count_localboot': 0,
                 'count_deploy': 0})
         elif what is not None and what == 'all':
             result = self._prepare_output(result={
                 'backend_id': backend_id,
                 'status': 'all',
                 'count_localboot': 0,
                 'count_deploy': 0})
         elif what is not None and what in ('deploy', 'localboot'):
             result = self._prepare_output(result={
                 'backend_id': backend_id,
                 'status': what,
                 'count': 0})
         return result
Beispiel #5
0
 def _init_backend(self):
     params = web.input()
     self._backend_id = params.get('backend_id', None)
     self._page.add_page_data({'backend_id': self._backend_id})
     self._backend = backends.backend_get({'_id': self._backend_id})
     self._transport = get_xmlrpc_transport(
         self._backend['backend_url'],
         self._backend['is_kerberos'])
     self._servers = Servers(self._transport)
     self._macs = Macs(self._transport)
     self._ribs = Ribs(self._transport)
     self._hosts = Hosts(self._transport)
Beispiel #6
0
 def _init_backend(self):
     params = web.input()
     self._backend_id = params.get('backend_id', None)
     self._page.add_page_data({'backend_id': self._backend_id})
     self._backend = backends.backend_get({'_id': self._backend_id})
     self._transport = get_xmlrpc_transport(
         self._backend['backend_url'], self._backend['is_kerberos'])
     self._servers = Servers(self._transport)
     self._macs = Macs(self._transport)
     self._ribs = Ribs(self._transport)
     self._hosts = Hosts(self._transport)
     self._backend_settings = BackendSettings(self._transport)
     self._environments = Environments(self._transport)
     self._defaultclasses = DefaultClasses(self._transport)
     self._classtemplates = ClassTemplates(self._transport)
     self._itypes_list = interfacetypes.itype_list()
     self._inet_list = inettypes.inet_list()
Beispiel #7
0
    def _freeipa_host_check(self, *args, **kwargs):
        verb = kwargs.get('verb', None)
        if verb is not None:
            params = web.input()
            backend_id = params.get('backend_id', None)
            host_id = params.get('host_id', None)
            web.debug('_freeipa_host_check: backendID: %s, host_id: %s' %
                      (backend_id, host_id))

            if backend_id is not None:
                backend = backends.backend_get({'_id': backend_id})
                if backend is not None:
                    try:
                        transport = get_xmlrpc_transport(
                            backend['backend_url'],
                            backend['is_kerberos'])
                        fhosts = FreeIPAHosts(transport)
                        hosts = Hosts(transport)
                        if host_id is not None:
                            h = hosts.get(id=host_id)
                            if h is not None:
                                result = fhosts.check(
                                    '{0}.{1}'.format(
                                        h['hostname'],
                                        h['domainname']))
                                if result is not None and result is not False:
                                    output = self._prepare_output(result={
                                        'backend_id': backend_id,
                                        'in_freeipa': True})
                                    return output
                    except KerberosError as e:
                        (first, last) = e.message
                        (message, error_no) = last
                        result = self._prepare_output(
                            result={'backend_id': backend_id,
                                    'error': True,
                                    'error_type': 'Kerberos',
                                    'error_msg': message,
                                    'error_no': error_no})
                        return result
            output = self._prepare_output(
                result={'backend_id': backend_id, 'in_freeipa': False})
            return output
Beispiel #8
0
 def _init_backend(self):
     params = web.input()
     self._backend_id = params.get('backend_id', None)
     self._page.add_page_data({'backend_id': self._backend_id})
     self._backend = backends.backend_get({'_id': self._backend_id})
     self._transport = get_xmlrpc_transport(
         self._backend['backend_url'], self._backend['is_kerberos'])
     self._installstate = InstallState(self._transport)
     self._backend_settings = BackendSettings(self._transport)
     self._hosts = Hosts(self._transport)
     self._freeipa = None
     backendsettings = self._backend_settings.get()
     if backendsettings['IS_FREEIPA_ENABLED']:
         try:
             from dc2.api.dc2.addons.freeipa import Hosts as FreeIPA_Hosts
         except ImportError as e:
             print('You did not install dc2.api')
             print(e)
             sys.exit(1)
         self._freeipa = FreeIPA_Hosts(self._transport)
Beispiel #9
0
 def _init_backend(self, backend):
     self._transport = get_xmlrpc_transport(backend['backend_url'],
                                            backend['is_kerberos'])
     self._defaultclasses = DefaultClasses(self._transport)
Beispiel #10
0
 def _init_backends(self, backend_id):
     backend = backends.backend_get({'_id':backend_id})
     transport = get_xmlrpc_transport(backend['backend_url'],
                                      backend['is_kerberos'])
     self._servers = Servers(transport)
Beispiel #11
0
 def _init_backend(self, backend):
     self._transport = get_xmlrpc_transport(backend['backend_url'],
                                            backend['is_kerberos'])
     self._pxemethods = PXEMethods(self._transport)
Beispiel #12
0
 def _init_backend(self, backend):
     self._transport = get_xmlrpc_transport(backend['backend_url'],
                                            backend['is_kerberos'])
     self._sysusers = SysUsers(self._transport)
Beispiel #13
0
 def _init_backend(self, backend):
     self._transport = get_xmlrpc_transport(backend['backend_url'],
                                            backend['is_kerberos'])
     self._environments = Environments(self._transport)