Yuta HIGUCHI
Committed by Gerrit Code Review

ONOS-4801 add default available field to gRPC model

- replace deprecated methods with new Protobuf 3 API
- cosmetic changes

Change-Id: I4655fc0fd76c8de83ea03615fc876c5aa9445367
...@@ -105,10 +105,12 @@ public final class ProtobufUtils { ...@@ -105,10 +105,12 @@ public final class ProtobufUtils {
105 String swVersion = deviceDescription.getSwVersion(); 105 String swVersion = deviceDescription.getSwVersion();
106 String serialNumber = deviceDescription.getSerialNumber(); 106 String serialNumber = deviceDescription.getSerialNumber();
107 ChassisId chassis = new ChassisId(deviceDescription.getChassisId()); 107 ChassisId chassis = new ChassisId(deviceDescription.getChassisId());
108 + boolean defaultAvailable = deviceDescription.getIsDefaultAvailable();
108 return new DefaultDeviceDescription(uri, type, manufacturer, 109 return new DefaultDeviceDescription(uri, type, manufacturer,
109 hwVersion, swVersion, serialNumber, 110 hwVersion, swVersion, serialNumber,
110 chassis, 111 chassis,
111 - asAnnotations(deviceDescription.getAnnotations())); 112 + defaultAvailable,
113 + asAnnotations(deviceDescription.getAnnotationsMap()));
112 } 114 }
113 115
114 /** 116 /**
...@@ -127,6 +129,7 @@ public final class ProtobufUtils { ...@@ -127,6 +129,7 @@ public final class ProtobufUtils {
127 .setSwVersion(deviceDescription.swVersion()) 129 .setSwVersion(deviceDescription.swVersion())
128 .setSerialNumber(deviceDescription.serialNumber()) 130 .setSerialNumber(deviceDescription.serialNumber())
129 .setChassisId(deviceDescription.chassisId().toString()) 131 .setChassisId(deviceDescription.chassisId().toString())
132 + .setIsDefaultAvailable(deviceDescription.isDefaultAvailable())
130 .putAllAnnotations(asMap(deviceDescription.annotations())) 133 .putAllAnnotations(asMap(deviceDescription.annotations()))
131 .build(); 134 .build();
132 } 135 }
...@@ -230,7 +233,7 @@ public final class ProtobufUtils { ...@@ -230,7 +233,7 @@ public final class ProtobufUtils {
230 boolean isEnabled = portDescription.getIsEnabled(); 233 boolean isEnabled = portDescription.getIsEnabled();
231 Port.Type type = translate(portDescription.getType()); 234 Port.Type type = translate(portDescription.getType());
232 long portSpeed = portDescription.getPortSpeed(); 235 long portSpeed = portDescription.getPortSpeed();
233 - SparseAnnotations annotations = asAnnotations(portDescription.getAnnotations()); 236 + SparseAnnotations annotations = asAnnotations(portDescription.getAnnotationsMap());
234 // TODO How to deal with more specific Port... 237 // TODO How to deal with more specific Port...
235 return new DefaultPortDescription(number, isEnabled, type, portSpeed, annotations); 238 return new DefaultPortDescription(number, isEnabled, type, portSpeed, annotations);
236 } 239 }
...@@ -242,7 +245,6 @@ public final class ProtobufUtils { ...@@ -242,7 +245,6 @@ public final class ProtobufUtils {
242 * @return gRPC PortDescription message 245 * @return gRPC PortDescription message
243 */ 246 */
244 public static org.onosproject.grpc.net.Port.PortDescription translate(PortDescription portDescription) { 247 public static org.onosproject.grpc.net.Port.PortDescription translate(PortDescription portDescription) {
245 - // TODO How to deal with more specific Port...
246 return org.onosproject.grpc.net.Port.PortDescription.newBuilder() 248 return org.onosproject.grpc.net.Port.PortDescription.newBuilder()
247 .setPortNumber(portDescription.portNumber().toString()) 249 .setPortNumber(portDescription.portNumber().toString())
248 .setIsEnabled(portDescription.isEnabled()) 250 .setIsEnabled(portDescription.isEnabled())
......
...@@ -12,6 +12,7 @@ message DeviceDescription { ...@@ -12,6 +12,7 @@ message DeviceDescription {
12 string serial_number = 6; 12 string serial_number = 6;
13 string chassis_id = 7; 13 string chassis_id = 7;
14 map<string, string> annotations = 8; 14 map<string, string> annotations = 8;
15 + bool is_default_available = 9;
15 } 16 }
16 17
17 enum MastershipRole { 18 enum MastershipRole {
......
...@@ -26,5 +26,3 @@ enum DeviceEventType { ...@@ -26,5 +26,3 @@ enum DeviceEventType {
26 PORT_STATS_UPDATED = 8; 26 PORT_STATS_UPDATED = 8;
27 } 27 }
28 28
29 -
30 -
......
...@@ -8,7 +8,7 @@ enum LinkType { ...@@ -8,7 +8,7 @@ enum LinkType {
8 DIRECT = 0; 8 DIRECT = 0;
9 9
10 // Signifies that this link is potentially comprised from multiple 10 // Signifies that this link is potentially comprised from multiple
11 - //underlying segments or hops, and as such should be used to tag 11 + // underlying segments or hops, and as such should be used to tag
12 // links traversing optical paths, tunnels or intervening 'dark' 12 // links traversing optical paths, tunnels or intervening 'dark'
13 // switches. 13 // switches.
14 INDIRECT = 1; 14 INDIRECT = 1;
......