Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Roque
slapos.core
Commits
604b5108
Commit
604b5108
authored
Jul 12, 2011
by
Rafael Monnerat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Small styles changes.
parent
0e76f9ec
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
9 deletions
+7
-9
slapos/proxy/views.py
slapos/proxy/views.py
+7
-9
No files found.
slapos/proxy/views.py
View file @
604b5108
...
@@ -13,7 +13,7 @@ class UnauthorizedError(Exception):
...
@@ -13,7 +13,7 @@ class UnauthorizedError(Exception):
pass
pass
def
partitiondict2partition
(
partition
):
def
partitiondict2partition
(
partition
):
# XXX-Cedric : change function name, as it does no longer create a
# XXX-Cedric : change function name, as it does no longer create a
# Partition instance, but rather create a dict ready to be sent in json
# Partition instance, but rather create a dict ready to be sent in json
slap_partition
=
dict
(
computer_id
=
app
.
config
[
'computer_id'
],
slap_partition
=
dict
(
computer_id
=
app
.
config
[
'computer_id'
],
computer_partition_id
=
partition
[
'reference'
],
computer_partition_id
=
partition
[
'reference'
],
...
@@ -70,7 +70,7 @@ def after_request(response):
...
@@ -70,7 +70,7 @@ def after_request(response):
g
.
db
.
commit
()
g
.
db
.
commit
()
g
.
db
.
close
()
g
.
db
.
close
()
return
response
return
response
@
app
.
route
(
'/<computer_id>'
,
methods
=
[
'GET'
])
@
app
.
route
(
'/<computer_id>'
,
methods
=
[
'GET'
])
def
getComputerInformation
(
computer_id
):
def
getComputerInformation
(
computer_id
):
"""Returns information about computer"""
"""Returns information about computer"""
...
@@ -88,7 +88,7 @@ def getComputerInformation(computer_id):
...
@@ -88,7 +88,7 @@ def getComputerInformation(computer_id):
else
:
else
:
raise
UnauthorizedError
,
"Only accept request for: %s"
%
\
raise
UnauthorizedError
,
"Only accept request for: %s"
%
\
app
.
config
[
'computer_id'
]
app
.
config
[
'computer_id'
]
@
app
.
route
(
'/<computer_id>/partition/<computer_partition_id>'
,
methods
=
[
'POST'
])
@
app
.
route
(
'/<computer_id>/partition/<computer_partition_id>'
,
methods
=
[
'POST'
])
def
setComputerPartitionConnectionJson
(
computer_id
,
computer_partition_id
):
def
setComputerPartitionConnectionJson
(
computer_id
,
computer_partition_id
):
# XXX-Cedric : change connection_xml to connection_json in sql
# XXX-Cedric : change connection_xml to connection_json in sql
...
@@ -96,7 +96,7 @@ def setComputerPartitionConnectionJson(computer_id, computer_partition_id):
...
@@ -96,7 +96,7 @@ def setComputerPartitionConnectionJson(computer_id, computer_partition_id):
argument_list
=
[
request
.
json
,
computer_partition_id
.
encode
()]
argument_list
=
[
request
.
json
,
computer_partition_id
.
encode
()]
execute_db
(
'partition'
,
query
,
argument_list
)
execute_db
(
'partition'
,
query
,
argument_list
)
return
'done'
return
'done'
@
app
.
route
(
'/buildingSoftwareRelease'
,
methods
=
[
'POST'
])
@
app
.
route
(
'/buildingSoftwareRelease'
,
methods
=
[
'POST'
])
def
buildingSoftwareRelease
():
def
buildingSoftwareRelease
():
return
'Ignored'
return
'Ignored'
...
@@ -206,7 +206,7 @@ def requestComputerPartition(partition_reference = ''):
...
@@ -206,7 +206,7 @@ def requestComputerPartition(partition_reference = ''):
a
(
partition_id
)
a
(
partition_id
)
if
instance_json
:
if
instance_json
:
# XXX-Cedric : change xml to sjon in sql
# XXX-Cedric : change xml to sjon in sql
q
+=
' ,xml=?'
q
+=
' ,xml=?'
a
(
instance_json
)
a
(
instance_json
)
q
+=
' WHERE reference=?'
q
+=
' WHERE reference=?'
a
(
partition
[
'reference'
].
encode
())
a
(
partition
[
'reference'
].
encode
())
...
@@ -252,19 +252,17 @@ def loadComputerConfigurationFromXML():
...
@@ -252,19 +252,17 @@ def loadComputerConfigurationFromXML():
xml
=
request
.
form
[
'xml'
]
xml
=
request
.
form
[
'xml'
]
computer_dict
=
xml_marshaller
.
xml_marshaller
.
loads
(
str
(
xml
))
computer_dict
=
xml_marshaller
.
xml_marshaller
.
loads
(
str
(
xml
))
if
app
.
config
[
'computer_id'
]
==
computer_dict
[
'reference'
]:
if
app
.
config
[
'computer_id'
]
==
computer_dict
[
'reference'
]:
args
=
[]
a
=
args
.
append
execute_db
(
'computer'
,
'INSERT OR REPLACE INTO %s values(:address, :netmask)'
,
execute_db
(
'computer'
,
'INSERT OR REPLACE INTO %s values(:address, :netmask)'
,
computer_dict
)
computer_dict
)
for
partition
in
computer_dict
[
'partition_list'
]:
for
partition
in
computer_dict
[
'partition_list'
]:
execute_db
(
'partition'
,
'INSERT OR IGNORE INTO %s (reference) values(:reference)'
,
partition
)
execute_db
(
'partition'
,
'INSERT OR IGNORE INTO %s (reference) values(:reference)'
,
partition
)
execute_db
(
'partition_network'
,
'DELETE FROM %s WHERE partition_reference = ?'
,
[
partition
[
'reference'
]])
execute_db
(
'partition_network'
,
'DELETE FROM %s WHERE partition_reference = ?'
,
[
partition
[
'reference'
]])
for
address
in
partition
[
'address_list'
]:
for
address
in
partition
[
'address_list'
]:
address
[
'reference'
]
=
partition
[
'tap'
][
'name'
]
address
[
'reference'
]
=
partition
[
'tap'
][
'name'
]
address
[
'partition_reference'
]
=
partition
[
'reference'
]
address
[
'partition_reference'
]
=
partition
[
'reference'
]
execute_db
(
'partition_network'
,
'INSERT OR REPLACE INTO %s (reference, partition_reference, address, netmask) values(:reference, :partition_reference, :addr, :netmask)'
,
address
)
execute_db
(
'partition_network'
,
'INSERT OR REPLACE INTO %s (reference, partition_reference, address, netmask) values(:reference, :partition_reference, :addr, :netmask)'
,
address
)
return
'done'
return
'done'
else
:
else
:
raise
UnauthorizedError
,
"Only accept request for: %s"
%
\
raise
UnauthorizedError
,
"Only accept request for: %s"
%
\
...
...
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