Exemple #1
0
    def _parseVolumeStatusClients_test(self):
        out = """<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<cliOutput>
  <opRet>0</opRet>
  <opErrno>0</opErrno>
  <opErrstr/>
  <volStatus>
    <volumes>
      <volume>
        <volName>music</volName>
        <nodeCount>2</nodeCount>
        <node>
          <hostname>192.168.122.2</hostname>
          <path>/tmp/music-b1</path>
          <peerid>f06b108e-a780-4519-bb22-c3083a1e3f8a</peerid>
          <port>49152</port>
          <status>1</status>
          <pid>1313</pid>
          <clientsStatus>
            <clientCount>2</clientCount>
            <client>
              <hostname>192.168.122.2:1021</hostname>
              <bytesRead>1172</bytesRead>
              <bytesWrite>792</bytesWrite>
            </client>
            <client>
              <hostname>192.168.122.2:1011</hostname>
              <bytesRead>10076</bytesRead>
              <bytesWrite>12152</bytesWrite>
            </client>
          </clientsStatus>
        </node>
        <node>
          <hostname>192.168.122.2</hostname>
          <path>/tmp/music-b2</path>
          <peerid>f06b108e-a780-4519-bb22-c3083a1e3f8a</peerid>
          <port>49153</port>
          <status>1</status>
          <pid>1335</pid>
          <clientsStatus>
            <clientCount>2</clientCount>
            <client>
              <hostname>192.168.122.2:1020</hostname>
              <bytesRead>1172</bytesRead>
              <bytesWrite>792</bytesWrite>
            </client>
            <client>
              <hostname>192.168.122.2:1010</hostname>
              <bytesRead>10864</bytesRead>
              <bytesWrite>12816</bytesWrite>
            </client>
          </clientsStatus>
        </node>
      </volume>
    </volumes>
  </volStatus>
</cliOutput>
"""
        tree = etree.fromstring(out)
        status = gcli._parseVolumeStatusClients(tree)
        self.assertEquals(status.keys(), ['bricks', 'name'])
        self.assertEquals(status['name'], 'music')
        oBricks = [{
            'brick':
            '192.168.122.2:/tmp/music-b1',
            'hostuuid':
            'f06b108e-a780-4519-bb22-c3083a1e3f8a',
            'clientsStatus': [{
                'bytesRead': '1172',
                'bytesWrite': '792',
                'hostname': '192.168.122.2:1021'
            }, {
                'bytesRead': '10076',
                'bytesWrite': '12152',
                'hostname': '192.168.122.2:1011'
            }]
        }, {
            'brick':
            '192.168.122.2:/tmp/music-b2',
            'hostuuid':
            'f06b108e-a780-4519-bb22-c3083a1e3f8a',
            'clientsStatus': [{
                'bytesRead': '1172',
                'bytesWrite': '792',
                'hostname': '192.168.122.2:1020'
            }, {
                'bytesRead': '10864',
                'bytesWrite': '12816',
                'hostname': '192.168.122.2:1010'
            }]
        }]
        self.assertEquals(status['bricks'], oBricks)
    def _parseVolumeStatusClients_test(self):
        out = """<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<cliOutput>
  <opRet>0</opRet>
  <opErrno>0</opErrno>
  <opErrstr/>
  <volStatus>
    <volumes>
      <volume>
        <volName>music</volName>
        <nodeCount>2</nodeCount>
        <node>
          <hostname>192.168.122.2</hostname>
          <path>/tmp/music-b1</path>
          <port>49152</port>
          <status>1</status>
          <pid>1313</pid>
          <clientsStatus>
            <clientCount>2</clientCount>
            <client>
              <hostname>192.168.122.2:1021</hostname>
              <bytesRead>1172</bytesRead>
              <bytesWrite>792</bytesWrite>
            </client>
            <client>
              <hostname>192.168.122.2:1011</hostname>
              <bytesRead>10076</bytesRead>
              <bytesWrite>12152</bytesWrite>
            </client>
          </clientsStatus>
        </node>
        <node>
          <hostname>192.168.122.2</hostname>
          <path>/tmp/music-b2</path>
          <port>49153</port>
          <status>1</status>
          <pid>1335</pid>
          <clientsStatus>
            <clientCount>2</clientCount>
            <client>
              <hostname>192.168.122.2:1020</hostname>
              <bytesRead>1172</bytesRead>
              <bytesWrite>792</bytesWrite>
            </client>
            <client>
              <hostname>192.168.122.2:1010</hostname>
              <bytesRead>10864</bytesRead>
              <bytesWrite>12816</bytesWrite>
            </client>
          </clientsStatus>
        </node>
      </volume>
    </volumes>
  </volStatus>
</cliOutput>
"""
        tree = etree.fromstring(out)
        status = gcli._parseVolumeStatusClients(tree)
        self.assertEquals(status.keys(), ['bricks', 'name'])
        self.assertEquals(status['name'], 'music')
        oBricks = [{'brick': '192.168.122.2:/tmp/music-b1',
                    'clientsStatus': [{'bytesRead': '1172',
                                       'bytesWrite': '792',
                                       'hostname': '192.168.122.2:1021'},
                                      {'bytesRead': '10076',
                                       'bytesWrite': '12152',
                                       'hostname': '192.168.122.2:1011'}]},
                   {'brick': '192.168.122.2:/tmp/music-b2',
                    'clientsStatus': [{'bytesRead': '1172',
                                       'bytesWrite': '792',
                                       'hostname': '192.168.122.2:1020'},
                                      {'bytesRead': '10864',
                                       'bytesWrite': '12816',
                                       'hostname': '192.168.122.2:1010'}]}]
        self.assertEquals(status['bricks'], oBricks)
