~rlane/nova/lp773690

« back to all changes in this revision

Viewing changes to nova/db/api.py

  • Committer: rlane at wikimedia
  • Date: 2011-04-29 22:30:40 UTC
  • mfrom: (382.1.655 nova)
  • Revision ID: rlane@wikimedia.org-20110429223040-i0x3ds9eqwrabyru
MergeĀ fromĀ trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
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.
18
 
"""
19
 
Defines interface for DB access.
 
18
 
 
19
"""Defines interface for DB access.
20
20
 
21
21
The underlying driver is loaded as a :class:`LazyPluggable`.
22
22
 
30
30
 
31
31
:enable_new_services:  when adding a new service to the database, is it in the
32
32
                       pool of available hardware (Default: True)
 
33
 
33
34
"""
34
35
 
35
36
from nova import exception
86
87
 
87
88
 
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)
91
92
 
92
93
 
113
114
def service_get_all_compute_sorted(context):
114
115
    """Get all compute services sorted by instance count.
115
116
 
116
 
    Returns a list of (Service, instance_count) tuples.
 
117
    :returns: a list of (Service, instance_count) tuples.
117
118
 
118
119
    """
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.
124
125
 
125
 
    Returns a list of (Service, network_count) tuples.
 
126
    :returns: a list of (Service, network_count) tuples.
126
127
 
127
128
    """
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.
133
134
 
134
 
    Returns a list of (Service, volume_count) tuples.
 
135
    :returns: a list of (Service, volume_count) tuples.
135
136
 
136
137
    """
137
138
    return IMPL.service_get_all_volume_sorted(context)
241
242
 
242
243
 
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)
246
247
 
247
248
 
253
254
def floating_ip_disassociate(context, address):
254
255
    """Disassociate an floating ip from a fixed ip by address.
255
256
 
256
 
    Returns the address of the existing fixed ip.
 
257
    :returns: the address of the existing fixed ip.
257
258
 
258
259
    """
259
260
    return IMPL.floating_ip_disassociate(context, address)
291
292
    return IMPL.floating_ip_update(context, address, values)
292
293
 
293
294
 
 
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)
 
298
 
294
299
####################
295
300
 
 
301
 
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)
299
305
 
300
306
 
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)
304
310
 
305
311
 
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)
309
315
 
310
316
 
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,
314
320
            status)
315
321
 
455
461
    return IMPL.instance_get_project_vpn(context, project_id)
456
462
 
457
463
 
458
 
def instance_is_vpn(context, instance_id):
459
 
    """True if instance is a vpn."""
460
 
    return IMPL.instance_is_vpn(context, instance_id)
461
 
 
462
 
 
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)
579
580
 
580
581
def network_delete_safe(context, network_id):
581
582
    """Delete network with key network_id.
 
583
 
582
584
    This method assumes that the network is not associated with any project
 
585
 
583
586
    """
584
587
    return IMPL.network_delete_safe(context, network_id)
585
588
 
674
677
    network if one is not found, otherwise it returns None.
675
678
 
676
679
    """
677
 
 
678
680
    return IMPL.project_get_network(context, project_id, associate)
679
681
 
680
682
 
722
724
 
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.
 
728
 
 
729
    """
726
730
    return IMPL.iscsi_target_create_safe(context, values)
727
731
 
728
732
 
1050
1054
 
1051
1055
 
1052
1056
def host_get_networks(context, host):
1053
 
    """Return all networks for which the given host is the designated
1054
 
    network host.
1055
 
 
1056
 
    """
 
1057
    """All networks for which the given host is the network host."""
1057
1058
    return IMPL.host_get_networks(context, host)
1058
1059
 
1059
1060
 
1115
1116
 
1116
1117
 
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)
1120
1121
 
1121
1122
 
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)
1125
1126
 
1126
1127
 
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)
1130
1131
 
1131
1132
 
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)
1135
1136
 
1136
1137
 
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)
1140
1141
 
1141
1142
 
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)
1145
1146
 
1146
1147
 
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.
 
1150
 
 
1151
    Use instance_type_destroy for most cases
 
1152
 
1150
1153
    """
1151
1154
    return IMPL.instance_type_purge(context, name)
1152
1155
 
1183
1186
 
1184
1187
 
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)
1188
1191
 
1189
1192
 
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)
1193
1196
 
1194
1197
 
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)