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
from
vm.models
import
Instance
class
SettyController
:
salthelper
=
SaltStackHelper
()
@staticmethod
@transaction.atomic
...
...
@@ -115,7 +116,7 @@ class SettyController:
@staticmethod
def
getMachineAvailableList
(
serviceId
,
usedHostnames
,
current_user
):
saltMinions
=
[]
#
SettyController.salthelper.getAllMinionsUngrouped()
saltMinions
=
SettyController
.
salthelper
.
getAllMinionsUngrouped
()
savedMachines
=
Machine
.
objects
.
filter
(
service
=
serviceId
)
savedHostNames
=
[]
...
...
@@ -143,12 +144,12 @@ class SettyController:
return
{
'error'
:
'already added or doesnt exists'
}
except
:
pass
#
if SettyController.salthelper.checkMinionExists(hostname):
machine
=
Machine
.
clone
()
machine
.
hostname
=
hostname
return
machine
.
getDataDictionary
()
#
else:
#
return {'error': 'already added or doesnt exists'}
if
SettyController
.
salthelper
.
checkMinionExists
(
hostname
):
machine
=
Machine
.
clone
()
machine
.
hostname
=
hostname
return
machine
.
getDataDictionary
()
else
:
return
{
'error'
:
'already added or doesnt exists'
}
@staticmethod
def
addServiceNode
(
elementTemplateId
):
...
...
circle/setty/saltstackhelper.py
View file @
1f4825c9
...
...
@@ -6,11 +6,10 @@ import salt.client
SALTSTACK_STATE_FOLDER
=
"/srv/salt"
class
SaltStackHelper
:
# def __init__(self):
#self.master_opts = salt.config.client_config('/etc/salt/master')
#self.salt_runner = salt.runner.RunnerClient(self.master_opts)
#self.salt_localclient = salt.client.LocalClient()
#self.salt_caller = salt.client.Caller()
def
__init__
(
self
):
self
.
master_opts
=
salt
.
config
.
client_config
(
'/etc/salt/master'
)
self
.
salt_runner
=
salt
.
runner
.
RunnerClient
(
self
.
master_opts
)
self
.
salt_localclient
=
salt
.
client
.
LocalClient
()
def
getAllMinionsGrouped
(
self
):
query_result
=
self
.
salt_runner
.
cmd
(
'manage.status'
,
[]);
...
...
@@ -39,7 +38,8 @@ class SaltStackHelper:
def
checkMinionExists
(
self
,
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
):
print
configFilePath
...
...
circle/setty/static/setty/setty.js
View file @
1f4825c9
...
...
@@ -101,6 +101,11 @@ jsPlumb.ready(function() {
event
:
"addMachine"
,
data
:
JSON
.
stringify
({
"hostname"
:
machineHostname
}
)
},
function
(
result
)
{
if
(
result
.
error
)
{
alert
(
result
.
error
)
return
;
}
addMachine
(
result
);
undoStack
.
splice
(
stackIndexer
,
0
,
removeElement
);
redoStack
.
splice
(
stackIndexer
,
0
,
addElement
);
...
...
@@ -789,7 +794,7 @@ jsPlumb.ready(function() {
$
.
post
(
""
,
{
event
:
"deploy"
,
},
function
(
result
)
{
if
(
result
.
status
==
'error'
)
if
(
result
.
error
)
alert
(
result
.
errors
);
else
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