Browse Source

Removed local patches

These patches make assumptions that are a bit too liberal.
As these cookbooks are more widely used, these should be
moved into a wrapper cookbook.

Change-Id: I5348876712418a520659aab606065e5a5b288d99
tags/eol-grizzly
John Dewey 6 years ago
parent
commit
36e51d8963

+ 0
- 79
files/default/cinder-volume-usage-audit View File

@@ -1,79 +0,0 @@
1
-#!/usr/bin/env python
2
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
3
-
4
-# Copyright (c) 2011 Openstack, LLC.
5
-# All Rights Reserved.
6
-#
7
-#    Licensed under the Apache License, Version 2.0 (the "License"); you may
8
-#    not use this file except in compliance with the License. You may obtain
9
-#    a copy of the License at
10
-#
11
-#         http://www.apache.org/licenses/LICENSE-2.0
12
-#
13
-#    Unless required by applicable law or agreed to in writing, software
14
-#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
15
-#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
16
-#    License for the specific language governing permissions and limitations
17
-#    under the License.
18
-
19
-"""Cron script to generate usage notifications for volumes existing during
20
-   the audit period.
21
-
22
-   Together with the notifications generated by volumes
23
-   create/delete/resize, over that time period, this allows an external
24
-   system consuming usage notification feeds to calculate volume usage
25
-   for each tenant.
26
-
27
-   Time periods are specified as 'hour', 'month', 'day' or 'year'
28
-
29
-   hour = previous hour. If run at 9:07am, will generate usage for 8-9am.
30
-   month = previous month. If the script is run April 1, it will generate
31
-           usages for March 1 through March 31.
32
-   day = previous day. if run on July 4th, it generates usages for July 3rd.
33
-   year = previous year. If run on Jan 1, it generates usages for
34
-        Jan 1 through Dec 31 of the previous year.
35
-"""
36
-
37
-import gettext
38
-import os
39
-import sys
40
-import traceback
41
-
42
-# If ../cinder/__init__.py exists, add ../ to Python search path, so that
43
-# it will override what happens to be installed in /usr/(local/)lib/python...
44
-POSSIBLE_TOPDIR = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]),
45
-                                   os.pardir,
46
-                                   os.pardir))
47
-if os.path.exists(os.path.join(POSSIBLE_TOPDIR, 'cinder', '__init__.py')):
48
-    sys.path.insert(0, POSSIBLE_TOPDIR)
49
-
50
-gettext.install('cinder', unicode=1)
51
-from cinder import context
52
-from cinder import db
53
-from cinder import flags
54
-from cinder.openstack.common import log as logging
55
-from cinder.openstack.common import rpc
56
-from cinder import utils
57
-import cinder.volume.utils
58
-
59
-
60
-FLAGS = flags.FLAGS
61
-
62
-if __name__ == '__main__':
63
-    admin_context = context.get_admin_context()
64
-    flags.parse_args(sys.argv)
65
-    logging.setup("cinder")
66
-    begin, end = utils.last_completed_audit_period('day')
67
-    print "Starting volume usage audit"
68
-    print "Creating usages for %s until %s" % (str(begin), str(end))
69
-    volumes = db.volume_get_active_by_window(admin_context,
70
-                                             begin,
71
-                                             end)
72
-    print "Found %d volumes" % len(volumes)
73
-    for volume_ref in volumes:
74
-        try:
75
-            cinder.volume.utils.notify_usage_exists(
76
-                    admin_context, volume_ref)
77
-        except Exception, e:
78
-            print traceback.format_exc(e)
79
-    print "Volume usage audit completed"

+ 0
- 35
files/default/fileutils_new-b322585613c21067571442aaf9e4e6feb167832b.py View File

@@ -1,35 +0,0 @@
1
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
2
-
3
-# Copyright 2011 OpenStack LLC.
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
-
19
-import errno
20
-import os
21
-
22
-
23
-def ensure_tree(path):
24
-    """Create a directory (and any ancestor directories required)
25
-
26
-    :param path: Directory to create
27
-    """
28
-    try:
29
-        os.makedirs(path)
30
-    except OSError as exc:
31
-        if exc.errno == errno.EEXIST:
32
-            if not os.path.isdir(path):
33
-                raise
34
-        else:
35
-            raise

+ 0
- 33
files/default/gettextutils_new-8e450aaa6ba1a2a88f6326c2e8d285d00fd28691.py View File

