本文整理汇总了Java中org.opendaylight.controller.switchmanager.SubnetConfig类的典型用法代码示例。如果您正苦于以下问题:Java SubnetConfig类的具体用法?Java SubnetConfig怎么用?Java SubnetConfig使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SubnetConfig类属于org.opendaylight.controller.switchmanager包,在下文中一共展示了SubnetConfig类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: saveSwitchConfigInternal
import org.opendaylight.controller.switchmanager.SubnetConfig; //导入依赖的package包/类
public Status saveSwitchConfigInternal() {
Status retS = null, retP = null;
ObjectWriter objWriter = new ObjectWriter();
retS = objWriter.write(new ConcurrentHashMap<String, SubnetConfig>(
subnetsConfigList), subnetFileName);
retP = objWriter.write(new ConcurrentHashMap<SpanConfig, SpanConfig>(
spanConfigList), spanFileName);
retS = objWriter.write(new ConcurrentHashMap<String, SwitchConfig>(
nodeConfigList), switchConfigFileName);
if (retS.equals(retP)) {
if (retS.isSuccess()) {
return retS;
} else {
return new Status(StatusCode.INTERNALERROR, "Save failed");
}
} else {
return new Status(StatusCode.INTERNALERROR, "Partial save failure");
}
}
示例2: testSwitchManagerAddRemoveSubnet
import org.opendaylight.controller.switchmanager.SubnetConfig; //导入依赖的package包/类
@Test
public void testSwitchManagerAddRemoveSubnet() {
SwitchManagerImpl switchmgr = new SwitchManagerImpl();
switchmgr.startUp();
ArrayList<String> portList = new ArrayList<String>();
portList.add("1/1");
portList.add("1/2");
portList.add("1/3");
SubnetConfig subnet = new SubnetConfig("subnet", "10.0.0.254/16",
portList);
// System.out.println("*" + switchmgr.addSubnet(subnet) + "*");
Status addResult = (switchmgr.addSubnet(subnet));
Assert.assertTrue(addResult.isSuccess());
Status removeResult = (switchmgr.removeSubnet(subnet.getName()));
Assert.assertTrue(removeResult.isSuccess());
SubnetConfig subnetConfigResult = switchmgr.getSubnetConfig(subnet
.getName());
Assert.assertTrue(subnetConfigResult == null);
}
示例3: addNodePorts
import org.opendaylight.controller.switchmanager.SubnetConfig; //导入依赖的package包/类
/**
*
* Add ports to a subnet
*
* @param containerName
* Name of the Container
* @param name
* Name of the SubnetConfig to be modified
* @param subnetConfigData
* the {@link SubnetConfig} structure in JSON passed as a POST
* parameter
* @return If the operation is successful or not
*/
@Path("/{containerName}/{subnetName}/add")
@POST
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@StatusCodes({
@ResponseCode(code = 202, condition = "Operation successful"),
@ResponseCode(code = 400, condition = "Invalid request"),
@ResponseCode(code = 404, condition = "The containerName or subnetName is not found"),
@ResponseCode(code = 500, condition = "Internal server error") })
public Response addNodePorts(
@PathParam("containerName") String containerName,
@PathParam("subnetName") String name,
@TypeHint(SubnetConfig.class) JAXBElement<SubnetConfig> subnetConfigData) {
SubnetConfig subnetConf = subnetConfigData.getValue();
return addOrDeletePorts(containerName, name, subnetConf, "add");
}
示例4: deleteNodePorts
import org.opendaylight.controller.switchmanager.SubnetConfig; //导入依赖的package包/类
/**
*
* Delete ports from a subnet
*
* @param containerName
* Name of the Container
* @param name
* Name of the SubnetConfig to be modified
* @param subnetConfigData
* the {@link SubnetConfig} structure in JSON passed as a POST
* parameter
* @return If the operation is successful or not
*/
@Path("/{containerName}/{subnetName}/delete")
@POST
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@StatusCodes({
@ResponseCode(code = 202, condition = "Operation successful"),
@ResponseCode(code = 400, condition = "Invalid request"),
@ResponseCode(code = 404, condition = "The containerName or subnetName is not found"),
@ResponseCode(code = 500, condition = "Internal server error") })
public Response deleteNodePorts(
@PathParam("containerName") String containerName,
@PathParam("subnetName") String name,
@TypeHint(SubnetConfig.class) JAXBElement<SubnetConfig> subnetConfigData) {
SubnetConfig subnetConf = subnetConfigData.getValue();
return addOrDeletePorts(containerName, name, subnetConf, "delete");
}
示例5: getSubnetGateways
import org.opendaylight.controller.switchmanager.SubnetConfig; //导入依赖的package包/类
@RequestMapping(value = "/subnets", method = RequestMethod.GET)
@ResponseBody
public DevicesJsonBean getSubnetGateways(HttpServletRequest request,
@RequestParam(required = false) String container) {
Gson gson = new Gson();
List<Map<String, String>> subnets = new ArrayList<Map<String, String>>();
String containerName = (container == null) ? GlobalConstants.DEFAULT
.toString() : container;
// Derive the privilege this user has on the current container
String userName = request.getUserPrincipal().getName();
Privilege privilege = DaylightWebUtil.getContainerPrivilege(
userName, containerName, this);
if (privilege != Privilege.NONE) {
ISwitchManager switchManager = (ISwitchManager) ServiceHelper
.getInstance(ISwitchManager.class, containerName, this);
if (switchManager != null) {
for (SubnetConfig conf : switchManager.getSubnetsConfigList()) {
Map<String, String> subnet = new HashMap<String, String>();
subnet.put("name", conf.getName());
subnet.put("subnet", conf.getSubnet());
subnet.put("json", gson.toJson(conf));
subnets.add(subnet);
}
}
}
DevicesJsonBean result = new DevicesJsonBean();
result.setPrivilege(privilege);
result.setColumnNames(SubnetConfig.getGuiFieldsNames());
result.setNodeData(subnets);
return result;
}
示例6: addSubnetGateways
import org.opendaylight.controller.switchmanager.SubnetConfig; //导入依赖的package包/类
@RequestMapping(value = "/subnetGateway/add", method = RequestMethod.GET)
@ResponseBody
public StatusJsonBean addSubnetGateways(
@RequestParam("gatewayName") String gatewayName,
@RequestParam("gatewayIPAddress") String gatewayIPAddress,
HttpServletRequest request,
@RequestParam(required = false) String container) {
String containerName = (container == null) ? GlobalConstants.DEFAULT
.toString() : container;
// Authorization check
String userName = request.getUserPrincipal().getName();
if (DaylightWebUtil.getContainerPrivilege(userName, containerName, this) != Privilege.WRITE) {
return unauthorizedMessage();
}
StatusJsonBean resultBean = new StatusJsonBean();
try {
ISwitchManager switchManager = (ISwitchManager) ServiceHelper
.getInstance(ISwitchManager.class, containerName, this);
SubnetConfig cfgObject = new SubnetConfig(gatewayName,
gatewayIPAddress, new ArrayList<String>());
Status result = switchManager.addSubnet(cfgObject);
if (result.isSuccess()) {
resultBean.setStatus(true);
resultBean.setMessage("Added gateway address successfully");
} else {
resultBean.setStatus(false);
resultBean.setMessage(result.getDescription());
}
} catch (Exception e) {
resultBean.setStatus(false);
resultBean.setMessage(e.getMessage());
}
return resultBean;
}
示例7: nonClusterObjectCreate
import org.opendaylight.controller.switchmanager.SubnetConfig; //导入依赖的package包/类
private void nonClusterObjectCreate() {
subnetsConfigList = new ConcurrentHashMap<String, SubnetConfig>();
spanConfigList = new ConcurrentHashMap<SpanConfig, SpanConfig>();
nodeConfigList = new ConcurrentHashMap<String, SwitchConfig>();
subnets = new ConcurrentHashMap<InetAddress, Subnet>();
configSaveEvent = new ConcurrentHashMap<Long, String>();
nodeProps = new ConcurrentHashMap<Node, Map<String, Property>>();
nodeConnectorProps = new ConcurrentHashMap<NodeConnector, Map<String, Property>>();
nodeConnectorNames = new ConcurrentHashMap<Node, Map<String, NodeConnector>>();
}
示例8: updateConfig
import org.opendaylight.controller.switchmanager.SubnetConfig; //导入依赖的package包/类
private Status updateConfig(SubnetConfig conf, boolean add) {
if (add) {
if(subnetsConfigList.putIfAbsent(conf.getName(), conf) != null) {
String msg = "Cluster conflict: Subnet with name " + conf.getName() + "already exists.";
return new Status(StatusCode.CONFLICT, msg);
}
} else {
subnetsConfigList.remove(conf.getName());
}
return new Status(StatusCode.SUCCESS);
}
示例9: semanticCheck
import org.opendaylight.controller.switchmanager.SubnetConfig; //导入依赖的package包/类
private Status semanticCheck(SubnetConfig conf) {
Subnet newSubnet = new Subnet(conf);
Set<InetAddress> IPs = subnets.keySet();
if (IPs == null) {
return new Status(StatusCode.SUCCESS);
}
for (InetAddress i : IPs) {
Subnet existingSubnet = subnets.get(i);
if ((existingSubnet != null)
&& !existingSubnet.isMutualExclusive(newSubnet)) {
return new Status(StatusCode.CONFLICT);
}
}
return new Status(StatusCode.SUCCESS);
}
示例10: removeSubnet
import org.opendaylight.controller.switchmanager.SubnetConfig; //导入依赖的package包/类
@Override
public Status removeSubnet(String name) {
SubnetConfig conf = subnetsConfigList.get(name);
if (conf == null) {
return new Status(StatusCode.SUCCESS, "Subnet not present");
}
return this.addRemoveSubnet(conf, false);
}
示例11: loadSubnetConfiguration
import org.opendaylight.controller.switchmanager.SubnetConfig; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private void loadSubnetConfiguration() {
ObjectReader objReader = new ObjectReader();
ConcurrentMap<String, SubnetConfig> confList = (ConcurrentMap<String, SubnetConfig>) objReader
.read(this, subnetFileName);
if (confList == null) {
return;
}
for (SubnetConfig conf : confList.values()) {
addSubnet(conf);
}
}
示例12: testSubnetConfigs
import org.opendaylight.controller.switchmanager.SubnetConfig; //导入依赖的package包/类
@Test
public void testSubnetConfigs() {
SubnetConfigs sc1 = new SubnetConfigs(null);
Assert.assertNull(sc1.getSubnetConfig());
ArrayList<SubnetConfig> list = new ArrayList<SubnetConfig>();
SubnetConfig s1 = new SubnetConfig();
list.add(s1);
sc1.setSubnetConfig(list);
Assert.assertTrue(sc1.getSubnetConfig().equals(list));
sc1.setSubnetConfig(null);
Assert.assertNull(sc1.getSubnetConfig());
}
示例13: retrieveCaches
import org.opendaylight.controller.switchmanager.SubnetConfig; //导入依赖的package包/类
@SuppressWarnings({ "unchecked", "deprecation" })
private void retrieveCaches() {
if (this.clusterContainerService == null) {
log.info("un-initialized clusterContainerService, can't create cache");
return;
}
subnetsConfigList = (ConcurrentMap<String, SubnetConfig>) clusterContainerService
.getCache("switchmanager.subnetsConfigList");
if (subnetsConfigList == null) {
log.error("\nFailed to get cache for subnetsConfigList");
}
spanConfigList = (ConcurrentMap<SpanConfig, SpanConfig>) clusterContainerService
.getCache("switchmanager.spanConfigList");
if (spanConfigList == null) {
log.error("\nFailed to get cache for spanConfigList");
}
nodeConfigList = (ConcurrentMap<String, SwitchConfig>) clusterContainerService
.getCache("switchmanager.nodeConfigList");
if (nodeConfigList == null) {
log.error("\nFailed to get cache for nodeConfigList");
}
subnets = (ConcurrentMap<InetAddress, Subnet>) clusterContainerService
.getCache("switchmanager.subnets");
if (subnets == null) {
log.error("\nFailed to get cache for subnets");
}
configSaveEvent = (ConcurrentMap<Long, String>) clusterContainerService
.getCache("switchmanager.configSaveEvent");
if (configSaveEvent == null) {
log.error("\nFailed to get cache for configSaveEvent");
}
nodeProps = (ConcurrentMap<Node, Map<String, Property>>) clusterContainerService
.getCache("switchmanager.nodeProps");
if (nodeProps == null) {
log.error("\nFailed to get cache for nodeProps");
}
nodeConnectorProps = (ConcurrentMap<NodeConnector, Map<String, Property>>) clusterContainerService
.getCache("switchmanager.nodeConnectorProps");
if (nodeConnectorProps == null) {
log.error("\nFailed to get cache for nodeConnectorProps");
}
nodeConnectorNames = (ConcurrentMap<Node, Map<String, NodeConnector>>) clusterContainerService
.getCache("switchmanager.nodeConnectorNames");
if (nodeConnectorNames == null) {
log.error("\nFailed to get cache for nodeConnectorNames");
}
}
示例14: getSubnetsConfigList
import org.opendaylight.controller.switchmanager.SubnetConfig; //导入依赖的package包/类
@Override
public List<SubnetConfig> getSubnetsConfigList() {
return new ArrayList<SubnetConfig>(subnetsConfigList.values());
}
示例15: getSubnetConfig
import org.opendaylight.controller.switchmanager.SubnetConfig; //导入依赖的package包/类
@Override
public SubnetConfig getSubnetConfig(String subnet) {
return subnetsConfigList.get(subnet);
}