use of org.ovirt.engine.ui.uicommonweb.models.hosts.HostDetailModel 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.HostDetailModel in project ovirt-engine by oVirt.
the class ClusterListModel method addHosts.
private void addHosts(final MultipleHostsModel hostsModel) {
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 then using defaults.
host.setSshPort(22);
// $NON-NLS-1$
host.setSshUsername("root");
host.setClusterId(hostsModel.getClusterModel().getClusterId());
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 = returnValueBase.isValid();
if (!isAllValidatePassed) {
break;
}
}
if (isAllValidatePassed) {
cancel();
}
}, null);
}
use of org.ovirt.engine.ui.uicommonweb.models.hosts.HostDetailModel in project ovirt-engine by oVirt.
the class ClusterListModel method fetchAndImportClusterHosts.
private void fetchAndImportClusterHosts(final ClusterModel clusterModel) {
getWindow().startProgress();
AsyncQuery<QueryReturnValue> aQuery = new AsyncQuery<>(result -> {
getWindow().stopProgress();
QueryReturnValue returnValue = result;
if (returnValue == null) {
onEmptyGlusterHosts(clusterModel);
return;
} else if (!returnValue.getSucceeded()) {
clusterModel.setMessage(Frontend.getInstance().getAppErrorsTranslator().translateErrorTextSingle(returnValue.getExceptionString()));
return;
}
Map<String, String> hostMap = returnValue.getReturnValue();
if (hostMap == null) {
onEmptyGlusterHosts(clusterModel);
return;
}
if (hostMap.containsValue(null) || hostMap.containsValue("")) {
// $NON-NLS-1$
onGlusterHostsWithoutFingerprint(hostMap, clusterModel);
return;
}
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);
}
importClusterHosts(clusterModel, list);
});
aQuery.setHandleFailure(true);
AsyncDataProvider.getInstance().getGlusterHosts(aQuery, clusterModel.getGlusterHostAddress().getEntity(), clusterModel.getGlusterHostPassword().getEntity(), clusterModel.getGlusterHostFingerprint().getEntity());
}
use of org.ovirt.engine.ui.uicommonweb.models.hosts.HostDetailModel 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.HostDetailModel in project ovirt-engine by oVirt.
the class MultipleHostsPopupView method initTableColumns.
private void initTableColumns() {
Column<EntityModel, String> nameColumn = new Column<EntityModel, String>(new TextInputCell()) {
@Override
public String getValue(EntityModel object) {
return ((HostDetailModel) object.getEntity()).getName();
}
};
// $NON-NLS-1$
hostsTable.addColumn(nameColumn, constants.nameHost(), "50px");
nameColumn.setFieldUpdater((index, object, value) -> ((HostDetailModel) object.getEntity()).setName(value));
hostsTable.addColumn(new AbstractEntityModelTextColumn<HostDetailModel>() {
@Override
public String getText(HostDetailModel hostModel) {
return hostModel.getAddress();
}
}, constants.ipHost(), // $NON-NLS-1$
"100px");
Column<EntityModel, String> passwordColumn = new Column<EntityModel, String>(new PasswordTextInputCell()) {
@Override
public String getValue(EntityModel object) {
return ((HostDetailModel) object.getEntity()).getPassword();
}
};
// $NON-NLS-1$
hostsTable.addColumn(passwordColumn, constants.hostPopupPasswordLabel(), "100px");
passwordColumn.setFieldUpdater((index, object, value) -> ((HostDetailModel) object.getEntity()).setPassword(value));
hostsTable.addColumn(new AbstractEntityModelTextColumn<HostDetailModel>() {
@Override
public String getText(HostDetailModel hostModel) {
return hostModel.getFingerprint();
}
}, constants.hostsPopupFingerprint(), // $NON-NLS-1$
"300px");
}
Aggregations