Skip to content

Commit 1cb0ce4

Browse files
author
Prachi Damle
committed
Removing BareMetalService referrences. We will load UserVMService by default.
1 parent 434c21a commit 1cb0ce4

10 files changed

Lines changed: 39 additions & 66 deletions

File tree

api/src/com/cloud/vm/VirtualMachine.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ public static boolean isSystemVM(VirtualMachine.Type vmtype) {
257257
/**
258258
* @return data center id.
259259
*/
260-
public long getDataCenterIdToDeployIn();
260+
public long getDataCenterId();
261261

262262
/**
263263
* @return id of the host it was assigned last time.

api/src/org/apache/cloudstack/api/BaseCmd.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,6 @@ public enum CommandType {
111111
@Inject public AutoScaleService _autoScaleService;
112112
@Inject public LoadBalancingRulesService _lbService;
113113
@Inject public RemoteAccessVpnService _ravService;
114-
@Inject public BareMetalVmService _bareMetalVmService;
115114
@Inject public ProjectService _projectService;
116115
@Inject public FirewallService _firewallService;
117116
@Inject public DomainService _domainService;

api/src/org/apache/cloudstack/api/command/user/template/CreateTemplateCmd.java

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -239,33 +239,23 @@ private boolean isBareMetal() {
239239

240240
@Override
241241
public void create() throws ResourceAllocationException {
242-
if (isBareMetal()) {
243-
_bareMetalVmService.createPrivateTemplateRecord(this, _accountService.getAccount(getEntityOwnerId()));
244-
/*Baremetal creates template record after taking image proceeded, use vmId as entity id and uuid here*/
245-
this.setEntityId(vmId);
246-
this.setEntityUuid(vmId.toString());
242+
VirtualMachineTemplate template = null;
243+
template = _userVmService.createPrivateTemplateRecord(this, _accountService.getAccount(getEntityOwnerId()));
244+
if (template != null) {
245+
this.setEntityId(template.getId());
246+
this.setEntityUuid(template.getUuid());
247247
} else {
248-
VirtualMachineTemplate template = null;
249-
template = _userVmService.createPrivateTemplateRecord(this, _accountService.getAccount(getEntityOwnerId()));
250-
if (template != null) {
251-
this.setEntityId(template.getId());
252-
this.setEntityUuid(template.getUuid());
253-
} else {
254-
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR,
255-
"Failed to create a template");
256-
}
248+
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR,
249+
"Failed to create a template");
257250
}
251+
258252
}
259253

