def _parseVolumeInfo_empty_test(self): out = """<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <cliOutput> <opRet>0</opRet> <opErrno>0</opErrno> <opErrstr/> <volInfo/> </cliOutput> """ tree = etree.fromstring(out) self.assertFalse(gcli._parseVolumeInfo(tree))
def _parseVolumeInfo_empty_test(self): out = """<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <cliOutput> <opRet>0</opRet> <opErrno>0</opErrno> <opErrstr/> <volInfo/> </cliOutput> """ tree = etree.fromstring(out) self.assertFalse(gcli._parseVolumeInfo(tree))
def _parseVolumeInfo_test(self): out = """<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <cliOutput> <opRet>0</opRet> <opErrno>0</opErrno> <opErrstr/> <volInfo> <volumes> <volume> <name>music</name> <id>b3114c71-741b-4c6f-a39e-80384c4ea3cf</id> <status>1</status> <statusStr>Started</statusStr> <brickCount>2</brickCount> <distCount>2</distCount> <stripeCount>1</stripeCount> <replicaCount>2</replicaCount> <type>2</type> <typeStr>Replicate</typeStr> <transport>0</transport> <bricks> <brick>192.168.122.2:/tmp/music-b1</brick> <brick>192.168.122.2:/tmp/music-b2</brick> </bricks> <optCount>1</optCount> <options> <option> <name>auth.allow</name> <value>*</value> </option> </options> </volume> <volume> <name>test1</name> <id>b444ed94-f346-4cda-bd55-0282f21d22db</id> <status>2</status> <statusStr>Stopped</statusStr> <brickCount>1</brickCount> <distCount>1</distCount> <stripeCount>1</stripeCount> <replicaCount>1</replicaCount> <type>0</type> <typeStr>Distribute</typeStr> <transport>1</transport> <bricks> <brick>192.168.122.2:/tmp/test1-b1</brick> </bricks> <optCount>0</optCount> <options/> </volume> <count>2</count> </volumes> </volInfo> </cliOutput> """ tree = etree.fromstring(out) oVolumeInfo = \ {'music': {'brickCount': '2', 'bricks': ['192.168.122.2:/tmp/music-b1', '192.168.122.2:/tmp/music-b2'], 'distCount': '2', 'options': {'auth.allow': '*'}, 'replicaCount': '2', 'stripeCount': '1', 'transportType': [gcli.TransportType.TCP], 'uuid': 'b3114c71-741b-4c6f-a39e-80384c4ea3cf', 'volumeName': 'music', 'volumeStatus': gcli.VolumeStatus.ONLINE, 'volumeType': 'REPLICATE'}, 'test1': {'brickCount': '1', 'bricks': ['192.168.122.2:/tmp/test1-b1'], 'distCount': '1', 'options': {}, 'replicaCount': '1', 'stripeCount': '1', 'transportType': [gcli.TransportType.RDMA], 'uuid': 'b444ed94-f346-4cda-bd55-0282f21d22db', 'volumeName': 'test1', 'volumeStatus': gcli.VolumeStatus.OFFLINE, 'volumeType': 'DISTRIBUTE'}} volumeInfo = gcli._parseVolumeInfo(tree) self.assertEquals(volumeInfo, oVolumeInfo)
def _parseVolumeInfo_test(self): out = """<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <cliOutput> <opRet>0</opRet> <opErrno>0</opErrno> <opErrstr/> <volInfo> <volumes> <volume> <name>music</name> <id>b3114c71-741b-4c6f-a39e-80384c4ea3cf</id> <status>1</status> <statusStr>Started</statusStr> <brickCount>2</brickCount> <distCount>2</distCount> <stripeCount>1</stripeCount> <replicaCount>2</replicaCount> <type>2</type> <typeStr>Replicate</typeStr> <transport>0</transport> <bricks> <brick>192.168.122.2:/tmp/m_b1<name>192.168.122.2:/tmp/m_b1</name> <hostUuid>04eb591b-2fd3-489e-a22c-5d342a3c713d</hostUuid> </brick> <brick>192.168.122.2:/tmp/m_b2<name>192.168.122.2:/tmp/m_b2</name> <hostUuid>04eb591b-2fd3-489e-a22c-5d342a3c713d</hostUuid> </brick> </bricks> <optCount>1</optCount> <options> <option> <name>auth.allow</name> <value>*</value> </option> </options> </volume> <volume> <name>test1</name> <id>b444ed94-f346-4cda-bd55-0282f21d22db</id> <status>2</status> <statusStr>Stopped</statusStr> <brickCount>1</brickCount> <distCount>1</distCount> <stripeCount>1</stripeCount> <replicaCount>1</replicaCount> <type>0</type> <typeStr>Distribute</typeStr> <transport>1</transport> <bricks> <brick>192.168.122.2:/tmp/t_b1<name>192.168.122.2:/tmp/t_b1</name> <hostUuid>04eb591b-2fd3-489e-a22c-5d342a3c713d</hostUuid> </brick> </bricks> <optCount>0</optCount> <options/> </volume> <count>2</count> </volumes> </volInfo> </cliOutput> """ tree = etree.fromstring(out) oVolumeInfo = \ {'music': {'brickCount': '2', 'bricks': ['192.168.122.2:/tmp/m_b1', '192.168.122.2:/tmp/m_b2'], 'distCount': '2', 'bricksInfo': [{ 'name': '192.168.122.2:/tmp/m_b1', 'hostUuid': '04eb591b-2fd3-489e-a22c-5d342a3c713d' }, { 'name': '192.168.122.2:/tmp/m_b2', 'hostUuid': '04eb591b-2fd3-489e-a22c-5d342a3c713d' }], 'options': {'auth.allow': '*'}, 'replicaCount': '2', 'stripeCount': '1', 'transportType': [gcli.TransportType.TCP], 'uuid': 'b3114c71-741b-4c6f-a39e-80384c4ea3cf', 'volumeName': 'music', 'volumeStatus': gcli.VolumeStatus.ONLINE, 'volumeType': 'REPLICATE'}, 'test1': {'brickCount': '1', 'bricks': ['192.168.122.2:/tmp/t_b1'], 'distCount': '1', 'bricksInfo': [{ 'name': '192.168.122.2:/tmp/t_b1', 'hostUuid': '04eb591b-2fd3-489e-a22c-5d342a3c713d' }], 'options': {}, 'replicaCount': '1', 'stripeCount': '1', 'transportType': [gcli.TransportType.RDMA], 'uuid': 'b444ed94-f346-4cda-bd55-0282f21d22db', 'volumeName': 'test1', 'volumeStatus': gcli.VolumeStatus.OFFLINE, 'volumeType': 'DISTRIBUTE'}} volumeInfo = gcli._parseVolumeInfo(tree) self.assertEquals(volumeInfo, oVolumeInfo)
def _parseVolumeInfo_test(self): out = """<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <cliOutput> <opRet>0</opRet> <opErrno>0</opErrno> <opErrstr/> <volInfo> <volumes> <volume> <name>music</name> <id>b3114c71-741b-4c6f-a39e-80384c4ea3cf</id> <status>1</status> <statusStr>Started</statusStr> <brickCount>2</brickCount> <distCount>2</distCount> <stripeCount>1</stripeCount> <replicaCount>2</replicaCount> <disperseCount>0</disperseCount> <redundancyCount>0</redundancyCount> <type>2</type> <typeStr>Replicate</typeStr> <transport>0</transport> <bricks> <brick>192.168.122.2:/tmp/m_b1<name>192.168.122.2:/tmp/m_b1</name> <hostUuid>04eb591b-2fd3-489e-a22c-5d342a3c713d</hostUuid> </brick> <brick>192.168.122.2:/tmp/m_b2<name>192.168.122.2:/tmp/m_b2</name> <hostUuid>04eb591b-2fd3-489e-a22c-5d342a3c713d</hostUuid> </brick> </bricks> <optCount>1</optCount> <options> <option> <name>auth.allow</name> <value>*</value> </option> </options> </volume> <volume> <name>test1</name> <id>b444ed94-f346-4cda-bd55-0282f21d22db</id> <status>2</status> <statusStr>Stopped</statusStr> <brickCount>1</brickCount> <distCount>1</distCount> <stripeCount>1</stripeCount> <replicaCount>1</replicaCount> <disperseCount>0</disperseCount> <redundancyCount>0</redundancyCount> <type>0</type> <typeStr>Distribute</typeStr> <transport>1</transport> <bricks> <brick>192.168.122.2:/tmp/t_b1<name>192.168.122.2:/tmp/t_b1</name> <hostUuid>04eb591b-2fd3-489e-a22c-5d342a3c713d</hostUuid> </brick> </bricks> <optCount>0</optCount> <options/> </volume> <count>2</count> </volumes> </volInfo> </cliOutput> """ tree = etree.fromstring(out) oVolumeInfo = { "music": { "brickCount": "2", "bricks": ["192.168.122.2:/tmp/m_b1", "192.168.122.2:/tmp/m_b2"], "distCount": "2", "bricksInfo": [ {"name": "192.168.122.2:/tmp/m_b1", "hostUuid": "04eb591b-2fd3-489e-a22c-5d342a3c713d"}, {"name": "192.168.122.2:/tmp/m_b2", "hostUuid": "04eb591b-2fd3-489e-a22c-5d342a3c713d"}, ], "options": {"auth.allow": "*"}, "replicaCount": "2", "stripeCount": "1", "disperseCount": "0", "redundancyCount": "0", "transportType": [gcli.TransportType.TCP], "uuid": "b3114c71-741b-4c6f-a39e-80384c4ea3cf", "volumeName": "music", "volumeStatus": gcli.VolumeStatus.ONLINE, "volumeType": "REPLICATE", }, "test1": { "brickCount": "1", "bricks": ["192.168.122.2:/tmp/t_b1"], "distCount": "1", "bricksInfo": [{"name": "192.168.122.2:/tmp/t_b1", "hostUuid": "04eb591b-2fd3-489e-a22c-5d342a3c713d"}], "options": {}, "replicaCount": "1", "stripeCount": "1", "disperseCount": "0", "redundancyCount": "0", "transportType": [gcli.TransportType.RDMA], "uuid": "b444ed94-f346-4cda-bd55-0282f21d22db", "volumeName": "test1", "volumeStatus": gcli.VolumeStatus.OFFLINE, "volumeType": "DISTRIBUTE", }, } volumeInfo = gcli._parseVolumeInfo(tree) self.assertEquals(volumeInfo, oVolumeInfo)