Created
January 8, 2016 23:06
-
-
Save clayg/409b9ed47fa550cfc8ca to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/swift/common/ring/builder.py b/swift/common/ring/builder.py | |
index 742e020..5fe9b2c 100644 | |
--- a/swift/common/ring/builder.py | |
+++ b/swift/common/ring/builder.py | |
@@ -334,18 +334,10 @@ class RingBuilder(object): | |
users may depend on it) | |
""" | |
if 'id' not in dev: | |
- dev['id'] = 0 | |
- if self.devs: | |
- dev_id_found = False | |
- # look for existing slots that we can reuse | |
- for i in range(len(self.devs)): | |
- if self.devs[i] is None: | |
- dev['id'] = i | |
- dev_id_found = True | |
- break | |
- if not dev_id_found: | |
- # no slots available for reuse, grab a brand new one | |
- dev['id'] = len(self.devs) | |
+ try: | |
+ dev['id'] = self.devs.index(None) | |
+ except ValueError: | |
+ dev['id'] = len(self.devs) | |
if dev['id'] < len(self.devs) and self.devs[dev['id']] is not None: | |
raise exceptions.DuplicateDeviceError( | |
'Duplicate device id: %d' % dev['id']) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment