Example #1
0
def add_update_tenant(tenant_id):
    tenant_lease = request.get_json()["vm_lease_policy"]
    if request.method == "POST":
        lease_manager.add_tenant_lease(get_context(), tenant_lease)
    else:
        lease_manager.update_tenant_lease(get_context(), tenant_lease)
    return jsonify({'success': True}), 200, {'ContentType': 'application/json'}
Example #2
0
def add_update_tenant(tenant_id):
    tenant_lease = request.get_json()["vm_lease_policy"]
    if request.method == "POST":
        lease_manager.add_tenant_lease(get_context(), tenant_lease)
    else:
        lease_manager.update_tenant_lease(get_context(), tenant_lease)
    return jsonify({'success': True}), 200, {'ContentType': 'application/json'}
Example #3
0
def add_update_vm_lease(tenant_id, instance_id):
    lease_obj = request.get_json()
    # ds = '2012-03-01T10:00:00Z' # or any date sting of differing formats.
    date = datetime.strptime(lease_obj['expiry'], DATE_FORMAT)
    lease_obj['expiry'] = date
    if request.method == "POST":
        lease_manager.add_instance_lease(get_context(), tenant_id, lease_obj)
    else:
        lease_manager.update_instance_lease(get_context(), tenant_id, lease_obj)
    return jsonify({'success': True}), 200, {'ContentType': 'application/json'}
Example #4
0
def add_update_vm_lease(tenant_id, instance_id):
    lease_obj = request.get_json()
    # ds = '2012-03-01T10:00:00Z' # or any date sting of differing formats.
    date = datetime.strptime(lease_obj['expiry'], DATE_FORMAT)
    lease_obj['expiry'] = date
    if request.method == "POST":
        lease_manager.add_instance_lease(get_context(), tenant_id, lease_obj)
    else:
        lease_manager.update_instance_lease(get_context(), tenant_id,
                                            lease_obj)
    return jsonify({'success': True}), 200, {'ContentType': 'application/json'}
Example #5
0
def get_tenant(tenant_id):
    tenant_lease = lease_manager.get_tenant_lease(get_context(), tenant_id)
    if not tenant_lease:
        return jsonify({'success': False}), 404, {
            'ContentType': 'application/json'
        }
    return jsonify(tenant_lease)
Example #6
0
def get_tenant_and_instances(tenant_id):
    instances = lease_manager.get_tenant_and_associated_instance_leases(
        get_context(), tenant_id)
    if not instances:
        return jsonify({'success': False}), 404, {
            'ContentType': 'application/json'
        }
    return jsonify(instances)
Example #7
0
def get_vm_lease(tenant_id, instance_id):
    lease_info = lease_manager.get_instance_lease(get_context(), instance_id)
    if lease_info:
        return jsonify(lease_info), 200, {'ContentType': 'application/json'}
    else:
        return jsonify({'error': 'Not found'}), 404, {
            'ContentType': 'application/json'
        }
Example #8
0
def delete_tenant_lease(tenant_id):
    lease_manager.delete_tenant_lease(get_context(), tenant_id)
    return jsonify({'success': True}), 200, {'ContentType': 'application/json'}
Example #9
0
def get_all_tenants():
    all_tenants = lease_manager.get_tenant_leases(get_context())
    if all_tenants:
        return jsonify({"all_tenants": all_tenants})
    else:
        return jsonify({}), 200, {'ContentType': 'application/json'}
Example #10
0
def get_vm_lease(tenant_id, instance_id):
    lease_info = lease_manager.get_instance_lease(get_context(), instance_id)
    if lease_info:
        return jsonify(lease_info), 200, {'ContentType': 'application/json'}
    else:
        return jsonify({'error': 'Not found'}), 404, {'ContentType': 'application/json'}
Example #11
0
def get_tenant_and_instances(tenant_id):
    instances = lease_manager.get_tenant_and_associated_instance_leases(get_context(), tenant_id)
    if not instances:
        return jsonify({'success': False}), 404, {'ContentType': 'application/json'}
    return jsonify(instances)
Example #12
0
def delete_tenant_lease(tenant_id):
    lease_manager.delete_tenant_lease(get_context(), tenant_id)
    return jsonify({'success': True}), 200, {'ContentType': 'application/json'}
Example #13
0
def get_tenant(tenant_id):
    tenant_lease = lease_manager.get_tenant_lease(get_context(), tenant_id)
    if not tenant_lease:
        return jsonify({'success': False}), 404, {'ContentType': 'application/json'}
    return jsonify(tenant_lease)
Example #14
0
def get_all_tenants():
    all_tenants = lease_manager.get_tenant_leases(get_context())
    if all_tenants:
        return jsonify({"all_tenants":all_tenants})
    else:
        return jsonify({}), 200, {'ContentType': 'application/json'}