Search in sources :

Example 46 with UserVm

use of com.cloud.uservm.UserVm in project cloudstack by apache.

the class ApiResponseHelper method showVmInfoForSharedNetworks.

private void showVmInfoForSharedNetworks(boolean forVirtualNetworks, IpAddress ipAddr, IPAddressResponse ipResponse) {
    if (!forVirtualNetworks) {
        NicVO nic = ApiDBUtils.findByIp4AddressAndNetworkId(ipAddr.getAddress().toString(), ipAddr.getNetworkId());
        if (nic == null) {
            // find in nic_secondary_ips, user vm only
            NicSecondaryIpVO secondaryIp = ApiDBUtils.findSecondaryIpByIp4AddressAndNetworkId(ipAddr.getAddress().toString(), ipAddr.getNetworkId());
            if (secondaryIp != null) {
                UserVm vm = ApiDBUtils.findUserVmById(secondaryIp.getVmId());
                if (vm != null) {
                    ipResponse.setVirtualMachineId(vm.getUuid());
                    ipResponse.setVirtualMachineName(vm.getHostName());
                    if (vm.getDisplayName() != null) {
                        ipResponse.setVirtualMachineDisplayName(vm.getDisplayName());
                    } else {
                        ipResponse.setVirtualMachineDisplayName(vm.getHostName());
                    }
                }
            }
        } else if (nic.getVmType() == VirtualMachine.Type.User) {
            UserVm vm = ApiDBUtils.findUserVmById(nic.getInstanceId());
            if (vm != null) {
                ipResponse.setVirtualMachineId(vm.getUuid());
                ipResponse.setVirtualMachineName(vm.getHostName());
                if (vm.getDisplayName() != null) {
                    ipResponse.setVirtualMachineDisplayName(vm.getDisplayName());
                } else {
                    ipResponse.setVirtualMachineDisplayName(vm.getHostName());
                }
            }
        } else if (nic.getVmType() == VirtualMachine.Type.DomainRouter) {
            ipResponse.setIsSystem(true);
        }
    }
}
Also used : NicSecondaryIpVO(com.cloud.vm.dao.NicSecondaryIpVO) UserVm(com.cloud.uservm.UserVm) NicVO(com.cloud.vm.NicVO)

Example 47 with UserVm

use of com.cloud.uservm.UserVm in project cloudstack by apache.

the class ApiResponseHelper method createLoadBalancerContainerReponse.

@Override
public ApplicationLoadBalancerResponse createLoadBalancerContainerReponse(ApplicationLoadBalancerRule lb, Map<Ip, UserVm> lbInstances) {
    ApplicationLoadBalancerResponse lbResponse = new ApplicationLoadBalancerResponse();
    lbResponse.setId(lb.getUuid());
    lbResponse.setName(lb.getName());
    lbResponse.setDescription(lb.getDescription());
    lbResponse.setAlgorithm(lb.getAlgorithm());
    lbResponse.setForDisplay(lb.isDisplay());
    Network nw = ApiDBUtils.findNetworkById(lb.getNetworkId());
    lbResponse.setNetworkId(nw.getUuid());
    populateOwner(lbResponse, lb);
    if (lb.getScheme() == Scheme.Internal) {
        lbResponse.setSourceIp(lb.getSourceIp().addr());
        // TODO - create the view for the load balancer rule to reflect the network uuid
        Network network = ApiDBUtils.findNetworkById(lb.getNetworkId());
        lbResponse.setSourceIpNetworkId(network.getUuid());
    } else {
        // for public, populate the ip information from the ip address
        IpAddress publicIp = ApiDBUtils.findIpAddressById(lb.getSourceIpAddressId());
        lbResponse.setSourceIp(publicIp.getAddress().addr());
        Network ntwk = ApiDBUtils.findNetworkById(publicIp.getNetworkId());
        lbResponse.setSourceIpNetworkId(ntwk.getUuid());
    }
    // set load balancer rules information (only one rule per load balancer in this release)
    List<ApplicationLoadBalancerRuleResponse> ruleResponses = new ArrayList<ApplicationLoadBalancerRuleResponse>();
    ApplicationLoadBalancerRuleResponse ruleResponse = new ApplicationLoadBalancerRuleResponse();
    ruleResponse.setInstancePort(lb.getDefaultPortStart());
    ruleResponse.setSourcePort(lb.getSourcePortStart());
    FirewallRule.State stateToSet = lb.getState();
    if (stateToSet.equals(FirewallRule.State.Revoke)) {
        stateToSet = FirewallRule.State.Deleting;
    }
    ruleResponse.setState(stateToSet.toString());
    ruleResponse.setObjectName("loadbalancerrule");
    ruleResponses.add(ruleResponse);
    lbResponse.setLbRules(ruleResponses);
    // set Lb instances information
    List<ApplicationLoadBalancerInstanceResponse> instanceResponses = new ArrayList<ApplicationLoadBalancerInstanceResponse>();
    for (Map.Entry<Ip, UserVm> entry : lbInstances.entrySet()) {
        Ip ip = entry.getKey();
        UserVm vm = entry.getValue();
        ApplicationLoadBalancerInstanceResponse instanceResponse = new ApplicationLoadBalancerInstanceResponse();
        instanceResponse.setIpAddress(ip.addr());
        instanceResponse.setId(vm.getUuid());
        instanceResponse.setName(vm.getInstanceName());
        instanceResponse.setObjectName("loadbalancerinstance");
        instanceResponses.add(instanceResponse);
    }
    lbResponse.setLbInstances(instanceResponses);
    // set tag information
    List<? extends ResourceTag> tags = ApiDBUtils.listByResourceTypeAndId(ResourceObjectType.LoadBalancer, lb.getId());
    List<ResourceTagResponse> tagResponses = new ArrayList<ResourceTagResponse>();
    for (ResourceTag tag : tags) {
        ResourceTagResponse tagResponse = createResourceTagResponse(tag, true);
        CollectionUtils.addIgnoreNull(tagResponses, tagResponse);
    }
    lbResponse.setTags(tagResponses);
    lbResponse.setObjectName("loadbalancer");
    return lbResponse;
}
Also used : PortableIp(org.apache.cloudstack.region.PortableIp) NicSecondaryIp(com.cloud.vm.NicSecondaryIp) Ip(com.cloud.utils.net.Ip) ArrayList(java.util.ArrayList) UserVm(com.cloud.uservm.UserVm) ResourceTag(com.cloud.server.ResourceTag) Network(com.cloud.network.Network) PhysicalNetwork(com.cloud.network.PhysicalNetwork) ResourceTagResponse(org.apache.cloudstack.api.response.ResourceTagResponse) IpAddress(com.cloud.network.IpAddress) ApplicationLoadBalancerRuleResponse(org.apache.cloudstack.api.response.ApplicationLoadBalancerRuleResponse) ApplicationLoadBalancerResponse(org.apache.cloudstack.api.response.ApplicationLoadBalancerResponse) FirewallRule(com.cloud.network.rules.FirewallRule) Map(java.util.Map) HashMap(java.util.HashMap) ApplicationLoadBalancerInstanceResponse(org.apache.cloudstack.api.response.ApplicationLoadBalancerInstanceResponse)

