@Override public String call(ZoneInventory arg) { return arg.getUuid(); } });
public static List<ZoneInventory> valueOf(Collection<ZoneVO> vos) { List<ZoneInventory> invs = new ArrayList<ZoneInventory>(vos.size()); for (ZoneVO vo : vos) { invs.add(ZoneInventory.valueOf(vo)); } return invs; }
public static APIUpdateZoneEvent __example__() { APIUpdateZoneEvent event = new APIUpdateZoneEvent(); ZoneInventory zone = new ZoneInventory(); zone.setName("TestZone"); zone.setUuid(uuid()); zone.setDescription("Test"); zone.setState(ZoneState.Enabled.toString()); zone.setType("zstack"); zone.setCreateDate(new Timestamp(org.zstack.header.message.DocUtils.date)); zone.setLastOpDate(new Timestamp(org.zstack.header.message.DocUtils.date)); event.setInventory(zone); return event; }
void preDelete(ZoneInventory zinv) throws ZoneException { for (ZoneDeleteExtensionPoint extp : delExts) { try { extp.preDeleteZone(zinv); } catch (ZoneException ze) { logger.debug(String.format("extension[%s] refused to delete zone[name: %s, uuid:%s] because %s", extp.getClass().getName(), zinv.getName(), zinv.getUuid(), ze.getMessage())); throw ze; } catch (Exception e) { logger.warn("Exception happened while calling " + extp.getClass().getCanonicalName() + ".preDelete, " + "zone name: " + zinv.getName() + " uuid: " + zinv.getUuid(), e); } } }
void preChange(ZoneVO vo, ZoneStateEvent event) throws ZoneException { ZoneInventory zinv = ZoneInventory.valueOf(vo); ZoneState next = AbstractZone.getNextState(vo.getState(), event); for (ZoneChangeStateExtensionPoint extp : changeExts) { try { extp.preChangeZoneState(zinv, event, next); } catch (ZoneException ze) { logger.debug(String.format("Extension: %s refused zone change state operation[ZoneStateEvent:%s] because %s", extp.getClass() .getCanonicalName(), event, ze.getMessage())); throw ze; } catch (Exception e) { logger.warn("Exception happened while calling " + extp.getClass().getCanonicalName() + ".preChangeZoneState(), " + "zone name: " + zinv.getName() + " uuid: " + zinv.getUuid(), e); } } }
ZoneInventory z = new ZoneInventory(); z.setName("zone"); z.setUuid(zoneUuid);
@Override public void after(APIEvent evt) { ntfy("changed zone state to %s",((APIChangeZoneStateEvent)evt).getInventory().getState()) .resource(uuid,ZoneVO.class.getSimpleName()) .messageAndEvent(that, evt).done(); } };
@Override public void run(List<MessageReply> replies) { if (!action.isActionCode(CascadeConstant.DELETION_FORCE_DELETE_CODE)) { for (MessageReply r : replies) { if (!r.isSuccess()) { completion.fail(r.getError()); return; } } } List<String> uuids = new ArrayList<String>(); for (MessageReply r : replies) { ZoneInventory inv = zones.get(replies.indexOf(r)); uuids.add(inv.getUuid()); logger.debug(String.format("delete zone[uuid:%s, name:%s]", inv.getUuid(), inv.getName())); } dbf.removeByPrimaryKeys(uuids, ZoneVO.class); completion.success(); } });
public static APICreateZoneEvent __example__() { APICreateZoneEvent event = new APICreateZoneEvent(); ZoneInventory zone = new ZoneInventory(); zone.setName("TestZone"); zone.setUuid(uuid()); zone.setDescription("Test"); zone.setState(ZoneState.Enabled.toString()); zone.setType("zstack"); zone.setCreateDate(new Timestamp(org.zstack.header.message.DocUtils.date)); zone.setLastOpDate(new Timestamp(org.zstack.header.message.DocUtils.date)); event.setInventory(zone); return event; }
@Override public String call(ZoneInventory arg) { return arg.getUuid(); } });
List<ClusterVO> vos = findClusterUnderZone(inventory.getUuid()); if (!vos.isEmpty()) { ClusterStateEvent clusterEvent = ClusterStateEvent.valueOf(event.toString()); logger.debug("Changing state of clusters in zone: " + inventory.getName() + " uuid: " + inventory.getUuid() + " by event: " + clusterEvent); List<MessageReply> replies = bus.call(msgs); for (MessageReply r : replies) {
void afterChange(ZoneVO vo, final ZoneStateEvent event, final ZoneState previousState) { final ZoneInventory zinv = ZoneInventory.valueOf(vo); CollectionUtils.safeForEach(changeExts, new ForEachFunction<ZoneChangeStateExtensionPoint>() { @Override public void run(ZoneChangeStateExtensionPoint arg) { arg.afterChangeZoneState(zinv, event, previousState); } }); }
public static APIChangeZoneStateEvent __example__() { APIChangeZoneStateEvent event = new APIChangeZoneStateEvent(); ZoneInventory zone = new ZoneInventory(); zone.setName("TestZone"); zone.setUuid(uuid()); zone.setDescription("Test"); zone.setState(ZoneState.Enabled.toString()); zone.setType("zstack"); zone.setCreateDate(new Timestamp(org.zstack.header.message.DocUtils.date)); zone.setLastOpDate(new Timestamp(org.zstack.header.message.DocUtils.date)); event.setInventory(zone); return event; }
@Override public String call(ZoneInventory arg) { return arg.getUuid(); } });
void beforeChange(ZoneVO vo, final ZoneStateEvent event) { final ZoneInventory zinv = ZoneInventory.valueOf(vo); final ZoneState next = AbstractZone.getNextState(vo.getState(), event); CollectionUtils.safeForEach(changeExts, new ForEachFunction<ZoneChangeStateExtensionPoint>() { @Override public void run(ZoneChangeStateExtensionPoint arg) { arg.beforeChangeZoneState(zinv, event, next); } }); }
public static APIGetZoneReply __example__() { APIGetZoneReply reply = new APIGetZoneReply(); ZoneInventory zone = new ZoneInventory(); zone.setName("TestZone"); zone.setUuid(uuid()); zone.setDescription("Test"); zone.setState(ZoneState.Enabled.toString()); zone.setType("zstack"); zone.setCreateDate(new Timestamp(org.zstack.header.message.DocUtils.date)); zone.setLastOpDate(new Timestamp(org.zstack.header.message.DocUtils.date)); reply.setInventories(asList(zone)); reply.setSuccess(true); return reply; }
@Override public String call(ZoneInventory arg) { return arg.getUuid(); } });
private void handle(APIGetZoneMsg msg) { APIGetZoneReply reply = new APIGetZoneReply(); if (msg.getUuid() != null) { ZoneVO vo = dbf.findByUuid(msg.getUuid(), ZoneVO.class); reply.setInventories(asList(ZoneInventory.valueOf(vo))); } else { reply.setInventories(ZoneInventory.valueOf(dbf.listAll(ZoneVO.class))); } bus.reply(msg, reply); }
public static APIQueryZoneReply __example__() { APIQueryZoneReply reply = new APIQueryZoneReply(); ZoneInventory zone = new ZoneInventory(); zone.setName("TestZone"); zone.setUuid(uuid()); zone.setDescription("Test"); zone.setState(ZoneState.Enabled.toString()); zone.setType("zstack"); zone.setCreateDate(new Timestamp(org.zstack.header.message.DocUtils.date)); zone.setLastOpDate(new Timestamp(org.zstack.header.message.DocUtils.date)); reply.setSuccess(true); reply.setInventories(asList(zone)); return reply; } }
@Override public Result audit(APIMessage msg, APIEvent rsp) { return new Result(rsp.isSuccess() ? ((APICreateZoneEvent)rsp).getInventory().getUuid() : "", ZoneVO.class); } }