Esempio n. 1
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