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
945046d1
Commit
945046d1
authored
Mar 18, 2020
by
wutu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix-bug
parent
7b3043a1
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
122 additions
and
13 deletions
+122
-13
bishe-cloud-center/src/main/resources/application.yml
bishe-cloud-center/src/main/resources/application.yml
+3
-3
bishe-edge-center/src/main/java/top/ninwoo/edgecenter/service/impl/TopologyServiceImpl.java
...p/ninwoo/edgecenter/service/impl/TopologyServiceImpl.java
+9
-0
bishe-edge-center/src/main/resources/application.yaml
bishe-edge-center/src/main/resources/application.yaml
+5
-2
bishe-test/src/main/resources/application.properties
bishe-test/src/main/resources/application.properties
+1
-1
bishe-test/src/test/java/top/ninwoo/BisheMultiNodeTests.java
bishe-test/src/test/java/top/ninwoo/BisheMultiNodeTests.java
+90
-4
bishe-utils/src/main/java/top/ninwoo/utils/service/OVSService.java
...ls/src/main/java/top/ninwoo/utils/service/OVSService.java
+2
-0
bishe-utils/src/main/java/top/ninwoo/utils/service/impl/OVSServiceImpl.java
...in/java/top/ninwoo/utils/service/impl/OVSServiceImpl.java
+5
-0
bishe-utils/src/main/java/top/ninwoo/utils/util/impl/OvsUtilsImpl.java
...rc/main/java/top/ninwoo/utils/util/impl/OvsUtilsImpl.java
+7
-3
No files found.
bishe-cloud-center/src/main/resources/application.yml
View file @
945046d1
server
:
server
:
port
:
909
0
port
:
909
1
zookeeper
:
zookeeper
:
url
:
192.168.
1.5
:2181
url
:
192.168.
0.108
:2181
bs
:
bs
:
cloudcenter
:
cloudcenter
:
name
:
my-bs-cloud-center
name
:
my-bs-cloud-center
ipservice
:
ipservice
:
url
:
192.168.1.5:23333
url
:
192.168.0.108:23333
\ No newline at end of file
\ No newline at end of file
bishe-edge-center/src/main/java/top/ninwoo/edgecenter/service/impl/TopologyServiceImpl.java
View file @
945046d1
...
@@ -3,6 +3,7 @@ package top.ninwoo.edgecenter.service.impl;
...
@@ -3,6 +3,7 @@ package top.ninwoo.edgecenter.service.impl;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
top.ninwoo.common.entity.ClusterConfig
;
import
top.ninwoo.common.entity.ClusterConfig
;
import
top.ninwoo.common.entity.NetworkTopology
;
import
top.ninwoo.common.entity.NetworkTopology
;
...
@@ -28,6 +29,11 @@ public class TopologyServiceImpl implements TopologyService {
...
@@ -28,6 +29,11 @@ public class TopologyServiceImpl implements TopologyService {
// 用于存储集群的拓扑
// 用于存储集群的拓扑
private
ConcurrentHashMap
<
Long
,
NetworkTopology
>
clustersTopo
=
new
ConcurrentHashMap
<>();
private
ConcurrentHashMap
<
Long
,
NetworkTopology
>
clustersTopo
=
new
ConcurrentHashMap
<>();
@Value
(
"${bs.sdn-controller.host}"
)
private
String
host
;
@Value
(
"${bs.sdn-controller.port}"
)
private
int
port
;
@Autowired
@Autowired
OVSService
ovsService
;
OVSService
ovsService
;
...
@@ -89,6 +95,8 @@ public class TopologyServiceImpl implements TopologyService {
...
@@ -89,6 +95,8 @@ public class TopologyServiceImpl implements TopologyService {
if
(!
appName1
.
contains
(
"remote"
)
&&
!
ovsService
.
isBridge
(
appName1
.
substring
(
3
)))
{
if
(!
appName1
.
contains
(
"remote"
)
&&
!
ovsService
.
isBridge
(
appName1
.
substring
(
3
)))
{
LOG
.
info
(
"创建虚拟交换机:{}"
,
appName1
.
substring
(
3
));
LOG
.
info
(
"创建虚拟交换机:{}"
,
appName1
.
substring
(
3
));
ovsService
.
addBridge
(
appName1
.
substring
(
3
));
ovsService
.
addBridge
(
appName1
.
substring
(
3
));
// todo 设置controller
ovsService
.
setController
(
appName1
.
substring
(
3
),
host
,
port
);
}
}
//LOG.info("Ovs Bridge[" + appName1 + "] is normal!");
//LOG.info("Ovs Bridge[" + appName1 + "] is normal!");
}
}
...
@@ -99,6 +107,7 @@ public class TopologyServiceImpl implements TopologyService {
...
@@ -99,6 +107,7 @@ public class TopologyServiceImpl implements TopologyService {
if
(!
appName2
.
contains
(
"remote"
)
&&
!
ovsService
.
isBridge
(
appName2
.
substring
(
3
)))
{
if
(!
appName2
.
contains
(
"remote"
)
&&
!
ovsService
.
isBridge
(
appName2
.
substring
(
3
)))
{
LOG
.
info
(
"创建虚拟交换机:{}"
,
appName2
.
substring
(
3
));
LOG
.
info
(
"创建虚拟交换机:{}"
,
appName2
.
substring
(
3
));
ovsService
.
addBridge
(
appName2
.
substring
(
3
));
ovsService
.
addBridge
(
appName2
.
substring
(
3
));
ovsService
.
setController
(
appName2
.
substring
(
3
),
host
,
port
);
}
}
}
}
...
...
bishe-edge-center/src/main/resources/application.yaml
View file @
945046d1
...
@@ -21,6 +21,9 @@ bs:
...
@@ -21,6 +21,9 @@ bs:
name
:
random
name
:
random
ip-prefix
:
192
ip-prefix
:
192
ipservice
:
ipservice
:
ip
:
192.168.1.5:23333
ip
:
192.168.0.108:23333
sdn-controller
:
host
:
192.168.61.131
port
:
6653
zookeeper
:
zookeeper
:
url
:
192.168.1.5:2181
url
:
192.168.0.108:2181
\ No newline at end of file
bishe-test/src/main/resources/application.properties
View file @
945046d1
bishe.app.app-name
=
joliu
bishe.app.app-name
=
joliu
bishe.app.cloud-url
=
192.168.31.154:9090
bishe.app.cloud-url
=
127.0.0.1:9091
\ No newline at end of file
\ No newline at end of file
bishe-test/src/test/java/top/ninwoo/BisheMultiNodeTests.java
View file @
945046d1
...
@@ -25,12 +25,98 @@ public class BisheMultiNodeTests {
...
@@ -25,12 +25,98 @@ public class BisheMultiNodeTests {
@Resource
@Resource
private
NetworkService
networkService
;
private
NetworkService
networkService
;
@Test
public
void
testNetworkChange
()
{
ArrayList
<
SeparatedClusterConfig
>
clusterConfigs
=
new
ArrayList
<>();
SeparatedClusterConfig
separatedClusterConfig
=
new
SeparatedClusterConfig
();
separatedClusterConfig
.
setEdgeNodeId
(
"192.168.61.130:8081"
);
ClusterConfig
clusterConfig
=
new
ClusterConfig
();
clusterConfig
.
setId
(
11111
l
);
clusterConfig
.
setOwner
(
"joliu"
);
ContainerDescription
containerDescription
=
new
ContainerDescription
();
containerDescription
.
setMode
(
"normal"
);
containerDescription
.
setReplicas
(
1
);
DockerContainer
container
=
new
DockerContainer
();
container
.
setName
(
"APP1"
);
container
.
setCommand
(
"sh"
);
container
.
setImage
(
"joliu/networktest"
);
containerDescription
.
setDockerContainer
(
container
);
List
<
ContainerDescription
>
cds
=
new
ArrayList
<>();
cds
.
add
(
containerDescription
);
clusterConfig
.
setDockers
(
cds
);
NetworkTopology
topo
=
new
NetworkTopology
();
topo
.
setAppNames
(
new
String
[]{
"APP1"
,
"br:ovs1"
,
"br:ovs2"
,
"br:remote:ovs3:192.168.61.131"
});
// 这个参数好像没啥用
topo
.
setTopologyId
(
11
);
topo
.
setTopology
(
new
int
[][]{
{
0
,
0
,
0
,
0
},
{
1
,
0
,
0
,
0
},
{
0
,
1
,
0
,
0
},
{
0
,
0
,
1
,
0
}});
clusterConfig
.
setTopology
(
topo
);
separatedClusterConfig
.
setClusterConfig
(
clusterConfig
);
clusterConfigs
.
add
(
separatedClusterConfig
);
// 第二个节点
SeparatedClusterConfig
separatedClusterConfig1
=
new
SeparatedClusterConfig
();
// TODO: 这个ID应该是从借口获取的
separatedClusterConfig1
.
setEdgeNodeId
(
"192.168.61.131:8081"
);
ClusterConfig
clusterConfig1
=
new
ClusterConfig
();
clusterConfig1
.
setId
(
11111
l
);
clusterConfig1
.
setOwner
(
"joliu"
);
ContainerDescription
containerDescription11
=
new
ContainerDescription
();
containerDescription11
.
setMode
(
"normal"
);
containerDescription11
.
setReplicas
(
1
);
DockerContainer
container11
=
new
DockerContainer
();
container11
.
setName
(
"APP3"
);
container11
.
setCommand
(
"sh"
);
container11
.
setImage
(
"joliu/networktest"
);
containerDescription11
.
setDockerContainer
(
container11
);
List
<
ContainerDescription
>
cds1
=
new
ArrayList
<>();
cds1
.
add
(
containerDescription11
);
ContainerDescription
containerDescription12
=
new
ContainerDescription
();
containerDescription12
.
setMode
(
"normal"
);
containerDescription12
.
setReplicas
(
1
);
DockerContainer
container12
=
new
DockerContainer
();
container12
.
setName
(
"APP4"
);
container12
.
setCommand
(
"sh"
);
container12
.
setImage
(
"joliu/networktest"
);
containerDescription12
.
setDockerContainer
(
container12
);
cds1
.
add
(
containerDescription12
);
clusterConfig1
.
setDockers
(
cds1
);
NetworkTopology
topo1
=
new
NetworkTopology
();
topo1
.
setAppNames
(
new
String
[]{
"APP2"
,
"br:ovs3"
,
"br:ovs4"
,
"br:ovs5"
,
"br:ovs6"
,
"br:ovs7"
,
"br:ovs8"
,
"br:remote:ovs2:192.168.61.130"
});
// 这个参数好像没啥用
topo1
.
setTopologyId
(
11
);
topo1
.
setTopology
(
new
int
[][]{{
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
}
,{
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
}
,{
0
,
1
,
0
,
0
,
0
,
0
,
0
,
0
}
,{
0
,
0
,
1
,
0
,
0
,
0
,
0
,
0
}
,{
0
,
0
,
1
,
1
,
0
,
0
,
0
,
0
}
,{
0
,
0
,
0
,
0
,
1
,
0
,
0
,
0
}
,{
1
,
0
,
0
,
0
,
0
,
1
,
0
,
0
}
,{
0
,
1
,
0
,
0
,
0
,
0
,
0
,
0
}});
clusterConfig1
.
setTopology
(
topo1
);
separatedClusterConfig1
.
setClusterConfig
(
clusterConfig1
);
clusterConfigs
.
add
(
separatedClusterConfig1
);
clusterService
.
sendClusterConfigToEdgeNode
(
clusterConfigs
);
}
@Test
@Test
public
void
testSendSeparateConfig
()
{
public
void
testSendSeparateConfig
()
{
ArrayList
<
SeparatedClusterConfig
>
clusterConfigs
=
new
ArrayList
<>();
ArrayList
<
SeparatedClusterConfig
>
clusterConfigs
=
new
ArrayList
<>();
SeparatedClusterConfig
separatedClusterConfig
=
new
SeparatedClusterConfig
();
SeparatedClusterConfig
separatedClusterConfig
=
new
SeparatedClusterConfig
();
// TODO: 这个ID应该是从借口获取的
// TODO: 这个ID应该是从借口获取的
separatedClusterConfig
.
setEdgeNodeId
(
"192.168.
31.16
:8081"
);
separatedClusterConfig
.
setEdgeNodeId
(
"192.168.
61.130
:8081"
);
ClusterConfig
clusterConfig
=
new
ClusterConfig
();
ClusterConfig
clusterConfig
=
new
ClusterConfig
();
clusterConfig
.
setId
(
11111
l
);
clusterConfig
.
setId
(
11111
l
);
clusterConfig
.
setOwner
(
"joliu"
);
clusterConfig
.
setOwner
(
"joliu"
);
...
@@ -59,7 +145,7 @@ public class BisheMultiNodeTests {
...
@@ -59,7 +145,7 @@ public class BisheMultiNodeTests {
clusterConfig
.
setDockers
(
cds
);
clusterConfig
.
setDockers
(
cds
);
NetworkTopology
topo
=
new
NetworkTopology
();
NetworkTopology
topo
=
new
NetworkTopology
();
topo
.
setAppNames
(
new
String
[]{
"APP1"
,
"APP2"
,
"br:ovs1"
,
"br:remote:ovs2:192.168.
31.220
"
});
topo
.
setAppNames
(
new
String
[]{
"APP1"
,
"APP2"
,
"br:ovs1"
,
"br:remote:ovs2:192.168.
61.131
"
});
// 这个参数好像没啥用
// 这个参数好像没啥用
topo
.
setTopologyId
(
11
);
topo
.
setTopologyId
(
11
);
topo
.
setTopology
(
new
int
[][]{{
0
,
0
,
0
,
0
},{
0
,
0
,
0
,
0
},{
1
,
1
,
0
,
0
},{
0
,
0
,
1
,
0
}});
topo
.
setTopology
(
new
int
[][]{{
0
,
0
,
0
,
0
},{
0
,
0
,
0
,
0
},{
1
,
1
,
0
,
0
},{
0
,
0
,
1
,
0
}});
...
@@ -70,7 +156,7 @@ public class BisheMultiNodeTests {
...
@@ -70,7 +156,7 @@ public class BisheMultiNodeTests {
// 构建第二个节点
// 构建第二个节点
SeparatedClusterConfig
separatedClusterConfig1
=
new
SeparatedClusterConfig
();
SeparatedClusterConfig
separatedClusterConfig1
=
new
SeparatedClusterConfig
();
// TODO: 这个ID应该是从借口获取的
// TODO: 这个ID应该是从借口获取的
separatedClusterConfig1
.
setEdgeNodeId
(
"192.168.
31.220
:8081"
);
separatedClusterConfig1
.
setEdgeNodeId
(
"192.168.
61.131
:8081"
);
ClusterConfig
clusterConfig1
=
new
ClusterConfig
();
ClusterConfig
clusterConfig1
=
new
ClusterConfig
();
clusterConfig1
.
setId
(
11111
l
);
clusterConfig1
.
setId
(
11111
l
);
clusterConfig1
.
setOwner
(
"joliu"
);
clusterConfig1
.
setOwner
(
"joliu"
);
...
@@ -99,7 +185,7 @@ public class BisheMultiNodeTests {
...
@@ -99,7 +185,7 @@ public class BisheMultiNodeTests {
clusterConfig1
.
setDockers
(
cds1
);
clusterConfig1
.
setDockers
(
cds1
);
NetworkTopology
topo1
=
new
NetworkTopology
();
NetworkTopology
topo1
=
new
NetworkTopology
();
topo1
.
setAppNames
(
new
String
[]{
"APP3"
,
"APP4"
,
"br:ovs2"
,
"br:remote:ovs1:192.168.
31.16
"
});
topo1
.
setAppNames
(
new
String
[]{
"APP3"
,
"APP4"
,
"br:ovs2"
,
"br:remote:ovs1:192.168.
61.130
"
});
// 这个参数好像没啥用
// 这个参数好像没啥用
topo1
.
setTopologyId
(
11
);
topo1
.
setTopologyId
(
11
);
topo1
.
setTopology
(
new
int
[][]{{
0
,
0
,
0
,
0
},{
0
,
0
,
0
,
0
},{
1
,
1
,
0
,
0
},{
0
,
0
,
1
,
0
}});
topo1
.
setTopology
(
new
int
[][]{{
0
,
0
,
0
,
0
},{
0
,
0
,
0
,
0
},{
1
,
1
,
0
,
0
},{
0
,
0
,
1
,
0
}});
...
...
bishe-utils/src/main/java/top/ninwoo/utils/service/OVSService.java
View file @
945046d1
...
@@ -23,4 +23,6 @@ public interface OVSService {
...
@@ -23,4 +23,6 @@ public interface OVSService {
boolean
delVxlan
(
String
bridgeName
);
boolean
delVxlan
(
String
bridgeName
);
boolean
delBridgePort
(
String
bridgeName
,
String
portName
);
boolean
delBridgePort
(
String
bridgeName
,
String
portName
);
void
setController
(
String
bridgeName
,
String
host
,
int
port
);
}
}
bishe-utils/src/main/java/top/ninwoo/utils/service/impl/OVSServiceImpl.java
View file @
945046d1
...
@@ -152,6 +152,11 @@ public class OVSServiceImpl implements OVSService, InitializingBean {
...
@@ -152,6 +152,11 @@ public class OVSServiceImpl implements OVSService, InitializingBean {
}
}
}
}
@Override
public
void
setController
(
String
bridgeName
,
String
host
,
int
port
)
{
ovsUtils
.
setController
(
bridgeName
,
host
,
port
);
}
/**
/**
* 连接两个虚拟交换机
* 连接两个虚拟交换机
* @param br1
* @param br1
...
...
bishe-utils/src/main/java/top/ninwoo/utils/util/impl/OvsUtilsImpl.java
View file @
945046d1
...
@@ -12,6 +12,8 @@ import top.ninwoo.utils.util.Utils;
...
@@ -12,6 +12,8 @@ import top.ninwoo.utils.util.Utils;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
import
java.util.UUID
;
import
java.util.concurrent.atomic.AtomicInteger
;
/**
/**
* @Author joliu
* @Author joliu
...
@@ -21,7 +23,7 @@ import java.util.List;
...
@@ -21,7 +23,7 @@ import java.util.List;
@Utils
@Utils
public
class
OvsUtilsImpl
implements
OvsUtils
{
public
class
OvsUtilsImpl
implements
OvsUtils
{
private
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
OvsUtilsImpl
.
class
);
private
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
OvsUtilsImpl
.
class
);
private
final
AtomicInteger
atomicInteger
=
new
AtomicInteger
(
0
);
@Autowired
@Autowired
LinuxCtlUtils
linuxCtlUtils
;
LinuxCtlUtils
linuxCtlUtils
;
...
@@ -272,9 +274,11 @@ public class OvsUtilsImpl implements OvsUtils {
...
@@ -272,9 +274,11 @@ public class OvsUtilsImpl implements OvsUtils {
@Override
@Override
public
boolean
setVxlan
(
String
bridgeName
,
String
remoteIp
)
{
public
boolean
setVxlan
(
String
bridgeName
,
String
remoteIp
)
{
// TODO: bug
// TODO: bug
int
id
=
atomicInteger
.
getAndIncrement
();
String
cmd
=
"echo 'Vudo3423' | sudo -S ovs-vsctl add-port "
+
bridgeName
String
cmd
=
"echo 'Vudo3423' | sudo -S ovs-vsctl add-port "
+
bridgeName
+
" vxlan0 -- set interface vxlan0 type=vxlan options:remote_ip="
+
remoteIp
;
+
" vxlan"
+
id
+
" -- set interface vxlan"
+
id
+
" type=vxlan options:remote_ip="
+
remoteIp
;
LOG
.
info
(
"设置VXLAN[bridgeName:{},remoteIP:{}]"
,
bridgeName
,
remoteIp
);
System
.
out
.
println
(
cmd
);
LOG
.
info
(
"设置VXLAN[bridgeName:{},remoteIP:{},{}]"
,
bridgeName
,
remoteIp
,
cmd
);
String
res
=
linuxCtlUtils
.
runCmd
(
cmd
);
String
res
=
linuxCtlUtils
.
runCmd
(
cmd
);
if
(!
""
.
equals
(
res
))
{
if
(!
""
.
equals
(
res
))
{
LOG
.
warn
(
"setVxlan:"
+
"["
+
bridgeName
+
"]:"
+
res
);
LOG
.
warn
(
"setVxlan:"
+
"["
+
bridgeName
+
"]:"
+
res
);
...
...
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