Search in sources :

Example 1 with CinderVolumeDriver

use of org.ovirt.engine.core.common.businessentities.storage.CinderVolumeDriver in project ovirt-engine by oVirt.

the class CinderBroker method updateConnectionInfoForDisk.

public void updateConnectionInfoForDisk(CinderDisk cinderDisk) {
    try {
        CinderConnectionInfo connectionInfo = initializeConnectionForDisk(cinderDisk);
        CinderVolumeDriver cinderVolumeDriver = CinderVolumeDriver.forValue(connectionInfo.getDriverVolumeType());
        if (cinderVolumeDriver == null) {
            logDiskEvent(cinderDisk, AuditLogType.CINDER_DISK_CONNECTION_VOLUME_DRIVER_UNSUPPORTED);
        }
        cinderDisk.setCinderConnectionInfo(connectionInfo);
    } catch (OpenStackResponseException ex) {
        logDiskEvent(cinderDisk, AuditLogType.CINDER_DISK_CONNECTION_FAILURE);
        throw ex;
    }
}
Also used : CinderConnectionInfo(org.ovirt.engine.core.common.businessentities.storage.CinderConnectionInfo) OpenStackResponseException(com.woorea.openstack.base.client.OpenStackResponseException) CinderVolumeDriver(org.ovirt.engine.core.common.businessentities.storage.CinderVolumeDriver)

Example 2 with CinderVolumeDriver

use of org.ovirt.engine.core.common.businessentities.storage.CinderVolumeDriver in project ovirt-engine by oVirt.

the class VmInfoBuildUtils method buildCinderDisk.

@SuppressWarnings("unchecked")
public void buildCinderDisk(CinderDisk cinderDisk, Map<String, Object> struct) {
    CinderConnectionInfo connectionInfo = cinderDisk.getCinderConnectionInfo();
    CinderVolumeDriver cinderVolumeDriver = CinderVolumeDriver.forValue(connectionInfo.getDriverVolumeType());
    if (cinderVolumeDriver == null) {
        log.error("Unsupported Cinder volume driver: '{}' (disk: '{}')", connectionInfo.getDriverVolumeType(), cinderDisk.getDiskAlias());
        return;
    }
    switch(cinderVolumeDriver) {
        case RBD:
            Map<String, Object> connectionInfoData = cinderDisk.getCinderConnectionInfo().getData();
            struct.put(VdsProperties.Path, connectionInfoData.get("name"));
            struct.put(VdsProperties.Format, VolumeFormat.RAW.toString().toLowerCase());
            struct.put(VdsProperties.PropagateErrors, PropagateErrors.Off.toString().toLowerCase());
            struct.put(VdsProperties.Protocol, cinderDisk.getCinderConnectionInfo().getDriverVolumeType());
            struct.put(VdsProperties.DiskType, VdsProperties.NETWORK);
            List<String> hostAddresses = (ArrayList<String>) connectionInfoData.get("hosts");
            List<String> hostPorts = (ArrayList<String>) connectionInfoData.get("ports");
            List<Map<String, Object>> hosts = new ArrayList<>();
            // (Cinder should ensure that the addresses and ports lists are synced in order).
            for (int i = 0; i < hostAddresses.size(); i++) {
                Map<String, Object> hostMap = new HashMap<>();
                hostMap.put(VdsProperties.NetworkDiskName, hostAddresses.get(i));
                hostMap.put(VdsProperties.NetworkDiskPort, hostPorts.get(i));
                hostMap.put(VdsProperties.NetworkDiskTransport, VdsProperties.Tcp);
                hosts.add(hostMap);
            }
            struct.put(VdsProperties.NetworkDiskHosts, hosts);
            boolean authEnabled = (boolean) connectionInfoData.get(VdsProperties.CinderAuthEnabled);
            String secretType = (String) connectionInfoData.get(VdsProperties.CinderSecretType);
            String authUsername = (String) connectionInfoData.get(VdsProperties.CinderAuthUsername);
            String secretUuid = (String) connectionInfoData.get(VdsProperties.CinderSecretUuid);
            if (authEnabled) {
                Map<String, Object> authMap = new HashMap<>();
                authMap.put(VdsProperties.NetworkDiskAuthSecretType, secretType);
                authMap.put(VdsProperties.NetworkDiskAuthUsername, authUsername);
                authMap.put(VdsProperties.NetworkDiskAuthSecretUuid, secretUuid);
                struct.put(VdsProperties.NetworkDiskAuth, authMap);
            }
            break;
    }
}
Also used : CinderConnectionInfo(org.ovirt.engine.core.common.businessentities.storage.CinderConnectionInfo) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) CinderVolumeDriver(org.ovirt.engine.core.common.businessentities.storage.CinderVolumeDriver) Map(java.util.Map) HashMap(java.util.HashMap)

Aggregations

CinderConnectionInfo (org.ovirt.engine.core.common.businessentities.storage.CinderConnectionInfo)2 CinderVolumeDriver (org.ovirt.engine.core.common.businessentities.storage.CinderVolumeDriver)2 OpenStackResponseException (com.woorea.openstack.base.client.OpenStackResponseException)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1