408
def migration_get_all_unconfirmed(context, confirm_window):
409
"""Finds all unconfirmed migrations within the confirmation window."""
410
return IMPL.migration_get_all_unconfirmed(context, confirm_window)
418
def migration_get_unconfirmed_by_dest_compute(context, confirm_window,
421
Finds all unconfirmed migrations within the confirmation window for
422
a specific destination compute host.
424
return IMPL.migration_get_unconfirmed_by_dest_compute(context,
425
confirm_window, dest_compute)
413
428
####################
416
def fixed_ip_associate(context, address, instance_id, network_id=None,
431
def fixed_ip_associate(context, address, instance_uuid, network_id=None,
418
433
"""Associate fixed ip to instance.
420
435
Raises if fixed ip is not available.
423
return IMPL.fixed_ip_associate(context, address, instance_id, network_id,
438
return IMPL.fixed_ip_associate(context, address, instance_uuid, network_id,
427
def fixed_ip_associate_pool(context, network_id, instance_id=None, host=None):
442
def fixed_ip_associate_pool(context, network_id, instance_uuid=None,
428
444
"""Find free ip in network and associate it to instance or host.
430
446
Raises if one is not available.
433
449
return IMPL.fixed_ip_associate_pool(context, network_id,
437
453
def fixed_ip_create(context, values):
469
485
return IMPL.fixed_ip_get_by_address(context, address)
472
def fixed_ip_get_by_instance(context, instance_id):
488
def fixed_ip_get_by_instance(context, instance_uuid):
473
489
"""Get fixed ips by instance or raise if none exist."""
474
return IMPL.fixed_ip_get_by_instance(context, instance_id)
477
def fixed_ip_get_by_network_host(context, network_id, host):
490
return IMPL.fixed_ip_get_by_instance(context, instance_uuid)
493
def fixed_ip_get_by_network_host(context, network_uuid, host):
478
494
"""Get fixed ip for a host in a network."""
479
return IMPL.fixed_ip_get_by_network_host(context, network_id, host)
495
return IMPL.fixed_ip_get_by_network_host(context, network_uuid, host)
482
498
def fixed_ips_by_virtual_interface(context, vif_id):
588
def instance_get_active_by_window(context, begin, end=None, project_id=None):
604
def instance_get_active_by_window(context, begin, end=None, project_id=None,
589
606
"""Get instances active during a certain time window.
591
Specifying a project_id will filter for a certain project."""
592
return IMPL.instance_get_active_by_window(context, begin, end, project_id)
608
Specifying a project_id will filter for a certain project.
609
Specifying a host will filter for instances on a given compute host.
611
return IMPL.instance_get_active_by_window(context, begin, end,
595
615
def instance_get_active_by_window_joined(context, begin, end=None,
616
project_id=None, host=None):
597
617
"""Get instances and joins active during a certain time window.
599
Specifying a project_id will filter for a certain project."""
619
Specifying a project_id will filter for a certain project.
620
Specifying a host will filter for instances on a given compute host.
600
622
return IMPL.instance_get_active_by_window_joined(context, begin, end,
604
626
def instance_get_all_by_project(context, project_id):
902
def auth_token_destroy(context, token_id):
903
"""Destroy an auth token."""
904
return IMPL.auth_token_destroy(context, token_id)
907
def auth_token_get(context, token_hash):
908
"""Retrieves a token given the hash representing it."""
909
return IMPL.auth_token_get(context, token_hash)
912
def auth_token_update(context, token_hash, values):
913
"""Updates a token given the hash representing it."""
914
return IMPL.auth_token_update(context, token_hash, values)
917
def auth_token_create(context, token):
918
"""Creates a new token."""
919
return IMPL.auth_token_create(context, token)
925
924
def quota_create(context, project_id, resource, limit):
926
925
"""Create a quota for the given project and resource."""
927
926
return IMPL.quota_create(context, project_id, resource, limit)
1241
1240
return IMPL.block_device_mapping_destroy(context, bdm_id)
1243
def block_device_mapping_destroy_by_instance_and_device(context, instance_uuid,
1245
"""Destroy the block device mapping."""
1246
return IMPL.block_device_mapping_destroy_by_instance_and_device(
1247
context, instance_uuid, device_name)
1244
1250
def block_device_mapping_destroy_by_instance_and_volume(context, instance_uuid,
1246
"""Destroy the block device mapping or raise if it does not exist."""
1252
"""Destroy the block device mapping."""
1247
1253
return IMPL.block_device_mapping_destroy_by_instance_and_volume(
1248
1254
context, instance_uuid, volume_id)
1364
1370
###################
1367
def user_get(context, id):
1368
"""Get user by id."""
1369
return IMPL.user_get(context, id)
1372
def user_get_by_access_key(context, access_key):
1373
"""Get user by access key."""
1374
return IMPL.user_get_by_access_key(context, access_key)
1377
def user_create(context, values):
1378
"""Create a new user."""
1379
return IMPL.user_create(context, values)
1382
def user_delete(context, id):
1383
"""Delete a user."""
1384
return IMPL.user_delete(context, id)
1387
def user_get_all(context):
1388
"""Create a new user."""
1389
return IMPL.user_get_all(context)
1392
def user_add_role(context, user_id, role):
1393
"""Add another global role for user."""
1394
return IMPL.user_add_role(context, user_id, role)
1397
def user_remove_role(context, user_id, role):
1398
"""Remove global role from user."""
1399
return IMPL.user_remove_role(context, user_id, role)
1402
def user_get_roles(context, user_id):
1403
"""Get global roles for user."""
1404
return IMPL.user_get_roles(context, user_id)
1407
def user_add_project_role(context, user_id, project_id, role):
1408
"""Add project role for user."""
1409
return IMPL.user_add_project_role(context, user_id, project_id, role)
1412
def user_remove_project_role(context, user_id, project_id, role):
1413
"""Remove project role from user."""
1414
return IMPL.user_remove_project_role(context, user_id, project_id, role)
1417
def user_get_roles_for_project(context, user_id, project_id):
1418
"""Return list of roles a user holds on project."""
1419
return IMPL.user_get_roles_for_project(context, user_id, project_id)
1422
def user_update(context, user_id, values):
1424
return IMPL.user_update(context, user_id, values)
1430
def project_get(context, id):
1431
"""Get project by id."""
1432
return IMPL.project_get(context, id)
1435
def project_create(context, values):
1436
"""Create a new project."""
1437
return IMPL.project_create(context, values)
1440
def project_add_member(context, project_id, user_id):
1441
"""Add user to project."""
1442
return IMPL.project_add_member(context, project_id, user_id)
1445
def project_get_all(context):
1446
"""Get all projects."""
1447
return IMPL.project_get_all(context)
1450
def project_get_by_user(context, user_id):
1451
"""Get all projects of which the given user is a member."""
1452
return IMPL.project_get_by_user(context, user_id)
1455
def project_remove_member(context, project_id, user_id):
1456
"""Remove the given user from the given project."""
1457
return IMPL.project_remove_member(context, project_id, user_id)
1460
def project_update(context, project_id, values):
1461
"""Update Remove the given user from the given project."""
1462
return IMPL.project_update(context, project_id, values)
1465
def project_delete(context, project_id):
1466
"""Delete project."""
1467
return IMPL.project_delete(context, project_id)
1470
1373
def project_get_networks(context, project_id, associate=True):
1471
1374
"""Return the network associated with the project.
1634
1537
return IMPL.bw_usage_get_by_uuids(context, uuids, start_period)
1637
def bw_usage_update(context,
1642
"""Update cached bw usage for an instance and network
1643
Creates new record if needed."""
1644
return IMPL.bw_usage_update(context,
1540
def bw_usage_update(context, uuid, mac, start_period, bw_in, bw_out,
1541
last_refreshed=None):
1542
"""Update cached bandwidth usage for an instance's network based on mac
1543
address. Creates new record if needed.
1545
return IMPL.bw_usage_update(context, uuid, mac, start_period, bw_in,
1546
bw_out, last_refreshed=last_refreshed)
1651
1549
####################
1654
def instance_type_extra_specs_get(context, instance_type_id):
1552
def instance_type_extra_specs_get(context, flavor_id):
1655
1553
"""Get all extra specs for an instance type."""
1656
return IMPL.instance_type_extra_specs_get(context, instance_type_id)
1659
def instance_type_extra_specs_delete(context, instance_type_id, key):
1554
return IMPL.instance_type_extra_specs_get(context, flavor_id)
1557
def instance_type_extra_specs_delete(context, flavor_id, key):
1660
1558
"""Delete the given extra specs item."""
1661
IMPL.instance_type_extra_specs_delete(context, instance_type_id, key)
1664
def instance_type_extra_specs_update_or_create(context, instance_type_id,
1559
IMPL.instance_type_extra_specs_delete(context, flavor_id, key)
1562
def instance_type_extra_specs_update_or_create(context, flavor_id,
1666
1564
"""Create or update instance type extra specs. This adds or modifies the
1667
1565
key/value pairs specified in the extra specs dict argument"""
1668
IMPL.instance_type_extra_specs_update_or_create(context, instance_type_id,
1566
IMPL.instance_type_extra_specs_update_or_create(context, flavor_id,
1868
1766
return IMPL.aggregate_get(context, aggregate_id)
1871
def aggregate_get_by_host(context, host):
1872
"""Get a specific aggregate by host"""
1873
return IMPL.aggregate_get_by_host(context, host)
1769
def aggregate_get_by_host(context, host, key=None):
1770
"""Get a list of aggregates that host belongs to"""
1771
return IMPL.aggregate_get_by_host(context, host, key)
1774
def aggregate_metadata_get_by_host(context, host, key=None):
1775
"""Get metadata for all aggregates that host belongs to.
1777
Returns a dictionary where each value is a set, this is to cover the case
1778
where there two aggregates have different values for the same key.
1779
Optional key filter"""
1780
return IMPL.aggregate_metadata_get_by_host(context, host, key)
1876
1783
def aggregate_update(context, aggregate_id, values):
1940
1847
return IMPL.get_ec2_instance_id_by_uuid(context, instance_id)
1943
def get_instance_uuid_by_ec2_id(context, instance_id):
1850
def get_instance_uuid_by_ec2_id(context, ec2_id):
1944
1851
"""Get uuid through ec2 id from instance_id_mappings table"""
1945
return IMPL.get_instance_uuid_by_ec2_id(context, instance_id)
1852
return IMPL.get_instance_uuid_by_ec2_id(context, ec2_id)
1948
1855
def ec2_instance_create(context, instance_ec2_id):
1949
1856
"""Create the ec2 id to instance uuid mapping on demand"""
1950
1857
return IMPL.ec2_instance_create(context, instance_ec2_id)
1860
####################
1863
def task_log_end_task(context, task_name,
1870
"""Mark a task as complete for a given host/time period"""
1871
return IMPL.task_log_end_task(context, task_name,
1880
def task_log_begin_task(context, task_name,
1887
"""Mark a task as started for a given host/time period"""
1888
return IMPL.task_log_begin_task(context, task_name,
1897
def task_log_get_all(context, task_name, period_beginning,
1898
period_ending, host=None, state=None, session=None):
1899
return IMPL.task_log_get_all(context, task_name, period_beginning,
1900
period_ending, host, state, session)
1903
def task_log_get(context, task_name, period_beginning,
1904
period_ending, host, state=None, session=None):
1905
return IMPL.task_log_get(context, task_name, period_beginning,
1906
period_ending, host, state, session)