Commit af04ed93 authored by Elf's avatar Elf

删除了ovs中的sudo命令

parent 16b2a979
...@@ -19,8 +19,13 @@ ...@@ -19,8 +19,13 @@
* 刘建瓯 * 刘建瓯
* 张夏童 * 张夏童
## 更新说明 ## 第一次更新说明
1. 使用域名替换配置中的IP,防止多人多次修改配置类并进行提交,避免合并分支时出现冲突的问题。 1. 使用域名替换配置中的IP,防止多人多次修改配置类并进行提交,避免合并分支时出现冲突的问题。
如果有需要在自己的电脑上进行部署,需要通过修改本机host的方式来修改对应节点的IP。 如果有需要在自己的电脑上进行部署,需要通过修改本机host的方式来修改对应节点的IP。
2. 测试代码 2. 测试代码
\ No newline at end of file
## 第二次更新说明(Elf:2020-8-12)
1. 平台docker化,删去ovs中的sudo命令,具体见cnf/cnf-utils/OvsUtilsImpl
2. 有关虚拟网卡对之间未作修改,原因是我还没想好如何在docker中运行
\ No newline at end of file
...@@ -33,7 +33,7 @@ public class OvsUtilsImpl implements OvsUtils { ...@@ -33,7 +33,7 @@ public class OvsUtilsImpl implements OvsUtils {
@Override @Override
public boolean isInstall() { 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")) { if(s.contains("Error")) {
return false; return false;
} else { } else {
...@@ -43,7 +43,7 @@ public class OvsUtilsImpl implements OvsUtils { ...@@ -43,7 +43,7 @@ public class OvsUtilsImpl implements OvsUtils {
@Override @Override
public Ovs showDetails() { 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); Ovs ovs = parseOvsString(res);
return ovs; return ovs;
...@@ -131,7 +131,7 @@ public class OvsUtilsImpl implements OvsUtils { ...@@ -131,7 +131,7 @@ public class OvsUtilsImpl implements OvsUtils {
@Override @Override
public void addBridge(String name) { 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); 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!");
...@@ -140,7 +140,7 @@ public class OvsUtilsImpl implements OvsUtils { ...@@ -140,7 +140,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 '" + passwd + "' | 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);
...@@ -149,7 +149,7 @@ public class OvsUtilsImpl implements OvsUtils { ...@@ -149,7 +149,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 '" + 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); String res = linuxCtlUtils.runCmd(cmd);
if(res.contains("Error")) { if(res.contains("Error")) {
throw new RuntimeException(res); throw new RuntimeException(res);
...@@ -158,7 +158,7 @@ public class OvsUtilsImpl implements OvsUtils { ...@@ -158,7 +158,7 @@ public class OvsUtilsImpl implements OvsUtils {
@Override @Override
public void delBridge(String name) { 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); LOG.info("删除网桥[{}]", name);
String res = linuxCtlUtils.runCmd(cmd); String res = linuxCtlUtils.runCmd(cmd);
if(res.contains("Error")) { if(res.contains("Error")) {
...@@ -174,7 +174,7 @@ public class OvsUtilsImpl implements OvsUtils { ...@@ -174,7 +174,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 '" + passwd + "' | 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)) {
...@@ -186,7 +186,7 @@ public class OvsUtilsImpl implements OvsUtils { ...@@ -186,7 +186,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 '" + passwd + "' | 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)) {
...@@ -278,7 +278,7 @@ public class OvsUtilsImpl implements OvsUtils { ...@@ -278,7 +278,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 '" + 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; + " 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);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment