Fix for IAAS-5476, update for instance lease

Instance lease update failed, fixing the code to call
the update lease of vm instead of tenant. Added a
functional test to call PUT on instance as well.

Ran the functional test
This commit is contained in:
Roopak Parikh 2016-05-23 23:25:47 -07:00
parent 844a2c307f
commit e1b921999e
2 changed files with 19 additions and 2 deletions

View File

@ -109,7 +109,7 @@ def add_update_vm_lease(tenant_id, instance_id):
if request.method == "POST":
lease_manager.add_instance_lease(get_context(), tenant_id, lease_obj)
else:
lease_manager.update_tenant_lease(get_context(), tenant_id, lease_obj)
lease_manager.update_instance_lease(get_context(), tenant_id, lease_obj)
return jsonify({'success': True}), 200, {'ContentType': 'application/json'}

View File

@ -152,8 +152,25 @@ def test_get_instance():
logger.debug(r.text)
assert_equal(r.status_code, 200)
@test(depends_on=[test_get_instance])
def test_update_instance():
expiry = datetime.utcnow()
expiry_str = datetime.strftime(expiry, DATE_FORMAT)
r = requests.put('http://127.0.0.1:' + port + '/v1/tenant/' + tenant_id1 + '/instance/' + instance_id1,
json={"instance_uuid": instance_id1, "expiry": expiry_str},
headers=headers)
logger.debug(r.text)
assert_equal(r.status_code, 200)
@test(depends_on=[test_update_instance])
def test_get_instance2():
r = requests.get('http://127.0.0.1:' + port + '/v1/tenant/' + tenant_id1 + '/instance/' + instance_id1,
headers=headers)
logger.debug(r.text)
assert_equal(r.status_code, 200)
@test(depends_on=[test_get_instance2])
def test_deleted_instance():
eventlet.greenthread.sleep(50)
# The instance lease should be deleted by now