yakumo.cinder.v2.consistency_group_snapshot

Package yakumo :: Package cinder :: Package v2 :: Module consistency_group_snapshot |
[hide private]
[frames] | no frames]

# Source Code for Module yakumo.cinder.v2.consistency_group_snapshot

     1  # Copyright 2014-2017 by Akira Yoshiyama <akirayoshiyama@gmail.com>.
     2  # All Rights Reserved.
     3  #
     4  #    Licensed under the Apache License, Version 2.0 (the "License"); you may
     5  #    not use this file except in compliance with the License. You may obtain
     6  #    a copy of the License at
     7  #
     8  #         http://www.apache.org/licenses/LICENSE-2.0
     9  #
    10  #    Unless required by applicable law or agreed to in writing, software
    11  #    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
    12  #    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
    13  #    License for the specific language governing permissions and limitations
    14  #    under the License.
    15
    16  """
    17  Resource class and its manager for consistency group snapshot on
    18  Block Storage V2 API
    19  """
    20
    21  from yakumo import base
    22  from yakumo.constant import UNDEF
    23  from yakumo import mapper
    24
    25
    26  ATTRIBUTE_MAPPING = [
    27      ('id', 'id', mapper.Noop),
    28      ('name', 'name', mapper.Noop),
    29      ('description', 'display_description', mapper.Noop),
    30      ('source_cg', 'consistencygroup_id',
    31       mapper.List(mapper.Resource('cinder.consistency_group'))),
    32      ('project', 'project_id', mapper.List(mapper.Resource('project'))),
    33      ('user', 'user_id', mapper.List(mapper.Resource('user'))),
    34      ('status', 'status', mapper.Noop),
    35      ('created_at', 'created_at', mapper.DateTime),
    36  ]
    37
    38
    39 -class Resource(base.Resource):
    40      """resource class for consistency group snapshot on Block Storage V2 API"""
    41
    42
    43 -class Manager(base.Manager):
    44      """manager class for consistency group snapshot on Block Storage V2 API"""
    45
    46      resource_class = Resource
    47      service_type = 'volume'
    48      _attr_mapping = ATTRIBUTE_MAPPING
    49      _hidden_methods = ['update']
    50      _json_resource_key = 'cgsnapshot'
    51      _json_resources_key = 'cgsnapshots'
    52      _url_resource_list_path = '/cgsnapshots/detail'
    53      _url_resource_path = '/cgsnapshots'
    54
    55 -    def create(self, name=UNDEF, description=UNDEF, source_cg=UNDEF,
    56                 project=UNDEF, user=UNDEF, status=UNDEF):
    57          """
    58          Create a consistency group snapshot
    59
    60          @keyword name: Consistency group name
    61          @type name: str
    62          @keyword description: Description
    63          @type description: str
    64          @keyword source_cg: Source consistency group
    65          @type source_cg: yakumo.cinder.v2.consistency_group.Resource
    66          @keyword project: Project (optional)
    67          @type project: yakumo.project.Resource
    68          @keyword user: User (optional)
    69          @type user: yakumo.user.Resource
    70          @return: Created consistency group snapshot
    71          @rtype: yakumo.cinder.v2.consistency_group_snapshot.Resource
    72          """
    73          return super(Manager, self).create(
    74              name=name,
    75              description=description,
    76              source_cg=source_cg,
    77              project=project,
    78              user=user,
    79              status=status)
    80