Ejemplo n.º 1
0
    def api(self):
        exc = None
        if self._client:
            return self._client
        for x in range(0, 3):
            try:
                server = self.params['provider']['server'] or self.params[
                    'server']
                user = self.params['provider']['user'] or self.params['user']
                password = self.params['provider']['password'] or self.params[
                    'password']
                server_port = self.params['provider'][
                    'server_port'] or self.params['server_port'] or 443
                validate_certs = self.params['provider'][
                    'validate_certs'] or self.params['validate_certs']

                result = ManagementRoot(server,
                                        user,
                                        password,
                                        port=server_port,
                                        verify=validate_certs,
                                        token='local')
                self._client = result
                return self._client
            except Exception as ex:
                exc = ex
                time.sleep(3)
        error = 'Unable to connect to {0} on port {1}.'.format(
            self.params['server'], self.params['server_port'])
        if exc is not None:
            error += ' The reported error was "{0}".'.format(str(exc))
        raise F5ModuleError(error)
Ejemplo n.º 2
0
 def api(self):
     result = ManagementRoot(self.params['server'],
                             self.params['user'],
                             self.params['password'],
                             port=self.params['server_port'],
                             verify=self.params['validate_certs'],
                             token='local')
     return result
Ejemplo n.º 3
0
 def api(self):
     try:
         result = ManagementRoot(self.params['server'],
                                 self.params['user'],
                                 self.params['password'],
                                 port=self.params['server_port'],
                                 verify=self.params['validate_certs'],
                                 token='local')
     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']))
     return result
Ejemplo n.º 4
0
 def api(self):
     result = None
     for x in range(0, 10):
         try:
             result = ManagementRoot(
                 self.params['server'],
                 self.params['user'],
                 self.params['password'],
                 port=self.params['server_port'],
                 verify=self.params['validate_certs'],
                 token='local'
             )
             break
         except Exception:
             time.sleep(3)
     if result:
         return result
     else:
         raise F5ModuleError(
             'Unable to connect to {0} on port {1}. '
             'Is "validate_certs" preventing this?'.format(self.params['server'], self.params['server_port'])
         )
Ejemplo n.º 5
0
def connect_to_f5(**kwargs):
    return ManagementRoot(kwargs['server'],
                          kwargs['user'],
                          kwargs['password'],
                          port=kwargs['server_port'],
                          token='local')
Ejemplo n.º 6
0
def mgmt_root(opt_bigip, opt_username, opt_password, opt_port, opt_token):
    return ManagementRoot(opt_bigip,
                          opt_username,
                          opt_password,
                          port=opt_port,
                          token=opt_token)