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

pull/63/head
Anthony Lapenna 9 years ago committed by GitHub
parent c74e8fc732
commit e67e20ce18

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

@ -18,6 +18,18 @@
</div> </div>
</div> </div>
<!-- !name-input --> <!-- !name-input -->
<!-- subnet-gateway-inputs -->
<div class="form-group">
<label for="network_subnet" class="col-sm-1 control-label text-left">Subnet</label>
<div class="col-sm-5">
<input type="text" class="form-control" ng-model="formValues.Subnet" id="network_subnet" placeholder="e.g. 172.20.0.0/16">
</div>
<label for="network_gateway" class="col-sm-1 control-label text-left">Gateway</label>
<div class="col-sm-5">
<input type="text" class="form-control" ng-model="formValues.Gateway" id="network_gateway" placeholder="e.g. 172.20.10.11">
</div>
</div>
<!-- !subnet-gateway-inputs -->
<!-- driver-input --> <!-- driver-input -->
<div class="form-group"> <div class="form-group">
<label for="network_driver" class="col-sm-1 control-label text-left">Driver</label> <label for="network_driver" class="col-sm-1 control-label text-left">Driver</label>

Loading…
Cancel
Save