mirror of https://github.com/apache/cloudstack.git
CloudStack CLOUDSTACK-723
Enhanced baremetal servers support on Cisco UCS change API response in line with new API response convention
This commit is contained in:
parent
ba0d8c67bc
commit
696b4ed8ea
|
|
@ -440,6 +440,10 @@ public class ApiConstants {
|
|||
public static final String AUTOSCALE_USER_ID = "autoscaleuserid";
|
||||
public static final String BAREMETAL_DISCOVER_NAME = "baremetaldiscovername";
|
||||
public static final String UCS_DN = "ucsdn";
|
||||
public static final String UCS_MANAGER_ID = "ucsmanagerid";
|
||||
public static final String UCS_PROFILE_DN = "profiledn";
|
||||
public static final String UCS_BLADE_DN = "bladedn";
|
||||
public static final String UCS_BLADE_ID = "bladeid";
|
||||
|
||||
public enum HostDetails {
|
||||
all, capacity, events, stats, min;
|
||||
|
|
|
|||
|
|
@ -41,8 +41,8 @@ public class UcsBladeVO {
|
|||
private Long hostId;
|
||||
|
||||
@Column(name="dn")
|
||||
private String dn;
|
||||
|
||||
private String dn;
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
|
@ -81,5 +81,5 @@ public class UcsBladeVO {
|
|||
|
||||
public void setUuid(String uuid) {
|
||||
this.uuid = uuid;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
13
plugins/hypervisors/ucs/src/com/cloud/ucs/manager/AddUcsManagerCmd.java
Normal file → Executable file
13
plugins/hypervisors/ucs/src/com/cloud/ucs/manager/AddUcsManagerCmd.java
Normal file → Executable file
|
|
@ -25,6 +25,7 @@ import org.apache.cloudstack.api.BaseCmd;
|
|||
import org.apache.cloudstack.api.BaseCmd.CommandType;
|
||||
import org.apache.cloudstack.api.Parameter;
|
||||
import org.apache.cloudstack.api.ServerApiException;
|
||||
import org.apache.cloudstack.api.response.ZoneResponse;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
|
|
@ -35,33 +36,33 @@ import com.cloud.exception.ResourceUnavailableException;
|
|||
import com.cloud.server.ManagementService;
|
||||
import com.cloud.user.Account;
|
||||
|
||||
@APICommand(description="Adds a Ucs manager", responseObject=AddUcsManagerResponse.class)
|
||||
@APICommand(name="addUcsManager", description="Adds a Ucs manager", responseObject=UcsManagerResponse.class)
|
||||
public class AddUcsManagerCmd extends BaseCmd {
|
||||
public static final Logger s_logger = Logger.getLogger(AddUcsManagerCmd.class);
|
||||
|
||||
@Inject
|
||||
private UcsManager mgr;
|
||||
|
||||
@Parameter(name=ApiConstants.ZONE_ID, type=CommandType.LONG, description="the Zone id for the ucs manager", required=true)
|
||||
@Parameter(name=ApiConstants.ZONE_ID, type=CommandType.UUID, description="the Zone id for the ucs manager", entityType=ZoneResponse.class, required=true)
|
||||
private Long zoneId;
|
||||
|
||||
@Parameter(name=ApiConstants.NAME, type=CommandType.STRING, description="the name of UCS manager")
|
||||
private String name;
|
||||
|
||||
@Parameter(name=ApiConstants.URL, type=CommandType.STRING, description="the name of UCS url")
|
||||
@Parameter(name=ApiConstants.URL, type=CommandType.STRING, description="the name of UCS url", required=true)
|
||||
private String url;
|
||||
|
||||
@Parameter(name=ApiConstants.USERNAME, type=CommandType.STRING, description="the username of UCS")
|
||||
@Parameter(name=ApiConstants.USERNAME, type=CommandType.STRING, description="the username of UCS", required=true)
|
||||
private String username;
|
||||
|
||||
@Parameter(name=ApiConstants.PASSWORD, type=CommandType.STRING, description="the password of UCS")
|
||||
@Parameter(name=ApiConstants.PASSWORD, type=CommandType.STRING, description="the password of UCS", required=true)
|
||||
private String password;
|
||||
|
||||
@Override
|
||||
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException,
|
||||
ResourceAllocationException, NetworkRuleConflictException {
|
||||
try {
|
||||
AddUcsManagerResponse rsp = mgr.addUcsManager(this);
|
||||
UcsManagerResponse rsp = mgr.addUcsManager(this);
|
||||
rsp.setObjectName("ucsmanager");
|
||||
rsp.setResponseName(getCommandName());
|
||||
this.setResponseObject(rsp);
|
||||
|
|
|
|||
11
plugins/hypervisors/ucs/src/com/cloud/ucs/manager/AssociateUcsProfileToBladeCmd.java
Normal file → Executable file
11
plugins/hypervisors/ucs/src/com/cloud/ucs/manager/AssociateUcsProfileToBladeCmd.java
Normal file → Executable file
|
|
@ -19,8 +19,10 @@ package com.cloud.ucs.manager;
|
|||
import javax.inject.Inject;
|
||||
|
||||
import org.apache.cloudstack.api.APICommand;
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import org.apache.cloudstack.api.ApiErrorCode;
|
||||
import org.apache.cloudstack.api.BaseCmd;
|
||||
import org.apache.cloudstack.api.Parameter;
|
||||
import org.apache.cloudstack.api.ServerApiException;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
|
|
@ -30,15 +32,18 @@ import com.cloud.exception.NetworkRuleConflictException;
|
|||
import com.cloud.exception.ResourceAllocationException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.user.Account;
|
||||
@APICommand(description="associate a profile to a blade", responseObject=AssociateUcsProfileToBladesInClusterResponse.class)
|
||||
@APICommand(name="associatesUscProfileToBlade", description="associate a profile to a blade", responseObject=AssociateUcsProfileToBladeResponse.class)
|
||||
public class AssociateUcsProfileToBladeCmd extends BaseCmd {
|
||||
public static final Logger s_logger = Logger.getLogger(AssociateUcsProfileToBladeCmd.class);
|
||||
|
||||
@Inject
|
||||
private UcsManager mgr;
|
||||
|
||||
|
||||
@Parameter(name=ApiConstants.UCS_MANAGER_ID, type=CommandType.UUID, description="ucs manager id", entityType=UcsManagerResponse.class, required=true)
|
||||
private Long ucsManagerId;
|
||||
@Parameter(name=ApiConstants.UCS_PROFILE_DN, type=CommandType.STRING, description="profile dn", required=true)
|
||||
private String profileDn;
|
||||
@Parameter(name=ApiConstants.UCS_BLADE_ID, type=CommandType.UUID, description="blade id", required=true)
|
||||
private Long bladeId;
|
||||
|
||||
@Override
|
||||
|
|
@ -46,7 +51,7 @@ public class AssociateUcsProfileToBladeCmd extends BaseCmd {
|
|||
ResourceAllocationException, NetworkRuleConflictException {
|
||||
try {
|
||||
mgr.associateProfileToBlade(this);
|
||||
AssociateUcsProfileToBladesInClusterResponse rsp = new AssociateUcsProfileToBladesInClusterResponse();
|
||||
AssociateUcsProfileToBladeResponse rsp = new AssociateUcsProfileToBladeResponse();
|
||||
rsp.setResponseName(getCommandName());
|
||||
rsp.setObjectName("associateucsprofiletobalde");
|
||||
this.setResponseObject(rsp);
|
||||
|
|
|
|||
|
|
@ -18,5 +18,5 @@ package com.cloud.ucs.manager;
|
|||
|
||||
import org.apache.cloudstack.api.BaseResponse;
|
||||
|
||||
public class AssociateUcsProfileToBladesInClusterResponse extends BaseResponse {
|
||||
public class AssociateUcsProfileToBladeResponse extends BaseResponse {
|
||||
}
|
||||
|
|
@ -0,0 +1,70 @@
|
|||
package com.cloud.ucs.manager;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.apache.cloudstack.api.APICommand;
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import org.apache.cloudstack.api.ApiErrorCode;
|
||||
import org.apache.cloudstack.api.BaseCmd;
|
||||
import org.apache.cloudstack.api.Parameter;
|
||||
import org.apache.cloudstack.api.ServerApiException;
|
||||
import org.apache.cloudstack.api.response.ListResponse;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.InsufficientCapacityException;
|
||||
import com.cloud.exception.NetworkRuleConflictException;
|
||||
import com.cloud.exception.ResourceAllocationException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.user.Account;
|
||||
|
||||
@APICommand(name="listUcsBlade", description="List ucs blades", responseObject=UcsBladeResponse.class)
|
||||
public class ListUcsBladeCmd extends BaseCmd {
|
||||
public static final Logger s_logger = Logger.getLogger(ListUcsBladeCmd.class);
|
||||
|
||||
@Inject
|
||||
private UcsManager mgr;
|
||||
|
||||
@Parameter(name=ApiConstants.UCS_MANAGER_ID, type=CommandType.UUID, description="ucs manager id", entityType=UcsManagerResponse.class, required=true)
|
||||
private Long ucsManagerId;
|
||||
|
||||
public UcsManager getMgr() {
|
||||
return mgr;
|
||||
}
|
||||
|
||||
public void setMgr(UcsManager mgr) {
|
||||
this.mgr = mgr;
|
||||
}
|
||||
|
||||
public Long getUcsManagerId() {
|
||||
return ucsManagerId;
|
||||
}
|
||||
|
||||
public void setUcsManagerId(Long ucsManagerId) {
|
||||
this.ucsManagerId = ucsManagerId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException,
|
||||
ResourceAllocationException, NetworkRuleConflictException {
|
||||
try {
|
||||
ListResponse<UcsBladeResponse> response = mgr.listUcsBlades(this);
|
||||
response.setResponseName(getCommandName());
|
||||
response.setObjectName("ucsblade");
|
||||
this.setResponseObject(response);
|
||||
} catch (Exception e) {
|
||||
s_logger.warn(e.getMessage(), e);
|
||||
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return "listucsbladeresponse";
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getEntityOwnerId() {
|
||||
return Account.ACCOUNT_ID_SYSTEM;
|
||||
}
|
||||
}
|
||||
4
plugins/hypervisors/ucs/src/com/cloud/ucs/manager/ListUcsManagerCmd.java
Normal file → Executable file
4
plugins/hypervisors/ucs/src/com/cloud/ucs/manager/ListUcsManagerCmd.java
Normal file → Executable file
|
|
@ -34,7 +34,7 @@ import com.cloud.exception.ResourceAllocationException;
|
|||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.server.ManagementService;
|
||||
import com.cloud.user.Account;
|
||||
@APICommand(description="List ucs manager", responseObject=ListUcsManagerResponse.class)
|
||||
@APICommand(description="List ucs manager", responseObject=UcsManagerResponse.class)
|
||||
public class ListUcsManagerCmd extends BaseCmd {
|
||||
public static final Logger s_logger = Logger.getLogger(ListUcsManagerCmd.class);
|
||||
|
||||
|
|
@ -48,7 +48,7 @@ public class ListUcsManagerCmd extends BaseCmd {
|
|||
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException,
|
||||
ResourceAllocationException, NetworkRuleConflictException {
|
||||
try {
|
||||
ListResponse<ListUcsManagerResponse> response = mgr.listUcsManager(this);
|
||||
ListResponse<UcsManagerResponse> response = mgr.listUcsManager(this);
|
||||
response.setResponseName(getCommandName());
|
||||
response.setObjectName("ucsmanager");
|
||||
this.setResponseObject(response);
|
||||
|
|
|
|||
|
|
@ -1,58 +0,0 @@
|
|||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
package com.cloud.ucs.manager;
|
||||
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import org.apache.cloudstack.api.BaseResponse;
|
||||
|
||||
import com.cloud.serializer.Param;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
public class ListUcsManagerResponse extends BaseResponse {
|
||||
@SerializedName(ApiConstants.ID) @Param(description="id of ucs manager")
|
||||
private String id;
|
||||
|
||||
@SerializedName(ApiConstants.NAME) @Param(description="name of ucs manager")
|
||||
private String name;
|
||||
|
||||
@SerializedName(ApiConstants.ZONE_ID) @Param(description="zone id the ucs manager belongs to")
|
||||
private String zoneId;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getZoneId() {
|
||||
return zoneId;
|
||||
}
|
||||
|
||||
public void setZoneId(String zoneId) {
|
||||
this.zoneId = zoneId;
|
||||
}
|
||||
}
|
||||
4
plugins/hypervisors/ucs/src/com/cloud/ucs/manager/ListUcsProfileCmd.java
Normal file → Executable file
4
plugins/hypervisors/ucs/src/com/cloud/ucs/manager/ListUcsProfileCmd.java
Normal file → Executable file
|
|
@ -35,7 +35,7 @@ import com.cloud.exception.ResourceAllocationException;
|
|||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.server.ManagementService;
|
||||
import com.cloud.user.Account;
|
||||
@APICommand(description="List profile in ucs manager", responseObject=ListUcsProfileResponse.class)
|
||||
@APICommand(description="List profile in ucs manager", responseObject=UcsProfileResponse.class)
|
||||
public class ListUcsProfileCmd extends BaseCmd {
|
||||
public static final Logger s_logger = Logger.getLogger(ListUcsProfileCmd.class);
|
||||
|
||||
|
|
@ -56,7 +56,7 @@ public class ListUcsProfileCmd extends BaseCmd {
|
|||
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException,
|
||||
ResourceAllocationException, NetworkRuleConflictException {
|
||||
try {
|
||||
ListResponse<ListUcsProfileResponse> response = mgr.listUcsProfiles(this);
|
||||
ListResponse<UcsProfileResponse> response = mgr.listUcsProfiles(this);
|
||||
response.setResponseName(getCommandName());
|
||||
response.setObjectName("ucsprofile");
|
||||
this.setResponseObject(response);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,56 @@
|
|||
package com.cloud.ucs.manager;
|
||||
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import org.apache.cloudstack.api.BaseResponse;
|
||||
import org.apache.cloudstack.api.EntityReference;
|
||||
|
||||
import com.cloud.serializer.Param;
|
||||
import com.cloud.ucs.database.UcsBladeVO;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
@EntityReference(value=UcsBladeVO.class)
|
||||
public class UcsBladeResponse extends BaseResponse {
|
||||
@SerializedName(ApiConstants.ID)
|
||||
@Param(description = "ucs blade id")
|
||||
private String id;
|
||||
@SerializedName(ApiConstants.UCS_MANAGER_ID)
|
||||
@Param(description = "ucs manager id")
|
||||
private String ucsManagerId;
|
||||
@SerializedName(ApiConstants.HOST_ID)
|
||||
@Param(description = "cloudstack host id this blade associates to")
|
||||
private String hostId;
|
||||
@SerializedName(ApiConstants.UCS_BLADE_DN)
|
||||
@Param(description = "ucs blade dn")
|
||||
private String dn;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getUcsManagerId() {
|
||||
return ucsManagerId;
|
||||
}
|
||||
|
||||
public void setUcsManagerId(String ucsManagerId) {
|
||||
this.ucsManagerId = ucsManagerId;
|
||||
}
|
||||
|
||||
public String getHostId() {
|
||||
return hostId;
|
||||
}
|
||||
|
||||
public void setHostId(String hostId) {
|
||||
this.hostId = hostId;
|
||||
}
|
||||
|
||||
public String getDn() {
|
||||
return dn;
|
||||
}
|
||||
|
||||
public void setDn(String dn) {
|
||||
this.dn = dn;
|
||||
}
|
||||
}
|
||||
|
|
@ -21,11 +21,13 @@ import org.apache.cloudstack.api.response.ListResponse;
|
|||
import com.cloud.utils.component.Manager;
|
||||
|
||||
public interface UcsManager extends Manager {
|
||||
AddUcsManagerResponse addUcsManager(AddUcsManagerCmd cmd);
|
||||
UcsManagerResponse addUcsManager(AddUcsManagerCmd cmd);
|
||||
|
||||
ListResponse<ListUcsProfileResponse> listUcsProfiles(ListUcsProfileCmd cmd);
|
||||
ListResponse<UcsProfileResponse> listUcsProfiles(ListUcsProfileCmd cmd);
|
||||
|
||||
ListResponse<ListUcsManagerResponse> listUcsManager(ListUcsManagerCmd cmd);
|
||||
ListResponse<UcsManagerResponse> listUcsManager(ListUcsManagerCmd cmd);
|
||||
|
||||
void associateProfileToBlade(AssociateUcsProfileToBladeCmd cmd);
|
||||
void associateProfileToBlade(AssociateUcsProfileToBladeCmd cmd);
|
||||
|
||||
ListResponse<UcsBladeResponse> listUcsBlades(ListUcsBladeCmd cmd);
|
||||
}
|
||||
|
|
|
|||
101
plugins/hypervisors/ucs/src/com/cloud/ucs/manager/UcsManagerImpl.java
Normal file → Executable file
101
plugins/hypervisors/ucs/src/com/cloud/ucs/manager/UcsManagerImpl.java
Normal file → Executable file
|
|
@ -42,8 +42,11 @@ import org.apache.log4j.Logger;
|
|||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.cloud.dc.ClusterDetailsDao;
|
||||
import com.cloud.dc.DataCenterVO;
|
||||
import com.cloud.dc.dao.ClusterDao;
|
||||
import com.cloud.dc.dao.DataCenterDao;
|
||||
import com.cloud.host.HostVO;
|
||||
import com.cloud.host.dao.HostDao;
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.org.Cluster;
|
||||
import com.cloud.resource.ResourceService;
|
||||
|
|
@ -78,8 +81,15 @@ public class UcsManagerImpl implements UcsManager {
|
|||
private ClusterDetailsDao clusterDetailsDao;
|
||||
@Inject
|
||||
private UcsBladeDao bladeDao;
|
||||
@Inject
|
||||
private HostDao hostDao;
|
||||
@Inject
|
||||
private DataCenterDao dcDao;
|
||||
|
||||
private Map<Long, String> cookies = new HashMap<Long, String>();
|
||||
private Map<Long, String> cookies = new HashMap<Long, String>();
|
||||
private String name;
|
||||
private int runLevel;
|
||||
private Map<String, Object> params;
|
||||
|
||||
@Override
|
||||
public boolean configure(String name, Map<String, Object> params) throws ConfigurationException {
|
||||
|
|
@ -98,7 +108,7 @@ public class UcsManagerImpl implements UcsManager {
|
|||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "UcsManager";
|
||||
return name;
|
||||
}
|
||||
|
||||
private void discoverBlades(UcsManagerVO ucsMgrVo) {
|
||||
|
|
@ -114,7 +124,7 @@ public class UcsManagerImpl implements UcsManager {
|
|||
|
||||
@Override
|
||||
@DB
|
||||
public AddUcsManagerResponse addUcsManager(AddUcsManagerCmd cmd) {
|
||||
public UcsManagerResponse addUcsManager(AddUcsManagerCmd cmd) {
|
||||
UcsManagerVO vo = new UcsManagerVO();
|
||||
vo.setUuid(UUID.randomUUID().toString());
|
||||
vo.setPassword(cmd.getPassword());
|
||||
|
|
@ -127,7 +137,7 @@ public class UcsManagerImpl implements UcsManager {
|
|||
txn.start();
|
||||
ucsDao.persist(vo);
|
||||
txn.commit();
|
||||
AddUcsManagerResponse rsp = new AddUcsManagerResponse();
|
||||
UcsManagerResponse rsp = new UcsManagerResponse();
|
||||
rsp.setId(String.valueOf(vo.getId()));
|
||||
rsp.setName(vo.getName());
|
||||
rsp.setUrl(vo.getUrl());
|
||||
|
|
@ -175,12 +185,12 @@ public class UcsManagerImpl implements UcsManager {
|
|||
}
|
||||
|
||||
@Override
|
||||
public ListResponse<ListUcsProfileResponse> listUcsProfiles(ListUcsProfileCmd cmd) {
|
||||
public ListResponse<UcsProfileResponse> listUcsProfiles(ListUcsProfileCmd cmd) {
|
||||
List<UcsProfile> profiles = getUcsProfiles(cmd.getUcsManagerId());
|
||||
ListResponse<ListUcsProfileResponse> response = new ListResponse<ListUcsProfileResponse>();
|
||||
List<ListUcsProfileResponse> rs = new ArrayList<ListUcsProfileResponse>();
|
||||
ListResponse<UcsProfileResponse> response = new ListResponse<UcsProfileResponse>();
|
||||
List<UcsProfileResponse> rs = new ArrayList<UcsProfileResponse>();
|
||||
for (UcsProfile p : profiles) {
|
||||
ListUcsProfileResponse r = new ListUcsProfileResponse();
|
||||
UcsProfileResponse r = new UcsProfileResponse();
|
||||
r.setObjectName("ucsprofile");
|
||||
r.setDn(p.getDn());
|
||||
rs.add(r);
|
||||
|
|
@ -250,55 +260,88 @@ public class UcsManagerImpl implements UcsManager {
|
|||
}
|
||||
|
||||
s_logger.debug(String.format("successfully associated profile[%s] to blade[%s]", pdn, bvo.getDn()));
|
||||
}
|
||||
}
|
||||
|
||||
private String hostIdToUuid(Long hostId) {
|
||||
HostVO vo = hostDao.findById(hostId);
|
||||
return vo.getUuid();
|
||||
}
|
||||
|
||||
private String zoneIdToUuid(Long zoneId) {
|
||||
DataCenterVO vo = dcDao.findById(zoneId);
|
||||
return vo.getUuid();
|
||||
}
|
||||
|
||||
private String ucsManagerIdToUuid(Long ucsMgrId) {
|
||||
UcsManagerVO vo = ucsDao.findById(ucsMgrId);
|
||||
return vo.getUuid();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ListResponse<ListUcsManagerResponse> listUcsManager(ListUcsManagerCmd cmd) {
|
||||
public ListResponse<UcsManagerResponse> listUcsManager(ListUcsManagerCmd cmd) {
|
||||
SearchCriteriaService<UcsManagerVO, UcsManagerVO> serv = SearchCriteria2.create(UcsManagerVO.class);
|
||||
serv.addAnd(serv.getEntity().getZoneId(), Op.EQ, cmd.getZoneId());
|
||||
List<UcsManagerVO> vos = serv.list();
|
||||
|
||||
List<ListUcsManagerResponse> rsps = new ArrayList<ListUcsManagerResponse>(vos.size());
|
||||
List<UcsManagerResponse> rsps = new ArrayList<UcsManagerResponse>(vos.size());
|
||||
for (UcsManagerVO vo : vos) {
|
||||
ListUcsManagerResponse rsp = new ListUcsManagerResponse();
|
||||
UcsManagerResponse rsp = new UcsManagerResponse();
|
||||
rsp.setObjectName("ucsmanager");
|
||||
rsp.setId(String.valueOf(vo.getId()));
|
||||
rsp.setName(vo.getName());
|
||||
rsp.setZoneId(String.valueOf(vo.getZoneId()));
|
||||
rsp.setId(vo.getUuid());
|
||||
rsp.setName(vo.getName());
|
||||
rsp.setUrl(vo.getUrl());
|
||||
rsp.setZoneId(zoneIdToUuid(vo.getZoneId()));
|
||||
rsps.add(rsp);
|
||||
}
|
||||
ListResponse<ListUcsManagerResponse> response = new ListResponse<ListUcsManagerResponse>();
|
||||
ListResponse<UcsManagerResponse> response = new ListResponse<UcsManagerResponse>();
|
||||
response.setResponses(rsps);
|
||||
return response;
|
||||
}
|
||||
|
||||
public ListResponse<UcsBladeResponse> listUcsBlades(ListUcsBladeCmd cmd) {
|
||||
SearchCriteriaService<UcsBladeVO, UcsBladeVO> serv = SearchCriteria2.create(UcsBladeVO.class);
|
||||
serv.addAnd(serv.getEntity().getUcsManagerId(), Op.EQ, cmd.getUcsManagerId());
|
||||
List<UcsBladeVO> vos = serv.list();
|
||||
|
||||
List<UcsBladeResponse> rsps = new ArrayList<UcsBladeResponse>(vos.size());
|
||||
for (UcsBladeVO vo : vos) {
|
||||
UcsBladeResponse rsp = new UcsBladeResponse();
|
||||
rsp.setObjectName("ucsblade");
|
||||
rsp.setId(vo.getUuid());
|
||||
rsp.setDn(vo.getDn());
|
||||
rsp.setHostId(hostIdToUuid(vo.getHostId()));
|
||||
rsp.setUcsManagerId(ucsManagerIdToUuid(vo.getUcsManagerId()));
|
||||
rsps.add(rsp);
|
||||
}
|
||||
|
||||
ListResponse<UcsBladeResponse> response = new ListResponse<UcsBladeResponse>();
|
||||
response.setResponses(rsps);
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setName(String name) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setConfigParams(Map<String, Object> params) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
public void setConfigParams(Map<String, Object> params) {
|
||||
this.params = params;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getConfigParams() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
return this.params;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRunLevel() {
|
||||
// TODO Auto-generated method stub
|
||||
return 0;
|
||||
return runLevel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRunLevel(int level) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
public void setRunLevel(int level) {
|
||||
this.runLevel = level;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,13 +16,16 @@
|
|||
// under the License.
|
||||
package com.cloud.ucs.manager;
|
||||
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import org.apache.cloudstack.api.EntityReference;
|
||||
|
||||
import org.apache.cloudstack.api.BaseResponse;
|
||||
|
||||
import com.cloud.serializer.Param;
|
||||
import com.cloud.ucs.database.UcsManagerVO;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
public class AddUcsManagerResponse extends BaseResponse {
|
||||
@EntityReference(value=UcsManagerVO.class)
|
||||
public class UcsManagerResponse extends BaseResponse {
|
||||
@SerializedName(ApiConstants.ID) @Param(description="the ID of the ucs manager")
|
||||
private String id;
|
||||
|
||||
|
|
@ -22,9 +22,9 @@ import org.apache.cloudstack.api.BaseResponse;
|
|||
import com.cloud.serializer.Param;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
public class ListUcsProfileResponse extends BaseResponse {
|
||||
@SerializedName(ApiConstants.UCS_DN) @Param(description="the dn of ucs profile")
|
||||
private String dn;
|
||||
public class UcsProfileResponse extends BaseResponse {
|
||||
@SerializedName(ApiConstants.UCS_DN) @Param(description="ucs profile dn")
|
||||
private String dn;
|
||||
|
||||
public String getDn() {
|
||||
return dn;
|
||||
Loading…
Reference in New Issue