Example 48 with UserVm

use of com.cloud.uservm.UserVm in project cloudstack by apache.

the class TemplateManagerImpl method detachIso.

@Override
@ActionEvent(eventType = EventTypes.EVENT_ISO_DETACH, eventDescription = "detaching ISO", async = true)
public boolean detachIso(long vmId, boolean forced) {
    Account caller = CallContext.current().getCallingAccount();
    Long userId = CallContext.current().getCallingUserId();
    // Verify input parameters
    UserVmVO vmInstanceCheck = _userVmDao.findById(vmId);
    if (vmInstanceCheck == null) {
        throw new InvalidParameterValueException("Unable to find a virtual machine with id " + vmId);
    }
    UserVm userVM = _userVmDao.findById(vmId);
    if (userVM == null) {
        throw new InvalidParameterValueException("Please specify a valid VM.");
    }
    _accountMgr.checkAccess(caller, null, true, userVM);
    Long isoId = userVM.getIsoId();
    if (isoId == null) {
        throw new InvalidParameterValueException("The specified VM has no ISO attached to it.");
    }
    CallContext.current().setEventDetails("Vm Id: " + userVM.getUuid() + " ISO Id: " + isoId);
    State vmState = userVM.getState();
    if (vmState != State.Running && vmState != State.Stopped) {
        throw new InvalidParameterValueException("Please specify a VM that is either Stopped or Running.");
    }
    // attach=false
    boolean result = attachISOToVM(vmId, userId, isoId, false, forced);
    // => detach
    if (result) {
        return result;
    } else {
        throw new CloudRuntimeException("Failed to detach iso");
    }
}
Also used : Account(com.cloud.user.Account) UserVmVO(com.cloud.vm.UserVmVO) UserVm(com.cloud.uservm.UserVm) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) State(com.cloud.vm.VirtualMachine.State) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) ActionEvent(com.cloud.event.ActionEvent)

Example 49 with UserVm

use of com.cloud.uservm.UserVm in project cloudstack by apache.

the class UserVmManagerImpl method updateNicIpForVirtualMachine.

