From 8215cf78571d9d2103b9b6d5f7f9b80904c87536 Mon Sep 17 00:00:00 2001 From: Hilscher Date: Sun, 16 Apr 2017 09:57:47 +0200 Subject: [PATCH] feat(container-creation): add support for devices (#729) --- .../createContainerController.js | 24 +++++++++++++- .../createContainer/createcontainer.html | 32 ++++++++++++++++++- 2 files changed, 54 insertions(+), 2 deletions(-) diff --git a/app/components/createContainer/createContainerController.js b/app/components/createContainer/createContainerController.js index f7b58efc6..0cb2a76dd 100644 --- a/app/components/createContainer/createContainerController.js +++ b/app/components/createContainer/createContainerController.js @@ -31,7 +31,8 @@ function ($scope, $state, $stateParams, $filter, Config, Info, Container, Contai Binds: [], NetworkMode: 'bridge', Privileged: false, - ExtraHosts: [] + ExtraHosts: [], + Devices:[] }, Labels: {} }; @@ -75,7 +76,14 @@ function ($scope, $state, $stateParams, $filter, Config, Info, Container, Contai $scope.removeExtraHost = function(index) { $scope.formValues.ExtraHosts.splice(index, 1); }; + + $scope.addDevice = function() { + $scope.config.HostConfig.Devices.push({ pathOnHost: '', pathInContainer: '' }); + }; + $scope.removeDevice = function(index) { + $scope.config.HostConfig.Devices.splice(index, 1); + }; Config.$promise.then(function (c) { var containersToHideLabels = c.hiddenLabels; @@ -275,6 +283,19 @@ function ($scope, $state, $stateParams, $filter, Config, Info, Container, Contai }); config.Labels = labels; } + + function prepareDevices(config) { + var path = []; + config.HostConfig.Devices.forEach(function (p) { + if (p.pathOnHost) { + if(p.pathInContainer === '') { + p.pathInContainer = p.pathOnHost; + } + path.push({PathOnHost:p.pathOnHost,PathInContainer:p.pathInContainer,CgroupPermissions:'rwm'}); + } + }); + config.HostConfig.Devices = path; + } function prepareConfiguration() { var config = angular.copy($scope.config); @@ -286,6 +307,7 @@ function ($scope, $state, $stateParams, $filter, Config, Info, Container, Contai prepareEnvironmentVariables(config); prepareVolumes(config); prepareLabels(config); + prepareDevices(config); return config; } diff --git a/app/components/createContainer/createcontainer.html b/app/components/createContainer/createcontainer.html index 3b5b13f30..cef979453 100644 --- a/app/components/createContainer/createcontainer.html +++ b/app/components/createContainer/createcontainer.html @@ -485,8 +485,38 @@ +
+ +
+
+ + + add device + +
+ +
+
+
+ host + +
+
+ container + +
+ +
+
+ +
+ +
+ - +