Package yakumo :: Package nova :: Package v2 :: Module security_group
[hide private]
[frames] | no frames]

Source Code for Module yakumo.nova.v2.security_group

 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 security groups in Compute API v2 
18  """ 
19   
20  from yakumo import base 
21  from yakumo.constant import UNDEF 
22  from yakumo import mapper 
23  from yakumo import utils 
24  from . import security_group_rule 
25   
26   
27  ATTRIBUTE_MAPPING = [ 
28      ('id', 'id', mapper.Noop), 
29      ('name', 'name', mapper.Noop), 
30      ('description', 'description', mapper.Noop), 
31      ('_rules', 'rules', mapper.Noop), 
32      ('project', 'tenant_id', mapper.Resource('project')), 
33  ] 
34   
35   
36 -class Resource(base.Resource):
37 """Resource class for security groups in Compute API v2""" 38 39 _sub_manager_list = { 40 'rules': security_group_rule.Manager 41 }
42 43
44 -class Manager(base.Manager):
45 """Manager class for security groups in Compute API v2""" 46 47 resource_class = Resource 48 service_type = 'compute' 49 _attr_mapping = ATTRIBUTE_MAPPING 50 _hidden_methods = ["update"] 51 _json_resource_key = 'security_group' 52 _json_resources_key = 'security_groups' 53 _url_resource_path = '/os-security-groups' 54
55 - def create(self, name=UNDEF, description=UNDEF, project=UNDEF):
56 """ 57 Create a security group 58 59 @keyword name: Security group name 60 @type name: str 61 @keyword description: Description 62 @type description: str 63 @keyword project: Project 64 @type project: yakumo.project.Resource 65 @return: Created security group 66 @rtype: yakumo.nova.v2.security_group.Resource 67 """ 68 return super(Manager, self).create(name=name, 69 description=description, 70 project=project)
71