use of org.onosproject.openstacknode.api.OpenstackNode in project onos by opennetworkinglab.
the class OpenstackNodeCodecTest method testOpenstackDpdkComputeNodeEncode.
/**
* Tests the openstack compute node encoding with dpdk config.
*/
@Test
public void testOpenstackDpdkComputeNodeEncode() {
DpdkInterface dpdkInterface1 = DefaultDpdkInterface.builder().deviceName("br-int").intf("dpdk0").mtu(Long.valueOf(1600)).pciAddress("0000:85:00.0").type(DpdkInterface.Type.DPDK).build();
DpdkInterface dpdkInterface2 = DefaultDpdkInterface.builder().deviceName("br-tun").intf("dpdk1").pciAddress("0000:85:00.1").type(DpdkInterface.Type.DPDK).build();
Collection<DpdkInterface> dpdkInterfaceCollection = new ArrayList<>();
dpdkInterfaceCollection.add(dpdkInterface1);
dpdkInterfaceCollection.add(dpdkInterface2);
DpdkConfig dpdkConfig = DefaultDpdkConfig.builder().datapathType(DpdkConfig.DatapathType.NETDEV).dpdkIntfs(dpdkInterfaceCollection).build();
OpenstackNode node = DefaultOpenstackNode.builder().hostname("compute").type(OpenstackNode.NodeType.COMPUTE).state(NodeState.INIT).managementIp(IpAddress.valueOf("10.10.10.1")).intgBridge(DeviceId.deviceId("br-int")).vlanIntf("vlan").dataIp(IpAddress.valueOf("20.20.20.2")).dpdkConfig(dpdkConfig).build();
ObjectNode nodeJson = openstackNodeCodec.encode(node, context);
assertThat(nodeJson, matchesOpenstackNode(node));
}
use of org.onosproject.openstacknode.api.OpenstackNode in project onos by opennetworkinglab.
the class OpenstackNodeManagerTest method testUpdateNodeStateIncomplete.
/**
* Checks if updating a node state to incomplete generates proper events.
*/
@Test
public void testUpdateNodeStateIncomplete() {
OpenstackNode updated = DefaultOpenstackNode.from(COMPUTE_3).state(NodeState.INCOMPLETE).build();
target.updateNode(updated);
assertEquals(ERR_NOT_MATCH, updated, target.node(COMPUTE_3_HOSTNAME));
validateEvents(OPENSTACK_NODE_UPDATED, OPENSTACK_NODE_INCOMPLETE);
}
use of org.onosproject.openstacknode.api.OpenstackNode in project onos by opennetworkinglab.
the class OpenstackNetworkingUtilTest method testGetGwByInstancePort.
/**
* Tests the getGwByInstancePort method.
*/
@Test
public void testGetGwByInstancePort() {
Set<OpenstackNode> gws = Sets.newConcurrentHashSet();
gws.add(genGateway(1));
gws.add(genGateway(2));
gws.add(genGateway(3));
int expectedGwIndex = 2;
OpenstackNode gw = getGwByInstancePort(gws, instancePort1);
assertEquals(genGateway(expectedGwIndex), gw);
assertNull(getGwByInstancePort(gws, null));
}
use of org.onosproject.openstacknode.api.OpenstackNode in project onos by opennetworkinglab.
the class OpenstackTroubleshootManager method probeNorthSouth.
@Override
public Reachability probeNorthSouth(InstancePort port) {
Optional<OpenstackNode> gw = osNodeService.completeNodes(GATEWAY).stream().findFirst();
if (!gw.isPresent()) {
log.warn("Gateway is not available to troubleshoot north-south traffic.");
return null;
}
// install flow rules to enforce forwarding ICMP_REPLY to controller
eventExecutor.execute(() -> setNorthSouthIcmpReplyRule(port, gw.get(), true));
timeoutPredicate(1, ICMP_RULE_INSTALL_TIMEOUT_MS, this::checkNorthSouthIcmpReplyRule, port.ipAddress().toString());
// send out ICMP ECHO request
sendIcmpEchoRequest(null, port, gw.get(), Direction.NORTH_SOUTH);
BooleanSupplier checkReachability = () -> icmpReachabilityMap.asJavaMap().values().stream().allMatch(Reachability::isReachable);
timeoutSupplier(1, ICMP_REPLY_TIMEOUT_MS, checkReachability);
// uninstall ICMP_REPLY enforcing rules
eventExecutor.execute(() -> setNorthSouthIcmpReplyRule(port, gw.get(), false));
return icmpReachabilityMap.asJavaMap().get(String.valueOf(icmpIdCounter.get()));
}
use of org.onosproject.openstacknode.api.OpenstackNode in project onos by opennetworkinglab.
the class OpenstackEastWestProbeCommand method doExecute.
@Override
protected void doExecute() {
OpenstackTroubleshootService tsService = get(OpenstackTroubleshootService.class);
InstancePortService instPortService = get(InstancePortService.class);
MastershipService mastershipService = get(MastershipService.class);
ClusterService clusterService = get(ClusterService.class);
OpenstackNodeService osNodeService = get(OpenstackNodeService.class);
if (tsService == null) {
error("Failed to troubleshoot openstack networking.");
return;
}
if ((!isAll && vmIps == null) || (isAll && vmIps != null)) {
print("Please specify one of VM IP address or -a option.");
return;
}
NodeId localNodeId = clusterService.getLocalNode().id();
for (OpenstackNode node : osNodeService.completeNodes(COMPUTE)) {
if (!localNodeId.equals(mastershipService.getMasterFor(node.intgBridge()))) {
error("Current node is not the master for all compute nodes. " + "Please enforce mastership first using openstack-reset-mastership -c !");
return;
}
}
if (isAll) {
printHeader();
// send ICMP PACKET_OUT to all connect VMs whose instance port state is ACTIVE
Set<InstancePort> activePorts = instPortService.instancePorts().stream().filter(p -> p.state() == ACTIVE).collect(Collectors.toSet());
activePorts.forEach(srcPort -> activePorts.forEach(dstPort -> printReachability(tsService.probeEastWest(srcPort, dstPort))));
} else {
if (vmIps.length > 2) {
print("Too many VM IPs. The number of IP should be limited to 2.");
return;
}
IpAddress srcIp = getIpAddress(vmIps[0]);
if (srcIp == null) {
return;
}
InstancePort srcPort = instPort(instPortService, srcIp);
if (srcPort == null) {
print("Specified source IP is not existing.");
return;
}
final Set<IpAddress> dstIps = Sets.newConcurrentHashSet();
if (vmIps.length == 2) {
IpAddress dstIp = getIpAddress(vmIps[1]);
if (dstIp == null) {
return;
}
dstIps.add(dstIp);
}
if (vmIps.length == 1) {
dstIps.addAll(instPortService.instancePorts().stream().filter(p -> !p.ipAddress().equals(srcIp)).filter(p -> p.state().equals(InstancePort.State.ACTIVE)).map(InstancePort::ipAddress).collect(Collectors.toSet()));
}
printHeader();
dstIps.stream().filter(ip -> instPort(instPortService, ip) != null).map(ip -> instPort(instPortService, ip)).forEach(port -> probeExecutor.execute(() -> printReachability(tsService.probeEastWest(srcPort, port))));
}
}
Aggregations