use of org.onosproject.ofagent.api.OFController in project onos by opennetworkinglab.
the class OFAgentCodec method decode.
public OFAgent decode(ObjectNode json, CodecContext context) {
JsonNode networkId = json.get("networkId");
checkNotNull(networkId);
JsonNode tenantId = json.get("tenantId");
checkNotNull(tenantId);
checkNotNull(json.get("controllers"));
checkState(json.get("controllers").isArray());
Set<OFController> controllers = Sets.newHashSet();
json.get("controllers").forEach(jsonController -> controllers.add((new OFControllerCodec()).decode((ObjectNode) jsonController, context)));
return DefaultOFAgent.builder().networkId(NetworkId.networkId(networkId.asLong())).tenantId(TenantId.tenantId(tenantId.asText())).controllers(controllers).state(OFAgent.State.STOPPED).build();
}
use of org.onosproject.ofagent.api.OFController in project onos by opennetworkinglab.
the class OFAgentCreateCommand method doExecute.
@Override
protected void doExecute() {
Set<OFController> ctrls = Sets.newHashSet();
for (String strCtrl : strCtrls) {
if (!isValidController(strCtrl)) {
print("Invalid controller %s, ignores it.", strCtrl);
continue;
}
String[] temp = strCtrl.split(":");
ctrls.add(DefaultOFController.of(IpAddress.valueOf(temp[0]), TpPort.tpPort(Integer.valueOf(temp[1]))));
}
VirtualNetworkService virtualNetworkService = get(VirtualNetworkService.class);
TenantId tenantId = virtualNetworkService.getTenantId(NetworkId.networkId(networkId));
checkNotNull(tenantId, "Virtual network %s does not have tenant.", networkId);
OFAgentAdminService adminService = get(OFAgentAdminService.class);
OFAgent ofAgent = DefaultOFAgent.builder().networkId(NetworkId.networkId(networkId)).tenantId(tenantId).controllers(ctrls).state(OFAgent.State.STOPPED).build();
adminService.createAgent(ofAgent);
print("Successfully created OFAgent for network %s, tenant %s", networkId, tenantId);
}
Aggregations