Пример #1
0
  private void handle(APICreateZoneMsg msg) {
    String zoneType = msg.getType();
    if (zoneType == null) {
      zoneType = BaseZoneFactory.type.toString();
    }
    ZoneFactory factory = this.getZoneFactory(ZoneType.valueOf(zoneType));
    APICreateZoneEvent evt = new APICreateZoneEvent(msg.getId());
    ZoneVO vo = new ZoneVO();
    if (msg.getResourceUuid() != null) {
      vo.setUuid(msg.getResourceUuid());
    } else {
      vo.setUuid(Platform.getUuid());
    }
    vo.setName(msg.getName());
    vo.setDescription(msg.getDescription());
    vo = factory.createZone(vo, msg);

    tagMgr.createTagsFromAPICreateMessage(msg, vo.getUuid(), ZoneVO.class.getSimpleName());

    evt.setInventory(ZoneInventory.valueOf(vo));
    logger.debug("Created zone: " + vo.getName() + " uuid:" + vo.getUuid());
    if (logf.isEnabled()) {
      logf.info(vo.getUuid(), String.format("Create zone successfully"));
    }
    bus.publish(evt);
  }
Пример #2
0
  private void passThrough(ZoneMessage msg) {
    ZoneVO vo = dbf.findByUuid(msg.getZoneUuid(), ZoneVO.class);
    if (vo == null && allowedMessageAfterSoftDeletion.contains(msg.getClass())) {
      ZoneEO eo = dbf.findByUuid(msg.getZoneUuid(), ZoneEO.class);
      vo = ObjectUtils.newAndCopy(eo, ZoneVO.class);
    }

    if (vo == null) {
      ErrorCode err =
          errf.instantiateErrorCode(
              SysErrors.RESOURCE_NOT_FOUND,
              String.format(
                  "unable to find zone[uuid:%s], it may have been deleted", msg.getZoneUuid()));
      bus.replyErrorByMessageType((Message) msg, err);
      return;
    }

    ZoneFactory factory = this.getZoneFactory(ZoneType.valueOf(vo.getType()));
    Zone zone = factory.getZone(vo);
    zone.handleMessage((Message) msg);
  }
Пример #3
0
 private void populateExtensions() {
   for (ZoneFactory f : pluginRgty.getExtensionList(ZoneFactory.class)) {
     ZoneFactory old = zoneFactories.get(f.getType().toString());
     if (old != null) {
       throw new CloudRuntimeException(
           String.format(
               "duplicate ZoneFactory[%s, %s] for type[%s]",
               f.getClass().getName(), old.getClass().getName(), f.getType()));
     }
     zoneFactories.put(f.getType().toString(), f);
   }
 }