Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gyuricska Milán
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
1f4825c9
authored
Oct 23, 2016
by
Sulyok Gabor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SaltStack controller and error handling fixes
parent
7bc6e462
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
14 deletions
+20
-14
circle/setty/controller.py
+8
-7
circle/setty/saltstackhelper.py
+6
-6
circle/setty/static/setty/setty.js
+6
-1
No files found.
circle/setty/controller.py
View file @
1f4825c9
...
@@ -8,6 +8,7 @@ import os
...
@@ -8,6 +8,7 @@ import os
from
vm.models
import
Instance
from
vm.models
import
Instance
class
SettyController
:
class
SettyController
:
salthelper
=
SaltStackHelper
()
@staticmethod
@staticmethod
@transaction.atomic
@transaction.atomic
...
@@ -115,7 +116,7 @@ class SettyController:
...
@@ -115,7 +116,7 @@ class SettyController:
@staticmethod
@staticmethod
def
getMachineAvailableList
(
serviceId
,
usedHostnames
,
current_user
):
def
getMachineAvailableList
(
serviceId
,
usedHostnames
,
current_user
):
saltMinions
=
[]
#
SettyController.salthelper.getAllMinionsUngrouped()
saltMinions
=
SettyController
.
salthelper
.
getAllMinionsUngrouped
()
savedMachines
=
Machine
.
objects
.
filter
(
service
=
serviceId
)
savedMachines
=
Machine
.
objects
.
filter
(
service
=
serviceId
)
savedHostNames
=
[]
savedHostNames
=
[]
...
@@ -143,12 +144,12 @@ class SettyController:
...
@@ -143,12 +144,12 @@ class SettyController:
return
{
'error'
:
'already added or doesnt exists'
}
return
{
'error'
:
'already added or doesnt exists'
}
except
:
except
:
pass
pass
#
if SettyController.salthelper.checkMinionExists(hostname):
if
SettyController
.
salthelper
.
checkMinionExists
(
hostname
):
machine
=
Machine
.
clone
()
machine
=
Machine
.
clone
()
machine
.
hostname
=
hostname
machine
.
hostname
=
hostname
return
machine
.
getDataDictionary
()
return
machine
.
getDataDictionary
()
#
else:
else
:
#
return {'error': 'already added or doesnt exists'}
return
{
'error'
:
'already added or doesnt exists'
}
@staticmethod
@staticmethod
def
addServiceNode
(
elementTemplateId
):
def
addServiceNode
(
elementTemplateId
):
...
...
circle/setty/saltstackhelper.py
View file @
1f4825c9
...
@@ -6,11 +6,10 @@ import salt.client
...
@@ -6,11 +6,10 @@ import salt.client
SALTSTACK_STATE_FOLDER
=
"/srv/salt"
SALTSTACK_STATE_FOLDER
=
"/srv/salt"
class
SaltStackHelper
:
class
SaltStackHelper
:
# def __init__(self):
def
__init__
(
self
):
#self.master_opts = salt.config.client_config('/etc/salt/master')
self
.
master_opts
=
salt
.
config
.
client_config
(
'/etc/salt/master'
)
#self.salt_runner = salt.runner.RunnerClient(self.master_opts)
self
.
salt_runner
=
salt
.
runner
.
RunnerClient
(
self
.
master_opts
)
#self.salt_localclient = salt.client.LocalClient()
self
.
salt_localclient
=
salt
.
client
.
LocalClient
()
#self.salt_caller = salt.client.Caller()
def
getAllMinionsGrouped
(
self
):
def
getAllMinionsGrouped
(
self
):
query_result
=
self
.
salt_runner
.
cmd
(
'manage.status'
,
[]);
query_result
=
self
.
salt_runner
.
cmd
(
'manage.status'
,
[]);
...
@@ -39,7 +38,8 @@ class SaltStackHelper:
...
@@ -39,7 +38,8 @@ class SaltStackHelper:
def
checkMinionExists
(
self
,
hostname
):
def
checkMinionExists
(
self
,
hostname
):
query_res
=
self
.
salt_localclient
.
cmd
(
hostname
,
'network.get_hostname'
);
query_res
=
self
.
salt_localclient
.
cmd
(
hostname
,
'network.get_hostname'
);
return
query_res
!=
None
print
query_res
return
query_res
!=
{}
def
deploy
(
self
,
hostname
,
configFilePath
):
def
deploy
(
self
,
hostname
,
configFilePath
):
print
configFilePath
print
configFilePath
...
...
circle/setty/static/setty/setty.js
View file @
1f4825c9
...
@@ -101,6 +101,11 @@ jsPlumb.ready(function() {
...
@@ -101,6 +101,11 @@ jsPlumb.ready(function() {
event
:
"addMachine"
,
event
:
"addMachine"
,
data
:
JSON
.
stringify
({
"hostname"
:
machineHostname
}
)
data
:
JSON
.
stringify
({
"hostname"
:
machineHostname
}
)
},
function
(
result
)
{
},
function
(
result
)
{
if
(
result
.
error
)
{
alert
(
result
.
error
)
return
;
}
addMachine
(
result
);
addMachine
(
result
);
undoStack
.
splice
(
stackIndexer
,
0
,
removeElement
);
undoStack
.
splice
(
stackIndexer
,
0
,
removeElement
);
redoStack
.
splice
(
stackIndexer
,
0
,
addElement
);
redoStack
.
splice
(
stackIndexer
,
0
,
addElement
);
...
@@ -789,7 +794,7 @@ jsPlumb.ready(function() {
...
@@ -789,7 +794,7 @@ jsPlumb.ready(function() {
$
.
post
(
""
,
{
$
.
post
(
""
,
{
event
:
"deploy"
,
event
:
"deploy"
,
},
function
(
result
)
{
},
function
(
result
)
{
if
(
result
.
status
==
'error'
)
if
(
result
.
error
)
alert
(
result
.
errors
);
alert
(
result
.
errors
);
else
else
alert
(
"Deploying...."
);
alert
(
"Deploying...."
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment