Examples of MidonetApi


Examples of org.midonet.client.MidonetApi

     * Test the standard case of addDhcpEntry with no errors.
     */
    public void testAddDhcpEntry() {

        //mockMgmt
        MidonetApi api = mock(MidonetApi.class, RETURNS_DEEP_STUBS);

        //mockDhcpHost
        DhcpHost mockDhcpHost = mock(DhcpHost.class);

        //mockHostCollection
        ResourceCollection<DhcpHost> hosts =
                new ResourceCollection<DhcpHost>(new ArrayList<DhcpHost>());

        //mockDhcpSubnet
        DhcpSubnet mockSub = mock(DhcpSubnet.class);
        when(mockSub.addDhcpHost()).thenReturn(mockDhcpHost);
        when(mockSub.getDhcpHosts()).thenReturn(hosts);

        //mockSubnetCollection
        ResourceCollection mockSubnetCollection = mock(ResourceCollection.class);
        when(mockSubnetCollection.get(anyInt())).thenReturn(mockSub);

        //mockBridge
        Bridge mockBridge = mock(Bridge.class);
        when(api.addBridge().tenantId(anyString()).name(anyString()).create()).thenReturn(mockBridge);
        when(mockBridge.getDhcpSubnets()).thenReturn(mockSubnetCollection);

        //mockRouter
        Router mockRouter = mock(Router.class);
        when(api.addRouter().tenantId(anyString()).name(anyString()).create()).thenReturn(mockRouter);

        //mockNetwork
        Network mockNetwork = mock(Network.class);
        when(mockNetwork.getAccountId()).thenReturn((long)1);
        when(mockNetwork.getGateway()).thenReturn("1.2.3.4");
View Full Code Here

Examples of org.midonet.client.MidonetApi

    /*
     * Test the standard case of implement with no errors.
     */
    public void testImplement() {
        //mock
        MidonetApi api = mock(MidonetApi.class, RETURNS_DEEP_STUBS);

        //mockAccountDao
        AccountDao mockAccountDao = mock(AccountDao.class);
        AccountVO mockAccountVO = mock(AccountVO.class);
        when(mockAccountDao.findById(anyLong())).thenReturn(mockAccountVO);
        when(mockAccountVO.getUuid()).thenReturn("1");
        MidoNetElement elem = new MidoNetElement();

        elem.setMidonetApi(api);
        elem.setAccountDao(mockAccountDao);

        //mockRPort
        RouterPort mockRPort = mock(RouterPort.class);
        when(mockRPort.getId()).thenReturn(UUID.fromString("550e8400-e29b-41d4-a716-446655440000"));

        //mockBPort
        BridgePort mockBPort = mock(BridgePort.class);
        when(mockBPort.link(any(UUID.class))).thenReturn(mockBPort);

        //mockPort
        Port mockPort = mock(Port.class);

        ResourceCollection<Port> peerPorts =
            new ResourceCollection<Port>(new ArrayList<Port>());

        peerPorts.add(mockPort);

        //mockBridge
        Bridge mockBridge = mock(Bridge.class, RETURNS_DEEP_STUBS);
        when(api.addBridge().tenantId(anyString()).name(anyString()).create()).thenReturn(mockBridge);
        when(mockBridge.addInteriorPort().create()).thenReturn(mockBPort);
        when(mockBridge.getPeerPorts()).thenReturn(peerPorts);

        //mockRouter
        Router mockRouter = mock(Router.class, RETURNS_DEEP_STUBS);
        when(api.addRouter().tenantId(anyString()).name(anyString()).create()).thenReturn(mockRouter);
        when(mockRouter.addInteriorRouterPort().create()).thenReturn(mockRPort);

        //mockNetwork
        Network mockNetwork = mock(Network.class);
        when(mockNetwork.getAccountId()).thenReturn((long)1);
View Full Code Here

Examples of org.midonet.client.MidonetApi

                "Could not find midonet API location in config");
        }

        if (this.api == null) {
            s_logger.info("midonet API server address is  " + value);
            setMidonetApi(new MidonetApi(value));
            this.api.enableLogging();
        }

        return true;
    }
