Package com.cloud.vm

Examples of com.cloud.vm.InstanceGroupVO


        Account caller = UserContext.current().getCaller();
        Long groupId = cmd.getId();
        String groupName = cmd.getGroupName();

        // Verify input parameters
        InstanceGroupVO group = _vmGroupDao.findById(groupId.longValue());
        if (group == null) {
            InvalidParameterValueException ex = new InvalidParameterValueException("unable to find a vm group with specified groupId");
            ex.addProxyObject(group, groupId, "groupId");
            throw ex;
        }

        _accountMgr.checkAccess(caller, null, true, group);

        // Check if name is already in use by this account (exclude this group)
        boolean isNameInUse = _vmGroupDao.isNameInUse(group.getAccountId(), groupName);

        if (isNameInUse && !group.getName().equals(groupName)) {
            throw new InvalidParameterValueException("Unable to update vm group, a group with name " + groupName + " already exists for account");
        }

        if (groupName != null) {
            _vmGroupDao.updateVmGroup(groupId, groupName);
View Full Code Here


            ResultSet result = statement.executeQuery();
            while (result.next()) {
                vmId = result.getLong(1);
                accountId = result.getLong(2);
                groupName = result.getString(3);
                InstanceGroupVO group = _vmGroupDao.findByAccountAndName(accountId, groupName);
                //Create vm group if the group doesn't exist for this account
                if (group == null) {
                    group = new InstanceGroupVO(groupName, accountId);
                    group =  _vmGroupDao.persist(group);
                    System.out.println("Created new isntance group with name " + groupName + " for account id=" + accountId);
                }

                if (group != null) {
                    InstanceGroupVMMapVO groupVmMapVO = new InstanceGroupVMMapVO(group.getId(), vmId);
                    _groupVMMapDao.persist(groupVmMapVO);
                    System.out.println("Assigned vm id=" + vmId + " to group with name " + groupName + " for account id=" + accountId);
                }
            }
            txn.commit();
View Full Code Here

        Account caller = CallContext.current().getCallingAccount();
        Long groupId = cmd.getId();
        String groupName = cmd.getGroupName();

        // Verify input parameters
        InstanceGroupVO group = _vmGroupDao.findById(groupId.longValue());
        if (group == null) {
            InvalidParameterValueException ex = new InvalidParameterValueException("unable to find a vm group with specified groupId");
            ex.addProxyObject(groupId.toString(), "groupId");
            throw ex;
        }

        _accountMgr.checkAccess(caller, null, true, group);

        // Check if name is already in use by this account (exclude this group)
        boolean isNameInUse = _vmGroupDao.isNameInUse(group.getAccountId(), groupName);

        if (isNameInUse && !group.getName().equals(groupName)) {
            throw new InvalidParameterValueException("Unable to update vm group, a group with name " + groupName + " already exists for account");
        }

        if (groupName != null) {
            _vmGroupDao.updateVmGroup(groupId, groupName);
View Full Code Here

TOP

Related Classes of com.cloud.vm.InstanceGroupVO

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.