use of com.sun.jersey.core.util.MultivaluedMapImpl in project cloudstack by apache.
the class MidoNetElement method getNetworkBridge.
private Bridge getNetworkBridge(long networkID, String accountUuid) {
MultivaluedMap qNetBridge = new MultivaluedMapImpl();
String networkUUIDStr = String.valueOf(networkID);
qNetBridge.add("tenant_id", accountUuid);
for (Bridge b : this.api.getBridges(qNetBridge)) {
if (b.getName().equals(networkUUIDStr)) {
return b;
}
}
return null;
}
use of com.sun.jersey.core.util.MultivaluedMapImpl in project cloudstack by apache.
the class MidoNetElement method getOrCreateProviderRouterPorts.
protected RouterPort[] getOrCreateProviderRouterPorts(Router tenantRouter, Router providerRouter) {
RouterPort[] ports = new RouterPort[2];
RouterPort tenantUplink = null;
RouterPort providerDownlink = null;
// Check if the ports and connection already exist
for (Port peerPort : tenantRouter.getPeerPorts((new MultivaluedMapImpl()))) {
if (peerPort != null && peerPort instanceof RouterPort) {
RouterPort checkPort = (RouterPort) peerPort;
if (checkPort.getDeviceId().compareTo(providerRouter.getId()) == 0) {
providerDownlink = checkPort;
tenantUplink = (RouterPort) api.getPort(checkPort.getPeerId());
break;
}
}
}
// Create the ports and connection if they don't exist
if (providerDownlink == null) {
// Add interior port on router side, with network details
providerDownlink = providerRouter.addInteriorRouterPort().networkAddress("169.254.255.0").networkLength(32).portAddress("169.254.255.1").create();
tenantUplink = tenantRouter.addInteriorRouterPort().networkAddress("169.254.255.0").networkLength(32).portAddress("169.254.255.2").create();
// Link them up
providerDownlink.link(tenantUplink.getId()).update();
}
ports[0] = tenantUplink;
ports[1] = providerDownlink;
return ports;
}
use of com.sun.jersey.core.util.MultivaluedMapImpl in project cloudstack by apache.
the class MidoNetVifDriver method plug.
@Override
public LibvirtVMDef.InterfaceDef plug(NicTO nic, String guestOsType, String nicAdapter) throws InternalErrorException, LibvirtException {
if (s_logger.isDebugEnabled()) {
s_logger.debug("nic=" + nic);
}
LibvirtVMDef.InterfaceDef intf = new LibvirtVMDef.InterfaceDef();
String trafficLabel = nic.getName();
if (nic.getBroadcastType() == Networks.BroadcastDomainType.Mido && (nic.getType() == Networks.TrafficType.Guest || nic.getType() == Networks.TrafficType.Public)) {
/*
* create the tap.
*/
String tapName = addTap();
/*
* grab the tenant id and the network id from the Broadcast URI.
* We need to pluck the values out of the String. The string
* should look like "mido://[tenant_id].[bridge_name]"
*/
MultivaluedMap qNet = new MultivaluedMapImpl();
String nicAuthority = nic.getBroadcastUri().getAuthority();
String tenantId = nicAuthority.split("\\.")[0];
qNet.add("tenant_id", tenantId);
String url = nicAuthority.split("\\.")[1];
String netName = url.split(":")[0];
MidonetApi api = new MidonetApi(_midoApiLocation);
api.enableLogging();
for (Bridge b : api.getBridges(qNet)) {
if (b.getName().equals(netName)) {
for (BridgePort p : b.getPorts()) {
UUID pvif = p.getVifId();
if (pvif != null && p.getVifId().toString().equals(nic.getUuid())) {
getMyHost(api).addHostInterfacePort().interfaceName(tapName).portId(p.getId()).create();
break;
}
}
}
}
intf.defEthernet(tapName, nic.getMac(), getGuestNicModel(guestOsType, nicAdapter), "");
} else {
throw new InternalErrorException("Only NICs of BroadcastDomain type Mido are supported by the MidoNetVifDriver");
}
return intf;
}
use of com.sun.jersey.core.util.MultivaluedMapImpl in project pentaho-platform by pentaho.
the class RepositoryResourceIT method a3_HappyPath_POST_withCommand.
@Test
public void a3_HappyPath_POST_withCommand() throws PlatformInitializationException {
createTestFile(publicFolderPath + ":" + "test.xjunit", "abcdefg");
WebResource webResource = resource();
MultivaluedMap<String, String> formData = new MultivaluedMapImpl();
formData.add("testParam", "testParamValue");
ClientResponse response = webResource.path("repos/:public:test.xjunit/testservice/dosomething").type(APPLICATION_FORM_URLENCODED).post(ClientResponse.class, formData);
assertResponse(response, Status.OK);
String expectedResponse = "hello this is service content generator servicing command dosomething";
assertEquals("Content generator failed to provide correct output", expectedResponse, response.getEntity(String.class));
}
use of com.sun.jersey.core.util.MultivaluedMapImpl in project pentaho-platform by pentaho.
the class RepositoryResourceIT method c3_HappyPath_POST_withCommand.
@Test
public void c3_HappyPath_POST_withCommand() {
WebResource webResource = resource();
MultivaluedMap<String, String> formData = new MultivaluedMapImpl();
formData.add("testParam", "testParamValue");
ClientResponse response = webResource.path("repos/test-plugin/testservice/dosomething").type(APPLICATION_FORM_URLENCODED).post(ClientResponse.class, formData);
assertResponse(response, Status.OK);
String expectedResponse = "hello this is service content generator servicing command dosomething";
assertEquals("Content generator failed to provide correct output", expectedResponse, response.getEntity(String.class));
}
Aggregations