Search in sources :

Example 1 with OFAgentAdminService

use of org.onosproject.ofagent.api.OFAgentAdminService in project onos by opennetworkinglab.

the class OFAgentStartCommand method doExecute.

@Override
protected void doExecute() {
    OFAgentAdminService adminService = get(OFAgentAdminService.class);
    adminService.startAgent(NetworkId.networkId(networkId));
    print("Successfully started OFAgent for network %s", networkId);
}
Also used : OFAgentAdminService(org.onosproject.ofagent.api.OFAgentAdminService)

Example 2 with OFAgentAdminService

use of org.onosproject.ofagent.api.OFAgentAdminService 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);
}
Also used : DefaultOFAgent(org.onosproject.ofagent.impl.DefaultOFAgent) OFAgent(org.onosproject.ofagent.api.OFAgent) OFAgentService(org.onosproject.ofagent.api.OFAgentService) OFAgentAdminService(org.onosproject.ofagent.api.OFAgentAdminService)

Example 3 with OFAgentAdminService

use of org.onosproject.ofagent.api.OFAgentAdminService 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);
}
Also used : DefaultOFAgent(org.onosproject.ofagent.impl.DefaultOFAgent) OFAgent(org.onosproject.ofagent.api.OFAgent) OFAgentService(org.onosproject.ofagent.api.OFAgentService) OFAgentAdminService(org.onosproject.ofagent.api.OFAgentAdminService)

Example 4 with OFAgentAdminService

use of org.onosproject.ofagent.api.OFAgentAdminService 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);
    }
}
Also used : OFAgent(org.onosproject.ofagent.api.OFAgent) OFAgentAdminService(org.onosproject.ofagent.api.OFAgentAdminService)

Example 5 with OFAgentAdminService

use of org.onosproject.ofagent.api.OFAgentAdminService in project onos by opennetworkinglab.

the class OFAgentStopCommand method doExecute.

@Override
protected void doExecute() {
    OFAgentAdminService adminService = get(OFAgentAdminService.class);
    adminService.stopAgent(NetworkId.networkId(networkId));
    print("Successfully stopped OFAgent for network %s", networkId);
}
Also used : OFAgentAdminService(org.onosproject.ofagent.api.OFAgentAdminService)

Aggregations

OFAgentAdminService (org.onosproject.ofagent.api.OFAgentAdminService)11 OFAgent (org.onosproject.ofagent.api.OFAgent)7 Path (javax.ws.rs.Path)5 Consumes (javax.ws.rs.Consumes)4 OFAgentService (org.onosproject.ofagent.api.OFAgentService)4 POST (javax.ws.rs.POST)3 DefaultOFAgent (org.onosproject.ofagent.impl.DefaultOFAgent)3 JsonNode (com.fasterxml.jackson.databind.JsonNode)2 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)2 DELETE (javax.ws.rs.DELETE)1 PUT (javax.ws.rs.PUT)1 VirtualNetworkService (org.onosproject.incubator.net.virtual.VirtualNetworkService)1 TenantId (org.onosproject.net.TenantId)1 OFController (org.onosproject.ofagent.api.OFController)1 DefaultOFController (org.onosproject.ofagent.impl.DefaultOFController)1