use of org.onosproject.net.behaviour.ControllerInfo in project onos by opennetworkinglab.
the class DefaultK8sHostHandler method createBridge.
private void createBridge(DeviceId ovsdb, K8sBridge bridge) {
Device device = deviceService.getDevice(ovsdb);
List<ControllerInfo> controllers = clusterService.getNodes().stream().map(n -> new ControllerInfo(n.ip(), DEFAULT_OFPORT, DEFAULT_OF_PROTO)).collect(Collectors.toList());
String dpid = bridge.dpid().substring(DPID_BEGIN);
BridgeDescription.Builder builder = DefaultBridgeDescription.builder().name(bridge.name()).failMode(BridgeDescription.FailMode.SECURE).datapathId(dpid).disableInBand().controllers(controllers);
BridgeConfig bridgeConfig = device.as(BridgeConfig.class);
bridgeConfig.addBridge(builder.build());
}
use of org.onosproject.net.behaviour.ControllerInfo in project onos by opennetworkinglab.
the class KubevirtNetworkHandler method createBridge.
private void createBridge(KubevirtNode node, KubevirtNetwork network) {
Device tenantBridge = deviceService.getDevice(network.tenantDeviceId(node.hostname()));
if (tenantBridge != null && deviceService.isAvailable(tenantBridge.id())) {
log.warn("The tenant bridge {} already exists at node {}", network.tenantBridgeName(), node.hostname());
return;
}
Device device = deviceService.getDevice(node.ovsdb());
IpAddress controllerIp = apiConfigService.apiConfig().controllerIp();
String serviceFqdn = apiConfigService.apiConfig().serviceFqdn();
IpAddress serviceIp = null;
if (controllerIp == null) {
if (serviceFqdn != null) {
serviceIp = resolveHostname(serviceFqdn);
}
if (serviceIp != null) {
controllerIp = serviceIp;
} else {
controllerIp = apiConfigService.apiConfig().ipAddress();
}
}
ControllerInfo controlInfo = new ControllerInfo(controllerIp, DEFAULT_OFPORT, DEFAULT_OF_PROTO);
List<ControllerInfo> controllers = Lists.newArrayList(controlInfo);
String dpid = network.tenantDeviceId(node.hostname()).toString().substring(DPID_BEGIN);
// if the bridge is already available, we skip creating a new bridge
if (!deviceService.isAvailable(DeviceId.deviceId(dpid))) {
BridgeDescription.Builder builder = DefaultBridgeDescription.builder().name(network.tenantBridgeName()).failMode(BridgeDescription.FailMode.SECURE).datapathId(dpid).disableInBand().controllers(controllers);
BridgeConfig bridgeConfig = device.as(BridgeConfig.class);
bridgeConfig.addBridge(builder.build());
log.info("Created a new tunnel bridge for network {} at node {}", network.networkId(), node.hostname());
waitFor(3);
}
}
use of org.onosproject.net.behaviour.ControllerInfo in project onos by opennetworkinglab.
the class DefaultKubevirtNodeHandler method createBridge.
/**
* Creates a bridge with a given name on a given kubernetes node.
*
* @param node kubevirt node
* @param bridgeName bridge name
* @param devId device identifier
*/
private void createBridge(KubevirtNode node, String bridgeName, DeviceId devId) {
Device device = deviceService.getDevice(node.ovsdb());
IpAddress controllerIp = apiConfigService.apiConfig().controllerIp();
String serviceFqdn = apiConfigService.apiConfig().serviceFqdn();
IpAddress serviceIp = null;
if (controllerIp == null) {
if (serviceFqdn != null) {
serviceIp = resolveHostname(serviceFqdn);
}
if (serviceIp != null) {
controllerIp = serviceIp;
} else {
controllerIp = apiConfigService.apiConfig().ipAddress();
}
}
ControllerInfo controlInfo = new ControllerInfo(controllerIp, DEFAULT_OFPORT, DEFAULT_OF_PROTO);
List<ControllerInfo> controllers = Lists.newArrayList(controlInfo);
String dpid = devId.toString().substring(DPID_BEGIN);
BridgeDescription.Builder builder = DefaultBridgeDescription.builder().name(bridgeName).failMode(BridgeDescription.FailMode.SECURE).datapathId(dpid).disableInBand().controllers(controllers);
BridgeConfig bridgeConfig = device.as(BridgeConfig.class);
bridgeConfig.addBridge(builder.build());
}
use of org.onosproject.net.behaviour.ControllerInfo in project onos by opennetworkinglab.
the class OpenstackNodeCodecTest method testOpenstackComputeNodeEncode.
/**
* Tests the openstack compute node encoding.
*/
@Test
public void testOpenstackComputeNodeEncode() {
OpenstackPhyInterface phyIntf1 = DefaultOpenstackPhyInterface.builder().network("mgmtnetwork").intf("eth3").build();
OpenstackPhyInterface phyIntf2 = DefaultOpenstackPhyInterface.builder().network("oamnetwork").intf("eth4").build();
OpenstackSshAuth sshAuth = DefaultOpenstackSshAuth.builder().id("sdn").password("sdn").build();
ControllerInfo controller1 = new ControllerInfo(IpAddress.valueOf("10.10.10.2"), 6653, "tcp");
ControllerInfo controller2 = new ControllerInfo(IpAddress.valueOf("10.10.10.3"), 6663, "tcp");
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")).phyIntfs(ImmutableList.of(phyIntf1, phyIntf2)).controllers(ImmutableList.of(controller1, controller2)).sshAuthInfo(sshAuth).build();
ObjectNode nodeJson = openstackNodeCodec.encode(node, context);
assertThat(nodeJson, matchesOpenstackNode(node));
}
use of org.onosproject.net.behaviour.ControllerInfo in project onos by opennetworkinglab.
the class DeviceSetControllersCommand method doExecute.
@Override
protected void doExecute() {
if (controllersListStrings == null && !removeCont && !removeAll) {
print("No controller are given, skipping.");
return;
}
if (controllersListStrings != null) {
Arrays.asList(controllersListStrings).forEach(cInfoString -> {
ControllerInfo controllerInfo = parseCInfoString(cInfoString);
if (controllerInfo != null) {
controllers.add(controllerInfo);
}
});
}
DriverService service = get(DriverService.class);
deviceId = DeviceId.deviceId(uri);
DriverHandler h = service.createHandler(deviceId);
ControllerConfig config = h.behaviour(ControllerConfig.class);
print("before:");
config.getControllers().forEach(c -> print(c.target()));
try {
if (removeAll) {
if (!controllers.isEmpty()) {
print("Controllers list should be empty to remove all controllers");
} else {
List<ControllerInfo> controllersToRemove = config.getControllers();
controllersToRemove.forEach(c -> print("Will remove " + c.target()));
config.removeControllers(controllersToRemove);
}
} else {
if (controllers.isEmpty()) {
print("Controllers list is empty, cannot set/remove empty controllers");
} else {
if (removeCont) {
print("Will remove specified controllers");
config.removeControllers(controllers);
} else {
print("Will add specified controllers");
config.setControllers(controllers);
}
}
}
} catch (NullPointerException e) {
print("No Device with requested parameters {} ", uri);
}
print("after:");
config.getControllers().forEach(c -> print(c.target()));
print("size %d", config.getControllers().size());
}
Aggregations