260254
@Override
261255
public void execute() {
262256
UserContext.current().setEventDetails("Template Id: "+getEntityId()+((getSnapshotId() == null) ? " from volume Id: " + getVolumeId() : " from snapshot Id: " + getSnapshotId()));
263257
VirtualMachineTemplate template = null;
264-
if (isBareMetal()) {
265-
template = _bareMetalVmService.createPrivateTemplate(this);
266-
} else {
267-
template = _userVmService.createPrivateTemplate(this);
268-
}
258+
template = _userVmService.createPrivateTemplate(this);
269259

270260
if (template != null){
271261
List<TemplateResponse> templateResponses;

api/src/org/apache/cloudstack/api/command/user/vm/DeployVMCmd.java

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -361,11 +361,7 @@ public void execute(){
361361
if (getStartVm()) {
362362
try {
363363
UserContext.current().setEventDetails("Vm Id: "+getEntityId());
364-
if (getHypervisor() == HypervisorType.BareMetal) {
365-
result = _bareMetalVmService.startVirtualMachine(this);
366-
} else {
367-
result = _userVmService.startVirtualMachine(this);
368-
}
364+
result = _userVmService.startVirtualMachine(this);
369365
} catch (ResourceUnavailableException ex) {
370366
s_logger.warn("Exception: ", ex);
371367
throw new ServerApiException(ApiErrorCode.RESOURCE_UNAVAILABLE_ERROR, ex.getMessage());
@@ -430,27 +426,23 @@ public void create() throws ResourceAllocationException{
430426
}
431427

432428
UserVm vm = null;
433-
if (getHypervisor() == HypervisorType.BareMetal) {
434-
vm = _bareMetalVmService.createVirtualMachine(this);
429+
if (zone.getNetworkType() == NetworkType.Basic) {
430+
if (getNetworkIds() != null) {
431+
throw new InvalidParameterValueException("Can't specify network Ids in Basic zone");
432+
} else {
433+
vm = _userVmService.createBasicSecurityGroupVirtualMachine(zone, serviceOffering, template, getSecurityGroupIdList(), owner, name,
434+
displayName, diskOfferingId, size, group, getHypervisor(), userData, sshKeyPairName, getIpToNetworkMap(), ipAddress, keyboard);
435+
}
435436
} else {
436-
if (zone.getNetworkType() == NetworkType.Basic) {
437-
if (getNetworkIds() != null) {
438-
throw new InvalidParameterValueException("Can't specify network Ids in Basic zone");
439-
} else {
440-
vm = _userVmService.createBasicSecurityGroupVirtualMachine(zone, serviceOffering, template, getSecurityGroupIdList(), owner, name,
441-
displayName, diskOfferingId, size, group, getHypervisor(), userData, sshKeyPairName, getIpToNetworkMap(), ipAddress, keyboard);
442-
}
437+
if (zone.isSecurityGroupEnabled()) {
438+
vm = _userVmService.createAdvancedSecurityGroupVirtualMachine(zone, serviceOffering, template, getNetworkIds(), getSecurityGroupIdList(),
439+
owner, name, displayName, diskOfferingId, size, group, getHypervisor(), userData, sshKeyPairName, getIpToNetworkMap(), ipAddress, keyboard);
443440
} else {
444-
if (zone.isSecurityGroupEnabled()) {
445-
vm = _userVmService.createAdvancedSecurityGroupVirtualMachine(zone, serviceOffering, template, getNetworkIds(), getSecurityGroupIdList(),
446-
owner, name, displayName, diskOfferingId, size, group, getHypervisor(), userData, sshKeyPairName, getIpToNetworkMap(), ipAddress, keyboard);
447-
} else {
448-
if (getSecurityGroupIdList() != null && !getSecurityGroupIdList().isEmpty()) {
449-
throw new InvalidParameterValueException("Can't create vm with security groups; security group feature is not enabled per zone");
450-
}
451-
vm = _userVmService.createAdvancedVirtualMachine(zone, serviceOffering, template, getNetworkIds(), owner, name, displayName,
452-
diskOfferingId, size, group, getHypervisor(), userData, sshKeyPairName, getIpToNetworkMap(), ipAddress, keyboard);
441+
if (getSecurityGroupIdList() != null && !getSecurityGroupIdList().isEmpty()) {
442+
throw new InvalidParameterValueException("Can't create vm with security groups; security group feature is not enabled per zone");
453443
}
444+
vm = _userVmService.createAdvancedVirtualMachine(zone, serviceOffering, template, getNetworkIds(), owner, name, displayName,
445+
diskOfferingId, size, group, getHypervisor(), userData, sshKeyPairName, getIpToNetworkMap(), ipAddress, keyboard);
454446
}
455447
}
456448

api/src/org/apache/cloudstack/api/command/user/vm/DestroyVMCmd.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,7 @@ public Long getInstanceId() {
9797
public void execute() throws ResourceUnavailableException, ConcurrentOperationException{
9898
UserContext.current().setEventDetails("Vm Id: "+getId());
9999
UserVm result;
100-
if (_userVmService.getHypervisorTypeOfUserVM(getId()) == HypervisorType.BareMetal) {
101-
result = _bareMetalVmService.destroyVm(this);
102-
} else {
103-
result = _userVmService.destroyVm(this);
104-
}
100+
result = _userVmService.destroyVm(this);
105101

106102
if (result != null) {
107103
UserVmResponse response = _responseGenerator.createUserVmResponse("virtualmachine", result).get(0);

api/src/org/apache/cloudstack/api/command/user/vm/RebootVMCmd.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,7 @@ public Long getInstanceId() {
9696
public void execute() throws ResourceUnavailableException, InsufficientCapacityException{
9797
UserContext.current().setEventDetails("Vm Id: "+getId());
9898
UserVm result;
99-
if (_userVmService.getHypervisorTypeOfUserVM(getId()) == HypervisorType.BareMetal) {
100-
result = _bareMetalVmService.rebootVirtualMachine(this);
101-
} else {
102-
result = _userVmService.rebootVirtualMachine(this);
103-
}
99+
result = _userVmService.rebootVirtualMachine(this);
104100

105101
if (result !=null){
106102
UserVmResponse response = _responseGenerator.createUserVmResponse("virtualmachine", result).get(0);

api/src/org/apache/cloudstack/api/command/user/vm/StartVMCmd.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,7 @@ public void execute() throws ResourceUnavailableException, InsufficientCapacityE
117117
UserContext.current().setEventDetails("Vm Id: " + getId());
118118

119119
UserVm result ;
120-
if (_userVmService.getHypervisorTypeOfUserVM(getId()) == HypervisorType.BareMetal) {
121-
result = _bareMetalVmService.startVirtualMachine(this);
122-
} else {
123-
result = _userVmService.startVirtualMachine(this);
124-
}
120+
result = _userVmService.startVirtualMachine(this);
125121

126122
if (result != null) {
127123
UserVmResponse response = _responseGenerator.createUserVmResponse("virtualmachine", result).get(0);

api/src/org/apache/cloudstack/api/command/user/vm/StopVMCmd.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,7 @@ public void execute() throws ServerApiException, ConcurrentOperationException {
114114
UserContext.current().setEventDetails("Vm Id: " + getId());
115115
UserVm result;
116116

117-
if (_userVmService.getHypervisorTypeOfUserVM(getId()) == HypervisorType.BareMetal) {
118-
result = _bareMetalVmService.stopVirtualMachine(getId(), isForced());
119-
} else {
120-
result = _userVmService.stopVirtualMachine(getId(), isForced());
121-
}
117+
result = _userVmService.stopVirtualMachine(getId(), isForced());
122118

123119
if (result != null) {
124120
UserVmResponse response = _responseGenerator.createUserVmResponse("virtualmachine", result).get(0);

client/tomcatconf/componentContext.xml.in

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@
4343
<bean id="clusteredAgentManagerImpl" class="com.cloud.agent.manager.ClusteredAgentManagerImpl" />
4444
<bean id="clusteredVirtualMachineManagerImpl" class="com.cloud.vm.ClusteredVirtualMachineManagerImpl" />
4545
<bean id="highAvailabilityManagerExtImpl" class="com.cloud.ha.HighAvailabilityManagerExtImpl" />
46-
<bean id="bareMetalVmManagerImpl" class="com.cloud.baremetal.BareMetalVmManagerImpl" />
46+
<!-- bean id="bareMetalVmManagerImpl" class="com.cloud.baremetal.BareMetalVmManagerImpl" / -->
47+
<bean id="userVmManagerImpl" class="com.cloud.vm.UserVmManagerImpl" />
4748
<bean id="consoleProxyManagerImpl" class="com.cloud.consoleproxy.ConsoleProxyManagerImpl" />
4849
<bean id="securityGroupManagerImpl2" class="com.cloud.network.security.SecurityGroupManagerImpl2" />
4950
<bean id="premiumSecondaryStorageManagerImpl" class="com.cloud.secstorage.PremiumSecondaryStorageManagerImpl" />

setup/db/4.1-new-db-schema.sql

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@ alter table template_spool_ref add update_count bigint unsigned;
2424
alter table volumes add disk_type varchar(255);
2525
alter table volumes drop foreign key `fk_volumes__account_id`;
2626
alter table vm_instance add column disk_offering_id bigint unsigned;
27+
alter table vm_instance add column cpu int(10) unsigned;
28+
alter table vm_instance add column ram bigint unsigned;
29+
alter table vm_instance add column owner varchar(255);
30+
alter table vm_instance add column speed int(10) unsigned;
31+
alter table vm_instance add column host_name varchar(255);
32+
alter table vm_instance add column display_name varchar(255);
33+
2734
alter table data_center add column owner varchar(255);
2835
alter table data_center add column created datetime COMMENT 'date created';
2936
alter table data_center add column lastUpdated datetime COMMENT 'last updated';
@@ -90,7 +97,7 @@ CREATE TABLE `cloud`.`vm_reservation` (
9097
`id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
9198
`uuid` varchar(40) NOT NULL COMMENT 'reservation id',
9299
`vm_id` bigint unsigned NOT NULL COMMENT 'vm id',
93-
`datacenter_id` bigint unsigned NOT NULL COMMENT 'zone id',
100+
`data_center_id` bigint unsigned NOT NULL COMMENT 'zone id',
94101
`pod_id` bigint unsigned NOT NULL COMMENT 'pod id',
95102
`cluster_id` bigint unsigned NOT NULL COMMENT 'cluster id',
96103
`host_id` bigint unsigned NOT NULL COMMENT 'host id',

0 commit comments

Comments
 (0)