Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
lxc
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
lxc
Commits
2a385c0d
Commit
2a385c0d
authored
May 02, 2016
by
Thomas Tanaka
Committed by
Stéphane Graber
May 11, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve on the case where default networking config is incomplete
Signed-off-by:
Thomas Tanaka
<
thomas.tanaka@oracle.com
>
parent
2da19674
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
50 additions
and
34 deletions
+50
-34
lxc-oracle.in
templates/lxc-oracle.in
+25
-17
lxc-sparclinux.in
templates/lxc-sparclinux.in
+25
-17
No files found.
templates/lxc-oracle.in
View file @
2a385c0d
...
...
@@ -40,10 +40,6 @@ done
# Make sure the usual locations are in PATH
export
PATH
=
$PATH
:/usr/sbin:/usr/bin:/sbin:/bin
# use virbr0 that is setup by default by libvirtd
lxc_network_type
=
veth
lxc_network_link
=
virbr0
die
()
{
echo
"failed:
$1
"
...
...
@@ -484,11 +480,6 @@ container_config_create()
echo
"lxc.include = @LXCTEMPLATECONFIG@/oracle.common.conf"
>>
$cfg_dir
/config
fi
# generate a hwaddr for the container with a high mac address
# see http://sourceforge.net/tracker/?func=detail&aid=3411497&group_id=163076&atid=826303
local
hwaddr
=
"fe:
`
dd
if
=
/dev/urandom
bs
=
8
count
=
1 2>/dev/null |od
-t
x8 |
\
head
-n
1 |awk
'{print $2}'
|
cut
-c1-10
|
\
sed
's/\(..\)/\1:/g; s/.$//'
`
"
cat
<<
EOF
>>
$cfg_dir
/config || die "unable to create
$cfg_dir
/config"
# Container configuration for Oracle Linux
$container_release_major
.
$container_release_minor
lxc.arch =
$arch
...
...
@@ -506,20 +497,37 @@ EOF
fi
echo
"# Networking"
>>
$cfg_dir
/config
# see if the network settings were already specified
# see if the
default
network settings were already specified
lxc_network_type
=
`
grep
'^lxc.network.type'
$cfg_dir
/config |
awk
-F
'[= \t]+'
'{ print $2 }'
`
if
[
-z
"
$lxc_network_type
"
-a
\
\(
$host_distribution
=
"OracleServer"
-o
\
$host_distribution
=
"Fedora"
\)
]
;
then
echo
"lxc.network.type = veth"
>>
$cfg_dir
/config
echo
"lxc.network.flags = up"
>>
$cfg_dir
/config
echo
"lxc.network.link = virbr0"
>>
$cfg_dir
/config
if
[
-z
"
$lxc_network_type
"
]
;
then
echo
"lxc.network.type = veth"
>>
$cfg_dir
/config
lxc_network_type
=
veth
fi
lxc_network_link
=
`
grep
'^lxc.network.link'
$cfg_dir
/config |
awk
-F
'[= \t]+'
'{ print $2 }'
`
if
[
-z
"
$lxc_network_link
"
]
;
then
echo
"lxc.network.link = lxcbr0"
>>
$cfg_dir
/config
lxc_network_link
=
lxcbr0
fi
lxc_network_hwaddr
=
`
grep
'^lxc.network.hwaddr'
$cfg_dir
/config |
awk
-F
'[= \t]+'
'{ print $2 }'
`
if
[
-z
"
$lxc_network_hwaddr
"
]
;
then
# generate a hwaddr for the container
# see http://sourceforge.net/tracker/?func=detail&aid=3411497&group_id=163076&atid=826303
local
hwaddr
=
"00:16:3e:
`
dd
if
=
/dev/urandom
bs
=
8
count
=
1 2>/dev/null |od
-t
x8 |
\
head
-n1
|
awk
'{print $2}'
|
cut
-c1-6
|
\
sed
's/\(..\)/\1:/g; s/.$//'
`
"
echo
"lxc.network.hwaddr =
$hwaddr
"
>>
$cfg_dir
/config
fi
lxc_network_flags
=
`
grep
'^lxc.network.flags'
$cfg_dir
/config |
awk
-F
'[= \t]+'
'{ print $2 }'
`
if
[
-z
"
$lxc_network_flags
"
]
;
then
echo
"lxc.network.flags = up"
>>
$cfg_dir
/config
fi
cat
<<
EOF
>>
$cfg_dir
/config || die "unable to create
$cfg_dir
/config"
lxc.network.name = eth0
lxc.network.mtu = 1500
lxc.network.hwaddr =
$hwaddr
EOF
}
...
...
templates/lxc-sparclinux.in
View file @
2a385c0d
...
...
@@ -44,10 +44,6 @@ done
# Make sure the usual locations are in PATH
export
PATH
=
$PATH
:/usr/sbin:/usr/bin:/sbin:/bin
# use virbr0 that is setup by default by libvirtd
lxc_network_type
=
veth
lxc_network_link
=
virbr0
die
()
{
echo
"failed:
$1
"
...
...
@@ -319,11 +315,6 @@ container_config_create()
echo
"lxc.include = @LXCTEMPLATECONFIG@/sparclinux.common.conf"
>>
$cfg_dir
/config
fi
# generate a hwaddr for the container with a high mac address
# see http://sourceforge.net/tracker/?func=detail&aid=3411497&group_id=163076&atid=826303
local
hwaddr
=
"fe:
`
dd
if
=
/dev/urandom
bs
=
8
count
=
1 2>/dev/null |od
-t
x8 |
\
head
-n
1 |awk
'{print $2}'
|
cut
-c1-10
|
\
sed
's/\(..\)/\1:/g; s/.$//'
`
"
cat
<<
EOF
>>
$cfg_dir
/config || die "unable to create
$cfg_dir
/config"
# Container configuration for Linux for SPARC
$container_release_major
.
$container_release_minor
lxc.arch =
$arch
...
...
@@ -336,20 +327,37 @@ EOF
echo
"lxc.cap.drop = setfcap setpcap"
>>
$cfg_dir
/config
echo
"# Networking"
>>
$cfg_dir
/config
# see if the network settings were already specified
# see if the
default
network settings were already specified
lxc_network_type
=
`
grep
'^lxc.network.type'
$cfg_dir
/config |
awk
-F
'[= \t]+'
'{ print $2 }'
`
if
[
-z
"
$lxc_network_type
"
-a
\
\(
$host_distribution
=
"SPARCLinux"
-o
\
$host_distribution
=
"Fedora"
\)
]
;
then
echo
"lxc.network.type = veth"
>>
$cfg_dir
/config
echo
"lxc.network.flags = up"
>>
$cfg_dir
/config
echo
"lxc.network.link = virbr0"
>>
$cfg_dir
/config
if
[
-z
"
$lxc_network_type
"
]
;
then
echo
"lxc.network.type = veth"
>>
$cfg_dir
/config
lxc_network_type
=
veth
fi
lxc_network_link
=
`
grep
'^lxc.network.link'
$cfg_dir
/config |
awk
-F
'[= \t]+'
'{ print $2 }'
`
if
[
-z
"
$lxc_network_link
"
]
;
then
echo
"lxc.network.link = lxcbr0"
>>
$cfg_dir
/config
lxc_network_link
=
lxcbr0
fi
lxc_network_hwaddr
=
`
grep
'^lxc.network.hwaddr'
$cfg_dir
/config |
awk
-F
'[= \t]+'
'{ print $2 }'
`
if
[
-z
"
$lxc_network_hwaddr
"
]
;
then
# generate a hwaddr for the container
# see http://sourceforge.net/tracker/?func=detail&aid=3411497&group_id=163076&atid=826303
local
hwaddr
=
"00:16:3e:
`
dd
if
=
/dev/urandom
bs
=
8
count
=
1 2>/dev/null |od
-t
x8 |
\
head
-n1
|
awk
'{print $2}'
|
cut
-c1-6
|
\
sed
's/\(..\)/\1:/g; s/.$//'
`
"
echo
"lxc.network.hwaddr =
$hwaddr
"
>>
$cfg_dir
/config
fi
lxc_network_flags
=
`
grep
'^lxc.network.flags'
$cfg_dir
/config |
awk
-F
'[= \t]+'
'{ print $2 }'
`
if
[
-z
"
$lxc_network_flags
"
]
;
then
echo
"lxc.network.flags = up"
>>
$cfg_dir
/config
fi
cat
<<
EOF
>>
$cfg_dir
/config || die "unable to create
$cfg_dir
/config"
lxc.network.name = eth0
lxc.network.mtu = 1500
lxc.network.hwaddr =
$hwaddr
EOF
}
...
...
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