use of org.ovirt.engine.ui.uicommonweb.models.hosts.MultipleHostsModel in project ovirt-engine by oVirt.
the class ClusterGeneralModel method fetchAndImportNewGlusterHosts.
public void fetchAndImportNewGlusterHosts() {
if (getWindow() != null) {
return;
}
final MultipleHostsModel hostsModel = new MultipleHostsModel();
setWindow(hostsModel);
hostsModel.setTitle(ConstantsManager.getInstance().getConstants().addMultipleHostsTitle());
hostsModel.setHelpTag(HelpTag.add_hosts);
// $NON-NLS-1$
hostsModel.setHashName("add_hosts");
// $NON-NLS-1$
UICommand command = UICommand.createOkUiCommand("OnSaveHosts", this);
hostsModel.getCommands().add(command);
hostsModel.getHosts().setItems(new ArrayList<EntityModel<HostDetailModel>>());
// $NON-NLS-1$
hostsModel.getCommands().add(UICommand.createCancelUiCommand("Cancel", this));
hostsModel.startProgress();
AsyncDataProvider.getInstance().getGlusterHostsNewlyAdded(new AsyncQuery<>(hostMap -> {
if (hostMap == null || hostMap.isEmpty()) {
hostsModel.setMessage(ConstantsManager.getInstance().getConstants().emptyNewGlusterHosts());
} else {
ArrayList<EntityModel<HostDetailModel>> list = new ArrayList<>();
for (Map.Entry<String, String> host : hostMap.entrySet()) {
HostDetailModel hostModel = new HostDetailModel(host.getKey(), host.getValue());
hostModel.setName(host.getKey());
// $NON-NLS-1$
hostModel.setPassword("");
EntityModel<HostDetailModel> entityModel = new EntityModel<>(hostModel);
list.add(entityModel);
}
hostsModel.getHosts().setItems(list);
}
hostsModel.stopProgress();
}), getEntity().getId(), true);
}
use of org.ovirt.engine.ui.uicommonweb.models.hosts.MultipleHostsModel in project ovirt-engine by oVirt.
the class ClusterListModel method postOnSaveInternalWithImport.
public void postOnSaveInternalWithImport(ActionReturnValue returnValue) {
MultipleHostsModel hostsModel = (MultipleHostsModel) getWindow();
if (returnValue != null && returnValue.getSucceeded()) {
hostsModel.getClusterModel().setClusterId((Guid) returnValue.getActionReturnValue());
addHosts(hostsModel);
}
}
use of org.ovirt.engine.ui.uicommonweb.models.hosts.MultipleHostsModel in project ovirt-engine by oVirt.
the class ClusterGeneralModel method onSaveHosts.
public void onSaveHosts() {
final MultipleHostsModel hostsModel = (MultipleHostsModel) getWindow();
if (hostsModel == null) {
return;
}
if (!hostsModel.validate()) {
return;
}
hostsModel.startProgress();
ArrayList<ActionParametersBase> parametersList = new ArrayList<>();
for (Object object : hostsModel.getHosts().getItems()) {
HostDetailModel hostDetailModel = (HostDetailModel) ((EntityModel) object).getEntity();
VDS host = new VDS();
host.setVdsName(hostDetailModel.getName());
host.setHostName(hostDetailModel.getAddress());
host.setSshKeyFingerprint(hostDetailModel.getFingerprint());
host.setPort(54321);
// TODO: get from UI, till than using defaults.
host.setSshPort(22);
// $NON-NLS-1$
host.setSshUsername("root");
host.setClusterId(getEntity().getId());
host.setPmEnabled(false);
AddVdsActionParameters parameters = new AddVdsActionParameters();
parameters.setVdsId(host.getId());
parameters.setvds(host);
parameters.setPassword(hostDetailModel.getPassword());
parameters.setOverrideFirewall(hostsModel.isConfigureFirewall());
parametersList.add(parameters);
}
// Todo: calling the runMultipleAction() with isRunOnlyIfAllValidationPass=false
// becuase this flag is now supported.
// should check what is the required behaviour and return to true if required.
Frontend.getInstance().runMultipleAction(ActionType.AddVds, parametersList, false, result -> {
hostsModel.stopProgress();
boolean isAllValidatePassed = true;
for (ActionReturnValue returnValueBase : result.getReturnValue()) {
isAllValidatePassed = isAllValidatePassed && returnValueBase.isValid();
if (!isAllValidatePassed) {
break;
}
}
if (isAllValidatePassed) {
updateAlerts();
cancel();
}
}, null);
}
use of org.ovirt.engine.ui.uicommonweb.models.hosts.MultipleHostsModel in project ovirt-engine by oVirt.
the class ClusterListModel method importClusterHosts.
private void importClusterHosts(ClusterModel clusterModel, ArrayList<EntityModel<HostDetailModel>> hostList) {
setWindow(null);
getAddMultipleHostsCommand().execute();
final MultipleHostsModel hostsModel = new MultipleHostsModel();
setWindow(hostsModel);
hostsModel.setTitle(ConstantsManager.getInstance().getConstants().addMultipleHostsTitle());
hostsModel.setHelpTag(HelpTag.add_hosts);
// $NON-NLS-1$
hostsModel.setHashName("add_hosts");
hostsModel.setClusterModel(clusterModel);
hostsModel.getHosts().setItems(hostList);
// $NON-NLS-1$
UICommand command = UICommand.createOkUiCommand("OnSaveHosts", this);
hostsModel.getCommands().add(command);
// $NON-NLS-1$
hostsModel.getCommands().add(UICommand.createCancelUiCommand("Cancel", this));
}
Aggregations