View Full Code Here

Examples of org.midonet.client.MidonetApi

            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()
View Full Code Here

Examples of org.midonet.client.MidonetApi

     * Test the standard case of addDhcpEntry with no errors.
     */
    public void testAddDhcpEntry() {

        //mockMgmt
        MidonetApi api = mock(MidonetApi.class, RETURNS_DEEP_STUBS);

        //mockDhcpHost
        DhcpHost mockDhcpHost = mock(DhcpHost.class);

        //mockHostCollection
        ResourceCollection<DhcpHost> hosts = new ResourceCollection<DhcpHost>(new ArrayList<DhcpHost>());

        //mockDhcpSubnet
        DhcpSubnet mockSub = mock(DhcpSubnet.class);
        when(mockSub.addDhcpHost()).thenReturn(mockDhcpHost);
        when(mockSub.getDhcpHosts()).thenReturn(hosts);

        //mockSubnetCollection
        ResourceCollection mockSubnetCollection = mock(ResourceCollection.class);
        when(mockSubnetCollection.get(anyInt())).thenReturn(mockSub);

        //mockBridge
        Bridge mockBridge = mock(Bridge.class);
        when(api.addBridge().tenantId(anyString()).name(anyString()).create()).thenReturn(mockBridge);
        when(mockBridge.getDhcpSubnets()).thenReturn(mockSubnetCollection);

        //mockRouter
        Router mockRouter = mock(Router.class);
        when(api.addRouter().tenantId(anyString()).name(anyString()).create()).thenReturn(mockRouter);

        //mockNetwork
        Network mockNetwork = mock(Network.class);
        when(mockNetwork.getAccountId()).thenReturn((long)1);
        when(mockNetwork.getGateway()).thenReturn("1.2.3.4");
View Full Code Here

Examples of org.midonet.client.MidonetApi

    /*
     * Test the standard case of implement with no errors.
     */
    public void testImplement() {
        //mock
        MidonetApi api = mock(MidonetApi.class, RETURNS_DEEP_STUBS);

        //mockAccountDao
        AccountDao mockAccountDao = mock(AccountDao.class);
        AccountVO mockAccountVO = mock(AccountVO.class);
        when(mockAccountDao.findById(anyLong())).thenReturn(mockAccountVO);
        when(mockAccountVO.getUuid()).thenReturn("1");
        MidoNetElement elem = new MidoNetElement();

        elem.setMidonetApi(api);
        elem.setAccountDao(mockAccountDao);

        //mockRPort
        RouterPort mockRPort = mock(RouterPort.class);
        when(mockRPort.getId()).thenReturn(UUID.fromString("550e8400-e29b-41d4-a716-446655440000"));

        //mockBPort
        BridgePort mockBPort = mock(BridgePort.class);
        when(mockBPort.link(any(UUID.class))).thenReturn(mockBPort);

        //mockPort
        Port mockPort = mock(Port.class);

        ResourceCollection<Port> peerPorts = new ResourceCollection<Port>(new ArrayList<Port>());

        peerPorts.add(mockPort);

        //mockBridge
        Bridge mockBridge = mock(Bridge.class, RETURNS_DEEP_STUBS);
        when(api.addBridge().tenantId(anyString()).name(anyString()).create()).thenReturn(mockBridge);
        when(mockBridge.addInteriorPort().create()).thenReturn(mockBPort);
        when(mockBridge.getPeerPorts()).thenReturn(peerPorts);

        //mockRouter
        Router mockRouter = mock(Router.class, RETURNS_DEEP_STUBS);
        when(api.addRouter().tenantId(anyString()).name(anyString()).create()).thenReturn(mockRouter);
        when(mockRouter.addInteriorRouterPort().create()).thenReturn(mockRPort);

        //mockNetwork
        Network mockNetwork = mock(Network.class);
        when(mockNetwork.getAccountId()).thenReturn((long)1);
View Full Code Here

Examples of org.midonet.client.MidonetApi

            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();
View Full Code Here

Examples of org.midonet.client.MidonetApi

            throw new ConfigurationException("Could not find midonet API location in config");
        }

        if (this.api == null) {
            s_logger.info("midonet API server address is  " + value);
            setMidonetApi(new MidonetApi(value));
            this.api.enableLogging();
        }

        return true;
    }
