1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-21 14:29:40 +02:00

feat(network): add the ability to specify a subnet/gateway when creating a network (#53)

This commit is contained in:
Anthony Lapenna 2016-07-08 17:12:33 +12:00 committed by GitHub
parent c74e8fc732
commit e67e20ce18
2 changed files with 31 additions and 2 deletions

View file

@ -2,13 +2,18 @@ angular.module('createNetwork', [])
.controller('CreateNetworkController', ['$scope', '$state', 'Messages', 'Network', 'errorMsgFilter',
function ($scope, $state, Messages, Network, errorMsgFilter) {
$scope.formValues = {
DriverOptions: []
DriverOptions: [],
Subnet: '',
Gateway: ''
};
$scope.config = {
Driver: 'bridge',
CheckDuplicate: true,
Internal: false
Internal: false,
IPAM: {
Config: []
}
};
$scope.addDriverOption = function() {
@ -36,6 +41,17 @@ function ($scope, $state, Messages, Network, errorMsgFilter) {
});
}
function prepareIPAMConfiguration(config) {
if ($scope.formValues.Subnet) {
var ipamConfig = {};
ipamConfig.Subnet = $scope.formValues.Subnet;
if ($scope.formValues.Gateway) {
ipamConfig.Gateway = $scope.formValues.Gateway ;
}
config.IPAM.Config.push(ipamConfig);
}
}
function prepareDriverOptions(config) {
var options = {};
$scope.formValues.DriverOptions.forEach(function (option) {
@ -46,6 +62,7 @@ function ($scope, $state, Messages, Network, errorMsgFilter) {
function prepareConfiguration() {
var config = angular.copy($scope.config);
prepareIPAMConfiguration(config);
prepareDriverOptions(config);
return config;
}