use of org.onosproject.openstacknode.api.OpenstackNodeAdminService in project onos by opennetworkinglab.
the class OpenstackConfigStatefulSnatCommand method syncRules.
private void syncRules() {
// All handlers in this application reacts the node complete event and
// tries to re-configure flow rules for the complete node.
OpenstackNodeService osNodeService = get(OpenstackNodeService.class);
OpenstackNodeAdminService osNodeAdminService = get(OpenstackNodeAdminService.class);
if (osNodeService == null) {
error("Failed to re-install flow rules for OpenStack networking.");
return;
}
osNodeService.completeNodes().forEach(osNode -> {
OpenstackNode updated = osNode.updateState(NodeState.INIT);
osNodeAdminService.updateNode(updated);
});
}
use of org.onosproject.openstacknode.api.OpenstackNodeAdminService in project onos by opennetworkinglab.
the class OpenstackConfigArpModeCommand method syncRules.
private void syncRules() {
// All handlers in this application reacts the node complete event and
// tries to re-configure flow rules for the complete node.
OpenstackNodeService osNodeService = get(OpenstackNodeService.class);
OpenstackNodeAdminService osNodeAdminService = get(OpenstackNodeAdminService.class);
if (osNodeService == null) {
error("Failed to re-install flow rules for OpenStack networking.");
return;
}
osNodeService.completeNodes().forEach(osNode -> {
OpenstackNode updated = osNode.updateState(NodeState.INIT);
osNodeAdminService.updateNode(updated);
});
}
use of org.onosproject.openstacknode.api.OpenstackNodeAdminService 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.openstacknode.api.OpenstackNodeAdminService in project onos by opennetworkinglab.
the class OpenstackSyncRulesCommand method doExecute.
@Override
protected void doExecute() {
// All handlers in this application reacts the node complete event and
// tries to re-configure flow rules for the complete node.
OpenstackNodeAdminService osNodeService = get(OpenstackNodeAdminService.class);
if (osNodeService == null) {
error("Failed to re-install flow rules for OpenStack networking.");
return;
}
// we first initialize the COMPUTE node, in order to feed all instance ports
// by referring to ports' information obtained from neutron server
osNodeService.completeNodes(COMPUTE).forEach(osNode -> syncRulesBaseForNode(osNodeService, osNode));
osNodeService.completeNodes(GATEWAY).forEach(osNode -> syncRulesBaseForNode(osNodeService, osNode));
print("Successfully requested re-installing flow rules.");
}
use of org.onosproject.openstacknode.api.OpenstackNodeAdminService in project onos by opennetworkinglab.
the class OpenstackNodeInitCommand method doExecute.
@Override
protected void doExecute() {
OpenstackNodeService osNodeService = get(OpenstackNodeService.class);
OpenstackNodeAdminService osNodeAdminService = get(OpenstackNodeAdminService.class);
if (isAll && isIncomplete) {
print("Please specify one of hostname, --all, and --incomplete options.");
return;
}
if (isAll) {
hostnames = osNodeService.nodes().stream().map(OpenstackNode::hostname).toArray(String[]::new);
} else if (isIncomplete) {
hostnames = osNodeService.nodes().stream().filter(osNode -> osNode.state() != NodeState.COMPLETE).map(OpenstackNode::hostname).toArray(String[]::new);
}
if (hostnames == null) {
print("Please specify one of hostname, --all, and --incomplete options.");
return;
}
for (String hostname : hostnames) {
OpenstackNode osNode = osNodeService.node(hostname);
if (osNode == null) {
print("Unable to find %s", hostname);
continue;
}
print("Initializing %s", hostname);
OpenstackNode updated = osNode.updateState(NodeState.INIT);
osNodeAdminService.updateNode(updated);
}
print("Done.");
}
Aggregations