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

Source Code for Module yakumo.nova.v2.security_group_default_rule

 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 group default rules in 
18  Compute API v2 
19  """ 
20   
21  from yakumo import base 
22  from yakumo.constant import UNDEF 
23  from yakumo import mapper 
24  from yakumo import utils 
25   
26   
27  ATTRIBUTE_MAPPING = [ 
28      ('id', 'id', mapper.Noop), 
29      ('cidr', 'ip_range', mapper.Noop), 
30      ('lower_port', 'from_port', mapper.Noop), 
31      ('upper_port', 'to_port', mapper.Noop), 
32      ('protocol', 'ip_protocol', mapper.Noop), 
33  ] 
34   
35   
36 -class Resource(base.Resource):
37 """Resource class for security group default rules in Compute API v2"""
38 39
40 -class Manager(base.Manager):
41 """Manager class for security group default rules in Compute API v2""" 42 43 resource_class = Resource 44 service_type = 'compute' 45 _attr_mapping = ATTRIBUTE_MAPPING 46 _hidden_methods = ["update"] 47 _json_resource_key = 'security_group_default_rule' 48 _json_resources_key = 'security_group_default_rules' 49 _url_resource_path = '/os-security-group-default-rules' 50
51 - def create(self, cidr=UNDEF, lower_port=UNDEF, upper_port=UNDEF, 52 protocol=UNDEF):
53 """ 54 Create a security group 55 56 @keyword cidr: IP range (e.q. '0.0.0.0/0', required) 57 @type cidr: str 58 @keyword lower_port: lower number of destination port 59 @type lower_port: int 60 @keyword upper_port: upper number of destination port 61 @type upper_port: int 62 @keyword protocol: protocol name ('tcp', 'udp', or 'icmp') 63 @type protocol: str 64 @return: Created security group 65 @rtype: yakumo.nova.v2.security_group_default_rule.Resource 66 """ 67 return super(Manager, self).create(cidr=cidr, 68 lower_port=lower_port, 69 upper_port=upper_port, 70 protocol=protocol)
71