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
1
Merge Requests
1
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
Romain Courteaud
slapos.core
Commits
093fb2ea
Commit
093fb2ea
authored
May 26, 2017
by
Tomáš Peterka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Format crumbles resources per partition and write them down to ~/.slapos-resource
parent
e2aecf92
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
0 deletions
+18
-0
slapos/format.py
slapos/format.py
+18
-0
No files found.
slapos/format.py
View file @
093fb2ea
...
@@ -376,6 +376,9 @@ class Computer(object):
...
@@ -376,6 +376,9 @@ class Computer(object):
with
open
(
path_to_xml
,
'wb'
)
as
fout
:
with
open
(
path_to_xml
,
'wb'
)
as
fout
:
fout
.
write
(
new_pretty_xml
)
fout
.
write
(
new_pretty_xml
)
for
partition
in
self
.
partition_list
:
partition
.
dump
()
def
backup_xml
(
self
,
path_to_archive
,
path_to_xml
):
def
backup_xml
(
self
,
path_to_archive
,
path_to_xml
):
"""
"""
Stores a copy of the current xml file to an historical archive.
Stores a copy of the current xml file to an historical archive.
...
@@ -632,6 +635,8 @@ class Computer(object):
...
@@ -632,6 +635,8 @@ class Computer(object):
class
Partition
(
object
):
class
Partition
(
object
):
"Represent a computer partition"
"Represent a computer partition"
resource_file
=
".slapos-resource"
def
__init__
(
self
,
reference
,
path
,
user
,
address_list
,
def
__init__
(
self
,
reference
,
path
,
user
,
address_list
,
tap
,
external_storage_list
=
[],
tun
=
None
):
tap
,
external_storage_list
=
[],
tun
=
None
):
"""
"""
...
@@ -687,6 +692,19 @@ class Partition(object):
...
@@ -687,6 +692,19 @@ class Partition(object):
os
.
chown
(
storage_path
,
owner_pw
.
pw_uid
,
owner_pw
.
pw_gid
)
os
.
chown
(
storage_path
,
owner_pw
.
pw_uid
,
owner_pw
.
pw_gid
)
os
.
chmod
(
storage_path
,
0o750
)
os
.
chmod
(
storage_path
,
0o750
)
def
dump
(
self
):
"""Dump available resources into ~partition_home/.slapos-resource."""
file_path
=
os
.
path
.
join
(
self
.
path
,
self
.
resource_file
)
logger
.
info
(
"Partition {} dumping resources to {}"
.
format
(
self
.
reference
,
file_path
))
data
=
_getDict
(
self
)
with
open
(
file_path
,
"wb"
)
as
fo
:
json
.
dump
(
data
,
fo
,
sort_keys
=
True
,
indent
=
4
)
owner_pw
=
pwd
.
getpwnam
(
self
.
user
.
name
)
os
.
chmod
(
file_path
,
0o740
)
os
.
chown
(
file_path
,
owner_pw
.
pw_uid
,
owner_pw
.
pw_gid
)
class
User
(
object
):
class
User
(
object
):
"""User: represent and manipulate a user on the system."""
"""User: represent and manipulate a user on the system."""
...
...
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