Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
SlapOS Develop
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
Eric Zheng
SlapOS Develop
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.
# Copyright (c) 2010 Vifib SARL and Contributors. All Rights Reserved.
...
@@ -26,15 +25,26 @@
...
@@ -26,15 +25,26 @@
#
#
##############################################################################
##############################################################################
import
random
import
random
import
os
from
slapos.recipe.librecipe
import
GenericBaseRecipe
from
slapos.recipe.librecipe
import
GenericBaseRecipe
class
Recipe
(
GenericBaseRecipe
):
class
Recipe
(
GenericBaseRecipe
):
def
__init__
(
self
,
buildout
,
name
,
options
):
def
__init__
(
self
,
buildout
,
name
,
options
):
# First octet has to represent a locally administered address
if
os
.
path
.
exists
(
options
[
'storage-path'
]):
octet_list
=
[
254
]
+
[
random
.
randint
(
0x00
,
0xff
)
for
x
in
range
(
5
)]
open_file
=
open
(
options
[
'storage-path'
],
'r'
)
options
[
'mac-address'
]
=
':'
.
join
([
'%02x'
%
x
for
x
in
octet_list
])
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
):
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
...
@@ -33,6 +33,7 @@ ca-dir = $${rootdirectory:srv}/ssl
[create-mac]
[create-mac]
recipe = slapos.cookbook:generate.mac
recipe = slapos.cookbook:generate.mac
storage-path = $${rootdirectory:srv}/mac
[kvm-instance]
[kvm-instance]
recipe = slapos.cookbook:kvm
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