本文整理汇总了Java中org.onosproject.incubator.net.virtual.NetworkId.networkId方法的典型用法代码示例。如果您正苦于以下问题:Java NetworkId.networkId方法的具体用法?Java NetworkId.networkId怎么用?Java NetworkId.networkId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.onosproject.incubator.net.virtual.NetworkId
的用法示例。
在下文中一共展示了NetworkId.networkId方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: decode
import org.onosproject.incubator.net.virtual.NetworkId; //导入方法依赖的package包/类
@Override
public VirtualPort decode(ObjectNode json, CodecContext context) {
if (json == null || !json.isObject()) {
return null;
}
NetworkId nId = NetworkId.networkId(Long.parseLong(extractMember(NETWORK_ID, json)));
DeviceId dId = DeviceId.deviceId(extractMember(DEVICE_ID, json));
VirtualNetworkService vnetService = context.getService(VirtualNetworkService.class);
Set<VirtualDevice> vDevs = vnetService.getVirtualDevices(nId);
VirtualDevice vDev = vDevs.stream()
.filter(virtualDevice -> virtualDevice.id().equals(dId))
.findFirst().orElse(null);
nullIsIllegal(vDev, dId.toString() + INVALID_VIRTUAL_DEVICE);
PortNumber portNum = PortNumber.portNumber(extractMember(PORT_NUM, json));
DeviceId physDId = DeviceId.deviceId(extractMember(PHYS_DEVICE_ID, json));
PortNumber physPortNum = PortNumber.portNumber(extractMember(PHYS_PORT_NUM, json));
DefaultAnnotations annotations = DefaultAnnotations.builder().build();
Device physDevice = new DefaultDevice(null, physDId,
null, null, null, null, null, null, annotations);
Port realizedBy = new DefaultPort(physDevice, physPortNum, true);
return new DefaultVirtualPort(nId, vDev, portNum, realizedBy);
}
示例2: setUp
import org.onosproject.incubator.net.virtual.NetworkId; //导入方法依赖的package包/类
@Before
public void setUp() {
VirtualNetworkService manager = new TestVirtualNetworkManager();
dispatcher.addSink(VirtualEvent.class, listenerRegistryManager);
prickleListener = new PrickleListener();
prickleManager = new PrickleManager(manager, NetworkId.networkId(1));
prickleManager.addListener(prickleListener);
gooListener = new GooListener();
gooManager = new GooManager(manager, NetworkId.networkId(1));
gooManager.addListener(gooListener);
barListener = new BarListener();
barManager = new BarManager(manager, NetworkId.networkId(2));
barManager.addListener(barListener);
}
示例3: decode
import org.onosproject.incubator.net.virtual.NetworkId; //导入方法依赖的package包/类
@Override
public VirtualPort decode(ObjectNode json, CodecContext context) {
if (json == null || !json.isObject()) {
return null;
}
NetworkId nId = NetworkId.networkId(Long.parseLong(extractMember(NETWORK_ID, json)));
DeviceId dId = DeviceId.deviceId(extractMember(DEVICE_ID, json));
VirtualNetworkService vnetService = context.getService(VirtualNetworkService.class);
Set<VirtualDevice> vDevs = vnetService.getVirtualDevices(nId);
VirtualDevice vDev = vDevs.stream()
.filter(virtualDevice -> virtualDevice.id().equals(dId))
.findFirst().orElse(null);
nullIsIllegal(vDev, dId.toString() + INVALID_VIRTUAL_DEVICE);
PortNumber portNum = PortNumber.portNumber(extractMember(PORT_NUM, json));
DeviceId physDId = DeviceId.deviceId(extractMember(PHYS_DEVICE_ID, json));
PortNumber physPortNum = PortNumber.portNumber(extractMember(PHYS_PORT_NUM, json));
ConnectPoint realizedBy = new ConnectPoint(physDId, physPortNum);
return new DefaultVirtualPort(nId, vDev, portNum, realizedBy);
}
示例4: removeVirtualNetwork
import org.onosproject.incubator.net.virtual.NetworkId; //导入方法依赖的package包/类
/**
* Removes the virtual network with the specified network identifier.
*
* @param networkId network identifier
* @return 204 NO CONTENT
*/
@DELETE
@Path("{networkId}")
public Response removeVirtualNetwork(@PathParam("networkId") long networkId) {
NetworkId nid = NetworkId.networkId(networkId);
vnetAdminService.removeVirtualNetwork(nid);
return Response.noContent().build();
}
示例5: getVirtualDevices
import org.onosproject.incubator.net.virtual.NetworkId; //导入方法依赖的package包/类
/**
* Returns all virtual network devices in a virtual network.
*
* @param networkId network identifier
* @return 200 OK with set of virtual devices, 404 not found
* @onos.rsModel VirtualDevices
*/
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("{networkId}/devices")
public Response getVirtualDevices(@PathParam("networkId") long networkId) {
NetworkId nid = NetworkId.networkId(networkId);
Set<VirtualDevice> vdevs = vnetService.getVirtualDevices(nid);
return ok(encodeArray(VirtualDevice.class, "devices", vdevs)).build();
}
示例6: removeVirtualDevice
import org.onosproject.incubator.net.virtual.NetworkId; //导入方法依赖的package包/类
/**
* Removes the virtual network device from the virtual network.
*
* @param networkId network identifier
* @param deviceId device identifier
* @return 204 NO CONTENT
*/
@DELETE
@Path("{networkId}/devices/{deviceId}")
public Response removeVirtualDevice(@PathParam("networkId") long networkId,
@PathParam("deviceId") String deviceId) {
NetworkId nid = NetworkId.networkId(networkId);
DeviceId did = DeviceId.deviceId(deviceId);
vnetAdminService.removeVirtualDevice(nid, did);
return Response.noContent().build();
}
示例7: getVirtualPorts
import org.onosproject.incubator.net.virtual.NetworkId; //导入方法依赖的package包/类
/**
* Returns all virtual network ports in a virtual device in a virtual network.
*
* @param networkId network identifier
* @param deviceId virtual device identifier
* @return 200 OK with set of virtual ports, 404 not found
* @onos.rsModel VirtualPorts
*/
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("{networkId}/devices/{deviceId}/ports")
public Response getVirtualPorts(@PathParam("networkId") long networkId,
@PathParam("deviceId") String deviceId) {
NetworkId nid = NetworkId.networkId(networkId);
Iterable<VirtualPort> vports = vnetService.getVirtualPorts(nid, DeviceId.deviceId(deviceId));
return ok(encodeArray(VirtualPort.class, "ports", vports)).build();
}
示例8: removeVirtualPort
import org.onosproject.incubator.net.virtual.NetworkId; //导入方法依赖的package包/类
/**
* Removes the virtual network port from the virtual device in a virtual network.
*
* @param networkId network identifier
* @param deviceId virtual device identifier
* @param portNum virtual port number
* @return 204 NO CONTENT
*/
@DELETE
@Path("{networkId}/devices/{deviceId}/ports/{portNum}")
public Response removeVirtualPort(@PathParam("networkId") long networkId,
@PathParam("deviceId") String deviceId,
@PathParam("portNum") long portNum) {
NetworkId nid = NetworkId.networkId(networkId);
vnetAdminService.removeVirtualPort(nid, DeviceId.deviceId(deviceId),
PortNumber.portNumber(portNum));
return Response.noContent().build();
}
示例9: getVirtualLinks
import org.onosproject.incubator.net.virtual.NetworkId; //导入方法依赖的package包/类
/**
* Returns all virtual network links in a virtual network.
*
* @param networkId network identifier
* @return 200 OK with set of virtual network links
* @onos.rsModel VirtualLinks
*/
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("{networkId}/links")
public Response getVirtualLinks(@PathParam("networkId") long networkId) {
NetworkId nid = NetworkId.networkId(networkId);
Set<VirtualLink> vlinks = vnetService.getVirtualLinks(nid);
return ok(encodeArray(VirtualLink.class, "links", vlinks)).build();
}
示例10: decode
import org.onosproject.incubator.net.virtual.NetworkId; //导入方法依赖的package包/类
@Override
public VirtualLink decode(ObjectNode json, CodecContext context) {
if (json == null || !json.isObject()) {
return null;
}
JsonCodec<Link> codec = context.codec(Link.class);
Link link = codec.decode(json, context);
NetworkId nId = NetworkId.networkId(Long.parseLong(extractMember(NETWORK_ID, json)));
return DefaultVirtualLink.builder()
.networkId(nId)
.src(link.src())
.dst(link.dst())
.build();
}
示例11: decode
import org.onosproject.incubator.net.virtual.NetworkId; //导入方法依赖的package包/类
@Override
public VirtualDevice decode(ObjectNode json, CodecContext context) {
if (json == null || !json.isObject()) {
return null;
}
DeviceId dId = DeviceId.deviceId(extractMember(ID, json));
NetworkId nId = NetworkId.networkId(Long.parseLong(extractMember(NETWORK_ID, json)));
return new DefaultVirtualDevice(nId, dId);
}
示例12: decode
import org.onosproject.incubator.net.virtual.NetworkId; //导入方法依赖的package包/类
@Override
public VirtualNetwork decode(ObjectNode json, CodecContext context) {
if (json == null || !json.isObject()) {
return null;
}
NetworkId nId = NetworkId.networkId(Long.parseLong(extractMember(NETWORK_ID, json)));
TenantId tId = TenantId.tenantId(extractMember(TENANT_ID, json));
return new DefaultVirtualNetwork(nId, tId);
}
示例13: createVirtualPort
import org.onosproject.incubator.net.virtual.NetworkId; //导入方法依赖的package包/类
/**
* Creates a virtual network port in a virtual device in a virtual network.
*
* @param networkId network identifier
* @param virtDeviceId virtual device identifier
* @param stream virtual port JSON stream
* @return status of the request - CREATED if the JSON is correct,
* BAD_REQUEST if the JSON is invalid
* @onos.rsModel VirtualPort
*/
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Path("{networkId}/devices/{deviceId}/ports")
public Response createVirtualPort(@PathParam("networkId") long networkId,
@PathParam("deviceId") String virtDeviceId,
InputStream stream) {
try {
ObjectNode jsonTree = (ObjectNode) mapper().readTree(stream);
// final VirtualPort vportReq = codec(VirtualPort.class).decode(jsonTree, this);
JsonNode specifiedNetworkId = jsonTree.get("networkId");
JsonNode specifiedDeviceId = jsonTree.get("deviceId");
if (specifiedNetworkId == null || specifiedNetworkId.asLong() != (networkId)) {
throw new IllegalArgumentException(INVALID_FIELD + "networkId");
}
if (specifiedDeviceId == null || !specifiedDeviceId.asText().equals(virtDeviceId)) {
throw new IllegalArgumentException(INVALID_FIELD + "deviceId");
}
JsonNode specifiedPortNum = jsonTree.get("portNum");
JsonNode specifiedPhysDeviceId = jsonTree.get("physDeviceId");
JsonNode specifiedPhysPortNum = jsonTree.get("physPortNum");
final NetworkId nid = NetworkId.networkId(networkId);
DeviceId vdevId = DeviceId.deviceId(virtDeviceId);
ConnectPoint realizedBy = new ConnectPoint(DeviceId.deviceId(specifiedPhysDeviceId.asText()),
PortNumber.portNumber(specifiedPhysPortNum.asText()));
VirtualPort vport = vnetAdminService.createVirtualPort(nid, vdevId,
PortNumber.portNumber(specifiedPortNum.asText()), realizedBy);
UriBuilder locationBuilder = uriInfo.getBaseUriBuilder()
.path("vnets").path(specifiedNetworkId.asText())
.path("devices").path(specifiedDeviceId.asText())
.path("ports").path(vport.number().toString());
return Response
.created(locationBuilder.build())
.build();
} catch (IOException e) {
throw new IllegalArgumentException(e);
}
}
示例14: getVirtualHosts
import org.onosproject.incubator.net.virtual.NetworkId; //导入方法依赖的package包/类
/**
* Returns all virtual network hosts in a virtual network.
*
* @param networkId network identifier
* @return 200 OK with set of virtual network hosts
* @onos.rsModel VirtualHosts
*/
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("{networkId}/hosts")
public Response getVirtualHosts(@PathParam("networkId") long networkId) {
NetworkId nid = NetworkId.networkId(networkId);
Set<VirtualHost> vhosts = vnetService.getVirtualHosts(nid);
return ok(encodeArray(VirtualHost.class, "hosts", vhosts)).build();
}
示例15: extractNetworkIdFromTopic
import org.onosproject.incubator.net.virtual.NetworkId; //导入方法依赖的package包/类
/**
* Returns the virtual network identifier extracted from the topic.
*
* @param topic topic to extract virtual network identifier
* @return an extracted virtual network identifier
* @throws IllegalArgumentException the topic not match with the pattern
* used for virtual network mastership store
*/
private NetworkId extractNetworkIdFromTopic(String topic) {
Matcher m = DEVICE_MASTERSHIP_TOPIC_PATTERN.matcher(topic);
if (m.matches()) {
return NetworkId.networkId(Long.getLong(m.group(1)));
} else {
throw new IllegalArgumentException("Invalid virtual mastership topic: "
+ topic);
}
}