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
This commit is contained in:
Harsh Shah 2014-07-21 14:32:01 -07:00
parent ca07062ced
commit 16e6fe3765
2 changed files with 10 additions and 3 deletions

View File

@ -36,14 +36,14 @@ class LeaseClientManager(base.BaseClientManager):
return self._get('/leases/%s' % lease_id, 'lease')
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."""
values = {}
if name:
values['name'] = name
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
if lease_end_date_change:
@ -57,7 +57,7 @@ class LeaseClientManager(base.BaseClientManager):
lease = self.get(lease_id)
self._add_lease_date(values, lease, 'start_date',
lease_start_date_change,
True)
defer_by is not None)
if not values:
return _('No values to update passed.')

View File

@ -258,6 +258,11 @@ class UpdateLease(command.UpdateCommand):
help='Time to defer the lease start',
default=None
)
group.add_argument(
'--advance-by',
help='Time to advance the lease start',
default=None
)
return parser
@ -271,6 +276,8 @@ class UpdateLease(command.UpdateCommand):
params['reduce_by'] = parsed_args.reduce_by
if 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