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);
}
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;
}
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;
}
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;
}
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);
}
Aggregations