protected static String getAccountUuidOfResource(String resourceUuid) { if (acntMgr == null) { acntMgr = Platform.getComponentLoader().getComponent(AccountManager.class); } return acntMgr.getOwnerAccountUuidOfResource(resourceUuid); }
private static String getAccountUuid(String resourceUuid) { AccountManager acntMgr = Platform.getComponentLoader().getComponent(AccountManager.class); String accountUuid = acntMgr.getOwnerAccountUuidOfResource(resourceUuid); DebugUtils.Assert(accountUuid!=null, String.format("cannot find account uuid for resource[uuid:%s]", resourceUuid)); return accountUuid; }
public static String makeImageInstallPath(String imageUuid, String mediaType) { String root; String suffix; if (mediaType.equals(ImageMediaType.RootVolumeTemplate.toString())) { root = ROOT_VOLUME_TEMPLATE_FOLDER; suffix = "template"; } else if (mediaType.equals(ImageMediaType.ISO.toString())) { root = ISO_FOLDER; suffix = "iso"; } else if (mediaType.equals(ImageMediaType.DataVolumeTemplate.toString())) { root = DATA_VOLUME_TEMPLATE_FOLDER; suffix = "volume"; } else if (mediaType.equals(VolumeSnapshotVO.class.getSimpleName())) { root = VOLUME_SNAPSHOT_FOLDER; suffix = "snapshot"; } else { throw new CloudRuntimeException(String.format("unknown image mediaType[%s]", mediaType)); } String accountUuid = getAccountManager().getOwnerAccountUuidOfResource(imageUuid); String filename = String.format("%s.%s", imageUuid, suffix); return PathUtil.join(root, accountFolder(accountUuid), imageUuid, filename); }
public static String makeVolumeInstallPath(String url, VolumeInventory vol) { String accountUuid = getAccountManager().getOwnerAccountUuidOfResource(vol.getUuid()); String fileName = makeFilename(url, "volume"); return PathUtil.join("volumes", accountFolder(accountUuid), vol.getUuid(), fileName); }
public static String makeImageInstallPath(ImageInventory iminv) { String root; if (iminv.getMediaType().equals(ImageMediaType.RootVolumeTemplate.toString())) { root = ROOT_VOLUME_TEMPLATE_FOLDER; } else if (iminv.getMediaType().equals(ImageMediaType.ISO.toString())) { root = ISO_FOLDER; } else if (iminv.getMediaType().equals(ImageMediaType.DataVolumeTemplate.toString())) { root = DATA_VOLUME_TEMPLATE_FOLDER; } else { throw new CloudRuntimeException(String.format("unknown image mediaType[%s]", iminv.getMediaType())); } String accountUuid = getAccountManager().getOwnerAccountUuidOfResource(iminv.getUuid()); String filename = makeFilename(iminv.getUrl(), iminv.getMediaType()); return PathUtil.join(root, accountFolder(accountUuid), iminv.getUuid(), filename); }
private void handle(final APIDetachL3NetworkFromVmMsg msg) { VmNicVO vmNicVO = dbf.findByUuid(msg.getVmNicUuid(), VmNicVO.class); String vmNicAccountUuid = acntMgr.getOwnerAccountUuidOfResource(vmNicVO.getUuid());
@Override public void handle(Map data) { self = dbf.reload(self); evt.setInventory(VmInstanceInventory.valueOf(self)); bus.publish(evt); VmNicInventory vmNicInventory = (VmNicInventory) data.get(vmNicInvKey); VmNicCanonicalEvents.VmNicEventData vmNicEventData = new VmNicCanonicalEvents.VmNicEventData(); vmNicEventData.setCurrentStatus(self.getState().toString()); String vmNicAccountUuid = acntMgr.getOwnerAccountUuidOfResource(vmNicInventory.getUuid()); vmNicEventData.setAccountUuid(vmNicAccountUuid); vmNicEventData.setInventory(vmNicInventory); evtf.fire(VmNicCanonicalEvents.VM_NIC_CREATED_PATH, vmNicEventData); } }).error(new FlowErrorHandler(msg) {
final VirtualRouterOfferingInventory offering = msg.getOffering(); final CreateVirtualRouterVmReply reply = new CreateVirtualRouterVmReply(); final String accountUuid = acntMgr.getOwnerAccountUuidOfResource(l3Network.getUuid());
String accountUuid = acntMgr.getOwnerAccountUuidOfResource(spec.getVmInventory().getUuid()); if (accountUuid == null) { throw new CloudRuntimeException(String.format("accountUuid for vm[uuid:%s] is null", spec.getVmInventory().getUuid()));
private void createEmptyVolume(final VolumeInventory volume, final String hostUuid, final String backingFile, final ReturnValueCompletion<String> completion) { final CreateEmptyVolumeCmd cmd = new CreateEmptyVolumeCmd(); cmd.setAccountUuid(acntMgr.getOwnerAccountUuidOfResource(volume.getUuid())); if (volume.getInstallPath() != null && !volume.getInstallPath().equals("")) { cmd.setInstallUrl(volume.getInstallPath()); } else { if (VolumeType.Root.toString().equals(volume.getType())) { cmd.setInstallUrl(makeRootVolumeInstallUrl(volume)); } else { cmd.setInstallUrl(makeDataVolumeInstallUrl(volume.getUuid())); } } cmd.setName(volume.getName()); cmd.setSize(volume.getSize()); cmd.setVolumeUuid(volume.getUuid()); cmd.setBackingFile(backingFile); httpCall(CREATE_EMPTY_VOLUME_PATH, hostUuid, cmd, CreateEmptyVolumeRsp.class, new ReturnValueCompletion<CreateEmptyVolumeRsp>(completion) { @Override public void success(CreateEmptyVolumeRsp returnValue) { completion.success(cmd.getInstallUrl()); } @Override public void fail(ErrorCode errorCode) { completion.fail(operr("unable to create an empty volume[uuid:%s, name:%s] on the kvm host[uuid:%s]", volume.getUuid(), volume.getName(), hostUuid).causedBy(errorCode)); } }); }
final String accountUuid = acntMgr.getOwnerAccountUuidOfResource(volume.getUuid()); final CreateRootVolumeFromTemplateCmd cmd = new CreateRootVolumeFromTemplateCmd(); cmd.setTemplatePathInCache(image.getInstallUrl());
@Override public void run(MessageReply r) { if (!r.isSuccess()) { completion.fail(r.getError()); } else { IncreasePrimaryStorageCapacityMsg msg = new IncreasePrimaryStorageCapacityMsg(); msg.setPrimaryStorageUuid(self.getPrimaryStorageUuid()); msg.setDiskSize(self.getSize()); bus.makeTargetServiceIdByResourceUuid(msg, PrimaryStorageConstant.SERVICE_ID, self.getPrimaryStorageUuid()); bus.send(msg); CollectionUtils.safeForEach(pluginRgty.getExtensionList(VolumeAfterExpungeExtensionPoint.class), new ForEachFunction<VolumeAfterExpungeExtensionPoint>() { @Override public void run(VolumeAfterExpungeExtensionPoint arg) { arg.volumeAfterExpunge(inv); } }); VolumeInventory volumeInventory = getSelfInventory(); String accountUuid = acntMgr.getOwnerAccountUuidOfResource(self.getUuid()); dbf.remove(self); completion.success(); new FireVolumeCanonicalEvent().fireVolumeStatusChangedEvent(VolumeStatus.Deleted, volumeInventory, accountUuid); } } });
@Override public void instantiateVolume(final PrimaryStorageInventory pinv, final VolumeInventory volume, final ReturnValueCompletion<VolumeInventory> complete) { String accounUuid = acntMgr.getOwnerAccountUuidOfResource(volume.getUuid());
String accountUuid = acntMgr.getOwnerAccountUuidOfResource(self.getUuid()); dbf.remove(self); completion.success();