View Full Code Here

Examples of org.midonet.client.MidonetApi

     * Test the standard case of addDhcpEntry with no errors.
     */
    public void testAddDhcpEntry() {

        //mockMgmt
        MidonetApi api = mock(MidonetApi.class, RETURNS_DEEP_STUBS);

        //mockDhcpHost
        DhcpHost mockDhcpHost = mock(DhcpHost.class);

        //mockHostCollection
        ResourceCollection<DhcpHost> hosts =
                new ResourceCollection<DhcpHost>(new ArrayList<DhcpHost>());

        //mockDhcpSubnet
        DhcpSubnet mockSub = mock(DhcpSubnet.class);
        when(mockSub.addDhcpHost()).thenReturn(mockDhcpHost);
        when(mockSub.getDhcpHosts()).thenReturn(hosts);

        //mockSubnetCollection
        ResourceCollection mockSubnetCollection = mock(ResourceCollection.class);
        when(mockSubnetCollection.get(anyInt())).thenReturn(mockSub);

        //mockBridge
        Bridge mockBridge = mock(Bridge.class);
        when(api.addBridge().tenantId(anyString()).name(anyString()).create()).thenReturn(mockBridge);
        when(mockBridge.getDhcpSubnets()).thenReturn(mockSubnetCollection);

        //mockRouter
        Router mockRouter = mock(Router.class);
        when(api.addRouter().tenantId(anyString()).name(anyString()).create()).thenReturn(mockRouter);

        //mockNetwork
        Network mockNetwork = mock(Network.class);
        when(mockNetwork.getAccountId()).thenReturn((long)1);
        when(mockNetwork.getGateway()).thenReturn("1.2.3.4");
View Full Code Here

Examples of org.midonet.client.MidonetApi

    /*
     * Test the standard case of implement with no errors.
     */
    public void testImplement() {
        //mock
        MidonetApi api = mock(MidonetApi.class, RETURNS_DEEP_STUBS);

        //mockAccountDao
        AccountDao mockAccountDao = mock(AccountDao.class);
        AccountVO mockAccountVO = mock(AccountVO.class);
        when(mockAccountDao.findById(anyLong())).thenReturn(mockAccountVO);
        when(mockAccountVO.getUuid()).thenReturn("1");
        MidoNetElement elem = new MidoNetElement();

        elem.setMidonetApi(api);
        elem.setAccountDao(mockAccountDao);

        //mockRPort
        RouterPort mockRPort = mock(RouterPort.class);
        when(mockRPort.getId()).thenReturn(UUID.fromString("550e8400-e29b-41d4-a716-446655440000"));

        //mockBPort
        BridgePort mockBPort = mock(BridgePort.class);
        when(mockBPort.link(any(UUID.class))).thenReturn(mockBPort);

        //mockPort
        Port mockPort = mock(Port.class);

        ResourceCollection<Port> peerPorts =
            new ResourceCollection<Port>(new ArrayList<Port>());

        peerPorts.add(mockPort);

        //mockBridge
        Bridge mockBridge = mock(Bridge.class, RETURNS_DEEP_STUBS);
        when(api.addBridge().tenantId(anyString()).name(anyString()).create()).thenReturn(mockBridge);
        when(mockBridge.addInteriorPort().create()).thenReturn(mockBPort);
        when(mockBridge.getPeerPorts()).thenReturn(peerPorts);

        //mockRouter
        Router mockRouter = mock(Router.class, RETURNS_DEEP_STUBS);
        when(api.addRouter().tenantId(anyString()).name(anyString()).create()).thenReturn(mockRouter);
        when(mockRouter.addInteriorRouterPort().create()).thenReturn(mockRPort);

        //mockNetwork
        Network mockNetwork = mock(Network.class);
        when(mockNetwork.getAccountId()).thenReturn((long)1);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.