Search in sources :

Example 81 with MultivaluedMapImpl

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;
}
Also used : MultivaluedMapImpl(com.sun.jersey.core.util.MultivaluedMapImpl) MultivaluedMap(javax.ws.rs.core.MultivaluedMap) Bridge(org.midonet.client.resource.Bridge)

Example 82 with MultivaluedMapImpl

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;
}
Also used : RouterPort(org.midonet.client.resource.RouterPort) BridgePort(org.midonet.client.resource.BridgePort) Port(org.midonet.client.resource.Port) MultivaluedMapImpl(com.sun.jersey.core.util.MultivaluedMapImpl) RouterPort(org.midonet.client.resource.RouterPort)

Example 83 with MultivaluedMapImpl

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;
}
Also used : BridgePort(org.midonet.client.resource.BridgePort) LibvirtVMDef(com.cloud.hypervisor.kvm.resource.LibvirtVMDef) MultivaluedMapImpl(com.sun.jersey.core.util.MultivaluedMapImpl) InternalErrorException(com.cloud.exception.InternalErrorException) MultivaluedMap(javax.ws.rs.core.MultivaluedMap) UUID(java.util.UUID) Bridge(org.midonet.client.resource.Bridge) MidonetApi(org.midonet.client.MidonetApi)

Example 84 with MultivaluedMapImpl

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));
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) WebResource(com.sun.jersey.api.client.WebResource) MultivaluedMapImpl(com.sun.jersey.core.util.MultivaluedMapImpl) Matchers.anyString(org.mockito.Matchers.anyString) JerseyTest(com.sun.jersey.test.framework.JerseyTest) Test(org.junit.Test)

Example 85 with MultivaluedMapImpl

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));
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) WebResource(com.sun.jersey.api.client.WebResource) MultivaluedMapImpl(com.sun.jersey.core.util.MultivaluedMapImpl) Matchers.anyString(org.mockito.Matchers.anyString) JerseyTest(com.sun.jersey.test.framework.JerseyTest) Test(org.junit.Test)

Aggregations

MultivaluedMapImpl (com.sun.jersey.core.util.MultivaluedMapImpl)131 Test (org.junit.Test)55 ClientResponse (com.sun.jersey.api.client.ClientResponse)48 WebResource (com.sun.jersey.api.client.WebResource)39 JSONObject (org.codehaus.jettison.json.JSONObject)39 Test (org.testng.annotations.Test)35 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)13 RMApp (org.apache.hadoop.yarn.server.resourcemanager.rmapp.RMApp)12 List (java.util.List)11 MockNM (org.apache.hadoop.yarn.server.resourcemanager.MockNM)11 JSONArray (org.codehaus.jettison.json.JSONArray)9 MultivaluedMap (javax.ws.rs.core.MultivaluedMap)8 Client (com.sun.jersey.api.client.Client)7 SearchFilter (org.apache.atlas.model.SearchFilter)7 AtlasTypesDef (org.apache.atlas.model.typedef.AtlasTypesDef)7 WebDriverHelper (org.orcid.api.common.WebDriverHelper)7 Response (javax.ws.rs.core.Response)6 AtlasEntityHeader (org.apache.atlas.model.instance.AtlasEntityHeader)6 AtlasLineageInfo (org.apache.atlas.model.lineage.AtlasLineageInfo)6 MockAM (org.apache.hadoop.yarn.server.resourcemanager.MockAM)6