コード例 #1
0
  /**
   * Deactivates the vCenter, its vCenter data centers, clusters and hosts.
   *
   * @param id the URN of a ViPR vCenter to be deactivated
   * @prereq none
   * @brief Delete vCenter
   * @return OK if deactivation completed successfully
   * @throws DatabaseException when a DB error occurs
   */
  @POST
  @Path("/{id}/deactivate")
  @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
  @CheckPermission(roles = {Role.SYSTEM_ADMIN, Role.TENANT_ADMIN})
  public TaskResourceRep deactivateVcenter(
      @PathParam("id") URI id,
      @DefaultValue("false") @QueryParam("detach-storage") boolean detachStorage)
      throws DatabaseException {
    if (ComputeSystemHelper.isVcenterInUse(_dbClient, id) && !detachStorage) {
      throw APIException.badRequests.resourceHasActiveReferences(Vcenter.class.getSimpleName(), id);
    } else {
      Vcenter vcenter = queryObject(Vcenter.class, id, true);

      // check the user permissions for this tenant org
      verifyAuthorizedSystemOrTenantOrgUser(
          _permissionsHelper.convertToACLEntries(vcenter.getAcls()));

      checkIfOtherTenantsUsingTheVcenter(vcenter);

      String taskId = UUID.randomUUID().toString();
      Operation op =
          _dbClient.createTaskOpStatus(
              Vcenter.class, vcenter.getId(), taskId, ResourceOperationTypeEnum.DELETE_VCENTER);

      ComputeSystemController controller = getController(ComputeSystemController.class, null);
      controller.detachVcenterStorage(vcenter.getId(), true, taskId);

      auditOp(OperationTypeEnum.DELETE_VCENTER, true, null, vcenter.auditParameters());

      TaskResourceRep taskResourceRep = toTask(vcenter, taskId, op);
      updateTaskTenant(taskResourceRep);

      return taskResourceRep;
    }
  }
コード例 #2
0
  /**
   * Updates one or more of the vCenter attributes. Discovery is initiated after the vCenter is
   * updated.
   *
   * @param id the URN of a ViPR vCenter
   * @param updateParam the parameter that has the attributes to be updated.
   * @prereq none
   * @brief Update vCenter
   * @return the vCenter discovery async task representation.
   */
  @PUT
  @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
  @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
  @CheckPermission(roles = {Role.SYSTEM_ADMIN, Role.TENANT_ADMIN})
  @Path("/{id}")
  public TaskResourceRep updateVcenter(
      @PathParam("id") URI id,
      VcenterUpdateParam updateParam,
      @QueryParam("validate_connection") @DefaultValue("false") final Boolean validateConnection,
      @QueryParam("discover_vcenter") @DefaultValue("true") final Boolean discoverVcenter) {

    // update the host
    Vcenter vcenter = queryObject(Vcenter.class, id, true);
    validateVcenter(updateParam, vcenter, validateConnection);

    // check the user permissions for this tenant org
    verifyAuthorizedSystemOrTenantOrgUser(
        _permissionsHelper.convertToACLEntries(vcenter.getAcls()));

    populateVcenterData(vcenter, updateParam);
    _dbClient.persistObject(vcenter);
    auditOp(OperationTypeEnum.UPDATE_VCENTER, true, null, vcenter.auditParameters());

    if (discoverVcenter) {
      return doDiscoverVcenter(vcenter);
    } else {
      return createManualReadyTask(vcenter);
    }
  }
コード例 #3
0
  /**
   * Creates a new vCenter. Discovery is initiated after the vCenter is created.
   *
   * @param createParam the parameter that has the attributes of the vCenter to be created.
   * @param validateConnection specifies if the connection to the vCenter to be validated before
   *     creating the vCenter or not. Default value is "false", so connection to the vCenter will
   *     not be validated if it is not specified.
   * @return the vCenter discovery async task.
   */
  @POST
  @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
  @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
  @CheckPermission(roles = {Role.SYSTEM_ADMIN, Role.TENANT_ADMIN})
  public TaskResourceRep createVcenter(
      VcenterCreateParam createParam,
      @QueryParam("validate_connection") @DefaultValue("false") final Boolean validateConnection) {
    validateVcenter(createParam, null, validateConnection);

    // create and persist the vcenter
    Vcenter vcenter = createNewVcenter(null, createParam);
    vcenter.setRegistrationStatus(DiscoveredDataObject.RegistrationStatus.REGISTERED.toString());
    _dbClient.createObject(vcenter);
    auditOp(OperationTypeEnum.CREATE_VCENTER, true, null, vcenter.auditParameters());

    return doDiscoverVcenter(queryObject(Vcenter.class, vcenter.getId(), true));
  }