diff --git a/v2.5/assets/css/style.css b/v2.5/assets/css/style.css
index eff29ce..a727ad7 100644
--- a/v2.5/assets/css/style.css
+++ b/v2.5/assets/css/style.css
@@ -1094,4 +1094,34 @@ h4.widget-title:hover {
}
.input-spacing{
margin-top: 8px;
+}
+.uploadContainer{
+ width: 25px;
+ height: 25px;
+ background-color: #6FB3E0;
+ display: inline-block;
+ line-height: 25px;
+ margin-top: 10px;
+ margin-right: -35px;
+ border-radius: 20px;
+}
+.uploadContainer:hover {
+ background-color: #EBEBEB;
+ cursor:pointer;
+}
+.uploadFile{
+ margin-left: 6px;
+ color: #fff;
+}
+.col1{
+ margin-top:10px;
+ float: left;
+ width: 46%;
+}
+.col2{
+ margin-top: 10px;
+ margin-left: 8%;
+ float: left;
+ position: relative;
+ width: 46%;
}
\ No newline at end of file
diff --git a/v2.5/src/app/controllers/modalControllers.coffee b/v2.5/src/app/controllers/modalControllers.coffee
index de57317..3cbdf2c 100644
--- a/v2.5/src/app/controllers/modalControllers.coffee
+++ b/v2.5/src/app/controllers/modalControllers.coffee
@@ -71,4 +71,26 @@ define(['./baseController'], ()->
$modalInstance.dismiss('cancel')
console.log($scope.detail)
]
+ .controller 'uploadFileModalInstanceCtrl', ['$scope', '$modalInstance', 'wizardService','allSwitches','allMachines',
+ ($scope, $modalInstance, wizardService, allSwitches, allMachines) ->
+ $scope.switchLoading = false
+ $scope.machineLoading = false
+
+ $scope.switchFileNameChanged = ->
+ wizardService.readDataFromFile($scope, '#switchInput', 'switchFile')
+
+ $scope.machineFileNameChanged = ->
+ wizardService.readDataFromFile($scope, '#machineInput', 'machineFile')
+
+ $scope.ok = ->
+ $scope.result = 'ok'
+ if $scope.switchFile
+ wizardService.addUploadSwitches($scope, allSwitches, allMachines)
+
+ if !$scope.switchFile and $scope.machineFile
+ wizardService.addUploadMachines($scope, allMachines, wizardService.getDataService())
+
+ $scope.cancel = ->
+ $modalInstance.dismiss('cancel')
+ ]
);
\ No newline at end of file
diff --git a/v2.5/src/app/controllers/wizardController.coffee b/v2.5/src/app/controllers/wizardController.coffee
index 79cded6..5cfc9c9 100644
--- a/v2.5/src/app/controllers/wizardController.coffee
+++ b/v2.5/src/app/controllers/wizardController.coffee
@@ -8,7 +8,6 @@ define(['./baseController'], ()->
wizardService.wizardInit($scope, $stateParams.id, clusterData, adaptersData, wizardStepsData, machinesHostsData, clusterConfigData)
$scope.skipForward = (nextStepId) ->
- console.log("next", nextStepId)
if $scope.currentStep != nextStepId
$scope.pendingStep = nextStepId
wizardService.triggerCommitByStepById($scope,$scope.currentStep ,nextStepId)
@@ -34,12 +33,13 @@ define(['./baseController'], ()->
wizardService.watchingCommittedStatus($scope)
]
- .controller 'svSelectCtrl', ['$scope', 'wizardService', '$filter', 'ngTableParams'
- ($scope, wizardService, $filter, ngTableParams) ->
+ .controller 'svSelectCtrl', ['$scope', 'wizardService', '$filter', 'ngTableParams', '$modal'
+ ($scope, wizardService, $filter, ngTableParams, $modal) ->
$scope.hideunselected = ''
$scope.search = {}
$scope.cluster = wizardService.getClusterInfo()
$scope.allservers = wizardService.getAllMachinesHost()
+ $scope.allAddedSwitches = []
wizardService.getServerColumns().success (data) ->
$scope.server_columns = data.showall
@@ -64,6 +64,17 @@ define(['./baseController'], ()->
else
sv.selected = false for sv in $scope.allservers
+ $scope.uploadFile = ->
+ modalInstance = $modal.open(
+ templateUrl: "src/app/partials/modalUploadFiles.html"
+ controller: "uploadFileModalInstanceCtrl"
+ resolve:
+ allSwitches: ->
+ return $scope.allAddedSwitches
+ allMachines: ->
+ return $scope.foundResults
+ )
+
#watch and add newly found servers to allservers array
wizardService.watchAndAddNewServers($scope)
diff --git a/v2.5/src/app/directives/findServerDirective.coffee b/v2.5/src/app/directives/findServerDirective.coffee
index 1c125e2..3d1841f 100644
--- a/v2.5/src/app/directives/findServerDirective.coffee
+++ b/v2.5/src/app/directives/findServerDirective.coffee
@@ -3,19 +3,19 @@ define(['./baseDirective'], ->
angular.module('compass.directives')
.directive 'findservers', ['wizardService','$modal', (wizardService, $modal) ->
- return {
- restrict: 'E'
- scope: {
+ return {
+ restrict: 'E'
+ scope: {
+ newFoundServers: '=results'
+ switches: '='
+ }
+ templateUrl: "src/app/partials/find-new-servers.tpl.html"
- newFoundServers: '=results'
- }
- templateUrl: "src/app/partials/find-new-servers.tpl.html"
-
- link: (scope, element, attrs) ->
- scope.switches = []
- scope.newFoundServers = []
- scope.isFindingNewServers = false
- wizardService.getSwitches().success (data) ->
+ link: (scope, element, attrs) ->
+ # scope.switches = []
+ scope.newFoundServers = []
+ scope.isFindingNewServers = false
+ wizardService.getSwitches().success (data) ->
scope.switches = data
scope.findServers = ->
diff --git a/v2.5/src/app/partials/modalUploadFiles.html b/v2.5/src/app/partials/modalUploadFiles.html
new file mode 100644
index 0000000..da5f6dc
--- /dev/null
+++ b/v2.5/src/app/partials/modalUploadFiles.html
@@ -0,0 +1,46 @@
+
+
+
+
Switch Files:
+
+
+
Results:
+
+
+
+
+
+
+
+
Machine File:
+
+
+
Results:
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/v2.5/src/app/partials/server_selection.tpl.html b/v2.5/src/app/partials/server_selection.tpl.html
index 47d7d16..6682de1 100644
--- a/v2.5/src/app/partials/server_selection.tpl.html
+++ b/v2.5/src/app/partials/server_selection.tpl.html
@@ -6,7 +6,7 @@
-
+
@@ -49,6 +49,9 @@
+
+
+
diff --git a/v2.5/src/app/server/appDev.js b/v2.5/src/app/server/appDev.js
index da098db..e7ecba5 100644
--- a/v2.5/src/app/server/appDev.js
+++ b/v2.5/src/app/server/appDev.js
@@ -674,6 +674,79 @@ define(['angular', 'angularMocks'], function() {
return [200, switchData, {}];
});
+ $httpBackend.whenPOST(settings.apiUrlBase + '/switchesbatch').respond(function(method, url, data) {
+ console.log(method, url, data);
+ var returnData = {
+ 'switches': [{
+ 'vendor': 'Huawei',
+ 'ip': '172.29.8.30',
+ 'created_at': '2015-05-04 11:49:00',
+ 'updated_at': '2015-05-04 11:49:00',
+ 'state': 'initialized',
+ 'filters': 'u',
+ 'credentials': {
+ 'version': '2c',
+ 'community': 'public'
+ },
+ 'id': 4
+ }],
+ 'fail_switches': [{
+ 'ip': '172.29.8.40'
+ }]
+ };
+ return [200, returnData, {}];
+ });
+
+ $httpBackend.whenPOST(settings.apiUrlBase + '/switches/machines').respond(function(method, url, data) {
+ console.log(method, url, data);
+ var returnData = {
+ 'switches_machines': [
+ {
+ 'machine_id': 3,
+ 'created_at': '2015-05-04 11:50:29',
+ 'updated_at': '2015-05-04 11:50:29',
+ 'switch_id': 1,
+ 'port': '100',
+ 'mac': '1a:2b:3c:4d:5e:6f',
+ 'tag': {},
+ 'location': {},
+ 'switch_ip': '0.0.0.0',
+ 'ipmi_credentials': {},
+ 'vlans': [],
+ 'id': 3,
+ 'switch_machine_id': 3
+ }, {
+ 'machine_id': 4,
+ 'created_at': '2015-05-04 11:50:29',
+ 'updated_at': '2015-05-04 11:50:29',
+ 'switch_id': 1,
+ 'port': '101',
+ 'mac': 'a1:b2:c3:d4:e5:f6',
+ 'tag': {},
+ 'location': {},
+ 'switch_ip': '0.0.0.0',
+ 'ipmi_credentials': {},
+ 'vlans': [],
+ 'id': 4,
+ 'switch_machine_id': 4
+ }
+ ],
+ 'duplicate_switches_machies': [
+ {
+ 'mac': 'a1:b2:c3:d4:e5:f6',
+ 'port': '101'
+ }
+ ],
+ 'fail_switches_machines': [
+ {
+ 'mac': 'a1:b2:c3:d4:e5:f6',
+ 'port': '103'
+ }
+ ]
+ };
+ return [200, returnData, {}];
+ });
+
$httpBackend.whenPOST(/\.*\/switches\/([0-9]|[1-9][0-9])\/action$/).respond(function(method, url, data) {
console.log(method, url, data);
var switchState = {
diff --git a/v2.5/src/app/services/dataService.coffee b/v2.5/src/app/services/dataService.coffee
index 8f77c87..110c8ad 100644
--- a/v2.5/src/app/services/dataService.coffee
+++ b/v2.5/src/app/services/dataService.coffee
@@ -111,7 +111,7 @@ define(['./baseService'], () ->
return @$http.get(@settings.apiUrlBase + '/clusters/' + id + '/healthreports/' + name)
postHealthCheck: (id, checkHealth) ->
- return @$http.post(@settings.apiUrlBase + '/clusters/' + id + '/action', angular.toJason(checkHealth))
+ return @$http.post(@settings.apiUrlBase + '/clusters/' + id + '/action', angular.toJson(checkHealth))
startHealthCheck: (id, request) ->
return @$http.post(@settings.apiUrlBase + '/clusters/' + id + '/action',angular.toJson(request))
@@ -120,5 +120,9 @@ define(['./baseService'], () ->
return @$http.get(@settings.apiUrlBase + '/oses/'+ id + '/ui_metadata')
getPackageConfigUiElements: (id) ->
return @$http.get(@settings.apiUrlBase + '/flavors/' + id + '/ui_metadata')
+ uploadSwitches: (data) ->
+ return @$http.post(@settings.apiUrlBase + '/switchesbatch', angular.toJson(data))
+ uploadMachines: (data) ->
+ return @$http.post(@settings.apiUrlBase + '/switches/machines', angular.toJson(data))
angular.module('compass.services').service('dataService', ['$http', 'settings', ($http,settings) -> new DS($http,settings)])
)
\ No newline at end of file
diff --git a/v2.5/src/app/services/wizardService.coffee b/v2.5/src/app/services/wizardService.coffee
index e13f26c..f09fa3b 100644
--- a/v2.5/src/app/services/wizardService.coffee
+++ b/v2.5/src/app/services/wizardService.coffee
@@ -1041,6 +1041,60 @@ define(['./baseService'], ()->
for s in source
target[index]["$$hashKey"] = source[index]["$$hashKey"]
index++
+ getDataService: ()->
+ @dataService
+
+ addUploadSwitches: ($scope, allSwitches, allMachines) ->
+ $scope.switchLoading = true
+ addUploadMachines = @addUploadMachines
+ dataService = @dataService
+ switches =$scope.switchFile.split("\n")
+ postData = []
+ for s in switches
+ componets = s.split(',')
+ temp = {}
+ temp.credentials = {}
+ temp.ip = componets[0] if componets[0]
+ temp.vendor = componets[1] if componets[1]
+ temp.credentials.version = componets[2] if componets[2]
+ temp.credentials.community = componets[3] if componets[3]
+ postData.push(temp)
+ dataService.uploadSwitches(postData).success (data) ->
+ $scope.uploadSwitchesReturn = data #show in the template
+ for s in data.switches
+ allSwitches.push(s)
+ $scope.switchLoading = false
+ if $scope.machineFile
+ addUploadMachines($scope, allMachines, dataService)
+ addUploadMachines: ($scope, allMachines, dataService) ->
+ $scope.machineLoading = true
+ machines = $scope.machineFile.split("\n")
+ postData = []
+ for m in machines
+ componets = m.split(',')
+ temp = {}
+ temp.mac = componets[0] if componets[0]
+ temp.port = componets[1] if componets[1]
+ temp.switch_ip = componets[2] if componets[2]
+ postData.push(temp)
+ dataService.uploadMachines(postData).success (data) ->
+ $scope.uploadMachinesReturn = data
+ for m in data.switches_machines
+ temp = {}
+ temp.id = m.machine_id
+ temp.mac = m.mac
+ temp.port = m.port
+ temp.switch_ip = m.switch_ip
+ temp.vlan = m.vlan
+ allMachines.push(temp)
+ $scope.machineLoading = false
+ readDataFromFile: ($scope, selector, target) ->
+ selectedFile = $(selector).get(0).files[0]
+ if selectedFile
+ reader = new FileReader()
+ reader.readAsText(selectedFile, "UTF-8")
+ reader.onload = (e) ->
+ $scope[target] = reader.result
angular.module('compass.services').service 'wizardService',[
'dataService'