mirror of
				https://github.com/apache/cloudstack.git
				synced 2025-11-04 00:02:37 +01:00 
			
		
		
		
	Removing BareMetalService referrences. We will load UserVMService by default.
This commit is contained in:
		
							parent
							
								
									434c21a149
								
							
						
					
					
						commit
						1cb0ce44df
					
				@ -257,7 +257,7 @@ public interface VirtualMachine extends RunningOn, ControlledEntity, Identity, I
 | 
			
		||||
    /**
 | 
			
		||||
     * @return data center id.
 | 
			
		||||
     */
 | 
			
		||||
    public long getDataCenterIdToDeployIn();
 | 
			
		||||
    public long getDataCenterId();
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @return id of the host it was assigned last time.
 | 
			
		||||
 | 
			
		||||
@ -111,7 +111,6 @@ public abstract class BaseCmd {
 | 
			
		||||
    @Inject public AutoScaleService _autoScaleService;
 | 
			
		||||
    @Inject public LoadBalancingRulesService _lbService;
 | 
			
		||||
    @Inject public RemoteAccessVpnService _ravService;
 | 
			
		||||
    @Inject public BareMetalVmService _bareMetalVmService;
 | 
			
		||||
    @Inject public ProjectService _projectService;
 | 
			
		||||
    @Inject public FirewallService _firewallService;
 | 
			
		||||
    @Inject public DomainService _domainService;
 | 
			
		||||
 | 
			
		||||
@ -239,33 +239,23 @@ import com.cloud.user.UserContext;
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void create() throws ResourceAllocationException {
 | 
			
		||||
        if (isBareMetal()) {
 | 
			
		||||
            _bareMetalVmService.createPrivateTemplateRecord(this, _accountService.getAccount(getEntityOwnerId()));
 | 
			
		||||
            /*Baremetal creates template record after taking image proceeded, use vmId as entity id and uuid here*/
 | 
			
		||||
            this.setEntityId(vmId);
 | 
			
		||||
            this.setEntityUuid(vmId.toString());
 | 
			
		||||
        VirtualMachineTemplate template = null;
 | 
			
		||||
        template = _userVmService.createPrivateTemplateRecord(this, _accountService.getAccount(getEntityOwnerId()));
 | 
			
		||||
        if (template != null) {
 | 
			
		||||
            this.setEntityId(template.getId());
 | 
			
		||||
            this.setEntityUuid(template.getUuid());
 | 
			
		||||
        } else {
 | 
			
		||||
            VirtualMachineTemplate template = null;
 | 
			
		||||
            template = _userVmService.createPrivateTemplateRecord(this, _accountService.getAccount(getEntityOwnerId()));
 | 
			
		||||
            if (template != null) {
 | 
			
		||||
                this.setEntityId(template.getId());
 | 
			
		||||
                this.setEntityUuid(template.getUuid());
 | 
			
		||||
            } else {
 | 
			
		||||
                throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR,
 | 
			
		||||
                "Failed to create a template");
 | 
			
		||||
            }
 | 
			
		||||
            throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR,
 | 
			
		||||
            "Failed to create a template");
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void execute() {
 | 
			
		||||
        UserContext.current().setEventDetails("Template Id: "+getEntityId()+((getSnapshotId() == null) ? " from volume Id: " + getVolumeId() : " from snapshot Id: " + getSnapshotId()));
 | 
			
		||||
        VirtualMachineTemplate template = null;
 | 
			
		||||
        if (isBareMetal()) {
 | 
			
		||||
            template = _bareMetalVmService.createPrivateTemplate(this);
 | 
			
		||||
        } else {
 | 
			
		||||
            template = _userVmService.createPrivateTemplate(this);
 | 
			
		||||
        }
 | 
			
		||||
        template = _userVmService.createPrivateTemplate(this);
 | 
			
		||||
 | 
			
		||||
        if (template != null){
 | 
			
		||||
            List<TemplateResponse> templateResponses;
 | 
			
		||||
 | 
			
		||||
@ -361,11 +361,7 @@ public class DeployVMCmd extends BaseAsyncCreateCmd {
 | 
			
		||||
        if (getStartVm()) {
 | 
			
		||||
            try {
 | 
			
		||||
                UserContext.current().setEventDetails("Vm Id: "+getEntityId());
 | 
			
		||||
                if (getHypervisor() == HypervisorType.BareMetal) {
 | 
			
		||||
                    result = _bareMetalVmService.startVirtualMachine(this);
 | 
			
		||||
                } else {
 | 
			
		||||
                    result = _userVmService.startVirtualMachine(this);
 | 
			
		||||
                }
 | 
			
		||||
                result = _userVmService.startVirtualMachine(this);
 | 
			
		||||
            } catch (ResourceUnavailableException ex) {
 | 
			
		||||
                s_logger.warn("Exception: ", ex);
 | 
			
		||||
                throw new ServerApiException(ApiErrorCode.RESOURCE_UNAVAILABLE_ERROR, ex.getMessage());
 | 
			
		||||
@ -430,27 +426,23 @@ public class DeployVMCmd extends BaseAsyncCreateCmd {
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            UserVm vm = null;
 | 
			
		||||
            if (getHypervisor() == HypervisorType.BareMetal) {
 | 
			
		||||
                vm = _bareMetalVmService.createVirtualMachine(this);
 | 
			
		||||
            } else {
 | 
			
		||||
                if (zone.getNetworkType() == NetworkType.Basic) {
 | 
			
		||||
                    if (getNetworkIds() != null) {
 | 
			
		||||
                        throw new InvalidParameterValueException("Can't specify network Ids in Basic zone");
 | 
			
		||||
                    } else {
 | 
			
		||||
                        vm = _userVmService.createBasicSecurityGroupVirtualMachine(zone, serviceOffering, template, getSecurityGroupIdList(), owner, name,
 | 
			
		||||
                                displayName, diskOfferingId, size, group, getHypervisor(), userData, sshKeyPairName, getIpToNetworkMap(), ipAddress, keyboard);
 | 
			
		||||
                    }
 | 
			
		||||
            if (zone.getNetworkType() == NetworkType.Basic) {
 | 
			
		||||
                if (getNetworkIds() != null) {
 | 
			
		||||
                    throw new InvalidParameterValueException("Can't specify network Ids in Basic zone");
 | 
			
		||||
                } else {
 | 
			
		||||
                    if (zone.isSecurityGroupEnabled())  {
 | 
			
		||||
                        vm = _userVmService.createAdvancedSecurityGroupVirtualMachine(zone, serviceOffering, template, getNetworkIds(), getSecurityGroupIdList(),
 | 
			
		||||
                                owner, name, displayName, diskOfferingId, size, group, getHypervisor(), userData, sshKeyPairName, getIpToNetworkMap(), ipAddress, keyboard);
 | 
			
		||||
                    } else {
 | 
			
		||||
                        if (getSecurityGroupIdList() != null && !getSecurityGroupIdList().isEmpty()) {
 | 
			
		||||
                            throw new InvalidParameterValueException("Can't create vm with security groups; security group feature is not enabled per zone");
 | 
			
		||||
                        }
 | 
			
		||||
                        vm = _userVmService.createAdvancedVirtualMachine(zone, serviceOffering, template, getNetworkIds(), owner, name, displayName,
 | 
			
		||||
                                diskOfferingId, size, group, getHypervisor(), userData, sshKeyPairName, getIpToNetworkMap(), ipAddress, keyboard);
 | 
			
		||||
                    vm = _userVmService.createBasicSecurityGroupVirtualMachine(zone, serviceOffering, template, getSecurityGroupIdList(), owner, name,
 | 
			
		||||
                            displayName, diskOfferingId, size, group, getHypervisor(), userData, sshKeyPairName, getIpToNetworkMap(), ipAddress, keyboard);
 | 
			
		||||
                }
 | 
			
		||||
            } else {
 | 
			
		||||
                if (zone.isSecurityGroupEnabled())  {
 | 
			
		||||
                    vm = _userVmService.createAdvancedSecurityGroupVirtualMachine(zone, serviceOffering, template, getNetworkIds(), getSecurityGroupIdList(),
 | 
			
		||||
                            owner, name, displayName, diskOfferingId, size, group, getHypervisor(), userData, sshKeyPairName, getIpToNetworkMap(), ipAddress, keyboard);
 | 
			
		||||
                } else {
 | 
			
		||||
                    if (getSecurityGroupIdList() != null && !getSecurityGroupIdList().isEmpty()) {
 | 
			
		||||
                        throw new InvalidParameterValueException("Can't create vm with security groups; security group feature is not enabled per zone");
 | 
			
		||||
                    }
 | 
			
		||||
                    vm = _userVmService.createAdvancedVirtualMachine(zone, serviceOffering, template, getNetworkIds(), owner, name, displayName,
 | 
			
		||||
                            diskOfferingId, size, group, getHypervisor(), userData, sshKeyPairName, getIpToNetworkMap(), ipAddress, keyboard);
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -97,11 +97,7 @@ public class DestroyVMCmd extends BaseAsyncCmd {
 | 
			
		||||
    public void execute() throws ResourceUnavailableException, ConcurrentOperationException{
 | 
			
		||||
        UserContext.current().setEventDetails("Vm Id: "+getId());
 | 
			
		||||
        UserVm result;
 | 
			
		||||
        if (_userVmService.getHypervisorTypeOfUserVM(getId()) == HypervisorType.BareMetal) {
 | 
			
		||||
            result = _bareMetalVmService.destroyVm(this);
 | 
			
		||||
        } else {
 | 
			
		||||
            result = _userVmService.destroyVm(this);
 | 
			
		||||
        }
 | 
			
		||||
        result = _userVmService.destroyVm(this);
 | 
			
		||||
 | 
			
		||||
        if (result != null) {
 | 
			
		||||
            UserVmResponse response = _responseGenerator.createUserVmResponse("virtualmachine", result).get(0);
 | 
			
		||||
 | 
			
		||||
@ -96,11 +96,7 @@ public class RebootVMCmd extends BaseAsyncCmd {
 | 
			
		||||
    public void execute() throws ResourceUnavailableException, InsufficientCapacityException{
 | 
			
		||||
        UserContext.current().setEventDetails("Vm Id: "+getId());
 | 
			
		||||
        UserVm result;
 | 
			
		||||
        if (_userVmService.getHypervisorTypeOfUserVM(getId()) == HypervisorType.BareMetal) {
 | 
			
		||||
            result = _bareMetalVmService.rebootVirtualMachine(this);
 | 
			
		||||
        } else {
 | 
			
		||||
            result = _userVmService.rebootVirtualMachine(this);
 | 
			
		||||
        }
 | 
			
		||||
        result = _userVmService.rebootVirtualMachine(this);
 | 
			
		||||
 | 
			
		||||
        if (result !=null){
 | 
			
		||||
            UserVmResponse response = _responseGenerator.createUserVmResponse("virtualmachine", result).get(0);
 | 
			
		||||
 | 
			
		||||
@ -117,11 +117,7 @@ public class StartVMCmd extends BaseAsyncCmd {
 | 
			
		||||
            UserContext.current().setEventDetails("Vm Id: " + getId());
 | 
			
		||||
 | 
			
		||||
            UserVm result ;
 | 
			
		||||
            if (_userVmService.getHypervisorTypeOfUserVM(getId()) == HypervisorType.BareMetal) {
 | 
			
		||||
                result = _bareMetalVmService.startVirtualMachine(this);
 | 
			
		||||
            } else {
 | 
			
		||||
                result = _userVmService.startVirtualMachine(this);
 | 
			
		||||
            }
 | 
			
		||||
            result = _userVmService.startVirtualMachine(this);
 | 
			
		||||
 | 
			
		||||
            if (result != null) {
 | 
			
		||||
                UserVmResponse response = _responseGenerator.createUserVmResponse("virtualmachine", result).get(0);
 | 
			
		||||
 | 
			
		||||
@ -114,11 +114,7 @@ public class StopVMCmd extends BaseAsyncCmd {
 | 
			
		||||
        UserContext.current().setEventDetails("Vm Id: " + getId());
 | 
			
		||||
        UserVm result;
 | 
			
		||||
 | 
			
		||||
        if (_userVmService.getHypervisorTypeOfUserVM(getId()) == HypervisorType.BareMetal) {
 | 
			
		||||
            result = _bareMetalVmService.stopVirtualMachine(getId(), isForced());
 | 
			
		||||
        } else {
 | 
			
		||||
            result = _userVmService.stopVirtualMachine(getId(), isForced());
 | 
			
		||||
        }
 | 
			
		||||
        result = _userVmService.stopVirtualMachine(getId(), isForced());
 | 
			
		||||
 | 
			
		||||
        if (result != null) {
 | 
			
		||||
            UserVmResponse response = _responseGenerator.createUserVmResponse("virtualmachine", result).get(0);
 | 
			
		||||
 | 
			
		||||
@ -43,7 +43,8 @@
 | 
			
		||||
  <bean id="clusteredAgentManagerImpl" class="com.cloud.agent.manager.ClusteredAgentManagerImpl" />
 | 
			
		||||
  <bean id="clusteredVirtualMachineManagerImpl" class="com.cloud.vm.ClusteredVirtualMachineManagerImpl" />
 | 
			
		||||
  <bean id="highAvailabilityManagerExtImpl" class="com.cloud.ha.HighAvailabilityManagerExtImpl" />
 | 
			
		||||
  <bean id="bareMetalVmManagerImpl" class="com.cloud.baremetal.BareMetalVmManagerImpl" />
 | 
			
		||||
  <!-- bean id="bareMetalVmManagerImpl" class="com.cloud.baremetal.BareMetalVmManagerImpl" / -->
 | 
			
		||||
  <bean id="userVmManagerImpl" class="com.cloud.vm.UserVmManagerImpl" />
 | 
			
		||||
  <bean id="consoleProxyManagerImpl" class="com.cloud.consoleproxy.ConsoleProxyManagerImpl" />
 | 
			
		||||
  <bean id="securityGroupManagerImpl2" class="com.cloud.network.security.SecurityGroupManagerImpl2" />
 | 
			
		||||
  <bean id="premiumSecondaryStorageManagerImpl" class="com.cloud.secstorage.PremiumSecondaryStorageManagerImpl" />
 | 
			
		||||
 | 
			
		||||
@ -24,6 +24,13 @@ alter table template_spool_ref add update_count bigint unsigned;
 | 
			
		||||
alter table volumes add disk_type varchar(255);
 | 
			
		||||
alter table volumes drop foreign key `fk_volumes__account_id`;
 | 
			
		||||
alter table vm_instance add column disk_offering_id bigint unsigned;
 | 
			
		||||
alter table vm_instance add column cpu int(10) unsigned;
 | 
			
		||||
alter table vm_instance add column ram bigint unsigned;
 | 
			
		||||
alter table vm_instance add column owner varchar(255);
 | 
			
		||||
alter table vm_instance add column speed int(10) unsigned;
 | 
			
		||||
alter table vm_instance add column host_name varchar(255);
 | 
			
		||||
alter table vm_instance add column display_name varchar(255);
 | 
			
		||||
 | 
			
		||||
alter table data_center add column owner varchar(255);
 | 
			
		||||
alter table data_center add column created datetime COMMENT 'date created';
 | 
			
		||||
alter table data_center add column lastUpdated datetime COMMENT 'last updated';
 | 
			
		||||
@ -90,7 +97,7 @@ CREATE TABLE `cloud`.`vm_reservation` (
 | 
			
		||||
  `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
 | 
			
		||||
  `uuid` varchar(40) NOT NULL COMMENT 'reservation id',
 | 
			
		||||
  `vm_id` bigint unsigned NOT NULL COMMENT 'vm id',
 | 
			
		||||
  `datacenter_id` bigint unsigned NOT NULL COMMENT 'zone id',
 | 
			
		||||
  `data_center_id` bigint unsigned NOT NULL COMMENT 'zone id',
 | 
			
		||||
  `pod_id` bigint unsigned NOT NULL COMMENT 'pod id',
 | 
			
		||||
  `cluster_id` bigint unsigned NOT NULL COMMENT 'cluster id',
 | 
			
		||||
  `host_id` bigint unsigned NOT NULL COMMENT 'host id',
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user