@@ -1,33 +0,0 @@
1
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
2
-
3
-# Copyright 2012 Red Hat, 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
-"""
19
-gettext for openstack-common modules.
20
-
21
-Usual usage in an openstack.common module:
22
-
23
-    from cinder.openstack.common.gettextutils import _
24
-"""
25
-
26
-import gettext
27
-
28
-
29
-t = gettext.translation('openstack-common', 'locale', fallback=True)
30
-
31
-
32
-def _(msg):
33
-    return t.ugettext(msg)

+ 0
- 233
files/default/lockutils_new-6dda4af1dd50582a0271fd6c96044ae61af9df7e.py View File

@@ -1,233 +0,0 @@
1
-# vim: tabstop=4 shiftwidth=4 softtabstop=4
2
-
3
-# Copyright 2011 OpenStack LLC.
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
-
19
-import errno
20
-import functools
21
-import os
22
-import shutil
23
-import tempfile
24
-import time
25
-import weakref
26
-
27
-from eventlet import semaphore
28
-
29
-from cinder.openstack.common import cfg
30
-from cinder.openstack.common import fileutils
31
-from cinder.openstack.common.gettextutils import _
32
-from cinder.openstack.common import log as logging
33
-
34
-
35
-LOG = logging.getLogger(__name__)
36
-
37
-
38
-util_opts = [
39
-    cfg.BoolOpt('disable_process_locking', default=False,
40
-                help='Whether to disable inter-process locks'),
41
-    cfg.StrOpt('lock_path',
42
-               default=os.path.abspath(os.path.join(os.path.dirname(__file__),
43
-                                                    '../')),
44
-               help='Directory to use for lock files')
45
-]
46
-
47
-
48
-CONF = cfg.CONF
49
-CONF.register_opts(util_opts)
50
-
51
-
52
-class _InterProcessLock(object):
53
-    """Lock implementation which allows multiple locks, working around
54
-    issues like bugs.debian.org/cgi-bin/bugreport.cgi?bug=632857 and does
55
-    not require any cleanup. Since the lock is always held on a file
56
-    descriptor rather than outside of the process, the lock gets dropped
57
-    automatically if the process crashes, even if __exit__ is not executed.
58
-
59
-    There are no guarantees regarding usage by multiple green threads in a
60
-    single process here. This lock works only between processes. Exclusive
61
-    access between local threads should be achieved using the semaphores
62
-    in the @synchronized decorator.
63
-
64
-    Note these locks are released when the descriptor is closed, so it's not
65
-    safe to close the file descriptor while another green thread holds the
66
-    lock. Just opening and closing the lock file can break synchronisation,
67
-    so lock files must be accessed only using this abstraction.
68
-    """
69
-
70
-    def __init__(self, name):
71
-        self.lockfile = None
72
-        self.fname = name
73
-
74
-    def __enter__(self):
75
-        self.lockfile = open(self.fname, 'w')
76
-
77
-        while True:
78
-            try:
79
-                # Using non-blocking locks since green threads are not
80
-                # patched to deal with blocking locking calls.
81
-                # Also upon reading the MSDN docs for locking(), it seems
82
-                # to have a laughable 10 attempts "blocking" mechanism.
83
-                self.trylock()
84
-                return self
85
-            except IOError, e:
86
-                if e.errno in (errno.EACCES, errno.EAGAIN):
87
-                    # external locks synchronise things like iptables
88
-                    # updates - give it some time to prevent busy spinning
89
-                    time.sleep(0.01)
90
-                else:
91
-                    raise
92
-
93
-    def __exit__(self, exc_type, exc_val, exc_tb):
94
-        try:
95
-            self.unlock()
96
-            self.lockfile.close()
97
-        except IOError:
98
-            LOG.exception(_("Could not release the acquired lock `%s`"),
99
-                          self.fname)
100
-
101
-    def trylock(self):
102
-        raise NotImplementedError()
103
-
104
-    def unlock(self):
105
-        raise NotImplementedError()
106
-
107
-
108
-class _WindowsLock(_InterProcessLock):
109
-    def trylock(self):
110
-        msvcrt.locking(self.lockfile, msvcrt.LK_NBLCK, 1)
111
-
112
-    def unlock(self):
113
-        msvcrt.locking(self.lockfile, msvcrt.LK_UNLCK, 1)
114
-
115
-
116
-class _PosixLock(_InterProcessLock):
117
-    def trylock(self):
118
-        fcntl.lockf(self.lockfile, fcntl.LOCK_EX | fcntl.LOCK_NB)
119
-
120
-    def unlock(self):
121
-        fcntl.lockf(self.lockfile, fcntl.LOCK_UN)
122
-
123
-
124
-if os.name == 'nt':
125
-    import msvcrt
126
-    InterProcessLock = _WindowsLock
127
-else:
128
-    import fcntl
129
-    InterProcessLock = _PosixLock
130
-
131
-_semaphores = weakref.WeakValueDictionary()
132
-
133
-
134
-def synchronized(name, lock_file_prefix, external=False, lock_path=None):
135
-    """Synchronization decorator.
136
-
137
-    Decorating a method like so::
138
-
139
-        @synchronized('mylock')
140
-        def foo(self, *args):
141
-           ...
142
-
143
-    ensures that only one thread will execute the bar method at a time.
144
-
145
-    Different methods can share the same lock::
146
-
147
-        @synchronized('mylock')
148
-        def foo(self, *args):
149
-           ...
150
-
151
-        @synchronized('mylock')
152
-        def bar(self, *args):
153
-           ...
154
-
155
-    This way only one of either foo or bar can be executing at a time.
156
-
157
-    The lock_file_prefix argument is used to provide lock files on disk with a
158
-    meaningful prefix. The prefix should end with a hyphen ('-') if specified.
159
-
160
-    The external keyword argument denotes whether this lock should work across
161
-    multiple processes. This means that if two different workers both run a
162
-    a method decorated with @synchronized('mylock', external=True), only one
163
-    of them will execute at a time.
164
-
165
-    The lock_path keyword argument is used to specify a special location for
166
-    external lock files to live. If nothing is set, then CONF.lock_path is
167
-    used as a default.
168
-    """
169
-
170
-    def wrap(f):
171
-        @functools.wraps(f)
172
-        def inner(*args, **kwargs):
173
-            # NOTE(soren): If we ever go natively threaded, this will be racy.
174
-            #              See http://stackoverflow.com/questions/5390569/dyn
175
-            #              amically-allocating-and-destroying-mutexes
176
-            sem = _semaphores.get(name, semaphore.Semaphore())
177
-            if name not in _semaphores:
178
-                # this check is not racy - we're already holding ref locally
179
-                # so GC won't remove the item and there was no IO switch
180
-                # (only valid in greenthreads)
181
-                _semaphores[name] = sem
182
-
183
-            with sem:
184
-                LOG.debug(_('Got semaphore "%(lock)s" for method '
185
-                            '"%(method)s"...'), {'lock': name,
186
-                                                 'method': f.__name__})
187
-                if external and not CONF.disable_process_locking:
188
-                    LOG.debug(_('Attempting to grab file lock "%(lock)s" for '
189
-                                'method "%(method)s"...'),
190
-                              {'lock': name, 'method': f.__name__})
191
-                    cleanup_dir = False
192
-
193
-                    # We need a copy of lock_path because it is non-local
194
-                    local_lock_path = lock_path
195
-                    if not local_lock_path:
196
-                        local_lock_path = CONF.lock_path
197
-
198
-                    if not local_lock_path:
199
-                        cleanup_dir = True
200
-                        local_lock_path = tempfile.mkdtemp()
201
-
202
-                    if not os.path.exists(local_lock_path):
203
-                        cleanup_dir = True
204
-                        fileutils.ensure_tree(local_lock_path)
205
-
206
-                    # NOTE(mikal): the lock name cannot contain directory
207
-                    # separators
208
-                    safe_name = name.replace(os.sep, '_')
209
-                    lock_file_name = '%s%s' % (lock_file_prefix, safe_name)
210
-                    lock_file_path = os.path.join(local_lock_path,
211
-                                                  lock_file_name)
212
-
213
-                    try:
214
-                        lock = InterProcessLock(lock_file_path)
215
-                        with lock:
216
-                            LOG.debug(_('Got file lock "%(lock)s" at %(path)s '
217
-                                        'for method "%(method)s"...'),
218
-                                      {'lock': name,
219
-                                       'path': lock_file_path,
220
-                                       'method': f.__name__})
221
-                            retval = f(*args, **kwargs)
222
-                    finally:
223
-                        # NOTE(vish): This removes the tempdir if we needed
224
-                        #             to create one. This is used to cleanup
225
-                        #             the locks left behind by unit tests.
226
-                        if cleanup_dir:
227
-                            shutil.rmtree(local_lock_path)
228
-                else:
229
-                    retval = f(*args, **kwargs)
230
-
231
-            return retval
232
-        return inner
233
-    return wrap