@Override
public UserVm updateNicIpForVirtualMachine(UpdateVmNicIpCmd cmd) {
    Long nicId = cmd.getNicId();
    String ipaddr = cmd.getIpaddress();
    Account caller = CallContext.current().getCallingAccount();
    // check whether the nic belongs to user vm.
    NicVO nicVO = _nicDao.findById(nicId);
    if (nicVO == null) {
        throw new InvalidParameterValueException("There is no nic for the " + nicId);
    }
    if (nicVO.getVmType() != VirtualMachine.Type.User) {
        throw new InvalidParameterValueException("The nic is not belongs to user vm");
    }
    UserVm vm = _vmDao.findById(nicVO.getInstanceId());
    if (vm == null) {
        throw new InvalidParameterValueException("There is no vm with the nic");
    }
    Network network = _networkDao.findById(nicVO.getNetworkId());
    if (network == null) {
        throw new InvalidParameterValueException("There is no network with the nic");
    }
    // Don't allow to update vm nic ip if network is not in Implemented/Setup/Allocated state
    if (!(network.getState() == Network.State.Allocated || network.getState() == Network.State.Implemented || network.getState() == Network.State.Setup)) {
        throw new InvalidParameterValueException("Network is not in the right state to update vm nic ip. Correct states are: " + Network.State.Allocated + ", " + Network.State.Implemented + ", " + Network.State.Setup);
    }
    NetworkOfferingVO offering = _networkOfferingDao.findByIdIncludingRemoved(network.getNetworkOfferingId());
    if (offering == null) {
        throw new InvalidParameterValueException("There is no network offering with the network");
    }
    if (!_networkModel.listNetworkOfferingServices(offering.getId()).isEmpty() && vm.getState() != State.Stopped) {
        InvalidParameterValueException ex = new InvalidParameterValueException("VM is not Stopped, unable to update the vm nic having the specified id");
        ex.addProxyObject(vm.getUuid(), "vmId");
        throw ex;
    }
    // verify permissions
    _accountMgr.checkAccess(caller, null, true, vm);
    Account ipOwner = _accountDao.findByIdIncludingRemoved(vm.getAccountId());
    // verify ip address
    s_logger.debug("Calling the ip allocation ...");
    DataCenter dc = _dcDao.findById(network.getDataCenterId());
    if (dc == null) {
        throw new InvalidParameterValueException("There is no dc with the nic");
    }
    if (dc.getNetworkType() == NetworkType.Advanced && network.getGuestType() == Network.GuestType.Isolated) {
        try {
            ipaddr = _ipAddrMgr.allocateGuestIP(network, ipaddr);
        } catch (InsufficientAddressCapacityException e) {
            throw new InvalidParameterValueException("Allocating ip to guest nic " + nicVO.getUuid() + " failed, for insufficient address capacity");
        }
        if (ipaddr == null) {
            throw new InvalidParameterValueException("Allocating ip to guest nic " + nicVO.getUuid() + " failed, please choose another ip");
        }
        if (nicVO.getIPv4Address() != null) {
            updatePublicIpDnatVmIp(vm.getId(), network.getId(), nicVO.getIPv4Address(), ipaddr);
            updateLoadBalancerRulesVmIp(vm.getId(), network.getId(), nicVO.getIPv4Address(), ipaddr);
            updatePortForwardingRulesVmIp(vm.getId(), network.getId(), nicVO.getIPv4Address(), ipaddr);
        }
    } else if (dc.getNetworkType() == NetworkType.Basic || network.getGuestType() == Network.GuestType.Shared) {
        // handle the basic networks here
        // for basic zone, need to provide the podId to ensure proper ip alloation
        Long podId = null;
        if (dc.getNetworkType() == NetworkType.Basic) {
            podId = vm.getPodIdToDeployIn();
            if (podId == null) {
                throw new InvalidParameterValueException("vm pod id is null in Basic zone; can't decide the range for ip allocation");
            }
        }
        try {
            ipaddr = _ipAddrMgr.allocatePublicIpForGuestNic(network, podId, ipOwner, ipaddr);
            if (ipaddr == null) {
                throw new InvalidParameterValueException("Allocating ip to guest nic " + nicVO.getUuid() + " failed, please choose another ip");
            }
            final IPAddressVO newIp = _ipAddressDao.findByIpAndSourceNetworkId(network.getId(), ipaddr);
            final Vlan vlan = _vlanDao.findById(newIp.getVlanId());
            nicVO.setIPv4Gateway(vlan.getVlanGateway());
            nicVO.setIPv4Netmask(vlan.getVlanNetmask());
            final IPAddressVO ip = _ipAddressDao.findByIpAndSourceNetworkId(nicVO.getNetworkId(), nicVO.getIPv4Address());
            if (ip != null) {
                Transaction.execute(new TransactionCallbackNoReturn() {

                    @Override
                    public void doInTransactionWithoutResult(TransactionStatus status) {
                        _ipAddrMgr.markIpAsUnavailable(ip.getId());
                        _ipAddressDao.unassignIpAddress(ip.getId());
                    }
                });
            }
        } catch (InsufficientAddressCapacityException e) {
            s_logger.error("Allocating ip to guest nic " + nicVO.getUuid() + " failed, for insufficient address capacity");
            return null;
        }
    } else {
        throw new InvalidParameterValueException("UpdateVmNicIpCmd is not supported in L2 network");
    }
    s_logger.debug("Updating IPv4 address of NIC " + nicVO + " to " + ipaddr + "/" + nicVO.getIPv4Netmask() + " with gateway " + nicVO.getIPv4Gateway());
    nicVO.setIPv4Address(ipaddr);
    _nicDao.persist(nicVO);
    return vm;
}
Also used : Account(com.cloud.user.Account) InsufficientAddressCapacityException(com.cloud.exception.InsufficientAddressCapacityException) TransactionStatus(com.cloud.utils.db.TransactionStatus) TransactionCallbackNoReturn(com.cloud.utils.db.TransactionCallbackNoReturn) Vlan(com.cloud.dc.Vlan) UserVm(com.cloud.uservm.UserVm) DataCenter(com.cloud.dc.DataCenter) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) Network(com.cloud.network.Network) PhysicalNetwork(com.cloud.network.PhysicalNetwork) NetworkOfferingVO(com.cloud.offerings.NetworkOfferingVO) IPAddressVO(com.cloud.network.dao.IPAddressVO)

Example 50 with UserVm

use of com.cloud.uservm.UserVm in project cloudstack by apache.

the class UserVmManagerImpl method updateVirtualMachine.

