blob: 107440c0e5774b74b072ab42b54dc366f6812392 [file] [log] [blame]
Gaurav Agrawalc6d536f2017-03-17 11:56:31 +05301/*
2 * Copyright 2017-present Open Networking Laboratory
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
janani bf41dec32017-03-24 18:44:07 +053016
17package org.onosproject.l3vpn.netl3vpn.impl;
Gaurav Agrawalc6d536f2017-03-17 11:56:31 +053018
19import org.apache.felix.scr.annotations.Activate;
20import org.apache.felix.scr.annotations.Component;
21import org.apache.felix.scr.annotations.Deactivate;
22import org.apache.felix.scr.annotations.Reference;
23import org.apache.felix.scr.annotations.ReferenceCardinality;
24import org.onosproject.core.CoreService;
25import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev20130715.IetfInetTypes;
26import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.l3vpn.svc.rev20160730.IetfL3VpnSvc;
27import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev20130715.IetfYangTypes;
28import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.l3vpn.svc.ext.rev20160730.L3VpnSvcExt;
29import org.onosproject.yang.model.YangModel;
30import org.onosproject.yang.model.YangModuleId;
31import org.onosproject.yang.runtime.DefaultAppModuleInfo;
32import org.onosproject.yang.runtime.DefaultModelRegistrationParam;
33import org.onosproject.yang.runtime.ModelRegistrationParam;
34import org.onosproject.yang.runtime.YangModelRegistry;
35import org.slf4j.Logger;
36import org.slf4j.LoggerFactory;
37
38import java.util.Iterator;
39
40import static org.onosproject.yang.runtime.helperutils.YangApacheUtils.getYangModel;
41
42/**
43 * The IETF net l3vpn manager implementation.
janani bf41dec32017-03-24 18:44:07 +053044 * // TODO: Implementation of the manager class.
Gaurav Agrawalc6d536f2017-03-17 11:56:31 +053045 */
46@Component(immediate = true)
47public class NetL3vpnManager {
48
49 private static final String APP_ID = "org.onosproject.app.l3vpn";
50 private final Logger log = LoggerFactory.getLogger(getClass());
51
52 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
53 protected CoreService coreService;
54
55 @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
56 protected YangModelRegistry modelRegistry;
57
58 private ModelRegistrationParam regParam = null;
59
60 @Activate
61 protected void activate() {
62 coreService.registerApplication(APP_ID);
63 log.info("Started");
64 //TODO implementation
65 }
66
67 @Deactivate
68 protected void deactivate() {
69 modelRegistry.unregisterModel(regParam);
70 log.info("Stopped");
71 }
72
73 private void registerModel() {
74 YangModel model = getYangModel(getClass());
75 Iterator<YangModuleId> it = model.getYangModulesId().iterator();
76
77 //Create model registration param.
78 ModelRegistrationParam.Builder b =
79 DefaultModelRegistrationParam.builder().setYangModel(model);
80
81 YangModuleId id;
82 while (it.hasNext()) {
83 id = it.next();
84 switch (id.moduleName()) {
85 case "ietf-inet-types":
86 b.addAppModuleInfo(id, new DefaultAppModuleInfo(
87 IetfInetTypes.class, null));
88 break;
89 case "ietf-l3vpn-svc":
90 b.addAppModuleInfo(id, new DefaultAppModuleInfo(
91 IetfL3VpnSvc.class, null));
92 break;
93 case "ietf-yang-types":
94 b.addAppModuleInfo(id, new DefaultAppModuleInfo(
95 IetfYangTypes.class, null));
96 break;
97 case "l3vpn-svc-ext":
98 b.addAppModuleInfo(id, new DefaultAppModuleInfo(
99 L3VpnSvcExt.class, null));
100 break;
101 default:
102 break;
103 }
104 }
105 regParam = b.build();
106 modelRegistry.registerModel(regParam);
107 }
108}