Skip to content

Commit

Permalink
Rename try_count and try_wait to retry_count and retry_interval
Browse files Browse the repository at this point in the history
These are a better fit at explaining what they do.
This is more explicit at letting users know we will retry once
per default in 10 seconds in case of failure.
  • Loading branch information
David Moreau Simard committed Feb 24, 2016
1 parent 786b9a2 commit ce2e212
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
14 changes: 7 additions & 7 deletions cicoclient/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,18 +90,18 @@ def get_parser(self, prog_name):
help='Requested amount of servers. Defaults to 1.'
)
parser.add_argument(
'--try-count',
'--retry-count',
metavar='<count>',
type=int,
default=1,
help='Number of attempts to make. Defaults to 1.'
help='Amount of retries to do in case of failure. Defaults to 1.'
)
parser.add_argument(
'--try-wait',
'--retry-interval',
metavar='<seconds>',
type=int,
default=30,
help='Wait between subsequent retries. Defaults to 30 (seconds).'
default=10,
help='Wait between subsequent retries. Defaults to 10 (seconds).'
)
return parser

Expand All @@ -115,8 +115,8 @@ def take_action(self, parsed_args):
hosts, ssid = api.node_get(arch=parsed_args.arch,
ver=parsed_args.release,
count=parsed_args.count,
try_count=parsed_args.try_count,
try_wait=parsed_args.try_wait)
retry_count=parsed_args.retry_count,
retry_interval=parsed_args.retry_interval)
message = "SSID for these servers: %s\n" % ssid
sys.stdout.write(message)

Expand Down
11 changes: 6 additions & 5 deletions cicoclient/wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,15 +114,16 @@ def inventory(self, all=False, ssid=None):
else:
return self.self_inventory

def node_get(self, arch=None, ver=None, count=1, try_count=1, try_wait=30):
def node_get(self, arch=None, ver=None, count=1, retry_count=1,
retry_interval=10):
"""
Requests specified amount of nodes with the provided parameters.
:param arch: Server architecture (ex: x86_64)
:param ver: CentOS version (ex: 7)
:param count: Amount of servers (ex: 2)
:param try_count: Number of times to try (ex: 10)
:param try_wait: Wait in seconds between each retry (ex: 30)
:param retry_count: Number of times to retry in case of failure (ex: 5)
:param retry_interval: Wait in seconds between each retry (ex: 30)
:return: [ [ requested_hosts ], ssid ]
"""
if self.api_key is None:
Expand All @@ -137,8 +138,8 @@ def node_get(self, arch=None, ver=None, count=1, try_count=1, try_wait=30):

resp, body = self.get('Node/get?%s' % args)
if not body:
for _ in range(try_count - 1):
time.sleep(try_wait)
for _ in range(retry_count - 1):
time.sleep(retry_interval)
resp, body = self.get('Node/get?%s' % args)
if body:
break
Expand Down

0 comments on commit ce2e212

Please sign in to comment.