@@ -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
0 commit comments