1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 """
17 Resource class and its manager for LB Pools in Networking V2 API
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 member
25 from . import vip
26
27
28 ATTRIBUTE_MAPPING = [
29 ('id', 'id', mapper.Noop),
30 ('name', 'name', mapper.Noop),
31 ('description', 'description', mapper.Noop),
32 ('lb_method', 'lb_method', mapper.Noop),
33 ('protocol', 'protocol', mapper.Noop),
34 ('subnet', 'subnet_id', mapper.Resource('neutron.subnet')),
35 ('project', 'tenant_id', mapper.Resource('project')),
36 ('health_monitors', 'health_monitors',
37 mapper.List(mapper.Resource('neutron.lb.health_monitor'))),
38 ('is_enabled', 'admin_state_up', mapper.Noop),
39 ('status', 'status', mapper.Noop),
40 ]
41
42
44 """Resource class for LB Pools in Networking V2 API"""
45
46 _sub_manager_list = {
47 'member': member.Manager,
48 'vip': vip.Manager
49 }
50
52 """
53 Update properties of a load balancer pool
54
55 @keyword name: Pool name (str)
56 @type name: Pool name (str)
57 @keyword lb_method: Load balance method (str)
58 ('ROUND_ROBIN', 'LEAST_CONNECTIONS' or 'SOURCE_IP')
59 @type lb_method: Load balance method (str)
60 @rtype: None
61 """
62 super(Resource, self).update(name=name, lb_method=lb_method)
63
65 """
66 Add a health monitor to a pool
67
68 @keyword health_monitor: Health monitor
69 @type health_monitor: yakumo.neutron.v2.lb.health_monitor.Resource
70 @rtype: None
71 """
72 self._http.post(self._url_resource_path, "health_monitors",
73 data=dict(health_monitor=health_monitor.id))
74
76 """
77 Remove a health monitor from a pool
78
79 @keyword health_monitor: Health monitor
80 @type health_monitor: yakumo.neutron.v2.lb.health_monitor.Resource
81 @rtype: None
82 """
83 self._http.delete(self._url_resource_path, "health_monitors",
84 health_monitor.id)
85
86
88 """Manager class for LB Pools in Networking V2 API"""
89
90 resource_class = Resource
91 service_type = 'network'
92 _attr_mapping = ATTRIBUTE_MAPPING
93 _json_resource_key = 'pool'
94 _json_resources_key = 'pools'
95 _url_resource_path = '/v2.0/lb/pools'
96
99 """
100 Create a load balancer pool
101
102 @keyword name: Pool name
103 @type name: str
104 @keyword description: Description
105 @type description: str
106 @keyword lb_method: Load balancing method
107 ('ROUND_ROBIN', 'LEAST_CONNECTIONS' or 'SOURCE_IP')
108 @type lb_method: str
109 @keyword protocol: 'TCP', 'HTTP' or 'HTTPS'
110 @type protocol: str
111 @keyword subnet: Subnet
112 @type subnet: yakumo.neutron.v2.subnet.Resource
113 @keyword is_enabled: Whether the pool is enabled
114 @type is_enabled: bool
115 @return: Created pool
116 @rtype: yakumo.neutron.v2.lb.pool.Resource
117 """
118 return super(Manager, self).create(name=name,
119 description=description,
120 lb_method=lb_method,
121 protocol=protocol,
122 subnet=subnet,
123 is_enabled=is_enabled)
124