Search in sources :

Example 11 with OFAgentAdminService

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);
}
Also used : TenantId(org.onosproject.net.TenantId) VirtualNetworkService(org.onosproject.incubator.net.virtual.VirtualNetworkService) DefaultOFController(org.onosproject.ofagent.impl.DefaultOFController) OFController(org.onosproject.ofagent.api.OFController) DefaultOFAgent(org.onosproject.ofagent.impl.DefaultOFAgent) OFAgent(org.onosproject.ofagent.api.OFAgent) 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