Commit bb20c16f authored by Elf's avatar Elf

中期答辩

parent 16b2a979
......@@ -72,6 +72,12 @@
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
</dependency>
<dependency>
<groupId>top.ninwoo</groupId>
<artifactId>cnf-weixingsim</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>
......
package top.ninwoo.cloudcenter.controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import top.ninwoo.cloudcenter.service.impl.MidCheckImpl;
import javax.annotation.Resource;
/**
* 中期检查
*/
@RestController
@RequestMapping("/midCheck")
public class MidCheck {
@Resource
private MidCheckImpl mc;
//步骤可分割
@GetMapping(value = "/cpc")
public String cpc() {
String str = mc.cpc();
return str;
}
//删除步骤可分割
@GetMapping(value = "/rmcpc")
public String rmcpc() {
return mc.rmcpc();
}
}
package top.ninwoo.cloudcenter.service.impl;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
import top.ninwoo.common.entity.*;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service
public class MidCheckImpl {
@Resource
private RestTemplate restTemplate;
private long cpcClusterID = 11111L;
private long dbcClusterID = 11113L;
private String EdgeNodeId = "192.168.190.135:18088";
private String CloudID = "192.168.190.135:9091";
private final static String SEND_CLUSTER_CONFIG_TO_EDGE_NODE
= "/cluster/sendClusterConfigToEdgeNode";
private final static String REMOVE_CLUSTER_FROM_EDGE_NODE
= "/cluster/removeClusterFromEdgeNode?clusterId=";
public String cpc(){
ArrayList<SeparatedClusterConfig> clusterConfigs = new ArrayList<>();
SeparatedClusterConfig separatedClusterConfig = new SeparatedClusterConfig();
List<ContainerDescription> cds = new ArrayList<>();
// TODO: 这个ID应该是从借接口获取的
separatedClusterConfig.setEdgeNodeId(EdgeNodeId);
ClusterConfig clusterConfig = new ClusterConfig();
clusterConfig.setId(cpcClusterID);
clusterConfig.setOwner("joliu");
//todo 这个需要接口传入
String[] sateName = new String[]{"sate1","sate2","sate3","sate4","sate5","sate6","sate7","sate8","sate9","sate10",
"sate11","sate12","sate13","sate14","sate15","sate16","sate17","sate18","sate19","sate20",
"sate21","sate22","sate23","sate24","sate25","sate26","sate27","sate28","sate29","sate30","br:ovs"};
//创建容器
ContainerDescription containerDescription0 = new ContainerDescription();
containerDescription0.setMode("normal");
containerDescription0.setReplicas(1);
DockerContainer container0 = new DockerContainer();
container0.setName(sateName[0]);
container0.setCommand("sh");
container0.setImage("joliu/networktest:schedule");
containerDescription0.setDockerContainer(container0);
cds.add(containerDescription0);
for (int k = 1; k < sateName.length - 1; k++) {
ContainerDescription containerDescription = new ContainerDescription();
containerDescription.setMode("normal");
containerDescription.setReplicas(1);
DockerContainer container = new DockerContainer();
container.setName(sateName[k]);
container.setCommand("sh");
container.setImage("joliu/networktest:server");
containerDescription.setDockerContainer(container);
cds.add(containerDescription);
}
clusterConfig.setDockers(cds);
NetworkTopology topo = new NetworkTopology();
topo.setAppNames(sateName);
// 这个参数好像没啥用
topo.setTopologyId(11);
//创建ovs和docker之间相连
int[][] toponet = new int[31][31];
for (int i = 0; i < toponet[0].length; i++) {
toponet[30][i] = 1;
}
topo.setTopology(toponet);
clusterConfig.setTopology(topo);
separatedClusterConfig.setClusterConfig(clusterConfig);
clusterConfigs.add(separatedClusterConfig);
//下发
Map<String, Object> param = new HashMap<>();
param.put("configs", clusterConfigs.toArray());
restTemplate.postForObject("http://" + CloudID + SEND_CLUSTER_CONFIG_TO_EDGE_NODE, clusterConfigs, List.class);
return "下发拓扑成功";
}
public String rmcpc() {
return restTemplate.getForObject("http://" + CloudID +
REMOVE_CLUSTER_FROM_EDGE_NODE + cpcClusterID, String.class);
}
}
{
"properties": [
{
"name": "main.allow-bean-definition-overriding",
"type": "java.lang.String",
"description": "Description for main.allow-bean-definition-overriding."
}
] }
\ No newline at end of file
......@@ -9,3 +9,7 @@ bs:
name: my-bs-cloud-center
ipservice:
url: ipservice.cnf.org:23333
spring:
main:
allow-bean-definition-overriding: true
\ No newline at end of file
......@@ -24,7 +24,7 @@ bs:
name: my-bs-cloud-center
edgenode:
name: random
ip-prefix: 192.168.31
ip-prefix: 192
ipservice:
ip: ipservice.cnf.org:23333
sdn-controller:
......
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