Search in sources :

Example 26 with NetworkService

use of com.att.cdp.zones.NetworkService in project AJSC by att.

the class TestNetworkService method testCreateAndDeletePort.

@Test
@Ignore
public void testCreateAndDeletePort() throws ZoneException {
    Context context = connect();
    NetworkService service = context.getNetworkService();
    String poolName = "TestNewPool";
    String tenantId = context.getTenant().getId();
    String networkId = "64e612b4-0a2a-4073-b408-66a3ef27aef7";
    String subnetId = "b124ab37-a285-4b8f-848b-e485c062594c";
    Subnet subnet = service.getSubnetById(subnetId);
    assertNotNull(subnet);
    Port port = service.createPort(subnet);
    assertNotNull(port);
    port.delete();
}
Also used : Context(com.att.cdp.zones.Context) Port(com.att.cdp.zones.model.Port) NetworkService(com.att.cdp.zones.NetworkService) Subnet(com.att.cdp.zones.model.Subnet) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 27 with NetworkService

use of com.att.cdp.zones.NetworkService in project AJSC by att.

the class OpenStackServer method loadNetworks.

/**
 * This method lazily loads the networks and ip addresses of the server
 *
 * @param context
 *            The context we are servicing
 */
@SuppressWarnings("nls")
private void loadNetworks(Context context) {
    if (networksProcessed.compareAndSet(false, true)) {
        try {
            NetworkService netService = context.getNetworkService();
            com.woorea.openstack.nova.model.Server.Addresses addresses = novaModel.getAddresses();
            if (addresses != null) {
                for (Map.Entry<String, List<com.woorea.openstack.nova.model.Server.Addresses.Address>> entry : addresses.getAddresses().entrySet()) {
                    String netName = entry.getKey();
                    try {
                        List<Network> nets = netService.getNetworksByName(netName);
                        if (!nets.isEmpty()) {
                            getNetworks().add(nets.get(0));
                        }
                        for (com.woorea.openstack.nova.model.Server.Addresses.Address osAddr : entry.getValue()) {
                            String type = osAddr.getType();
                            if (type != null) {
                                if (type.equalsIgnoreCase("fixed")) {
                                    getFixedAddresses().add(osAddr.getAddr());
                                } else {
                                    getFloatingAddresses().add(osAddr.getAddr());
                                }
                            }
                        }
                    } catch (ZoneException e) {
                        LOG.error(EELFResourceManager.format(e));
                    }
                }
            }
        } catch (Exception e) {
            LOG.error(String.format("Unexpected exception %s retrieving addresses for server %s", e.getClass().getSimpleName(), getId()));
            LOG.error(EELFResourceManager.format(e));
        }
    }
}
Also used : ConnectedServer(com.att.cdp.zones.spi.model.ConnectedServer) Server(com.att.cdp.zones.model.Server) ZoneException(com.att.cdp.exceptions.ZoneException) ZoneException(com.att.cdp.exceptions.ZoneException) Network(com.att.cdp.zones.model.Network) NetworkService(com.att.cdp.zones.NetworkService) ArrayList(java.util.ArrayList) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

NetworkService (com.att.cdp.zones.NetworkService)27 Context (com.att.cdp.zones.Context)24 Ignore (org.junit.Ignore)22 Test (org.junit.Test)21 ZoneException (com.att.cdp.exceptions.ZoneException)15 Network (com.att.cdp.zones.model.Network)13 Subnet (com.att.cdp.zones.model.Subnet)12 Port (com.att.cdp.zones.model.Port)8 ArrayList (java.util.ArrayList)5 Server (com.att.cdp.zones.model.Server)4 ComputeService (com.att.cdp.zones.ComputeService)3 ConnectedServer (com.att.cdp.zones.spi.model.ConnectedServer)3 HashMap (java.util.HashMap)3 List (java.util.List)3 OpenStackContext (com.att.cdp.openstack.OpenStackContext)2 OpenStackACL (com.att.cdp.openstack.model.OpenStackACL)2 OpenStackFault (com.att.cdp.openstack.model.OpenStackFault)2 OpenStackPort (com.att.cdp.openstack.model.OpenStackPort)2 OpenStackServer (com.att.cdp.openstack.model.OpenStackServer)2 ACL (com.att.cdp.zones.model.ACL)2