本文整理汇总了Java中org.onlab.packet.ChassisId类的典型用法代码示例。如果您正苦于以下问题:Java ChassisId类的具体用法?Java ChassisId怎么用?Java ChassisId使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ChassisId类属于org.onlab.packet包,在下文中一共展示了ChassisId类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: routerAdded
import org.onlab.packet.ChassisId; //导入依赖的package包/类
@Override
public void routerAdded(OspfRouter ospfRouter) {
String routerId = ospfRouter.routerIp().toString();
log.info("Added device {}", routerId);
DeviceId deviceId = DeviceId.deviceId(OspfRouterId.uri(ospfRouter.routerIp()));
Device.Type deviceType = Device.Type.ROUTER;
//If our routerType is Dr or Bdr type is PSEUDO
if (ospfRouter.isDr()) {
deviceType = Device.Type.ROUTER;
} else {
deviceType = Device.Type.VIRTUAL;
}
//deviceId = DeviceId.deviceId(routerDetails);
ChassisId cId = new ChassisId();
DefaultAnnotations.Builder newBuilder = DefaultAnnotations.builder();
newBuilder.set(AnnotationKeys.TYPE, "l3");
newBuilder.set("routerId", routerId);
DeviceDescription description =
new DefaultDeviceDescription(OspfRouterId.uri(ospfRouter.routerIp()),
deviceType, UNKNOWN, UNKNOWN, UNKNOWN,
UNKNOWN, cId, newBuilder.build());
deviceProviderService.deviceConnected(deviceId, description);
}
示例2: nodeAdded
import org.onlab.packet.ChassisId; //导入依赖的package包/类
@Override
public void nodeAdded(OvsdbNodeId nodeId) {
checkNotNull(nodeId, ISNOTNULL);
DeviceId deviceId = DeviceId.deviceId(nodeId.toString());
URI uri = URI.create(nodeId.toString());
ChassisId cid = new ChassisId();
String ipAddress = nodeId.getIpAddress();
SparseAnnotations annotations = DefaultAnnotations.builder()
.set("ipaddress", ipAddress).build();
DeviceDescription deviceDescription = new DefaultDeviceDescription(
uri,
Device.Type.CONTROLLER,
UNKNOWN, UNKNOWN,
UNKNOWN, UNKNOWN,
cid,
annotations);
providerService.deviceConnected(deviceId, deviceDescription);
}
示例3: routerAdded
import org.onlab.packet.ChassisId; //导入依赖的package包/类
@Override
public void routerAdded(IsisRouter isisRouter) {
String systemId = isisRouter.systemId();
log.info("Added device {}", systemId);
DeviceId deviceId = DeviceId.deviceId(IsisRouterId.uri(systemId));
Device.Type deviceType = Device.Type.ROUTER;
//If our routerType is Dr or Bdr type is PSEUDO
if (isisRouter.isDis()) {
deviceType = Device.Type.ROUTER;
} else {
deviceType = Device.Type.VIRTUAL;
}
ChassisId cId = new ChassisId();
DefaultAnnotations.Builder newBuilder = DefaultAnnotations.builder();
newBuilder.set(AnnotationKeys.TYPE, "L3");
newBuilder.set("RouterId", systemId);
DeviceDescription description =
new DefaultDeviceDescription(IsisRouterId.uri(systemId), deviceType, UNKNOWN, UNKNOWN, UNKNOWN,
UNKNOWN, cId, newBuilder.build());
deviceProviderService.deviceConnected(deviceId, description);
System.out.println("Device added: " + systemId);
}
示例4: inPacket
import org.onlab.packet.ChassisId; //导入依赖的package包/类
@Override
public InboundPacket inPacket() {
ONOSLLDP lldp = ONOSLLDP.onosLLDP(src.deviceId().toString(),
new ChassisId(),
(int) src.port().toLong());
Ethernet ethPacket = new Ethernet();
ethPacket.setEtherType(Ethernet.TYPE_LLDP);
ethPacket.setDestinationMACAddress(ONOSLLDP.LLDP_NICIRA);
ethPacket.setPayload(lldp);
ethPacket.setPad(true);
ethPacket.setSourceMACAddress("DE:AD:BE:EF:BA:11");
return new DefaultInboundPacket(dst, ethPacket,
ByteBuffer.wrap(ethPacket.serialize()));
}
示例5: deviceAdded
import org.onlab.packet.ChassisId; //导入依赖的package包/类
private void deviceAdded(RestSBDevice nodeId) {
Preconditions.checkNotNull(nodeId, ISNOTNULL);
DeviceId deviceId = nodeId.deviceId();
ChassisId cid = new ChassisId();
String ipAddress = nodeId.ip().toString();
SparseAnnotations annotations = DefaultAnnotations.builder()
.set(IPADDRESS, ipAddress)
.set(AnnotationKeys.PROTOCOL, REST.toUpperCase())
.build();
DeviceDescription deviceDescription = new DefaultDeviceDescription(
deviceId.uri(),
Device.Type.SWITCH,
UNKNOWN, UNKNOWN,
UNKNOWN, UNKNOWN,
cid,
annotations);
nodeId.setActive(true);
providerService.deviceConnected(deviceId, deviceDescription);
addedDevices.add(deviceId);
}
示例6: decode
import org.onlab.packet.ChassisId; //导入依赖的package包/类
/**
* {@inheritDoc}
*
* Note: ProviderId is not part of JSON representation.
* Returned object will have random ProviderId set.
*/
@Override
public Device decode(ObjectNode json, CodecContext context) {
if (json == null || !json.isObject()) {
return null;
}
DeviceId id = deviceId(json.get(ID).asText());
// TODO: add providerId to JSON if we need to recover them.
ProviderId pid = new ProviderId(id.uri().getScheme(), "DeviceCodec");
Type type = Type.valueOf(json.get(TYPE).asText());
String mfr = json.get(MFR).asText();
String hw = json.get(HW).asText();
String sw = json.get(SW).asText();
String serial = json.get(SERIAL).asText();
ChassisId chassisId = new ChassisId(json.get(CHASSIS_ID).asText());
Annotations annotations = extractAnnotations(json, context);
return new DefaultDevice(pid, id, type, mfr, hw, sw, serial,
chassisId, annotations);
}
示例7: composeDevice
import org.onlab.packet.ChassisId; //导入依赖的package包/类
/**
* Returns a Device, merging descriptions from multiple Providers.
*
* @param deviceId device identifier
* @return Device instance
*/
private Device composeDevice(DeviceId deviceId) {
ProviderId primaryProviderId = getPrimaryProviderId(deviceId);
DeviceDescription primaryDeviceDescription =
deviceDescriptions.get(new DeviceKey(primaryProviderId, deviceId));
Type type = primaryDeviceDescription.type();
String manufacturer = primaryDeviceDescription.manufacturer();
String hwVersion = primaryDeviceDescription.hwVersion();
String swVersion = primaryDeviceDescription.swVersion();
String serialNumber = primaryDeviceDescription.serialNumber();
ChassisId chassisId = primaryDeviceDescription.chassisId();
DefaultAnnotations annotations = mergeAnnotations(deviceId);
return new DefaultDevice(primaryProviderId, deviceId, type, manufacturer,
hwVersion, swVersion, serialNumber,
chassisId, annotations);
}
示例8: TestDevice
import org.onlab.packet.ChassisId; //导入依赖的package包/类
private TestDevice(ProviderId providerId,
DeviceId id,
Type type,
String manufacturer,
String hwVersion,
String swVersion,
String serialNumber,
ChassisId chassisId,
Annotations... annotations) {
super(providerId,
id,
type,
manufacturer,
hwVersion,
swVersion,
serialNumber,
chassisId,
annotations);
}
示例9: parseDevice
import org.onlab.packet.ChassisId; //导入依赖的package包/类
private void parseDevice(DeviceProviderService dps, JsonNode node) {
URI uri = URI.create(get(node, "uri"));
Device.Type type = Device.Type.valueOf(get(node, "type"));
String mfr = get(node, "mfr");
String hw = get(node, "hw");
String sw = get(node, "sw");
String serial = get(node, "serial");
ChassisId cid = new ChassisId(get(node, "mac"));
SparseAnnotations annotations = annotations(node.get("annotations"));
DeviceDescription desc =
new DefaultDeviceDescription(uri, type, mfr, hw, sw, serial,
cid, annotations);
DeviceId deviceId = deviceId(uri);
dps.deviceConnected(deviceId, desc);
JsonNode ports = node.get("ports");
if (ports != null) {
parsePorts(dps, deviceId, ports);
}
}
示例10: TestDeviceService
import org.onlab.packet.ChassisId; //导入依赖的package包/类
public TestDeviceService() {
Device d1 = new DefaultDevice(ProviderId.NONE, DID1, Device.Type.SWITCH,
"TESTMF", "TESTHW", "TESTSW", "TESTSN", new ChassisId());
Device d2 = new DefaultDevice(ProviderId.NONE, DID2, Device.Type.SWITCH,
"TESTMF", "TESTHW", "TESTSW", "TESTSN", new ChassisId());
devices.put(DID1, d1);
devices.put(DID2, d2);
pd1 = new DefaultPort(d1, PortNumber.portNumber(1), true);
pd2 = new DefaultPort(d1, PortNumber.portNumber(2), true);
pd3 = new DefaultPort(d2, PortNumber.portNumber(1), true);
pd4 = new DefaultPort(d2, PortNumber.portNumber(2), true);
ports.putAll(DID1, Lists.newArrayList(pd1, pd2));
ports.putAll(DID2, Lists.newArrayList(pd3, pd4));
}
示例11: parseProductInformation
import org.onlab.packet.ChassisId; //导入依赖的package包/类
private DeviceDescription parseProductInformation() {
DeviceService devsvc = checkNotNull(handler().get(DeviceService.class));
DeviceId devid = handler().data().deviceId();
Device dev = devsvc.getDevice(devid);
if (dev == null) {
return new DefaultDeviceDescription(devid.uri(), FIBER_SWITCH,
DEFAULT_MANUFACTURER, DEFAULT_DESCRIPTION_DATA,
DEFAULT_DESCRIPTION_DATA, DEFAULT_DESCRIPTION_DATA,
new ChassisId());
}
String reply = netconfGet(handler(), getProductInformationFilter());
HierarchicalConfiguration cfg = configAt(reply, KEY_DATA_PRODINF);
return new DefaultDeviceDescription(dev.id().uri(), FIBER_SWITCH,
cfg.getString(KEY_MANUFACTURER), cfg.getString(KEY_HWVERSION),
cfg.getString(KEY_SWVERSION), cfg.getString(KEY_SERIALNUMBER),
dev.chassisId());
}
示例12: discoverDeviceDetails
import org.onlab.packet.ChassisId; //导入依赖的package包/类
@Override
public DeviceDescription discoverDeviceDetails() {
log.debug("getting device description");
DeviceService deviceService = checkNotNull(handler().get(DeviceService.class));
DeviceId deviceId = handler().data().deviceId();
Device device = deviceService.getDevice(deviceId);
if (device == null) {
return new DefaultDeviceDescription(deviceId.uri(),
Device.Type.OTN,
"Ciena",
"WaveServer",
"Unknown",
"Unknown",
new ChassisId());
} else {
return new DefaultDeviceDescription(device.id().uri(),
Device.Type.OTN,
device.manufacturer(),
device.hwVersion(),
device.swVersion(),
device.serialNumber(),
device.chassisId());
}
}
示例13: parseJuniperDescription
import org.onlab.packet.ChassisId; //导入依赖的package包/类
/**
* Parses device configuration and returns the device description.
*
* @param deviceId the id of the device
* @param sysInfoCfg system configuration
* @param chassisText chassis string
* @return device description
*/
public static DeviceDescription parseJuniperDescription(DeviceId deviceId,
HierarchicalConfiguration sysInfoCfg,
String chassisText) {
HierarchicalConfiguration info = sysInfoCfg.configurationAt(SYS_INFO);
String hw = info.getString(HW_MODEL) == null ? UNKNOWN : info.getString(HW_MODEL);
String sw = UNKNOWN;
if (info.getString(OS_NAME) != null || info.getString(OS_VER) != null) {
sw = info.getString(OS_NAME) + " " + info.getString(OS_VER);
}
String serial = info.getString(SER_NUM) == null ? UNKNOWN : info.getString(SER_NUM);
Matcher matcher = ADD_PATTERN.matcher(chassisText);
if (matcher.lookingAt()) {
String chassis = matcher.group(1);
MacAddress chassisMac = MacAddress.valueOf(chassis);
return new DefaultDeviceDescription(deviceId.uri(), ROUTER,
JUNIPER, hw, sw, serial,
new ChassisId(chassisMac.toLong()),
DefaultAnnotations.EMPTY);
}
return new DefaultDeviceDescription(deviceId.uri(), ROUTER,
JUNIPER, hw, sw, serial,
null, DefaultAnnotations.EMPTY);
}
示例14: createDeviceRepresentation
import org.onlab.packet.ChassisId; //导入依赖的package包/类
private DeviceDescription createDeviceRepresentation(DeviceId deviceId, NetconfDeviceConfig config) {
Preconditions.checkNotNull(deviceId, ISNULL);
//Netconf configuration object
ChassisId cid = new ChassisId();
String ipAddress = config.ip().toString();
SparseAnnotations annotations = DefaultAnnotations.builder()
.set(IPADDRESS, ipAddress)
.set(PORT, String.valueOf(config.port()))
.set(AnnotationKeys.PROTOCOL, SCHEME_NAME.toUpperCase())
.build();
return new DefaultDeviceDescription(
deviceId.uri(),
Device.Type.SWITCH,
UNKNOWN, UNKNOWN,
UNKNOWN, UNKNOWN,
cid, false,
annotations);
}
示例15: connectDevice
import org.onlab.packet.ChassisId; //导入依赖的package包/类
private void connectDevice(Tl1Device device) {
try {
// Add device to TL1 controller
DeviceId deviceId = DeviceId.deviceId(
new URI(Tl1DeviceConfig.TL1, device.ip() + ":" + device.port(), null));
if (controller.addDevice(deviceId, device)) {
SparseAnnotations ann = DefaultAnnotations.builder()
.set(AnnotationKeys.PROTOCOL, Tl1DeviceConfig.TL1.toUpperCase())
.build();
// Register device in the core with default parameters and mark it as unavailable
DeviceDescription dd = new DefaultDeviceDescription(deviceId.uri(),
Device.Type.SWITCH,
UNKNOWN, UNKNOWN,
UNKNOWN, UNKNOWN,
new ChassisId(),
false, ann);
providerService.deviceConnected(deviceId, dd);
}
} catch (URISyntaxException e) {
log.error("Skipping device {}", device, e);
}
}