示例#1
0
  checkCompletedRequests: function(requests) {
    var reqId;
    var req;
    for (var idxReq = 0; idxReq < activeRequests.length; idxReq++) {
      reqId = activeRequests[idxReq];
      req = findRequestStatus(requests, reqId);

      let resourceLinks = req && req.resourceLinks ? req.resourceLinks : null;

      if (req && utils.isRequestFinished(req)) {
        // remove from active
        activeRequests.splice(idxReq, 1);
        if (req.requestProgressByComponent.hasOwnProperty('Compute Provision')) {
          // Host Created
          return this.hostOperationSuccess();
        } else if (req.requestProgressByComponent.hasOwnProperty('Host Removal')) {
          // Host Removed
          return this.hostOperationSuccess();
        } else if (req.requestProgressByComponent.hasOwnProperty('Configure Host')) {
          // Host auto-configured
          return this.hostOperationSuccess();
        } else if (req.requestProgressByComponent.hasOwnProperty('Container Allocation')) {
          // Container created
          this.containerOperationSuccess(constants.CONTAINERS.OPERATION.CREATE);

        } else if (req.requestProgressByComponent.hasOwnProperty('Container Removal')) {
          // Container Removed
          this.containerOperationSuccess(constants.CONTAINERS.OPERATION.REMOVE, resourceLinks);

        } else if (req.requestProgressByComponent.hasOwnProperty('Container Network Removal')) {
          // Network Removed
          this.networkOperationSuccess(constants.RESOURCES.NETWORKS.OPERATION.REMOVE);

        } else if (req.requestProgressByComponent.hasOwnProperty('Container Volume Removal')) {
          // Volume Removed
          this.volumeOperationSuccess(constants.RESOURCES.VOLUMES.OPERATION.REMOVE);

        } else if (req.requestProgressByComponent.hasOwnProperty('Container Operation')) {

          if (req.name === 'Start') {
            // Container Started
            this.containerOperationSuccess(constants.CONTAINERS.OPERATION.START, resourceLinks);

          } else if (req.name === 'Stop') {
            // Container Stopped
            this.containerOperationSuccess(constants.CONTAINERS.OPERATION.STOP, resourceLinks);
          } else {
            // Default container operation
            this.containerOperationSuccess(constants.CONTAINERS.OPERATION.DEFAULT, resourceLinks);
          }
        } else if (req.requestProgressByComponent.hasOwnProperty('Resource Clustering')) {
          // Container clustering
          this.containerOperationSuccess(constants.CONTAINERS.OPERATION.CLUSTERING, resourceLinks);

        } else if (req.requestProgressByComponent.hasOwnProperty('Container Network Allocation')) {
          // Network created
          this.containerOperationSuccess(constants.CONTAINERS.OPERATION.NETWORKCREATE,
                                          resourceLinks);
        } else if (req.requestProgressByComponent.hasOwnProperty('Container Volume Allocation')) {
          // Volume created
          this.containerOperationSuccess(constants.CONTAINERS.OPERATION.CREATE_VOLUME,
                                          resourceLinks);
        }
      } else if (req && utils.isRequestFailed(req)) {

        activeRequests.splice(idxReq, 1);

        if (req.requestProgressByComponent.hasOwnProperty('Container Removal')) {
          // Container Removed
          this.containerOperationFail(constants.CONTAINERS.OPERATION.REMOVE, resourceLinks);

        } else if (req.requestProgressByComponent.hasOwnProperty('Container Network Removal')) {
          // Network Removal
          this.networkOperationFail(constants.RESOURCES.NETWORKS.OPERATION.REMOVE);
        } else if (req.requestProgressByComponent.hasOwnProperty('Container Volume Removal')) {
          // Volume Removal
          this.volumeOperationFail(constants.RESOURCES.VOLUMES.OPERATION.REMOVE);

        } else if (req.requestProgressByComponent.hasOwnProperty('Container Operation')) {

          if (req.name === 'Start') {
            // Container Started
            this.containerOperationFail(constants.CONTAINERS.OPERATION.START, resourceLinks);

          } else if (req.name === 'Stop') {
            // Container Stopped
            this.containerOperationFail(constants.CONTAINERS.OPERATION.STOP, resourceLinks);
          }
        }
      }
    }
  },
示例#2
0
 let failedRequestStatuses = requestStatuses.filter((requestStatus) => {
   return utils.isRequestFailed(requestStatus);
 });