Search in sources :

Example 11 with Port

use of com.att.cdp.zones.model.Port in project AJSC by att.

the class OpenStackNetworkService method getInterfaces.

/**
 * @throws ZoneException
 * @see com.att.cdp.zones.NetworkService#getInterfaces(java.lang.String)
 */
@Override
public List<com.att.cdp.zones.model.Port> getInterfaces(String serverId) throws ZoneException {
    InterfaceAttachments list = null;
    com.att.cdp.zones.model.Port port = null;
    List<com.att.cdp.zones.model.Port> ports = new ArrayList<>();
    connect();
    trackRequest();
    RequestState.put(RequestState.SERVICE, "Compute");
    RequestState.put(RequestState.SERVICE_URL, novaConnector.getEndpoint());
    try {
        list = novaConnector.getClient().servers().listInterfaceAttachments(serverId).execute();
        if (list != null && list.getList() != null && list.getList().size() > 0) {
            for (InterfaceAttachment intf : list.getList()) {
                port = new com.att.cdp.zones.model.Port();
                port.setPortState(OpenStackPort.mapState(intf.getPortState()));
                port.setMacAddr(intf.getMacAddress());
                port.setId(intf.getPortId());
                port.setSubnetId(intf.getNetworkId());
                List<String> addresses = new ArrayList<>();
                for (FixedIp ip : intf.getFixedIps()) {
                    addresses.add(ip.getIpAddress());
                }
                port.setAddresses(addresses);
                ports.add(port);
            }
        }
    } catch (OpenStackBaseException e) {
        ExceptionMapper.mapException(e);
    }
    return ports;
}
Also used : InterfaceAttachment(com.woorea.openstack.nova.model.InterfaceAttachment) OpenStackBaseException(com.woorea.openstack.base.client.OpenStackBaseException) Port(com.att.cdp.zones.model.Port) OpenStackPort(com.att.cdp.openstack.model.OpenStackPort) ArrayList(java.util.ArrayList) FixedIp(com.woorea.openstack.nova.model.FixedIp) Port(com.att.cdp.zones.model.Port) InterfaceAttachments(com.woorea.openstack.nova.model.InterfaceAttachments)

Example 12 with Port

use of com.att.cdp.zones.model.Port in project AJSC by att.

the class TestComputeService method testDeletePort.

@Ignore
@Test
public void testDeletePort() throws ZoneException {
    String[] ids = { "0e1ae02a-f34e-4208-a031-ba251c9d6538", "7235a241-a5d1-473c-97e2-f3115e91d878", "791b9689-7f19-469a-9759-154018315d4b", "958bbf73-7559-439d-bbad-94e67fc07263", "b43449bc-a427-4838-a0ab-4fd544533677", "b94deec4-fdcc-41d9-ae93-8d0f746011d2" };
    Context context = connect();
    ComputeService compute = context.getComputeService();
    NetworkService network = context.getNetworkService();
    for (String id : ids) {
        Port port = network.getPort(id);
        if (port != null) {
            port.delete();
        }
    }
}
Also used : Context(com.att.cdp.zones.Context) Port(com.att.cdp.zones.model.Port) NetworkService(com.att.cdp.zones.NetworkService) ComputeService(com.att.cdp.zones.ComputeService) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 13 with Port

use of com.att.cdp.zones.model.Port in project AJSC by att.

the class TestComputeService method testListPorts.

/**
 * Test that we can list all ports on some server
 *
 * @throws ZoneException
 *             if anything fails
 */
@Test
@Ignore
public void testListPorts() throws ZoneException {
    Context context = connect();
    ComputeService service = context.getComputeService();
    List<Server> servers = service.getServers();
    assertNotNull(servers);
    assertFalse(servers.isEmpty());
    for (Server server : servers) {
        List<Port> ports = service.getPorts(server);
        assertNotNull(ports);
        assertFalse(ports.isEmpty());
        List<Port> serverPorts = server.getPorts();
        assertNotNull(serverPorts);
        assertFalse(serverPorts.isEmpty());
        assertTrue(ports.containsAll(serverPorts));
    // System.out.printf("Server %s has %d ports\n", server.getName(),
    // ports.size());
    }
}
Also used : Context(com.att.cdp.zones.Context) Server(com.att.cdp.zones.model.Server) Port(com.att.cdp.zones.model.Port) ComputeService(com.att.cdp.zones.ComputeService) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 14 with Port

use of com.att.cdp.zones.model.Port in project AJSC by att.

the class TestNetworkService method testListPorts.

/**
 * Test that we can list all ports on the network
 *
 * @throws ZoneException
 *             If the test cannot connect to the provider
 */
@Test
@Ignore
public void testListPorts() throws ZoneException {
    Context context = connect();
    NetworkService service = context.getNetworkService();
    List<Port> ports = service.getPorts();
    assertNotNull(ports);
    assertFalse(ports.isEmpty());
    Port port = ports.get(0);
    assertNotNull(port.getId());
    assertNotNull(port.getMacAddr());
}
Also used : Context(com.att.cdp.zones.Context) Port(com.att.cdp.zones.model.Port) NetworkService(com.att.cdp.zones.NetworkService) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 15 with Port

use of com.att.cdp.zones.model.Port 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)

Aggregations

Port (com.att.cdp.zones.model.Port)16 Context (com.att.cdp.zones.Context)12 OpenStackPort (com.att.cdp.openstack.model.OpenStackPort)8 NetworkService (com.att.cdp.zones.NetworkService)8 Ignore (org.junit.Ignore)7 Test (org.junit.Test)7 Server (com.att.cdp.zones.model.Server)6 OpenStackBaseException (com.woorea.openstack.base.client.OpenStackBaseException)6 Subnet (com.att.cdp.zones.model.Subnet)5 ArrayList (java.util.ArrayList)5 ZoneException (com.att.cdp.exceptions.ZoneException)4 OpenStackContext (com.att.cdp.openstack.OpenStackContext)4 OpenStackServer (com.att.cdp.openstack.model.OpenStackServer)4 ComputeService (com.att.cdp.zones.ComputeService)4 ConnectedServer (com.att.cdp.zones.spi.model.ConnectedServer)4 InterfaceAttachment (com.woorea.openstack.nova.model.InterfaceAttachment)3 InterfaceAttachments (com.woorea.openstack.nova.model.InterfaceAttachments)3 OpenStackACL (com.att.cdp.openstack.model.OpenStackACL)2 OpenStackFault (com.att.cdp.openstack.model.OpenStackFault)2 ACL (com.att.cdp.zones.model.ACL)2