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
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
alex037yang
openXG-WIC-Cnf
Commits
64eb53da
Commit
64eb53da
authored
Jun 22, 2020
by
joliu
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature-cnf-without-password-1' into 'feature-cnf'
Resolve "删除用户名密码强耦合问题" See merge request
xidiancos/cnf!2
parents
8e2e57da
a2645114
Changes
3
Hide 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 @
64eb53da
...
...
@@ -21,7 +21,7 @@ public class OvsDockerUtilsImpl implements OvsDockerUtils {
@Override
public
String
addPort
(
String
bridgeName
,
String
devName
,
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
;
String
res
=
linuxCtlUtils
.
runCmd
(
cmd
);
if
(
res
.
contains
(
"Error"
))
{
...
...
@@ -37,7 +37,7 @@ public class OvsDockerUtilsImpl implements OvsDockerUtils {
@Override
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
;
return
linuxCtlUtils
.
runCmd
(
cmd
);
...
...
cnf-utils/src/main/java/top/ninwoo/utils/util/impl/OvsUtilsImpl.java
View file @
64eb53da
...
...
@@ -40,7 +40,7 @@ public class OvsUtilsImpl implements OvsUtils {
@Override
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
);
return
ovs
;
...
...
@@ -128,7 +128,7 @@ public class OvsUtilsImpl implements OvsUtils {
@Override
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
);
if
(
res
.
contains
(
"Error"
))
{
throw
new
RuntimeException
(
"linux bridge has existed!"
);
...
...
@@ -137,7 +137,7 @@ public class OvsUtilsImpl implements OvsUtils {
@Override
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
);
if
(
res
.
contains
(
"Error"
))
{
throw
new
RuntimeException
(
res
);
...
...
@@ -146,7 +146,7 @@ public class OvsUtilsImpl implements OvsUtils {
@Override
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
);
if
(
res
.
contains
(
"Error"
))
{
throw
new
RuntimeException
(
res
);
...
...
@@ -155,7 +155,7 @@ public class OvsUtilsImpl implements OvsUtils {
@Override
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
);
String
res
=
linuxCtlUtils
.
runCmd
(
cmd
);
if
(
res
.
contains
(
"Error"
))
{
...
...
@@ -171,7 +171,7 @@ public class OvsUtilsImpl implements OvsUtils {
*/
@Override
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
);
LOG
.
info
(
"为Bridge:{} 添加Port:{}"
,
bridgeName
,
port
);
if
(!
""
.
equals
(
res
))
{
...
...
@@ -183,7 +183,7 @@ public class OvsUtilsImpl implements OvsUtils {
@Override
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
);
String
res
=
linuxCtlUtils
.
runCmd
(
cmd
);
if
(!
""
.
equals
(
res
))
{
...
...
@@ -203,7 +203,7 @@ public class OvsUtilsImpl implements OvsUtils {
public
String
[]
createVethPair
(
String
br1
,
String
br2
)
{
String
veth1
=
br1
+
"_"
+
br2
;
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
);
String
res
=
linuxCtlUtils
.
runCmd
(
cmd
);
if
(!
""
.
equals
(
res
))
{
...
...
@@ -221,7 +221,7 @@ public class OvsUtilsImpl implements OvsUtils {
public
boolean
delVethPort
(
String
[]
veths
)
{
String
veth1
=
veths
[
0
];
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
);
String
res
=
linuxCtlUtils
.
runCmd
(
cmd
);
if
(!
""
.
equals
(
res
))
{
...
...
@@ -239,7 +239,7 @@ public class OvsUtilsImpl implements OvsUtils {
*/
@Override
public
boolean
enableLinuxPort
(
String
port
)
{
String
cmd
=
"
echo 'Vudo3423' | sudo -S
ifconfig "
+
port
+
" up"
;
String
cmd
=
"ifconfig "
+
port
+
" up"
;
LOG
.
info
(
"启动Linux端口:{}"
,
port
);
String
res
=
linuxCtlUtils
.
runCmd
(
cmd
);
if
(!
""
.
equals
(
res
))
{
...
...
@@ -275,7 +275,7 @@ public class OvsUtilsImpl implements OvsUtils {
public
boolean
setVxlan
(
String
bridgeName
,
String
remoteIp
)
{
// TODO: bug
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
;
System
.
out
.
println
(
cmd
);
LOG
.
info
(
"设置VXLAN[bridgeName:{},remoteIP:{},{}]"
,
bridgeName
,
remoteIp
,
cmd
);
...
...
cnf-utils/src/test/java/top/ninwoo/utils/DockerServiceTests.java
View file @
64eb53da
...
...
@@ -37,7 +37,7 @@ public class DockerServiceTests {
@Test
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
);
}
...
...
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