use of org.onosproject.ofagent.api.OFAgentAdminService 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