~ubuntu-branches/ubuntu/quantal/nova/quantal-proposed

« back to all changes in this revision

Viewing changes to nova/network/quantum/sg.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short
  • Date: 2012-08-16 14:04:11 UTC
  • mto: This revision was merged to the branch mainline in revision 84.
  • Revision ID: package-import@ubuntu.com-20120816140411-0mr4n241wmk30t9l
Tags: upstream-2012.2~f3
ImportĀ upstreamĀ versionĀ 2012.2~f3

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# vim: tabstop=4 shiftwidth=4 softtabstop=4
2
 
 
3
 
# Copyright 2012 Nicira Networks, Inc
4
 
# All Rights Reserved.
5
 
#
6
 
#    Licensed under the Apache License, Version 2.0 (the "License"); you may
7
 
#    not use this file except in compliance with the License. You may obtain
8
 
#    a copy of the License at
9
 
#
10
 
#         http://www.apache.org/licenses/LICENSE-2.0
11
 
#
12
 
#    Unless required by applicable law or agreed to in writing, software
13
 
#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14
 
#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15
 
#    License for the specific language governing permissions and limitations
16
 
#    under the License.
17
 
 
18
 
'''Implement Security Groups abstraction and API.
19
 
 
20
 
The nova security_group_handler flag specifies which class is to be used
21
 
to implement the security group calls.
22
 
 
23
 
The NullSecurityGroupHandler provides a "no-op" plugin that is loaded
24
 
by default and has no impact on current system behavior.  In the future,
25
 
special purposes classes that inherit from SecurityGroupHandlerBase
26
 
will provide enhanced functionality and will be loadable via the
27
 
security_group_handler flag.
28
 
'''
29
 
 
30
 
from nova.openstack.common import log as logging
31
 
 
32
 
 
33
 
LOG = logging.getLogger(__name__)
34
 
 
35
 
 
36
 
class SecurityGroupHandlerBase(object):
37
 
 
38
 
    def __init__(self):
39
 
        raise NotImplementedError()
40
 
 
41
 
    def trigger_security_group_create_refresh(self, context, group):
42
 
        '''Called when a rule is added to a security_group.
43
 
 
44
 
        :param context: the security context.
45
 
        :param group: the new group added. group is a dictionary that contains
46
 
            the following: user_id, project_id, name, description).'''
47
 
        raise NotImplementedError()
48
 
 
49
 
    def trigger_security_group_destroy_refresh(self, context,
50
 
                                               security_group_id):
51
 
        '''Called when a rule is added to a security_group.
52
 
 
53
 
        :param context: the security context.
54
 
        :param security_group_id: the security group identifier.'''
55
 
        raise NotImplementedError()
56
 
 
57
 
    def trigger_security_group_rule_create_refresh(self, context,
58
 
                                                   rule_ids):
59
 
        '''Called when a rule is added to a security_group.
60
 
 
61
 
        :param context: the security context.
62
 
        :param rule_ids: a list of rule ids that have been affected.'''
63
 
        raise NotImplementedError()
64
 
 
65
 
    def trigger_security_group_rule_destroy_refresh(self, context,
66
 
                                                     rule_ids):
67
 
        '''Called when a rule is removed from a security_group.
68
 
 
69
 
        :param context: the security context.
70
 
        :param rule_ids: a list of rule ids that have been affected.'''
71
 
        raise NotImplementedError()
72
 
 
73
 
    def trigger_instance_add_security_group_refresh(self, context, instance,
74
 
                                                    group_name):
75
 
        '''Called when a security group gains a new member.
76
 
 
77
 
        :param context: the security context.
78
 
        :param instance: the instance to be associated.
79
 
        :param group_name: the name of the security group to be associated.'''
80
 
        raise NotImplementedError()
81
 
 
82
 
    def trigger_instance_remove_security_group_refresh(self, context, instance,
83
 
                                                       group_name):
84
 
        '''Called when a security group loses a member.
85
 
 
86
 
        :param context: the security context.
87
 
        :param instance: the instance to be associated.
88
 
        :param group_name: the name of the security group to be associated.'''
89
 
        raise NotImplementedError()
90
 
 
91
 
    def trigger_security_group_members_refresh(self, context, group_ids):
92
 
        '''Called when a security group gains or loses a member.
93
 
 
94
 
        :param context: the security context.
95
 
        :param group_ids: a list of security group identifiers.'''
96
 
        raise NotImplementedError()
97
 
 
98
 
 
99
 
class NullSecurityGroupHandler(SecurityGroupHandlerBase):
100
 
 
101
 
    def __init__(self):
102
 
        pass
103
 
 
104
 
    def trigger_security_group_create_refresh(self, context, group):
105
 
        '''Called when a rule is added to a security_group.
106
 
 
107
 
        :param context: the security context.
108
 
        :param group: the new group added. group is a dictionary that contains
109
 
            the following: user_id, project_id, name, description).'''
110
 
        pass
111
 
 
112
 
    def trigger_security_group_destroy_refresh(self, context,
113
 
                                               security_group_id):
114
 
        '''Called when a rule is added to a security_group.
115
 
 
116
 
        :param context: the security context.
117
 
        :param security_group_id: the security group identifier.'''
118
 
        pass
119
 
 
120
 
    def trigger_security_group_rule_create_refresh(self, context,
121
 
                                                   rule_ids):
122
 
        '''Called when a rule is added to a security_group.
123
 
 
124
 
        :param context: the security context.
125
 
        :param rule_ids: a list of rule ids that have been affected.'''
126
 
        pass
127
 
 
128
 
    def trigger_security_group_rule_destroy_refresh(self, context,
129
 
                                                     rule_ids):
130
 
        '''Called when a rule is removed from a security_group.
131
 
 
132
 
        :param context: the security context.
133
 
        :param rule_ids: a list of rule ids that have been affected.'''
134
 
        pass
135
 
 
136
 
    def trigger_instance_add_security_group_refresh(self, context, instance,
137
 
                                                    group_name):
138
 
        '''Called when a security group gains a new member.
139
 
 
140
 
        :param context: the security context.
141
 
        :param instance: the instance to be associated.
142
 
        :param group_name: the name of the security group to be associated.'''
143
 
        pass
144
 
 
145
 
    def trigger_instance_remove_security_group_refresh(self, context, instance,
146
 
                                                       group_name):
147
 
        '''Called when a security group loses a member.
148
 
 
149
 
        :param context: the security context.
150
 
        :param instance: the instance to be associated.
151
 
        :param group_name: the name of the security group to be associated.'''
152
 
        pass
153
 
 
154
 
    def trigger_security_group_members_refresh(self, context, group_ids):
155
 
        '''Called when a security group gains or loses a member.
156
 
 
157
 
        :param context: the security context.
158
 
        :param group_ids: a list of security group identifiers.'''
159
 
        pass