Skip to content

Commit a473e49

Browse files
author
frank
committed
CLOUDSTACK-4093
UCS:API: Need delete UCS_manager API
1 parent 0243f04 commit a473e49

4 files changed

Lines changed: 72 additions & 0 deletions

File tree

‎client/tomcatconf/commands.properties.in‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -617,6 +617,7 @@ listUcsManagers=1
617617
listUcsProfiles=1
618618
listUcsBlades=1
619619
associateUcsProfileToBlade=1
620+
deleteUcsManager=1
620621

621622
#### New Load Balancer commands
622623
createLoadBalancer=15

‎plugins/hypervisors/ucs/src/com/cloud/ucs/manager/UcsManager.java‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,6 @@ public interface UcsManager extends Manager, PluggableService {
4040
UcsBladeResponse associateProfileToBlade(AssociateUcsProfileToBladeCmd cmd);
4141

4242
ListResponse<UcsBladeResponse> listUcsBlades(ListUcsBladeCmd cmd);
43+
44+
void deleteUcsManager(Long id);
4345
}

‎plugins/hypervisors/ucs/src/com/cloud/ucs/manager/UcsManagerImpl.java‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,4 +491,15 @@ public List<Class<?>> getCommands() {
491491
cmds.add(AssociateUcsProfileToBladeCmd.class);
492492
return cmds;
493493
}
494+
495+
@Override
496+
public void deleteUcsManager(Long id) {
497+
SearchCriteriaService<UcsBladeVO, UcsBladeVO> serv = SearchCriteria2.create(UcsBladeVO.class);
498+
serv.addAnd(serv.getEntity().getUcsManagerId(), Op.EQ, id);
499+
List<UcsBladeVO> vos = serv.list();
500+
for (UcsBladeVO vo : vos) {
501+
bladeDao.remove(vo.getId());
502+
}
503+
ucsDao.remove(id);
504+
}
494505
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
package org.apache.cloudstack.api;
2+
3+
import com.cloud.exception.ConcurrentOperationException;
4+
import com.cloud.exception.InsufficientCapacityException;
5+
import com.cloud.exception.NetworkRuleConflictException;
6+
import com.cloud.exception.ResourceAllocationException;
7+
import com.cloud.exception.ResourceUnavailableException;
8+
import com.cloud.ucs.manager.UcsManager;
9+
import com.cloud.user.Account;
10+
import com.cloud.utils.exception.CloudRuntimeException;
11+
12+
import org.apache.cloudstack.api.response.SuccessResponse;
13+
import org.apache.cloudstack.api.response.UcsManagerResponse;
14+
import org.apache.log4j.Logger;
15+
16+
import javax.inject.Inject;
17+
18+
@APICommand(name="deleteUcsManager", description="Delete a Ucs manager", responseObject= SuccessResponse.class)
19+
public class DeleteUcsManagerCmd extends BaseCmd {
20+
private static final Logger logger = Logger.getLogger(DeleteUcsManagerCmd.class);
21+
22+
@Inject
23+
private UcsManager mgr;
24+
25+
@Parameter(name=ApiConstants.UCS_MANAGER_ID, type= BaseCmd.CommandType.UUID, description="ucs manager id", entityType=UcsManagerResponse.class, required=true)
26+
private Long ucsManagerId;
27+
28+
public Long getUcsManagerId() {
29+
return ucsManagerId;
30+
}
31+
32+
@Override
33+
public void execute() throws ResourceUnavailableException,
34+
InsufficientCapacityException, ServerApiException,
35+
ConcurrentOperationException, ResourceAllocationException,
36+
NetworkRuleConflictException {
37+
try {
38+
mgr.deleteUcsManager(ucsManagerId);
39+
SuccessResponse rsp = new SuccessResponse();
40+
rsp.setResponseName(getCommandName());
41+
rsp.setObjectName("success");
42+
this.setResponseObject(rsp);
43+
} catch (Exception e) {
44+
logger.debug(e.getMessage(), e);
45+
throw new CloudRuntimeException(e);
46+
}
47+
}
48+
49+
@Override
50+
public String getCommandName() {
51+
return "deleteUcsManagerResponse";
52+
}
53+
54+
@Override
55+
public long getEntityOwnerId() {
56+
return Account.ACCOUNT_ID_SYSTEM;
57+
}
58+
}

0 commit comments

Comments
 (0)