2 * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
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
8 define(['app/vpp/vpp.module'], function(vpp) {
9 vpp.register.factory('bdmInterfaceService', function(VPPRestangular, bdmVppService) {
12 var Interface = function(tpId, interfaceName) {
13 this['tp-id'] = tpId || null;
14 this['vbridge-topology:user-interface'] = interfaceName;
17 s.createObj = function(tpId, interfaceName) {
18 return new Interface(tpId, interfaceName);
21 s.add = function(interf, bridgeDomainId, vppId, successCallback, errorCallback) {
22 var restObj = VPPRestangular.one('restconf').one('config').one('network-topology:network-topology')
23 .one('topology').one(bridgeDomainId).one('node').one(vppId).one('termination-point').one(encodeURIComponent(interf['tp-id']));
25 var dataObj = {'termination-point': [interf]};
27 var write = function() {
28 restObj.customPUT(dataObj).then(function(data) {
29 successCallback(data);
31 errorCallback(res.data, res.status);
35 var errorCallback = function() {};
37 bdmVppService.checkAndWriteVpp(bridgeDomainId, vppId, write, errorCallback);
42 s.delete = function(interf, bridgeDomainId, vppId, successCallback, errorCallback) {
43 var restObj = VPPRestangular.one('restconf').one('config').one('network-topology:network-topology')
44 .one('topology').one(bridgeDomainId).one('node').one(vppId).one('termination-point').one(encodeURIComponent(interf['tp-id']));
46 restObj.remove().then(function(data) {
47 successCallback(data);
49 errorCallback(res.data, res.status);
53 s.get = function(bridgeDomainId, vppId, successCallback, errorCallback) {
54 var restObj = VPPRestangular.one('restconf').one('config').one('network-topology:network-topology')
55 .one('topology').one(bridgeDomainId).one('node').one(vppId);
57 restObj.get().then(function(data) {
58 successCallback(data);
60 errorCallback(res.data, res.status);