コード例 #1
0
ファイル: ComDemo.java プロジェクト: fhermeni/FIT4Green
 /* (non-Javadoc)
  * @see org.f4g.com.IComOperationSet#powerOn(org.f4g.schema.actions.PowerOnActionType)
  */
 @Override
 public boolean powerOn(PowerOnActionType action) {
   // Here include the code to power on a host
   log.debug("POWERING ON: " + action.getNodeName());
   return false;
 }
コード例 #2
0
ファイル: ComDemo.java プロジェクト: fhermeni/FIT4Green
  /**
   * Execute a list of actions on behalf of the Controller
   *
   * @param actionRequest
   * @return true if successful, false otherwise
   */
  @Override
  public boolean executeActionList(ArrayList actionList) {

    PowerOnActionType powerOnAction;
    PowerOffActionType powerOffAction;
    LiveMigrateVMActionType migrateAction;
    MoveVMActionType moveAction;
    int i = 0;

    String key = null;
    ComOperation operation;
    ComOperationCollector operationSet = null;

    // initialize operationSet
    operationSet = new ComOperationCollector();

    // First
    log.debug(this.comName + ": executing action list...");
    JAXBElement<? extends AbstractBaseActionType> elem;
    Iterator iter = actionList.iterator();
    while (iter.hasNext()) {
      elem = (JAXBElement<? extends AbstractBaseActionType>) iter.next();

      Object action = elem.getValue();
      action = elem.getValue().getClass().cast(action);
      try {
        if (action.getClass().equals(PowerOffActionType.class)) {
          // perform power off action
          powerOffAction = (PowerOffActionType) action;

          // set the status of powering on to the servers
          key = comName + "_" + powerOffAction.getNodeName();
          operation =
              new ComOperation(ComOperation.TYPE_UPDATE, "./status", ServerStatusType.POWERING_OFF);
          operationSet.add(operation);
          if (operationSet != null) {
            monitor.simpleUpdateNode(key, operationSet);
          }

          this.powerOff(powerOffAction);
        } else if (action.getClass().equals(PowerOnActionType.class)) {
          // perform power on action

          powerOnAction = (PowerOnActionType) action;

          // set the status of powering on to the servers
          key = comName + "_" + powerOnAction.getNodeName();
          operation =
              new ComOperation(ComOperation.TYPE_UPDATE, "./status", ServerStatusType.POWERING_ON);
          operationSet.add(operation);
          if (operationSet != null) {
            monitor.simpleUpdateNode(key, operationSet);
          }
          // call the method to power on
          this.powerOn(powerOnAction);
        } else if (action.getClass().equals(LiveMigrateVMActionType.class)) {
          // perform migrate vm action
          migrateAction = (LiveMigrateVMActionType) action;
          this.liveMigrate(migrateAction);
        } else if (action.getClass().equals(MoveVMActionType.class)) {
          // perform move vm action
          moveAction = (MoveVMActionType) action;
          this.moveVm(moveAction);
        }
      } catch (SecurityException e) {
        log.error("Exception", e);
      } catch (IllegalArgumentException e) {
        log.error("Exception", e);
      }
    }

    return true;
  }