public static String toTypedJsonString(Object obj) { return toJsonString(map(e(obj.getClass().getName(), obj))); }
private String jsonMessage() { return gson.toJson(map(e(rbacEntity.getApiMessage().getClass().getName(), rbacEntity.getApiMessage()))); }
private void saveLdapCleanBindingFilterTag(List<String> systemTags, String uuid) { if(systemTags == null || systemTags.isEmpty()) { return; } PatternedSystemTag tag = LdapSystemTags.LDAP_CLEAN_BINDING_FILTER; String token = LdapSystemTags.LDAP_CLEAN_BINDING_FILTER_TOKEN; String tagValue = SystemTagUtils.findTagValue(systemTags, tag, token); if(StringUtils.isEmpty(tagValue)){ return; } SystemTagCreator creator = tag.newSystemTagCreator(uuid); creator.recreate = true; creator.setTagByTokens(map(CollectionDSL.e(token, tagValue))); creator.create(); }
private void saveLdapServerTypeTag(List<String> systemTags, String uuid) { if(systemTags == null || systemTags.isEmpty()) { return; } PatternedSystemTag tag = LdapSystemTags.LDAP_SERVER_TYPE; String token = LdapSystemTags.LDAP_SERVER_TYPE_TOKEN; String tagValue = SystemTagUtils.findTagValue(systemTags, tag, token); if(StringUtils.isEmpty(tagValue)){ return; } SystemTagCreator creator = tag.newSystemTagCreator(uuid); creator.recreate = true; creator.setTagByTokens(map(CollectionDSL.e(token, tagValue))); creator.create(); }
private void saveLdapUseAsLoginNameTag(List<String> systemTags, String uuid) { if(systemTags == null || systemTags.isEmpty()) { return; } PatternedSystemTag tag = LdapSystemTags.LDAP_USE_AS_LOGIN_NAME; String token = LdapSystemTags.LDAP_USE_AS_LOGIN_NAME_TOKEN; String tagValue = SystemTagUtils.findTagValue(systemTags, tag, token); if(StringUtils.isEmpty(tagValue)){ return; } SystemTagCreator creator = tag.newSystemTagCreator(uuid); creator.recreate = true; creator.setTagByTokens(map(CollectionDSL.e(token, tagValue))); creator.create(); }
public void deleteStaticIpByVmUuidAndL3Uuid(String vmUuid, String l3Uuid) { VmSystemTags.STATIC_IP.delete(vmUuid, TagUtils.tagPatternToSqlPattern(VmSystemTags.STATIC_IP.instantiateTag( map(e(VmSystemTags.STATIC_IP_L3_UUID_TOKEN, l3Uuid)) ))); }
private String makeAndSaveVmSystemSerialNumber(String vmUuid) { String serialNumber; String tag = VmSystemTags.VM_SYSTEM_SERIAL_NUMBER.getTag(vmUuid); if (tag != null) { serialNumber = VmSystemTags.VM_SYSTEM_SERIAL_NUMBER.getTokenByTag(tag, VmSystemTags.VM_SYSTEM_SERIAL_NUMBER_TOKEN); } else { SystemTagCreator creator = VmSystemTags.VM_SYSTEM_SERIAL_NUMBER.newSystemTagCreator(vmUuid); creator.ignoreIfExisting = true; creator.inherent = true; creator.setTagByTokens(map(e(VmSystemTags.VM_SYSTEM_SERIAL_NUMBER_TOKEN, UUID.randomUUID().toString()))); SystemTagInventory inv = creator.create(); serialNumber = VmSystemTags.VM_SYSTEM_SERIAL_NUMBER.getTokenByTag(inv.getTag(), VmSystemTags.VM_SYSTEM_SERIAL_NUMBER_TOKEN); } return serialNumber; }
private void handle(final APISetL3NetworkMtuMsg msg) { final APISetL3NetworkMtuEvent evt = new APISetL3NetworkMtuEvent(msg.getId()); NetworkServiceSystemTag.L3_MTU.delete(msg.getL3NetworkUuid()); SystemTagCreator creator = NetworkServiceSystemTag.L3_MTU.newSystemTagCreator(msg.getL3NetworkUuid()); creator.ignoreIfExisting = true; creator.inherent = false; creator.setTagByTokens( map( e(NetworkServiceSystemTag.MTU_TOKEN, msg.getMtu()), e(NetworkServiceSystemTag.L3_UUID_TOKEN, msg.getL3NetworkUuid()) ) ); creator.create(); bus.publish(evt); }
private void handle(APISetVmHostnameMsg msg) { if (!VmSystemTags.HOSTNAME.hasTag(self.getUuid())) { SystemTagCreator creator = VmSystemTags.HOSTNAME.newSystemTagCreator(self.getUuid()); creator.setTagByTokens(map( e(VmSystemTags.HOSTNAME_TOKEN, msg.getHostname()) )); creator.create(); } else { VmSystemTags.HOSTNAME.update(self.getUuid(), VmSystemTags.HOSTNAME.instantiateTag( map(e(VmSystemTags.HOSTNAME_TOKEN, msg.getHostname())) )); } APISetVmHostnameEvent evt = new APISetVmHostnameEvent(msg.getId()); bus.publish(evt); }
private void handle(APISetVmBootModeMsg msg) { SystemTagCreator creator = VmSystemTags.BOOT_MODE.newSystemTagCreator(self.getUuid()); creator.setTagByTokens(map( e(VmSystemTags.BOOT_MODE_TOKEN, msg.getBootMode()) )); creator.recreate = true; creator.create(); APISetVmBootModeEvent evt = new APISetVmBootModeEvent(msg.getId()); bus.publish(evt); }
private String setVolumeWwn(String volumeUUid) { String wwn; String tag = KVMSystemTags.VOLUME_WWN.getTag(volumeUUid); if (tag != null) { wwn = KVMSystemTags.VOLUME_WWN.getTokenByTag(tag, KVMSystemTags.VOLUME_WWN_TOKEN); } else { SystemTagCreator creator = KVMSystemTags.VOLUME_WWN.newSystemTagCreator(volumeUUid); creator.ignoreIfExisting = true; creator.inherent = true; creator.setTagByTokens(map(e(KVMSystemTags.VOLUME_WWN_TOKEN, new WwnUtils().getRandomWwn()))); SystemTagInventory inv = creator.create(); wwn = KVMSystemTags.VOLUME_WWN.getTokenByTag(inv.getTag(), KVMSystemTags.VOLUME_WWN_TOKEN); } DebugUtils.Assert(new WwnUtils().isValidWwn(wwn), String.format("Not a valid wwn[%s] for volume[uuid:%s]", wwn, volumeUUid)); return wwn; }
private void handle(APISetVmSshKeyMsg msg) { APISetVmSshKeyEvent evt = new APISetVmSshKeyEvent(msg.getId()); SystemTagCreator creator = VmSystemTags.SSHKEY.newSystemTagCreator(self.getUuid()); creator.setTagByTokens(map(e(VmSystemTags.SSHKEY_TOKEN, msg.getSshKey()))); creator.recreate = true; creator.create(); evt.setInventory(getSelfInventory()); bus.publish(evt); }
private void handle(APISetVmConsolePasswordMsg msg) { APISetVmConsolePasswordEvent evt = new APISetVmConsolePasswordEvent(msg.getId()); SystemTagCreator creator = VmSystemTags.CONSOLE_PASSWORD.newSystemTagCreator(self.getUuid()); creator.setTagByTokens(map(e(VmSystemTags.CONSOLE_PASSWORD_TOKEN, msg.getConsolePassword()))); creator.recreate = true; creator.create(); evt.setInventory(getSelfInventory()); bus.publish(evt); }
private void handle(final APISetL3NetworkRouterInterfaceIpMsg msg) { APISetL3NetworkRouterInterfaceIpEvent event = new APISetL3NetworkRouterInterfaceIpEvent(msg.getId()); L3NetworkSystemTags.ROUTER_INTERFACE_IP.delete(msg.getRouterInterfaceIp()); SystemTagCreator creator = L3NetworkSystemTags.ROUTER_INTERFACE_IP.newSystemTagCreator(msg.getL3NetworkUuid()); creator.ignoreIfExisting = false; creator.inherent = false; creator.setTagByTokens( map( e(L3NetworkSystemTags.ROUTER_INTERFACE_IP_TOKEN, msg.getRouterInterfaceIp()) ) ); creator.create(); bus.publish(event); }
@Override public PrimaryStorageInventory createPrimaryStorage(PrimaryStorageVO vo, APIAddPrimaryStorageMsg msg) { String mountPathBase = NfsPrimaryStorageGlobalConfig.MOUNT_BASE.value(String.class); if (mountPathBase == null) { mountPathBase = NfsPrimaryStorageConstant.DEFAULT_NFS_MOUNT_PATH_ON_HOST; } String mountPath = PathUtil.join(mountPathBase, "prim-" + vo.getUuid()); vo.setMountPath(mountPath); vo = dbf.persistAndRefresh(vo); SystemTagCreator creator = PrimaryStorageSystemTags.CAPABILITY_HYPERVISOR_SNAPSHOT.newSystemTagCreator(vo.getUuid()); creator.setTagByTokens(map( e(PrimaryStorageSystemTags.CAPABILITY_HYPERVISOR_SNAPSHOT_TOKEN, KVMConstant.KVM_HYPERVISOR_TYPE) )); creator.create(); return PrimaryStorageInventory.valueOf(vo); }
private void createExchanges() throws IOException { Channel chan = channelPool.acquire(); try { chan.exchangeDeclare(BusExchange.NO_ROUTE.toString(), BusExchange.NO_ROUTE.getType()); Map<String, Object> args = map(e("alternate-exchange", (Object) BusExchange.NO_ROUTE.toString())); chan.exchangeDeclare(BusExchange.P2P.toString(), BusExchange.P2P.getType(), true, false, args); chan.exchangeDeclare(BusExchange.BROADCAST.toString(), BusExchange.BROADCAST.getType()); } finally { channelPool.returnChannel(chan); } }