Initial OR-TAPI mapping: Topology
[transportpce.git] / tapi / src / main / java / org / opendaylight / transportpce / tapi / utils / TapiInitialORMapping.java
1 /*
2  * Copyright © 2021 Nokia, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.transportpce.tapi.utils;
9
10 import java.util.HashMap;
11 import java.util.Map;
12 import org.opendaylight.transportpce.tapi.topology.TapiTopologyException;
13 import org.opendaylight.transportpce.tapi.topology.TopologyUtils;
14 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.tapi.context.ServiceInterfacePoint;
15 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.common.rev181210.tapi.context.ServiceInterfacePointKey;
16 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.context.Topology;
17 import org.opendaylight.yang.gen.v1.urn.onf.otcc.yang.tapi.topology.rev181210.topology.context.TopologyKey;
18 import org.slf4j.Logger;
19 import org.slf4j.LoggerFactory;
20
21 public class TapiInitialORMapping {
22
23     private static final Logger LOG = LoggerFactory.getLogger(TapiInitialORMapping.class);
24     private final TapiContext tapiContext;
25     private final TopologyUtils topologyUtils;
26
27     public TapiInitialORMapping(TopologyUtils topologyUtils, TapiContext tapiContext) {
28         this.topologyUtils = topologyUtils;
29         this.tapiContext = tapiContext;
30     }
31
32     public void performTopoInitialMapping() {
33         // creation of both topologies but with the fully roadm infrastructure.
34         try {
35             LOG.info("Performing initial mapping between OR and TAPI models.");
36             Topology t0FullMultiLayer = this.topologyUtils.createFullOtnTopology();
37             Map<TopologyKey, Topology> topologyMap = new HashMap<>();
38             topologyMap.put(t0FullMultiLayer.key(), t0FullMultiLayer);
39             this.tapiContext.updateTopologyContext(topologyMap);
40             Map<ServiceInterfacePointKey, ServiceInterfacePoint> sipMap = this.topologyUtils.getSipMap();
41             this.tapiContext.updateSIPContext(sipMap);
42         } catch (TapiTopologyException e) {
43             LOG.error("error building TAPI topology", e);
44         }
45     }
46 }