Oleksiy Petrenko | caad203 | 2018-04-20 14:42:46 +0300 | [diff] [blame] | 1 | try: |
| 2 | import os_client_config |
| 3 | from keystoneauth1 import exceptions as ka_exceptions |
| 4 | REQUIREMENTS_MET = True |
| 5 | except ImportError: |
| 6 | REQUIREMENTS_MET = False |
| 7 | |
| 8 | from neutronv2 import networks |
| 9 | from neutronv2 import subnetpools |
| 10 | from neutronv2 import auto_alloc |
| 11 | from neutronv2 import subnets |
| 12 | |
| 13 | network_get_details = networks.network_get_details |
| 14 | network_update = networks.network_update |
| 15 | network_delete = networks.network_delete |
| 16 | network_list = networks.network_list |
| 17 | network_create = networks.network_create |
| 18 | network_bulk_create = networks.network_bulk_create |
| 19 | |
| 20 | subnetpool_get_details = subnetpools.subnetpool_get_details |
| 21 | subnetpool_update = subnetpools.subnetpool_update |
| 22 | subnetpool_delete = subnetpools.subnetpool_delete |
| 23 | subnetpool_list = subnetpools.subnetpool_list |
| 24 | subnetpool_create = subnetpools.subnetpool_create |
| 25 | |
| 26 | auto_alloc_get_details = auto_alloc.auto_alloc_get_details |
| 27 | auto_alloc_delete = auto_alloc.auto_alloc_delete |
| 28 | |
| 29 | subnet_list = subnets.subnet_list |
| 30 | subnet_create = subnets.subnet_create |
| 31 | subnet_bulk_create = subnets.subnet_bulk_create |
| 32 | subnet_get_details = subnets.subnet_get_details |
| 33 | subnet_update = subnets.subnet_update |
| 34 | subnet_delete = subnets.subnet_delete |
| 35 | |
| 36 | |
| 37 | __all__ = ( |
| 38 | 'network_get_details', 'network_update', 'network_delete', 'network_list', |
| 39 | 'network_create', 'network_bulk_create', 'subnetpool_get_details', |
| 40 | 'subnetpool_update', 'subnetpool_delete', 'subnetpool_list', |
| 41 | 'subnetpool_create', 'auto_alloc_get_details', 'auto_alloc_delete', |
| 42 | 'subnet_list', 'subnet_create', 'subnet_bulk_create', 'subnet_get_details', |
| 43 | 'subnet_update', 'subnet_delete', |
| 44 | ) |
| 45 | |
| 46 | |
| 47 | def __virtual__(): |
| 48 | """Only load neutronv2 if requirements are available.""" |
| 49 | if REQUIREMENTS_MET: |
| 50 | return 'neutronv2' |
| 51 | else: |
| 52 | return False, ("The neutronv2 execution module cannot be loaded: " |
| 53 | "os_client_config or keystoneauth are unavailable.") |