Per-project vpns, certificates, and revocation
This commit is contained in:
parent
193ecfa544
commit
025207ee56
@ -117,6 +117,45 @@ def service_update(context, service_id, values):
|
||||
###################
|
||||
|
||||
|
||||
def certificate_create(context, values):
|
||||
"""Create a certificate from the values dictionary."""
|
||||
return IMPL.certificate_create(context, values)
|
||||
|
||||
|
||||
def certificate_destroy(context, certificate_id):
|
||||
"""Destroy the certificate or raise if it does not exist."""
|
||||
return IMPL.certificate_destroy(context, certificate_id)
|
||||
|
||||
|
||||
def certificate_get_all_by_project(context, project_id):
|
||||
"""Get all certificates for a project."""
|
||||
return IMPL.certificate_get_all_by_project(context, project_id)
|
||||
|
||||
|
||||
def certificate_get_all_by_user(context, user_id):
|
||||
"""Get all certificates for a user."""
|
||||
return IMPL.certificate_get_all_by_user(context, user_id)
|
||||
|
||||
|
||||
def certificate_get_all_by_user_and_project(context, user_id, project_id):
|
||||
"""Get all certificates for a user and project."""
|
||||
return IMPL.certificate_get_all_by_user_and_project(context,
|
||||
user_id,
|
||||
project_id)
|
||||
|
||||
|
||||
def certificate_update(context, certificate_id, values):
|
||||
"""Set the given properties on an certificate and update it.
|
||||
|
||||
Raises NotFound if service does not exist.
|
||||
|
||||
"""
|
||||
return IMPL.service_update(context, certificate_id, values)
|
||||
|
||||
|
||||
###################
|
||||
|
||||
|
||||
def floating_ip_allocate_address(context, host, project_id):
|
||||
"""Allocate free floating ip and return the address.
|
||||
|
||||
|
@ -253,6 +253,84 @@ def service_update(context, service_id, values):
|
||||
###################
|
||||
|
||||
|
||||
@require_admin_context
|
||||
def certificate_get(context, certificate_id, session=None):
|
||||
if not session:
|
||||
session = get_session()
|
||||
|
||||
result = session.query(models.Certificate).\
|
||||
filter_by(id=certificate_id).\
|
||||
filter_by(deleted=can_read_deleted(context)).\
|
||||
first()
|
||||
|
||||
if not result:
|
||||
raise exception.NotFound('No certificate for id %s' % certificate_id)
|
||||
|
||||
return result
|
||||
|
||||
|
||||
@require_admin_context
|
||||
def certificate_create(context, values):
|
||||
certificate_ref = models.Certificate()
|
||||
for (key, value) in values.iteritems():
|
||||
certificate_ref[key] = value
|
||||
certificate_ref.save()
|
||||
return certificate_ref
|
||||
|
||||
|
||||
@require_admin_context
|
||||
def certificate_destroy(context, certificate_id):
|
||||
session = get_session()
|
||||
with session.begin():
|
||||
certificate_ref = certificate_get(context,
|
||||
certificate_id,
|
||||
session=session)
|
||||
certificate_ref.delete(session=session)
|
||||
|
||||
|
||||
@require_admin_context
|
||||
def certificate_get_all_by_project(context, project_id):
|
||||
session = get_session()
|
||||
return session.query(models.Certificate).\
|
||||
filter_by(project_id=project_id).\
|
||||
filter_by(deleted=False).\
|
||||
all()
|
||||
|
||||
|
||||
@require_admin_context
|
||||
def certificate_get_all_by_user(context, user_id):
|
||||
session = get_session()
|
||||
return session.query(models.Certificate).\
|
||||
filter_by(user_id=user_id).\
|
||||
filter_by(deleted=False).\
|
||||
all()
|
||||
|
||||
|
||||
@require_admin_context
|
||||
def certificate_get_all_by_user_and_project(_context, user_id, project_id):
|
||||
session = get_session()
|
||||
return session.query(models.Certificate).\
|
||||
filter_by(user_id=user_id).\
|
||||
filter_by(project_id=project_id).\
|
||||
filter_by(deleted=False).\
|
||||
all()
|
||||
|
||||
|
||||
@require_admin_context
|
||||
def certificate_update(context, certificate_id, values):
|
||||
session = get_session()
|
||||
with session.begin():
|
||||
certificate_ref = certificate_get(context,
|
||||
certificate_id,
|
||||
session=session)
|
||||
for (key, value) in values.iteritems():
|
||||
certificate_ref[key] = value
|
||||
certificate_ref.save(session=session)
|
||||
|
||||
|
||||
###################
|
||||
|
||||
|
||||
@require_context
|
||||
def floating_ip_allocate_address(context, host, project_id):
|
||||
authorize_project_context(context, project_id)
|
||||
|
Loading…
x
Reference in New Issue
Block a user