当前位置: 首页>>代码示例>>Java>>正文


Java UserVmVO.getAccountId方法代码示例

本文整理汇总了Java中com.cloud.vm.UserVmVO.getAccountId方法的典型用法代码示例。如果您正苦于以下问题:Java UserVmVO.getAccountId方法的具体用法?Java UserVmVO.getAccountId怎么用?Java UserVmVO.getAccountId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.cloud.vm.UserVmVO的用法示例。


在下文中一共展示了UserVmVO.getAccountId方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createAndPersistVMSnapshot

import com.cloud.vm.UserVmVO; //导入方法依赖的package包/类
/**
 * Create, persist and return vm snapshot for userVmVo with given parameters.
 * Persistence and support for custom service offerings are done on the same transaction
 * @param userVmVo user vm
 * @param vmId vm id
 * @param vsDescription vm description
 * @param vmSnapshotName vm snapshot name
 * @param vsDisplayName vm snapshot display name
 * @param vmSnapshotType vm snapshot type
 * @return vm snapshot
 * @throws CloudRuntimeException if vm snapshot couldn't be persisted
 */
protected VMSnapshot createAndPersistVMSnapshot(UserVmVO userVmVo, String vsDescription, String vmSnapshotName, String vsDisplayName, VMSnapshot.Type vmSnapshotType) {
    final Long vmId = userVmVo.getId();
    final Long serviceOfferingId = userVmVo.getServiceOfferingId();
    final VMSnapshotVO vmSnapshotVo =
            new VMSnapshotVO(userVmVo.getAccountId(), userVmVo.getDomainId(), vmId, vsDescription, vmSnapshotName, vsDisplayName, serviceOfferingId,
                    vmSnapshotType, null);
    return Transaction.execute(new TransactionCallbackWithException<VMSnapshot, CloudRuntimeException>() {
        @Override
        public VMSnapshot doInTransaction(TransactionStatus status) {
            VMSnapshot vmSnapshot = _vmSnapshotDao.persist(vmSnapshotVo);
            if (vmSnapshot == null) {
                throw new CloudRuntimeException("Failed to create snapshot for vm: " + vmId);
            }
            addSupportForCustomServiceOffering(vmId, serviceOfferingId, vmSnapshot.getId());
            return vmSnapshot;
        }
    });
}
 
开发者ID:apache,项目名称:cloudstack,代码行数:31,代码来源:VMSnapshotManagerImpl.java

示例2: accountAndUserValidation

import com.cloud.vm.UserVmVO; //导入方法依赖的package包/类
private Long accountAndUserValidation(final Account account, final long userId, final UserVmVO vmInstanceCheck, final VMTemplateVO template, final String msg) throws
        PermissionDeniedException {

    if (account != null) {
        if (!_accountMgr.isAdmin(account.getId())) {
            if ((vmInstanceCheck != null) && (account.getId() != vmInstanceCheck.getAccountId())) {
                throw new PermissionDeniedException(msg + ". Permission denied.");
            }

            if ((template != null) &&
                    (!template.isPublicTemplate() && (account.getId() != template.getAccountId()) && (template.getTemplateType() != TemplateType.PERHOST))) {
                //special handling for the project case
                final Account owner = _accountMgr.getAccount(template.getAccountId());
                if (owner.getType() == Account.ACCOUNT_TYPE_PROJECT) {
                    if (!_projectMgr.canAccessProjectAccount(account, owner.getId())) {
                        throw new PermissionDeniedException(msg + ". Permission denied. The caller can't access project's template");
                    }
                } else {
                    throw new PermissionDeniedException(msg + ". Permission denied.");
                }
            }
        } else {
            if ((vmInstanceCheck != null) && !_domainDao.isChildDomain(account.getDomainId(), vmInstanceCheck.getDomainId())) {
                throw new PermissionDeniedException(msg + ". Permission denied.");
            }
            // FIXME: if template/ISO owner is null we probably need to
            // throw some kind of exception

            if (template != null) {
                final Account templateOwner = _accountDao.findById(template.getAccountId());
                if ((templateOwner != null) && !_domainDao.isChildDomain(account.getDomainId(), templateOwner.getDomainId())) {
                    throw new PermissionDeniedException(msg + ". Permission denied.");
                }
            }
        }
    }

    return userId;
}
 
开发者ID:MissionCriticalCloud,项目名称:cosmic,代码行数:40,代码来源:TemplateAdapterBase.java

示例3: accountAndUserValidation

import com.cloud.vm.UserVmVO; //导入方法依赖的package包/类
private Long accountAndUserValidation(Account account, long userId, UserVmVO vmInstanceCheck, VMTemplateVO template, String msg) throws PermissionDeniedException {

        if (account != null) {
            if (!_accountMgr.isAdmin(account.getId())) {
                if ((vmInstanceCheck != null) && (account.getId() != vmInstanceCheck.getAccountId())) {
                    throw new PermissionDeniedException(msg + ". Permission denied.");
                }

                if ((template != null) &&
                    (!template.isPublicTemplate() && (account.getId() != template.getAccountId()) && (template.getTemplateType() != TemplateType.PERHOST))) {
                    //special handling for the project case
                    Account owner = _accountMgr.getAccount(template.getAccountId());
                    if (owner.getType() == Account.ACCOUNT_TYPE_PROJECT) {
                        if (!_projectMgr.canAccessProjectAccount(account, owner.getId())) {
                            throw new PermissionDeniedException(msg + ". Permission denied. The caller can't access project's template");
                        }
                    } else {
                        throw new PermissionDeniedException(msg + ". Permission denied.");
                    }
                }
            } else {
                if ((vmInstanceCheck != null) && !_domainDao.isChildDomain(account.getDomainId(), vmInstanceCheck.getDomainId())) {
                    throw new PermissionDeniedException(msg + ". Permission denied.");
                }
                // FIXME: if template/ISO owner is null we probably need to
                // throw some kind of exception

                if (template != null) {
                    Account templateOwner = _accountDao.findById(template.getAccountId());
                    if ((templateOwner != null) && !_domainDao.isChildDomain(account.getDomainId(), templateOwner.getDomainId())) {
                        throw new PermissionDeniedException(msg + ". Permission denied.");
                    }
                }
            }
        }

        return userId;
    }
 
开发者ID:apache,项目名称:cloudstack,代码行数:39,代码来源:TemplateAdapterBase.java


注:本文中的com.cloud.vm.UserVmVO.getAccountId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。