Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
jijisa
/
porch
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
7a99e061
authored
Sep 18, 2017
by
Heechul Kim
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
stretch support added.
parent
45fa329a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
0 deletions
scripts/macgen.py
scripts/macgen.py
0 → 100644
View file @
7a99e061
# python script to generate xen or kvm MAC address.
#
import
sys
import
random
#
def
randomMAC
(
hypervisor
=
'kvm'
):
l_first_three
=
[]
if
hypervisor
==
'xen'
:
l_first_three
=
[
0x00
,
0x16
,
0x3e
]
elif
hypervisor
==
'kvm'
:
l_first_three
=
[
0x52
,
0x54
,
0x00
]
else
:
# unknown hypervisor
raise
Exception
(
"Unknown hypervisor. should be 'kvm' or 'xen'"
)
mac
=
l_first_three
+
[
random
.
randint
(
0x00
,
0x7f
),
random
.
randint
(
0x00
,
0xff
),
random
.
randint
(
0x00
,
0xff
)
]
print
(
':'
.
join
(
map
(
lambda
x
:
"
%02
x"
%
x
,
mac
)))
if
__name__
==
"__main__"
:
if
len
(
sys
.
argv
)
==
2
:
randomMAC
(
sys
.
argv
[
1
])
else
:
randomMAC
()
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