@Override
public UserVm updateVirtualMachine(long id, String displayName, String group, Boolean ha, Boolean isDisplayVmEnabled, Long osTypeId, String userData, Boolean isDynamicallyScalable, HTTPMethod httpMethod, String customId, String hostName, String instanceName, List<Long> securityGroupIdList, Map<String, Map<Integer, String>> extraDhcpOptionsMap) throws ResourceUnavailableException, InsufficientCapacityException {
    UserVmVO vm = _vmDao.findById(id);
    if (vm == null) {
        throw new CloudRuntimeException("Unable to find virtual machine with id " + id);
    }
    if (instanceName != null) {
        VMInstanceVO vmInstance = _vmInstanceDao.findVMByInstanceName(instanceName);
        if (vmInstance != null && vmInstance.getId() != id) {
            throw new CloudRuntimeException("Instance name : " + instanceName + " is not unique");
        }
    }
    if (vm.getState() == State.Error || vm.getState() == State.Expunging) {
        s_logger.error("vm is not in the right state: " + id);
        throw new InvalidParameterValueException("Vm with id " + id + " is not in the right state");
    }
    if (displayName == null) {
        displayName = vm.getDisplayName();
    }
    if (ha == null) {
        ha = vm.isHaEnabled();
    }
    ServiceOffering offering = _serviceOfferingDao.findById(vm.getId(), vm.getServiceOfferingId());
    if (!offering.isOfferHA() && ha) {
        throw new InvalidParameterValueException("Can't enable ha for the vm as it's created from the Service offering having HA disabled");
    }
    if (isDisplayVmEnabled == null) {
        isDisplayVmEnabled = vm.isDisplayVm();
    }
    boolean updateUserdata = false;
    if (userData != null) {
        // check and replace newlines
        userData = userData.replace("\\n", "");
        userData = validateUserData(userData, httpMethod);
        // update userData on domain router.
        updateUserdata = true;
    } else {
        userData = vm.getUserData();
    }
    if (osTypeId == null) {
        osTypeId = vm.getGuestOSId();
    }
    if (group != null) {
        addInstanceToGroup(id, group);
    }
    if (isDynamicallyScalable == null) {
        isDynamicallyScalable = vm.isDynamicallyScalable();
    } else {
        if (isDynamicallyScalable == true) {
            VMTemplateVO template = _templateDao.findByIdIncludingRemoved(vm.getTemplateId());
            if (!template.isDynamicallyScalable()) {
                throw new InvalidParameterValueException("Dynamic Scaling cannot be enabled for the VM since its template does not have dynamic scaling enabled");
            }
            if (!offering.isDynamicScalingEnabled()) {
                throw new InvalidParameterValueException("Dynamic Scaling cannot be enabled for the VM since its service offering does not have dynamic scaling enabled");
            }
            if (!UserVmManager.EnableDynamicallyScaleVm.valueIn(vm.getDataCenterId())) {
                s_logger.debug(String.format("Dynamic Scaling cannot be enabled for the VM %s since the global setting enable.dynamic.scale.vm is set to false", vm.getUuid()));
                throw new InvalidParameterValueException("Dynamic Scaling cannot be enabled for the VM since corresponding global setting is set to false");
            }
        }
    }
    boolean isVMware = (vm.getHypervisorType() == HypervisorType.VMware);
    if (securityGroupIdList != null && isVMware) {
        throw new InvalidParameterValueException("Security group feature is not supported for vmWare hypervisor");
    } else {
        // Get default guest network in Basic zone
        Network defaultNetwork = null;
        try {
            DataCenterVO zone = _dcDao.findById(vm.getDataCenterId());
            if (zone.getNetworkType() == NetworkType.Basic) {
                // Get default guest network in Basic zone
                defaultNetwork = _networkModel.getExclusiveGuestNetwork(zone.getId());
            } else if (zone.isSecurityGroupEnabled()) {
                NicVO defaultNic = _nicDao.findDefaultNicForVM(vm.getId());
                if (defaultNic != null) {
                    defaultNetwork = _networkDao.findById(defaultNic.getNetworkId());
                }
            }
        } catch (InvalidParameterValueException e) {
            if (s_logger.isDebugEnabled()) {
                s_logger.debug(e.getMessage(), e);
            }
            defaultNetwork = _networkModel.getDefaultNetworkForVm(id);
        }
        if (securityGroupIdList != null && _networkModel.isSecurityGroupSupportedInNetwork(defaultNetwork) && _networkModel.canAddDefaultSecurityGroup()) {
            if (vm.getState() == State.Stopped) {
                // Remove instance from security groups
                _securityGroupMgr.removeInstanceFromGroups(id);
                // Add instance in provided groups
                _securityGroupMgr.addInstanceToGroups(id, securityGroupIdList);
            } else {
                throw new InvalidParameterValueException("Virtual machine must be stopped prior to update security groups ");
            }
        }
    }
    List<? extends Nic> nics = _nicDao.listByVmId(vm.getId());
    if (hostName != null) {
        // Check is hostName is RFC compliant
        checkNameForRFCCompliance(hostName);
        if (vm.getHostName().equalsIgnoreCase(hostName)) {
            s_logger.debug("Vm " + vm + " is already set with the hostName specified: " + hostName);
            hostName = null;
        }
        // Verify that vm's hostName is unique
        List<NetworkVO> vmNtwks = new ArrayList<NetworkVO>(nics.size());
        for (Nic nic : nics) {
            vmNtwks.add(_networkDao.findById(nic.getNetworkId()));
        }
        checkIfHostNameUniqueInNtwkDomain(hostName, vmNtwks);
    }
    List<NetworkVO> networks = nics.stream().map(nic -> _networkDao.findById(nic.getNetworkId())).collect(Collectors.toList());
    verifyExtraDhcpOptionsNetwork(extraDhcpOptionsMap, networks);
    for (Nic nic : nics) {
        _networkMgr.saveExtraDhcpOptions(networks.stream().filter(network -> network.getId() == nic.getNetworkId()).findFirst().get().getUuid(), nic.getId(), extraDhcpOptionsMap);
    }
    _vmDao.updateVM(id, displayName, ha, osTypeId, userData, isDisplayVmEnabled, isDynamicallyScalable, customId, hostName, instanceName);
    if (updateUserdata) {
        updateUserData(vm);
    }
    if (State.Running == vm.getState()) {
        updateDns(vm, hostName);
    }
    return _vmDao.findById(id);
}
Also used : DataCenterVO(com.cloud.dc.DataCenterVO) ServiceOfferingJoinVO(com.cloud.api.query.vo.ServiceOfferingJoinVO) SecurityGroupManager(com.cloud.network.security.SecurityGroupManager) AccountService(com.cloud.user.AccountService) DeleteVMGroupCmd(org.apache.cloudstack.api.command.user.vmgroup.DeleteVMGroupCmd) NetworkModel(com.cloud.network.NetworkModel) UsageEventUtils(com.cloud.event.UsageEventUtils) HostDao(com.cloud.host.dao.HostDao) ExecutionException(com.cloud.utils.exception.ExecutionException) ResourceState(com.cloud.resource.ResourceState) ResetVMPasswordCmd(org.apache.cloudstack.api.command.user.vm.ResetVMPasswordCmd) Autowired(org.springframework.beans.factory.annotation.Autowired) Pod(com.cloud.dc.Pod) TemplateDataStoreDao(org.apache.cloudstack.storage.datastore.db.TemplateDataStoreDao) StringUtils(org.apache.commons.lang3.StringUtils) Base64(org.apache.commons.codec.binary.Base64) AgentUnavailableException(com.cloud.exception.AgentUnavailableException) PvlanSetupCommand(com.cloud.agent.api.PvlanSetupCommand) SnapshotDao(com.cloud.storage.dao.SnapshotDao) DiskOffering(com.cloud.offering.DiskOffering) TransactionCallbackWithException(com.cloud.utils.db.TransactionCallbackWithException) Document(org.w3c.dom.Document) Map(java.util.Map) ResizeVolumeCmd(org.apache.cloudstack.api.command.user.volume.ResizeVolumeCmd) VlanDao(com.cloud.dc.dao.VlanDao) TrafficType(com.cloud.network.Networks.TrafficType) GuestOSCategoryVO(com.cloud.storage.GuestOSCategoryVO) NetworkOrchestrationService(org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationService) Service(com.cloud.network.Network.Service) PhysicalNetworkDao(com.cloud.network.dao.PhysicalNetworkDao) VolumeOrchestrationService(org.apache.cloudstack.engine.orchestration.service.VolumeOrchestrationService) VmDiskStatisticsDao(com.cloud.user.dao.VmDiskStatisticsDao) ModifyTargetsCommand(com.cloud.agent.api.ModifyTargetsCommand) Network(com.cloud.network.Network) TransactionStatus(com.cloud.utils.db.TransactionStatus) DeploymentPlanner(com.cloud.deploy.DeploymentPlanner) ApiDBUtils(com.cloud.api.ApiDBUtils) QueryService(org.apache.cloudstack.query.QueryService) NetworkOfferingVO(com.cloud.offerings.NetworkOfferingVO) AffinityGroupVO(org.apache.cloudstack.affinity.AffinityGroupVO) ResourceTagVO(com.cloud.tags.ResourceTagVO) Stream(java.util.stream.Stream) ServiceOfferingVO(com.cloud.service.ServiceOfferingVO) ServiceOffering(com.cloud.offering.ServiceOffering) InsufficientServerCapacityException(com.cloud.exception.InsufficientServerCapacityException) UpdateVMCmd(org.apache.cloudstack.api.command.user.vm.UpdateVMCmd) DocumentBuilderFactory(javax.xml.parsers.DocumentBuilderFactory) VMSnapshotVO(com.cloud.vm.snapshot.VMSnapshotVO) AsyncCallFuture(org.apache.cloudstack.framework.async.AsyncCallFuture) ManagerBase(com.cloud.utils.component.ManagerBase) UserDataServiceProvider(com.cloud.network.element.UserDataServiceProvider) AssignVMCmd(org.apache.cloudstack.api.command.admin.vm.AssignVMCmd) ResourceUnavailableException(com.cloud.exception.ResourceUnavailableException) Availability(com.cloud.offering.NetworkOffering.Availability) VMTemplateDao(com.cloud.storage.dao.VMTemplateDao) DataCenterVO(com.cloud.dc.DataCenterVO) GetVolumeStatsAnswer(com.cloud.agent.api.GetVolumeStatsAnswer) LinkedHashMap(java.util.LinkedHashMap) SnapshotVO(com.cloud.storage.SnapshotVO) NetworkType(com.cloud.dc.DataCenter.NetworkType) ClusterDao(com.cloud.dc.dao.ClusterDao) UserDao(com.cloud.user.dao.UserDao) SearchCriteria(com.cloud.utils.db.SearchCriteria) VlanVO(com.cloud.dc.VlanVO) User(com.cloud.user.User) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) GetVolumeStatsCommand(com.cloud.agent.api.GetVolumeStatsCommand) AffinityGroupVMMapDao(org.apache.cloudstack.affinity.dao.AffinityGroupVMMapDao) ResourceTag(com.cloud.server.ResourceTag) GetVmNetworkStatsCommand(com.cloud.agent.api.GetVmNetworkStatsCommand) InstanceGroupDao(com.cloud.vm.dao.InstanceGroupDao) VirtualMachineMigrationException(com.cloud.exception.VirtualMachineMigrationException) CommandSetupHelper(com.cloud.network.router.CommandSetupHelper) VMTemplateStorageResourceAssoc(com.cloud.storage.VMTemplateStorageResourceAssoc) UserVm(com.cloud.uservm.UserVm) NicTO(com.cloud.agent.api.to.NicTO) Vlan(com.cloud.dc.Vlan) HighAvailabilityManager(com.cloud.ha.HighAvailabilityManager) UserVmDao(com.cloud.vm.dao.UserVmDao) DestroyVMCmd(org.apache.cloudstack.api.command.user.vm.DestroyVMCmd) NicDao(com.cloud.vm.dao.NicDao) IOException(java.io.IOException) PhysicalNetwork(com.cloud.network.PhysicalNetwork) DB(com.cloud.utils.db.DB) GetVmStatsAnswer(com.cloud.agent.api.GetVmStatsAnswer) PrimaryDataStoreDriver(org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreDriver) Command(com.cloud.agent.api.Command) ControlledEntity(org.apache.cloudstack.acl.ControlledEntity) StringReader(java.io.StringReader) GlobalLock(com.cloud.utils.db.GlobalLock) ConfigurationDao(org.apache.cloudstack.framework.config.dao.ConfigurationDao) StorageManager(com.cloud.storage.StorageManager) AnnotationDao(org.apache.cloudstack.annotation.dao.AnnotationDao) URLDecoder(java.net.URLDecoder) Date(java.util.Date) SecurityGroupAction(org.apache.cloudstack.api.command.user.vm.SecurityGroupAction) StoragePool(com.cloud.storage.StoragePool) AlertManager(com.cloud.alert.AlertManager) UserStatisticsDao(com.cloud.user.dao.UserStatisticsDao) ResourceType(com.cloud.configuration.Resource.ResourceType) Cluster(com.cloud.org.Cluster) GuestOSCategoryDao(com.cloud.storage.dao.GuestOSCategoryDao) GetVmNetworkStatsAnswer(com.cloud.agent.api.GetVmNetworkStatsAnswer) DataStore(org.apache.cloudstack.engine.subsystem.api.storage.DataStore) OrchestrationService(org.apache.cloudstack.engine.service.api.OrchestrationService) CreateVMGroupCmd(org.apache.cloudstack.api.command.user.vmgroup.CreateVMGroupCmd) Answer(com.cloud.agent.api.Answer) RSAHelper(com.cloud.utils.crypt.RSAHelper) Config(com.cloud.configuration.Config) DeploymentPlanningManager(com.cloud.deploy.DeploymentPlanningManager) UserVO(com.cloud.user.UserVO) Capacity(com.cloud.capacity.Capacity) State(com.cloud.vm.VirtualMachine.State) DeployDestination(com.cloud.deploy.DeployDestination) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Commands(com.cloud.agent.manager.Commands) UUID(java.util.UUID) Pair(com.cloud.utils.Pair) Collectors(java.util.stream.Collectors) VpcManager(com.cloud.network.vpc.VpcManager) Objects(java.util.Objects) DiskOfferingVO(com.cloud.storage.DiskOfferingVO) Entry(java.util.Map.Entry) StoragePoolType(com.cloud.storage.Storage.StoragePoolType) DedicatedResourceVO(com.cloud.dc.DedicatedResourceVO) NetUtils(com.cloud.utils.net.NetUtils) DataStoreManager(org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager) DataCenterDeployment(com.cloud.deploy.DataCenterDeployment) UnsupportedServiceException(com.cloud.exception.UnsupportedServiceException) DiskOfferingDao(com.cloud.storage.dao.DiskOfferingDao) Domain(com.cloud.domain.Domain) DBEncryptionUtil(com.cloud.utils.crypt.DBEncryptionUtil) PortForwardingRuleVO(com.cloud.network.rules.PortForwardingRuleVO) HashSet(java.util.HashSet) Inject(javax.inject.Inject) ConfigKey(org.apache.cloudstack.framework.config.ConfigKey) IPAddressVO(com.cloud.network.dao.IPAddressVO) Qualifier(org.springframework.beans.factory.annotation.Qualifier) VolumeDao(com.cloud.storage.dao.VolumeDao) IPAddressDao(com.cloud.network.dao.IPAddressDao) FirewallRulesDao(com.cloud.network.dao.FirewallRulesDao) Snapshot(com.cloud.storage.Snapshot) NamedThreadFactory(com.cloud.utils.concurrency.NamedThreadFactory) ExecutorService(java.util.concurrent.ExecutorService) DataCenter(com.cloud.dc.DataCenter) PermissionDeniedException(com.cloud.exception.PermissionDeniedException) UpdateDefaultNicForVMCmd(org.apache.cloudstack.api.command.user.vm.UpdateDefaultNicForVMCmd) HostVO(com.cloud.host.HostVO) InputSource(org.xml.sax.InputSource) VMTemplateVO(com.cloud.storage.VMTemplateVO) NodeList(org.w3c.dom.NodeList) ConfigurationManager(com.cloud.configuration.ConfigurationManager) MapUtils(org.apache.commons.collections.MapUtils) VirtualMachineTO(com.cloud.agent.api.to.VirtualMachineTO) UserVmDeployAsIsDetailsDao(com.cloud.deployasis.dao.UserVmDeployAsIsDetailsDao) AddNicToVMCmd(org.apache.cloudstack.api.command.user.vm.AddNicToVMCmd) UserVmDeployAsIsDetailVO(com.cloud.deployasis.UserVmDeployAsIsDetailVO) VolumeStatsEntry(com.cloud.agent.api.VolumeStatsEntry) SSHKeyPairDao(com.cloud.user.dao.SSHKeyPairDao) DiskTO(com.cloud.agent.api.to.DiskTO) NumbersUtil.toHumanReadableSize(com.cloud.utils.NumbersUtil.toHumanReadableSize) ApiConstants(org.apache.cloudstack.api.ApiConstants) UUIDManager(com.cloud.utils.db.UUIDManager) Element(org.w3c.dom.Element) DataStoreRole(com.cloud.storage.DataStoreRole) VolumeApiResult(org.apache.cloudstack.engine.subsystem.api.storage.VolumeService.VolumeApiResult) TemplateDeployAsIsDetailsDao(com.cloud.deployasis.dao.TemplateDeployAsIsDetailsDao) StoragePoolVO(org.apache.cloudstack.storage.datastore.db.StoragePoolVO) FirewallManager(com.cloud.network.rules.FirewallManager) DpdkHelper(com.cloud.hypervisor.kvm.dpdk.DpdkHelper) OVFPropertyTO(com.cloud.agent.api.to.deployasis.OVFPropertyTO) Arrays(java.util.Arrays) ByteScaleUtils(org.apache.cloudstack.utils.bytescale.ByteScaleUtils) UpdateVmNicIpCmd(org.apache.cloudstack.api.command.user.vm.UpdateVmNicIpCmd) VolumeService(org.apache.cloudstack.engine.subsystem.api.storage.VolumeService) Transaction(com.cloud.utils.db.Transaction) TransactionCallbackWithExceptionNoReturn(com.cloud.utils.db.TransactionCallbackWithExceptionNoReturn) NoTransitionException(com.cloud.utils.fsm.NoTransitionException) AgentManager(com.cloud.agent.AgentManager) ServiceOfferingDetailsDao(com.cloud.service.dao.ServiceOfferingDetailsDao) VirtualMachineTemplate(com.cloud.template.VirtualMachineTemplate) TemplateType(com.cloud.storage.Storage.TemplateType) Matcher(java.util.regex.Matcher) VmNetworkStatsEntry(com.cloud.agent.api.VmNetworkStatsEntry) ServiceOfferingDao(com.cloud.service.dao.ServiceOfferingDao) NetworkServiceMapDao(com.cloud.network.dao.NetworkServiceMapDao) CloudException(com.cloud.exception.CloudException) PlannerHostReservationDao(com.cloud.deploy.dao.PlannerHostReservationDao) Storage(com.cloud.storage.Storage) NicExtraDhcpOptionDao(com.cloud.vm.dao.NicExtraDhcpOptionDao) CapacityManager(com.cloud.capacity.CapacityManager) CallContext(org.apache.cloudstack.context.CallContext) GetVmStatsCommand(com.cloud.agent.api.GetVmStatsCommand) LoadBalancerVMMapDao(com.cloud.network.dao.LoadBalancerVMMapDao) NetworkGuru(com.cloud.network.guru.NetworkGuru) ResourceManager(com.cloud.resource.ResourceManager) TemplateApiService(com.cloud.template.TemplateApiService) Set(java.util.Set) ScopeType(com.cloud.storage.ScopeType) UpgradeVMCmd(org.apache.cloudstack.api.command.user.vm.UpgradeVMCmd) DettachCommand(org.apache.cloudstack.storage.command.DettachCommand) OperationTimedoutException(com.cloud.exception.OperationTimedoutException) Executors(java.util.concurrent.Executors) VMTemplateZoneVO(com.cloud.storage.VMTemplateZoneVO) InsufficientCapacityException(com.cloud.exception.InsufficientCapacityException) VMSnapshotManager(com.cloud.vm.snapshot.VMSnapshotManager) VpcVirtualNetworkApplianceManager(com.cloud.network.router.VpcVirtualNetworkApplianceManager) PortForwardingRulesDao(com.cloud.network.rules.dao.PortForwardingRulesDao) GuestOSDao(com.cloud.storage.dao.GuestOSDao) InsufficientAddressCapacityException(com.cloud.exception.InsufficientAddressCapacityException) HypervisorCapabilitiesDao(com.cloud.hypervisor.dao.HypervisorCapabilitiesDao) ServiceOfferingJoinDao(com.cloud.api.query.dao.ServiceOfferingJoinDao) AccountDao(com.cloud.user.dao.AccountDao) AffinityGroupDao(org.apache.cloudstack.affinity.dao.AffinityGroupDao) IpAddressManager(com.cloud.network.IpAddressManager) NumbersUtil(com.cloud.utils.NumbersUtil) PrimaryDataStore(org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStore) UsageEventVO(com.cloud.event.UsageEventVO) StorageUnavailableException(com.cloud.exception.StorageUnavailableException) HTTPMethod(org.apache.cloudstack.api.BaseCmd.HTTPMethod) ArrayList(java.util.ArrayList) VmStatsEntry(com.cloud.agent.api.VmStatsEntry) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) TemplateDataStoreVO(org.apache.cloudstack.storage.datastore.db.TemplateDataStoreVO) StartAnswer(com.cloud.agent.api.StartAnswer) PlannerHostReservationVO(com.cloud.deploy.PlannerHostReservationVO) VmDiskStatsEntry(com.cloud.agent.api.VmDiskStatsEntry) ConfigurationManagerImpl(com.cloud.configuration.ConfigurationManagerImpl) VMInstanceDao(com.cloud.vm.dao.VMInstanceDao) DomainRouterDao(com.cloud.vm.dao.DomainRouterDao) LinkedHashSet(java.util.LinkedHashSet) HypervisorType(com.cloud.hypervisor.Hypervisor.HypervisorType) Journal(com.cloud.utils.Journal) UsageEventDao(com.cloud.event.dao.UsageEventDao) ScaleVMCmd(org.apache.cloudstack.api.command.user.vm.ScaleVMCmd) LoadBalancerVMMapVO(com.cloud.network.dao.LoadBalancerVMMapVO) DeployVMCmdByAdmin(org.apache.cloudstack.api.command.admin.vm.DeployVMCmdByAdmin) ResetVMSSHKeyCmd(org.apache.cloudstack.api.command.user.vm.ResetVMSSHKeyCmd) ResourceTagDao(com.cloud.tags.dao.ResourceTagDao) RestoreVMSnapshotAnswer(com.cloud.agent.api.RestoreVMSnapshotAnswer) VolumeDataFactory(org.apache.cloudstack.engine.subsystem.api.storage.VolumeDataFactory) HostPodDao(com.cloud.dc.dao.HostPodDao) Host(com.cloud.host.Host) ActionEvent(com.cloud.event.ActionEvent) AccountManager(com.cloud.user.AccountManager) DocumentBuilder(javax.xml.parsers.DocumentBuilder) ImageFormat(com.cloud.storage.Storage.ImageFormat) ExcludeList(com.cloud.deploy.DeploymentPlanner.ExcludeList) RulesManager(com.cloud.network.rules.RulesManager) StatsCollector(com.cloud.server.StatsCollector) ManagementService(com.cloud.server.ManagementService) DataStoreDriver(org.apache.cloudstack.engine.subsystem.api.storage.DataStoreDriver) ActionEventUtils(com.cloud.event.ActionEventUtils) TemplateManager(com.cloud.template.TemplateManager) DeleteCommand(org.apache.cloudstack.storage.command.DeleteCommand) RemoveNicFromVMCmd(org.apache.cloudstack.api.command.user.vm.RemoveNicFromVMCmd) VMNetworkMapDao(org.apache.cloudstack.engine.cloud.entity.api.db.dao.VMNetworkMapDao) StoragePoolStatus(com.cloud.storage.StoragePoolStatus) Grouping(com.cloud.org.Grouping) BackupDao(org.apache.cloudstack.backup.dao.BackupDao) NumberUtils(org.apache.commons.lang.math.NumberUtils) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) SecurityGroupDao(com.cloud.network.security.dao.SecurityGroupDao) DataStoreProviderManager(org.apache.cloudstack.engine.subsystem.api.storage.DataStoreProviderManager) Logger(org.apache.log4j.Logger) ResourceAllocationException(com.cloud.exception.ResourceAllocationException) ResourceLimitService(com.cloud.user.ResourceLimitService) SecurityGroup(com.cloud.network.security.SecurityGroup) DomainDao(com.cloud.domain.dao.DomainDao) Ip(com.cloud.utils.net.Ip) TransactionCallbackNoReturn(com.cloud.utils.db.TransactionCallbackNoReturn) ManagedContextRunnable(org.apache.cloudstack.managed.context.ManagedContextRunnable) PrimaryDataStoreDao(org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao) IpAddresses(com.cloud.network.Network.IpAddresses) SSHKeyPair(com.cloud.user.SSHKeyPair) AffinityConflictException(com.cloud.exception.AffinityConflictException) Account(com.cloud.user.Account) DedicatedResourceDao(com.cloud.dc.dao.DedicatedResourceDao) Status(com.cloud.host.Status) VMSnapshotDao(com.cloud.vm.snapshot.dao.VMSnapshotDao) List(java.util.List) DataCenterDao(com.cloud.dc.dao.DataCenterDao) ACLType(org.apache.cloudstack.acl.ControlledEntity.ACLType) ConcurrentOperationException(com.cloud.exception.ConcurrentOperationException) SAXException(org.xml.sax.SAXException) Pattern(java.util.regex.Pattern) UnsupportedEncodingException(java.io.UnsupportedEncodingException) Backup(org.apache.cloudstack.backup.Backup) GetVmIpAddressCommand(com.cloud.agent.api.GetVmIpAddressCommand) OVFNetworkTO(com.cloud.agent.api.to.deployasis.OVFNetworkTO) InstanceGroupVMMapDao(com.cloud.vm.dao.InstanceGroupVMMapDao) VmDiskStatisticsVO(com.cloud.user.VmDiskStatisticsVO) EntityManager(com.cloud.utils.db.EntityManager) VolumeApiService(com.cloud.storage.VolumeApiService) StartVMCmd(org.apache.cloudstack.api.command.user.vm.StartVMCmd) AccessType(org.apache.cloudstack.acl.SecurityChecker.AccessType) HashMap(java.util.HashMap) ConfigurationException(javax.naming.ConfigurationException) AffinityGroupService(org.apache.cloudstack.affinity.AffinityGroupService) NetworkDao(com.cloud.network.dao.NetworkDao) VM_USERDATA_MAX_LENGTH(com.cloud.configuration.ConfigurationManagerImpl.VM_USERDATA_MAX_LENGTH) EventTypes(com.cloud.event.EventTypes) RebootVMCmd(org.apache.cloudstack.api.command.user.vm.RebootVMCmd) GuestOSVO(com.cloud.storage.GuestOSVO) RestoreVMCmd(org.apache.cloudstack.api.command.user.vm.RestoreVMCmd) DataStoreProvider(org.apache.cloudstack.engine.subsystem.api.storage.DataStoreProvider) CollectionUtils(org.apache.commons.collections.CollectionUtils) UserVmDetailsDao(com.cloud.vm.dao.UserVmDetailsDao) NetworkVO(com.cloud.network.dao.NetworkVO) Configurable(org.apache.cloudstack.framework.config.Configurable) VlanType(com.cloud.dc.Vlan.VlanType) GPU(com.cloud.gpu.GPU) AnnotationService(org.apache.cloudstack.annotation.AnnotationService) LoadBalancingRulesManager(com.cloud.network.lb.LoadBalancingRulesManager) SSHKeyPairVO(com.cloud.user.SSHKeyPairVO) VolumeInfo(org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo) AffinityGroupVMMapVO(org.apache.cloudstack.affinity.AffinityGroupVMMapVO) Hypervisor(com.cloud.hypervisor.Hypervisor) ChangeOfferingForVolumeCmd(org.apache.cloudstack.api.command.user.volume.ChangeOfferingForVolumeCmd) VirtualMachineEntity(org.apache.cloudstack.engine.cloud.entity.api.VirtualMachineEntity) GetVmDiskStatsCommand(com.cloud.agent.api.GetVmDiskStatsCommand) DateUtil(com.cloud.utils.DateUtil) TimeUnit(java.util.concurrent.TimeUnit) BackupManager(org.apache.cloudstack.backup.BackupManager) GetVmDiskStatsAnswer(com.cloud.agent.api.GetVmDiskStatsAnswer) NetworkOffering(com.cloud.offering.NetworkOffering) HostPodVO(com.cloud.dc.HostPodVO) VMTemplateZoneDao(com.cloud.storage.dao.VMTemplateZoneDao) DeployVMCmd(org.apache.cloudstack.api.command.user.vm.DeployVMCmd) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) NetworkOfferingDao(com.cloud.offerings.dao.NetworkOfferingDao) RecoverVMCmd(org.apache.cloudstack.api.command.admin.vm.RecoverVMCmd) Volume(com.cloud.storage.Volume) RestoreVMSnapshotCommand(com.cloud.agent.api.RestoreVMSnapshotCommand) DomainVO(com.cloud.domain.DomainVO) ManagementServerException(com.cloud.exception.ManagementServerException) FirewallRuleVO(com.cloud.network.rules.FirewallRuleVO) Provider(com.cloud.network.Network.Provider) UserStatisticsVO(com.cloud.user.UserStatisticsVO) VolumeVO(com.cloud.storage.VolumeVO) NetworkHelper(com.cloud.network.router.NetworkHelper) NetworkVO(com.cloud.network.dao.NetworkVO) ServiceOffering(com.cloud.offering.ServiceOffering) VMTemplateVO(com.cloud.storage.VMTemplateVO) ArrayList(java.util.ArrayList) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) Network(com.cloud.network.Network) PhysicalNetwork(com.cloud.network.PhysicalNetwork)

Aggregations

UserVm (com.cloud.uservm.UserVm)196 ServerApiException (com.cloud.api.ServerApiException)59 UserVmResponse (com.cloud.api.response.UserVmResponse)59 ArrayList (java.util.ArrayList)54 ServerApiException (org.apache.cloudstack.api.ServerApiException)48 UserVmResponse (org.apache.cloudstack.api.response.UserVmResponse)47 ResourceUnavailableException (com.cloud.exception.ResourceUnavailableException)32 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)30 ConcurrentOperationException (com.cloud.exception.ConcurrentOperationException)28 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)28 Network (com.cloud.network.Network)26 Account (com.cloud.user.Account)22 InsufficientCapacityException (com.cloud.exception.InsufficientCapacityException)21 ManagementServerException (com.cloud.exception.ManagementServerException)21 HashMap (java.util.HashMap)16 ServiceOffering (com.cloud.offering.ServiceOffering)15 DataCenter (com.cloud.dc.DataCenter)14 List (java.util.List)14 ActionEvent (com.cloud.event.ActionEvent)12 VirtualMachineMigrationException (com.cloud.exception.VirtualMachineMigrationException)12