Merge "enginefacade: 'dnsdomain' and 'ec2'"
This commit is contained in:
commit
3f8c69b2ef
@ -1030,23 +1030,20 @@ def floating_ip_update(context, address, values):
|
|||||||
return float_ip_ref
|
return float_ip_ref
|
||||||
|
|
||||||
|
|
||||||
def _dnsdomain_get(context, session, fqdomain):
|
###################
|
||||||
return model_query(context, models.DNSDomain,
|
|
||||||
session=session, read_deleted="no").\
|
|
||||||
|
@require_context
|
||||||
|
@main_context_manager.reader
|
||||||
|
def dnsdomain_get(context, fqdomain):
|
||||||
|
return model_query(context, models.DNSDomain, read_deleted="no").\
|
||||||
filter_by(domain=fqdomain).\
|
filter_by(domain=fqdomain).\
|
||||||
with_lockmode('update').\
|
with_lockmode('update').\
|
||||||
first()
|
first()
|
||||||
|
|
||||||
|
|
||||||
@require_context
|
def _dnsdomain_get_or_create(context, fqdomain):
|
||||||
def dnsdomain_get(context, fqdomain):
|
domain_ref = dnsdomain_get(context, fqdomain)
|
||||||
session = get_session()
|
|
||||||
with session.begin():
|
|
||||||
return _dnsdomain_get(context, session, fqdomain)
|
|
||||||
|
|
||||||
|
|
||||||
def _dnsdomain_get_or_create(context, session, fqdomain):
|
|
||||||
domain_ref = _dnsdomain_get(context, session, fqdomain)
|
|
||||||
if not domain_ref:
|
if not domain_ref:
|
||||||
dns_ref = models.DNSDomain()
|
dns_ref = models.DNSDomain()
|
||||||
dns_ref.update({'domain': fqdomain,
|
dns_ref.update({'domain': fqdomain,
|
||||||
@ -1057,30 +1054,30 @@ def _dnsdomain_get_or_create(context, session, fqdomain):
|
|||||||
return domain_ref
|
return domain_ref
|
||||||
|
|
||||||
|
|
||||||
|
@main_context_manager.writer
|
||||||
def dnsdomain_register_for_zone(context, fqdomain, zone):
|
def dnsdomain_register_for_zone(context, fqdomain, zone):
|
||||||
session = get_session()
|
domain_ref = _dnsdomain_get_or_create(context, fqdomain)
|
||||||
with session.begin():
|
domain_ref.scope = 'private'
|
||||||
domain_ref = _dnsdomain_get_or_create(context, session, fqdomain)
|
domain_ref.availability_zone = zone
|
||||||
domain_ref.scope = 'private'
|
context.session.add(domain_ref)
|
||||||
domain_ref.availability_zone = zone
|
|
||||||
session.add(domain_ref)
|
|
||||||
|
|
||||||
|
|
||||||
|
@main_context_manager.writer
|
||||||
def dnsdomain_register_for_project(context, fqdomain, project):
|
def dnsdomain_register_for_project(context, fqdomain, project):
|
||||||
session = get_session()
|
domain_ref = _dnsdomain_get_or_create(context, fqdomain)
|
||||||
with session.begin():
|
domain_ref.scope = 'public'
|
||||||
domain_ref = _dnsdomain_get_or_create(context, session, fqdomain)
|
domain_ref.project_id = project
|
||||||
domain_ref.scope = 'public'
|
context.session.add(domain_ref)
|
||||||
domain_ref.project_id = project
|
|
||||||
session.add(domain_ref)
|
|
||||||
|
|
||||||
|
|
||||||
|
@main_context_manager.writer
|
||||||
def dnsdomain_unregister(context, fqdomain):
|
def dnsdomain_unregister(context, fqdomain):
|
||||||
model_query(context, models.DNSDomain).\
|
model_query(context, models.DNSDomain).\
|
||||||
filter_by(domain=fqdomain).\
|
filter_by(domain=fqdomain).\
|
||||||
delete()
|
delete()
|
||||||
|
|
||||||
|
|
||||||
|
@main_context_manager.reader
|
||||||
def dnsdomain_get_all(context):
|
def dnsdomain_get_all(context):
|
||||||
return model_query(context, models.DNSDomain, read_deleted="no").all()
|
return model_query(context, models.DNSDomain, read_deleted="no").all()
|
||||||
|
|
||||||
@ -3797,17 +3794,16 @@ def reservation_expire(context):
|
|||||||
###################
|
###################
|
||||||
|
|
||||||
|
|
||||||
def _ec2_volume_get_query(context, session=None):
|
def _ec2_volume_get_query(context):
|
||||||
return model_query(context, models.VolumeIdMapping,
|
return model_query(context, models.VolumeIdMapping, read_deleted='yes')
|
||||||
session=session, read_deleted='yes')
|
|
||||||
|
|
||||||
|
|
||||||
def _ec2_snapshot_get_query(context, session=None):
|
def _ec2_snapshot_get_query(context):
|
||||||
return model_query(context, models.SnapshotIdMapping,
|
return model_query(context, models.SnapshotIdMapping, read_deleted='yes')
|
||||||
session=session, read_deleted='yes')
|
|
||||||
|
|
||||||
|
|
||||||
@require_context
|
@require_context
|
||||||
|
@main_context_manager.writer
|
||||||
def ec2_volume_create(context, volume_uuid, id=None):
|
def ec2_volume_create(context, volume_uuid, id=None):
|
||||||
"""Create ec2 compatible volume by provided uuid."""
|
"""Create ec2 compatible volume by provided uuid."""
|
||||||
ec2_volume_ref = models.VolumeIdMapping()
|
ec2_volume_ref = models.VolumeIdMapping()
|
||||||
@ -3815,12 +3811,13 @@ def ec2_volume_create(context, volume_uuid, id=None):
|
|||||||
if id is not None:
|
if id is not None:
|
||||||
ec2_volume_ref.update({'id': id})
|
ec2_volume_ref.update({'id': id})
|
||||||
|
|
||||||
ec2_volume_ref.save()
|
ec2_volume_ref.save(context.session)
|
||||||
|
|
||||||
return ec2_volume_ref
|
return ec2_volume_ref
|
||||||
|
|
||||||
|
|
||||||
@require_context
|
@require_context
|
||||||
|
@main_context_manager.reader
|
||||||
def ec2_volume_get_by_uuid(context, volume_uuid):
|
def ec2_volume_get_by_uuid(context, volume_uuid):
|
||||||
result = _ec2_volume_get_query(context).\
|
result = _ec2_volume_get_query(context).\
|
||||||
filter_by(uuid=volume_uuid).\
|
filter_by(uuid=volume_uuid).\
|
||||||
@ -3833,6 +3830,7 @@ def ec2_volume_get_by_uuid(context, volume_uuid):
|
|||||||
|
|
||||||
|
|
||||||
@require_context
|
@require_context
|
||||||
|
@main_context_manager.reader
|
||||||
def ec2_volume_get_by_id(context, volume_id):
|
def ec2_volume_get_by_id(context, volume_id):
|
||||||
result = _ec2_volume_get_query(context).\
|
result = _ec2_volume_get_query(context).\
|
||||||
filter_by(id=volume_id).\
|
filter_by(id=volume_id).\
|
||||||
@ -3845,6 +3843,7 @@ def ec2_volume_get_by_id(context, volume_id):
|
|||||||
|
|
||||||
|
|
||||||
@require_context
|
@require_context
|
||||||
|
@main_context_manager.writer
|
||||||
def ec2_snapshot_create(context, snapshot_uuid, id=None):
|
def ec2_snapshot_create(context, snapshot_uuid, id=None):
|
||||||
"""Create ec2 compatible snapshot by provided uuid."""
|
"""Create ec2 compatible snapshot by provided uuid."""
|
||||||
ec2_snapshot_ref = models.SnapshotIdMapping()
|
ec2_snapshot_ref = models.SnapshotIdMapping()
|
||||||
@ -3852,12 +3851,13 @@ def ec2_snapshot_create(context, snapshot_uuid, id=None):
|
|||||||
if id is not None:
|
if id is not None:
|
||||||
ec2_snapshot_ref.update({'id': id})
|
ec2_snapshot_ref.update({'id': id})
|
||||||
|
|
||||||
ec2_snapshot_ref.save()
|
ec2_snapshot_ref.save(context.session)
|
||||||
|
|
||||||
return ec2_snapshot_ref
|
return ec2_snapshot_ref
|
||||||
|
|
||||||
|
|
||||||
@require_context
|
@require_context
|
||||||
|
@main_context_manager.reader
|
||||||
def ec2_snapshot_get_by_ec2_id(context, ec2_id):
|
def ec2_snapshot_get_by_ec2_id(context, ec2_id):
|
||||||
result = _ec2_snapshot_get_query(context).\
|
result = _ec2_snapshot_get_query(context).\
|
||||||
filter_by(id=ec2_id).\
|
filter_by(id=ec2_id).\
|
||||||
@ -3870,6 +3870,7 @@ def ec2_snapshot_get_by_ec2_id(context, ec2_id):
|
|||||||
|
|
||||||
|
|
||||||
@require_context
|
@require_context
|
||||||
|
@main_context_manager.reader
|
||||||
def ec2_snapshot_get_by_uuid(context, snapshot_uuid):
|
def ec2_snapshot_get_by_uuid(context, snapshot_uuid):
|
||||||
result = _ec2_snapshot_get_query(context).\
|
result = _ec2_snapshot_get_query(context).\
|
||||||
filter_by(uuid=snapshot_uuid).\
|
filter_by(uuid=snapshot_uuid).\
|
||||||
|
Loading…
Reference in New Issue
Block a user