use of org.onosproject.ofagent.api.OFAgent in project onos by opennetworkinglab.
the class OFAgentAddControllerCommand method doExecute.
@Override
protected void doExecute() {
if (!isValidController(strCtrl)) {
error("Invalid controller string %s, must be IP:PORT", strCtrl);
return;
}
OFAgentService service = get(OFAgentService.class);
OFAgentAdminService adminService = get(OFAgentAdminService.class);
OFAgent existing = service.agent(NetworkId.networkId(networkId));
if (existing == null) {
error("OFAgent for network %s does not exist", networkId);
return;
}
String[] temp = strCtrl.split(":");
OFAgent updated = DefaultOFAgent.builder().from(existing).addController(DefaultOFController.of(IpAddress.valueOf(temp[0]), TpPort.tpPort(Integer.valueOf(temp[1])))).build();
adminService.updateAgent(updated);
}
use of org.onosproject.ofagent.api.OFAgent in project onos by opennetworkinglab.
the class OFAgentDeleteControllerCommand method doExecute.
@Override
protected void doExecute() {
if (!isValidController(strCtrl)) {
error("Invalid controller string %s, must be IP:PORT", strCtrl);
return;
}
OFAgentService service = get(OFAgentService.class);
OFAgentAdminService adminService = get(OFAgentAdminService.class);
OFAgent existing = service.agent(NetworkId.networkId(networkId));
if (existing == null) {
error("OFAgent for network %s does not exist", networkId);
return;
}
String[] temp = strCtrl.split(":");
OFAgent updated = DefaultOFAgent.builder().from(existing).deleteController(DefaultOFController.of(IpAddress.valueOf(temp[0]), TpPort.tpPort(Integer.valueOf(temp[1])))).build();
adminService.updateAgent(updated);
}
use of org.onosproject.ofagent.api.OFAgent in project onos by opennetworkinglab.
the class OFAgentRemoveCommand method doExecute.
@Override
protected void doExecute() {
OFAgentAdminService adminService = get(OFAgentAdminService.class);
OFAgent removed = adminService.removeAgent(NetworkId.networkId(networkId));
if (removed != null) {
print("Successfully removed OFAgent for network %s", networkId);
} else {
print("Failed to remove OFAgent for network %s", networkId);
}
}
use of org.onosproject.ofagent.api.OFAgent in project onos by opennetworkinglab.
the class OFAgentManager method stopAgent.
@Override
public void stopAgent(NetworkId networkId) {
checkNotNull(networkId, ERR_NULL_NETID);
synchronized (this) {
OFAgent existing = ofAgentStore.ofAgent(networkId);
if (existing == null) {
final String error = String.format(MSG_OFAGENT, networkId, ERR_NOT_EXIST);
throw new IllegalStateException(error);
}
if (existing.state() == STOPPED) {
final String error = String.format(MSG_OFAGENT, networkId, MSG_IN_STOPPED);
throw new IllegalStateException(error);
}
OFAgent updated = DefaultOFAgent.builder().from(existing).state(STOPPED).build();
ofAgentStore.updateOfAgent(updated);
log.info(String.format(MSG_OFAGENT, networkId, MSG_STOPPED));
}
}
use of org.onosproject.ofagent.api.OFAgent in project onos by opennetworkinglab.
the class OFAgentManager method startAgent.
@Override
public void startAgent(NetworkId networkId) {
checkNotNull(networkId, ERR_NULL_NETID);
synchronized (this) {
OFAgent existing = ofAgentStore.ofAgent(networkId);
if (existing == null) {
final String error = String.format(MSG_OFAGENT, networkId, ERR_NOT_EXIST);
throw new IllegalStateException(error);
}
if (existing.state() == STARTED) {
final String error = String.format(MSG_OFAGENT, networkId, MSG_IN_STARTED);
throw new IllegalStateException(error);
}
OFAgent updated = DefaultOFAgent.builder().from(existing).state(STARTED).build();
ofAgentStore.updateOfAgent(updated);
log.info(String.format(MSG_OFAGENT, networkId, MSG_STARTED));
}
}
Aggregations