Ejemplo n.º 1
0
  @Override
  protected void executeSave() {
    IFrontendActionAsyncCallback addNetworkCallback =
        new IFrontendActionAsyncCallback() {
          @Override
          public void executed(FrontendActionAsyncResult result1) {
            VdcReturnValueBase retVal = result1.getReturnValue();
            boolean succeeded = false;
            if (retVal != null && retVal.getSucceeded()) {
              succeeded = true;
            }
            postSaveAction(succeeded ? (Guid) retVal.getActionReturnValue() : null, succeeded);
          }
        };

    final AddNetworkStoragePoolParameters parameters =
        new AddNetworkStoragePoolParameters(getSelectedDc().getId(), getNetwork());
    parameters.setVnicProfileRequired(false);

    // New network
    if (getExport().getEntity()) {
      Provider externalProvider = getExternalProviders().getSelectedItem();
      ProviderNetwork providerNetwork = new ProviderNetwork();
      providerNetwork.setProviderId(externalProvider.getId());
      getNetwork().setProvidedBy(providerNetwork);

      Frontend.getInstance()
          .runAction(VdcActionType.AddNetworkOnProvider, parameters, addNetworkCallback, null);
    } else {
      Frontend.getInstance()
          .runAction(VdcActionType.AddNetwork, parameters, addNetworkCallback, null);
    }
  }
Ejemplo n.º 2
0
  public void onImport() {
    if (!validate()) {
      return;
    }

    List<VdcActionParametersBase> multipleActionParameters =
        new LinkedList<VdcActionParametersBase>();
    List<IFrontendActionAsyncCallback> callbacks = new LinkedList<IFrontendActionAsyncCallback>();
    dcClusters = new HashMap<Guid, Collection<VDSGroup>>();

    for (final ExternalNetwork externalNetwork :
        (Iterable<ExternalNetwork>) importedNetworks.getItems()) {
      final Network network = externalNetwork.getNetwork();
      final Guid dcId = ((StoragePool) externalNetwork.getDataCenters().getSelectedItem()).getId();
      network.setName(externalNetwork.getDisplayName());
      network.setDataCenterId(dcId);
      AddNetworkStoragePoolParameters params = new AddNetworkStoragePoolParameters(dcId, network);
      params.setVnicProfileRequired(false);
      multipleActionParameters.add(params);
      callbacks.add(
          new IFrontendActionAsyncCallback() {

            @Override
            public void executed(FrontendActionAsyncResult result) {
              VdcReturnValueBase returnValue = result.getReturnValue();
              if (returnValue != null && returnValue.getSucceeded()) {
                network.setId((Guid) returnValue.getActionReturnValue());

                // Perform sequentially: first fetch clusters, then attach network, then create VNIC
                // profile
                fetchDcClusters(dcId, network, externalNetwork.isPublicUse());
              }
            }
          });
    }

    Frontend.getInstance()
        .runMultipleActions(VdcActionType.AddNetwork, multipleActionParameters, callbacks);
    cancel();
  }