Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
slapos
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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Rafael Monnerat
slapos
Commits
eed7410e
Commit
eed7410e
authored
Jun 20, 2012
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Stabilize the mac address generation.
Mac address is now stored in plaintext on the file system.
parent
3d460bf3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
5 deletions
+16
-5
slapos/recipe/generatemac.py
slapos/recipe/generatemac.py
+15
-5
software/kvm/instance-kvm.cfg
software/kvm/instance-kvm.cfg
+1
-0
No files found.
slapos/recipe/generatemac.py
View file @
eed7410e
##############################################################################
#
# Copyright (c) 2010 Vifib SARL and Contributors. All Rights Reserved.
...
...
@@ -26,15 +25,26 @@
#
##############################################################################
import
random
import
os
from
slapos.recipe.librecipe
import
GenericBaseRecipe
class
Recipe
(
GenericBaseRecipe
):
def
__init__
(
self
,
buildout
,
name
,
options
):
# First octet has to represent a locally administered address
octet_list
=
[
254
]
+
[
random
.
randint
(
0x00
,
0xff
)
for
x
in
range
(
5
)]
options
[
'mac-address'
]
=
':'
.
join
([
'%02x'
%
x
for
x
in
octet_list
])
if
os
.
path
.
exists
(
options
[
'storage-path'
]):
open_file
=
open
(
options
[
'storage-path'
],
'r'
)
options
[
'mac-address'
]
=
open_file
.
read
()
open_file
.
close
()
if
options
.
get
(
'mac-address'
,
''
)
==
''
:
# First octet has to represent a locally administered address
octet_list
=
[
254
]
+
[
random
.
randint
(
0x00
,
0xff
)
for
x
in
range
(
5
)]
options
[
'mac-address'
]
=
':'
.
join
([
'%02x'
%
x
for
x
in
octet_list
])
return
GenericBaseRecipe
.
__init__
(
self
,
buildout
,
name
,
options
)
def
install
(
self
):
return
[]
open_file
=
open
(
self
.
options
[
'storage-path'
],
'w'
)
open_file
.
write
(
self
.
options
[
'mac-address'
])
open_file
.
close
()
return
[
self
.
options
[
'storage-path'
]]
software/kvm/instance-kvm.cfg
View file @
eed7410e
...
...
@@ -33,6 +33,7 @@ ca-dir = $${rootdirectory:srv}/ssl
[create-mac]
recipe = slapos.cookbook:generate.mac
storage-path = $${rootdirectory:srv}/mac
[kvm-instance]
recipe = slapos.cookbook:kvm
...
...
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