Matteo Scandolo | ede125b | 2017-08-08 13:05:25 -0700 | [diff] [blame] | 1 | |
| 2 | # Copyright 2017-present Open Networking Foundation |
| 3 | # |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | # you may not use this file except in compliance with the License. |
| 6 | # You may obtain a copy of the License at |
| 7 | # |
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | # See the License for the specific language governing permissions and |
| 14 | # limitations under the License. |
| 15 | |
| 16 | |
Scott Baker | c41914d | 2017-06-26 14:00:52 -0700 | [diff] [blame] | 17 | lab="External" |
| 18 | for service in ["HyperCache", "RequestRouter"]: |
| 19 | for node in ListAll("Node"): |
| 20 | node_id = node["node_id"] |
| 21 | for interface_id in node["interface_ids"]: |
| 22 | iface=Read("Interface", interface_id) |
| 23 | if iface["is_primary"] and len(iface["ip_address_ids"])==1: |
| 24 | ip_id = iface["ip_address_ids"][0] |
| 25 | if ListAll("LogicalInterface", {"node_id": node_id, "ip_address_ids": [ip_id], "label": lab, "service": service}): |
| 26 | print "External label exists for node", node_id, "ip", ip_id, "service", service |
| 27 | else: |
| 28 | print "Adding external label for node", node_id, "ip", ip_id, "service", service |
| 29 | li = Create("LogicalInterface", {"node_id": node_id, "label": lab, "service": service}) |
| 30 | Bind("LogicalInterface", li, "IpAddress", ip_id) |