Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
OpenXG-WIC-Cnf
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
3
Issues
3
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
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
CommunityXG
OpenXG-WIC-Cnf
Commits
a2645114
Commit
a2645114
authored
Jun 21, 2020
by
wutu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改为默认在root目录下进行部署,去掉原有的账户密码强绑定关系
parent
8e2e57da
Pipeline
#103
passed with stage
in 0 seconds
Changes
3
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
14 deletions
+14
-14
cnf-utils/src/main/java/top/ninwoo/utils/util/impl/OvsDockerUtilsImpl.java
...n/java/top/ninwoo/utils/util/impl/OvsDockerUtilsImpl.java
+2
-2
cnf-utils/src/main/java/top/ninwoo/utils/util/impl/OvsUtilsImpl.java
...rc/main/java/top/ninwoo/utils/util/impl/OvsUtilsImpl.java
+11
-11
cnf-utils/src/test/java/top/ninwoo/utils/DockerServiceTests.java
...ls/src/test/java/top/ninwoo/utils/DockerServiceTests.java
+1
-1
No files found.
cnf-utils/src/main/java/top/ninwoo/utils/util/impl/OvsDockerUtilsImpl.java
View file @
a2645114
...
@@ -21,7 +21,7 @@ public class OvsDockerUtilsImpl implements OvsDockerUtils {
...
@@ -21,7 +21,7 @@ public class OvsDockerUtilsImpl implements OvsDockerUtils {
@Override
@Override
public
String
addPort
(
String
bridgeName
,
String
devName
,
public
String
addPort
(
String
bridgeName
,
String
devName
,
String
containerId
,
String
ip
)
{
String
containerId
,
String
ip
)
{
String
cmd
=
"
echo 'Vudo3423' | sudo -S
ovs-docker add-port "
+
bridgeName
String
cmd
=
"ovs-docker add-port "
+
bridgeName
+
" "
+
devName
+
" "
+
containerId
+
" --ipaddress="
+
ip
;
+
" "
+
devName
+
" "
+
containerId
+
" --ipaddress="
+
ip
;
String
res
=
linuxCtlUtils
.
runCmd
(
cmd
);
String
res
=
linuxCtlUtils
.
runCmd
(
cmd
);
if
(
res
.
contains
(
"Error"
))
{
if
(
res
.
contains
(
"Error"
))
{
...
@@ -37,7 +37,7 @@ public class OvsDockerUtilsImpl implements OvsDockerUtils {
...
@@ -37,7 +37,7 @@ public class OvsDockerUtilsImpl implements OvsDockerUtils {
@Override
@Override
public
String
delPort
(
String
bridgeName
,
String
devName
,
String
containerId
)
{
public
String
delPort
(
String
bridgeName
,
String
devName
,
String
containerId
)
{
String
cmd
=
"
echo 'Vudo3423' | sudo -S
ovs-docker del-port "
+
bridgeName
+
" "
String
cmd
=
"ovs-docker del-port "
+
bridgeName
+
" "
+
devName
+
" "
+
containerId
;
+
devName
+
" "
+
containerId
;
return
linuxCtlUtils
.
runCmd
(
cmd
);
return
linuxCtlUtils
.
runCmd
(
cmd
);
...
...
cnf-utils/src/main/java/top/ninwoo/utils/util/impl/OvsUtilsImpl.java
View file @
a2645114
...
@@ -40,7 +40,7 @@ public class OvsUtilsImpl implements OvsUtils {
...
@@ -40,7 +40,7 @@ public class OvsUtilsImpl implements OvsUtils {
@Override
@Override
public
Ovs
showDetails
()
{
public
Ovs
showDetails
()
{
String
res
=
linuxCtlUtils
.
runCmd
(
"
echo 'Vudo3423' | sudo -S
ovs-vsctl show"
);
String
res
=
linuxCtlUtils
.
runCmd
(
"ovs-vsctl show"
);
Ovs
ovs
=
parseOvsString
(
res
);
Ovs
ovs
=
parseOvsString
(
res
);
return
ovs
;
return
ovs
;
...
@@ -128,7 +128,7 @@ public class OvsUtilsImpl implements OvsUtils {
...
@@ -128,7 +128,7 @@ public class OvsUtilsImpl implements OvsUtils {
@Override
@Override
public
void
addBridge
(
String
name
)
{
public
void
addBridge
(
String
name
)
{
String
cmd
=
"
echo 'Vudo3423' | sudo -S
ovs-vsctl add-br "
+
name
;
String
cmd
=
"ovs-vsctl add-br "
+
name
;
String
res
=
linuxCtlUtils
.
runCmd
(
cmd
);
String
res
=
linuxCtlUtils
.
runCmd
(
cmd
);
if
(
res
.
contains
(
"Error"
))
{
if
(
res
.
contains
(
"Error"
))
{
throw
new
RuntimeException
(
"linux bridge has existed!"
);
throw
new
RuntimeException
(
"linux bridge has existed!"
);
...
@@ -137,7 +137,7 @@ public class OvsUtilsImpl implements OvsUtils {
...
@@ -137,7 +137,7 @@ public class OvsUtilsImpl implements OvsUtils {
@Override
@Override
public
void
setBridgeProtocol
(
String
bridgeName
,
String
protocol
)
{
public
void
setBridgeProtocol
(
String
bridgeName
,
String
protocol
)
{
String
cmd
=
"
echo 'Vudo3423' | sudo -S
ovs-vsctl set bridge "
+
bridgeName
+
" protocols="
+
protocol
;
String
cmd
=
"ovs-vsctl set bridge "
+
bridgeName
+
" protocols="
+
protocol
;
String
res
=
linuxCtlUtils
.
runCmd
(
cmd
);
String
res
=
linuxCtlUtils
.
runCmd
(
cmd
);
if
(
res
.
contains
(
"Error"
))
{
if
(
res
.
contains
(
"Error"
))
{
throw
new
RuntimeException
(
res
);
throw
new
RuntimeException
(
res
);
...
@@ -146,7 +146,7 @@ public class OvsUtilsImpl implements OvsUtils {
...
@@ -146,7 +146,7 @@ public class OvsUtilsImpl implements OvsUtils {
@Override
@Override
public
void
setController
(
String
bridgeName
,
String
host
,
int
port
)
{
public
void
setController
(
String
bridgeName
,
String
host
,
int
port
)
{
String
cmd
=
"
echo 'Vudo3423' | sudo -S
ovs-vsctl set-controller "
+
bridgeName
+
" tcp:"
+
host
+
":"
+
port
;
String
cmd
=
"ovs-vsctl set-controller "
+
bridgeName
+
" tcp:"
+
host
+
":"
+
port
;
String
res
=
linuxCtlUtils
.
runCmd
(
cmd
);
String
res
=
linuxCtlUtils
.
runCmd
(
cmd
);
if
(
res
.
contains
(
"Error"
))
{
if
(
res
.
contains
(
"Error"
))
{
throw
new
RuntimeException
(
res
);
throw
new
RuntimeException
(
res
);
...
@@ -155,7 +155,7 @@ public class OvsUtilsImpl implements OvsUtils {
...
@@ -155,7 +155,7 @@ public class OvsUtilsImpl implements OvsUtils {
@Override
@Override
public
void
delBridge
(
String
name
)
{
public
void
delBridge
(
String
name
)
{
String
cmd
=
"
echo 'Vudo3423' | sudo -S
ovs-vsctl del-br "
+
name
;
String
cmd
=
"ovs-vsctl del-br "
+
name
;
LOG
.
info
(
"删除网桥[{}]"
,
name
);
LOG
.
info
(
"删除网桥[{}]"
,
name
);
String
res
=
linuxCtlUtils
.
runCmd
(
cmd
);
String
res
=
linuxCtlUtils
.
runCmd
(
cmd
);
if
(
res
.
contains
(
"Error"
))
{
if
(
res
.
contains
(
"Error"
))
{
...
@@ -171,7 +171,7 @@ public class OvsUtilsImpl implements OvsUtils {
...
@@ -171,7 +171,7 @@ public class OvsUtilsImpl implements OvsUtils {
*/
*/
@Override
@Override
public
boolean
addBridgePort
(
String
bridgeName
,
String
port
)
{
public
boolean
addBridgePort
(
String
bridgeName
,
String
port
)
{
String
cmd
=
"
echo 'Vudo3423' | sudo -S
ovs-vsctl add-port "
+
bridgeName
+
" "
+
port
;
String
cmd
=
"ovs-vsctl add-port "
+
bridgeName
+
" "
+
port
;
String
res
=
linuxCtlUtils
.
runCmd
(
cmd
);
String
res
=
linuxCtlUtils
.
runCmd
(
cmd
);
LOG
.
info
(
"为Bridge:{} 添加Port:{}"
,
bridgeName
,
port
);
LOG
.
info
(
"为Bridge:{} 添加Port:{}"
,
bridgeName
,
port
);
if
(!
""
.
equals
(
res
))
{
if
(!
""
.
equals
(
res
))
{
...
@@ -183,7 +183,7 @@ public class OvsUtilsImpl implements OvsUtils {
...
@@ -183,7 +183,7 @@ public class OvsUtilsImpl implements OvsUtils {
@Override
@Override
public
boolean
delBridgePort
(
String
bridgeName
,
String
port
)
{
public
boolean
delBridgePort
(
String
bridgeName
,
String
port
)
{
String
cmd
=
"
echo 'Vudo3423' | sudo -S
ovs-vsctl del-port "
+
bridgeName
+
" "
+
port
;
String
cmd
=
"ovs-vsctl del-port "
+
bridgeName
+
" "
+
port
;
LOG
.
info
(
"删除Bridge:{} Port:{}"
,
bridgeName
,
port
);
LOG
.
info
(
"删除Bridge:{} Port:{}"
,
bridgeName
,
port
);
String
res
=
linuxCtlUtils
.
runCmd
(
cmd
);
String
res
=
linuxCtlUtils
.
runCmd
(
cmd
);
if
(!
""
.
equals
(
res
))
{
if
(!
""
.
equals
(
res
))
{
...
@@ -203,7 +203,7 @@ public class OvsUtilsImpl implements OvsUtils {
...
@@ -203,7 +203,7 @@ public class OvsUtilsImpl implements OvsUtils {
public
String
[]
createVethPair
(
String
br1
,
String
br2
)
{
public
String
[]
createVethPair
(
String
br1
,
String
br2
)
{
String
veth1
=
br1
+
"_"
+
br2
;
String
veth1
=
br1
+
"_"
+
br2
;
String
veth2
=
br2
+
"_"
+
br1
;
String
veth2
=
br2
+
"_"
+
br1
;
String
cmd
=
"
echo 'Vudo3423' | sudo -S
ip link add "
+
veth1
+
" type veth peer name "
+
veth2
;
String
cmd
=
"ip link add "
+
veth1
+
" type veth peer name "
+
veth2
;
LOG
.
info
(
"创建虚拟网卡对[{},{}]"
,
veth1
,
veth2
);
LOG
.
info
(
"创建虚拟网卡对[{},{}]"
,
veth1
,
veth2
);
String
res
=
linuxCtlUtils
.
runCmd
(
cmd
);
String
res
=
linuxCtlUtils
.
runCmd
(
cmd
);
if
(!
""
.
equals
(
res
))
{
if
(!
""
.
equals
(
res
))
{
...
@@ -221,7 +221,7 @@ public class OvsUtilsImpl implements OvsUtils {
...
@@ -221,7 +221,7 @@ public class OvsUtilsImpl implements OvsUtils {
public
boolean
delVethPort
(
String
[]
veths
)
{
public
boolean
delVethPort
(
String
[]
veths
)
{
String
veth1
=
veths
[
0
];
String
veth1
=
veths
[
0
];
String
veth2
=
veths
[
1
];
String
veth2
=
veths
[
1
];
String
cmd
=
"
echo 'Vudo3423' | sudo -S
ip link del "
+
veth1
+
" type veth peer name "
+
veth2
;
String
cmd
=
"ip link del "
+
veth1
+
" type veth peer name "
+
veth2
;
LOG
.
info
(
"删除虚拟网卡对[{},{}]"
,
veth1
,
veth2
);
LOG
.
info
(
"删除虚拟网卡对[{},{}]"
,
veth1
,
veth2
);
String
res
=
linuxCtlUtils
.
runCmd
(
cmd
);
String
res
=
linuxCtlUtils
.
runCmd
(
cmd
);
if
(!
""
.
equals
(
res
))
{
if
(!
""
.
equals
(
res
))
{
...
@@ -239,7 +239,7 @@ public class OvsUtilsImpl implements OvsUtils {
...
@@ -239,7 +239,7 @@ public class OvsUtilsImpl implements OvsUtils {
*/
*/
@Override
@Override
public
boolean
enableLinuxPort
(
String
port
)
{
public
boolean
enableLinuxPort
(
String
port
)
{
String
cmd
=
"
echo 'Vudo3423' | sudo -S
ifconfig "
+
port
+
" up"
;
String
cmd
=
"ifconfig "
+
port
+
" up"
;
LOG
.
info
(
"启动Linux端口:{}"
,
port
);
LOG
.
info
(
"启动Linux端口:{}"
,
port
);
String
res
=
linuxCtlUtils
.
runCmd
(
cmd
);
String
res
=
linuxCtlUtils
.
runCmd
(
cmd
);
if
(!
""
.
equals
(
res
))
{
if
(!
""
.
equals
(
res
))
{
...
@@ -275,7 +275,7 @@ public class OvsUtilsImpl implements OvsUtils {
...
@@ -275,7 +275,7 @@ public class OvsUtilsImpl implements OvsUtils {
public
boolean
setVxlan
(
String
bridgeName
,
String
remoteIp
)
{
public
boolean
setVxlan
(
String
bridgeName
,
String
remoteIp
)
{
// TODO: bug
// TODO: bug
int
id
=
atomicInteger
.
getAndIncrement
();
int
id
=
atomicInteger
.
getAndIncrement
();
String
cmd
=
"
echo 'Vudo3423' | sudo -S
ovs-vsctl add-port "
+
bridgeName
String
cmd
=
"ovs-vsctl add-port "
+
bridgeName
+
" vxlan"
+
id
+
" -- set interface vxlan"
+
id
+
" type=vxlan options:remote_ip="
+
remoteIp
;
+
" vxlan"
+
id
+
" -- set interface vxlan"
+
id
+
" type=vxlan options:remote_ip="
+
remoteIp
;
System
.
out
.
println
(
cmd
);
System
.
out
.
println
(
cmd
);
LOG
.
info
(
"设置VXLAN[bridgeName:{},remoteIP:{},{}]"
,
bridgeName
,
remoteIp
,
cmd
);
LOG
.
info
(
"设置VXLAN[bridgeName:{},remoteIP:{},{}]"
,
bridgeName
,
remoteIp
,
cmd
);
...
...
cnf-utils/src/test/java/top/ninwoo/utils/DockerServiceTests.java
View file @
a2645114
...
@@ -37,7 +37,7 @@ public class DockerServiceTests {
...
@@ -37,7 +37,7 @@ public class DockerServiceTests {
@Test
@Test
public
void
testSudo
()
{
public
void
testSudo
()
{
String
result
=
linuxCtlService
.
runCmd
(
"
echo Vudo3423 | sudo -S
ovs-vsctl show"
);
String
result
=
linuxCtlService
.
runCmd
(
"ovs-vsctl show"
);
System
.
out
.
println
(
result
);
System
.
out
.
println
(
result
);
}
}
...
...
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