use of org.ovirt.engine.core.common.businessentities.Cluster in project ovirt-engine by oVirt.
the class EditHostModel method setSelectedCluster.
public void setSelectedCluster(VDS host) {
ArrayList<Cluster> clusters;
if (getCluster().getItems() == null) {
Cluster tempVar = new Cluster();
tempVar.setName(host.getClusterName());
tempVar.setId(host.getClusterId());
tempVar.setCompatibilityVersion(host.getClusterCompatibilityVersion());
getCluster().setItems(new ArrayList<>(Arrays.asList(new Cluster[] { tempVar })));
}
clusters = (ArrayList<Cluster>) getCluster().getItems();
updateModelClusterFromVds(clusters, host);
if (getCluster().getSelectedItem() == null) {
getCluster().setSelectedItem(Linq.firstOrNull(clusters));
}
}
use of org.ovirt.engine.core.common.businessentities.Cluster in project ovirt-engine by oVirt.
the class FenceAgentModel method test.
/**
* Execute the fence agent test.
*/
public void test() {
validatePmModels();
if (!isValid()) {
return;
}
setMessage(ConstantsManager.getInstance().getConstants().testingInProgressItWillTakeFewSecondsPleaseWaitMsg());
getTestCommand().setIsExecutionAllowed(false);
Cluster cluster = getHost().getCluster().getSelectedItem();
GetFenceAgentStatusParameters param = new GetFenceAgentStatusParameters();
FenceAgent agent = new FenceAgent();
if (getHost().getHostId() != null) {
param.setVdsId(getHost().getHostId());
}
agent.setOrder(getOrder().getEntity());
agent.setIp(getManagementIp().getEntity());
agent.setType(getPmType().getSelectedItem());
agent.setUser(getPmUserName().getEntity());
agent.setPassword(getPmPassword().getEntity());
agent.setPort(getPmPort().getEntity());
agent.setOptionsMap(getPmOptionsMap());
param.setAgent(agent);
param.setStoragePoolId(cluster.getStoragePoolId() != null ? cluster.getStoragePoolId() : Guid.Empty);
param.setFenceProxySources(FenceProxySourceTypeHelper.parseFromString(getHost().getPmProxyPreferences()));
param.setVdsName(getHost().getName().getEntity());
param.setHostName(getHost().getHost().getEntity());
param.setClusterId(cluster.getId());
Frontend.getInstance().runQuery(QueryType.GetFenceAgentStatus, param, new AsyncQuery<QueryReturnValue>(returnValue -> {
String msg;
if (returnValue == null) {
msg = ConstantsManager.getInstance().getConstants().testFailedUnknownErrorMsg();
} else {
FenceOperationResult result = returnValue.getReturnValue();
if (result.getStatus() == FenceOperationResult.Status.SUCCESS) {
msg = ConstantsManager.getInstance().getMessages().testSuccessfulWithPowerStatus(result.getPowerStatus() == PowerStatus.ON ? ConstantsManager.getInstance().getConstants().powerOn() : ConstantsManager.getInstance().getConstants().powerOff());
} else {
msg = ConstantsManager.getInstance().getMessages().testFailedWithErrorMsg(result.getMessage());
}
}
setMessage(msg);
getTestCommand().setIsExecutionAllowed(true);
}, true));
}
use of org.ovirt.engine.core.common.businessentities.Cluster in project ovirt-engine by oVirt.
the class RegisterVmModel method prepareParameters.
private List<ActionParametersBase> prepareParameters() {
ArrayList<ActionParametersBase> parameters = new ArrayList<>();
for (RegisterVmData registerVmData : getEntities().getItems()) {
VM vm = registerVmData.getEntity();
Cluster cluster = registerVmData.getCluster().getSelectedItem();
ImportVmFromConfParameters params = new ImportVmFromConfParameters(cloneExternalVnicProfiles(cluster), registerVmData.getReassignMacs().getEntity());
params.setContainerId(vm.getId());
params.setStorageDomainId(getStorageDomainId());
params.setImagesExistOnTargetStorageDomain(true);
params.setClusterId(cluster != null ? cluster.getId() : null);
params.setAllowPartialImport(registerVmData.getAllowPartialImport().getEntity());
if (isQuotaEnabled()) {
Quota quota = registerVmData.getClusterQuota().getSelectedItem();
params.setQuotaId(quota != null ? quota.getId() : null);
params.setDiskMap(vm.getDiskMap());
updateDiskQuotas(new ArrayList<>(params.getDiskMap().values()));
}
parameters.add(params);
}
return parameters;
}
use of org.ovirt.engine.core.common.businessentities.Cluster in project ovirt-engine by oVirt.
the class BalloonEnabled method balloonEnabled.
public static boolean balloonEnabled(UnitVmModel model) {
Cluster cluster = model.getSelectedCluster();
Integer osType = model.getOSType().getSelectedItem();
Boolean deviceEnabled = Boolean.TRUE.equals(model.getMemoryBalloonDeviceEnabled().getEntity());
if (cluster == null || osType == null) {
if (model.getBehavior() instanceof ExistingBlankTemplateModelBehavior || model.getBehavior() instanceof ExistingInstanceTypeModelBehavior || model.getBehavior() instanceof NewInstanceTypeModelBehavior) {
return deviceEnabled;
}
return false;
}
return deviceEnabled && AsyncDataProvider.getInstance().isBalloonEnabled(osType, model.getCompatibilityVersion());
}
use of org.ovirt.engine.core.common.businessentities.Cluster in project ovirt-engine by oVirt.
the class DataCenterGuideModel method onSelectHost.
public void onSelectHost() {
MoveHost model = (MoveHost) getWindow();
if (model.getProgress() != null) {
return;
}
if (!model.validate()) {
return;
}
model.setSelectedHosts(new ArrayList<MoveHostData>());
for (MoveHostData a : model.getItems()) {
if (a.getIsSelected()) {
model.getSelectedHosts().add(a);
}
}
Cluster cluster = model.getCluster().getSelectedItem();
final List<ActionParametersBase> parameterList = new ArrayList<>();
for (MoveHostData hostData : model.getSelectedHosts()) {
VDS host = hostData.getEntity();
// Try to change host's cluster as neccessary.
if (host.getClusterId() != null && !host.getClusterId().equals(cluster.getId())) {
parameterList.add(new ChangeVDSClusterParameters(cluster.getId(), host.getId()));
}
}
model.startProgress();
Frontend.getInstance().runMultipleAction(ActionType.ChangeVDSCluster, parameterList, new IFrontendMultipleActionAsyncCallback() {
@Override
public void executed(FrontendMultipleActionAsyncResult result) {
final DataCenterGuideModel dataCenterGuideModel = (DataCenterGuideModel) result.getState();
List<MoveHostData> hosts = ((MoveHost) dataCenterGuideModel.getWindow()).getSelectedHosts();
List<ActionReturnValue> retVals = result.getReturnValue();
final List<ActionParametersBase> activateVdsParameterList = new ArrayList<>();
if (retVals != null && hosts.size() == retVals.size()) {
int i = 0;
for (MoveHostData selectedHostData : hosts) {
VDS selectedHost = selectedHostData.getEntity();
if (selectedHost.getStatus() == VDSStatus.PendingApproval && retVals.get(i) != null && retVals.get(i).getSucceeded()) {
Frontend.getInstance().runAction(ActionType.ApproveVds, new ApproveVdsParameters(selectedHost.getId()), null, this);
} else if (selectedHostData.getActivateHost()) {
activateVdsParameterList.add(new VdsActionParameters(selectedHostData.getEntity().getId()));
}
i++;
}
}
if (activateVdsParameterList.isEmpty()) {
dataCenterGuideModel.getWindow().stopProgress();
dataCenterGuideModel.cancel();
dataCenterGuideModel.postAction();
} else {
final String searchString = getVdsSearchString((MoveHost) dataCenterGuideModel.getWindow());
Timer timer = new Timer() {
public void run() {
checkVdsClusterChangeSucceeded(searchString, parameterList, activateVdsParameterList);
}
};
timer.schedule(2000);
}
}
}, this);
}
Aggregations