2018-01-09 20:15:02 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
#
|
|
|
|
# Copyright (c) 2017 F5 Networks Inc.
|
|
|
|
# GNU General Public License v3.0 (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
|
|
|
|
|
|
|
from __future__ import absolute_import, division, print_function
|
|
|
|
__metaclass__ = type
|
|
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
from f5.bigip import ManagementRoot
|
|
|
|
from icontrol.exceptions import iControlUnexpectedHTTPError
|
|
|
|
HAS_F5SDK = True
|
|
|
|
except ImportError:
|
|
|
|
HAS_F5SDK = False
|
|
|
|
|
|
|
|
try:
|
|
|
|
from library.module_utils.network.f5.common import F5BaseClient
|
2018-01-18 00:14:35 +00:00
|
|
|
from library.module_utils.network.f5.common import F5ModuleError
|
2018-01-09 20:15:02 +00:00
|
|
|
except ImportError:
|
|
|
|
from ansible.module_utils.network.f5.common import F5BaseClient
|
2018-01-18 00:14:35 +00:00
|
|
|
from ansible.module_utils.network.f5.common import F5ModuleError
|
2018-01-09 20:15:02 +00:00
|
|
|
|
|
|
|
|
|
|
|
class F5Client(F5BaseClient):
|
|
|
|
@property
|
|
|
|
def api(self):
|
2018-01-18 00:14:35 +00:00
|
|
|
try:
|
|
|
|
result = ManagementRoot(
|
|
|
|
self.params['server'],
|
|
|
|
self.params['user'],
|
|
|
|
self.params['password'],
|
|
|
|
port=self.params['server_port'],
|
|
|
|
verify=self.params['validate_certs'],
|
|
|
|
token='tmos'
|
|
|
|
)
|
|
|
|
except Exception:
|
|
|
|
raise F5ModuleError(
|
|
|
|
'Unable to connect to {0} on port {1}. '
|
|
|
|
'Is "validate_certs" preventing this?'.format(self.params['server'], self.params['server_port'])
|
|
|
|
)
|
2018-01-09 20:15:02 +00:00
|
|
|
return result
|