Search in sources :

Example 1 with ResourceMakeAvailable

use of com.linbit.linstor.api.model.ResourceMakeAvailable in project cloudstack by apache.

the class LinstorStorageAdaptor method connectPhysicalDisk.

@Override
public boolean connectPhysicalDisk(String volumePath, KVMStoragePool pool, Map<String, String> details) {
    s_logger.debug(String.format("Linstor: connectPhysicalDisk %s:%s -> %s", pool.getUuid(), volumePath, details));
    if (volumePath == null) {
        s_logger.warn("volumePath is null, ignoring");
        return false;
    }
    final DevelopersApi api = getLinstorAPI(pool);
    try {
        final String rscName = getLinstorRscName(volumePath);
        ResourceMakeAvailable rma = new ResourceMakeAvailable();
        ApiCallRcList answers = api.resourceMakeAvailableOnNode(rscName, localNodeName, rma);
        checkLinstorAnswersThrow(answers);
        // allow 2 primaries for live migration, should be removed by disconnect on the other end
        ResourceDefinitionModify rdm = new ResourceDefinitionModify();
        Properties props = new Properties();
        props.put("DrbdOptions/Net/allow-two-primaries", "yes");
        rdm.setOverrideProps(props);
        answers = api.resourceDefinitionModify(rscName, rdm);
        if (answers.hasError()) {
            s_logger.error("Unable to set 'allow-two-primaries' on " + rscName);
            throw new CloudRuntimeException(answers.get(0).getMessage());
        }
    } catch (ApiException apiEx) {
        s_logger.error(apiEx);
        throw new CloudRuntimeException(apiEx.getBestMessage(), apiEx);
    }
    return true;
}
Also used : ApiCallRcList(com.linbit.linstor.api.model.ApiCallRcList) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) ResourceDefinitionModify(com.linbit.linstor.api.model.ResourceDefinitionModify) DevelopersApi(com.linbit.linstor.api.DevelopersApi) ResourceMakeAvailable(com.linbit.linstor.api.model.ResourceMakeAvailable) Properties(com.linbit.linstor.api.model.Properties) ApiException(com.linbit.linstor.api.ApiException)

Aggregations

CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)1 ApiException (com.linbit.linstor.api.ApiException)1 DevelopersApi (com.linbit.linstor.api.DevelopersApi)1 ApiCallRcList (com.linbit.linstor.api.model.ApiCallRcList)1 Properties (com.linbit.linstor.api.model.Properties)1 ResourceDefinitionModify (com.linbit.linstor.api.model.ResourceDefinitionModify)1 ResourceMakeAvailable (com.linbit.linstor.api.model.ResourceMakeAvailable)1