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
Labels
Merge Requests
18
Merge Requests
18
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
nexedi
slapos.core
Commits
7fe0677c
Commit
7fe0677c
authored
May 29, 2013
by
Jondy Zhao
Committed by
Marco Mariani
Aug 15, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
New feature: get net drive usage report from slave node.
parent
f932e38f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
99 additions
and
0 deletions
+99
-0
master/product/Vifib/Tool/SlapTool.py
master/product/Vifib/Tool/SlapTool.py
+58
-0
slapos/slap/doc/netdrive_usage.xsd
slapos/slap/doc/netdrive_usage.xsd
+37
-0
slapos/slap/slap.py
slapos/slap/slap.py
+4
-0
No files found.
master/product/Vifib/Tool/SlapTool.py
View file @
7fe0677c
...
...
@@ -699,6 +699,64 @@ class SlapTool(BaseTool):
self
.
REQUEST
.
response
.
setBody
(
result
)
return
self
.
REQUEST
.
response
security
.
declareProtected
(
Permissions
.
AccessContentsInformation
,
'reportNetDriveUsageFromXML'
)
def
reportNetDriveUsageFromXML
(
self
,
xml
):
"Generate sale packing list from net drive usage report"
#We retrieve XSD model
try
:
netdrive_usage_model
=
\
pkg_resources
.
resource_string
(
'slapos.slap'
,
'doc/netdrive_usage.xsd'
)
except
IOError
:
netdrive_usage_model
=
\
pkg_resources
.
resource_string
(
__name__
,
'../../../../slapos/slap/doc/netdrive_usage.xsd'
)
if
not
self
.
_validateXML
(
xml
,
netdrive_usage_model
):
raise
NotImplementedError
(
'XML file sent by the node is not valid !'
)
splm
=
self
.
getPortalObject
().
getDefaultModule
(
'Sale Packing List'
)
computer_id
=
''
# Insert one line
root
=
etree
.
XML
(
xml
)
for
element
in
root
.
iter
(
'item'
):
if
not
computer_id
==
element
[
0
].
text
:
computer_id
=
element
[
0
].
text
computer
=
self
.
_getComputerDocument
(
computer_id
)
domain_account
=
element
[
1
].
text
report_date
=
element
[
2
].
text
usage_amount
=
element
[
3
].
text
# Search sale packing list by domain_account and the month of report_date
year
,
month
,
day
=
report_date
.
split
(
'-'
)
reference
=
"NetDriveUsage-%s-%d.%d"
%
(
domain_account
,
year
,
month
)
spl
=
splm
.
searchFolder
(
reference
=
reference
)
if
spl
is
None
:
spl
=
splm
.
newContent
(
portal_type
=
'Sale Packing List'
,
title
=
'Net Drive Usage - %s'
%
domain_account
,
reference
=
reference
,
source_value
=
'Net Drive'
,
destination_value
=
domain_account
,
start_date
=
DateTime
(
year
,
month
,
1
),
)
spl
.
newContent
(
portal_type
=
'Sale Packing List Line'
,
resource_value
=
sequence
.
get
(
'resource'
),
delivery_date
=
report_date
,
resource_value
=
computer_id
,
quantity
=
usage_amount
)
# step through all steps of packing list workflow
# spl.confirm()
# spl.setReady()
# spl.start()
# spl.stop()
# spl.deliver()
return
'Content properly posted.'
####################################################
# Internal methods
####################################################
...
...
slapos/slap/doc/netdrive_usage.xsd
0 → 100644
View file @
7fe0677c
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema
xmlns:xs=
"http://www.w3.org/2001/XMLSchema"
elementFormDefault=
"qualified"
>
<xs:element
name=
"report"
>
<xs:complexType>
<xs:sequence>
<xs:element
ref=
"item"
minOccurs=
"0"
maxOccurs=
"unbounded"
/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element
name=
"item"
>
<xs:complexType>
<xs:sequence>
<xs:element
name=
"computer"
type=
"xs:string"
/>
<xs:element
name=
"account"
type=
"xs:string"
/>
<xs:element
name=
"date"
type=
"xs:date"
/>
<xs:element
name=
"usage"
type=
"xs:decimal"
/>
<xs:element
ref=
"details"
/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element
name=
"details"
>
<xs:complexType>
<xs:element
ref=
"line"
minOccurs=
"0"
maxOccurs=
"unbounded"
/>
</xs:complexType>
</xs:element>
<xs:element
name=
"line"
>
<xs:complexType>
<xs:all>
<xs:element
name=
"drive"
type=
"xs:string"
/>
<xs:element
name=
"remote"
type=
"xs:string"
/>
<xs:element
name=
"start"
type=
"xs:time"
/>
<xs:element
name=
"duration"
type=
"xs:integer"
/>
<xs:element
name=
"bytes"
type=
"xs:integer"
/>
</xs:all>
</xs:complexType>
</xs:element>
</xs:schema>
slapos/slap/slap.py
View file @
7fe0677c
...
...
@@ -345,6 +345,10 @@ class Computer(SlapDocument):
'computer_id'
:
self
.
_computer_id
})
return
xml_marshaller
.
loads
(
xml
)
def
reportNetDriveUsage
(
self
,
xml
):
self
.
_connection_helper
.
POST
(
'/reportNetDriveUsageFromXML'
,
{
'xml'
:
xml
})
return
self
.
_connection_helper
.
response
.
read
()
def
parsed_error_message
(
status
,
body
,
path
):
m
=
re
.
search
(
'(Error Value:
\
n
.*)'
,
body
,
re
.
MULTILINE
)
...
...
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