public void SetAsDisplay() {
    network network = (network) getSelectedItem();

    Frontend.RunAction(
        VdcActionType.UpdateDisplayToVdsGroup,
        new DisplayNetworkToVdsGroupParameters(getEntity(), network, true));
  }
  public void OnAddHost() {
    CancelConfirm();

    HostModel model = (HostModel) getWindow();

    if (model.getProgress() != null) {
      return;
    }

    if (!model.Validate()) {
      return;
    }

    // Save changes.
    VDS host = new VDS();
    host.setvds_name((String) model.getName().getEntity());
    host.sethost_name((String) model.getHost().getEntity());
    host.setManagmentIp((String) model.getManagementIp().getEntity());
    host.setport((Integer) model.getPort().getEntity());
    host.setvds_group_id(((VDSGroup) model.getCluster().getSelectedItem()).getId());
    host.setpm_enabled((Boolean) model.getIsPm().getEntity());
    host.setpm_user(
        (Boolean) model.getIsPm().getEntity() ? (String) model.getPmUserName().getEntity() : null);
    host.setpm_password(
        (Boolean) model.getIsPm().getEntity() ? (String) model.getPmPassword().getEntity() : null);
    host.setpm_type(
        (Boolean) model.getIsPm().getEntity()
            ? (String) model.getPmType().getSelectedItem()
            : null);
    host.setPmOptionsMap(
        (Boolean) model.getIsPm().getEntity()
            ? new ValueObjectMap(model.getPmOptionsMap(), false)
            : null);

    AddVdsActionParameters vdsActionParams = new AddVdsActionParameters();
    vdsActionParams.setvds(host);
    vdsActionParams.setVdsId(host.getId());
    vdsActionParams.setRootPassword((String) model.getRootPassword().getEntity());

    model.StartProgress(null);

    Frontend.RunAction(
        VdcActionType.AddVds,
        vdsActionParams,
        new IFrontendActionAsyncCallback() {
          @Override
          public void Executed(FrontendActionAsyncResult result) {

            ClusterGuideModel localModel = (ClusterGuideModel) result.getState();
            localModel.PostOnAddHost(result.getReturnValue());
          }
        },
        this);
  }
  private void ChangePassword() {
    VdcReturnValueBase returnValue =
        Frontend.RunAction(
            VdcActionType.ChangeUserPassword,
            new ChangeUserPasswordParameters(
                (String) getUserName().getEntity(),
                (String) getPassword().getEntity(),
                (String) getNewPassword().getEntity(),
                (String) getDomain().getSelectedItem()));

    if (returnValue != null && returnValue.getSucceeded()) {
      // TODO:
    }
  }
  public void OnSave() {
    ClusterNetworkModel model = (ClusterNetworkModel) getWindow();
    network network = new network(null);

    if (getEntity() == null) {
      Cancel();
      return;
    }

    if (!model.Validate() || getEntity().getstorage_pool_id() == null) {
      return;
    }

    network.setstorage_pool_id(getEntity().getstorage_pool_id());
    network.setname((String) model.getName().getEntity());
    network.setstp((Boolean) model.getIsStpEnabled().getEntity());
    network.setdescription((String) model.getDescription().getEntity());
    network.setvlan_id(null);
    if ((Boolean) model.getHasVLanTag().getEntity()) {
      network.setvlan_id(Integer.parseInt(model.getVLanTag().getEntity().toString()));
    }

    Frontend.RunAction(
        VdcActionType.AddNetwork,
        new AddNetworkStoragePoolParameters(network.getstorage_pool_id().getValue(), network),
        new IFrontendActionAsyncCallback() {
          @Override
          public void Executed(FrontendActionAsyncResult result) {

            Object[] data = (Object[]) result.getState();
            ClusterNetworkListModel networkListModel = (ClusterNetworkListModel) data[0];
            VdcReturnValueBase retVal = result.getReturnValue();
            if (retVal != null && retVal.getSucceeded()) {
              network tempVar = new network(null);
              tempVar.setId((Guid) retVal.getActionReturnValue());
              tempVar.setname(((network) data[1]).getname());
              Frontend.RunAction(
                  VdcActionType.AttachNetworkToVdsGroup,
                  new AttachNetworkToVdsGroupParameter(networkListModel.getEntity(), tempVar));
            }
            networkListModel.Cancel();
          }
        },
        new Object[] {this, network});
  }
  @Override
  public void Login() {
    // Completely override the base class functionality.

    if (!Validate()) {
      return;
    }

    // Clear config cache on login (to make sure we don't use old config in a new session)
    DataProvider.ClearConfigCache();

    Frontend.RunAction(
        VdcActionType.LoginUser,
        new LoginUserParameters(
            (String) getUserName().getEntity(),
            (String) getPassword().getEntity(),
            (String) getDomain().getSelectedItem(),
            "",
            "",
            ""),
        new IFrontendActionAsyncCallback() {
          @Override
          public void Executed(FrontendActionAsyncResult result) {

            UserPortalLoginModel model = (UserPortalLoginModel) result.getState();
            VdcReturnValueBase returnValue = result.getReturnValue();
            boolean success = returnValue != null && returnValue.getSucceeded();
            if (success) {
              model.setLoggedUser((VdcUser) returnValue.getActionReturnValue());
              model.getLoggedInEvent().raise(this, EventArgs.Empty);
            } else {
              model.getPassword().setEntity("");
              if (returnValue != null) {
                model.setMessage(Linq.FirstOrDefault(returnValue.getCanDoActionMessages()));
              }
              model.getLoginFailedEvent().raise(this, EventArgs.Empty);
            }
          }
        },
        this);
  }