use of com.cloud.api.response.ListResponse in project cosmic by MissionCriticalCloud.
the class LdapImportUsersCmd method execute.
@Override
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException, NetworkRuleConflictException {
List<LdapUser> users;
try {
if (StringUtils.isNotBlank(groupName)) {
users = _ldapManager.getUsersInGroup(groupName);
} else {
users = _ldapManager.getUsers();
}
} catch (final NoLdapUserMatchingQueryException ex) {
users = new ArrayList<>();
s_logger.info("No Ldap user matching query. " + " ::: " + ex.getMessage());
}
final List<LdapUser> addedUsers = new ArrayList<>();
for (final LdapUser user : users) {
final Domain domain = getDomain(user);
try {
createCloudstackUserAccount(user, getAccountName(user), domain);
addedUsers.add(user);
} catch (final InvalidParameterValueException ex) {
s_logger.error("Failed to create user with username: " + user.getUsername() + " ::: " + ex.getMessage());
}
}
final ListResponse<LdapUserResponse> response = new ListResponse<>();
response.setResponses(createLdapUserResponse(addedUsers));
response.setResponseName(getCommandName());
setResponseObject(response);
}
use of com.cloud.api.response.ListResponse in project cosmic by MissionCriticalCloud.
the class DedicateZoneCmd method execute.
// ///////////////////////////////////////////////////
// ///////////////// Accessors ///////////////////////
// ///////////////////////////////////////////////////
@Override
public void execute() {
final List<? extends DedicatedResources> result = dedicatedService.dedicateZone(getZoneId(), getDomainId(), getAccountName());
final ListResponse<DedicateZoneResponse> response = new ListResponse<>();
final List<DedicateZoneResponse> zoneResponseList = new ArrayList<>();
if (result != null) {
for (final DedicatedResources resource : result) {
final DedicateZoneResponse zoneresponse = dedicatedService.createDedicateZoneResponse(resource);
zoneResponseList.add(zoneresponse);
}
response.setResponses(zoneResponseList);
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to dedicate zone");
}
}
use of com.cloud.api.response.ListResponse in project cosmic by MissionCriticalCloud.
the class ListDedicatedHostsCmd method execute.
// ///////////////////////////////////////////////////
// ///////////// API Implementation///////////////////l
// ///////////////////////////////////////////////////
@Override
public void execute() {
final Pair<List<? extends DedicatedResourceVO>, Integer> result = dedicatedService.listDedicatedHosts(this);
final ListResponse<DedicateHostResponse> response = new ListResponse<>();
final List<DedicateHostResponse> Responses = new ArrayList<>();
if (result != null) {
for (final DedicatedResources resource : result.first()) {
final DedicateHostResponse hostResponse = dedicatedService.createDedicateHostResponse(resource);
Responses.add(hostResponse);
}
response.setResponses(Responses, result.second());
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to list dedicated hosts");
}
}
use of com.cloud.api.response.ListResponse in project cosmic by MissionCriticalCloud.
the class ListDedicatedPodsCmd method execute.
// ///////////////////////////////////////////////////
// ///////////// API Implementation///////////////////
// ///////////////////////////////////////////////////
@Override
public void execute() {
final Pair<List<? extends DedicatedResourceVO>, Integer> result = dedicatedService.listDedicatedPods(this);
final ListResponse<DedicatePodResponse> response = new ListResponse<>();
final List<DedicatePodResponse> Responses = new ArrayList<>();
if (result != null) {
for (final DedicatedResources resource : result.first()) {
final DedicatePodResponse podresponse = dedicatedService.createDedicatePodResponse(resource);
Responses.add(podresponse);
}
response.setResponses(Responses, result.second());
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to list dedicated pods");
}
}
use of com.cloud.api.response.ListResponse in project cosmic by MissionCriticalCloud.
the class ListNiciraNvpDevicesCmd method execute.
// ///////////////////////////////////////////////////
// ///////////// API Implementation///////////////////
// ///////////////////////////////////////////////////
@Override
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ResourceAllocationException {
try {
final List<NiciraNvpDeviceVO> niciraDevices = niciraNvpElementService.listNiciraNvpDevices(this);
final ListResponse<NiciraNvpDeviceResponse> response = new ListResponse<>();
final List<NiciraNvpDeviceResponse> niciraDevicesResponse = new ArrayList<>();
if (niciraDevices != null && !niciraDevices.isEmpty()) {
for (final NiciraNvpDeviceVO niciraDeviceVO : niciraDevices) {
final NiciraNvpDeviceResponse niciraDeviceResponse = niciraNvpElementService.createNiciraNvpDeviceResponse(niciraDeviceVO);
niciraDevicesResponse.add(niciraDeviceResponse);
}
}
response.setResponses(niciraDevicesResponse);
response.setResponseName(getCommandName());
setResponseObject(response);
} catch (final InvalidParameterValueException invalidParamExcp) {
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, invalidParamExcp.getMessage());
} catch (final CloudRuntimeException runtimeExcp) {
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, runtimeExcp.getMessage());
}
}
Aggregations