Skip to content

Commit dcef281

Browse files
frankfrank
authored andcommitted
CloudStack CLOUDSTACK-723
Enhanced baremetal servers support on Cisco UCS change API response in line with new API response convention Conflicts: api/src/org/apache/cloudstack/api/ApiConstants.java
1 parent 558b808 commit dcef281

14 files changed

Lines changed: 240 additions & 114 deletions

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,10 @@ public class ApiConstants {
454454
public static final String GUEST_VM_CIDR = "guestvmcidr";
455455
public static final String NETWORK_CIDR = "networkcidr";
456456
public static final String RESERVED_IP_RANGE = "reservediprange";
457+
public static final String UCS_MANAGER_ID = "ucsmanagerid";
458+
public static final String UCS_PROFILE_DN = "profiledn";
459+
public static final String UCS_BLADE_DN = "bladedn";
460+
public static final String UCS_BLADE_ID = "bladeid";
457461

458462
public enum HostDetails {
459463
all, capacity, events, stats, min;

‎plugins/hypervisors/ucs/src/com/cloud/ucs/database/UcsBladeVO.java‎

100644100755
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ public class UcsBladeVO {
4141
private Long hostId;
4242

4343
@Column(name="dn")
44-
private String dn;
45-
44+
private String dn;
45+
4646
public long getId() {
4747
return id;
4848
}
@@ -81,5 +81,5 @@ public String getUuid() {
8181

8282
public void setUuid(String uuid) {
8383
this.uuid = uuid;
84-
}
84+
}
8585
}

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

100644100755
Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import org.apache.cloudstack.api.BaseCmd.CommandType;
2626
import org.apache.cloudstack.api.Parameter;
2727
import org.apache.cloudstack.api.ServerApiException;
28+
import org.apache.cloudstack.api.response.ZoneResponse;
2829
import org.apache.log4j.Logger;
2930

3031
import com.cloud.exception.ConcurrentOperationException;
@@ -35,33 +36,33 @@
3536
import com.cloud.server.ManagementService;
3637
import com.cloud.user.Account;
3738

38-
@APICommand(description="Adds a Ucs manager", responseObject=AddUcsManagerResponse.class)
39+
@APICommand(name="addUcsManager", description="Adds a Ucs manager", responseObject=UcsManagerResponse.class)
3940
public class AddUcsManagerCmd extends BaseCmd {
4041
public static final Logger s_logger = Logger.getLogger(AddUcsManagerCmd.class);
4142

4243
@Inject
4344
private UcsManager mgr;
4445

45-
@Parameter(name=ApiConstants.ZONE_ID, type=CommandType.LONG, description="the Zone id for the ucs manager", required=true)
46+
@Parameter(name=ApiConstants.ZONE_ID, type=CommandType.UUID, description="the Zone id for the ucs manager", entityType=ZoneResponse.class, required=true)
4647
private Long zoneId;
4748

4849
@Parameter(name=ApiConstants.NAME, type=CommandType.STRING, description="the name of UCS manager")
4950
private String name;
5051

51-
@Parameter(name=ApiConstants.URL, type=CommandType.STRING, description="the name of UCS url")
52+
@Parameter(name=ApiConstants.URL, type=CommandType.STRING, description="the name of UCS url", required=true)
5253
private String url;
5354

54-
@Parameter(name=ApiConstants.USERNAME, type=CommandType.STRING, description="the username of UCS")
55+
@Parameter(name=ApiConstants.USERNAME, type=CommandType.STRING, description="the username of UCS", required=true)
5556
private String username;
5657

57-
@Parameter(name=ApiConstants.PASSWORD, type=CommandType.STRING, description="the password of UCS")
58+
@Parameter(name=ApiConstants.PASSWORD, type=CommandType.STRING, description="the password of UCS", required=true)
5859
private String password;
5960

6061
@Override
6162
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException,
6263
ResourceAllocationException, NetworkRuleConflictException {
6364
try {
64-
AddUcsManagerResponse rsp = mgr.addUcsManager(this);
65+
UcsManagerResponse rsp = mgr.addUcsManager(this);
6566
rsp.setObjectName("ucsmanager");
6667
rsp.setResponseName(getCommandName());
6768
this.setResponseObject(rsp);

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

100644100755
Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@
1919
import javax.inject.Inject;
2020

2121
import org.apache.cloudstack.api.APICommand;
22+
import org.apache.cloudstack.api.ApiConstants;
2223
import org.apache.cloudstack.api.ApiErrorCode;
2324
import org.apache.cloudstack.api.BaseCmd;
25+
import org.apache.cloudstack.api.Parameter;
2426
import org.apache.cloudstack.api.ServerApiException;
2527
import org.apache.log4j.Logger;
2628

@@ -30,23 +32,26 @@
3032
import com.cloud.exception.ResourceAllocationException;
3133
import com.cloud.exception.ResourceUnavailableException;
3234
import com.cloud.user.Account;
33-
@APICommand(description="associate a profile to a blade", responseObject=AssociateUcsProfileToBladesInClusterResponse.class)
35+
@APICommand(name="associatesUscProfileToBlade", description="associate a profile to a blade", responseObject=AssociateUcsProfileToBladeResponse.class)
3436
public class AssociateUcsProfileToBladeCmd extends BaseCmd {
3537
public static final Logger s_logger = Logger.getLogger(AssociateUcsProfileToBladeCmd.class);
3638

3739
@Inject
3840
private UcsManager mgr;
39-
41+
42+
@Parameter(name=ApiConstants.UCS_MANAGER_ID, type=CommandType.UUID, description="ucs manager id", entityType=UcsManagerResponse.class, required=true)
4043
private Long ucsManagerId;
44+
@Parameter(name=ApiConstants.UCS_PROFILE_DN, type=CommandType.STRING, description="profile dn", required=true)
4145
private String profileDn;
46+
@Parameter(name=ApiConstants.UCS_BLADE_ID, type=CommandType.UUID, description="blade id", required=true)
4247
private Long bladeId;
4348

4449
@Override
4550
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException,
4651
ResourceAllocationException, NetworkRuleConflictException {
4752
try {
4853
mgr.associateProfileToBlade(this);
49-
AssociateUcsProfileToBladesInClusterResponse rsp = new AssociateUcsProfileToBladesInClusterResponse();
54+
AssociateUcsProfileToBladeResponse rsp = new AssociateUcsProfileToBladeResponse();
5055
rsp.setResponseName(getCommandName());
5156
rsp.setObjectName("associateucsprofiletobalde");
5257
this.setResponseObject(rsp);

plugins/hypervisors/ucs/src/com/cloud/ucs/manager/AssociateUcsProfileToBladesInClusterResponse.java renamed to plugins/hypervisors/ucs/src/com/cloud/ucs/manager/AssociateUcsProfileToBladeResponse.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@
1818

1919
import org.apache.cloudstack.api.BaseResponse;
2020

21-
public class AssociateUcsProfileToBladesInClusterResponse extends BaseResponse {
21+
public class AssociateUcsProfileToBladeResponse extends BaseResponse {
2222
}
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
package com.cloud.ucs.manager;
2+
3+
import javax.inject.Inject;
4+
5+
import org.apache.cloudstack.api.APICommand;
6+
import org.apache.cloudstack.api.ApiConstants;
7+
import org.apache.cloudstack.api.ApiErrorCode;
8+
import org.apache.cloudstack.api.BaseCmd;
9+
import org.apache.cloudstack.api.Parameter;
10+
import org.apache.cloudstack.api.ServerApiException;
11+
import org.apache.cloudstack.api.response.ListResponse;
12+
import org.apache.log4j.Logger;
13+
14+
import com.cloud.exception.ConcurrentOperationException;
15+
import com.cloud.exception.InsufficientCapacityException;
16+
import com.cloud.exception.NetworkRuleConflictException;
17+
import com.cloud.exception.ResourceAllocationException;
18+
import com.cloud.exception.ResourceUnavailableException;
19+
import com.cloud.user.Account;
20+
21+
@APICommand(name="listUcsBlade", description="List ucs blades", responseObject=UcsBladeResponse.class)
22+
public class ListUcsBladeCmd extends BaseCmd {
23+
public static final Logger s_logger = Logger.getLogger(ListUcsBladeCmd.class);
24+
25+
@Inject
26+
private UcsManager mgr;
27+
28+
@Parameter(name=ApiConstants.UCS_MANAGER_ID, type=CommandType.UUID, description="ucs manager id", entityType=UcsManagerResponse.class, required=true)
29+
private Long ucsManagerId;
30+
31+
public UcsManager getMgr() {
32+
return mgr;
33+
}
34+
35+
public void setMgr(UcsManager mgr) {
36+
this.mgr = mgr;
37+
}
38+
39+
public Long getUcsManagerId() {
40+
return ucsManagerId;
41+
}
42+
43+
public void setUcsManagerId(Long ucsManagerId) {
44+
this.ucsManagerId = ucsManagerId;
45+
}
46+
47+
@Override
48+
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException,
49+
ResourceAllocationException, NetworkRuleConflictException {
50+
try {
51+
ListResponse<UcsBladeResponse> response = mgr.listUcsBlades(this);
52+
response.setResponseName(getCommandName());
53+
response.setObjectName("ucsblade");
54+
this.setResponseObject(response);
55+
} catch (Exception e) {
56+
s_logger.warn(e.getMessage(), e);
57+
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, e.getMessage());
58+
}
59+
}
60+
61+
@Override
62+
public String getCommandName() {
63+
return "listucsbladeresponse";
64+
}
65+
66+
@Override
67+
public long getEntityOwnerId() {
68+
return Account.ACCOUNT_ID_SYSTEM;
69+
}
70+
}

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

100644100755
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
import com.cloud.exception.ResourceUnavailableException;
3535
import com.cloud.server.ManagementService;
3636
import com.cloud.user.Account;
37-
@APICommand(description="List ucs manager", responseObject=ListUcsManagerResponse.class)
37+
@APICommand(description="List ucs manager", responseObject=UcsManagerResponse.class)
3838
public class ListUcsManagerCmd extends BaseCmd {
3939
public static final Logger s_logger = Logger.getLogger(ListUcsManagerCmd.class);
4040

@@ -48,7 +48,7 @@ public class ListUcsManagerCmd extends BaseCmd {
4848
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException,
4949
ResourceAllocationException, NetworkRuleConflictException {
5050
try {
51-
ListResponse<ListUcsManagerResponse> response = mgr.listUcsManager(this);
51+
ListResponse<UcsManagerResponse> response = mgr.listUcsManager(this);
5252
response.setResponseName(getCommandName());
5353
response.setObjectName("ucsmanager");
5454
this.setResponseObject(response);

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

Lines changed: 0 additions & 58 deletions
This file was deleted.

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

100644100755
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
import com.cloud.exception.ResourceUnavailableException;
3636
import com.cloud.server.ManagementService;
3737
import com.cloud.user.Account;
38-
@APICommand(description="List profile in ucs manager", responseObject=ListUcsProfileResponse.class)
38+
@APICommand(description="List profile in ucs manager", responseObject=UcsProfileResponse.class)
3939
public class ListUcsProfileCmd extends BaseCmd {
4040
public static final Logger s_logger = Logger.getLogger(ListUcsProfileCmd.class);
4141

@@ -56,7 +56,7 @@ public void setUcsManagerId(Long ucsManagerId) {
5656
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException,
5757
ResourceAllocationException, NetworkRuleConflictException {
5858
try {
59-
ListResponse<ListUcsProfileResponse> response = mgr.listUcsProfiles(this);
59+
ListResponse<UcsProfileResponse> response = mgr.listUcsProfiles(this);
6060
response.setResponseName(getCommandName());
6161
response.setObjectName("ucsprofile");
6262
this.setResponseObject(response);
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
package com.cloud.ucs.manager;
2+
3+
import org.apache.cloudstack.api.ApiConstants;
4+
import org.apache.cloudstack.api.BaseResponse;
5+
import org.apache.cloudstack.api.EntityReference;
6+
7+
import com.cloud.serializer.Param;
8+
import com.cloud.ucs.database.UcsBladeVO;
9+
import com.google.gson.annotations.SerializedName;
10+
@EntityReference(value=UcsBladeVO.class)
11+
public class UcsBladeResponse extends BaseResponse {
12+
@SerializedName(ApiConstants.ID)
13+
@Param(description = "ucs blade id")
14+
private String id;
15+
@SerializedName(ApiConstants.UCS_MANAGER_ID)
16+
@Param(description = "ucs manager id")
17+
private String ucsManagerId;
18+
@SerializedName(ApiConstants.HOST_ID)
19+
@Param(description = "cloudstack host id this blade associates to")
20+
private String hostId;
21+
@SerializedName(ApiConstants.UCS_BLADE_DN)
22+
@Param(description = "ucs blade dn")
23+
private String dn;
24+
25+
public String getId() {
26+
return id;
27+
}
28+
29+
public void setId(String id) {
30+
this.id = id;
31+
}
32+
33+
public String getUcsManagerId() {
34+
return ucsManagerId;
35+
}
36+
37+
public void setUcsManagerId(String ucsManagerId) {
38+
this.ucsManagerId = ucsManagerId;
39+
}
40+
41+
public String getHostId() {
42+
return hostId;
43+
}
44+
45+
public void setHostId(String hostId) {
46+
this.hostId = hostId;
47+
}
48+
49+
public String getDn() {
50+
return dn;
51+
}
52+
53+
public void setDn(String dn) {
54+
this.dn = dn;
55+
}
56+
}

0 commit comments

Comments
 (0)