@Override
    public ObjectNode encode(KubevirtNode node, CodecContext context) {
        checkNotNull(node, "Kubevirt node cannot be null");

        ObjectNode result = context.mapper().createObjectNode()
                .put(HOST_NAME, node.hostname())
                .put(TYPE, node.type().name())
                .put(STATE, node.state().name())
                .put(MANAGEMENT_IP, node.managementIp().toString());

        // serialize integration bridge config
        if (node.intgBridge() != null) {
            result.put(INTEGRATION_BRIDGE, node.intgBridge().toString());
        }

        // serialize tunnel bridge config
        if (node.tunBridge() != null) {
            result.put(TUNNEL_BRIDGE, node.tunBridge().toString());
        }

        // serialize data IP only if it presents
        if (node.dataIp() != null) {
            result.put(DATA_IP, node.dataIp().toString());
        }

        // serialize physical interfaces, it is valid only if any of physical interface presents
        if (node.phyIntfs() != null && !node.phyIntfs().isEmpty()) {
            ArrayNode phyIntfs = context.mapper().createArrayNode();
            node.phyIntfs().forEach(phyIntf -> {
                ObjectNode phyIntfJson =
                        context.codec(KubevirtPhyInterface.class).encode(phyIntf, context);
                phyIntfs.add(phyIntfJson);
            });
            result.set(PHYSICAL_INTERFACES, phyIntfs);
        }

        // serialize external bridge if exist
        if (node.gatewayBridgeName() != null) {
            result.put(GATEWAY_BRIDGE_NAME, node.gatewayBridgeName());
        }

        return result;
    }
@Test
    public void testKubevirtComputeNodeEncode() {
        KubevirtPhyInterface phyIntf1 = DefaultKubevirtPhyInterface.builder()
                .network("mgmtnetwork")
                .intf("eth3")
                .physBridge(DEVICE_ID_1)
                .build();

        KubevirtPhyInterface phyIntf2 = DefaultKubevirtPhyInterface.builder()
                .network("oamnetwork")
                .intf("eth4")
                .physBridge(DEVICE_ID_2)
                .build();

        KubevirtNode node = DefaultKubevirtNode.builder()
                .hostname("worker")
                .type(KubevirtNode.Type.WORKER)
                .state(KubevirtNodeState.INIT)
                .managementIp(IpAddress.valueOf("10.10.10.1"))
                .intgBridge(DeviceId.deviceId("br-int"))
                .tunBridge(DeviceId.deviceId("br-tun"))
                .dataIp(IpAddress.valueOf("20.20.20.2"))
                .phyIntfs(ImmutableList.of(phyIntf1, phyIntf2))
                .build();

        ObjectNode nodeJson = kubevirtNodeCodec.encode(node, context);
        assertThat(nodeJson, matchesKubevirtNode(node));
    }