Search in sources :

Example 1 with KubevirtNode

use of org.onosproject.kubevirtnode.api.KubevirtNode in project onos by opennetworkinglab.

the class DefaultKubevirtPort method tenantDeviceId.

@Override
public DeviceId tenantDeviceId() {
    KubevirtNetworkService networkService = DefaultServiceDirectory.getService(KubevirtNetworkService.class);
    KubevirtNodeService nodeService = DefaultServiceDirectory.getService(KubevirtNodeService.class);
    KubevirtNetwork network = networkService.network(networkId);
    KubevirtNode node = nodeService.node(deviceId);
    if (network == null || node == null) {
        return null;
    } else {
        return network.tenantDeviceId(node.hostname());
    }
}
Also used : KubevirtNodeService(org.onosproject.kubevirtnode.api.KubevirtNodeService) KubevirtNode(org.onosproject.kubevirtnode.api.KubevirtNode)

Example 2 with KubevirtNode

use of org.onosproject.kubevirtnode.api.KubevirtNode in project onos by opennetworkinglab.

the class KubevirtSyncRulesCommand method syncRulesBaseForNode.

private void syncRulesBaseForNode(KubevirtNodeAdminService service, KubevirtNode node) {
    KubevirtNode updated = node.updateState(INIT);
    service.updateNode(updated);
    boolean result = true;
    long timeoutExpiredMs = System.currentTimeMillis() + TIMEOUT_MS;
    while (service.node(node.hostname()).state() != COMPLETE) {
        long waitMs = timeoutExpiredMs - System.currentTimeMillis();
        waitFor(SLEEP_S);
        if (waitMs <= 0) {
            result = false;
            break;
        }
    }
    if (result) {
        print(SUCCESS_MSG, node.hostname());
    } else {
        error(FAIL_MSG, node.hostname());
    }
}
Also used : KubevirtNode(org.onosproject.kubevirtnode.api.KubevirtNode)

Example 3 with KubevirtNode

use of org.onosproject.kubevirtnode.api.KubevirtNode in project onos by opennetworkinglab.

the class KubevirtNetworkHandler method setDefaultEgressRuleToGatewayNode.

private void setDefaultEgressRuleToGatewayNode(KubevirtRouter router, KubevirtNetwork network, DeviceId gwDeviceId, boolean install) {
    MacAddress routerMacAddress = getRouterMacAddress(router);
    if (routerMacAddress == null) {
        log.warn("Setting gateway default eggress rule to gateway for tenant internal network because " + "there's no br-int port for device {}", gwDeviceId);
        return;
    }
    KubevirtNode gwNode = kubevirtNodeService.node(gwDeviceId);
    if (gwNode == null) {
        log.warn("Setting gateway default eggress rule to gateway for tenant internal network because " + "there's no gateway node for device {}", gwDeviceId);
        return;
    }
    PortNumber tunToIntPortNum = portNumber(deviceService, gwNode.tunBridge(), TUNNEL_TO_INTEGRATION);
    TrafficSelector.Builder sBuilder = DefaultTrafficSelector.builder().matchTunnelId(Long.parseLong(network.segmentId()));
    TrafficTreatment.Builder tBuilder = DefaultTrafficTreatment.builder().setOutput(tunToIntPortNum);
    flowService.setRule(appId, gwNode.tunBridge(), sBuilder.build(), tBuilder.build(), PRIORITY_TUNNEL_RULE, TUNNEL_DEFAULT_TABLE, install);
}
Also used : KubevirtNode(org.onosproject.kubevirtnode.api.KubevirtNode) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) KubevirtNetworkingUtil.getRouterMacAddress(org.onosproject.kubevirtnetworking.util.KubevirtNetworkingUtil.getRouterMacAddress) MacAddress(org.onlab.packet.MacAddress) PortNumber(org.onosproject.net.PortNumber) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment)

Example 4 with KubevirtNode

use of org.onosproject.kubevirtnode.api.KubevirtNode in project onos by opennetworkinglab.

the class KubevirtNetworkHandler method setGatewayRuleToWorkerNodeWhenNodeCreated.

private void setGatewayRuleToWorkerNodeWhenNodeCreated(KubevirtNode node, KubevirtNetwork network) {
    KubevirtRouter router = getRouterForKubevirtNetwork(kubevirtRouterService, network);
    if (router == null) {
        return;
    }
    KubevirtNode electedGw = gatewayNodeForSpecifiedRouter(nodeService, router);
    if (electedGw == null) {
        return;
    }
    setDefaultGatewayRuleToWorkerNodeTunBridge(router, network, electedGw.intgBridge(), node, true);
}
Also used : KubevirtNode(org.onosproject.kubevirtnode.api.KubevirtNode) KubevirtRouter(org.onosproject.kubevirtnetworking.api.KubevirtRouter)

Example 5 with KubevirtNode

use of org.onosproject.kubevirtnode.api.KubevirtNode in project onos by opennetworkinglab.

the class KubevirtNetworkHandler method setGatewayArpRulesForTenantNetwork.

private void setGatewayArpRulesForTenantNetwork(KubevirtNode node, KubevirtNetwork network) {
    KubevirtRouter router = getRouterForKubevirtNetwork(kubevirtRouterService, network);
    if (router == null) {
        return;
    }
    KubevirtNode electedGw = gatewayNodeForSpecifiedRouter(nodeService, router);
    if (electedGw == null) {
        return;
    }
    setGatewayArpRuleForTenantInternalNetwork(router, network, TENANT_ARP_TABLE, electedGw.intgBridge(), network.tenantDeviceId(node.hostname()), true);
}
Also used : KubevirtNode(org.onosproject.kubevirtnode.api.KubevirtNode) KubevirtRouter(org.onosproject.kubevirtnetworking.api.KubevirtRouter)

Aggregations

KubevirtNode (org.onosproject.kubevirtnode.api.KubevirtNode)46 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)11 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)11 KubevirtNodeAdminService (org.onosproject.kubevirtnode.api.KubevirtNodeAdminService)10 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)10 TrafficSelector (org.onosproject.net.flow.TrafficSelector)10 DefaultKubevirtNode (org.onosproject.kubevirtnode.api.DefaultKubevirtNode)9 PortNumber (org.onosproject.net.PortNumber)9 Produces (javax.ws.rs.Produces)8 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)6 Path (javax.ws.rs.Path)6 Test (org.junit.Test)6 JsonNode (com.fasterxml.jackson.databind.JsonNode)5 GET (javax.ws.rs.GET)5 KubevirtNodeService (org.onosproject.kubevirtnode.api.KubevirtNodeService)5 KubevirtNodeJsonMatcher.matchesKubevirtNode (org.onosproject.kubevirtnode.codec.KubevirtNodeJsonMatcher.matchesKubevirtNode)5 MacAddress (org.onlab.packet.MacAddress)4 KubevirtPhyInterface (org.onosproject.kubevirtnode.api.KubevirtPhyInterface)4 Device (org.onosproject.net.Device)4 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)3