use of org.apache.cloudstack.api.response.ListResponse in project cloudstack by apache.
the class ListOvsElementsCmd method execute.
@Override
public void execute() throws ResourceUnavailableException, InsufficientCapacityException, ServerApiException, ConcurrentOperationException, ResourceAllocationException {
List<? extends OvsProvider> providers = _service.get(0).searchForOvsElement(this);
ListResponse<OvsProviderResponse> response = new ListResponse<OvsProviderResponse>();
List<OvsProviderResponse> providerResponses = new ArrayList<OvsProviderResponse>();
for (OvsProvider provider : providers) {
OvsProviderResponse providerResponse = _responseGenerator.createOvsProviderResponse(provider);
providerResponses.add(providerResponse);
}
response.setResponses(providerResponses);
response.setResponseName(getCommandName());
this.setResponseObject(response);
}
use of org.apache.cloudstack.api.response.ListResponse in project cloudstack by apache.
the class ListCfgCmdTest method testCreateSuccess.
@Test
public void testCreateSuccess() {
Configuration cfg = Mockito.mock(Configuration.class);
listCfgsByCmd._mgr = mgr;
listCfgsByCmd._responseGenerator = responseGenerator;
List<Configuration> configList = new ArrayList<Configuration>();
configList.add(cfg);
Pair<List<? extends Configuration>, Integer> result = new Pair<List<? extends Configuration>, Integer>(configList, 1);
try {
Mockito.when(mgr.searchForConfigurations(listCfgsByCmd)).thenReturn(result);
} catch (Exception e) {
Assert.fail("Received exception when success expected " + e.getMessage());
}
ConfigurationResponse cfgResponse = new ConfigurationResponse();
cfgResponse.setName("Test case");
Mockito.when(responseGenerator.createConfigurationResponse(cfg)).thenReturn(cfgResponse);
listCfgsByCmd.execute();
Mockito.verify(responseGenerator).createConfigurationResponse(cfg);
ListResponse<ConfigurationResponse> actualResponse = (ListResponse<ConfigurationResponse>) listCfgsByCmd.getResponseObject();
Assert.assertEquals(cfgResponse, actualResponse.getResponses().get(0));
}
use of org.apache.cloudstack.api.response.ListResponse in project cloudstack by apache.
the class ListVpnGatewaysCmd method execute.
@Override
public void execute() {
Pair<List<? extends Site2SiteVpnGateway>, Integer> gws = _s2sVpnService.searchForVpnGateways(this);
ListResponse<Site2SiteVpnGatewayResponse> response = new ListResponse<Site2SiteVpnGatewayResponse>();
List<Site2SiteVpnGatewayResponse> gwResponses = new ArrayList<Site2SiteVpnGatewayResponse>();
for (Site2SiteVpnGateway gw : gws.first()) {
if (gw == null) {
continue;
}
Site2SiteVpnGatewayResponse site2SiteVpnGatewayRes = _responseGenerator.createSite2SiteVpnGatewayResponse(gw);
site2SiteVpnGatewayRes.setObjectName("vpngateway");
gwResponses.add(site2SiteVpnGatewayRes);
}
response.setResponses(gwResponses, gws.second());
response.setResponseName(getCommandName());
setResponseObject(response);
}
use of org.apache.cloudstack.api.response.ListResponse in project cloudstack by apache.
the class ListVpnUsersCmd method execute.
@Override
public void execute() {
Pair<List<? extends VpnUser>, Integer> vpnUsers = _ravService.searchForVpnUsers(this);
ListResponse<VpnUsersResponse> response = new ListResponse<VpnUsersResponse>();
List<VpnUsersResponse> vpnResponses = new ArrayList<VpnUsersResponse>();
for (VpnUser vpnUser : vpnUsers.first()) {
vpnResponses.add(_responseGenerator.createVpnUserResponse(vpnUser));
}
response.setResponses(vpnResponses, vpnUsers.second());
response.setResponseName(getCommandName());
setResponseObject(response);
}
use of org.apache.cloudstack.api.response.ListResponse in project cloudstack by apache.
the class ListRemoteAccessVpnsCmd method execute.
@Override
public void execute() {
Pair<List<? extends RemoteAccessVpn>, Integer> vpns = _ravService.searchForRemoteAccessVpns(this);
ListResponse<RemoteAccessVpnResponse> response = new ListResponse<RemoteAccessVpnResponse>();
List<RemoteAccessVpnResponse> vpnResponses = new ArrayList<RemoteAccessVpnResponse>();
if (vpns.first() != null && !vpns.first().isEmpty()) {
for (RemoteAccessVpn vpn : vpns.first()) {
vpnResponses.add(_responseGenerator.createRemoteAccessVpnResponse(vpn));
}
}
response.setResponses(vpnResponses, vpns.second());
response.setResponseName(getCommandName());
setResponseObject(response);
}
Aggregations