use of org.onosproject.openstacknetworking.api.InstancePortAdminService in project onos by opennetworkinglab.
the class PreCommitPortManagerTest method testUnsubscribePreCommit.
/**
* Tests unsubscribe pre-commit method.
*/
@Test
public void testUnsubscribePreCommit() {
sampleSubscribe();
InstancePortAdminService service = new TestInstancePortAdminService();
target.unsubscribePreCommit(PORT_ID_1, OPENSTACK_PORT_PRE_REMOVE, service, CLASS_NAME_1);
target.unsubscribePreCommit(PORT_ID_2, OPENSTACK_PORT_PRE_REMOVE, service, CLASS_NAME_2);
assertEquals(0, target.subscriberCountByEventType(PORT_ID_1, OPENSTACK_PORT_PRE_REMOVE));
assertEquals(1, target.subscriberCountByEventType(PORT_ID_2, OPENSTACK_PORT_PRE_REMOVE));
assertEquals(0, target.subscriberCount(PORT_ID_1));
assertEquals(2, target.subscriberCount(PORT_ID_2));
}
use of org.onosproject.openstacknetworking.api.InstancePortAdminService in project onos by opennetworkinglab.
the class OpenstackFlowTraceCommand method doExecute.
@Override
protected void doExecute() {
OpenstackNodeAdminService osNodeService = get(OpenstackNodeAdminService.class);
InstancePortAdminService instancePortService = get(InstancePortAdminService.class);
OpenstackNetworkAdminService osNetService = get(OpenstackNetworkAdminService.class);
Optional<InstancePort> srcInstance = instancePortService.instancePorts().stream().filter(port -> port.ipAddress().toString().equals(srcIp)).findAny();
if (!srcInstance.isPresent()) {
print(NO_ELEMENT);
return;
}
OpenstackNode srcNode = osNodeService.node(srcInstance.get().deviceId());
if (srcNode == null || srcNode.sshAuthInfo() == null) {
log.error("Openstack node {} is null or has no SSH authentication information.\n" + " Please refers to the sample network-cfg.json in " + "OpenstackNode app to push SSH authentication information", srcNode == null ? "" : srcNode.hostname());
return;
}
if (dstIp.equals(osNetService.gatewayIp(srcInstance.get().portId()))) {
dstIp = srcIp;
}
// print uplink flow trace result
String requestStringUplink = traceRequestString(srcIp, dstIp, srcInstance.get(), osNetService, true);
print(FLOW_TRACE_REQUEST_STRING_UPLINK + requestStringUplink);
String requestStringDownlink = traceRequestString(srcIp, dstIp, srcInstance.get(), osNetService, false);
print(FLOW_TRACE_REQUEST_STRING_DOWNLINK + requestStringDownlink);
String traceResult = sendTraceRequestToNode(requestStringUplink + '\n' + requestStringDownlink, srcNode);
print(traceResult);
}
use of org.onosproject.openstacknetworking.api.InstancePortAdminService in project onos by opennetworkinglab.
the class OpenstackResetPortsCommand method doExecute.
@Override
protected void doExecute() {
InstancePortAdminService service = get(InstancePortAdminService.class);
if ((!isAll && !isInactive && portIds == null) || (isAll && isInactive) || (isInactive && portIds != null) || (portIds != null && isAll)) {
print("Please specify one of portIds, --all, and --inactive options.");
return;
}
if (isAll) {
portIds = service.instancePorts().stream().map(InstancePort::portId).toArray(String[]::new);
} else if (isInactive) {
portIds = service.instancePorts().stream().filter(p -> p.state() == INACTIVE).map(InstancePort::portId).toArray(String[]::new);
}
for (String portId : portIds) {
resetPort(service, portId);
print("Successfully requested re-installing flow rules for port %s!", portId);
}
print("Done.");
}
use of org.onosproject.openstacknetworking.api.InstancePortAdminService in project onos by opennetworkinglab.
the class PurgeInstancePortsCommand method doExecute.
@Override
protected void doExecute() {
InstancePortAdminService service = get(InstancePortAdminService.class);
if ((!isAll && !isInactive && !isPending && portIds == null) || (isAll && isInactive && isPending) || (isInactive && isPending && portIds != null) || (portIds != null && isAll && isPending) || (isAll && isInactive && portIds != null)) {
print("Please specify one of portIds, --all or --inactive or --pending options.");
return;
}
if (isAll) {
portIds = service.instancePorts().stream().map(InstancePort::portId).toArray(String[]::new);
} else if (isInactive) {
portIds = service.instancePorts().stream().filter(p -> p.state() == INACTIVE).map(InstancePort::portId).toArray(String[]::new);
} else if (isPending) {
portIds = service.instancePorts().stream().filter(p -> p.state() == REMOVE_PENDING).map(InstancePort::portId).toArray(String[]::new);
}
for (String portId : portIds) {
service.removeInstancePort(portId);
print("Instance port %s has been removed!", portId);
}
print("Done.");
}
Aggregations