Skip to content

Commit c8ae2a9

Browse files
author
Prachi Damle
committed
API to list planners and set the planner in Service offering
Conflicts: server/src/com/cloud/server/ManagementServerImpl.java setup/db/db/schema-410to420.sql
1 parent cf7d40c commit c8ae2a9

11 files changed

Lines changed: 219 additions & 39 deletions

File tree

api/src/com/cloud/server/ManagementService.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ public interface ManagementService {
123123
/**
124124
* Searches for servers by the specified search criteria Can search by: "name", "type", "state", "dataCenterId",
125125
* "podId"
126-
*
126+
*
127127
* @param cmd
128128
* @return List of Hosts
129129
*/
@@ -407,4 +407,6 @@ public interface ManagementService {
407407
*/
408408
List<? extends Capacity> listTopConsumedResources(ListCapacityCmd cmd);
409409

410+
List<String> listDeploymentPlanners();
411+
410412
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,7 @@ public class ApiConstants {
475475
public static final String HEALTHCHECK_PINGPATH = "pingpath";
476476
public static final String AFFINITY_GROUP_IDS = "affinitygroupids";
477477
public static final String AFFINITY_GROUP_NAMES = "affinitygroupnames";
478+
public static final String DEPLOYMENT_PLANNER = "deploymentplanner";
478479

479480
public enum HostDetails {
480481
all, capacity, events, stats, min;
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
// Licensed to the Apache Software Foundation (ASF) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The ASF licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
package org.apache.cloudstack.api.command.admin.config;
18+
19+
import java.util.ArrayList;
20+
import java.util.List;
21+
22+
import org.apache.cloudstack.api.APICommand;
23+
import org.apache.cloudstack.api.BaseListCmd;
24+
import org.apache.cloudstack.api.response.DeploymentPlannersResponse;
25+
import org.apache.cloudstack.api.response.ListResponse;
26+
import org.apache.log4j.Logger;
27+
28+
@APICommand(name = "listDeploymentPlanners", description = "Lists all DeploymentPlanners available.", responseObject = DeploymentPlannersResponse.class)
29+
public class ListDeploymentPlannersCmd extends BaseListCmd {
30+
public static final Logger s_logger = Logger.getLogger(ListDeploymentPlannersCmd.class.getName());
31+
32+
private static final String s_name = "listdeploymentplannersresponse";
33+
34+
/////////////////////////////////////////////////////
35+
//////////////// API parameters /////////////////////
36+
/////////////////////////////////////////////////////
37+
38+
39+
/////////////////////////////////////////////////////
40+
/////////////////// Accessors ///////////////////////
41+
/////////////////////////////////////////////////////
42+
43+
44+
/////////////////////////////////////////////////////
45+
/////////////// API Implementation///////////////////
46+
/////////////////////////////////////////////////////
47+
48+
@Override
49+
public String getCommandName() {
50+
return s_name;
51+
}
52+
53+
@Override
54+
public void execute(){
55+
List<String> planners = _mgr.listDeploymentPlanners();
56+
ListResponse<DeploymentPlannersResponse> response = new ListResponse<DeploymentPlannersResponse>();
57+
List<DeploymentPlannersResponse> plannerResponses = new ArrayList<DeploymentPlannersResponse>();
58+
59+
for (String planner : planners) {
60+
DeploymentPlannersResponse plannerResponse = new DeploymentPlannersResponse();
61+
plannerResponse.setName(planner);
62+
plannerResponse.setObjectName("deploymentPlanner");
63+
plannerResponses.add(plannerResponse);
64+
}
65+
66+
response.setResponses(plannerResponses);
67+
response.setResponseName(getCommandName());
68+
this.setResponseObject(response);
69+
70+
}
71+
}

api/src/org/apache/cloudstack/api/command/admin/offering/CreateServiceOfferingCmd.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@ public class CreateServiceOfferingCmd extends BaseCmd {
8484
@Parameter(name=ApiConstants.NETWORKRATE, type=CommandType.INTEGER, description="data transfer rate in megabits per second allowed. Supported only for non-System offering and system offerings having \"domainrouter\" systemvmtype")
8585
private Integer networkRate;
8686

87+
@Parameter(name = ApiConstants.DEPLOYMENT_PLANNER, type = CommandType.STRING, description = "The deployment planner heuristics used to deploy a VM of this offering, default \"FirstFitPlanner\".")
88+
private String deploymentPlanner;
89+
8790
/////////////////////////////////////////////////////
8891
/////////////////// Accessors ///////////////////////
8992
/////////////////////////////////////////////////////
@@ -148,6 +151,10 @@ public Integer getNetworkRate() {
148151
return networkRate;
149152
}
150153

154+
public String getDeploymentPlanner() {
155+
return deploymentPlanner;
156+
}
157+
151158
/////////////////////////////////////////////////////
152159
/////////////// API Implementation///////////////////
153160
/////////////////////////////////////////////////////

client/tomcatconf/componentContext.xml.in

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,6 @@
155155
<ref bean="FirstFitPlanner" />
156156
<ref bean="UserDispersingPlanner" />
157157
<ref bean="UserConcentratedPodPlanner" />
158-
159158
<!--
160159
<ref bean="BareMetalPlanner" />
161160
-->
@@ -248,6 +247,4 @@
248247
</list>
249248
</property>
250249
</bean>
251-
252-
253250
</beans>

server/src/com/cloud/configuration/ConfigurationManager.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,11 @@ public interface ConfigurationManager extends ConfigurationService, Manager {
7878
* TODO
7979
* @param id
8080
* @param useVirtualNetwork
81+
* @param deploymentPlanner
8182
* @return ID
8283
*/
8384
ServiceOfferingVO createServiceOffering(long userId, boolean isSystem, VirtualMachine.Type vm_typeType, String name, int cpu, int ramSize, int speed, String displayText, boolean localStorageRequired,
84-
boolean offerHA, boolean limitResourceUse, boolean volatileVm, String tags, Long domainId, String hostTag, Integer networkRate);
85+
boolean offerHA, boolean limitResourceUse, boolean volatileVm, String tags, Long domainId, String hostTag, Integer networkRate, String deploymentPlanner);
8586

8687
/**
8788
* Creates a new disk offering

server/src/com/cloud/configuration/ConfigurationManagerImpl.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1821,16 +1821,16 @@ public ServiceOffering createServiceOffering(CreateServiceOfferingCmd cmd) {
18211821
}
18221822

18231823
return createServiceOffering(userId, cmd.getIsSystem(), vmType, cmd.getServiceOfferingName(), cpuNumber.intValue(), memory.intValue(), cpuSpeed.intValue(), cmd.getDisplayText(),
1824-
localStorageRequired, offerHA, limitCpuUse, volatileVm, cmd.getTags(), cmd.getDomainId(), cmd.getHostTag(), cmd.getNetworkRate());
1824+
localStorageRequired, offerHA, limitCpuUse, volatileVm, cmd.getTags(), cmd.getDomainId(), cmd.getHostTag(), cmd.getNetworkRate(), cmd.getDeploymentPlanner());
18251825
}
18261826

18271827
@Override
18281828
@ActionEvent(eventType = EventTypes.EVENT_SERVICE_OFFERING_CREATE, eventDescription = "creating service offering")
18291829
public ServiceOfferingVO createServiceOffering(long userId, boolean isSystem, VirtualMachine.Type vm_type, String name, int cpu, int ramSize, int speed, String displayText,
1830-
boolean localStorageRequired, boolean offerHA, boolean limitResourceUse, boolean volatileVm, String tags, Long domainId, String hostTag, Integer networkRate) {
1830+
boolean localStorageRequired, boolean offerHA, boolean limitResourceUse, boolean volatileVm, String tags, Long domainId, String hostTag, Integer networkRate, String deploymentPlanner) {
18311831
tags = cleanupTags(tags);
18321832
ServiceOfferingVO offering = new ServiceOfferingVO(name, cpu, ramSize, speed, networkRate, null, offerHA, limitResourceUse, volatileVm, displayText, localStorageRequired, false, tags, isSystem, vm_type,
1833-
domainId, hostTag);
1833+
domainId, hostTag, deploymentPlanner);
18341834

18351835
if ((offering = _serviceOfferingDao.persist(offering)) != null) {
18361836
UserContext.current().setEventDetails("Service offering id=" + offering.getId());

server/src/com/cloud/server/ManagementServerImpl.java

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@
107107
import org.apache.commons.codec.binary.Base64;
108108
import org.apache.log4j.Logger;
109109
import org.springframework.stereotype.Component;
110-
111110
import com.cloud.agent.AgentManager;
112111
import com.cloud.agent.api.GetVncPortAnswer;
113112
import com.cloud.agent.api.GetVncPortCommand;
@@ -136,6 +135,7 @@
136135
import com.cloud.dc.Vlan.VlanType;
137136
import com.cloud.dc.dao.*;
138137
import com.cloud.deploy.DataCenterDeployment;
138+
import com.cloud.deploy.DeploymentPlanner;
139139
import com.cloud.deploy.DeploymentPlanner.ExcludeList;
140140
import com.cloud.domain.DomainVO;
141141
import com.cloud.domain.dao.DomainDao;
@@ -460,6 +460,9 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
460460
private List<UserAuthenticator> _userAuthenticators;
461461
private List<UserAuthenticator> _userPasswordEncoders;
462462

463+
@Inject
464+
protected List<DeploymentPlanner> _planners;
465+
463466
@Inject ClusterManager _clusterMgr;
464467
private String _hashKey = null;
465468

@@ -2301,6 +2304,10 @@ public List<Class<?>> getCommands() {
23012304
cmdList.add(AssignToGlobalLoadBalancerRuleCmd.class);
23022305
cmdList.add(RemoveFromGlobalLoadBalancerRuleCmd.class);
23032306
cmdList.add(ListStorageProvidersCmd.class);
2307+
cmdList.add(CreateAffinityGroupCmd.class);
2308+
cmdList.add(DeleteAffinityGroupCmd.class);
2309+
cmdList.add(ListAffinityGroupsCmd.class);
2310+
cmdList.add(UpdateVMAffinityGroupCmd.class);
23042311
return cmdList;
23052312
}
23062313

@@ -3366,4 +3373,14 @@ public void enableAdminUser(String password) {
33663373

33673374
}
33683375

3376+
@Override
3377+
public List<String> listDeploymentPlanners() {
3378+
List<String> plannersAvailable = new ArrayList<String>();
3379+
for (DeploymentPlanner planner : _planners) {
3380+
plannersAvailable.add(planner.getName());
3381+
}
3382+
3383+
return plannersAvailable;
3384+
}
3385+
33693386
}

0 commit comments

Comments
 (0)