+ 0
- 1294
files/default/netapp_new-42cdc4d947a73ae6a3dbbaab36634e425b57c18c.py
File diff suppressed because it is too large
View File


+ 0
- 24
recipes/scheduler.rb View File

@@ -54,30 +54,6 @@ service "cinder-scheduler" do
54 54
   action [ :enable, :start ]
55 55
 end
56 56
 
57
-cookbook_file "/usr/local/bin/cinder-volume-usage-audit" do
58
-  source "cinder-volume-usage-audit"
59
-  mode  00755
60
-  owner "root"
61
-  group "root"
62
-end
63
-
64
-# run cronjob only on one node
65
-cron_cmd = "/usr/local/bin/cinder-volume-usage-audit > /var/log/cinder/audit.log 2>&1"
66
-node_search = search(:node, "roles:openstack-volume-scheduler AND chef_environment:#{node.chef_environment}")
67
-cron_node = node_search.collect{|a| a.name}.sort[0]
68
-if node.name == cron_node
69
-  cron "cinder-volume-usage-audit" do
70
-    action :create
71
-    minute node["cinder"]["cron"]["minute"]
72
-    command cron_cmd
73
-  end
74
-else
75
-  cron "cinder-volume-usage-audit" do
76
-    action :delete
77
-    command cron_cmd
78
-  end
79
-end
80
-
81 57
 template "/etc/cinder/cinder.conf" do
