28
28
:sql_connection: string specifying the sqlalchemy connection to use, like:
29
29
`sqlite:///var/lib/nova/nova.sqlite`.
31
:enable_new_services: when adding a new service to the database, is it in the
32
pool of available hardware (Default: True)
32
35
from nova import exception
37
40
FLAGS = flags.FLAGS
38
41
flags.DEFINE_string('db_backend', 'sqlalchemy',
39
42
'The backend to use for db')
43
flags.DEFINE_boolean('enable_new_services', True,
44
'Services to be added to the available pool on create')
45
flags.DEFINE_string('instance_name_template', 'instance-%08x',
46
'Template string to be used to generate instance names')
47
flags.DEFINE_string('volume_name_template', 'volume-%08x',
48
'Template string to be used to generate instance names')
42
51
IMPL = utils.LazyPluggable(FLAGS['db_backend'],
76
85
return IMPL.service_get(context, service_id)
88
def service_get_all(context, disabled=False):
89
"""Get all service."""
90
return IMPL.service_get_all(context, None, disabled)
79
93
def service_get_all_by_topic(context, topic):
80
"""Get all compute services for a given topic."""
94
"""Get all services for a given topic."""
81
95
return IMPL.service_get_all_by_topic(context, topic)
98
def service_get_all_by_host(context, host):
99
"""Get all services for a given host."""
100
return IMPL.service_get_all_by_host(context, host)
84
103
def service_get_all_compute_sorted(context):
85
104
"""Get all compute services sorted by instance count.
130
149
###################
152
def certificate_create(context, values):
153
"""Create a certificate from the values dictionary."""
154
return IMPL.certificate_create(context, values)
157
def certificate_destroy(context, certificate_id):
158
"""Destroy the certificate or raise if it does not exist."""
159
return IMPL.certificate_destroy(context, certificate_id)
162
def certificate_get_all_by_project(context, project_id):
163
"""Get all certificates for a project."""
164
return IMPL.certificate_get_all_by_project(context, project_id)
167
def certificate_get_all_by_user(context, user_id):
168
"""Get all certificates for a user."""
169
return IMPL.certificate_get_all_by_user(context, user_id)
172
def certificate_get_all_by_user_and_project(context, user_id, project_id):
173
"""Get all certificates for a user and project."""
174
return IMPL.certificate_get_all_by_user_and_project(context,
179
def certificate_update(context, certificate_id, values):
180
"""Set the given properties on an certificate and update it.
182
Raises NotFound if service does not exist.
185
return IMPL.service_update(context, certificate_id, values)
133
191
def floating_ip_allocate_address(context, host, project_id):
134
192
"""Allocate free floating ip and return the address.
241
299
return IMPL.fixed_ip_get_instance(context, address)
302
def fixed_ip_get_instance_v6(context, address):
303
return IMPL.fixed_ip_get_instance_v6(context, address)
244
306
def fixed_ip_get_network(context, address):
245
307
"""Get a network for a fixed ip by address."""
246
308
return IMPL.fixed_ip_get_network(context, address)
299
361
return IMPL.instance_get_fixed_address(context, instance_id)
364
def instance_get_fixed_address_v6(context, instance_id):
365
return IMPL.instance_get_fixed_address_v6(context, instance_id)
302
368
def instance_get_floating_address(context, instance_id):
303
369
"""Get the first floating ip address of an instance."""
304
370
return IMPL.instance_get_floating_address(context, instance_id)
307
def instance_get_by_internal_id(context, internal_id):
308
"""Get an instance by internal id."""
309
return IMPL.instance_get_by_internal_id(context, internal_id)
373
def instance_get_project_vpn(context, project_id):
374
"""Get a vpn instance by project or return None."""
375
return IMPL.instance_get_project_vpn(context, project_id)
378
def instance_get_by_id(context, instance_id):
379
"""Get an instance by id."""
380
return IMPL.instance_get_by_id(context, instance_id)
312
383
def instance_is_vpn(context, instance_id):
334
405
security_group_id)
408
def instance_action_create(context, values):
409
"""Create an instance action from the values dictionary."""
410
return IMPL.instance_action_create(context, values)
413
def instance_get_actions(context, instance_id):
414
"""Get instance actions by instance id."""
415
return IMPL.instance_get_actions(context, instance_id)
337
418
###################
468
549
###################
471
def project_get_network(context, project_id):
552
def project_get_network(context, project_id, associate=True):
472
553
"""Return the network associated with the project.
474
Raises NotFound if no such network can be found.
555
If associate is true, it will attempt to associate a new
556
network if one is not found, otherwise it returns None.
477
560
return IMPL.project_get_network(context, project_id)
563
def project_get_network_v6(context, project_id):
564
return IMPL.project_get_network_v6(context, project_id)
480
567
###################
660
747
def security_group_get(context, security_group_id):
661
"""Get security group by its internal id."""
748
"""Get security group by its id."""
662
749
return IMPL.security_group_get(context, security_group_id)
711
798
security_group_id)
801
def security_group_rule_get_by_security_group_grantee(context,
803
"""Get all rules that grant access to the given security group."""
804
return IMPL.security_group_rule_get_by_security_group_grantee(context,
714
808
def security_group_rule_destroy(context, security_group_rule_id):
715
809
"""Deletes a security group rule."""
716
810
return IMPL.security_group_rule_destroy(context, security_group_rule_id)
835
929
return IMPL.host_get_networks(context, host)
935
def console_pool_create(context, values):
936
"""Create console pool."""
937
return IMPL.console_pool_create(context, values)
940
def console_pool_get(context, pool_id):
941
"""Get a console pool."""
942
return IMPL.console_pool_get(context, pool_id)
945
def console_pool_get_by_host_type(context, compute_host, proxy_host,
947
"""Fetch a console pool for a given proxy host, compute host, and type."""
948
return IMPL.console_pool_get_by_host_type(context,
954
def console_pool_get_all_by_host_type(context, host, console_type):
955
"""Fetch all pools for given proxy host and type."""
956
return IMPL.console_pool_get_all_by_host_type(context,
961
def console_create(context, values):
962
"""Create a console."""
963
return IMPL.console_create(context, values)
966
def console_delete(context, console_id):
967
"""Delete a console."""
968
return IMPL.console_delete(context, console_id)
971
def console_get_by_pool_instance(context, pool_id, instance_id):
972
"""Get console entry for a given instance and pool."""
973
return IMPL.console_get_by_pool_instance(context, pool_id, instance_id)
976
def console_get_all_by_instance(context, instance_id):
977
"""Get consoles for a given instance."""
978
return IMPL.console_get_all_by_instance(context, instance_id)
981
def console_get(context, console_id, instance_id=None):
982
"""Get a specific console (possibly on a given instance)."""
983
return IMPL.console_get(context, console_id, instance_id)