Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
CIRCLE
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
94
Merge Requests
10
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
e13d6e98
authored
Dec 08, 2016
by
Sulyok Gabor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Better error messages and bugfixes, some code cleanup
parent
67dd3488
Pipeline
#294
failed with stage
in 0 seconds
Changes
3
Pipelines
1
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
75 additions
and
80 deletions
+75
-80
circle/setty/controller.py
+12
-33
circle/setty/models.py
+63
-40
circle/setty/saltstackhelper.py
+0
-7
No files found.
circle/setty/controller.py
View file @
e13d6e98
...
@@ -131,6 +131,8 @@ class SettyController:
...
@@ -131,6 +131,8 @@ class SettyController:
@staticmethod
@staticmethod
def
getInformation
(
elementTemplateId
,
hostname
):
def
getInformation
(
elementTemplateId
,
hostname
):
if
hostname
and
elementTemplateId
:
return
{
'status'
:
'error'
,
'errors'
:
'BOTH_ELEMENTEMPLATE_HOSTNAME_FILLED'
}
if
elementTemplateId
:
if
elementTemplateId
:
try
:
try
:
elementTemplate
=
ElementTemplate
.
objects
.
get
(
elementTemplate
=
ElementTemplate
.
objects
.
get
(
...
@@ -143,8 +145,6 @@ class SettyController:
...
@@ -143,8 +145,6 @@ class SettyController:
return
{
'status'
:
'error'
,
'errors'
:
'ELEMENTTEMPLATE_COULDNT_GET_PROTOTYPE'
}
return
{
'status'
:
'error'
,
'errors'
:
'ELEMENTTEMPLATE_COULDNT_GET_PROTOTYPE'
}
elif
hostname
:
elif
hostname
:
return
Machine
.
getInformation
()
return
Machine
.
getInformation
()
elif
hostname
and
elementTemplateId
:
return
{
'status'
:
'error'
,
'errors'
:
'BOTH_ELEMENTEMPLATE_HOSTNAME_FILLED'
}
else
:
else
:
return
{
'status'
:
'error'
,
'errors'
:
'UNKNOWN_ERROR'
}
return
{
'status'
:
'error'
,
'errors'
:
'UNKNOWN_ERROR'
}
...
@@ -155,13 +155,7 @@ class SettyController:
...
@@ -155,13 +155,7 @@ class SettyController:
'''
'''
@staticmethod
@staticmethod
def
getMachineAvailableList
(
serviceId
,
usedHostnames
,
current_user
):
def
getMachineAvailableList
(
usedHostnames
,
current_user
):
savedMachines
=
Machine
.
objects
.
filter
(
service
=
serviceId
)
savedHostNames
=
[]
for
machine
in
savedMachines
:
savedHostNames
.
append
(
machine
.
hostname
)
userInstances
=
Instance
.
objects
.
filter
(
userInstances
=
Instance
.
objects
.
filter
(
owner
=
current_user
,
destroyed_at
=
None
)
owner
=
current_user
,
destroyed_at
=
None
)
userMachines
=
[]
userMachines
=
[]
...
@@ -169,14 +163,17 @@ class SettyController:
...
@@ -169,14 +163,17 @@ class SettyController:
if
instance
.
vm_name
:
if
instance
.
vm_name
:
userMachines
.
append
(
instance
.
vm_name
)
userMachines
.
append
(
instance
.
vm_name
)
usedHostnamesByUser
=
set
(
savedHostNames
+
usedHostnames
)
availableInstances
=
set
(
set
(
userMachines
)
-
usedHostnamesByUser
)
saltMinions
=
SettyController
.
salthelper
.
getAllMinionsUngrouped
()
saltMinions
=
SettyController
.
salthelper
.
getAllMinionsUngrouped
()
if
not
usedHostnamesByUser
:
if
not
usedHostnames
:
return
{
'machinedata'
:
[
machineName
for
machineName
in
userMachines
if
machineName
in
saltMinions
]}
return
{
'machinedata'
:
[
machineName
for
machineName
in
userMachines
if
machineName
in
saltMinions
]}
availableInstances
=
set
(
set
(
userMachines
)
-
usedHostnames
)
return
{
'machinedata'
:
[
machineName
for
machineName
in
availableInstances
if
machineName
in
saltMinions
]}
return
{
'machinedata'
:
[
machineName
for
machineName
in
availableInstances
if
machineName
in
saltMinions
]}
'''
'''
Add a machine with the given hostname to the Service. If there is a
Add a machine with the given hostname to the Service. If there is a
...
@@ -185,13 +182,8 @@ class SettyController:
...
@@ -185,13 +182,8 @@ class SettyController:
back the new Machine instance
back the new Machine instance
'''
'''
#TODO: addMachine requires usedHostnames too for safety
@staticmethod
@staticmethod
def
addMachine
(
hostname
):
def
addMachine
(
hostname
):
try
:
Machine
.
objects
.
get
(
hostname
=
hostname
)
except
:
return
{
'status'
:
'error'
,
'errors'
:
'MACHINE_ALREADY_ADDED'
}
if
SettyController
.
salthelper
.
checkMinionExists
(
hostname
):
if
SettyController
.
salthelper
.
checkMinionExists
(
hostname
):
machine
=
Machine
.
clone
()
machine
=
Machine
.
clone
()
machine
.
hostname
=
hostname
machine
.
hostname
=
hostname
...
@@ -251,19 +243,6 @@ class SettyController:
...
@@ -251,19 +243,6 @@ class SettyController:
nodesToBeDeployed
.
sort
(
reverse
=
True
)
nodesToBeDeployed
.
sort
(
reverse
=
True
)
dbgCheck
=
[]
# for node in nodesToBeDeployed:
# commandArray = []
#
# for command in node.generatedCommands:
# logger.error( "salt '"+ command.hostname +"' state.sls " + command.command + " pillar=\"" + str(command.parameters) + '"' )
# commandArray.append( command.toDict() )
#
# dbgCheck.append({ "nodeName": str(node.__class__.__name__),
# "hostingMachineName": str(node.getHostingMachine().hostname ),
# "commands": commandArray })
#return {"status": "error", "errors":dbgCheck}
# phase three: deploy the nodes
# phase three: deploy the nodes
for
node
in
nodesToBeDeployed
:
for
node
in
nodesToBeDeployed
:
...
...
circle/setty/models.py
View file @
e13d6e98
This diff is collapsed.
Click to expand it.
circle/setty/saltstackhelper.py
View file @
e13d6e98
...
@@ -31,13 +31,6 @@ class SaltCommand:
...
@@ -31,13 +31,6 @@ class SaltCommand:
self
.
command
=
""
self
.
command
=
""
self
.
parameters
=
None
self
.
parameters
=
None
# For debugging purposes only
def
toDict
(
self
):
return
{
'hostname'
:
self
.
hostname
,
'command'
:
self
.
command
,
'parameters'
:
self
.
parameters
}
class
SaltStackHelper
:
class
SaltStackHelper
:
def
__init__
(
self
):
def
__init__
(
self
):
...
...
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