Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
H
hostinfo
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Redmine
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Anders Blomdell
hostinfo
Commits
f03a4c60
Commit
f03a4c60
authored
11 years ago
by
Anders Blomdell
Browse files
Options
Downloads
Patches
Plain Diff
Version 2013-10-24 11:23
M src/hostinfo/dhcpd.py M src/hostinfo/yp.py
parent
b6dd7535
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/hostinfo/dhcpd.py
+29
-38
29 additions, 38 deletions
src/hostinfo/dhcpd.py
src/hostinfo/yp.py
+10
-3
10 additions, 3 deletions
src/hostinfo/yp.py
with
39 additions
and
41 deletions
src/hostinfo/dhcpd.py
+
29
−
38
View file @
f03a4c60
...
...
@@ -80,8 +80,9 @@ option PXE.mtftp-tmout code 4 = unsigned integer 8;
option PXE.mtftp-delay code 5 = unsigned integer 8;
option arch code 93 = unsigned integer 16; # RFC4578
class
"
pxeclient
_allow
"
{
class
"
pxeclient
"
{
match if substring (option vendor-class-identifier, 0, 9) =
"
PXEClient
"
;
next-server %(next_server)s;
if option arch = 00:06 {
filename
"
bootia32.efi
"
;
} else if option arch = 00:07 {
...
...
@@ -93,31 +94,12 @@ class "pxeclient_allow" {
"""
PXE_DENY
=
"""
class
"
pxeclient_deny
"
{
match if substring (option vendor-class-identifier, 0, 9) =
"
PXEClient
"
;
ignore booting;
}
"""
CLASS_PXECLIENT
=
"""
class
"
pxeclient
"
{
match if substring (option vendor-class-identifier, 0, 9) =
"
PXEClient
"
;
next-server %(next_server)s;
if option arch = 00:06 {
filename
"
bootia32.efi
"
;
} else if option arch = 00:07 {
filename
"
bootx64.efi
"
;
} else {
filename
"
pxelinux.0
"
;
}
}
}
class
"
noboot
"
{
match if substring (option vendor-class-identifier, 0, 9) !=
"
PXEClient
"
;
ignore booting;
}
"""
def
MacOS_NETBOOT
(
dhcphost
):
if
not
os
.
path
.
exists
(
'
/local/macos
'
):
return
''
...
...
@@ -175,7 +157,10 @@ def generate(tree, options):
|use-host-decl-names on;
"""
)
if
get_pxeboot
(
dhcp
)
==
'
only
'
:
result
+=
PXE_ALLOW
if
not
options
.
next_server
:
raise
util
.
HostinfoException
(
'
next_server not defined
'
,
where
=
dhcp
)
result
+=
PXE_ALLOW
%
dict
(
next_server
=
options
.
next_server
)
pass
else
:
result
+=
PXE_DENY
...
...
@@ -193,7 +178,8 @@ def generate(tree, options):
def
emit_interface
(
tree
,
options
,
interface
):
result
=
util
.
StringArray
()
subnet
=
dict
(
map
(
lambda
d
:
(
get_subnet
(
tree
,
d
.
_parent
),
d
),
subnet
=
dict
(
map
(
lambda
d
:
(
get_subnet
(
tree
,
d
.
_parent
),
map
(
None
,
d
.
_parent
.
_dhcpserver_
)),
interface
.
_ip_
.
_dhcpserver_
))
result
+=
'
shared-network
"
MAC(%s)
"
{
'
%
interface
.
ethernet
[
0
]
for
sn
,
dhcp
in
map
(
lambda
n
:
(
n
,
subnet
[
n
]),
sorted
(
subnet
)):
...
...
@@ -217,9 +203,10 @@ def emit_network(tree, options, subnet, dhcp):
netmask
=
net
.
netmask
,
broadcast
=
net
.
broadcast
,
host
=
options
.
host
))
if
dhcp
.
first
[
0
]
and
dhcp
.
last
[
0
]:
first
=
util
.
address
(
dhcp
.
first
[
0
])
last
=
util
.
address
(
dhcp
.
last
[
0
])
for
d
in
dhcp
:
if
d
.
first
[
0
]
and
d
.
last
[
0
]:
first
=
util
.
address
(
d
.
first
[
0
])
last
=
util
.
address
(
d
.
last
[
0
])
assert
first
in
net
,
'
%s not part of %s
'
%
(
first
,
net
)
assert
last
in
net
,
'
%s not part of %s
'
%
(
last
,
net
)
if
pxeboot
==
'
no
'
:
...
...
@@ -233,6 +220,7 @@ def emit_network(tree, options, subnet, dhcp):
| }
"""
%
dict
(
first
=
first
,
last
=
last
))
pass
pass
pass
result
+=
emit_subnet_info
(
subnet
).
indent
()
result
+=
'
}
'
return
result
...
...
@@ -346,7 +334,10 @@ def get_subnet(tree, ip):
def
get_pxeboot
(
dhcp
):
try
:
p
=
set
(
map
(
lambda
d
:
d
.
pxeboot
[
0
]
or
'
no
'
,
dhcp
))
assert
len
(
p
)
==
1
,
"
Mixed pxeboot not allowed (%s)
"
%
'
,
'
.
join
(
p
)
if
len
(
p
)
!=
1
:
raise
util
.
HostinfoException
(
"
Mixed pxeboot not allowed (%s)
"
%
'
,
'
.
join
(
p
),
where
=
dhcp
)
result
=
p
.
pop
()
pass
except
TypeError
:
...
...
This diff is collapsed.
Click to expand it.
src/hostinfo/yp.py
+
10
−
3
View file @
f03a4c60
...
...
@@ -103,9 +103,16 @@ def netgroup(tree):
pass
pass
for
g
in
tree
.
_host_
.
_interface_
.
_netgroup_
:
for
ip
in
filter
(
lambda
ip
:
(
not
ip
.
alias
[
0
]
and
not
ip
.
vlan
[
0
]
and
not
ip
.
never
[
0
]),
g
.
_parent
.
_ip_
):
def
exclude
(
ip
):
if
ip
.
alias
[
0
]
or
ip
.
vlan
[
0
]
or
ip
.
never
[
0
]:
return
False
if
ip
.
exclude_netgroups
[
0
]:
if
g
.
name
[
0
]
in
ip
.
exclude_netgroups
[
0
].
split
(
'
,
'
):
return
False
pass
return
True
for
ip
in
filter
(
exclude
,
g
.
_parent
.
_ip_
):
if
not
g
.
name
[
0
:]
in
netgroup
:
netgroup
[
g
.
name
[
0
:]]
=
[
]
pass
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment