Coverage for manila/db/api.py: 100%
553 statements
« prev ^ index » next coverage.py v7.11.0, created at 2026-02-18 22:19 +0000
« prev ^ index » next coverage.py v7.11.0, created at 2026-02-18 22:19 +0000
1# Copyright (c) 2011 X.commerce, a business unit of eBay Inc.
2# Copyright 2010 United States Government as represented by the
3# Administrator of the National Aeronautics and Space Administration.
4# All Rights Reserved.
5#
6# Licensed under the Apache License, Version 2.0 (the "License"); you may
7# not use this file except in compliance with the License. You may obtain
8# a copy of the License at
9#
10# http://www.apache.org/licenses/LICENSE-2.0
11#
12# Unless required by applicable law or agreed to in writing, software
13# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15# License for the specific language governing permissions and limitations
16# under the License.
18"""Defines interface for DB access.
20The underlying driver is loaded as a :class:`LazyPluggable`.
22Functions in this module are imported into the manila.db namespace. Call these
23functions from manila.db namespace, not the manila.db.api namespace.
25All functions in this module return objects that implement a dictionary-like
26interface. Currently, many of these objects are sqlalchemy objects that
27implement a dictionary interface. However, a future goal is to have all of
28these objects be simple dictionaries.
31**Related Flags**
33:backend: string to lookup in the list of LazyPluggable backends.
34 `sqlalchemy` is the only supported backend right now.
36:connection: string specifying the sqlalchemy connection to use, like:
37 `sqlite:///var/lib/manila/manila.sqlite`.
39:enable_new_services: when adding a new service to the database, is it in the
40 pool of available hardware (Default: True)
42"""
43from oslo_config import cfg
44from oslo_db import api as db_api
46db_opts = [
47 cfg.StrOpt('db_backend',
48 default='sqlalchemy',
49 help='The backend to use for database.'),
50 cfg.BoolOpt('enable_new_services',
51 default=True,
52 help='Services to be added to the available pool on create.'),
53 cfg.StrOpt('share_name_template',
54 default='share-%s',
55 help='Template string to be used to generate share names.'),
56 cfg.StrOpt('share_snapshot_name_template',
57 default='share-snapshot-%s',
58 help='Template string to be used to generate share snapshot '
59 'names.'),
60 cfg.StrOpt('share_backup_name_template',
61 default='share-backup-%s',
62 help='Template string to be used to generate backup names.'),
63]
65CONF = cfg.CONF
66CONF.register_opts(db_opts)
68_BACKEND_MAPPING = {'sqlalchemy': 'manila.db.sqlalchemy.api'}
69IMPL = db_api.DBAPI.from_config(cfg.CONF, backend_mapping=_BACKEND_MAPPING,
70 lazy=True)
73def authorize_project_context(context, project_id):
74 """Ensures a request has permission to access the given project."""
75 return IMPL.authorize_project_context(context, project_id)
78def authorize_quota_class_context(context, class_name):
79 """Ensures a request has permission to access the given quota class."""
80 return IMPL.authorize_quota_class_context(context, class_name)
83###################
86def service_destroy(context, service_id):
87 """Destroy the service or raise if it does not exist."""
88 return IMPL.service_destroy(context, service_id)
91def service_get(context, service_id):
92 """Get a service or raise if it does not exist."""
93 return IMPL.service_get(context, service_id)
96def service_get_by_host_and_topic(context, host, topic):
97 """Get a service by host it's on and topic it listens to."""
98 return IMPL.service_get_by_host_and_topic(context, host, topic)
101def service_get_all(context, disabled=None):
102 """Get all services."""
103 return IMPL.service_get_all(context, disabled)
106def service_get_all_by_topic(context, topic, consider_disabled=False):
107 """Get all services for a given topic."""
108 return IMPL.service_get_all_by_topic(context, topic,
109 consider_disabled=consider_disabled)
112def service_get_all_share_sorted(context):
113 """Get all share services sorted by share count.
115 :returns: a list of (Service, share_count) tuples.
117 """
118 return IMPL.service_get_all_share_sorted(context)
121def service_get_by_args(context, host, binary):
122 """Get the state of an service by node name and binary."""
123 return IMPL.service_get_by_args(context, host, binary)
126def service_create(context, values):
127 """Create a service from the values dictionary."""
128 return IMPL.service_create(context, values)
131def service_update(context, service_id, values):
132 """Set the given properties on an service and update it.
134 Raises NotFound if service does not exist.
136 """
137 return IMPL.service_update(context, service_id, values)
140####################
143def quota_create(context, project_id, resource, limit, user_id=None,
144 share_type_id=None):
145 """Create a quota for the given project and resource."""
146 return IMPL.quota_create(context, project_id, resource, limit,
147 user_id=user_id, share_type_id=share_type_id)
150def quota_get_all_by_project_and_user(context, project_id, user_id):
151 """Retrieve all quotas associated with a given project and user."""
152 return IMPL.quota_get_all_by_project_and_user(context, project_id, user_id)
155def quota_get_all_by_project_and_share_type(context, project_id,
156 share_type_id):
157 """Retrieve all quotas associated with a given project and user."""
158 return IMPL.quota_get_all_by_project_and_share_type(
159 context, project_id, share_type_id)
162def quota_get_all_by_project(context, project_id):
163 """Retrieve all quotas associated with a given project."""
164 return IMPL.quota_get_all_by_project(context, project_id)
167def quota_get_all(context, project_id):
168 """Retrieve all user quotas associated with a given project."""
169 return IMPL.quota_get_all(context, project_id)
172def quota_update(context, project_id, resource, limit, user_id=None,
173 share_type_id=None):
174 """Update a quota or raise if it does not exist."""
175 return IMPL.quota_update(context, project_id, resource, limit,
176 user_id=user_id, share_type_id=share_type_id)
179###################
182def quota_class_create(context, class_name, resource, limit):
183 """Create a quota class for the given name and resource."""
184 return IMPL.quota_class_create(context, class_name, resource, limit)
187def quota_class_get(context, class_name, resource):
188 """Retrieve a quota class or raise if it does not exist."""
189 return IMPL.quota_class_get(context, class_name, resource)
192def quota_class_get_default(context):
193 """Retrieve all default quotas."""
194 return IMPL.quota_class_get_default(context)
197def quota_class_get_all_by_name(context, class_name):
198 """Retrieve all quotas associated with a given quota class."""
199 return IMPL.quota_class_get_all_by_name(context, class_name)
202def quota_class_update(context, class_name, resource, limit):
203 """Update a quota class or raise if it does not exist."""
204 return IMPL.quota_class_update(context, class_name, resource, limit)
207###################
210def quota_usage_get(context, project_id, resource, user_id=None,
211 share_type_id=None):
212 """Retrieve a quota usage or raise if it does not exist."""
213 return IMPL.quota_usage_get(
214 context, project_id, resource, user_id=user_id,
215 share_type_id=share_type_id)
218def quota_usage_get_all_by_project_and_user(context, project_id, user_id):
219 """Retrieve all usage associated with a given resource."""
220 return IMPL.quota_usage_get_all_by_project_and_user(context,
221 project_id, user_id)
224def quota_usage_get_all_by_project_and_share_type(context, project_id,
225 share_type_id):
226 """Retrieve all usage associated with a given resource."""
227 return IMPL.quota_usage_get_all_by_project_and_share_type(
228 context, project_id, share_type_id)
231def quota_usage_get_all_by_project(context, project_id):
232 """Retrieve all usage associated with a given resource."""
233 return IMPL.quota_usage_get_all_by_project(context, project_id)
236def quota_usage_create(context, project_id, user_id, resource, in_use,
237 reserved=0, until_refresh=None, share_type_id=None):
238 """Create a quota usage."""
239 return IMPL.quota_usage_create(
240 context, project_id, user_id, resource, in_use, reserved,
241 until_refresh, share_type_id=share_type_id)
244def quota_usage_update(context, project_id, user_id, resource,
245 share_type_id=None, **kwargs):
246 """Update a quota usage or raise if it does not exist."""
247 return IMPL.quota_usage_update(
248 context, project_id, user_id, resource, share_type_id=share_type_id,
249 **kwargs)
252###################
255def quota_reserve(context, resources, quotas, user_quotas, share_type_quotas,
256 deltas, expire, until_refresh, max_age,
257 project_id=None, user_id=None, share_type_id=None,
258 overquota_allowed=False):
259 """Check quotas and create appropriate reservations."""
260 return IMPL.quota_reserve(
261 context, resources, quotas, user_quotas, share_type_quotas, deltas,
262 expire, until_refresh, max_age, project_id=project_id, user_id=user_id,
263 share_type_id=share_type_id, overquota_allowed=overquota_allowed)
266def reservation_commit(context, reservations, project_id=None, user_id=None,
267 share_type_id=None):
268 """Commit quota reservations."""
269 return IMPL.reservation_commit(
270 context, reservations, project_id=project_id, user_id=user_id,
271 share_type_id=share_type_id)
274def reservation_rollback(context, reservations, project_id=None, user_id=None,
275 share_type_id=None):
276 """Roll back quota reservations."""
277 return IMPL.reservation_rollback(
278 context, reservations, project_id=project_id, user_id=user_id,
279 share_type_id=share_type_id)
282def quota_destroy_all_by_project_and_user(context, project_id, user_id):
283 """Destroy all quotas associated with a given project and user."""
284 return IMPL.quota_destroy_all_by_project_and_user(context,
285 project_id, user_id)
288def quota_destroy_all_by_share_type(context, share_type_id, project_id=None):
289 """Destroy all quotas associated with a given share type and project."""
290 return IMPL.quota_destroy_all_by_share_type(
291 context, share_type_id, project_id=project_id)
294def quota_destroy_all_by_project(context, project_id):
295 """Destroy all quotas associated with a given project."""
296 return IMPL.quota_destroy_all_by_project(context, project_id)
299def reservation_expire(context):
300 """Roll back any expired reservations."""
301 return IMPL.reservation_expire(context)
304###################
307def share_instance_get(context, instance_id, with_share_data=False):
308 """Get share instance by id."""
309 return IMPL.share_instance_get(context, instance_id,
310 with_share_data=with_share_data)
313def share_instance_create(context, share_id, values):
314 """Create new share instance."""
315 return IMPL.share_instance_create(context, share_id, values)
318def share_instance_delete(context, instance_id,
319 need_to_update_usages=False):
320 """Delete share instance."""
321 return IMPL.share_instance_delete(
322 context, instance_id,
323 need_to_update_usages=need_to_update_usages)
326def update_share_instance_quota_usages(context, instance_id):
327 """Update share instance quota usages"""
328 return IMPL.update_share_instance_quota_usages(context, instance_id)
331def share_instance_update(context, instance_id, values, with_share_data=False):
332 """Update share instance fields."""
333 return IMPL.share_instance_update(context, instance_id, values,
334 with_share_data=with_share_data)
337def share_and_snapshot_instances_status_update(
338 context, values, share_instance_ids=None, snapshot_instance_ids=None,
339 current_expected_status=None):
340 return IMPL.share_and_snapshot_instances_status_update(
341 context, values, share_instance_ids=share_instance_ids,
342 snapshot_instance_ids=snapshot_instance_ids,
343 current_expected_status=current_expected_status)
346def share_instance_status_update(context, share_instance_ids, values):
347 """Updates the status of a bunch of share instances at once."""
348 return IMPL.share_instance_status_update(
349 context, share_instance_ids, values)
352def share_instance_get_all(context, filters=None):
353 """Returns all share instances."""
354 return IMPL.share_instance_get_all(context, filters=filters)
357def share_instance_get_all_by_share_server(
358 context, share_server_id, with_share_data=False,
359):
360 """Returns all share instances with given share_server_id."""
361 return IMPL.share_instance_get_all_by_share_server(
362 context, share_server_id, with_share_data=with_share_data)
365def share_instance_get_all_by_host(
366 context, host, with_share_data=False, status=None,
367):
368 """Returns all share instances with given host."""
369 return IMPL.share_instance_get_all_by_host(
370 context, host, with_share_data=with_share_data, status=status)
373def share_instance_get_all_by_share_network(context, share_network_id):
374 """Returns list of shares that belong to given share network."""
375 return IMPL.share_instance_get_all_by_share_network(
376 context, share_network_id)
379def share_instance_get_all_by_share(context, share_id):
380 """Returns list of shares that belong to given share."""
381 return IMPL.share_instance_get_all_by_share(context, share_id)
384def share_instance_get_all_by_share_group_id(context, share_group_id):
385 """Returns list of share instances that belong to given share group."""
386 return IMPL.share_instance_get_all_by_share_group_id(
387 context, share_group_id)
390def share_instance_sizes_sum_by_host(context, host):
391 """Returns sum of sizes of all share instances on given host."""
392 return IMPL.share_instance_sizes_sum_by_host(context, host)
394###################
397def share_create(context, share_values, create_share_instance=True):
398 """Create new share."""
399 return IMPL.share_create(context, share_values,
400 create_share_instance=create_share_instance)
403def share_update(context, share_id, values):
404 """Update share fields."""
405 return IMPL.share_update(context, share_id, values)
408def share_get(context, share_id, **kwargs):
409 """Get share by id."""
410 return IMPL.share_get(context, share_id, **kwargs)
413def share_get_all(context, filters=None, sort_key=None, sort_dir=None):
414 """Get all shares."""
415 return IMPL.share_get_all(
416 context, filters=filters, sort_key=sort_key, sort_dir=sort_dir,
417 )
420def share_get_all_with_count(context, filters=None, sort_key=None,
421 sort_dir=None):
422 """Get all shares."""
423 return IMPL.share_get_all_with_count(
424 context, filters=filters, sort_key=sort_key, sort_dir=sort_dir)
427def share_get_all_by_project(context, project_id, filters=None,
428 is_public=False, sort_key=None, sort_dir=None):
429 """Returns all shares with given project ID."""
430 return IMPL.share_get_all_by_project(
431 context, project_id, filters=filters, is_public=is_public,
432 sort_key=sort_key, sort_dir=sort_dir)
435def share_get_all_by_project_with_count(
436 context, project_id, filters=None, is_public=False, sort_key=None,
437 sort_dir=None,):
438 """Returns all shares with given project ID."""
439 return IMPL.share_get_all_by_project_with_count(
440 context, project_id, filters=filters, is_public=is_public,
441 sort_key=sort_key, sort_dir=sort_dir)
444def share_get_all_by_share_group_id(context, share_group_id,
445 filters=None, sort_key=None,
446 sort_dir=None):
447 """Returns all shares with given project ID and share group id."""
448 return IMPL.share_get_all_by_share_group_id(
449 context, share_group_id, filters=filters,
450 sort_key=sort_key, sort_dir=sort_dir)
453def share_get_all_by_share_group_id_with_count(context, share_group_id,
454 filters=None, sort_key=None,
455 sort_dir=None):
456 """Returns all shares with given project ID and share group id."""
457 return IMPL.share_get_all_by_share_group_id_with_count(
458 context, share_group_id, filters=filters, sort_key=sort_key,
459 sort_dir=sort_dir)
462def share_get_all_by_share_server(context, share_server_id, filters=None,
463 sort_key=None, sort_dir=None):
464 """Returns all shares with given share server ID."""
465 return IMPL.share_get_all_by_share_server(
466 context, share_server_id, filters=filters, sort_key=sort_key,
467 sort_dir=sort_dir)
470def share_get_all_soft_deleted(
471 context, share_server_id, filters=None, sort_key=None, sort_dir=None):
472 """Returns all shares in recycle bin with given share server ID."""
473 return IMPL.share_get_all_soft_deleted(
474 context, share_server_id, filters=filters, sort_key=sort_key,
475 sort_dir=sort_dir)
478def share_get_all_by_share_server_with_count(
479 context, share_server_id, filters=None, sort_key=None, sort_dir=None):
480 """Returns all shares with given share server ID."""
481 return IMPL.share_get_all_by_share_server_with_count(
482 context, share_server_id, filters=filters, sort_key=sort_key,
483 sort_dir=sort_dir)
486def share_get_all_soft_deleted_by_network(
487 context, share_network_id, filters=None, sort_key=None, sort_dir=None):
488 """Returns all shares in recycle bin with given share network ID."""
489 return IMPL.share_get_all_soft_deleted_by_network(
490 context, share_network_id, filters=filters, sort_key=sort_key,
491 sort_dir=sort_dir)
494def share_delete(context, share_id):
495 """Delete share."""
496 return IMPL.share_delete(context, share_id)
499def share_soft_delete(context, share_id):
500 """Soft delete share."""
501 return IMPL.share_soft_delete(context, share_id)
504def share_restore(context, share_id):
505 """Restore share."""
506 return IMPL.share_restore(context, share_id)
508###################
511def transfer_get(context, transfer_id):
512 """Get a share transfer record or raise if it does not exist."""
513 return IMPL.transfer_get(context, transfer_id)
516def transfer_get_all(context, limit=None, sort_key=None,
517 sort_dir=None, filters=None, offset=None):
518 """Get all share transfer records."""
519 return IMPL.transfer_get_all(context, limit=limit,
520 sort_key=sort_key, sort_dir=sort_dir,
521 filters=filters, offset=offset)
524def transfer_get_all_by_project(context, project_id,
525 limit=None, sort_key=None,
526 sort_dir=None, filters=None, offset=None):
527 """Get all share transfer records for specified project."""
528 return IMPL.transfer_get_all_by_project(context, project_id,
529 limit=limit, sort_key=sort_key,
530 sort_dir=sort_dir,
531 filters=filters, offset=offset)
534def transfer_get_all_expired(context):
535 """Get all expired transfers DB records."""
536 return IMPL.transfer_get_all_expired(context)
539def transfer_create(context, values):
540 """Create an entry in the transfers table."""
541 return IMPL.transfer_create(context, values)
544def transfer_destroy(context, transfer_id, update_share_status=True):
545 """Destroy a record in the share transfer table."""
546 return IMPL.transfer_destroy(context, transfer_id,
547 update_share_status=update_share_status)
550def transfer_accept(context, transfer_id, user_id, project_id,
551 accept_snapshots=False):
552 """Accept a share transfer."""
553 return IMPL.transfer_accept(context, transfer_id, user_id, project_id,
554 accept_snapshots=accept_snapshots)
557def transfer_accept_rollback(context, transfer_id, user_id,
558 project_id, rollback_snap=False):
559 """Rollback a share transfer."""
560 return IMPL.transfer_accept_rollback(context, transfer_id,
561 user_id, project_id,
562 rollback_snap=rollback_snap)
565###################
568def share_access_create(context, values):
569 """Allow access to share."""
570 return IMPL.share_access_create(context, values)
573def share_access_update(context, access_id, values):
574 """Update access to share."""
575 return IMPL.share_access_update(context, access_id, values)
578def share_access_get(context, access_id):
579 """Get share access rule."""
580 return IMPL.share_access_get(context, access_id)
583def share_access_get_with_context(context, access_id):
584 """Get share access rule."""
585 return IMPL.share_access_get_with_context(context, access_id)
588def share_access_get_all_for_share(context, share_id, filters=None):
589 """Get all access rules for given share."""
590 return IMPL.share_access_get_all_for_share(context, share_id,
591 filters=filters)
594def share_access_get_all_for_instance(context, instance_id, filters=None,
595 with_share_access_data=True):
596 """Get all access rules related to a certain share instance."""
597 return IMPL.share_access_get_all_for_instance(
598 context, instance_id, filters=filters,
599 with_share_access_data=with_share_access_data)
602def share_access_get_all_by_type_and_access(context, share_id, access_type,
603 access):
604 """Returns share access by given type and access."""
605 return IMPL.share_access_get_all_by_type_and_access(
606 context, share_id, access_type, access)
609def share_access_check_for_existing_access(context, share_id, access_type,
610 access_to):
611 """Returns True if rule corresponding to the type and client exists."""
612 return IMPL.share_access_check_for_existing_access(
613 context, share_id, access_type, access_to)
616def share_instance_access_create(context, values, share_instance_id):
617 """Allow access to share instance."""
618 return IMPL.share_instance_access_create(
619 context, values, share_instance_id)
622def share_instance_access_copy(context, share_id, instance_id):
623 """Maps the existing access rules for the share to the instance in the DB.
625 Adds the instance mapping to the share's access rules and
626 returns the share's access rules.
627 """
628 return IMPL.share_instance_access_copy(context, share_id, instance_id)
631def share_instance_access_get(context, access_id, instance_id,
632 with_share_access_data=True):
633 """Get access rule mapping for share instance."""
634 return IMPL.share_instance_access_get(
635 context, access_id, instance_id,
636 with_share_access_data=with_share_access_data)
639def share_instance_access_update(context, access_id, instance_id, updates):
640 """Update the access mapping row for a given share instance and access."""
641 return IMPL.share_instance_access_update(
642 context, access_id, instance_id, updates)
645def share_instance_access_delete(context, mapping_id):
646 """Deny access to share instance."""
647 return IMPL.share_instance_access_delete(context, mapping_id)
650def share_access_metadata_update(context, access_id, metadata):
651 """Update metadata of share access rule."""
652 return IMPL.share_access_metadata_update(context, access_id, metadata)
655def share_access_metadata_delete(context, access_id, key):
656 """Delete metadata of share access rule."""
657 return IMPL.share_access_metadata_delete(context, access_id, key)
660####################
663def share_snapshot_instance_update(context, instance_id, values):
664 """Set the given properties on a share snapshot instance and update it.
666 Raises NotFound if snapshot instance does not exist.
667 """
668 return IMPL.share_snapshot_instance_update(context, instance_id, values)
671def share_snapshot_instances_status_update(
672 context, snapshot_instance_ids, values):
673 """Updates the status of a bunch of share snapshot instances at once."""
674 return IMPL.share_snapshot_instances_status_update(
675 context, snapshot_instance_ids, values)
678def share_snapshot_instance_create(context, snapshot_id, values):
679 """Create a share snapshot instance for an existing snapshot."""
680 return IMPL.share_snapshot_instance_create(
681 context, snapshot_id, values)
684def share_snapshot_instance_get(context, instance_id, with_share_data=False):
685 """Get a snapshot instance or raise a NotFound exception."""
686 return IMPL.share_snapshot_instance_get(
687 context, instance_id, with_share_data=with_share_data)
690def share_snapshot_instance_get_all_with_filters(context, filters,
691 with_share_data=False):
692 """Get all snapshot instances satisfying provided filters."""
693 return IMPL.share_snapshot_instance_get_all_with_filters(
694 context, filters, with_share_data=with_share_data)
697def share_snapshot_instance_delete(context, snapshot_instance_id):
698 """Delete a share snapshot instance."""
699 return IMPL.share_snapshot_instance_delete(context, snapshot_instance_id)
702####################
705def share_snapshot_create(context, values, create_snapshot_instance=True):
706 """Create a snapshot from the values dictionary."""
707 return IMPL.share_snapshot_create(
708 context, values, create_snapshot_instance=create_snapshot_instance)
711def share_snapshot_get(context, snapshot_id, project_only=True):
712 """Get a snapshot or raise if it does not exist."""
713 return IMPL.share_snapshot_get(context, snapshot_id,
714 project_only=project_only)
717def share_snapshot_get_all(context, filters=None, limit=None, offset=None,
718 sort_key=None, sort_dir=None):
719 """Get all snapshots."""
720 return IMPL.share_snapshot_get_all(
721 context, filters=filters, limit=limit, offset=offset,
722 sort_key=sort_key, sort_dir=sort_dir)
725def share_snapshot_get_all_with_count(context, filters=None, limit=None,
726 offset=None, sort_key=None,
727 sort_dir=None):
728 """Get all snapshots."""
729 return IMPL.share_snapshot_get_all_with_count(
730 context, filters=filters, limit=limit, offset=offset,
731 sort_key=sort_key, sort_dir=sort_dir)
734def share_snapshot_get_all_by_project(context, project_id, filters=None,
735 limit=None, offset=None, sort_key=None,
736 sort_dir=None):
737 """Get all snapshots belonging to a project."""
738 return IMPL.share_snapshot_get_all_by_project(
739 context, project_id, filters=filters, limit=limit, offset=offset,
740 sort_key=sort_key, sort_dir=sort_dir)
743def share_snapshot_get_all_by_project_with_count(context, project_id,
744 filters=None, limit=None,
745 offset=None, sort_key=None,
746 sort_dir=None):
747 """Get all snapshots belonging to a project."""
748 return IMPL.share_snapshot_get_all_by_project_with_count(
749 context, project_id, filters=filters, limit=limit, offset=offset,
750 sort_key=sort_key, sort_dir=sort_dir)
753def share_snapshot_get_all_for_share(context, share_id, filters=None,
754 sort_key=None, sort_dir=None):
755 """Get all snapshots for a share."""
756 return IMPL.share_snapshot_get_all_for_share(
757 context, share_id, filters=filters, sort_key=sort_key,
758 sort_dir=sort_dir,
759 )
762def share_snapshot_get_latest_for_share(context, share_id):
763 """Get the most recent snapshot for a share."""
764 return IMPL.share_snapshot_get_latest_for_share(context, share_id)
767def share_snapshot_update(context, snapshot_id, values):
768 """Set the given properties on an snapshot and update it.
770 Raises NotFound if snapshot does not exist.
771 """
772 return IMPL.share_snapshot_update(context, snapshot_id, values)
775###################
776def share_snapshot_access_create(context, values):
777 """Create a share snapshot access from the values dictionary."""
778 return IMPL.share_snapshot_access_create(context, values)
781def share_snapshot_access_get(context, access_id):
782 """Get share snapshot access rule from given access_id."""
783 return IMPL.share_snapshot_access_get(context, access_id)
786def share_snapshot_access_get_all_for_snapshot_instance(
787 context, snapshot_instance_id,
788):
789 """Get all access rules related to a certain snapshot instance."""
790 return IMPL.share_snapshot_access_get_all_for_snapshot_instance(
791 context, snapshot_instance_id)
794def share_snapshot_access_get_all_for_share_snapshot(context,
795 share_snapshot_id,
796 filters):
797 """Get all access rules for a given share snapshot according to filters."""
798 return IMPL.share_snapshot_access_get_all_for_share_snapshot(
799 context, share_snapshot_id, filters)
802def share_snapshot_check_for_existing_access(context, share_snapshot_id,
803 access_type, access_to):
804 """Returns True if rule corresponding to the type and client exists."""
805 return IMPL.share_snapshot_check_for_existing_access(context,
806 share_snapshot_id,
807 access_type,
808 access_to)
811def share_snapshot_export_locations_get(context, snapshot_id):
812 """Get all export locations for a given share snapshot."""
813 return IMPL.share_snapshot_export_locations_get(context, snapshot_id)
816def share_snapshot_instance_access_update(
817 context, access_id, instance_id, updates):
818 """Update the state of the share snapshot instance access."""
819 return IMPL.share_snapshot_instance_access_update(
820 context, access_id, instance_id, updates)
823def share_snapshot_instance_access_get(context, share_snapshot_instance_id,
824 access_id):
825 """Get the share snapshot instance access related to given ids."""
826 return IMPL.share_snapshot_instance_access_get(
827 context, share_snapshot_instance_id, access_id)
830def share_snapshot_instance_access_delete(context, access_id,
831 snapshot_instance_id):
832 """Delete share snapshot instance access given its id."""
833 return IMPL.share_snapshot_instance_access_delete(
834 context, access_id, snapshot_instance_id)
837def share_snapshot_instance_export_location_create(context, values):
838 """Create a share snapshot instance export location."""
839 return IMPL.share_snapshot_instance_export_location_create(context, values)
842def share_snapshot_instance_export_locations_update(
843 context, share_snapshot_instance_id, export_locations, delete=True):
844 """Update export locations of a share instance."""
845 return IMPL.share_snapshot_instance_export_locations_update(
846 context, share_snapshot_instance_id, export_locations, delete=delete)
849def share_snapshot_instance_export_locations_get_all(
850 context, share_snapshot_instance_id):
851 """Get the share snapshot instance export locations for given id."""
852 return IMPL.share_snapshot_instance_export_locations_get_all(
853 context, share_snapshot_instance_id)
856def share_snapshot_instance_export_location_get(context, el_id):
857 """Get the share snapshot instance export location for given id."""
858 return IMPL.share_snapshot_instance_export_location_get(
859 context, el_id)
862def share_snapshot_instance_export_location_delete(context, el_id):
863 """Delete share snapshot instance export location given its id."""
864 return IMPL.share_snapshot_instance_export_location_delete(context, el_id)
867####################
869def share_snapshot_metadata_get(context, share_snapshot_id, **kwargs):
870 """Get all metadata for a share snapshot."""
871 return IMPL.share_snapshot_metadata_get(context,
872 share_snapshot_id,
873 **kwargs)
876def share_snapshot_metadata_get_item(context, share_snapshot_id, key):
877 """Get metadata item for a share snapshot."""
878 return IMPL.share_snapshot_metadata_get_item(context,
879 share_snapshot_id, key)
882def share_snapshot_metadata_delete(context, share_snapshot_id, key):
883 """Delete the given metadata item."""
884 IMPL.share_snapshot_metadata_delete(context, share_snapshot_id, key)
887def share_snapshot_metadata_update(context, share_snapshot_id,
888 metadata, delete):
889 """Update metadata if it exists, otherwise create it."""
890 return IMPL.share_snapshot_metadata_update(context, share_snapshot_id,
891 metadata, delete)
894def share_snapshot_metadata_update_item(context, share_snapshot_id,
895 metadata):
896 """Update metadata item if it exists, otherwise create it."""
897 return IMPL.share_snapshot_metadata_update_item(context,
898 share_snapshot_id,
899 metadata)
900###################
903def security_service_create(context, values):
904 """Create security service DB record."""
905 return IMPL.security_service_create(context, values)
908def security_service_delete(context, id):
909 """Delete security service DB record."""
910 return IMPL.security_service_delete(context, id)
913def security_service_update(context, id, values):
914 """Update security service DB record."""
915 return IMPL.security_service_update(context, id, values)
918def security_service_get(context, id, **kwargs):
919 """Get security service DB record."""
920 return IMPL.security_service_get(context, id, **kwargs)
923def security_service_get_all(context):
924 """Get all security service DB records."""
925 return IMPL.security_service_get_all(context)
928def security_service_get_all_by_project(context, project_id):
929 """Get all security service DB records for the given project."""
930 return IMPL.security_service_get_all_by_project(context, project_id)
933def security_service_get_all_by_share_network(context, share_network_id):
934 """Get all security service DB records for the given share network."""
935 return IMPL.security_service_get_all_by_share_network(context,
936 share_network_id)
939####################
940def share_metadata_get(context, share_id):
941 """Get all metadata for a share."""
942 return IMPL.share_metadata_get(context, share_id)
945def share_metadata_get_item(context, share_id, key):
946 """Get metadata item for given key and for a given share.."""
947 return IMPL.share_metadata_get_item(context, share_id, key)
950def share_metadata_delete(context, share_id, key):
951 """Delete the given metadata item."""
952 return IMPL.share_metadata_delete(context, share_id, key)
955def share_metadata_update(context, share, metadata, delete):
956 """Update metadata if it exists, otherwise create it."""
957 return IMPL.share_metadata_update(context, share, metadata, delete)
960def share_metadata_update_item(context, share_id, item):
961 """update meta item containing key and value for given share."""
962 return IMPL.share_metadata_update_item(context, share_id, item)
965###################
967def export_location_get_by_uuid(
968 context, export_location_uuid, ignore_secondary_replicas=False,
969):
970 """Get specific export location of a share."""
971 return IMPL.export_location_get_by_uuid(
972 context, export_location_uuid,
973 ignore_secondary_replicas=ignore_secondary_replicas)
976def export_location_get_all(context, share_id):
977 """Get all export locations of a share."""
978 return IMPL.export_location_get_all(context, share_id)
981def export_location_get_all_by_share_id(
982 context, share_id,
983 include_admin_only=True,
984 ignore_migration_destination=False,
985 ignore_secondary_replicas=False,
986):
987 """Get all export locations of a share by its ID."""
988 return IMPL.export_location_get_all_by_share_id(
989 context, share_id, include_admin_only=include_admin_only,
990 ignore_migration_destination=ignore_migration_destination,
991 ignore_secondary_replicas=ignore_secondary_replicas)
994def export_location_get_all_by_share_instance_id(
995 context, share_instance_id, include_admin_only=True,
996):
997 """Get all export locations of a share instance by its ID."""
998 return IMPL.export_location_get_all_by_share_instance_id(
999 context, share_instance_id, include_admin_only=include_admin_only)
1002def export_locations_update(
1003 context, share_instance_id, export_locations, delete=True,
1004):
1005 """Update export locations of a share instance."""
1006 return IMPL.export_locations_update(
1007 context, share_instance_id, export_locations, delete)
1010####################
1012def export_location_metadata_get(context, export_location_uuid):
1013 """Get all metadata of an export location."""
1014 return IMPL.export_location_metadata_get(context, export_location_uuid)
1017def export_location_metadata_get_item(context, export_location_uuid, key):
1018 """Get metadata item for a share export location."""
1019 return IMPL.export_location_metadata_get_item(context,
1020 export_location_uuid,
1021 key)
1024def export_location_metadata_delete(context, export_location_uuid, keys):
1025 """Delete metadata of an export location."""
1026 return IMPL.export_location_metadata_delete(
1027 context, export_location_uuid, keys)
1030def export_location_metadata_update(context, export_location_uuid, metadata,
1031 delete):
1032 """Update metadata of an export location."""
1033 return IMPL.export_location_metadata_update(
1034 context, export_location_uuid, metadata, delete)
1037def export_location_metadata_update_item(context, export_location_uuid,
1038 metadata):
1039 """Update metadata item if it exists, otherwise create it."""
1040 return IMPL.export_location_metadata_update_item(context,
1041 export_location_uuid,
1042 metadata)
1044####################
1047def share_network_create(context, values):
1048 """Create a share network DB record."""
1049 return IMPL.share_network_create(context, values)
1052def share_network_delete(context, id):
1053 """Delete a share network DB record."""
1054 return IMPL.share_network_delete(context, id)
1057def share_network_update(context, id, values):
1058 """Update a share network DB record."""
1059 return IMPL.share_network_update(context, id, values)
1062def share_network_get(context, id):
1063 """Get requested share network DB record."""
1064 return IMPL.share_network_get(context, id)
1067def share_network_get_all_by_filter(context, filters=None):
1068 """Get all share network DB records for the given filter."""
1069 return IMPL.share_network_get_all_by_filter(context, filters=filters)
1072def share_network_get_all(context):
1073 """Get all share network DB records."""
1074 return IMPL.share_network_get_all(context)
1077def share_network_get_all_by_project(context, project_id):
1078 """Get all share network DB records for the given project."""
1079 return IMPL.share_network_get_all_by_project(context, project_id)
1082def share_network_get_all_by_security_service(context, security_service_id):
1083 """Get all share network DB records for the given project."""
1084 return IMPL.share_network_get_all_by_security_service(
1085 context, security_service_id)
1088def share_network_add_security_service(context, id, security_service_id):
1089 """Associate a security service with a share network."""
1090 return IMPL.share_network_add_security_service(context,
1091 id,
1092 security_service_id)
1095def share_network_remove_security_service(context, id, security_service_id):
1096 """Dissociate a security service from a share network."""
1097 return IMPL.share_network_remove_security_service(context,
1098 id,
1099 security_service_id)
1102def share_network_security_service_association_get(
1103 context, share_network_id, security_service_id):
1104 """Get given share network and security service association."""
1105 return IMPL.share_network_security_service_association_get(
1106 context, share_network_id, security_service_id)
1109def share_network_update_security_service(context, id,
1110 current_security_service_id,
1111 new_security_service_id):
1112 """Update a security service association with a share network."""
1113 return IMPL.share_network_update_security_service(
1114 context, id, current_security_service_id, new_security_service_id)
1117##################
1120def share_network_subnet_create(context, values):
1121 """Create a share network subnet DB record."""
1122 return IMPL.share_network_subnet_create(context, values)
1125def share_network_subnet_delete(context, network_subnet_id):
1126 """Delete a share network subnet DB record."""
1127 return IMPL.share_network_subnet_delete(context, network_subnet_id)
1130def share_network_subnet_update(context, network_subnet_id, values):
1131 """Update a share network subnet DB record."""
1132 return IMPL.share_network_subnet_update(context, network_subnet_id, values)
1135def share_network_subnet_get(context, network_subnet_id, parent_id=None):
1136 """Get requested share network subnet DB record."""
1137 return IMPL.share_network_subnet_get(
1138 context,
1139 network_subnet_id,
1140 parent_id=parent_id,
1141 )
1144def share_network_subnet_get_all_with_same_az(context, network_subnet_id):
1145 """Get requested az share network subnets DB record."""
1146 return IMPL.share_network_subnet_get_all_with_same_az(
1147 context, network_subnet_id,
1148 )
1151def share_network_subnet_get_all(context):
1152 """Get all share network subnet DB record."""
1153 return IMPL.share_network_subnet_get_all(context)
1156def share_network_subnets_get_all_by_availability_zone_id(
1157 context, share_network_id, availability_zone_id,
1158 fallback_to_default=True,
1159):
1160 """Get the share network subnets DB record in a given AZ.
1162 This method returns list of subnets DB record for a given share network id
1163 and an availability zone. If the 'availability_zone_id' is 'None', a
1164 record may be returned and it will represent the default share network
1165 subnets. If there is no subnet for a specific availability zone id and
1166 "fallback_to_default" is True, this method will return the default share
1167 network subnets, if it exists.
1168 """
1169 return IMPL.share_network_subnets_get_all_by_availability_zone_id(
1170 context, share_network_id, availability_zone_id,
1171 fallback_to_default=fallback_to_default,
1172 )
1175def share_network_subnet_get_default_subnets(context, share_network_id):
1176 """Get the default share network subnets DB records."""
1177 return IMPL.share_network_subnet_get_default_subnets(
1178 context, share_network_id,
1179 )
1182def share_network_subnet_get_all_by_share_server_id(context, share_server_id):
1183 """Get the subnets that are being used by the share server."""
1184 return IMPL.share_network_subnet_get_all_by_share_server_id(
1185 context, share_server_id,
1186 )
1188####################
1191def share_network_subnet_metadata_get(context, share_network_subnet_id,
1192 **kwargs):
1193 """Get all metadata for a share network subnet."""
1194 return IMPL.share_network_subnet_metadata_get(context,
1195 share_network_subnet_id,
1196 **kwargs)
1199def share_network_subnet_metadata_get_item(context, share_network_subnet_id,
1200 key):
1201 """Get metadata item for a share network subnet."""
1202 return IMPL.share_network_subnet_metadata_get_item(context,
1203 share_network_subnet_id,
1204 key)
1207def share_network_subnet_metadata_delete(context, share_network_subnet_id,
1208 key):
1209 """Delete the given metadata item."""
1210 IMPL.share_network_subnet_metadata_delete(context, share_network_subnet_id,
1211 key)
1214def share_network_subnet_metadata_update(context, share_network_subnet_id,
1215 metadata, delete):
1216 """Update metadata if it exists, otherwise create it."""
1217 return IMPL.share_network_subnet_metadata_update(context,
1218 share_network_subnet_id,
1219 metadata, delete)
1222def share_network_subnet_metadata_update_item(context, share_network_subnet_id,
1223 metadata):
1224 """Update metadata item if it exists, otherwise create it."""
1225 return IMPL.share_network_subnet_metadata_update_item(
1226 context, share_network_subnet_id, metadata)
1228###################
1231def network_allocation_create(context, values):
1232 """Create a network allocation DB record."""
1233 return IMPL.network_allocation_create(context, values)
1236def network_allocation_delete(context, id):
1237 """Delete a network allocation DB record."""
1238 return IMPL.network_allocation_delete(context, id)
1241def network_allocation_update(context, id, values, read_deleted=None):
1242 """Update a network allocation DB record."""
1243 return IMPL.network_allocation_update(context, id, values,
1244 read_deleted=read_deleted)
1247def network_allocation_get(context, id, read_deleted=None):
1248 """Get a network allocation DB record."""
1249 return IMPL.network_allocation_get(context, id, read_deleted=read_deleted)
1252def network_allocations_get_for_share_server(
1253 context, share_server_id, label=None, subnet_id=None,
1254):
1255 """Get network allocations for share server."""
1256 return IMPL.network_allocations_get_for_share_server(
1257 context, share_server_id, label=label, subnet_id=subnet_id,
1258 )
1261def network_allocations_get_by_ip_address(context, ip_address):
1262 """Get network allocations by IP address."""
1263 return IMPL.network_allocations_get_by_ip_address(context, ip_address)
1266##################
1269def share_server_create(context, values):
1270 """Create share server DB record."""
1271 return IMPL.share_server_create(context, values)
1274def share_server_delete(context, id):
1275 """Delete share server DB record."""
1276 return IMPL.share_server_delete(context, id)
1279def share_server_update(context, id, values):
1280 """Update share server DB record."""
1281 return IMPL.share_server_update(context, id, values)
1284def share_server_get(context, id):
1285 """Get share server DB record by ID."""
1286 return IMPL.share_server_get(context, id)
1289def share_server_search_by_identifier(context, identifier):
1290 """Search for share servers based on given identifier."""
1291 return IMPL.share_server_search_by_identifier(
1292 context, identifier,
1293 )
1296def share_server_get_all_by_host_and_share_subnet_valid(
1297 context, host, share_subnet_id,
1298):
1299 """Get share server DB records by host and share net not error."""
1300 return IMPL.share_server_get_all_by_host_and_share_subnet_valid(
1301 context, host, share_subnet_id,
1302 )
1305def share_server_get_all_by_host_and_or_share_subnet(
1306 context, host=None, share_subnet_id=None,
1307):
1308 """Get share server DB records by host and/or share net."""
1309 return IMPL.share_server_get_all_by_host_and_or_share_subnet(
1310 context, host=host, share_subnet_id=share_subnet_id,
1311 )
1314def share_server_get_all(context):
1315 """Get all share server DB records."""
1316 return IMPL.share_server_get_all(context)
1319def share_server_get_all_with_filters(context, filters):
1320 """Get all share servers that match with the specified filters."""
1321 return IMPL.share_server_get_all_with_filters(context, filters)
1324def share_server_get_all_by_host(context, host, filters=None):
1325 """Get all share servers related to particular host."""
1326 return IMPL.share_server_get_all_by_host(context, host, filters=filters)
1329def share_server_get_all_unused_deletable(context, host, updated_before):
1330 """Get all free share servers DB records."""
1331 return IMPL.share_server_get_all_unused_deletable(context, host,
1332 updated_before)
1335def share_get_all_expired(context):
1336 """Get all expired share DB records."""
1337 return IMPL.share_get_all_expired(context)
1340def share_server_backend_details_set(context, share_server_id, server_details):
1341 """Create DB record with backend details."""
1342 return IMPL.share_server_backend_details_set(context, share_server_id,
1343 server_details)
1346def share_server_backend_details_get_item(context, share_server_id, meta_key):
1347 """Get backend details."""
1348 return IMPL.share_server_backend_details_get_item(context, share_server_id,
1349 meta_key)
1352def share_server_backend_details_delete(context, share_server_id):
1353 """Delete backend details DB records for a share server."""
1354 return IMPL.share_server_backend_details_delete(context, share_server_id)
1357def share_servers_update(context, share_server_ids, values):
1358 """Updates values of a bunch of share servers at once."""
1359 return IMPL.share_servers_update(
1360 context, share_server_ids, values)
1363##################
1366def share_type_create(context, values, projects=None):
1367 """Create a new share type."""
1368 return IMPL.share_type_create(context, values, projects)
1371def share_type_update(context, share_type_id, values):
1372 """Update an exist share type."""
1373 return IMPL.share_type_update(context, share_type_id, values)
1376def share_type_get_all(context, inactive=False, filters=None):
1377 """Get all share types.
1379 :param context: context to query under
1380 :param inactive: Include inactive share types to the result set
1381 :param filters: Filters for the query in the form of key/value.
1382 :is_public: Filter share types based on visibility:
1384 * **True**: List public share types only
1385 * **False**: List private share types only
1386 * **None**: List both public and private share types
1388 :returns: list of matching share types
1389 """
1390 return IMPL.share_type_get_all(context, inactive, filters)
1393def share_type_get(context, type_id, inactive=False, expected_fields=None):
1394 """Get share type by id.
1396 :param context: context to query under
1397 :param type_id: share type id to get.
1398 :param inactive: Consider inactive share types when searching
1399 :param expected_fields: Return those additional fields.
1400 Supported fields are: projects.
1401 :returns: share type
1402 """
1403 return IMPL.share_type_get(context, type_id, inactive, expected_fields)
1406def share_type_get_by_name(context, name):
1407 """Get share type by name."""
1408 return IMPL.share_type_get_by_name(context, name)
1411def share_type_get_by_name_or_id(context, name_or_id):
1412 """Get share type by name or ID and return None if not found."""
1413 return IMPL.share_type_get_by_name_or_id(context, name_or_id)
1416def share_type_access_get_all(context, type_id):
1417 """Get all share type access of a share type."""
1418 return IMPL.share_type_access_get_all(context, type_id)
1421def share_type_access_add(context, type_id, project_id):
1422 """Add share type access for project."""
1423 return IMPL.share_type_access_add(context, type_id, project_id)
1426def share_type_access_remove(context, type_id, project_id):
1427 """Remove share type access for project."""
1428 return IMPL.share_type_access_remove(context, type_id, project_id)
1431def share_type_destroy(context, id):
1432 """Delete a share type."""
1433 return IMPL.share_type_destroy(context, id)
1436####################
1439def share_type_extra_specs_get(context, share_type_id):
1440 """Get all extra specs for a share type."""
1441 return IMPL.share_type_extra_specs_get(context, share_type_id)
1444def share_type_extra_specs_delete(context, share_type_id, key):
1445 """Delete the given extra specs item."""
1446 return IMPL.share_type_extra_specs_delete(context, share_type_id, key)
1449def share_type_extra_specs_update_or_create(context, share_type_id,
1450 extra_specs):
1451 """Create or update share type extra specs.
1453 This adds or modifies the key/value pairs specified in the extra
1454 specs dict argument.
1455 """
1456 return IMPL.share_type_extra_specs_update_or_create(context,
1457 share_type_id,
1458 extra_specs)
1461def driver_private_data_get(context, entity_id, key=None, default=None):
1462 """Get one, list or all key-value pairs for given entity_id."""
1463 return IMPL.driver_private_data_get(context, entity_id, key, default)
1466def driver_private_data_update(context, entity_id, details,
1467 delete_existing=False):
1468 """Update key-value pairs for given entity_id."""
1469 return IMPL.driver_private_data_update(context, entity_id, details,
1470 delete_existing)
1473def driver_private_data_delete(context, entity_id, key=None):
1474 """Remove one, list or all key-value pairs for given entity_id."""
1475 return IMPL.driver_private_data_delete(context, entity_id, key)
1478####################
1480def availability_zone_get(context, id_or_name):
1481 """Get availability zone by name or id."""
1482 return IMPL.availability_zone_get(context, id_or_name)
1485def availability_zone_get_all(context):
1486 """Get all active availability zones."""
1487 return IMPL.availability_zone_get_all(context)
1490####################
1492def share_group_get(context, share_group_id):
1493 """Get a share group or raise if it does not exist."""
1494 return IMPL.share_group_get(context, share_group_id)
1497def share_group_get_all(context, detailed=True, filters=None, sort_key=None,
1498 sort_dir=None):
1499 """Get all share groups."""
1500 return IMPL.share_group_get_all(
1501 context, detailed=detailed, filters=filters, sort_key=sort_key,
1502 sort_dir=sort_dir)
1505def share_group_get_all_by_host(context, host, detailed=True, filters=None,
1506 sort_key=None, sort_dir=None):
1507 """Get all share groups belonging to a host."""
1508 return IMPL.share_group_get_all_by_host(
1509 context, host, detailed=detailed, filters=filters, sort_key=sort_key,
1510 sort_dir=sort_dir)
1513def share_group_create(context, values):
1514 """Create a share group from the values dictionary."""
1515 return IMPL.share_group_create(context, values)
1518def share_group_get_all_by_share_server(context, share_server_id,
1519 filters=None, sort_key=None,
1520 sort_dir=None):
1521 """Get all share groups associated with a share server."""
1522 return IMPL.share_group_get_all_by_share_server(
1523 context, share_server_id, filters=filters, sort_key=sort_key,
1524 sort_dir=sort_dir)
1527def share_group_get_all_by_project(context, project_id, detailed=True,
1528 filters=None, sort_key=None,
1529 sort_dir=None):
1530 """Get all share groups belonging to a project."""
1531 return IMPL.share_group_get_all_by_project(
1532 context, project_id, detailed=detailed, filters=filters,
1533 sort_key=sort_key, sort_dir=sort_dir)
1536def share_group_update(context, share_group_id, values):
1537 """Set the given properties on a share group and update it.
1539 Raises NotFound if share group does not exist.
1540 """
1541 return IMPL.share_group_update(context, share_group_id, values)
1544def share_group_destroy(context, share_group_id):
1545 """Destroy the share group or raise if it does not exist."""
1546 return IMPL.share_group_destroy(context, share_group_id)
1549def count_shares_in_share_group(context, share_group_id):
1550 """Returns the number of undeleted shares with the specified group."""
1551 return IMPL.count_shares_in_share_group(context, share_group_id)
1554def get_all_shares_by_share_group(context, share_group_id):
1555 return IMPL.get_all_shares_by_share_group(context, share_group_id)
1558def count_share_group_snapshots_in_share_group(context, share_group_id):
1559 """Returns the number of sg snapshots with the specified share group."""
1560 return IMPL.count_share_group_snapshots_in_share_group(
1561 context, share_group_id)
1564def count_share_groups_in_share_network(context, share_network_id):
1565 """Return the number of groups with the specified share network."""
1566 return IMPL.count_share_groups_in_share_network(context, share_network_id)
1569def count_share_group_snapshot_members_in_share(
1570 context, share_id, include_deferred_deleting=True
1571):
1572 """Returns the number of group snapshot members linked to the share."""
1573 return IMPL.count_share_group_snapshot_members_in_share(
1574 context, share_id, include_deferred_deleting=include_deferred_deleting)
1577def share_group_snapshot_get(context, share_group_snapshot_id):
1578 """Get a share group snapshot."""
1579 return IMPL.share_group_snapshot_get(context, share_group_snapshot_id)
1582def share_group_snapshot_get_all(context, detailed=True, filters=None,
1583 sort_key=None, sort_dir=None):
1584 """Get all share group snapshots."""
1585 return IMPL.share_group_snapshot_get_all(
1586 context, detailed=detailed, filters=filters, sort_key=sort_key,
1587 sort_dir=sort_dir)
1590def share_group_snapshot_get_all_by_project(context, project_id, detailed=True,
1591 filters=None, sort_key=None,
1592 sort_dir=None):
1593 """Get all share group snapshots belonging to a project."""
1594 return IMPL.share_group_snapshot_get_all_by_project(
1595 context, project_id, detailed=detailed, filters=filters,
1596 sort_key=sort_key, sort_dir=sort_dir)
1599def share_group_snapshot_create(context, values):
1600 """Create a share group snapshot from the values dictionary."""
1601 return IMPL.share_group_snapshot_create(context, values)
1604def share_group_snapshot_update(context, share_group_snapshot_id, values):
1605 """Set the given properties on a share group snapshot and update it.
1607 Raises NotFound if share group snapshot does not exist.
1608 """
1609 return IMPL.share_group_snapshot_update(
1610 context, share_group_snapshot_id, values)
1613def share_group_snapshot_destroy(context, share_group_snapshot_id):
1614 """Destroy the share_group_snapshot or raise if it does not exist."""
1615 return IMPL.share_group_snapshot_destroy(context, share_group_snapshot_id)
1618def share_group_snapshot_members_get_all(context, share_group_snapshot_id):
1619 """Return the members of a share group snapshot."""
1620 return IMPL.share_group_snapshot_members_get_all(
1621 context, share_group_snapshot_id)
1624def share_group_snapshot_member_create(context, values):
1625 """Create a share group snapshot member from the values dictionary."""
1626 return IMPL.share_group_snapshot_member_create(context, values)
1629def share_group_snapshot_member_update(context, member_id, values):
1630 """Set the given properties on a share group snapshot member and update it.
1632 Raises NotFound if share_group_snapshot member does not exist.
1633 """
1634 return IMPL.share_group_snapshot_member_update(context, member_id, values)
1637def share_resources_host_update(context, current_host, new_host):
1638 """Update the host attr of all share resources that are on current_host."""
1639 return IMPL.share_resources_host_update(context, current_host, new_host)
1642####################
1644def share_replicas_get_all(context, with_share_server=False,
1645 with_share_data=False):
1646 """Returns all share replicas regardless of share."""
1647 return IMPL.share_replicas_get_all(
1648 context, with_share_server=with_share_server,
1649 with_share_data=with_share_data)
1652def share_replicas_get_all_by_share(context, share_id, with_share_server=False,
1653 with_share_data=False):
1654 """Returns all share replicas for a given share."""
1655 return IMPL.share_replicas_get_all_by_share(
1656 context, share_id, with_share_server=with_share_server,
1657 with_share_data=with_share_data)
1660def share_replicas_get_available_active_replica(context, share_id,
1661 with_share_server=False,
1662 with_share_data=False):
1663 """Returns an active replica for a given share."""
1664 return IMPL.share_replicas_get_available_active_replica(
1665 context, share_id, with_share_server=with_share_server,
1666 with_share_data=with_share_data)
1669def share_replica_get(context, replica_id, with_share_server=False,
1670 with_share_data=False):
1671 """Get share replica by id."""
1672 return IMPL.share_replica_get(
1673 context, replica_id, with_share_server=with_share_server,
1674 with_share_data=with_share_data)
1677def share_replica_update(context, share_replica_id, values,
1678 with_share_data=False):
1679 """Updates a share replica with given values."""
1680 return IMPL.share_replica_update(context, share_replica_id, values,
1681 with_share_data=with_share_data)
1684def share_replica_delete(context, replica_id, need_to_update_usages=True):
1685 """Deletes a share replica."""
1686 return IMPL.share_replica_delete(
1687 context, replica_id, need_to_update_usages=need_to_update_usages)
1690def purge_deleted_records(context, age_in_days):
1691 """Purge deleted rows older than given age from all tables
1693 :raises: InvalidParameterValue if age_in_days is incorrect.
1694 """
1695 return IMPL.purge_deleted_records(context, age_in_days=age_in_days)
1698####################
1701def share_group_type_create(context, values, projects=None):
1702 """Create a new share group type."""
1703 return IMPL.share_group_type_create(context, values, projects)
1706def share_group_type_get_all(context, inactive=False, filters=None):
1707 """Get all share group types.
1709 :param context: context to query under
1710 :param inactive: Include inactive share group types to the result set
1711 :param filters: Filters for the query in the form of key/value.
1712 :is_public: Filter share group types based on visibility:
1714 * **True**: List public group types only
1715 * **False**: List private group types only
1716 * **None**: List both public and private group types
1718 :returns: list of matching share group types
1719 """
1720 return IMPL.share_group_type_get_all(context, inactive, filters)
1723def share_group_type_get(context, type_id, inactive=False,
1724 expected_fields=None):
1725 """Get share_group type by id.
1727 :param context: context to query under
1728 :param type_id: group type id to get.
1729 :param inactive: Consider inactive group types when searching
1730 :param expected_fields: Return those additional fields.
1731 Supported fields are: projects.
1732 :returns: share group type
1733 """
1734 return IMPL.share_group_type_get(
1735 context, type_id, inactive, expected_fields)
1738def share_group_type_get_by_name(context, name):
1739 """Get share group type by name."""
1740 return IMPL.share_group_type_get_by_name(context, name)
1743def share_group_type_access_get_all(context, type_id):
1744 """Get all share group type access of a share group type."""
1745 return IMPL.share_group_type_access_get_all(context, type_id)
1748def share_group_type_access_add(context, type_id, project_id):
1749 """Add share group type access for project."""
1750 return IMPL.share_group_type_access_add(context, type_id, project_id)
1753def share_group_type_access_remove(context, type_id, project_id):
1754 """Remove share group type access for project."""
1755 return IMPL.share_group_type_access_remove(context, type_id, project_id)
1758def share_group_type_destroy(context, type_id):
1759 """Delete a share group type."""
1760 return IMPL.share_group_type_destroy(context, type_id)
1763def share_group_type_specs_get(context, type_id):
1764 """Get all group specs for a share group type."""
1765 return IMPL.share_group_type_specs_get(context, type_id)
1768def share_group_type_specs_delete(context, type_id, key):
1769 """Delete the given group specs item."""
1770 return IMPL.share_group_type_specs_delete(context, type_id, key)
1773def share_group_type_specs_update_or_create(context, type_id, group_specs):
1774 """Create or update share group type specs.
1776 This adds or modifies the key/value pairs specified in the group
1777 specs dict argument.
1778 """
1779 return IMPL.share_group_type_specs_update_or_create(
1780 context, type_id, group_specs)
1783####################
1786def message_get(context, message_id):
1787 """Return a message with the specified ID."""
1788 return IMPL.message_get(context, message_id)
1791def message_get_all(context, filters=None, limit=None, offset=None,
1792 sort_key=None, sort_dir=None):
1793 """Returns all messages with the project of the specified context."""
1794 return IMPL.message_get_all(context, filters=filters, limit=limit,
1795 offset=offset, sort_key=sort_key,
1796 sort_dir=sort_dir)
1799def message_create(context, values):
1800 """Creates a new message with the specified values."""
1801 return IMPL.message_create(context, values)
1804def message_destroy(context, message_id):
1805 """Deletes message with the specified ID."""
1806 return IMPL.message_destroy(context, message_id)
1809def cleanup_expired_messages(context):
1810 """Soft delete expired messages"""
1811 return IMPL.cleanup_expired_messages(context)
1814def backend_info_get(context, host):
1815 """Get hash info for given host."""
1816 return IMPL.backend_info_get(context, host)
1819def backend_info_update(context, host, value=None,
1820 delete_existing=False):
1821 """Update hash info for host."""
1822 return IMPL.backend_info_update(context, host=host, value=value,
1823 delete_existing=delete_existing)
1825####################
1828def async_operation_data_get(context, entity_id, key=None, default=None):
1829 """Get one, list or all key-value pairs for given entity_id."""
1830 return IMPL.async_operation_data_get(context, entity_id, key, default)
1833def async_operation_data_update(context, entity_id, details,
1834 delete_existing=False):
1835 """Update key-value pairs for given entity_id."""
1836 return IMPL.async_operation_data_update(context, entity_id, details,
1837 delete_existing)
1840def async_operation_data_delete(context, entity_id, key=None):
1841 """Remove one, list or all key-value pairs for given entity_id."""
1842 return IMPL.async_operation_data_delete(context, entity_id, key)
1844####################
1847def share_backup_create(context, share_id, values):
1848 """Create new share backup with specified values."""
1849 return IMPL.share_backup_create(context, share_id, values)
1852def share_backup_update(context, backup_id, values):
1853 """Updates a share backup with given values."""
1854 return IMPL.share_backup_update(context, backup_id, values)
1857def share_backup_get(context, backup_id):
1858 """Get share backup by id."""
1859 return IMPL.share_backup_get(context, backup_id)
1862def share_backups_get_all(context, filters=None, limit=None, offset=None,
1863 sort_key=None, sort_dir=None):
1864 """Get all backups."""
1865 return IMPL.share_backups_get_all(
1866 context, filters=filters, limit=limit, offset=offset,
1867 sort_key=sort_key, sort_dir=sort_dir)
1870def share_backup_delete(context, backup_id):
1871 """Deletes backup with the specified ID."""
1872 return IMPL.share_backup_delete(context, backup_id)
1874#####################
1877def resource_lock_create(context, values):
1878 """Create a resource lock."""
1879 return IMPL.resource_lock_create(context, values)
1882def resource_lock_update(context, lock_id, values):
1883 """Update a resource lock."""
1884 return IMPL.resource_lock_update(context, lock_id, values)
1887def resource_lock_delete(context, lock_id):
1888 """Delete a resource lock."""
1889 return IMPL.resource_lock_delete(context, lock_id)
1892def resource_lock_get(context, lock_id):
1893 """Retrieve a resource lock."""
1894 return IMPL.resource_lock_get(context, lock_id)
1897def resource_lock_get_all(context, **kwargs):
1898 """Retrieve all resource locks."""
1899 return IMPL.resource_lock_get_all(context, **kwargs)
1901##################
1904def encryption_keys_get_count(context, filters=None):
1905 """Get count of encryption keys."""
1906 return IMPL.encryption_keys_get_count(context, filters=filters)
1909def encryption_keys_get_all(context, filters=None):
1910 """Get all encryption keys."""
1911 return IMPL.encryption_keys_get_all(context, filters=filters)