• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2010 Reza Lotun http://reza.lotun.name
2#
3# Permission is hereby granted, free of charge, to any person obtaining a
4# copy of this software and associated documentation files (the
5# "Software"), to deal in the Software without restriction, including
6# without limitation the rights to use, copy, modify, merge, publish, dis-
7# tribute, sublicense, and/or sell copies of the Software, and to permit
8# persons to whom the Software is furnished to do so, subject to the fol-
9# lowing conditions:
10#
11# The above copyright notice and this permission notice shall be included
12# in all copies or substantial portions of the Software.
13#
14# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
16# ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
17# SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
18# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20# IN THE SOFTWARE.
21
22from boto.resultset import ResultSet
23
24
25class AppCookieStickinessPolicy(object):
26    def __init__(self, connection=None):
27        self.cookie_name = None
28        self.policy_name = None
29
30    def __repr__(self):
31        return 'AppCookieStickiness(%s, %s)' % (self.policy_name,
32                                                self.cookie_name)
33
34    def startElement(self, name, attrs, connection):
35        pass
36
37    def endElement(self, name, value, connection):
38        if name == 'CookieName':
39            self.cookie_name = value
40        elif name == 'PolicyName':
41            self.policy_name = value
42
43
44class LBCookieStickinessPolicy(object):
45    def __init__(self, connection=None):
46        self.policy_name = None
47        self.cookie_expiration_period = None
48
49    def __repr__(self):
50        return 'LBCookieStickiness(%s, %s)' % (self.policy_name,
51                                               self.cookie_expiration_period)
52
53    def startElement(self, name, attrs, connection):
54        pass
55
56    def endElement(self, name, value, connection):
57        if name == 'CookieExpirationPeriod':
58            self.cookie_expiration_period = value
59        elif name == 'PolicyName':
60            self.policy_name = value
61
62
63class OtherPolicy(object):
64    def __init__(self, connection=None):
65        self.policy_name = None
66
67    def __repr__(self):
68        return 'OtherPolicy(%s)' % (self.policy_name)
69
70    def startElement(self, name, attrs, connection):
71        pass
72
73    def endElement(self, name, value, connection):
74        self.policy_name = value
75
76
77class Policies(object):
78    """
79    ELB Policies
80    """
81    def __init__(self, connection=None):
82        self.connection = connection
83        self.app_cookie_stickiness_policies = None
84        self.lb_cookie_stickiness_policies = None
85        self.other_policies = None
86
87    def __repr__(self):
88        app = 'AppCookieStickiness%s' % self.app_cookie_stickiness_policies
89        lb = 'LBCookieStickiness%s' % self.lb_cookie_stickiness_policies
90        other = 'Other%s' % self.other_policies
91        return 'Policies(%s,%s,%s)' % (app, lb, other)
92
93    def startElement(self, name, attrs, connection):
94        if name == 'AppCookieStickinessPolicies':
95            rs = ResultSet([('member', AppCookieStickinessPolicy)])
96            self.app_cookie_stickiness_policies = rs
97            return rs
98        elif name == 'LBCookieStickinessPolicies':
99            rs = ResultSet([('member', LBCookieStickinessPolicy)])
100            self.lb_cookie_stickiness_policies = rs
101            return rs
102        elif name == 'OtherPolicies':
103            rs = ResultSet([('member', OtherPolicy)])
104            self.other_policies = rs
105            return rs
106
107    def endElement(self, name, value, connection):
108        return
109