Factory function selects the proper class and creates object based on device_type.
(*args: Any, **kwargs: Any)
| 502 | |
| 503 | |
| 504 | def ConnectHandler(*args: Any, **kwargs: Any) -> "BaseConnection": |
| 505 | """Factory function selects the proper class and creates object based on device_type.""" |
| 506 | device_type = kwargs["device_type"] |
| 507 | if device_type not in platforms: |
| 508 | if device_type is None: |
| 509 | msg_str = platforms_str |
| 510 | else: |
| 511 | msg_str = telnet_platforms_str if "_telnet" in device_type else platforms_str |
| 512 | raise ValueError( |
| 513 | "Unsupported 'device_type' currently supported platforms are: {}".format(msg_str) |
| 514 | ) |
| 515 | ConnectionClass = ssh_dispatcher(device_type) |
| 516 | return ConnectionClass(*args, **kwargs) |
| 517 | |
| 518 | |
| 519 | def TelnetFallback(*args: Any, **kwargs: Any) -> "BaseConnection": |