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
0e76f9ec
Commit
0e76f9ec
authored
Jul 12, 2011
by
Rafael Monnerat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Drop deprecated code
This make sure code is using new API
parent
00d7dd90
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
101 deletions
+0
-101
slapos/proxy/views.py
slapos/proxy/views.py
+0
-101
No files found.
slapos/proxy/views.py
View file @
0e76f9ec
...
@@ -12,107 +12,6 @@ DB_VERSION = app.open_resource('schema.sql').readline().strip().split(':')[1]
...
@@ -12,107 +12,6 @@ DB_VERSION = app.open_resource('schema.sql').readline().strip().split(':')[1]
class
UnauthorizedError
(
Exception
):
class
UnauthorizedError
(
Exception
):
pass
pass
#Deprecated
def
xml2dict
(
xml
):
result_dict
=
{}
if
xml
is
not
None
and
xml
!=
''
:
tree
=
etree
.
fromstring
(
xml
.
encode
(
'utf-8'
))
for
element
in
tree
.
iter
(
tag
=
etree
.
Element
):
if
element
.
tag
==
'parameter'
:
key
=
element
.
get
(
'id'
)
value
=
result_dict
.
get
(
key
,
None
)
if
value
is
not
None
:
value
=
value
+
' '
+
element
.
text
else
:
value
=
element
.
text
result_dict
[
key
]
=
value
return
result_dict
#Deprecated
def
dict2xml
(
dictionnary
):
instance
=
etree
.
Element
(
'instance'
)
for
parameter_id
,
parameter_value
in
dictionnary
.
iteritems
():
# cast everything to string
parameter_value
=
str
(
parameter_value
)
etree
.
SubElement
(
instance
,
"parameter"
,
attrib
=
{
'id'
:
parameter_id
}).
text
=
parameter_value
return
etree
.
tostring
(
instance
,
pretty_print
=
True
,
xml_declaration
=
True
,
encoding
=
'utf-8'
)
#Deprecated
def
partitiondict2partitionXML
(
partition
):
slap_partition
=
ComputerPartition
(
app
.
config
[
'computer_id'
],
partition
[
'reference'
])
slap_partition
.
_requested_state
=
'started'
if
partition
[
'software_release'
]:
slap_partition
.
_need_modification
=
1
else
:
slap_partition
.
_need_modification
=
0
try
:
slap_partition
.
_parameter_dict
=
xml2dict
(
partition
[
'xml'
])
except
XMLSyntaxError
:
# Maybe it was encoded in json
slap_partition
.
_parameter_dict
=
json
.
loads
(
partition
[
'xml'
])
address_list
=
[]
for
address
in
execute_db
(
'partition_network'
,
'SELECT * FROM %s WHERE partition_reference=?'
,
[
partition
[
'reference'
]]):
address_list
.
append
((
address
[
'reference'
],
address
[
'address'
]))
slap_partition
.
_parameter_dict
[
'ip_list'
]
=
address_list
slap_partition
.
_parameter_dict
[
'slap_software_type'
]
=
partition
[
'software_type'
]
slap_partition
.
_connection_dict
=
xml2dict
(
partition
[
'connection_xml'
])
slap_partition
.
_software_release_document
=
SoftwareRelease
(
software_release
=
partition
[
'software_release'
],
computer_guid
=
app
.
config
[
'computer_id'
])
return
slap_partition
#Deprecated. Only used for current version of slapgrid
@
app
.
route
(
'/registerComputerPartition'
,
methods
=
[
'GET'
])
def
registerComputerPartitionXml
():
computer_reference
=
request
.
args
[
'computer_reference'
]
computer_partition_reference
=
request
.
args
[
'computer_partition_reference'
]
if
app
.
config
[
'computer_id'
]
==
computer_reference
:
partition
=
execute_db
(
'partition'
,
'SELECT * FROM %s WHERE reference=?'
,
[
computer_partition_reference
.
encode
()],
one
=
True
)
if
partition
is
None
:
raise
UnauthorizedError
return
xml_marshaller
.
xml_marshaller
.
dumps
(
partitiondict2partitionXML
(
partition
))
else
:
raise
UnauthorizedError
,
"Only accept request for: %s"
%
\
app
.
config
[
'computer_id'
]
#Deprecated. Only used for current version of slapgrid
@
app
.
route
(
'/getComputerInformation'
,
methods
=
[
'GET'
])
def
getComputerInformationXml
():
computer_id
=
request
.
args
[
'computer_id'
]
if
app
.
config
[
'computer_id'
]
==
computer_id
:
slap_computer
=
Computer
(
computer_id
)
slap_computer
.
_software_release_list
=
[]
for
sr
in
execute_db
(
'software'
,
'select * from %s'
):
slap_computer
.
_software_release_list
.
append
(
SoftwareRelease
(
software_release
=
sr
[
'url'
],
computer_guid
=
computer_id
))
slap_computer
.
_computer_partition_list
=
[]
for
partition
in
execute_db
(
'partition'
,
'SELECT * FROM %s'
):
slap_computer
.
_computer_partition_list
.
append
(
partitiondict2partitionXML
(
partition
))
return
xml_marshaller
.
xml_marshaller
.
dumps
(
slap_computer
)
else
:
raise
UnauthorizedError
,
"Only accept request for: %s"
%
\
app
.
config
[
'computer_id'
]
#Deprecated. Only used for current version of slapgrid
@
app
.
route
(
'/setComputerPartitionConnectionXml'
,
methods
=
[
'POST'
])
def
setComputerPartitionConnectionXml
():
computer_id
=
request
.
form
[
'computer_id'
]
computer_partition_id
=
request
.
form
[
'computer_partition_id'
]
connection_xml
=
request
.
form
[
'connection_xml'
]
connection_dict
=
xml_marshaller
.
xml_marshaller
.
loads
(
connection_xml
.
encode
())
connection_xml
=
dict2xml
(
connection_dict
)
query
=
'UPDATE %s SET connection_xml=? WHERE reference=?'
argument_list
=
[
connection_xml
,
computer_partition_id
.
encode
()]
execute_db
(
'partition'
,
query
,
argument_list
)
return
'done'
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
...
...
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