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
Léo-Paul Géneau
slapos.core
Commits
a1f378f7
Commit
a1f378f7
authored
Jun 14, 2013
by
Marco Mariani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
some whitespace/indent changes to please pep8
parent
314fd21e
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
56 additions
and
54 deletions
+56
-54
slapos/client.py
slapos/client.py
+9
-7
slapos/format.py
slapos/format.py
+39
-41
slapos/util.py
slapos/util.py
+8
-5
slapos/version.py
slapos/version.py
+0
-1
No files found.
slapos/client.py
View file @
a1f378f7
...
@@ -80,6 +80,7 @@ class ClientConfig(object):
...
@@ -80,6 +80,7 @@ class ClientConfig(object):
if
self
.
cert_file
:
if
self
.
cert_file
:
self
.
cert_file
=
os
.
path
.
expanduser
(
self
.
cert_file
)
self
.
cert_file
=
os
.
path
.
expanduser
(
self
.
cert_file
)
def
init
(
conf
):
def
init
(
conf
):
"""Initialize Slap instance, connect to server and create
"""Initialize Slap instance, connect to server and create
aliases to common software releases"""
aliases to common software releases"""
...
@@ -122,13 +123,13 @@ def do_request(conf, local):
...
@@ -122,13 +123,13 @@ def do_request(conf, local):
conf
.
software_url
=
local
[
conf
.
software_url
]
conf
.
software_url
=
local
[
conf
.
software_url
]
try
:
try
:
partition
=
local
[
'slap'
].
registerOpenOrder
().
request
(
partition
=
local
[
'slap'
].
registerOpenOrder
().
request
(
software_release
=
conf
.
software_url
,
software_release
=
conf
.
software_url
,
partition_reference
=
conf
.
reference
,
partition_reference
=
conf
.
reference
,
partition_parameter_kw
=
conf
.
parameters
,
partition_parameter_kw
=
conf
.
parameters
,
software_type
=
conf
.
type
,
software_type
=
conf
.
type
,
filter_kw
=
conf
.
node
,
filter_kw
=
conf
.
node
,
state
=
conf
.
state
,
state
=
conf
.
state
,
shared
=
conf
.
slave
shared
=
conf
.
slave
)
)
print
"Instance requested.
\
n
State is : %s."
%
partition
.
getState
()
print
"Instance requested.
\
n
State is : %s."
%
partition
.
getState
()
print
"Connection parameters of instance are:"
print
"Connection parameters of instance are:"
...
@@ -185,6 +186,7 @@ def do_console(local):
...
@@ -185,6 +186,7 @@ def do_console(local):
readline
.
parse_and_bind
(
"tab: complete"
)
readline
.
parse_and_bind
(
"tab: complete"
)
historyPath
=
os
.
path
.
expanduser
(
"~/.slapconsolehistory"
)
historyPath
=
os
.
path
.
expanduser
(
"~/.slapconsolehistory"
)
def
save_history
(
historyPath
=
historyPath
):
def
save_history
(
historyPath
=
historyPath
):
readline
.
write_history_file
(
historyPath
)
readline
.
write_history_file
(
historyPath
)
if
os
.
path
.
exists
(
historyPath
):
if
os
.
path
.
exists
(
historyPath
):
...
...
slapos/format.py
View file @
a1f378f7
...
@@ -307,7 +307,6 @@ class Computer(object):
...
@@ -307,7 +307,6 @@ 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
)
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.
...
@@ -318,7 +317,6 @@ class Computer(object):
...
@@ -318,7 +317,6 @@ class Computer(object):
with
zipfile
.
ZipFile
(
path_to_archive
,
'a'
)
as
archive
:
with
zipfile
.
ZipFile
(
path_to_archive
,
'a'
)
as
archive
:
archive
.
writestr
(
saved_filename
,
xml_content
,
zipfile
.
ZIP_DEFLATED
)
archive
.
writestr
(
saved_filename
,
xml_content
,
zipfile
.
ZIP_DEFLATED
)
@
classmethod
@
classmethod
def
load
(
cls
,
path_to_xml
,
reference
,
ipv6_interface
):
def
load
(
cls
,
path_to_xml
,
reference
,
ipv6_interface
):
"""
"""
...
@@ -336,11 +334,11 @@ class Computer(object):
...
@@ -336,11 +334,11 @@ class Computer(object):
# Reconstructing the computer object from the xml
# Reconstructing the computer object from the xml
computer
=
Computer
(
computer
=
Computer
(
reference
=
reference
,
reference
=
reference
,
addr
=
dumped_dict
[
'address'
],
addr
=
dumped_dict
[
'address'
],
netmask
=
dumped_dict
[
'netmask'
],
netmask
=
dumped_dict
[
'netmask'
],
ipv6_interface
=
ipv6_interface
,
ipv6_interface
=
ipv6_interface
,
software_user
=
dumped_dict
.
get
(
'software_user'
,
'slapsoft'
),
software_user
=
dumped_dict
.
get
(
'software_user'
,
'slapsoft'
),
)
)
for
partition_dict
in
dumped_dict
[
'partition_list'
]:
for
partition_dict
in
dumped_dict
[
'partition_list'
]:
...
@@ -358,11 +356,11 @@ class Computer(object):
...
@@ -358,11 +356,11 @@ class Computer(object):
address_list
=
partition_dict
[
'address_list'
]
address_list
=
partition_dict
[
'address_list'
]
partition
=
Partition
(
partition
=
Partition
(
reference
=
partition_dict
[
'reference'
],
reference
=
partition_dict
[
'reference'
],
path
=
partition_dict
[
'path'
],
path
=
partition_dict
[
'path'
],
user
=
user
,
user
=
user
,
address_list
=
address_list
,
address_list
=
address_list
,
tap
=
tap
,
tap
=
tap
,
)
)
computer
.
partition_list
.
append
(
partition
)
computer
.
partition_list
.
append
(
partition
)
...
@@ -730,7 +728,7 @@ class Interface(object):
...
@@ -730,7 +728,7 @@ class Interface(object):
if
isGlobalScopeAddress
(
q
[
'addr'
].
split
(
'%'
)[
0
])
if
isGlobalScopeAddress
(
q
[
'addr'
].
split
(
'%'
)[
0
])
]
]
except
KeyError
:
except
KeyError
:
raise
ValueError
(
"%s must have at least one IPv6 address assigned"
%
\
raise
ValueError
(
"%s must have at least one IPv6 address assigned"
%
interface_name
)
interface_name
)
if
sys
.
platform
==
'cygwin'
:
if
sys
.
platform
==
'cygwin'
:
for
q
in
address_list
:
for
q
in
address_list
:
...
@@ -838,8 +836,8 @@ class Interface(object):
...
@@ -838,8 +836,8 @@ class Interface(object):
while
try_num
>
0
:
while
try_num
>
0
:
addr
=
random
.
choice
([
q
for
q
in
netaddr
.
glob_to_iprange
(
addr
=
random
.
choice
([
q
for
q
in
netaddr
.
glob_to_iprange
(
netaddr
.
cidr_to_glob
(
self
.
ipv4_local_network
))]).
format
()
netaddr
.
cidr_to_glob
(
self
.
ipv4_local_network
))]).
format
()
if
dict
(
addr
=
addr
,
netmask
=
netmask
)
not
in
\
if
(
dict
(
addr
=
addr
,
netmask
=
netmask
)
not
in
self
.
getIPv4LocalAddressList
(
):
self
.
getIPv4LocalAddressList
()
):
# Checking the validity of the IPv6 address
# Checking the validity of the IPv6 address
if
self
.
_addSystemAddress
(
addr
,
netmask
,
False
):
if
self
.
_addSystemAddress
(
addr
,
netmask
,
False
):
return
dict
(
addr
=
addr
,
netmask
=
netmask
)
return
dict
(
addr
=
addr
,
netmask
=
netmask
)
...
@@ -926,8 +924,8 @@ class Interface(object):
...
@@ -926,8 +924,8 @@ class Interface(object):
addr
=
':'
.
join
(
address_dict
[
'addr'
].
split
(
':'
)[:
-
1
]
+
[
'%x'
%
(
addr
=
':'
.
join
(
address_dict
[
'addr'
].
split
(
':'
)[:
-
1
]
+
[
'%x'
%
(
random
.
randint
(
1
,
65000
),
)])
random
.
randint
(
1
,
65000
),
)])
socket
.
inet_pton
(
socket
.
AF_INET6
,
addr
)
socket
.
inet_pton
(
socket
.
AF_INET6
,
addr
)
if
dict
(
addr
=
addr
,
netmask
=
netmask
)
not
in
\
if
(
dict
(
addr
=
addr
,
netmask
=
netmask
)
not
in
self
.
getGlobalScopeAddressList
(
):
self
.
getGlobalScopeAddressList
()
):
# Checking the validity of the IPv6 address
# Checking the validity of the IPv6 address
if
self
.
_addSystemAddress
(
addr
,
netmask
):
if
self
.
_addSystemAddress
(
addr
,
netmask
):
return
dict
(
addr
=
addr
,
netmask
=
netmask
)
return
dict
(
addr
=
addr
,
netmask
=
netmask
)
...
@@ -947,8 +945,8 @@ def parse_computer_definition(conf, definition_path):
...
@@ -947,8 +945,8 @@ def parse_computer_definition(conf, definition_path):
netmask
=
None
netmask
=
None
if
computer_definition
.
has_option
(
'computer'
,
'address'
):
if
computer_definition
.
has_option
(
'computer'
,
'address'
):
address
,
netmask
=
computer_definition
.
get
(
'computer'
,
'address'
).
split
(
'/'
)
address
,
netmask
=
computer_definition
.
get
(
'computer'
,
'address'
).
split
(
'/'
)
if
conf
.
alter_network
and
conf
.
interface_name
is
not
None
\
if
(
conf
.
alter_network
and
conf
.
interface_name
is
not
None
and
conf
.
ipv4_local_network
is
not
None
:
and
conf
.
ipv4_local_network
is
not
None
)
:
interface
=
Interface
(
logger
=
conf
.
logger
,
interface
=
Interface
(
logger
=
conf
.
logger
,
name
=
conf
.
interface_name
,
name
=
conf
.
interface_name
,
ipv4_local_network
=
conf
.
ipv4_local_network
,
ipv4_local_network
=
conf
.
ipv4_local_network
,
...
...
slapos/util.py
View file @
a1f378f7
# -*- coding: utf-8 -*-
# -*- coding: utf-8 -*-
import
os
,
errno
import
errno
import
os
def
mkdir_p
(
path
,
mode
=
0o777
):
def
mkdir_p
(
path
,
mode
=
0o777
):
"""
\
"""
\
...
@@ -17,6 +19,7 @@ def mkdir_p(path, mode=0o777):
...
@@ -17,6 +19,7 @@ def mkdir_p(path, mode=0o777):
else
:
else
:
raise
raise
def
chownDirectory
(
path
,
uid
,
gid
):
def
chownDirectory
(
path
,
uid
,
gid
):
os
.
chown
(
path
,
uid
,
gid
)
os
.
chown
(
path
,
uid
,
gid
)
for
root
,
dirs
,
files
in
os
.
walk
(
path
):
for
root
,
dirs
,
files
in
os
.
walk
(
path
):
...
...
slapos/version.py
View file @
a1f378f7
version
=
'0.35.2-dev'
version
=
'0.35.2-dev'
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