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
af04ed93
Commit
af04ed93
authored
Aug 12, 2020
by
Elf
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
删除了ovs中的sudo命令
parent
16b2a979
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
11 deletions
+16
-11
README.md
README.md
+7
-2
cnf-utils/src/main/java/top/ninwoo/utils/util/impl/OvsUtilsImpl.java
...rc/main/java/top/ninwoo/utils/util/impl/OvsUtilsImpl.java
+9
-9
No files found.
README.md
View file @
af04ed93
...
...
@@ -19,8 +19,13 @@
*
刘建瓯
*
张夏童
## 更新说明
##
第一次
更新说明
1.
使用域名替换配置中的IP,防止多人多次修改配置类并进行提交,避免合并分支时出现冲突的问题。
如果有需要在自己的电脑上进行部署,需要通过修改本机host的方式来修改对应节点的IP。
2.
测试代码
## 第二次更新说明(Elf:2020-8-12)
1.
平台docker化,删去ovs中的sudo命令,具体见cnf/cnf-utils/OvsUtilsImpl
2.
有关虚拟网卡对之间未作修改,原因是我还没想好如何在docker中运行
\ No newline at end of file
cnf-utils/src/main/java/top/ninwoo/utils/util/impl/OvsUtilsImpl.java
View file @
af04ed93
...
...
@@ -33,7 +33,7 @@ public class OvsUtilsImpl implements OvsUtils {
@Override
public
boolean
isInstall
()
{
// 可能会遇到权限问题
String
s
=
linuxCtlUtils
.
runCmd
(
"
echo '"
+
passwd
+
"' | sudo -S
ovs-vsctl --version"
);
String
s
=
linuxCtlUtils
.
runCmd
(
"ovs-vsctl --version"
);
if
(
s
.
contains
(
"Error"
))
{
return
false
;
}
else
{
...
...
@@ -43,7 +43,7 @@ public class OvsUtilsImpl implements OvsUtils {
@Override
public
Ovs
showDetails
()
{
String
res
=
linuxCtlUtils
.
runCmd
(
"
echo '"
+
passwd
+
"' | sudo -S
ovs-vsctl show"
);
String
res
=
linuxCtlUtils
.
runCmd
(
"ovs-vsctl show"
);
Ovs
ovs
=
parseOvsString
(
res
);
return
ovs
;
...
...
@@ -131,7 +131,7 @@ public class OvsUtilsImpl implements OvsUtils {
@Override
public
void
addBridge
(
String
name
)
{
String
cmd
=
"
echo '"
+
passwd
+
"' | 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!"
);
...
...
@@ -140,7 +140,7 @@ public class OvsUtilsImpl implements OvsUtils {
@Override
public
void
setBridgeProtocol
(
String
bridgeName
,
String
protocol
)
{
String
cmd
=
"
echo '"
+
passwd
+
"' | 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
);
...
...
@@ -149,7 +149,7 @@ public class OvsUtilsImpl implements OvsUtils {
@Override
public
void
setController
(
String
bridgeName
,
String
host
,
int
port
)
{
String
cmd
=
"
echo '"
+
passwd
+
"' | 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
);
...
...
@@ -158,7 +158,7 @@ public class OvsUtilsImpl implements OvsUtils {
@Override
public
void
delBridge
(
String
name
)
{
String
cmd
=
"
echo '"
+
passwd
+
"' | 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"
))
{
...
...
@@ -174,7 +174,7 @@ public class OvsUtilsImpl implements OvsUtils {
*/
@Override
public
boolean
addBridgePort
(
String
bridgeName
,
String
port
)
{
String
cmd
=
"
echo '"
+
passwd
+
"' | 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
))
{
...
...
@@ -186,7 +186,7 @@ public class OvsUtilsImpl implements OvsUtils {
@Override
public
boolean
delBridgePort
(
String
bridgeName
,
String
port
)
{
String
cmd
=
"
echo '"
+
passwd
+
"' | 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
))
{
...
...
@@ -278,7 +278,7 @@ public class OvsUtilsImpl implements OvsUtils {
public
boolean
setVxlan
(
String
bridgeName
,
String
remoteIp
)
{
// TODO: bug
int
id
=
atomicInteger
.
getAndIncrement
();
String
cmd
=
"
echo '"
+
passwd
+
"' | 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
);
...
...
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