Skip to content

Commit

Permalink
Merge branch 'master' of github.com:a10networks/acos-client into stab…
Browse files Browse the repository at this point in the history
…le/stein
  • Loading branch information
ytsai-a10 committed Jul 21, 2021
2 parents 98e1c31 + bb007cd commit 4e23991
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 12 deletions.
20 changes: 10 additions & 10 deletions acos_client/v30/axapi_http.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,9 @@
import time

from requests.adapters import HTTPAdapter
from requests import exceptions as req_exceptions
from requests import Session

import acos_client
from acos_client import errors as ae
from acos_client import logutils
from acos_client.v30 import responses as acos_responses

Expand Down Expand Up @@ -166,24 +164,26 @@ def request_impl(self, method, api_url, params={}, headers=None,
def request(self, method, api_url, params={}, headers=None,
file_name=None, file_content=None, axapi_args=None,
max_retries=None, timeout=None, **kwargs):
attemps = 300
if timeout and timeout > attemps:
attemps = timeout
retry_timeout = 300
if timeout and timeout > retry_timeout:
retry_timeout = timeout
start_time = time.time()
loop = True

while attemps > 0:
while loop:
try:
return self.request_impl(method, api_url, params, headers,
file_name=file_name, file_content=file_content,
max_retries=max_retries,
timeout=timeout, axapi_args=axapi_args,
**kwargs)

except (ae.ACOSSystemIsBusy, ae.ACOSSystemNotReady, req_exceptions.ConnectionError) as e:
except acos_responses.axapi_retry_exceptions() as e:
LOG.warning("ACOS device system is busy: %s", str(e))
attemps = attemps - 2
if attemps <= 0:
loop = ((time.time() - start_time) <= retry_timeout)
if not loop:
raise e
time.sleep(2)
time.sleep(1)
except (Exception) as e:
raise e

Expand Down
5 changes: 5 additions & 0 deletions acos_client/v30/responses.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import re

from acos_client import errors as ae
from requests import exceptions as req_ex

RESPONSE_CODES = {
33619969: {
Expand Down Expand Up @@ -276,3 +277,7 @@ def raise_axapi_ex(response, method, api_url):
raise ae.ACOSException(code, response['response']['err']['msg'])

raise ae.ACOSException()


def axapi_retry_exceptions():
return (ae.ACOSSystemIsBusy, ae.ACOSSystemNotReady, req_ex.ConnectionError)
3 changes: 3 additions & 0 deletions acos_client/v30/slb/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ def get(self, name, max_retries=None, timeout=None, **kwargs):
return self._get(self.url_prefix + name, max_retries=max_retries, timeout=timeout,
axapi_args=kwargs)

def get_all(self):
return self._get(self.url_prefix)

def _set(self, name, ip_address, status=1, server_templates=None, port_list=None,
conn_resume=None, conn_limit=None, health_check=None, **kwargs):
params = {
Expand Down
2 changes: 1 addition & 1 deletion acos_client/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
# License for the specific language governing permissions and limitations
# under the License.

VERSION = '2.7.0'
VERSION = '2.8.0'
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

setup(
name = "acos-client",
version = "2.7.0",
version = "2.8.0",
packages = find_packages(),

author = "A10 Networks",
Expand Down

0 comments on commit 4e23991

Please sign in to comment.