59
58
cfg.StrOpt('instance_name_template',
60
59
default='instance-%08x',
61
60
help='Template string to be used to generate instance names'),
62
cfg.StrOpt('volume_name_template',
64
help='Template string to be used to generate instance names'),
65
61
cfg.StrOpt('snapshot_name_template',
66
62
default='snapshot-%s',
67
63
help='Template string to be used to generate snapshot names'),
71
FLAGS.register_opts(db_opts)
67
CONF.register_opts(db_opts)
73
69
IMPL = utils.LazyPluggable('db_backend',
74
70
sqlalchemy='nova.db.sqlalchemy.api')
626
620
return IMPL.instance_get_all_by_host(context, host)
623
def instance_get_all_by_host_and_node(context, host, node):
624
"""Get all instances belonging to a node."""
625
return IMPL.instance_get_all_by_host_and_node(context, host, node)
629
628
def instance_get_all_by_host_and_not_type(context, host, type_id=None):
630
629
"""Get all instances belonging to a host with a different type_id."""
631
630
return IMPL.instance_get_all_by_host_and_not_type(context, host, type_id)
800
794
return IMPL.network_delete_safe(context, network_id)
803
def network_create_fixed_ips(context, network_id, num_vpn_clients):
804
"""Create the ips for the network, reserving sepecified ips."""
805
return IMPL.network_create_fixed_ips(context, network_id, num_vpn_clients)
808
797
def network_disassociate(context, network_id):
809
798
"""Disassociate the network from project or raise if it does not exist."""
810
799
return IMPL.network_disassociate(context, network_id)
865
854
return IMPL.network_get_all_by_host(context, host)
868
def network_get_index(context, network_id):
869
"""Get non-conflicting index for network."""
870
return IMPL.network_get_index(context, network_id)
873
def network_set_cidr(context, network_id, cidr):
874
"""Set the Classless Inner Domain Routing for the network."""
875
return IMPL.network_set_cidr(context, network_id, cidr)
878
857
def network_set_host(context, network_id, host_id):
879
858
"""Safely set the host for network."""
880
859
return IMPL.network_set_host(context, network_id, host_id)
959
933
return IMPL.quota_class_update(context, class_name, resource, limit)
962
def quota_class_destroy(context, class_name, resource):
963
"""Destroy the quota class or raise if it does not exist."""
964
return IMPL.quota_class_destroy(context, class_name, resource)
967
def quota_class_destroy_all_by_name(context, class_name):
968
"""Destroy all quotas associated with a given quota class."""
969
return IMPL.quota_class_destroy_all_by_name(context, class_name)
972
936
###################
975
def quota_usage_create(context, project_id, resource, in_use, reserved,
977
"""Create a quota usage for the given project and resource."""
978
return IMPL.quota_usage_create(context, project_id, resource,
979
in_use, reserved, until_refresh)
982
939
def quota_usage_get(context, project_id, resource):
983
940
"""Retrieve a quota usage or raise if it does not exist."""
984
941
return IMPL.quota_usage_get(context, project_id, resource)
989
946
return IMPL.quota_usage_get_all_by_project(context, project_id)
992
def quota_usage_update(context, project_id, resource, in_use, reserved,
949
def quota_usage_update(context, project_id, resource, **kwargs):
994
950
"""Update a quota usage or raise if it does not exist."""
995
return IMPL.quota_usage_update(context, project_id, resource,
996
in_use, reserved, until_refresh)
999
def quota_usage_destroy(context, project_id, resource):
1000
"""Destroy the quota usage or raise if it does not exist."""
1001
return IMPL.quota_usage_destroy(context, project_id, resource)
951
return IMPL.quota_usage_update(context, project_id, resource, **kwargs)
1004
954
###################
1059
1004
###################
1062
def volume_allocate_iscsi_target(context, volume_id, host):
1063
"""Atomically allocate a free iscsi_target from the pool."""
1064
return IMPL.volume_allocate_iscsi_target(context, volume_id, host)
1067
def volume_attached(context, volume_id, instance_id, mountpoint):
1068
"""Ensure that a volume is set as attached."""
1069
return IMPL.volume_attached(context, volume_id, instance_id, mountpoint)
1072
def volume_create(context, values):
1073
"""Create a volume from the values dictionary."""
1074
return IMPL.volume_create(context, values)
1077
def volume_data_get_for_project(context, project_id, session=None):
1078
"""Get (volume_count, gigabytes) for project."""
1079
return IMPL.volume_data_get_for_project(context, project_id,
1083
def volume_destroy(context, volume_id):
1084
"""Destroy the volume or raise if it does not exist."""
1085
return IMPL.volume_destroy(context, volume_id)
1088
def volume_detached(context, volume_id):
1089
"""Ensure that a volume is set as detached."""
1090
return IMPL.volume_detached(context, volume_id)
1093
def volume_get(context, volume_id):
1094
"""Get a volume or raise if it does not exist."""
1095
return IMPL.volume_get(context, volume_id)
1098
def volume_get_all(context):
1099
"""Get all volumes."""
1100
return IMPL.volume_get_all(context)
1103
def volume_get_all_by_host(context, host):
1104
"""Get all volumes belonging to a host."""
1105
return IMPL.volume_get_all_by_host(context, host)
1108
def volume_get_all_by_instance_uuid(context, instance_uuid):
1109
"""Get all volumes belonging to an instance."""
1110
return IMPL.volume_get_all_by_instance_uuid(context, instance_uuid)
1113
def volume_get_all_by_project(context, project_id):
1114
"""Get all volumes belonging to a project."""
1115
return IMPL.volume_get_all_by_project(context, project_id)
1118
def volume_get_by_ec2_id(context, ec2_id):
1119
"""Get a volume by ec2 id."""
1120
return IMPL.volume_get_by_ec2_id(context, ec2_id)
1123
1007
def volume_get_iscsi_target_num(context, volume_id):
1124
1008
"""Get the target num (tid) allocated to the volume."""
1125
1009
return IMPL.volume_get_iscsi_target_num(context, volume_id)
1128
def volume_update(context, volume_id, values):
1129
"""Set the given properties on a volume and update it.
1131
Raises NotFound if volume does not exist.
1134
return IMPL.volume_update(context, volume_id, values)
1137
1012
def get_ec2_volume_id_by_uuid(context, volume_id):
1138
1013
return IMPL.get_ec2_volume_id_by_uuid(context, volume_id)
1161
1036
####################
1164
def snapshot_create(context, values):
1165
"""Create a snapshot from the values dictionary."""
1166
return IMPL.snapshot_create(context, values)
1169
def snapshot_destroy(context, snapshot_id):
1170
"""Destroy the snapshot or raise if it does not exist."""
1171
return IMPL.snapshot_destroy(context, snapshot_id)
1174
def snapshot_get(context, snapshot_id):
1175
"""Get a snapshot or raise if it does not exist."""
1176
return IMPL.snapshot_get(context, snapshot_id)
1179
def snapshot_get_all(context):
1180
"""Get all snapshots."""
1181
return IMPL.snapshot_get_all(context)
1184
def snapshot_get_all_by_project(context, project_id):
1185
"""Get all snapshots belonging to a project."""
1186
return IMPL.snapshot_get_all_by_project(context, project_id)
1189
def snapshot_get_all_for_volume(context, volume_id):
1190
"""Get all snapshots for a volume."""
1191
return IMPL.snapshot_get_all_for_volume(context, volume_id)
1194
def snapshot_update(context, snapshot_id, values):
1195
"""Set the given properties on a snapshot and update it.
1197
Raises NotFound if snapshot does not exist.
1200
return IMPL.snapshot_update(context, snapshot_id, values)
1203
####################
1206
1039
def block_device_mapping_create(context, values):
1207
1040
"""Create an entry of block device mapping"""
1208
1041
return IMPL.block_device_mapping_create(context, values)
1500
1333
return IMPL.instance_system_metadata_get(context, instance_uuid)
1503
def instance_system_metadata_delete(context, instance_uuid, key):
1504
"""Delete the given system metadata item."""
1505
IMPL.instance_system_metadata_delete(context, instance_uuid, key)
1508
1336
def instance_system_metadata_update(context, instance_uuid, metadata, delete):
1509
1337
"""Update metadata if it exists, otherwise create it."""
1510
1338
IMPL.instance_system_metadata_update(
1543
1371
####################
1374
def bw_usage_get(context, uuid, start_period, mac):
1375
"""Return bw usage for instance and mac in a given audit period."""
1376
return IMPL.bw_usage_get(context, uuid, start_period, mac)
1546
1379
def bw_usage_get_by_uuids(context, uuids, start_period):
1547
1380
"""Return bw usages for instance(s) in a given audit period."""
1548
1381
return IMPL.bw_usage_get_by_uuids(context, uuids, start_period)
1551
1384
def bw_usage_update(context, uuid, mac, start_period, bw_in, bw_out,
1552
last_refreshed=None):
1385
last_ctr_in, last_ctr_out, last_refreshed=None):
1553
1386
"""Update cached bandwidth usage for an instance's network based on mac
1554
1387
address. Creates new record if needed.
1556
1389
return IMPL.bw_usage_update(context, uuid, mac, start_period, bw_in,
1557
bw_out, last_refreshed=last_refreshed)
1390
bw_out, last_ctr_in, last_ctr_out, last_refreshed=last_refreshed)
1560
1393
####################
1584
def volume_metadata_get(context, volume_id):
1585
"""Get all metadata for a volume."""
1586
return IMPL.volume_metadata_get(context, volume_id)
1589
def volume_metadata_delete(context, volume_id, key):
1590
"""Delete the given metadata item."""
1591
IMPL.volume_metadata_delete(context, volume_id, key)
1594
def volume_metadata_update(context, volume_id, metadata, delete):
1595
"""Update metadata if it exists, otherwise create it."""
1596
IMPL.volume_metadata_update(context, volume_id, metadata, delete)
1602
def volume_type_create(context, values):
1603
"""Create a new volume type."""
1604
return IMPL.volume_type_create(context, values)
1607
def volume_type_get_all(context, inactive=False):
1608
"""Get all volume types."""
1609
return IMPL.volume_type_get_all(context, inactive)
1612
def volume_type_get(context, id):
1613
"""Get volume type by id."""
1614
return IMPL.volume_type_get(context, id)
1617
def volume_type_get_by_name(context, name):
1618
"""Get volume type by name."""
1619
return IMPL.volume_type_get_by_name(context, name)
1622
def volume_type_destroy(context, name):
1623
"""Delete a volume type."""
1624
return IMPL.volume_type_destroy(context, name)
1627
def volume_get_active_by_window(context, begin, end=None, project_id=None):
1628
"""Get all the volumes inside the window.
1630
Specifying a project_id will filter for a certain project."""
1631
return IMPL.volume_get_active_by_window(context, begin, end, project_id)
1634
####################
1637
def volume_type_extra_specs_get(context, volume_type_id):
1638
"""Get all extra specs for a volume type."""
1639
return IMPL.volume_type_extra_specs_get(context, volume_type_id)
1642
def volume_type_extra_specs_delete(context, volume_type_id, key):
1643
"""Delete the given extra specs item."""
1644
IMPL.volume_type_extra_specs_delete(context, volume_type_id, key)
1647
def volume_type_extra_specs_update_or_create(context, volume_type_id,
1649
"""Create or update volume type extra specs. This adds or modifies the
1650
key/value pairs specified in the extra specs dict argument"""
1651
IMPL.volume_type_extra_specs_update_or_create(context, volume_type_id,
1655
1414
###################
1673
1432
####################
1676
def sm_backend_conf_create(context, values):
1677
"""Create a new SM Backend Config entry."""
1678
return IMPL.sm_backend_conf_create(context, values)
1681
def sm_backend_conf_update(context, sm_backend_conf_id, values):
1682
"""Update a SM Backend Config entry."""
1683
return IMPL.sm_backend_conf_update(context, sm_backend_conf_id, values)
1686
def sm_backend_conf_delete(context, sm_backend_conf_id):
1687
"""Delete a SM Backend Config."""
1688
return IMPL.sm_backend_conf_delete(context, sm_backend_conf_id)
1691
def sm_backend_conf_get(context, sm_backend_conf_id):
1692
"""Get a specific SM Backend Config."""
1693
return IMPL.sm_backend_conf_get(context, sm_backend_conf_id)
1696
def sm_backend_conf_get_by_sr(context, sr_uuid):
1697
"""Get a specific SM Backend Config."""
1698
return IMPL.sm_backend_conf_get_by_sr(context, sr_uuid)
1701
def sm_backend_conf_get_all(context):
1702
"""Get all SM Backend Configs."""
1703
return IMPL.sm_backend_conf_get_all(context)
1706
####################
1709
def sm_flavor_create(context, values):
1710
"""Create a new SM Flavor entry."""
1711
return IMPL.sm_flavor_create(context, values)
1714
def sm_flavor_update(context, sm_flavor_id, values):
1715
"""Update a SM Flavor entry."""
1716
return IMPL.sm_flavor_update(context, sm_flavor_id, values)
1719
def sm_flavor_delete(context, sm_flavor_id):
1720
"""Delete a SM Flavor."""
1721
return IMPL.sm_flavor_delete(context, sm_flavor_id)
1724
def sm_flavor_get(context, sm_flavor_id):
1725
"""Get a specific SM Flavor."""
1726
return IMPL.sm_flavor_get(context, sm_flavor_id)
1729
def sm_flavor_get_all(context):
1730
"""Get all SM Flavors."""
1731
return IMPL.sm_flavor_get_all(context)
1734
def sm_flavor_get_by_label(context, sm_flavor_label):
1735
"""Get a specific SM Flavor given label."""
1736
return IMPL.sm_flavor_get_by_label(context, sm_flavor_label)
1739
####################
1742
def sm_volume_create(context, values):
1743
"""Create a new child Zone entry."""
1744
return IMPL.sm_volume_create(context, values)
1747
def sm_volume_update(context, volume_id, values):
1748
"""Update a child Zone entry."""
1749
return IMPL.sm_volume_update(context, values)
1752
def sm_volume_delete(context, volume_id):
1753
"""Delete a child Zone."""
1754
return IMPL.sm_volume_delete(context, volume_id)
1757
def sm_volume_get(context, volume_id):
1758
"""Get a specific child Zone."""
1759
return IMPL.sm_volume_get(context, volume_id)
1762
def sm_volume_get_all(context):
1763
"""Get all child Zones."""
1764
return IMPL.sm_volume_get_all(context)
1767
####################
1770
1435
def aggregate_create(context, values, metadata=None):
1771
1436
"""Create a new aggregate with metadata."""
1772
1437
return IMPL.aggregate_create(context, values, metadata)