82 58
   source "cinder.conf.erb"
83 59
   group  node["cinder"]["group"]

+ 0
- 37
recipes/volume.rb View File

@@ -100,40 +100,3 @@ template "/etc/tgt/targets.conf" do
100 100
 
101 101
   notifies :restart, "service[iscsitarget]", :immediately
102 102
 end
103
-
104
-cookbook_file "/usr/share/pyshared/cinder/openstack/common/fileutils.py" do
105
-  source "fileutils_new-b322585613c21067571442aaf9e4e6feb167832b.py"
106
-  mode  00644
107
-  owner "root"
108
-  group "root"
109
-end
110
-
111
-link "/usr/lib/python2.7/dist-packages/cinder/openstack/common/fileutils.py" do
112
-  to  "/usr/share/pyshared/cinder/openstack/common/fileutils.py"
113
-end
114
-
115
-cookbook_file "/usr/share/pyshared/cinder/openstack/common/gettextutils.py" do
116
-  source "gettextutils_new-8e450aaa6ba1a2a88f6326c2e8d285d00fd28691.py"
117
-  mode  00644
118
-  owner "root"
119
-  group "root"
120
-end
121
-
122
-cookbook_file "/usr/share/pyshared/cinder/openstack/common/lockutils.py" do
123
-  source "lockutils_new-6dda4af1dd50582a0271fd6c96044ae61af9df7e.py"
124
-  mode  00644
125
-  owner "root"
126
-  group "root"
127
-end
128
-
129
-link "/usr/lib/python2.7/dist-packages/cinder/openstack/common/lockutils.py" do
130
-  to "/usr/share/pyshared/cinder/openstack/common/lockutils.py"
131
-end
132
-
133
-cookbook_file node["cinder"]["netapp"]["driver"] do
134
-  source "netapp_new-42cdc4d947a73ae6a3dbbaab36634e425b57c18c.py"
135
-  mode  00644
136
-  owner "root"
137
-  group "root"
138
-  notifies :restart, "service[cinder-volume]"
139
-end

+ 0
- 23
spec/scheduler_spec.rb View File

@@ -32,29 +32,6 @@ describe "cinder::scheduler" do
32 32
       expect(@chef_run).to set_service_to_start_on_boot "cinder-scheduler"
33 33
     end
34 34
 
35
-    describe "cinder-volume-usage-audit" do
36
-      before do
37
-        f = "/usr/local/bin/cinder-volume-usage-audit"
38
-        @file = @chef_run.cookbook_file f
39
-      end 
40
-
41
-      it "has proper owner" do
42
-        expect(@file).to be_owned_by "root", "root"
43
-      end 
44
-
45
-      it "has proper modes" do
46
-        expect(sprintf("%o", @file.mode)).to eq "755"
47
-      end 
48
-    end 
49
-
50
-    it "has cinder-volume-usage-audit cronjob" do
51
-      cron = @chef_run.cron "cinder-volume-usage-audit"
52
-      cmd = "/usr/local/bin/cinder-volume-usage-audit > " \
53
-            "/var/log/cinder/audit.log 2>&1"
54
-      expect(cron.command).to eq cmd
55
-      expect(cron.minute).to eq '00'
56
-    end
57
-
58 35
     expect_creates_cinder_conf "service[cinder-scheduler]"
59 36
   end
60 37
 end

+ 0
- 1
spec/spec_helper.rb View File

@@ -22,7 +22,6 @@ def cinder_stubs
22 22
   ::Chef::Recipe.any_instance.stub(:db_password).and_return String.new
23 23
   ::Chef::Recipe.any_instance.stub(:user_password).and_return String.new
24 24
   ::Chef::Recipe.any_instance.stub(:service_password).and_return String.new
25
-  ::Chef::Recipe.any_instance.stub(:search).and_return([OpenStruct.new(:name => 'fauxhai.local')])
26 25
 end
27 26
 
28 27
 def expect_runs_openstack_common_logging_recipe

+ 2
- 87
spec/volume_spec.rb View File

@@ -45,11 +45,11 @@ describe "cinder::volume" do
45 45
     describe "targets.conf" do
46 46
       before do
47 47
         @file = @chef_run.template "/etc/tgt/targets.conf"
48
-      end 
48
+      end
49 49
 
50 50
       it "has proper modes" do
51 51
         expect(sprintf("%o", @file.mode)).to eq "600"
52
-      end 
52
+      end
53 53
 
54 54
       it "notifies iscsi restart" do
55 55
         expect(@file).to notify "service[iscsitarget]", :restart
@@ -61,91 +61,6 @@ describe "cinder::volume" do
61 61
         expect(@chef_run).not_to create_file_with_content @file.name,
62 62
           "include /var/lib/cinder/volumes/*"
63 63
       end
64
-    end 
65
-
66
-    describe "patches" do
67
-      before do
68
-        @os_dir = "/usr/share/pyshared/cinder/openstack/common"
69
-        @dist_dir = "/usr/lib/python2.7/dist-packages/cinder/openstack/common"
70
-      end
71
-
72
-      describe "fileutils.py" do
73
-        before do
74
-          @source = ::File.join @os_dir, "fileutils.py"
75
-          @file = @chef_run.cookbook_file @source
76
-        end 
77
-
78
-        it "has proper owner" do
79
-          expect(@file).to be_owned_by "root", "root"
80
-        end 
81
-
82
-        it "has proper modes" do
83
-          expect(sprintf("%o", @file.mode)).to eq "644"
84
-        end 
85
-
86
-        it "symlinks fileutils.py" do
87
-          ln = ::File.join @dist_dir, "fileutils.py"
88
-          expect(@chef_run.link(ln)).to link_to @source
89
-        end
90
-      end 
91
-
92
-      describe "gettextutils.py" do
93
-        before do
94
-          @source = ::File.join @os_dir, "gettextutils.py"
95
-          @file = @chef_run.cookbook_file @source
96
-        end 
97
-
98
-        it "has proper owner" do
99
-          expect(@file).to be_owned_by "root", "root"
100
-        end 
101
-
102
-        it "has proper modes" do
103
-          expect(sprintf("%o", @file.mode)).to eq "644"
104
-        end 
105
-
106
-        it "symlinks gettextutils.py" do
107
-          pending "TODO: should there be a gettextutils symlink?"
108
-        end
109
-      end
110
-
111
-      describe "lockutils.py" do
112
-        before do
113
-          @source = ::File.join @os_dir, "lockutils.py"
114
-          @file = @chef_run.cookbook_file @source
115
-        end 
116
-
117
-        it "has proper owner" do
118
-          expect(@file).to be_owned_by "root", "root"
119
-        end 
120
-
121
-        it "has proper modes" do
122
-          expect(sprintf("%o", @file.mode)).to eq "644"
123
-        end 
124
-
125
-        it "symlinks gettextutils.py" do
126
-          ln = ::File.join @dist_dir, "lockutils.py"
127
-          expect(@chef_run.link(ln)).to link_to @source
128
-        end
129
-      end
130
-
131
-      describe "netapp.py" do
132
-        before do
133
-          f = "/usr/share/pyshared/cinder/volume/netapp.py"
134
-          @file = @chef_run.cookbook_file f
135
-        end 
136
-
137
-        it "has proper owner" do
138
-          expect(@file).to be_owned_by "root", "root"
139
-        end 
140
-
141
-        it "has proper modes" do
142
-          expect(sprintf("%o", @file.mode)).to eq "644"
143
-        end 
144
-
145
-        it "notifies nova-api-ec2 restart" do
146
-          expect(@file).to notify "service[cinder-volume]", :restart
147
-        end
148
-      end
149 64
     end
150 65
   end
151 66
 end

Loading…
Cancel
Save