~lazypower/charms/trusty/nexentaedge-swift-gw/metadata-typo

« back to all changes in this revision

Viewing changes to hooks/configurationSteps/neadmStatusProcessor.py

  • Committer: anton.skriptsov at nexenta
  • Date: 2016-01-14 15:37:28 UTC
  • Revision ID: anton.skriptsov@nexenta.com-20160114153728-prghpi416mgiz9qb
fix lint errors

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#/usr/bin/env python
2
 
 
3
 
import os
4
 
import sys
5
1
import re
6
 
import traceback
7
2
import subprocess
8
3
 
9
4
from settings import Settings
14
9
    _checkpoint_cmd = [Settings.NEADM_CMD, 'system', 'service-checkpoint',
15
10
                       'set']
16
11
 
17
 
    #_status_cmd = ['/opt/nedge/neadm/fake-neadm-status.sh']
 
12
    # _status_cmd = ['/opt/nedge/neadm/fake-neadm-status.sh']
18
13
    _status_header = re.compile(
19
14
        "^.*ZONE:HOST.*SID.*UTIL.*CAP.*CPU.*MEM.*DEV.*STATE.*$")
20
15
    _status_names = ['zonehost', 'type', 'sid', 'util', 'cap', 'cpu', 'mem',
36
31
            return ex.output
37
32
        except Exception as e:
38
33
            self.exit_code = 1
39
 
            return "Failed to start {} command".format(command)
 
34
            return "Command {0} failed. Exeption:{1}".format(command, e.output)
40
35
 
41
36
    def get_status(self):
42
37
        output = self.get_raw_output(NeadmStatusProcessor._status_cmd)
43
38
        result = NeadmStatus()
44
 
        #error exit code
 
39
        # error exit code
45
40
        if self.exit_code:
46
41
            result.exit_code = self.exit_code
47
42
            result.output = output
53
48
                continue
54
49
 
55
50
            params = line.split()
56
 
            #print(params)
 
51
            # print(params)
57
52
            if len(params) < 8:
58
53
                continue
59
54
 
66
61
                node[name] = params[NeadmStatusProcessor._status_names.index(
67
62
                    name)]
68
63
 
69
 
    #remove special chars from colored status
 
64
    # remove special chars from colored status
70
65
            node['status'] = re.sub("([^A-Z]+)", '', node['status'])
71
66
            result.append(node)
72
 
            #print(node)
 
67
            # print(node)
73
68
 
74
69
        return result
75
70