Search in sources :

Example 1 with Option

use of org.ovirt.engine.api.model.Option in project ovirt-engine by oVirt.

the class BackendGlusterVolumeResource method resetOption.

@Override
public Response resetOption(Action action) {
    Option option = action.getOption();
    validateParameters(option, "name");
    return resetOption(action, option.getName(), option.getValue(), action.isSetForce() ? action.isForce() : false);
}
Also used : Option(org.ovirt.engine.api.model.Option)

Example 2 with Option

use of org.ovirt.engine.api.model.Option in project ovirt-engine by oVirt.

the class GlusterVolumeMapper method map.

@Mapping(from = GlusterVolumeEntity.class, to = GlusterVolume.class)
public static GlusterVolume map(GlusterVolumeEntity fromVolume, GlusterVolume toVolume) {
    GlusterVolume volume = toVolume != null ? toVolume : new GlusterVolume();
    if (fromVolume.getId() != null) {
        volume.setId(fromVolume.getId().toString());
    }
    if (fromVolume.getName() != null) {
        volume.setName(fromVolume.getName());
    }
    if (fromVolume.getVolumeType() != null) {
        volume.setVolumeType(map(fromVolume.getVolumeType(), null));
    }
    if (fromVolume.getTransportTypes() != null) {
        ArrayList<TransportType> transportTypeList = new ArrayList<>();
        for (org.ovirt.engine.core.common.businessentities.gluster.TransportType transportType : fromVolume.getTransportTypes()) {
            transportTypeList.add(map(transportType, null));
        }
        volume.setTransportTypes(new GlusterVolume.TransportTypesList());
        volume.getTransportTypes().getTransportTypes().addAll(transportTypeList);
    }
    volume.setReplicaCount(fromVolume.getReplicaCount());
    volume.setStripeCount(fromVolume.getStripeCount());
    volume.setDisperseCount(fromVolume.getDisperseCount());
    volume.setRedundancyCount(fromVolume.getRedundancyCount());
    if (fromVolume.getStatus() != null) {
        volume.setStatus(mapVolumeStatus(fromVolume.getStatus()));
    }
    if (fromVolume.getOptions() != null) {
        Options glusterOptions = new Options();
        List<Option> options = glusterOptions.getOptions();
        for (GlusterVolumeOptionEntity option : fromVolume.getOptions()) {
            options.add(mapOption(option));
        }
        volume.setOptions(glusterOptions);
    }
    return volume;
}
Also used : Options(org.ovirt.engine.api.model.Options) GlusterVolume(org.ovirt.engine.api.model.GlusterVolume) ArrayList(java.util.ArrayList) GlusterVolumeOptionEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeOptionEntity) Option(org.ovirt.engine.api.model.Option) TransportType(org.ovirt.engine.api.model.TransportType)

Example 3 with Option

use of org.ovirt.engine.api.model.Option in project ovirt-engine by oVirt.

the class GlusterVolumeMapper method mapOption.

private static Option mapOption(GlusterVolumeOptionEntity fromOption) {
    Option option = new Option();
    option.setName(fromOption.getKey());
    option.setValue(fromOption.getValue());
    return option;
}
Also used : Option(org.ovirt.engine.api.model.Option)

Example 4 with Option

use of org.ovirt.engine.api.model.Option in project ovirt-engine by oVirt.

the class HostNicMapper method map.

