15
15
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
16
16
# License for the specific language governing permissions and limitations
17
17
# under the License.
19
Defines interface for DB access.
19
"""Defines interface for DB access.
21
21
The underlying driver is loaded as a :class:`LazyPluggable`.
88
89
def service_get_by_host_and_topic(context, host, topic):
89
"""Get a service by host it's on and topic it listens to"""
90
"""Get a service by host it's on and topic it listens to."""
90
91
return IMPL.service_get_by_host_and_topic(context, host, topic)
113
114
def service_get_all_compute_sorted(context):
114
115
"""Get all compute services sorted by instance count.
116
Returns a list of (Service, instance_count) tuples.
117
:returns: a list of (Service, instance_count) tuples.
119
120
return IMPL.service_get_all_compute_sorted(context)
122
123
def service_get_all_network_sorted(context):
123
124
"""Get all network services sorted by network count.
125
Returns a list of (Service, network_count) tuples.
126
:returns: a list of (Service, network_count) tuples.
128
129
return IMPL.service_get_all_network_sorted(context)
131
132
def service_get_all_volume_sorted(context):
132
133
"""Get all volume services sorted by volume count.
134
Returns a list of (Service, volume_count) tuples.
135
:returns: a list of (Service, volume_count) tuples.
137
138
return IMPL.service_get_all_volume_sorted(context)
243
244
def floating_ip_deallocate(context, address):
244
"""Deallocate an floating ip by address"""
245
"""Deallocate an floating ip by address."""
245
246
return IMPL.floating_ip_deallocate(context, address)
253
254
def floating_ip_disassociate(context, address):
254
255
"""Disassociate an floating ip from a fixed ip by address.
256
Returns the address of the existing fixed ip.
257
:returns: the address of the existing fixed ip.
259
260
return IMPL.floating_ip_disassociate(context, address)
291
292
return IMPL.floating_ip_update(context, address, values)
295
def floating_ip_set_auto_assigned(context, address):
296
"""Set auto_assigned flag to floating ip"""
297
return IMPL.floating_ip_set_auto_assigned(context, address)
294
299
####################
296
302
def migration_update(context, id, values):
297
"""Update a migration instance"""
303
"""Update a migration instance."""
298
304
return IMPL.migration_update(context, id, values)
301
307
def migration_create(context, values):
302
"""Create a migration record"""
308
"""Create a migration record."""
303
309
return IMPL.migration_create(context, values)
306
312
def migration_get(context, migration_id):
307
"""Finds a migration by the id"""
313
"""Finds a migration by the id."""
308
314
return IMPL.migration_get(context, migration_id)
311
317
def migration_get_by_instance_and_status(context, instance_id, status):
312
"""Finds a migration by the instance id its migrating"""
318
"""Finds a migration by the instance id its migrating."""
313
319
return IMPL.migration_get_by_instance_and_status(context, instance_id,
455
461
return IMPL.instance_get_project_vpn(context, project_id)
458
def instance_is_vpn(context, instance_id):
459
"""True if instance is a vpn."""
460
return IMPL.instance_is_vpn(context, instance_id)
463
464
def instance_set_state(context, instance_id, state, description=None):
464
465
"""Set the state of an instance."""
465
466
return IMPL.instance_set_state(context, instance_id, state, description)
580
581
def network_delete_safe(context, network_id):
581
582
"""Delete network with key network_id.
582
584
This method assumes that the network is not associated with any project
584
587
return IMPL.network_delete_safe(context, network_id)
723
725
The device is not returned. If the create violates the unique
724
726
constraints because the iscsi_target and host already exist,
725
no exception is raised."""
727
no exception is raised.
726
730
return IMPL.iscsi_target_create_safe(context, values)
1052
1056
def host_get_networks(context, host):
1053
"""Return all networks for which the given host is the designated
1057
"""All networks for which the given host is the network host."""
1057
1058
return IMPL.host_get_networks(context, host)
1117
1118
def instance_type_create(context, values):
1118
"""Create a new instance type"""
1119
"""Create a new instance type."""
1119
1120
return IMPL.instance_type_create(context, values)
1122
1123
def instance_type_get_all(context, inactive=False):
1123
"""Get all instance types"""
1124
"""Get all instance types."""
1124
1125
return IMPL.instance_type_get_all(context, inactive)
1127
1128
def instance_type_get_by_id(context, id):
1128
"""Get instance type by id"""
1129
"""Get instance type by id."""
1129
1130
return IMPL.instance_type_get_by_id(context, id)
1132
1133
def instance_type_get_by_name(context, name):
1133
"""Get instance type by name"""
1134
"""Get instance type by name."""
1134
1135
return IMPL.instance_type_get_by_name(context, name)
1137
1138
def instance_type_get_by_flavor_id(context, id):
1138
"""Get instance type by name"""
1139
"""Get instance type by name."""
1139
1140
return IMPL.instance_type_get_by_flavor_id(context, id)
1142
1143
def instance_type_destroy(context, name):
1143
"""Delete a instance type"""
1144
"""Delete a instance type."""
1144
1145
return IMPL.instance_type_destroy(context, name)
1147
1148
def instance_type_purge(context, name):
1148
"""Purges (removes) an instance type from DB
1149
Use instance_type_destroy for most cases
1149
"""Purges (removes) an instance type from DB.
1151
Use instance_type_destroy for most cases
1151
1154
return IMPL.instance_type_purge(context, name)
1185
1188
def instance_metadata_get(context, instance_id):
1186
"""Get all metadata for an instance"""
1189
"""Get all metadata for an instance."""
1187
1190
return IMPL.instance_metadata_get(context, instance_id)
1190
1193
def instance_metadata_delete(context, instance_id, key):
1191
"""Delete the given metadata item"""
1194
"""Delete the given metadata item."""
1192
1195
IMPL.instance_metadata_delete(context, instance_id, key)
1195
1198
def instance_metadata_update_or_create(context, instance_id, metadata):
1196
"""Create or update instance metadata"""
1199
"""Create or update instance metadata."""
1197
1200
IMPL.instance_metadata_update_or_create(context, instance_id, metadata)