Exemple #3
0
    def _parseVolumeStatusClients_test(self):
        out = """<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<cliOutput>
  <opRet>0</opRet>
  <opErrno>0</opErrno>
  <opErrstr/>
  <volStatus>
    <volumes>
      <volume>
        <volName>music</volName>
        <nodeCount>2</nodeCount>
        <node>
          <hostname>192.168.122.2</hostname>
          <path>/tmp/music-b1</path>
          <peerid>f06b108e-a780-4519-bb22-c3083a1e3f8a</peerid>
          <port>49152</port>
          <status>1</status>
          <pid>1313</pid>
          <clientsStatus>
            <clientCount>2</clientCount>
            <client>
              <hostname>192.168.122.2:1021</hostname>
              <bytesRead>1172</bytesRead>
              <bytesWrite>792</bytesWrite>
            </client>
            <client>
              <hostname>192.168.122.2:1011</hostname>
              <bytesRead>10076</bytesRead>
              <bytesWrite>12152</bytesWrite>
            </client>
          </clientsStatus>
        </node>
        <node>
          <hostname>192.168.122.2</hostname>
          <path>/tmp/music-b2</path>
          <peerid>f06b108e-a780-4519-bb22-c3083a1e3f8a</peerid>
          <port>49153</port>
          <status>1</status>
          <pid>1335</pid>
          <clientsStatus>
            <clientCount>2</clientCount>
            <client>
              <hostname>192.168.122.2:1020</hostname>
              <bytesRead>1172</bytesRead>
              <bytesWrite>792</bytesWrite>
            </client>
            <client>
              <hostname>192.168.122.2:1010</hostname>
              <bytesRead>10864</bytesRead>
              <bytesWrite>12816</bytesWrite>
            </client>
          </clientsStatus>
        </node>
      </volume>
    </volumes>
  </volStatus>
</cliOutput>
"""
        tree = etree.fromstring(out)
        status = gcli._parseVolumeStatusClients(tree)
        self.assertEquals(status.keys(), ["bricks", "name"])
        self.assertEquals(status["name"], "music")
        oBricks = [
            {
                "brick": "192.168.122.2:/tmp/music-b1",
                "hostuuid": "f06b108e-a780-4519-bb22-c3083a1e3f8a",
                "clientsStatus": [
                    {"bytesRead": "1172", "bytesWrite": "792", "hostname": "192.168.122.2:1021"},
                    {"bytesRead": "10076", "bytesWrite": "12152", "hostname": "192.168.122.2:1011"},
                ],
            },
            {
                "brick": "192.168.122.2:/tmp/music-b2",
                "hostuuid": "f06b108e-a780-4519-bb22-c3083a1e3f8a",
                "clientsStatus": [
                    {"bytesRead": "1172", "bytesWrite": "792", "hostname": "192.168.122.2:1020"},
                    {"bytesRead": "10864", "bytesWrite": "12816", "hostname": "192.168.122.2:1010"},
                ],
            },
        ]
        self.assertEquals(status["bricks"], oBricks)