@Mapping(from = HostNic.class, to = VdsNetworkInterface.class)
public static VdsNetworkInterface map(HostNic model, VdsNetworkInterface template) {
    VdsNetworkInterface entity;
    if (template != null) {
        entity = template;
    } else if (model.isSetBonding()) {
        entity = new Bond();
    } else if (model.isSetVlan()) {
        entity = new Vlan();
    } else {
        entity = new Nic();
    }
    if (model.isSetId()) {
        entity.setId(GuidUtils.asGuid(model.getId()));
    }
    if (model.isSetNetwork() && model.getNetwork().isSetName()) {
        entity.setNetworkName(model.getNetwork().getName());
    }
    if (model.isSetName()) {
        entity.setName(model.getName());
    }
    if (model.isSetBaseInterface()) {
        entity.setBaseInterface(model.getBaseInterface());
    }
    mapIpv4FromModel(model, entity);
    mapIpv6FromModel(model, entity);
    if (model.isSetMac() && model.getMac().isSetAddress()) {
        entity.setMacAddress(model.getMac().getAddress());
    }
    if (model.isSetBonding()) {
        entity.setBonded(true);
        if (model.getBonding().isSetOptions()) {
            List<Option> bondingOptions = model.getBonding().getOptions().getOptions();
            String optionsString = bondingOptions.stream().filter(Option::isSetName).map(x -> x.getName() + "=" + x.getValue()).collect(joining(" "));
            entity.setBondOptions(optionsString);
        }
    }
    if (model.isSetQos()) {
        entity.setQos((HostNetworkQos) QosMapper.map(model.getQos(), null));
    }
    return entity;
}
Also used : StringUtils(org.apache.commons.lang.StringUtils) InterfaceStatus(org.ovirt.engine.core.common.businessentities.network.InterfaceStatus) HostNic(org.ovirt.engine.api.model.HostNic) GuidUtils(org.ovirt.engine.api.restapi.utils.GuidUtils) VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface) Ipv6BootProtocol(org.ovirt.engine.core.common.businessentities.network.Ipv6BootProtocol) Option(org.ovirt.engine.api.model.Option) Network(org.ovirt.engine.api.model.Network) Mac(org.ovirt.engine.api.model.Mac) BootProtocol(org.ovirt.engine.api.model.BootProtocol) Bonding(org.ovirt.engine.api.model.Bonding) IpVersion(org.ovirt.engine.api.model.IpVersion) HostNetworkQos(org.ovirt.engine.core.common.businessentities.network.HostNetworkQos) Vlan(org.ovirt.engine.core.common.businessentities.network.Vlan) Nic(org.ovirt.engine.core.common.businessentities.network.Nic) Ipv4BootProtocol(org.ovirt.engine.core.common.businessentities.network.Ipv4BootProtocol) Collectors.joining(java.util.stream.Collectors.joining) NicStatus(org.ovirt.engine.api.model.NicStatus) UpdateHostNicVfsConfigParameters(org.ovirt.engine.core.common.action.UpdateHostNicVfsConfigParameters) List(java.util.List) HostNicVirtualFunctionsConfiguration(org.ovirt.engine.api.model.HostNicVirtualFunctionsConfiguration) Bond(org.ovirt.engine.core.common.businessentities.network.Bond) Ip(org.ovirt.engine.api.model.Ip) Options(org.ovirt.engine.api.model.Options) HostNicVfsConfig(org.ovirt.engine.core.common.businessentities.network.HostNicVfsConfig) VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface) HostNic(org.ovirt.engine.api.model.HostNic) Nic(org.ovirt.engine.core.common.businessentities.network.Nic) Option(org.ovirt.engine.api.model.Option) Vlan(org.ovirt.engine.core.common.businessentities.network.Vlan) Bond(org.ovirt.engine.core.common.businessentities.network.Bond)

Example 5 with Option

use of org.ovirt.engine.api.model.Option in project ovirt-engine by oVirt.

the class FenceAgentMapper method addPortToOptions.

/**
 * Adds 'port' to options. The engine requires it this way, but conceptually this is wrong and the engine should
 * take care of it and not delegate this responsibility to clients (TODO).
 */
private static void addPortToOptions(Agent model) {
    if (!model.isSetOptions()) {
        model.setOptions(new Options());
    }
    Option option = new Option();
    option.setName(PORT_OPTION);
    option.setValue(String.valueOf(model.getPort()));
    model.getOptions().getOptions().add(option);
}
Also used : Options(org.ovirt.engine.api.model.Options) Option(org.ovirt.engine.api.model.Option)

Aggregations

Option (org.ovirt.engine.api.model.Option)13 Test (org.junit.Test)4 Action (org.ovirt.engine.api.model.Action)4 AbstractBackendSubResourceTest (org.ovirt.engine.api.restapi.resource.AbstractBackendSubResourceTest)4 Options (org.ovirt.engine.api.model.Options)3 WebApplicationException (javax.ws.rs.WebApplicationException)2 GlusterVolumeOptionParameters (org.ovirt.engine.core.common.action.gluster.GlusterVolumeOptionParameters)2 GlusterVolumeOptionEntity (org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeOptionEntity)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Collectors.joining (java.util.stream.Collectors.joining)1 StringUtils (org.apache.commons.lang.StringUtils)1 Bonding (org.ovirt.engine.api.model.Bonding)1 BootProtocol (org.ovirt.engine.api.model.BootProtocol)1 GlusterVolume (org.ovirt.engine.api.model.GlusterVolume)1 HostNic (org.ovirt.engine.api.model.HostNic)1 HostNicVirtualFunctionsConfiguration (org.ovirt.engine.api.model.HostNicVirtualFunctionsConfiguration)1 Ip (org.ovirt.engine.api.model.Ip)1 IpVersion (org.ovirt.engine.api.model.IpVersion)1 Mac (org.ovirt.engine.api.model.Mac)1