GUI -- Updated Intent View to have resources and details listed for each intent.
Change-Id: I2dc0f88970a574d0fe91348fa91bc16b7143a68b
Showing
3 changed files
with
164 additions
and
5 deletions
| ... | @@ -19,12 +19,21 @@ import com.fasterxml.jackson.databind.node.ArrayNode; | ... | @@ -19,12 +19,21 @@ import com.fasterxml.jackson.databind.node.ArrayNode; |
| 19 | import com.fasterxml.jackson.databind.node.ObjectNode; | 19 | import com.fasterxml.jackson.databind.node.ObjectNode; |
| 20 | import com.google.common.collect.ImmutableSet; | 20 | import com.google.common.collect.ImmutableSet; |
| 21 | import org.onosproject.core.ApplicationId; | 21 | import org.onosproject.core.ApplicationId; |
| 22 | +import org.onosproject.net.ConnectPoint; | ||
| 23 | +import org.onosproject.net.intent.ConnectivityIntent; | ||
| 24 | +import org.onosproject.net.intent.HostToHostIntent; | ||
| 22 | import org.onosproject.net.intent.Intent; | 25 | import org.onosproject.net.intent.Intent; |
| 23 | import org.onosproject.net.intent.IntentService; | 26 | import org.onosproject.net.intent.IntentService; |
| 27 | +import org.onosproject.net.intent.LinkCollectionIntent; | ||
| 28 | +import org.onosproject.net.intent.MultiPointToSinglePointIntent; | ||
| 29 | +import org.onosproject.net.intent.PathIntent; | ||
| 30 | +import org.onosproject.net.intent.PointToPointIntent; | ||
| 31 | +import org.onosproject.net.intent.SinglePointToMultiPointIntent; | ||
| 24 | 32 | ||
| 25 | import java.util.ArrayList; | 33 | import java.util.ArrayList; |
| 26 | import java.util.Arrays; | 34 | import java.util.Arrays; |
| 27 | import java.util.List; | 35 | import java.util.List; |
| 36 | +import java.util.Set; | ||
| 28 | 37 | ||
| 29 | /** | 38 | /** |
| 30 | * Message handler for intent view related messages. | 39 | * Message handler for intent view related messages. |
| ... | @@ -73,11 +82,131 @@ public class IntentViewMessageHandler extends AbstractTabularViewMessageHandler | ... | @@ -73,11 +82,131 @@ public class IntentViewMessageHandler extends AbstractTabularViewMessageHandler |
| 73 | private static final String KEY = "key"; | 82 | private static final String KEY = "key"; |
| 74 | private static final String TYPE = "type"; | 83 | private static final String TYPE = "type"; |
| 75 | private static final String PRIORITY = "priority"; | 84 | private static final String PRIORITY = "priority"; |
| 85 | + private static final String RESOURCES = "resources"; | ||
| 86 | + private static final String DETAILS = "details"; | ||
| 76 | 87 | ||
| 77 | private static final String[] COL_IDS = { | 88 | private static final String[] COL_IDS = { |
| 78 | - APP_ID, KEY, TYPE, PRIORITY | 89 | + APP_ID, KEY, TYPE, PRIORITY, RESOURCES, DETAILS |
| 79 | }; | 90 | }; |
| 80 | 91 | ||
| 92 | + private String formatDetails(Intent intent) { | ||
| 93 | + StringBuilder details = new StringBuilder(""); | ||
| 94 | + | ||
| 95 | + if (intent instanceof ConnectivityIntent) { | ||
| 96 | + ConnectivityIntent ci = (ConnectivityIntent) intent; | ||
| 97 | + if (!ci.selector().criteria().isEmpty()) { | ||
| 98 | + details.append("selector=") | ||
| 99 | + .append(ci.selector().criteria().toString()); | ||
| 100 | + } | ||
| 101 | + if (!ci.treatment().allInstructions().isEmpty()) { | ||
| 102 | + details.append("treatment=") | ||
| 103 | + .append(ci.treatment().allInstructions().toString()); | ||
| 104 | + } | ||
| 105 | + if (ci.constraints() != null && !ci.constraints().isEmpty()) { | ||
| 106 | + details.append("constraints=") | ||
| 107 | + .append(ci.constraints().toString()); | ||
| 108 | + } | ||
| 109 | + } | ||
| 110 | + | ||
| 111 | + if (intent instanceof HostToHostIntent) { | ||
| 112 | + HostToHostIntent pi = (HostToHostIntent) intent; | ||
| 113 | + details.append(" host1=") | ||
| 114 | + .append(pi.one().toString()) | ||
| 115 | + .append(", host2=") | ||
| 116 | + .append(pi.two().toString()); | ||
| 117 | + | ||
| 118 | + } else if (intent instanceof PointToPointIntent) { | ||
| 119 | + PointToPointIntent pi = (PointToPointIntent) intent; | ||
| 120 | + ConnectPoint ingress = pi.ingressPoint(); | ||
| 121 | + ConnectPoint egress = pi.egressPoint(); | ||
| 122 | + details.append(" ingress=") | ||
| 123 | + .append(ingress.elementId().toString()) | ||
| 124 | + .append('/') | ||
| 125 | + .append(ingress.port().toString()) | ||
| 126 | + | ||
| 127 | + .append(", egress=") | ||
| 128 | + .append(egress.elementId().toString()) | ||
| 129 | + .append('/') | ||
| 130 | + .append(egress.port().toString()) | ||
| 131 | + .append(' '); | ||
| 132 | + | ||
| 133 | + } else if (intent instanceof MultiPointToSinglePointIntent) { | ||
| 134 | + MultiPointToSinglePointIntent pi | ||
| 135 | + = (MultiPointToSinglePointIntent) intent; | ||
| 136 | + Set<ConnectPoint> ingresses = pi.ingressPoints(); | ||
| 137 | + ConnectPoint egress = pi.egressPoint(); | ||
| 138 | + | ||
| 139 | + details.append(" ingress="); | ||
| 140 | + for (ConnectPoint ingress : ingresses) { | ||
| 141 | + details.append(ingress.elementId().toString()) | ||
| 142 | + .append('/') | ||
| 143 | + .append(ingress.port().toString()) | ||
| 144 | + .append(' '); | ||
| 145 | + } | ||
| 146 | + | ||
| 147 | + details.append(", egress=") | ||
| 148 | + .append(egress.elementId().toString()) | ||
| 149 | + .append('/') | ||
| 150 | + .append(egress.port().toString()) | ||
| 151 | + .append(' '); | ||
| 152 | + | ||
| 153 | + } else if (intent instanceof SinglePointToMultiPointIntent) { | ||
| 154 | + SinglePointToMultiPointIntent pi | ||
| 155 | + = (SinglePointToMultiPointIntent) intent; | ||
| 156 | + ConnectPoint ingress = pi.ingressPoint(); | ||
| 157 | + Set<ConnectPoint> egresses = pi.egressPoints(); | ||
| 158 | + | ||
| 159 | + details.append(" ingress=") | ||
| 160 | + .append(ingress.elementId().toString()) | ||
| 161 | + .append('/') | ||
| 162 | + .append(ingress.port().toString()) | ||
| 163 | + .append(", egress="); | ||
| 164 | + | ||
| 165 | + for (ConnectPoint egress : egresses) { | ||
| 166 | + details.append(egress.elementId().toString()) | ||
| 167 | + .append('/') | ||
| 168 | + .append(egress.port().toString()) | ||
| 169 | + .append(' '); | ||
| 170 | + } | ||
| 171 | + | ||
| 172 | + } else if (intent instanceof PathIntent) { | ||
| 173 | + PathIntent pi = (PathIntent) intent; | ||
| 174 | + details.append(" path=") | ||
| 175 | + .append(pi.path().links().toString()) | ||
| 176 | + .append(", cost=") | ||
| 177 | + .append(pi.path().cost()); | ||
| 178 | + | ||
| 179 | + } else if (intent instanceof LinkCollectionIntent) { | ||
| 180 | + LinkCollectionIntent li = (LinkCollectionIntent) intent; | ||
| 181 | + Set<ConnectPoint> egresses = li.egressPoints(); | ||
| 182 | + | ||
| 183 | + details.append(" links=") | ||
| 184 | + .append(li.links().toString()) | ||
| 185 | + .append(", egress="); | ||
| 186 | + | ||
| 187 | + for (ConnectPoint egress : egresses) { | ||
| 188 | + details.append(egress.elementId().toString()) | ||
| 189 | + .append('/') | ||
| 190 | + .append(egress.port().toString()) | ||
| 191 | + .append(' '); | ||
| 192 | + } | ||
| 193 | + } | ||
| 194 | + | ||
| 195 | + if (details.toString().equals("")) { | ||
| 196 | + details.append("No details for this intent"); | ||
| 197 | + } else { | ||
| 198 | + details.insert(0, "Details: "); | ||
| 199 | + } | ||
| 200 | + return details.toString(); | ||
| 201 | + } | ||
| 202 | + | ||
| 203 | + private String formatResources(Intent i) { | ||
| 204 | + if (!i.resources().isEmpty()) { | ||
| 205 | + return "Resources: " + i.resources(); | ||
| 206 | + } | ||
| 207 | + return "No resources for this intent."; | ||
| 208 | + } | ||
| 209 | + | ||
| 81 | public IntentTableRow(Intent i) { | 210 | public IntentTableRow(Intent i) { |
| 82 | ApplicationId appid = i.appId(); | 211 | ApplicationId appid = i.appId(); |
| 83 | 212 | ||
| ... | @@ -85,6 +214,8 @@ public class IntentViewMessageHandler extends AbstractTabularViewMessageHandler | ... | @@ -85,6 +214,8 @@ public class IntentViewMessageHandler extends AbstractTabularViewMessageHandler |
| 85 | add(KEY, i.key().toString()); | 214 | add(KEY, i.key().toString()); |
| 86 | add(TYPE, i.getClass().getSimpleName()); | 215 | add(TYPE, i.getClass().getSimpleName()); |
| 87 | add(PRIORITY, Integer.toString(i.priority())); | 216 | add(PRIORITY, Integer.toString(i.priority())); |
| 217 | + add(RESOURCES, formatResources(i)); | ||
| 218 | + add(DETAILS, formatDetails(i)); | ||
| 88 | } | 219 | } |
| 89 | 220 | ||
| 90 | @Override | 221 | @Override | ... | ... |
| ... | @@ -18,5 +18,28 @@ | ... | @@ -18,5 +18,28 @@ |
| 18 | ONOS GUI -- Intent View -- CSS file | 18 | ONOS GUI -- Intent View -- CSS file |
| 19 | */ | 19 | */ |
| 20 | 20 | ||
| 21 | -#ov-intent td { | ||
| 22 | -} | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 21 | +.light #ov-intent tr:nth-child(6n + 1), | ||
| 22 | +.light #ov-intent tr:nth-child(6n + 2), | ||
| 23 | +.light #ov-intent tr:nth-child(6n + 3) { | ||
| 24 | + background-color: #eee; | ||
| 25 | +} | ||
| 26 | +.light #ov-intent tr:nth-child(6n + 4), | ||
| 27 | +.light #ov-intent tr:nth-child(6n + 5), | ||
| 28 | +.light #ov-intent tr:nth-child(6n) { | ||
| 29 | + background-color: #ddd; | ||
| 30 | +} | ||
| 31 | +.dark #ov-intent tr:nth-child(6n + 1), | ||
| 32 | +.dark #ov-intent tr:nth-child(6n + 2), | ||
| 33 | +.dark #ov-intent tr:nth-child(6n + 3) { | ||
| 34 | + background-color: #444; | ||
| 35 | +} | ||
| 36 | +.dark #ov-intent tr:nth-child(6n + 4), | ||
| 37 | +.dark #ov-intent tr:nth-child(6n + 5), | ||
| 38 | +.dark #ov-intent tr:nth-child(6n) { | ||
| 39 | + background-color: #333; | ||
| 40 | +} | ||
| 41 | + | ||
| 42 | +#ov-intent td.resources, | ||
| 43 | +#ov-intent td.details { | ||
| 44 | + padding-left: 36px; | ||
| 45 | +} | ... | ... |
| ... | @@ -31,13 +31,18 @@ | ... | @@ -31,13 +31,18 @@ |
| 31 | </thead> | 31 | </thead> |
| 32 | 32 | ||
| 33 | <tbody> | 33 | <tbody> |
| 34 | - <tr ng-repeat="intent in ctrl.intentData" | 34 | + <tr ng-repeat-start="intent in ctrl.intentData"> |
| 35 | - ng-repeat-done> | ||
| 36 | <td>{{intent.appId}}</td> | 35 | <td>{{intent.appId}}</td> |
| 37 | <td>{{intent.key}}</td> | 36 | <td>{{intent.key}}</td> |
| 38 | <td>{{intent.type}}</td> | 37 | <td>{{intent.type}}</td> |
| 39 | <td>{{intent.priority}}</td> | 38 | <td>{{intent.priority}}</td> |
| 40 | </tr> | 39 | </tr> |
| 40 | + <tr> | ||
| 41 | + <td class="resources" colspan="4">{{intent.resources}}</td> | ||
| 42 | + </tr> | ||
| 43 | + <tr ng-repeat-end ng-repeat-done> | ||
| 44 | + <td class="details" colspan="4">{{intent.details}}</td> | ||
| 45 | + </tr> | ||
| 41 | </tbody> | 46 | </tbody> |
| 42 | </table> | 47 | </table> |
| 43 | 48 | ... | ... |
-
Please register or login to post a comment