1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 """
17 Resource class and its manager for subnets in Networking V2 API
18 """
19
20 from yakumo import base
21 from yakumo.constant import UNDEF
22 from yakumo import mapper
23
24
25 ATTRIBUTE_MAPPING = [
26 ('id', 'id', mapper.Noop),
27 ('name', 'name', mapper.Noop),
28 ('network', 'network_id', mapper.Resource('neutron.network')),
29 ('gateway_ip', 'gateway_ip', mapper.Noop),
30 ('dns_nameservers', 'dns_nameservers', mapper.Noop),
31 ('host_route', 'host_route', mapper.Noop),
32 ('ip_version', 'ip_version', mapper.Noop),
33 ('cidr', 'cidr', mapper.Noop),
34 ('is_dhcp_enabled', 'enable_dhcp', mapper.Noop),
35 ('ipv6_ra_mode', 'ipv6_ra_mode', mapper.Noop),
36 ('ipv6_address_mode', 'ipv6_address_mode', mapper.Noop),
37 ]
38
39
41 """Resource class for subnets in Networking V2 API"""
42
46 """
47 Update properties of a subnet
48 @keyword name: Subnet name
49 @type name: str
50 @keyword allocation_pools: Allocation pools
51 @type allocation_pools: str
52 @keyword gateway_ip: Gateway IP address
53 @type gateway_ip: str
54 @keyword is_dhcp_enabled: Whether DHCP is enabled
55 @type is_dhcp_enabled: bool
56 @keyword dns_nameservers: DNS nameservers
57 @type dns_nameservers: str
58 @keyword host_routes: Host routes
59 @type host_routes: str
60 @rtype: None
61 """
62 super(Resource, self).update(
63 name=name,
64 allocation_pools=allocation_pools,
65 gateway_ip=gateway_ip,
66 is_dhcp_enabled=is_dhcp_enabled,
67 dns_nameservers=dns_nameservers,
68 host_routes=host_routes)
69
70
72 """Manager class for subnets in Networking V2 API"""
73
74 resource_class = Resource
75 service_type = 'network'
76 _attr_mapping = ATTRIBUTE_MAPPING
77 _json_resource_key = 'subnet'
78 _json_resources_key = 'subnets'
79 _url_resource_path = '/v2.0/subnets'
80
81 - def create(self, name=UNDEF, network=UNDEF, project=UNDEF,
82 allocation_pools=UNDEF, gateway_ip=UNDEF, ip_version=UNDEF,
83 cidr=UNDEF, is_dhcp_enabled=UNDEF, dns_nameservers=UNDEF,
84 host_routes=UNDEF, ipv6_ra_mode=UNDEF, ipv6_address_mode=UNDEF):
85 """
86 Create a subnet
87
88 @keyword name: Subnet name
89 @type name: str
90 @keyword network: Network
91 @type network: yakumo.neutron.v2.network.Resource
92 @keyword project: Project
93 @type project: yakumo.project.Resource
94 @keyword allocation_pools: Allocation pools
95 @type allocation_pools: str
96 @keyword gateway_ip: Gateway IP address
97 @type gateway_ip: str
98 @keyword ip_version: IP version
99 @type ip_version: int
100 @keyword cidr: CIDR
101 @type cidr: str
102 @keyword is_dhcp_enabled: Whether DHCP is enabled
103 @type is_dhcp_enabled: bool
104 @keyword dns_nameservers: DNS nameservers
105 @type dns_nameservers: str
106 @keyword host_routes: Host routes
107 @type host_routes: str
108 @keyword ipv6_ra_mode: IPv6 RA mode
109 @type ipv6_ra_mode: str
110 @keyword ipv6_address_mode: IPv6 address mode
111 @type ipv6_address_mode: str
112 @return: Created subnet
113 @rtype: yakumo.neutron.v2.subnet.Resource
114 """
115 return super(Manager, self).create(
116 name=name,
117 network=network,
118 project=project,
119 allocation_pools=allocation_pools,
120 gateway_ip=gateway_ip,
121 ip_version=ip_version, cidr=cidr,
122 is_dhcp_enabled=is_dhcp_enabled,
123 dns_nameservers=dns_nameservers,
124 host_routes=host_routes,
125 ipv6_ra_mode=ipv6_ra_mode,
126 ipv6_address_mode=ipv6_address_mode)
127