Rename scalar relationships to use singular names
Each reservation can only be linked with a single instance reservation or compute host reservation (both are declared with uselist=False). It makes more sense to name them with a singular form. This has no impact on table names. Change-Id: Ifea01e4b5eb9f7fc26cbcfc88d4059abaf0a5aa7
This commit is contained in:
parent
29d28fe82f
commit
55ff47254d
|
@ -84,16 +84,16 @@ class Reservation(mb.BlazarBase):
|
|||
server_default=sa.false())
|
||||
resources_changed = sa.Column(sa.Boolean, nullable=False,
|
||||
server_default=sa.false())
|
||||
instance_reservations = relationship('InstanceReservations',
|
||||
uselist=False,
|
||||
cascade='all,delete',
|
||||
backref='reservation',
|
||||
lazy='joined')
|
||||
computehost_reservations = relationship('ComputeHostReservation',
|
||||
uselist=False,
|
||||
cascade="all,delete",
|
||||
backref='reservation',
|
||||
lazy='joined')
|
||||
instance_reservation = relationship('InstanceReservations',
|
||||
uselist=False,
|
||||
cascade='all,delete',
|
||||
backref='reservation',
|
||||
lazy='joined')
|
||||
computehost_reservation = relationship('ComputeHostReservation',
|
||||
uselist=False,
|
||||
cascade="all,delete",
|
||||
backref='reservation',
|
||||
lazy='joined')
|
||||
computehost_allocations = relationship('ComputeHostAllocation',
|
||||
uselist=True,
|
||||
cascade="all,delete",
|
||||
|
@ -103,9 +103,9 @@ class Reservation(mb.BlazarBase):
|
|||
def to_dict(self):
|
||||
d = super(Reservation, self).to_dict()
|
||||
|
||||
if self.computehost_reservations:
|
||||
if self.computehost_reservation:
|
||||
|
||||
res = self.computehost_reservations.to_dict()
|
||||
res = self.computehost_reservation.to_dict()
|
||||
d['hypervisor_properties'] = res['hypervisor_properties']
|
||||
d['resource_properties'] = res['resource_properties']
|
||||
d['before_end'] = res['before_end']
|
||||
|
@ -118,11 +118,11 @@ class Reservation(mb.BlazarBase):
|
|||
e = "Invalid count range: {0}".format(res['count_range'])
|
||||
raise RuntimeError(e)
|
||||
|
||||
if self.instance_reservations:
|
||||
if self.instance_reservation:
|
||||
ir_keys = ['vcpus', 'memory_mb', 'disk_gb', 'amount', 'affinity',
|
||||
'flavor_id', 'aggregate_id', 'server_group_id',
|
||||
'resource_properties']
|
||||
d.update(self.instance_reservations.to_dict(include=ir_keys))
|
||||
d.update(self.instance_reservation.to_dict(include=ir_keys))
|
||||
|
||||
return d
|
||||
|
||||
|
|
|
@ -79,7 +79,7 @@ class VirtualInstancePlugin(base.BasePlugin, nova.NovaClientWrapper):
|
|||
|
||||
def max_usages(self, host, reservations):
|
||||
def resource_usage_by_event(event, resource_type):
|
||||
return event['reservation']['instance_reservations'][resource_type]
|
||||
return event['reservation']['instance_reservation'][resource_type]
|
||||
|
||||
events_list = []
|
||||
for r in reservations:
|
||||
|
|
|
@ -110,7 +110,7 @@ def _create_physical_lease(values=_get_fake_phys_lease_values(),
|
|||
'reservation_id': reservation['id']
|
||||
}
|
||||
db_api.host_allocation_create(allocation_values)
|
||||
computehost_reservations = {
|
||||
computehost_reservation = {
|
||||
'id': _get_fake_random_uuid(),
|
||||
'reservation_id': values['reservations'][0]['id'],
|
||||
'resource_properties': phys_res['resource_properties'],
|
||||
|
@ -118,7 +118,7 @@ def _create_physical_lease(values=_get_fake_phys_lease_values(),
|
|||
'count_range': "{0} - {1}".format(phys_res['min'],
|
||||
phys_res['max'])
|
||||
}
|
||||
db_api.host_reservation_create(computehost_reservations)
|
||||
db_api.host_reservation_create(computehost_reservation)
|
||||
return lease
|
||||
|
||||
|
||||
|
|
|
@ -394,11 +394,11 @@ class TestVirtualInstancePlugin(tests.TestCase):
|
|||
reservations = [
|
||||
{
|
||||
'lease_id': 'lease-1',
|
||||
'instance_reservations': {
|
||||
'instance_reservation': {
|
||||
'vcpus': 2, 'memory_mb': 3072, 'disk_gb': 20}},
|
||||
{
|
||||
'lease_id': 'lease-2',
|
||||
'instance_reservations': {
|
||||
'instance_reservation': {
|
||||
'vcpus': 3, 'memory_mb': 2048, 'disk_gb': 30}}
|
||||
]
|
||||
|
||||
|
@ -427,11 +427,11 @@ class TestVirtualInstancePlugin(tests.TestCase):
|
|||
reservations = [
|
||||
{
|
||||
'lease_id': 'lease-1',
|
||||
'instance_reservations': {
|
||||
'instance_reservation': {
|
||||
'vcpus': 2, 'memory_mb': 3072, 'disk_gb': 20}},
|
||||
{
|
||||
'lease_id': 'lease-2',
|
||||
'instance_reservations': {
|
||||
'instance_reservation': {
|
||||
'vcpus': 3, 'memory_mb': 2048, 'disk_gb': 30}},
|
||||
]
|
||||
|
||||
|
@ -455,11 +455,11 @@ class TestVirtualInstancePlugin(tests.TestCase):
|
|||
reservations = [
|
||||
{
|
||||
'lease_id': 'lease-1',
|
||||
'instance_reservations': {
|
||||
'instance_reservation': {
|
||||
'vcpus': 2, 'memory_mb': 3072, 'disk_gb': 20}},
|
||||
{
|
||||
'lease_id': 'lease-1',
|
||||
'instance_reservations': {
|
||||
'instance_reservation': {
|
||||
'vcpus': 3, 'memory_mb': 2048, 'disk_gb': 30}},
|
||||
]
|
||||
|
||||
|
@ -493,15 +493,15 @@ class TestVirtualInstancePlugin(tests.TestCase):
|
|||
reservations = [
|
||||
{
|
||||
'lease_id': 'lease-1',
|
||||
'instance_reservations': {
|
||||
'instance_reservation': {
|
||||
'vcpus': 2, 'memory_mb': 3072, 'disk_gb': 20}},
|
||||
{
|
||||
'lease_id': 'lease-2',
|
||||
'instance_reservations': {
|
||||
'instance_reservation': {
|
||||
'vcpus': 1, 'memory_mb': 1024, 'disk_gb': 10}},
|
||||
{
|
||||
'lease_id': 'lease-3',
|
||||
'instance_reservations': {
|
||||
'instance_reservation': {
|
||||
'vcpus': 4, 'memory_mb': 2048, 'disk_gb': 40
|
||||
}},
|
||||
]
|
||||
|
|
Loading…
Reference in New Issue