Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Neutron agent-list #807

Merged
merged 5 commits into from Sep 19, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion core-integration-test/pom.xml
Expand Up @@ -104,7 +104,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.6</version>
<version>${maven.jar.plugin.version}</version>
<executions>
<execution>
<goals>
Expand Down
@@ -0,0 +1,72 @@
package org.openstack4j.api.network;

import static org.testng.Assert.assertEquals;

import java.text.SimpleDateFormat;
import java.util.List;

import org.openstack4j.api.AbstractTest;
import org.openstack4j.api.Builders;
import org.openstack4j.model.network.Agent;
import org.openstack4j.model.network.Agent.Type;
import org.openstack4j.model.network.Network;
import org.openstack4j.model.network.State;
import org.testng.annotations.Test;

/**
* Tests the Compute -> Network API against the mock webserver and spec based
* json responses
*
* @author Yin Zhang
* @author Qin An
*/
@Test(suiteName = "Network")
public class NetworkTests extends AbstractTest {

private static final String JSON_NETWORK = "/network/network.json";
private static final String JSON_AGENTS = "/network/agents.json";
private static final String JSON_NETWORK_EXTERNAL = "/network/network-external.json";
private static final String NETWORK_NAME = "net1";
private static final String NETWORK_ID = "4e8e5957-649f-477b-9e5b-f1f75b21c03c";

@Test
public void getNetwork() throws Exception {
respondWith(JSON_NETWORK);
Network n = osv3().networking().network().get(NETWORK_ID);
assertEquals(n.getName(), NETWORK_NAME);
assertEquals(n.getStatus(), State.ACTIVE);
assertEquals(n.isRouterExternal(), false);
}

@Test
public void createNetwork() throws Exception {
respondWith(JSON_NETWORK_EXTERNAL);
Network n = osv3().networking().network()
.create(Builders.network().name(NETWORK_NAME).isRouterExternal(true).adminStateUp(true).build());
assertEquals(n.getName(), NETWORK_NAME);
assertEquals(n.getStatus(), State.ACTIVE);
assertEquals(n.isRouterExternal(), true);
}

@Test
public void agentList() throws Exception {
respondWith(JSON_AGENTS);
List<? extends Agent> agentList = osv3().networking().agent().list();
Agent agent = agentList.get(0);
assertEquals(agentList.size(), 12);
assertEquals(agent.getBinary(), "neutron-dhcp-agent");
assertEquals(agent.getAdminStateUp(), true);
assertEquals(agent.getAlive(), true);
assertEquals(agent.getAgentType(), Type.DHCP);
assertEquals(agent.getHost(), "cic-0-3");
assertEquals(agent.getId(), "086d8a3d-ef23-4708-909b-0c459528e2a6");
assertEquals(agent.getCreatedAt(), (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")).parse("2015-03-18 20:28:02"));
assertEquals(agent.getAgentType(), Type.DHCP);
assertEquals(agent.getAgentType(), Type.DHCP);
}

@Override
protected Service service() {
return Service.NETWORK;
}
}
271 changes: 271 additions & 0 deletions core-test/src/main/resources/network/agents.json
@@ -0,0 +1,271 @@
{
"agents":[
{
"binary":"neutron-dhcp-agent",
"description":null,
"admin_state_up":true,
"heartbeat_timestamp":"2015-03-19 15:55:22",
"alive":true,
"topic":"dhcp_agent",
"host":"cic-0-3",
"agent_type":"DHCP agent",
"created_at":"2015-03-18 20:28:02",
"started_at":"2015-03-18 20:28:02",
"id":"086d8a3d-ef23-4708-909b-0c459528e2a6",
"configurations":{
"subnets":6,
"use_namespaces":true,
"dhcp_lease_duration":120,
"dhcp_driver":"neutron.agent.linux.dhcp.Dnsmasq",
"networks":6,
"ports":8
}
},
{
"binary":"neutron-l3-agent",
"description":null,
"admin_state_up":true,
"heartbeat_timestamp":"2015-03-19 15:55:23",
"alive":true,
"topic":"l3_agent",
"host":"cic-0-2",
"agent_type":"L3 agent",
"created_at":"2015-03-18 20:02:02",
"started_at":"2015-03-18 20:02:02",
"id":"190ecbc2-77e0-4e4f-a96b-aa849edb357b",
"configurations":{
"router_id":"",
"gateway_external_network_id":"",
"handle_internal_only_routers":false,
"use_namespaces":true,
"routers":0,
"interfaces":0,
"floating_ips":0,
"interface_driver":"neutron.agent.linux.interface.OVSInterfaceDriver",
"ex_gw_ports":0
}
},
{
"binary":"neutron-openvswitch-agent",
"description":null,
"admin_state_up":true,
"heartbeat_timestamp":"2015-03-19 15:55:21",
"alive":true,
"topic":"N/A",
"host":"compute-0-8",
"agent_type":"Open vSwitch agent",
"created_at":"2015-03-18 20:38:39",
"started_at":"2015-03-18 20:38:56",
"id":"342d52e4-f253-443e-ab68-b7147b6b01ba",
"configurations":{
"tunnel_types":[

],
"tunneling_ip":"",
"bridge_mappings":{
"default":"br-prv"
},
"l2_population":false,
"devices":1
}
},
{
"binary":"neutron-openvswitch-agent",
"description":null,
"admin_state_up":true,
"heartbeat_timestamp":"2015-03-19 15:55:22",
"alive":true,
"topic":"N/A",
"host":"compute-0-7",
"agent_type":"Open vSwitch agent",
"created_at":"2015-03-18 20:38:39",
"started_at":"2015-03-18 20:38:56",
"id":"4604070d-cb78-4500-8af8-97b346b5ccca",
"configurations":{
"tunnel_types":[

],
"tunneling_ip":"",
"bridge_mappings":{
"default":"br-prv"
},
"l2_population":false,
"devices":0
}
},
{
"binary":"neutron-openvswitch-agent",
"description":null,
"admin_state_up":true,
"heartbeat_timestamp":"2015-03-19 15:55:23",
"alive":true,
"topic":"N/A",
"host":"cic-0-4",
"agent_type":"Open vSwitch agent",
"created_at":"2015-03-18 20:20:57",
"started_at":"2015-03-18 20:25:42",
"id":"862ad7e5-11f0-4c3c-86e7-0995b6c66d11",
"configurations":{
"tunnel_types":[

],
"tunneling_ip":"",
"bridge_mappings":{
"default":"br-prv"
},
"l2_population":false,
"devices":0
}
},
{
"binary":"neutron-openvswitch-agent",
"description":null,
"admin_state_up":true,
"heartbeat_timestamp":"2015-03-19 15:55:25",
"alive":true,
"topic":"N/A",
"host":"cic-0-3",
"agent_type":"Open vSwitch agent",
"created_at":"2015-03-18 20:20:46",
"started_at":"2015-03-18 20:25:35",
"id":"a594869e-cef0-49c9-a06e-54eb3ce74730",
"configurations":{
"tunnel_types":[

],
"tunneling_ip":"",
"bridge_mappings":{
"default":"br-prv"
},
"l2_population":false,
"devices":7
}
},
{
"binary":"neutron-openvswitch-agent",
"description":null,
"admin_state_up":true,
"heartbeat_timestamp":"2015-03-19 15:55:24",
"alive":true,
"topic":"N/A",
"host":"compute-0-5",
"agent_type":"Open vSwitch agent",
"created_at":"2015-03-18 20:38:42",
"started_at":"2015-03-18 20:38:59",
"id":"c98d1a7a-e972-4bcf-844c-dfb764e806c6",
"configurations":{
"tunnel_types":[

],
"tunneling_ip":"",
"bridge_mappings":{
"default":"br-prv"
},
"l2_population":false,
"devices":2
}
},
{
"binary":"neutron-openvswitch-agent",
"description":null,
"admin_state_up":true,
"heartbeat_timestamp":"2015-03-19 15:55:25",
"alive":true,
"topic":"N/A",
"host":"cic-0-2",
"agent_type":"Open vSwitch agent",
"created_at":"2015-03-18 19:57:10",
"started_at":"2015-03-18 19:59:05",
"id":"cbccc4f9-9083-4a31-bfba-705556c2c898",
"configurations":{
"tunnel_types":[

],
"tunneling_ip":"",
"bridge_mappings":{
"default":"br-prv"
},
"l2_population":false,
"devices":0
}
},
{
"binary":"neutron-metadata-agent",
"description":null,
"admin_state_up":true,
"heartbeat_timestamp":"2015-03-19 15:55:25",
"alive":true,
"topic":"N/A",
"host":"cic-0-3",
"agent_type":"Metadata agent",
"created_at":"2015-03-18 20:26:45",
"started_at":"2015-03-18 20:26:45",
"id":"d228eaae-1690-4d5e-b991-929f00df00ae",
"configurations":{
"nova_metadata_port":8775,
"nova_metadata_ip":"192.168.2.20",
"metadata_proxy_socket":"/var/lib/neutron/metadata_proxy"
}
},
{
"binary":"neutron-openvswitch-agent",
"description":null,
"admin_state_up":true,
"heartbeat_timestamp":"2015-03-19 15:55:21",
"alive":true,
"topic":"N/A",
"host":"compute-0-6",
"agent_type":"Open vSwitch agent",
"created_at":"2015-03-18 20:38:39",
"started_at":"2015-03-18 20:38:56",
"id":"d30479f4-52a0-4664-aafa-820889edcc05",
"configurations":{
"tunnel_types":[

],
"tunneling_ip":"",
"bridge_mappings":{
"default":"br-prv"
},
"l2_population":false,
"devices":5
}
},
{
"binary":"neutron-metadata-agent",
"description":null,
"admin_state_up":true,
"heartbeat_timestamp":"2015-03-19 15:55:23",
"alive":true,
"topic":"N/A",
"host":"cic-0-2",
"agent_type":"Metadata agent",
"created_at":"2015-03-18 19:59:48",
"started_at":"2015-03-18 19:59:48",
"id":"d4700160-9945-428b-994c-4570e255e2ee",
"configurations":{
"nova_metadata_port":8775,
"nova_metadata_ip":"192.168.2.20",
"metadata_proxy_socket":"/var/lib/neutron/metadata_proxy"
}
},
{
"binary":"neutron-metadata-agent",
"description":null,
"admin_state_up":true,
"heartbeat_timestamp":"2015-03-19 15:55:23",
"alive":true,
"topic":"N/A",
"host":"cic-0-4",
"agent_type":"Metadata agent",
"created_at":"2015-03-18 20:26:53",
"started_at":"2015-03-18 20:26:53",
"id":"e06c1445-abee-49e2-9f2c-769257f8b989",
"configurations":{
"nova_metadata_port":8775,
"nova_metadata_ip":"192.168.2.20",
"metadata_proxy_socket":"/var/lib/neutron/metadata_proxy"
}
}
]
}
25 changes: 25 additions & 0 deletions core-test/src/main/resources/network/network-external.json
@@ -0,0 +1,25 @@
{
"network": {
"status": "ACTIVE",
"subnets": [],
"name": "net1",
"admin_state_up": true,
"tenant_id": "9bacb3c5d39d41a79512987f338cf177",
"segments": [
{
"provider:segmentation_id": 2,
"provider:physical_network": "8bab8453-1bc9-45af-8c70-f83aa9b50453",
"provider:network_type": "vlan"
},
{
"provider:segmentation_id": null,
"provider:physical_network": "8bab8453-1bc9-45af-8c70-f83aa9b50453",
"provider:network_type": "stt"
}
],
"router:external": true,
"shared": false,
"port_security_enabled": true,
"id": "4e8e5957-649f-477b-9e5b-f1f75b21c03c"
}
}