300
300
primaryjoin=instance_id == Instance.uuid)
303
class InstanceActions(BASE, NovaBase):
304
"""Represents a guest VM's actions and results"""
305
__tablename__ = "instance_actions"
306
id = Column(Integer, primary_key=True)
307
instance_uuid = Column(String(36), ForeignKey('instances.uuid'))
308
action = Column(String(255))
312
303
class InstanceTypes(BASE, NovaBase):
313
304
"""Represent possible instance_types or flavor of VM offered"""
314
305
__tablename__ = "instance_types"
335
326
class Volume(BASE, NovaBase):
336
327
"""Represents a block storage device that can be attached to a vm."""
337
328
__tablename__ = 'volumes'
338
id = Column(Integer, primary_key=True, autoincrement=True)
329
id = Column(String(36), primary_key=True)
342
333
return FLAGS.volume_name_template % self.id
335
ec2_id = Column(Integer)
344
336
user_id = Column(String(255))
345
337
project_id = Column(String(255))
347
snapshot_id = Column(String(255))
339
snapshot_id = Column(String(36))
349
341
host = Column(String(255)) # , ForeignKey('hosts.id'))
350
342
size = Column(Integer)
351
343
availability_zone = Column(String(255)) # TODO(vish): foreign key?
352
instance_id = Column(Integer, ForeignKey('instances.id'), nullable=True)
353
instance = relationship(Instance,
354
backref=backref('volumes'),
355
foreign_keys=instance_id,
356
primaryjoin='and_(Volume.instance_id==Instance.id,'
357
'Volume.deleted==False)')
344
instance_uuid = Column(String(36))
358
345
mountpoint = Column(String(255))
359
346
attach_time = Column(String(255)) # TODO(vish): datetime
360
347
status = Column(String(255)) # TODO(vish): enum?
379
366
id = Column(Integer, primary_key=True)
380
367
key = Column(String(255))
381
368
value = Column(String(255))
382
volume_id = Column(Integer, ForeignKey('volumes.id'), nullable=False)
369
volume_id = Column(String(36), ForeignKey('volumes.id'), nullable=False)
383
370
volume = relationship(Volume, backref="volume_metadata",
384
371
foreign_keys=volume_id,
385
372
primaryjoin='and_('
419
406
class Quota(BASE, NovaBase):
420
407
"""Represents a single quota override for a project.
422
If there is no row for a given project id and resource, then
423
the default for the deployment is used. If the row is present
424
but the hard limit is Null, then the resource is unlimited.
409
If there is no row for a given project id and resource, then the
410
default for the quota class is used. If there is no row for a
411
given quota class and resource, then the default for the
412
deployment is used. If the row is present but the hard limit is
413
Null, then the resource is unlimited.
427
416
__tablename__ = 'quotas'
433
422
hard_limit = Column(Integer, nullable=True)
425
class QuotaClass(BASE, NovaBase):
426
"""Represents a single quota override for a quota class.
428
If there is no row for a given quota class and resource, then the
429
default for the deployment is used. If the row is present but the
430
hard limit is Null, then the resource is unlimited.
433
__tablename__ = 'quota_classes'
434
id = Column(Integer, primary_key=True)
436
class_name = Column(String(255), index=True)
438
resource = Column(String(255))
439
hard_limit = Column(Integer, nullable=True)
442
class QuotaUsage(BASE, NovaBase):
443
"""Represents the current usage for a given resource."""
445
__tablename__ = 'quota_usages'
446
id = Column(Integer, primary_key=True)
448
project_id = Column(String(255), index=True)
449
resource = Column(String(255))
451
in_use = Column(Integer)
452
reserved = Column(Integer)
456
return self.in_use + self.reserved
458
until_refresh = Column(Integer, nullable=True)
461
class Reservation(BASE, NovaBase):
462
"""Represents a resource reservation for quotas."""
464
__tablename__ = 'reservations'
465
id = Column(Integer, primary_key=True)
466
uuid = Column(String(36), nullable=False)
468
usage_id = Column(Integer, ForeignKey('quota_usages.id'), nullable=False)
469
usage = relationship(QuotaUsage,
470
backref=backref('reservations'),
471
foreign_keys=usage_id,
473
'Reservation.usage_id == QuotaUsage.id,'
474
'Reservation.deleted == False)')
476
project_id = Column(String(255), index=True)
477
resource = Column(String(255))
479
delta = Column(Integer)
480
expire = Column(DateTime, nullable=False)
436
483
class Snapshot(BASE, NovaBase):
437
484
"""Represents a block storage device that can be attached to a vm."""
438
485
__tablename__ = 'snapshots'
439
id = Column(Integer, primary_key=True, autoincrement=True)
486
id = Column(String(36), primary_key=True)
449
496
user_id = Column(String(255))
450
497
project_id = Column(String(255))
452
volume_id = Column(Integer)
499
volume_id = Column(String(36))
453
500
status = Column(String(255))
454
501
progress = Column(String(255))
455
502
volume_size = Column(Integer)
463
510
__tablename__ = "block_device_mapping"
464
511
id = Column(Integer, primary_key=True, autoincrement=True)
466
instance_id = Column(Integer, ForeignKey('instances.id'), nullable=False)
513
instance_uuid = Column(Integer, ForeignKey('instances.uuid'),
467
515
instance = relationship(Instance,
468
516
backref=backref('balock_device_mapping'),
469
foreign_keys=instance_id,
470
primaryjoin='and_(BlockDeviceMapping.instance_id=='
517
foreign_keys=instance_uuid,
518
primaryjoin='and_(BlockDeviceMapping.'
472
521
'BlockDeviceMapping.deleted=='
474
523
device_name = Column(String(255), nullable=False)
482
531
# for ephemeral device
483
532
virtual_name = Column(String(255), nullable=True)
485
# for snapshot or volume
486
snapshot_id = Column(Integer, ForeignKey('snapshots.id'), nullable=True)
488
snapshot = relationship(Snapshot,
489
foreign_keys=snapshot_id)
534
snapshot_id = Column(String(36))
491
volume_id = Column(Integer, ForeignKey('volumes.id'), nullable=True)
492
volume = relationship(Volume,
493
foreign_keys=volume_id)
536
volume_id = Column(String(36), nullable=True)
494
537
volume_size = Column(Integer, nullable=True)
496
539
# for no device to suppress devices.
507
550
id = Column(Integer, primary_key=True)
508
551
target_num = Column(Integer)
509
552
host = Column(String(255))
510
volume_id = Column(Integer, ForeignKey('volumes.id'), nullable=True)
553
volume_id = Column(String(36), ForeignKey('volumes.id'), nullable=True)
511
554
volume = relationship(Volume,
512
555
backref=backref('iscsi_target', uselist=False),
513
556
foreign_keys=volume_id,
811
854
class InstanceMetadata(BASE, NovaBase):
812
"""Represents a metadata key/value pair for an instance"""
855
"""Represents a user-provided metadata key/value pair for an instance"""
813
856
__tablename__ = 'instance_metadata'
814
857
id = Column(Integer, primary_key=True)
815
858
key = Column(String(255))
822
865
'InstanceMetadata.deleted == False)')
868
class InstanceSystemMetadata(BASE, NovaBase):
869
"""Represents a system-owned metadata key/value pair for an instance"""
870
__tablename__ = 'instance_system_metadata'
871
id = Column(Integer, primary_key=True)
872
key = Column(String(255))
873
value = Column(String(255))
874
instance_uuid = Column(String(36),
875
ForeignKey('instances.uuid'),
878
primary_join = ('and_(InstanceSystemMetadata.instance_uuid == '
879
'Instance.uuid, InstanceSystemMetadata.deleted == False)')
880
instance = relationship(Instance, backref="system_metadata",
881
foreign_keys=instance_uuid,
882
primaryjoin=primary_join)
825
885
class InstanceTypeExtraSpecs(BASE, NovaBase):
826
886
"""Represents additional specs as key/value pairs for an instance_type"""
827
887
__tablename__ = 'instance_type_extra_specs'
926
986
"""Cache for instance bandwidth usage data pulled from the hypervisor"""
927
987
__tablename__ = 'bw_usage_cache'
928
988
id = Column(Integer, primary_key=True, nullable=False)
989
uuid = Column(String(36), nullable=False)
929
990
mac = Column(String(255), nullable=False)
930
991
start_period = Column(DateTime, nullable=False)
931
992
last_refreshed = Column(DateTime)
940
1001
uuid = Column(String(36), nullable=False)
1004
class VolumeIdMapping(BASE, NovaBase):
1005
"""Compatability layer for the EC2 volume service"""
1006
__tablename__ = 'volume_id_mappings'
1007
id = Column(Integer, primary_key=True, nullable=False, autoincrement=True)
1008
uuid = Column(String(36), nullable=False)
1011
class SnapshotIdMapping(BASE, NovaBase):
1012
"""Compatability layer for the EC2 snapshot service"""
1013
__tablename__ = 'snapshot_id_mappings'
1014
id = Column(Integer, primary_key=True, nullable=False, autoincrement=True)
1015
uuid = Column(String(36), nullable=False)
943
1018
class SMFlavors(BASE, NovaBase):
944
1019
"""Represents a flavor for SM volumes."""
945
1020
__tablename__ = 'sm_flavors'
961
1036
class SMVolume(BASE, NovaBase):
962
1037
__tablename__ = 'sm_volume'
963
id = Column(Integer(), ForeignKey(Volume.id), primary_key=True)
1038
id = Column(String(36), ForeignKey(Volume.id), primary_key=True)
964
1039
backend_id = Column(Integer, ForeignKey('sm_backend_config.id'),
966
1041
vdi_uuid = Column(String(255))