|
| 1 | +# Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 2 | +# not use this file except in compliance with the License. You may obtain |
| 3 | +# a copy of the License at |
| 4 | +# |
| 5 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 6 | +# |
| 7 | +# Unless required by applicable law or agreed to in writing, software |
| 8 | +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 9 | +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 10 | +# License for the specific language governing permissions and limitations |
| 11 | +# under the License. |
| 12 | + |
| 13 | +from oslo_log import log as logging |
| 14 | + |
| 15 | +from networking_generic_switch.devices import netmiko_devices |
| 16 | + |
| 17 | + |
| 18 | +LOG = logging.getLogger(__name__) |
| 19 | + |
| 20 | + |
| 21 | +class Fake(netmiko_devices.NetmikoSwitch): |
| 22 | + """Netmiko device driver for Fake switches.""" |
| 23 | + |
| 24 | + NETMIKO_DEVICE_TYPE = "linux" |
| 25 | + |
| 26 | + ADD_NETWORK = ( |
| 27 | + "add network {segmentation_id}", |
| 28 | + ) |
| 29 | + |
| 30 | + DELETE_NETWORK = ( |
| 31 | + "delete network {segmentation_id}", |
| 32 | + ) |
| 33 | + |
| 34 | + PLUG_PORT_TO_NETWORK = ( |
| 35 | + "plug port {port} to network {segmentation_id}", |
| 36 | + ) |
| 37 | + |
| 38 | + DELETE_PORT = ( |
| 39 | + "delete port {port}", |
| 40 | + ) |
| 41 | + |
| 42 | + ADD_NETWORK_TO_TRUNK = ( |
| 43 | + "add network {segmentation_id} to trunk {port}", |
| 44 | + ) |
| 45 | + |
| 46 | + REMOVE_NETWORK_FROM_TRUNK = ( |
| 47 | + "remove network {segmentation_id} from trunk {port}", |
| 48 | + ) |
| 49 | + |
| 50 | + ENABLE_PORT = ( |
| 51 | + "enable {port}", |
| 52 | + ) |
| 53 | + |
| 54 | + DISABLE_PORT = ( |
| 55 | + "disable {port}", |
| 56 | + ) |
| 57 | + |
| 58 | + ERROR_MSG_PATTERNS = () |
| 59 | + """Sequence of error message patterns. |
| 60 | +
|
| 61 | + Sequence of re.RegexObject objects representing patterns to check for in |
| 62 | + device output that indicate a failure to apply configuration. |
| 63 | + """ |
| 64 | + |
| 65 | + def send_commands_to_device(self, cmd_set): |
| 66 | + if not cmd_set: |
| 67 | + LOG.debug("Nothing to execute") |
| 68 | + return |
| 69 | + |
| 70 | + for cmd in cmd_set: |
| 71 | + LOG.info("%s", cmd) |
| 72 | + return "Success!" |
0 commit comments