def test_shrink_volume(self, monkeypatch): volume_name = "vol1" brick_details = [ [ {"12.23.34.45": "brick3"}, {"22.23.34.45": "brick3"}, {"32.23.34.45": "brick3"}, ], ] replica_count = "3" action = "start" def mock_cook_gdeploy_config(recipe): expected_recipe = [ {"hosts": ["12.23.34.45", "22.23.34.45", "32.23.34.45"]}, { "volume": { "volname": "vol1", "action": "remove-brick", "bricks": [ "12.23.34.45:brick3", "22.23.34.45:brick3", "32.23.34.45:brick3" ], "state": "start", "ignore_volume_errors": "no", } }, ] assert recipe[1] == expected_recipe[1] return "" monkeypatch.setattr(sgv, 'cook_gdeploy_config', mock_cook_gdeploy_config) def mock_invoke_gdeploy(config): out = "succefully created" err = "" rc = 0 return out, err, rc monkeypatch.setattr(sgv, 'invoke_gdeploy', mock_invoke_gdeploy) out, err, rc = sgv.shrink_gluster_volume( volume_name, brick_details, replica_count=replica_count, action=action ) assert out == "succefully created" assert err == "" assert rc == 0
def shrink_volume(self, volume_name, brick_details, action, replica_count=None, disperse_count=None, redundancy_count=None, force=False): args = {} if replica_count: args.update({"replica_count": replica_count}) if disperse_count: args.update({"disperse_count": disperse_count}) if redundancy_count: args.update({"redundancy_count": redundacy_count}) if force: args.update({"force": force}) out, err, rc = shrink_gluster_volume.shrink_gluster_volume( volume_name, brick_details, action, **args) if rc == 0: Event( Message( priority="info", publisher=NS.publisher_id, payload={ "message": "Volume %s shrinked successfully" % volume_name }, cluster_id=NS.tendrl_context.integration_id, )) else: Event( Message( priority="error", publisher=NS.publisher_id, payload={ "message": "Volume shrink failed for volume " "%s. Details: %s" % (volume_name, out) }, cluster_id=NS.tendrl_context.integration_id, )) return False return True
def shrink_volume(self, volume_name, brick_details, action, replica_count=None, disperse_count=None, force=False, decrease_replica_count=False): args = {} if replica_count: args.update({"replica_count": replica_count}) if disperse_count: args.update({"disperse_count": disperse_count}) if force: args.update({"force": force}) if decrease_replica_count: args.update({"decrease_replica_count": decrease_replica_count}) out, err, rc = shrink_gluster_volume.shrink_gluster_volume( volume_name, brick_details, action, **args ) if rc == 0: logger.log( "info", NS.publisher_id, {"message": "Volume %s shrinked successfully" % volume_name}, integration_id=NS.tendrl_context.integration_id ) else: logger.log( "info", NS.publisher_id, {"message": "Volume shrink failed for volume " "%s. Details: %s" % (volume_name, out)}, integration_id=NS.tendrl_context.integration_id ) return False return True
def shrink_volume(self, volume_name, brick_details, action, replica_count=None, disperse_count=None, force=False, decrease_replica_count=False): args = {} if replica_count: args.update({"replica_count": replica_count}) if disperse_count: args.update({"disperse_count": disperse_count}) if force: args.update({"force": force}) if decrease_replica_count: args.update({"decrease_replica_count": decrease_replica_count}) out, err, rc = shrink_gluster_volume.shrink_gluster_volume( volume_name, brick_details, action, **args) if rc == 0: logger.log( "info", NS.publisher_id, {"message": "Volume %s shrinked successfully" % volume_name}, integration_id=NS.tendrl_context.integration_id) else: logger.log("info", NS.publisher_id, { "message": "Volume shrink failed for volume " "%s. Details: %s" % (volume_name, out) }, integration_id=NS.tendrl_context.integration_id) return False return True