578578import com .cloud .host .dao .HostDao ;
579579import com .cloud .host .dao .HostDetailsDao ;
580580import com .cloud .host .dao .HostTagsDao ;
581+ import com .cloud .hypervisor .Hypervisor ;
581582import com .cloud .hypervisor .Hypervisor .HypervisorType ;
582583import com .cloud .hypervisor .HypervisorCapabilities ;
583584import com .cloud .hypervisor .HypervisorCapabilitiesVO ;
@@ -762,8 +763,6 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
762763 private ImageStoreDao _imgStoreDao ;
763764 @ Inject
764765 private ServiceOfferingDetailsDao _serviceOfferingDetailsDao ;
765-
766-
767766 @ Inject
768767 private ProjectManager _projectMgr ;
769768 @ Inject
@@ -801,6 +800,8 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
801800
802801 protected List <DeploymentPlanner > _planners ;
803802
803+ private final List <HypervisorType > supportedHypervisors = new ArrayList <Hypervisor .HypervisorType >();
804+
804805 public List <DeploymentPlanner > getPlanners () {
805806 return _planners ;
806807 }
@@ -879,6 +880,9 @@ public boolean configure(final String name, final Map<String, Object> params) th
879880 _availableIdsMap .put (id , true );
880881 }
881882
883+ supportedHypervisors .add (HypervisorType .KVM );
884+ supportedHypervisors .add (HypervisorType .XenServer );
885+
882886 return true ;
883887 }
884888
@@ -3778,7 +3782,7 @@ public boolean updateClusterPassword(final UpdateHostPasswordCmd command) {
37783782 }
37793783
37803784 final ClusterVO cluster = ApiDBUtils .findClusterById (command .getClusterId ());
3781- if (cluster == null || cluster . getHypervisorType () != HypervisorType . XenServer || cluster .getHypervisorType () != HypervisorType . KVM ) {
3785+ if (cluster == null || ! supportedHypervisors . contains ( cluster .getHypervisorType ()) ) {
37823786 throw new InvalidParameterValueException ("This operation is not supported for this hypervisor type" );
37833787 }
37843788 return updateHostsInCluster (command );
@@ -3793,10 +3797,9 @@ public boolean updateHostPassword(final UpdateHostPasswordCmd cmd) {
37933797
37943798 final HostVO host = _hostDao .findById (cmd .getHostId ());
37953799
3796- if (host . getHypervisorType () != HypervisorType . XenServer || host .getHypervisorType () != HypervisorType . KVM ) {
3800+ if (! supportedHypervisors . contains ( host .getHypervisorType ()) ) {
37973801 throw new InvalidParameterValueException ("This operation is not supported for this hypervisor type" );
37983802 }
3799-
38003803 Transaction .execute (new TransactionCallbackNoReturn () {
38013804 @ Override
38023805 public void doInTransactionWithoutResult (final TransactionStatus status ) {
@@ -3816,7 +3819,6 @@ public void doInTransactionWithoutResult(final TransactionStatus status) {
38163819 }
38173820 }
38183821 });
3819-
38203822 return true ;
38213823 }
38223824
0 commit comments