|
| 1 | +# coding=utf-8 |
| 2 | +# |
| 3 | +# Copyright 2014-2016 F5 Networks Inc. |
| 4 | +# |
| 5 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | +# you may not use this file except in compliance with the License. |
| 7 | +# You may obtain a copy of the License at |
| 8 | +# |
| 9 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +# |
| 11 | +# Unless required by applicable law or agreed to in writing, software |
| 12 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | +# See the License for the specific language governing permissions and |
| 15 | +# limitations under the License. |
| 16 | +# |
| 17 | + |
| 18 | +"""BIG-IP® Global Traffic Manager™ (GTM®) pool module. |
| 19 | +
|
| 20 | +REST URI |
| 21 | + ``http://localhost/mgmt/tm/gtm/server`` |
| 22 | +
|
| 23 | +GUI Path |
| 24 | + ``DNS --> GSLB : Servers`` |
| 25 | +
|
| 26 | +REST Kind |
| 27 | + ``tm:gtm:server:*`` |
| 28 | +""" |
| 29 | + |
| 30 | +from f5.bigip.resource import Collection |
| 31 | +from f5.bigip.resource import Resource |
| 32 | + |
| 33 | + |
| 34 | +class Servers(Collection): |
| 35 | + """BIG-IP® GTM server collection""" |
| 36 | + def __init__(self, gtm): |
| 37 | + super(Servers, self).__init__(gtm) |
| 38 | + self._meta_data['allowed_lazy_attributes'] = [Server] |
| 39 | + self._meta_data['attribute_registry'] = \ |
| 40 | + {'tm:gtm:server:serverstate': Server} |
| 41 | + |
| 42 | + |
| 43 | +class Server(Resource): |
| 44 | + """BIG-IP® GTM server resource""" |
| 45 | + def __init__(self, servers): |
| 46 | + super(Server, self).__init__(servers) |
| 47 | + self._meta_data['required_json_kind'] = 'tm:gtm:server:serverstate' |
| 48 | + self._meta_data['required_creation_parameters'].update( |
| 49 | + ('datacenter', 'addresses')) |
| 50 | + self._meta_data['attribute_registry'] = { |
| 51 | + 'tm:gtm:server:virtual-servers:virtual-serverscollectionstate': |
| 52 | + Virtual_Servers_s |
| 53 | + } |
| 54 | + |
| 55 | + |
| 56 | +class Virtual_Servers_s(Collection): |
| 57 | + """BIG-IP® GTM virtual server sub-collection""" |
| 58 | + def __init__(self, server): |
| 59 | + super(Virtual_Servers_s, self).__init__(server) |
| 60 | + self._meta_data['allowed_lazy_attributes'] = [Virtual_Servers] |
| 61 | + self._meta_data['required_json_kind'] = \ |
| 62 | + 'tm:gtm:server:virtual-servers:virtual-serverscollectionstate' |
| 63 | + self._meta_data['attribute_registry'] = { |
| 64 | + 'tm:gtm:server:virtual-servers:virtual-serversstate': |
| 65 | + Virtual_Servers} |
| 66 | + |
| 67 | + |
| 68 | +class Virtual_Servers(Resource): |
| 69 | + """BIG-IP® GTM virtual server resource""" |
| 70 | + def __init__(self, virtual_servers_s): |
| 71 | + super(Virtual_Servers, self).__init__(virtual_servers_s) |
| 72 | + self._meta_data['required_creation_parameters'].update(( |
| 73 | + 'destination',)) |
| 74 | + self._meta_data['required_json_kind'] = \ |
| 75 | + 'tm:gtm:server:virtual-servers:virtual-serversstate' |
0 commit comments