Commit 16e6fe37 authored by Harsh Shah's avatar Harsh Shah

Added option --advance-by to allow advancing of lease start date

Added option --advance-by to the mutually exclusive group containing
--defer-by to allow the user to advance the start date of a lease.

Change-Id: I4cb801e29407917f3d409a7866bd53ec2184e93d
Closes-Bug: 1314791
parent ca07062c
...@@ -36,14 +36,14 @@ class LeaseClientManager(base.BaseClientManager): ...@@ -36,14 +36,14 @@ class LeaseClientManager(base.BaseClientManager):
return self._get('/leases/%s' % lease_id, 'lease') return self._get('/leases/%s' % lease_id, 'lease')
def update(self, lease_id, name=None, prolong_for=None, reduce_by=None, def update(self, lease_id, name=None, prolong_for=None, reduce_by=None,
defer_by=None): advance_by=None, defer_by=None):
"""Update attributes of the lease.""" """Update attributes of the lease."""
values = {} values = {}
if name: if name:
values['name'] = name values['name'] = name
lease_end_date_change = prolong_for or reduce_by lease_end_date_change = prolong_for or reduce_by
lease_start_date_change = defer_by lease_start_date_change = defer_by or advance_by
lease = None lease = None
if lease_end_date_change: if lease_end_date_change:
...@@ -57,7 +57,7 @@ class LeaseClientManager(base.BaseClientManager): ...@@ -57,7 +57,7 @@ class LeaseClientManager(base.BaseClientManager):
lease = self.get(lease_id) lease = self.get(lease_id)
self._add_lease_date(values, lease, 'start_date', self._add_lease_date(values, lease, 'start_date',
lease_start_date_change, lease_start_date_change,
True) defer_by is not None)
if not values: if not values:
return _('No values to update passed.') return _('No values to update passed.')
......
...@@ -258,6 +258,11 @@ class UpdateLease(command.UpdateCommand): ...@@ -258,6 +258,11 @@ class UpdateLease(command.UpdateCommand):
help='Time to defer the lease start', help='Time to defer the lease start',
default=None default=None
) )
group.add_argument(
'--advance-by',
help='Time to advance the lease start',
default=None
)
return parser return parser
...@@ -271,6 +276,8 @@ class UpdateLease(command.UpdateCommand): ...@@ -271,6 +276,8 @@ class UpdateLease(command.UpdateCommand):
params['reduce_by'] = parsed_args.reduce_by params['reduce_by'] = parsed_args.reduce_by
if parsed_args.defer_by: if parsed_args.defer_by:
params['defer_by'] = parsed_args.defer_by params['defer_by'] = parsed_args.defer_by
if parsed_args.advance_by:
params['advance_by'] = parsed_args.advance_by
return params return params
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment