});
};
- $scope.addProfile = new CpeuiDialogs.Dialog('AddProfile', {}, function(obj) {
- if (obj.default_cbs) {
- obj.cbs = Math.floor(obj.cir/10);
+ var profileDialogController = function($scope, $mdDialog) {
+
+ $scope.getDefualtCbs = function(cir) {
+ return Math.round(cir * 0.0125);
}
+
+ $scope.done = function() {
+ if ($scope.obj.default_cbs) {
+ $scope.obj.cbs = $scope.getDefualtCbs($scope.obj.cir);
+ }
+ if ($scope.projectForm.$valid) {
+ $scope.callback($scope.obj);
+ $mdDialog.hide();
+ }
+ };
+ };
+
+ $scope.addProfile = new CpeuiDialogs.Dialog('AddProfile', {}, function(obj) {
CpeuiSvc.addProfile(obj['bw-profile'], obj.cir, obj.cbs, function() {
$scope.updateProfilesView();
});
- });
+ }, profileDialogController);
$scope.editProfile = function(profileName, cbs, cir) {
new CpeuiDialogs.Dialog('AddProfile', {}, function(obj) {
- if (obj.default_cbs) {
- obj.cbs = Math.floor(obj.cir/10);
- }
CpeuiSvc.editProfile(obj['bw-profile'], obj.cir, obj.cbs, function() {
$scope.updateProfilesView();
});
- }).show(null,{edit:true, profileName:profileName, cbs:cbs, cir:cir});
+ }, profileDialogController).show(null,{edit:true, profileName:profileName, cbs:cbs, cir:cir});
};
$scope.deleteProfile = function(profileName) {
<thead>
<tr>
<th>Profile Name</th>
- <th>Committed Information Rate (KB/s)</th>
- <th>Committed Burst Size (bytes)</th>
+ <th>Committed Information Rate (kb/s)</th>
+ <th>Committed Burst Size (Bytes)</th>
<th></th>
</tr>
</thead>
'app/cpeui/tenant.controller',
'app/cpeui/tenantsTable.controller' ];
var services = ['app/cpeui/services/cpeui.services',
+ 'app/cpeui/services/utils',
'app/cpeui/services/cpeui.dialogs', ];
var directives = [];
var modules = [ 'app/cpeui/cpeui.module' ];
cpeui.controller('CpeuiCtrl', function($scope, $rootScope, $state, $mdDialog,$mdMedia) {
- $rootScope['section_logo'] = 'static/cpe.png'; // Add your topbar logo
- // location here such as
- // 'assets/images/logo_topology.gif'
-
$rootScope.section_logo = 'src/app/cpeui/static/logo_hpe.gif';
var mainTabIndexs = {
'app/cpeui/assets/angular-material.min',
'app/cpeui/assets/angular-animate.min',
'app/cpeui/assets/angular-aria.min',
- 'app/cpeui/assets/angular-messages.min', 'app/cpeui/utils' ], function(ng) {
+ 'app/cpeui/assets/angular-messages.min'], function(ng) {
var cpeui = angular.module('app.cpeui', [ 'app.core', 'ui.router.state','restangular', 'config', 'ngMaterial', 'ngMessages', 'ngAnimate' ]);
- cpeui.config(function($stateProvider, $compileProvider, $controllerProvider, $provide, NavHelperProvider, $translateProvider) {
+ cpeui.config(function($stateProvider, $compileProvider, $controllerProvider, $provide, NavHelperProvider, $translateProvider, $urlRouterProvider) {
cpeui.register = cpeui; // for adding services, controllers, directives etc.
// to angular module before bootstrap
service : $provide.service
};
+
+ $urlRouterProvider.otherwise("/cpeui/admin/");
NavHelperProvider.addControllerUrl('app/cpeui/cpeui.controller');
NavHelperProvider.addToMenu('cpe', {
<md-content layout-padding>
<md-input-container class="md-block" ng-init="obj['bw-profile'] = params.profileName">
<label>Profile Name</label>
- <input name="profilename" ng-model="obj['bw-profile']" ng-disabled="params.edit">
+ <input name="profilename" required ng-model="obj['bw-profile']" ng-disabled="params.edit">
<div ng-messages="projectForm.profilename.$error">
<div ng-message="required">This is required!</div>
</div>
</md-input-container>
<md-input-container class="md-block" ng-init="obj.cir = params.cir">
- <label>Committed Information Rate (KB/s)</label>
+ <label>Committed Information Rate (kb/s)</label>
<input type="number" required name="cir" ng-model="obj.cir" min="0">
<div ng-messages="projectForm.cir.$error">
<div ng-message="required">Number is required!</div>
<div ng-message="min">Number must be positive!</div>
</div>
</md-input-container>
- <md-checkbox name="" ng-model="obj.default_cbs" ng-init="obj.default_cbs = true">
- Use default Committed Burst Size {{obj.cir ? '('+((obj.cir - (obj.cir % 10)) / 10) + ' bytes)': ''}}
+ <md-checkbox name="" ng-model="obj.default_cbs" ng-init="obj.default_cbs = (!params.edit || getDefualtCbs(params.cir) == params.cbs)">
+ Use default Committed Burst Size {{obj.cir ? ('(' + getDefualtCbs(obj.cir) + ' Bytes)') : ''}}
</md-checkbox>
<md-input-container class="md-block" ng-if="!obj.default_cbs" ng-init="obj.cbs = params.cbs">
- <label>Committed Burst Size (bytes)</label>
+ <label>Committed Burst Size (Bytes)</label>
<input type="number" required name="cbs" ng-model="obj.cbs" min="0">
<div ng-messages="projectForm.cbs.$error">
<div ng-message="required">Number is required!</div>
this.dialogController = function($scope, $mdDialog, params) {
$scope.params = params;
+ $scope.callback = callback;
$scope.obj = {};
$scope.hide = function() {
};
$scope.done = function() {
if ($scope.projectForm.$valid) {
- callback($scope.obj);
+ $scope.callback($scope.obj);
$mdDialog.hide();
}
};
--- /dev/null
+define([ 'app/cpeui/cpeui.module' ], function(cpeui) {
+
+ Array.prototype.filterByField = function(field_name, value, to_filter_out) {
+ if (to_filter_out == undefined) {
+ to_filter_out = false;
+ }
+ return this.filter(function(item) {
+ return (item[field_name] == value) != to_filter_out;
+ });
+ };
+});
+++ /dev/null
-Array.prototype.filterByField = function(field_name, value, to_filter_out) {
- if (to_filter_out == undefined) {
- to_filter_out = false;
- }
- return this.filter(function(item) {
- return (item[field_name] == value) != to_filter_out;
- });
-};
\ No newline at end of file
private static final Logger Log = LoggerFactory.getLogger(DataWaitListener.class);
InstanceIdentifier<D> objectIdentifierId;
private ListenerRegistration<DataWaitListener> dataWaitListenerRegistration;
- Boolean dataAvailable = false;
+ private Boolean dataAvailable = false;
+ private final Object lockDataAvailable = new Object();
private int maxRetries;
LogicalDatastoreType logicalDatastoreType;
DataWaitGetter<D> getData;
if (newDataObject.getRootPath() != null && newDataObject.getRootNode() != null) {
Log.info("data {} created", newDataObject.getRootNode().getIdentifier());
}
- synchronized (dataAvailable) {
- dataAvailable.notifyAll();
+ synchronized (lockDataAvailable) {
+ lockDataAvailable.notifyAll();
}
}
if (modifiedDataObject.getRootPath() != null && modifiedDataObject.getRootNode() != null) {
Log.info("data {} updated", modifiedDataObject.getRootNode().getIdentifier());
}
- synchronized (dataAvailable) {
- dataAvailable.notifyAll();
+ synchronized (lockDataAvailable) {
+ lockDataAvailable.notifyAll();
}
}
}
public boolean waitForData(int retry) {
- synchronized (dataAvailable) {
+ synchronized (lockDataAvailable) {
dataAvailable = dataAvailable();
if (dataAvailable == true) {
return true;
return false;
}
try {
- dataAvailable.wait(waitMillisec);
+ lockDataAvailable.wait(waitMillisec);
} catch (InterruptedException e1) {
}
}
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.etree.rev160614.EtreeInterface.EtreeInterfaceType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.VpnToDpnList;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.vpn.to.dpn.list.VpnInterfaces;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.to.vpn.id.VpnInstance;
import org.opendaylight.yangtools.concepts.ListenerRegistration;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
MdsalUtils.commitTransaction(tx);
InstanceIdentifier<VpnInstance> vpnId = NetvirtVpnUtils.getVpnInstanceToVpnIdIdentifier(vpnName);
- DataWaitListener<VpnInstance> vpnInstanceWaiter = new DataWaitListener<VpnInstance>(dataBroker, vpnId,
- 5, LogicalDatastoreType.CONFIGURATION, vpn -> vpn.getVrfId());
+ DataWaitListener<VpnInstance> vpnInstanceWaiter = new DataWaitListener<>(dataBroker, vpnId, 10,
+ LogicalDatastoreType.CONFIGURATION, vpn -> vpn.getVrfId());
if (!vpnInstanceWaiter.waitForData()) {
String errorMessage = String.format("Fail to wait for vrfId for vpn %s", vpnName);
Log.error(errorMessage);
String vpnName = operIpvcVpn.getVpnId();
InstanceIdentifier<VpnInstance> vpnId = NetvirtVpnUtils.getVpnInstanceToVpnIdIdentifier(vpnName);
@SuppressWarnings("resource")
- DataWaitListener<VpnInstance> vpnInstanceWaiter = new DataWaitListener<VpnInstance>(dataBroker, vpnId, 5,
+ DataWaitListener<VpnInstance> vpnInstanceWaiter = new DataWaitListener<>(dataBroker, vpnId, 10,
LogicalDatastoreType.CONFIGURATION, vpn -> vpn.getVrfId());
if (!vpnInstanceWaiter.waitForData()) {
String errorMessage = String.format("Fail to wait for vrfId for vpn %s", vpnName);
uniToRemove.removeAll(updateUni);
removeUnis(ipvcId, operIpvcVpn, uniToRemove, txRemove);
MdsalUtils.commitTransaction(txRemove);
+ }
+ List<Uni> uniToCreate = new ArrayList<>(updateUni);
+ uniToCreate.removeAll(originalUni);
- List<Uni> uniToCreate = new ArrayList<>(updateUni);
- uniToCreate.removeAll(originalUni);
- for (Uni uni : uniToCreate) {
- createInterfaces(vpnName, uni, ipvcId, rd);
- }
- createUnis(ipvcId, uniToCreate);
+ for (Uni uni : uniToCreate) {
+ createInterfaces(vpnName, uni, ipvcId, rd);
}
+ createUnis(ipvcId, uniToCreate);
} catch (final Exception e) {
Log.error("Update ipvc failed !", e);
MdsalUtils.commitTransaction(tx);
}
+ waitForInterfaceDpn(vpnName, rd, interfaceName);
+
+ NetvirtVpnUtils.createVpnPortFixedIp(dataBroker, vpnName, interfaceName, ipUni.getIpAddress(),
+ uni.getMacAddress());
+ }
+
+ private void waitForInterfaceDpn(String vpnName, String rd, String interfaceName) {
InstanceIdentifier<VpnInstanceOpDataEntry> vpnId = NetvirtVpnUtils.getVpnInstanceOpDataIdentifier(rd);
+ DataWaitGetter<VpnInstanceOpDataEntry> getInterfByName = (vpn) -> {
+ if (vpn.getVpnToDpnList() == null)
+ return null;
+ for (VpnToDpnList is : vpn.getVpnToDpnList()) {
+ if (is.getVpnInterfaces() == null)
+ continue;
+ for (VpnInterfaces i : is.getVpnInterfaces()) {
+ if (i.getInterfaceName().equals(interfaceName))
+ return interfaceName;
+ }
+ }
+ return null;
+ };
@SuppressWarnings("resource")
- DataWaitListener<VpnInstanceOpDataEntry> vpnInstanceWaiter = new DataWaitListener<VpnInstanceOpDataEntry>(
- dataBroker, vpnId, 5, LogicalDatastoreType.OPERATIONAL, vpn -> vpn.getVpnToDpnList());
+ DataWaitListener<VpnInstanceOpDataEntry> vpnInstanceWaiter = new DataWaitListener<>(dataBroker, vpnId, 10,
+ LogicalDatastoreType.OPERATIONAL, getInterfByName);
if (!vpnInstanceWaiter.waitForData()) {
String errorMessage = String.format("Fail to wait for vpn to dpn list %s", vpnName);
Log.error(errorMessage);
throw new UnsupportedOperationException(errorMessage);
}
-
- NetvirtVpnUtils.createVpnPortFixedIp(dataBroker, vpnName, interfaceName, ipUni.getIpAddress(),
- uni.getMacAddress());
}
private String createElanInterface(String vpnName, InstanceIdentifier<Ipvc> ipvcId, String uniId, String elanName,
public static void addDirectSubnetToVpn(DataBroker dataBroker,
final NotificationPublishService notificationPublishService, String vpnName, String subnetName,
- IpPrefix subnetIpPrefix, String interfaceName, int waitForElan) {
+ IpPrefix subnetIpPrefix, String interfaceName, String intfMac, int waitForElan) {
InstanceIdentifier<ElanInstance> elanIdentifierId = NetvirtUtils.getElanInstanceInstanceIdentifier(subnetName);
@SuppressWarnings("resource") // AutoCloseable
- DataWaitListener<ElanInstance> elanTagWaiter = new DataWaitListener<ElanInstance>(dataBroker, elanIdentifierId,
+ DataWaitListener<ElanInstance> elanTagWaiter = new DataWaitListener<>(dataBroker, elanIdentifierId,
10, LogicalDatastoreType.CONFIGURATION, el -> el.getElanTag());
if (!elanTagWaiter.waitForData()) {
logger.error("Trying to add invalid elan {} to vpn {}", subnetName, vpnName);
String subnetIp = getSubnetFromPrefix(ipPrefixToString(subnetIpPrefix));
logger.info("Adding subnet {} {} to vpn {}", subnetName, subnetIp, vpnName);
- updateSubnetNode(dataBroker, new Uuid(vpnName), subnetId, subnetIp);
+ updateSubnetNode(dataBroker, new Uuid(vpnName), subnetId, subnetIp, intfMac);
logger.info("Adding port {} to subnet {}", interfaceName, subnetName);
- updateSubnetmapNodeWithPorts(dataBroker, subnetId, new Uuid(interfaceName), null);
+ updateSubnetmapNodeWithPorts(dataBroker, subnetId, new Uuid(interfaceName), null, vpnName);
Optional<ElanInstance> elanInstance = MdsalUtils.read(dataBroker, LogicalDatastoreType.CONFIGURATION,
elanIdentifierId);
publishSubnetRemoveNotification(notificationPublishService, subnetId, vpnName, elanTag);
logger.info("Removing port {} from subnet {}", interfaceName, subnetName);
- updateSubnetmapNodeWithPorts(dataBroker, subnetId, null, new Uuid(interfaceName));
+ updateSubnetmapNodeWithPorts(dataBroker, subnetId, null, new Uuid(interfaceName), vpnName);
logger.info("Removing subnet {} from vpn {}", subnetName, vpnName);
removeSubnetNode(dataBroker, new Uuid(vpnName));
logger.debug("Deleted subnet-network mapping for network {}", networkId.getValue());
}
- protected static void updateSubnetNode(DataBroker dataBroker, Uuid vpnId, Uuid subnetId, String subnetIp) {
+ protected static void updateSubnetNode(DataBroker dataBroker, Uuid vpnId, Uuid subnetId, String subnetIp,
+ String intfMac) {
Subnetmap subnetmap = null;
SubnetmapBuilder builder = null;
InstanceIdentifier<Subnetmap> id = InstanceIdentifier.builder(Subnetmaps.class)
builder.setSubnetIp(subnetIp);
builder.setNetworkId(subnetId);
builder.setVpnId(vpnId);
+ builder.setRouterIntfMacAddress(intfMac);
subnetmap = builder.build();
logger.debug("Creating/Updating subnetMap node: {} ", subnetId.getValue());
}
private static void updateSubnetmapNodeWithPorts(DataBroker dataBroker, Uuid subnetId, Uuid portIdToAdd,
- Uuid portIdToRemove) {
+ Uuid portIdToRemove, String vpnName) {
Subnetmap subnetmap = null;
InstanceIdentifier<Subnetmap> id = InstanceIdentifier.builder(Subnetmaps.class)
.child(Subnetmap.class, new SubnetmapKey(subnetId)).build();
portIdToRemove.getValue());
}
+ builder.setRouterId(new Uuid(vpnName));
builder.setPortList(portList);
}
subnetmap = builder.build();
private final int waitForElanInterval;
public SubnetListener(final DataBroker dataBroker, final NotificationPublishService notPublishService,
- final IGwMacListener gwMacListener, int sleepInterval) {
+ final IGwMacListener gwMacListener, int sleepInterval) {
super(dataBroker);
this.notificationPublishService = notPublishService;
this.gwMacListener = gwMacListener;
ipUniSubnets.forEach(s -> removeNetwork(s, uniId, ipUniId, ipvcId));
}
-
private void createNetwork(DataTreeModification<Subnet> newDataObject) {
Subnet newSubnet = newDataObject.getRootNode().getDataAfter();
return;
}
- String srcTpAddressStr = NetvirtVpnUtils.getIpAddressFromPrefix(NetvirtVpnUtils.ipPrefixToString(ipUni.getIpAddress()));
+ String srcTpAddressStr = NetvirtVpnUtils
+ .getIpAddressFromPrefix(NetvirtVpnUtils.ipPrefixToString(ipUni.getIpAddress()));
IpAddress srcIpAddress = new IpAddress(srcTpAddressStr.toCharArray());
String subnet = NetvirtVpnUtils.ipPrefixToString(newSubnet.getSubnet());
- gwMacListener.resolveGwMac(ipvcVpn.getVpnId(), vpnElan.getElanPort(), srcIpAddress, newSubnet.getGateway(), subnet);
+ gwMacListener.resolveGwMac(ipvcVpn.getVpnId(), vpnElan.getElanPort(), srcIpAddress, newSubnet.getGateway(),
+ subnet);
}
private void checkCreateDirectNetwork(Subnet newSubnet, IpvcVpn ipvcVpn, InstanceIdentifier<Ipvc> ipvcId,
return;
}
+ org.opendaylight.yang.gen.v1.http.metroethernetforum.org.ns.yang.mef.interfaces.rev150526.mef.interfaces.unis.Uni operUni = MefInterfaceUtils
+ .getUni(dataBroker, newSubnet.getUniId().getValue(), LogicalDatastoreType.OPERATIONAL);
+ if (operUni == null) {
+ Log.error("Uni {} for network {} is not operational", newSubnet.getUniId(), newSubnet.getSubnet());
+ return;
+ }
+ String portMacAddress = operUni.getMacAddress().getValue();
+
NetvirtVpnUtils.addDirectSubnetToVpn(dataBroker, notificationPublishService, ipvcVpn.getVpnId(),
- vpnElan.getElanId(), newSubnet.getSubnet(), vpnElan.getElanPort(), waitForElanInterval);
+ vpnElan.getElanId(), newSubnet.getSubnet(), vpnElan.getElanPort(), portMacAddress, waitForElanInterval);
}
vpnElan.getElanId(), vpnElan.getElanPort(), subnetStr);
}
-
private void removeDirectNetwork(Subnet deletedSubnet, IpvcVpn ipvcVpn, InstanceIdentifier<Ipvc> ipvcId) {
if (deletedSubnet.getGateway() != null) {
return;
return;
}
- String srcTpAddressStr = NetvirtVpnUtils.getIpAddressFromPrefix(NetvirtVpnUtils.ipPrefixToString(ipUni.getIpAddress()));
+ String srcTpAddressStr = NetvirtVpnUtils
+ .getIpAddressFromPrefix(NetvirtVpnUtils.ipPrefixToString(ipUni.getIpAddress()));
IpAddress srcIpAddress = new IpAddress(srcTpAddressStr.toCharArray());
String subnet = NetvirtVpnUtils.ipPrefixToString(deletedSubnet.getSubnet());
- gwMacListener.unResolveGwMac(ipvcVpn.getVpnId(), vpnElan.getElanPort(), srcIpAddress, deletedSubnet.getGateway(), subnet);
+ gwMacListener.unResolveGwMac(ipvcVpn.getVpnId(), vpnElan.getElanPort(), srcIpAddress,
+ deletedSubnet.getGateway(), subnet);
NetvirtVpnUtils.removeVpnInterfaceAdjacency(dataBroker, vpnElan.getElanPort(), deletedSubnet.getSubnet());
NetvirtVpnUtils.removeVpnInterfaceAdjacency(dataBroker, vpnElan.getElanPort(), deletedSubnet.getGateway());