Commit af04ed93 authored by Elf's avatar Elf

删除了ovs中的sudo命令

parent 16b2a979
......@@ -19,8 +19,13 @@
* 刘建瓯
* 张夏童
## 更新说明
## 第一次更新说明
1. 使用域名替换配置中的IP,防止多人多次修改配置类并进行提交,避免合并分支时出现冲突的问题。
如果有需要在自己的电脑上进行部署,需要通过修改本机host的方式来修改对应节点的IP。
2. 测试代码
\ No newline at end of file
2. 测试代码
## 第二次更新说明(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 {
@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);
......
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