Example #1
0
    def _parsePeerStatus_test(self):
        out = """<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<cliOutput>
  <opRet>0</opRet>
  <opErrno>0</opErrno>
  <opErrstr/>
  <peerStatus>
    <peer>
      <uuid>610f466c-781a-4e04-8f67-8eba9a201867</uuid>
      <hostname>192.168.2.21</hostname>
      <connected>1</connected>
      <state>3</state>
      <stateStr>Peer in Cluster</stateStr>
    </peer>
    <peer>
      <uuid>12345678-781a-aaaa-bbbb-8eba9a201867</uuid>
      <hostname>FC16-1</hostname>
      <connected>0</connected>
      <state>3</state>
      <stateStr>Peer in Cluster</stateStr>
    </peer>
    <peer>
      <uuid>12345678-cccc-aaaa-bbbb-8eba9a201867</uuid>
      <hostname>FC16-2</hostname>
      <connected>1</connected>
      <state>2</state>
      <stateStr>Peer rejected</stateStr>
    </peer>
  </peerStatus>
</cliOutput>
"""
        tree = etree.fromstring(out)
        hostList = gcli._parsePeerStatus(
            tree, "fedora-16-test", "711d2887-3222-46d8-801a-7e3f646bdd4d", gcli.HostStatus.CONNECTED
        )
        self.assertEquals(
            hostList,
            [
                {
                    "hostname": "fedora-16-test",
                    "uuid": "711d2887-3222-46d8-801a-7e3f646bdd4d",
                    "status": gcli.HostStatus.CONNECTED,
                },
                {
                    "hostname": "192.168.2.21",
                    "uuid": "610f466c-781a-4e04-8f67-8eba9a201867",
                    "status": gcli.HostStatus.CONNECTED,
                },
                {
                    "hostname": "FC16-1",
                    "uuid": "12345678-781a-aaaa-bbbb-8eba9a201867",
                    "status": gcli.HostStatus.DISCONNECTED,
                },
                {
                    "hostname": "FC16-2",
                    "uuid": "12345678-cccc-aaaa-bbbb-8eba9a201867",
                    "status": gcli.HostStatus.UNKNOWN,
                },
            ],
        )
Example #2
0
    def _parsePeerStatus_test(self):
        out = """<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<cliOutput>
  <opRet>0</opRet>
  <opErrno>0</opErrno>
  <opErrstr/>
  <peerStatus>
    <peer>
      <uuid>610f466c-781a-4e04-8f67-8eba9a201867</uuid>
      <hostname>192.168.2.21</hostname>
      <connected>1</connected>
      <state>3</state>
      <stateStr>Peer in Cluster</stateStr>
    </peer>
    <peer>
      <uuid>12345678-781a-aaaa-bbbb-8eba9a201867</uuid>
      <hostname>FC16-1</hostname>
      <connected>0</connected>
      <state>3</state>
      <stateStr>Peer in Cluster</stateStr>
    </peer>
    <peer>
      <uuid>12345678-cccc-aaaa-bbbb-8eba9a201867</uuid>
      <hostname>FC16-2</hostname>
      <connected>1</connected>
      <state>2</state>
      <stateStr>Peer rejected</stateStr>
    </peer>
  </peerStatus>
</cliOutput>
"""
        tree = etree.fromstring(out)
        hostList = \
            gcli._parsePeerStatus(tree, 'fedora-16-test',
                                  '711d2887-3222-46d8-801a-7e3f646bdd4d',
                                  gcli.HostStatus.CONNECTED)
        self.assertEquals(hostList, [{
            'hostname': 'fedora-16-test',
            'uuid': '711d2887-3222-46d8-801a-7e3f646bdd4d',
            'status': gcli.HostStatus.CONNECTED
        }, {
            'hostname': '192.168.2.21',
            'uuid': '610f466c-781a-4e04-8f67-8eba9a201867',
            'status': gcli.HostStatus.CONNECTED
        }, {
            'hostname': 'FC16-1',
            'uuid': '12345678-781a-aaaa-bbbb-8eba9a201867',
            'status': gcli.HostStatus.DISCONNECTED
        }, {
            'hostname': 'FC16-2',
            'uuid': '12345678-cccc-aaaa-bbbb-8eba9a201867',
            'status': gcli.HostStatus.UNKNOWN
        }])
    def _parsePeerStatus_empty_test(self):
        out = """<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<cliOutput>
  <opRet>0</opRet>
  <opErrno>0</opErrno>
  <opErrstr>No peers present</opErrstr>
  <peerStatus/>
</cliOutput>
"""
        tree = etree.fromstring(out)
        hostList = \
            gcli._parsePeerStatus(tree, 'fedora-16-test',
                                  '711d2887-3222-46d8-801a-7e3f646bdd4d',
                                  gcli.HostStatus.CONNECTED)
        self.assertEquals(hostList,
                          [{'hostname': 'fedora-16-test',
                            'uuid': '711d2887-3222-46d8-801a-7e3f646bdd4d',
                            'status': gcli.HostStatus.CONNECTED}])
Example #4
0
    def _parsePeerStatus_empty_test(self):
        out = """<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<cliOutput>
  <opRet>0</opRet>
  <opErrno>0</opErrno>
  <opErrstr>No peers present</opErrstr>
  <peerStatus/>
</cliOutput>
"""
        tree = etree.fromstring(out)
        hostList = \
            gcli._parsePeerStatus(tree, 'fedora-16-test',
                                  '711d2887-3222-46d8-801a-7e3f646bdd4d',
                                  gcli.HostStatus.CONNECTED)
        self.assertEquals(hostList,
                          [{'hostname': 'fedora-16-test',
                            'uuid': '711d2887-3222-46d8-801a-7e3f646bdd4d',
                            'status': gcli.HostStatus.CONNECTED}])