1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 """
17 Resource class and its manager for LBaaS listeners 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
25
26 ATTRIBUTE_MAPPING = [
27 ('id', 'id', mapper.Noop),
28 ('name', 'name', mapper.Noop),
29 ('description', 'description', mapper.Noop),
30 ('protocol', 'protocol', mapper.Noop),
31 ('protocol_port', 'protocol_port', mapper.Noop),
32 ('connection_limit', 'connection_limit', mapper.Noop),
33 ('default_tls_container_ref', 'default_tls_container_ref',
34 mapper.Noop),
35 ('sni_container_refs', 'sni_container_refs', mapper.Noop),
36 ('default_pool', 'default_pool_id',
37 mapper.Resource('neutron.lbaas.pool')),
38 ('project', 'tenant_id', mapper.Resource('project')),
39 ('is_enabled', 'admin_state_up', mapper.Noop),
40 ]
41
42
44 """Resource class for LBaaS listeners in Networking V2 API"""
45
49
50 """
51 Update a listener for LBaaS
52
53 @keyword name: Listener name
54 @type name: srt
55 @keyword description: Description
56 @type description: str
57 @keyword connection_limit: Maximun connection number
58 @type connection_limit: int
59 @keyword default_tls_container_ref: A reference to a container of
60 TLS secrets
61 @type default_tls_container_ref: str
62 @keyword sni_container_refs: A list of references to TLS secrets
63 @type sni_container_refs: [str]
64 @keyword is_enabled: Is listener enabled
65 @type is_enabled: bool
66 @rtype: None
67 """
68 super(Resource, self).update(
69 name=name,
70 description=description,
71 connection_limit=connection_limit,
72 default_tls_container_ref=default_tls_container_ref,
73 sni_container_refs=sni_container_refs,
74 is_enabled=is_enabled)
75
76
78 """Manager class for LBaaS listeners in Networking V2 API"""
79
80 resource_class = Resource
81 service_type = 'network'
82 _attr_mapping = ATTRIBUTE_MAPPING
83 _json_resource_key = 'listener'
84 _json_resources_key = 'listeners'
85 _url_resource_path = '/v2.0/lbaas/listeners'
86
91 """
92 Create a listener for LBaaS
93
94 @keyword name: Listener name
95 @type name: str
96 @keyword description: Description
97 @type description: str
98 @keyword protocol: Protocol ('TCP', 'UDP', 'HTTP' or 'HTTPS')
99 @type protocol: str
100 @keyword protocol_port: Protocol port number
101 @type protocol_port: int
102 @keyword connection_limit: Maximun connection number
103 @type connection_limit: int
104 @keyword default_tls_container_ref: A reference to a container of
105 TLS secrets
106 @type default_tls_container_ref: str
107 @keyword sni_container_refs: A list of references to TLS secrets
108 @type sni_container_refs: str
109 @keyword project: Project
110 @type project: yakumo.project.Resource
111 @keyword is_enabled: Whether the listner is enabled
112 @type is_enabled: bool
113 @return: Created listener
114 @rtype: yakumo.neutron.v2.lbaas.listener.Resource
115 """
116 load_balancer = self.parent_resource
117 return super(Manager, self).create(
118 name=name,
119 description=description,
120 protocol=protocol,
121 protocol_port=protocol_port,
122 connection_limit=connection_limit,
123 loadbalancer=loadbalancer,
124 default_tls_container_ref=default_tls_container_ref,
125 sni_container_refs=sni_container_refs,
126 project=project,
127 is_enabled=is_enabled)
128