From ef39bac014e0ef04a06b86c100d9d7e472d76789 Mon Sep 17 00:00:00 2001 From: Christos Stavrakakis Date: Tue, 11 Nov 2014 08:50:31 +0000 Subject: [PATCH 01/43] Bump version to 0.16 --- version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version b/version index a025b3a0f..f9a79caf9 100644 --- a/version +++ b/version @@ -1,2 +1,2 @@ # This is a comment! -0.16next +0.16 From 796c732b668d25ac7e599d20eabe299a6d4b838a Mon Sep 17 00:00:00 2001 From: indorilftw Date: Wed, 12 Nov 2014 11:39:03 +0200 Subject: [PATCH 02/43] PEP8 fixes on ci directory --- ci/pep8.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/pep8.py b/ci/pep8.py index 46e75f012..c4d5a33bd 100755 --- a/ci/pep8.py +++ b/ci/pep8.py @@ -39,7 +39,7 @@ def filter_files(files): # Check if file is a python file if not f.endswith(".py"): continue - #Check if file is to be excluded + # Check if file is to be excluded if os.path.basename(f) in EXCLUDE: continue # Check if file existsw From be2e9edf7446edc12d1191c4664c87c2b0251f2d Mon Sep 17 00:00:00 2001 From: indorilftw Date: Wed, 12 Nov 2014 11:41:09 +0200 Subject: [PATCH 03/43] PEP8 fixes on contrib/snf-pithos-tools directory --- .../pithos/tools/dispatcher.py | 6 +- .../pithos/tools/lib/client.py | 18 +- .../snf-pithos-tools/pithos/tools/lib/fuse.py | 14 +- contrib/snf-pithos-tools/pithos/tools/sh.py | 21 +- contrib/snf-pithos-tools/pithos/tools/test.py | 718 +++++++++--------- 5 files changed, 398 insertions(+), 379 deletions(-) diff --git a/contrib/snf-pithos-tools/pithos/tools/dispatcher.py b/contrib/snf-pithos-tools/pithos/tools/dispatcher.py index d818fafa2..6213e7525 100755 --- a/contrib/snf-pithos-tools/pithos/tools/dispatcher.py +++ b/contrib/snf-pithos-tools/pithos/tools/dispatcher.py @@ -76,11 +76,11 @@ def main(): level=logging.DEBUG if DEBUG else logging.INFO) logger = logging.getLogger('dispatcher') - host = 'amqp://%s:%s@%s:%s' % (opts.user, opts.password, opts.host, opts.port) + host = 'amqp://%s:%s@%s:%s' % (opts.user, opts.password, opts.host, opts.port) queue = opts.queue key = opts.key exchange = opts.exchange - + client = AMQPClient(hosts=[host]) client.connect() @@ -89,7 +89,7 @@ def main(): type='topic') client.basic_publish(exchange=exchange, routing_key=key, - body= json.dumps({"test": "0123456789"})) + body=json.dumps({"test": "0123456789"})) client.close() sys.exit() diff --git a/contrib/snf-pithos-tools/pithos/tools/lib/client.py b/contrib/snf-pithos-tools/pithos/tools/lib/client.py index c85cb3462..3d4876128 100644 --- a/contrib/snf-pithos-tools/pithos/tools/lib/client.py +++ b/contrib/snf-pithos-tools/pithos/tools/lib/client.py @@ -85,13 +85,13 @@ def _req(self, method, path, body=None, headers=None, format='text', kwargs['headers'].setdefault('content-length', len(body) if body else 0) - #print '#', method, full_path, kwargs - #t1 = datetime.datetime.utcnow() + # print '#', method, full_path, kwargs + # t1 = datetime.datetime.utcnow() conn.request(method, full_path, **kwargs) resp = conn.getresponse() - #t2 = datetime.datetime.utcnow() - #print 'response time:', str(t2-t1) + # t2 = datetime.datetime.utcnow() + # print 'response time:', str(t2-t1) return _handle_response(resp, self.verbose, self.debug) def _chunked_transfer(self, path, method='PUT', f=stdin, headers=None, @@ -129,13 +129,13 @@ def _chunked_transfer(self, path, method='PUT', f=stdin, headers=None, try: conn.send(data) except: - #retry + # retry conn.send(data) data = '0\r\n\r\n' try: conn.send(data) except: - #retry + # retry conn.send(data) resp = conn.getresponse() @@ -294,7 +294,7 @@ def list_objects(self, container, format='text', 'delimiter': delimiter, 'path': path}) l = self._list('/%s/%s' % (account, container), format, params, **headers) - #TODO support filter trashed with xml also + # TODO support filter trashed with xml also if format != 'xml' and not include_trashed: l = self._filter_trashed(l) return l @@ -995,7 +995,7 @@ def move_object(self, src_container, src_object, dst_container, **headers) def list_shared_with_me(self, limit=None, marker=None, format='text', - translate=None): + translate=None): """lists other accounts that share objects to the user""" l = ['limit', 'marker'] params = {} @@ -1050,5 +1050,5 @@ def _handle_response(response, verbose=False, debug=False): if int(response.status) in ERROR_CODES.keys(): raise Fault(data, int(response.status)) - #print '**', response.status, headers, data, '\n' + # print '**', response.status, headers, data, '\n' return response.status, headers, data diff --git a/contrib/snf-pithos-tools/pithos/tools/lib/fuse.py b/contrib/snf-pithos-tools/pithos/tools/lib/fuse.py index 7c5752cda..460b037c9 100644 --- a/contrib/snf-pithos-tools/pithos/tools/lib/fuse.py +++ b/contrib/snf-pithos-tools/pithos/tools/lib/fuse.py @@ -210,9 +210,8 @@ class fuse_operations(Structure): ('open', CFUNCTYPE(c_int, c_char_p, POINTER(fuse_file_info))), ('read', CFUNCTYPE(c_int, c_char_p, POINTER(c_byte), c_size_t, c_off_t, POINTER(fuse_file_info))), - ( - 'write', CFUNCTYPE(c_int, c_char_p, POINTER(c_byte), c_size_t, c_off_t, - POINTER(fuse_file_info))), + ('write', CFUNCTYPE(c_int, c_char_p, POINTER(c_byte), c_size_t, c_off_t, + POINTER(fuse_file_info))), ('statfs', CFUNCTYPE(c_int, c_char_p, POINTER(c_statvfs))), ('flush', CFUNCTYPE(c_int, c_char_p, POINTER(fuse_file_info))), ('release', CFUNCTYPE(c_int, c_char_p, POINTER(fuse_file_info))), @@ -222,10 +221,9 @@ class fuse_operations(Structure): ('listxattr', CFUNCTYPE(c_int, c_char_p, POINTER(c_byte), c_size_t)), ('removexattr', CFUNCTYPE(c_int, c_char_p, c_char_p)), ('opendir', CFUNCTYPE(c_int, c_char_p, POINTER(fuse_file_info))), - ( - 'readdir', CFUNCTYPE(c_int, c_char_p, c_voidp, CFUNCTYPE(c_int, c_voidp, - c_char_p, POINTER( - c_stat), c_off_t), c_off_t, POINTER(fuse_file_info))), + ('readdir', CFUNCTYPE(c_int, c_char_p, c_voidp, CFUNCTYPE(c_int, c_voidp, + c_char_p, POINTER(c_stat), c_off_t), c_off_t, + POINTER(fuse_file_info))), ('releasedir', CFUNCTYPE(c_int, c_char_p, POINTER(fuse_file_info))), ('fsyncdir', CFUNCTYPE(c_int, c_char_p, c_int, POINTER( fuse_file_info))), @@ -298,7 +296,7 @@ class as is to Operations, instead of just the fh field. args.append('-s') kwargs.setdefault('fsname', operations.__class__.__name__) args.append('-o') - args.append(','.join(key if val == True else '%s=%s' % (key, val) + args.append(','.join(key if val else '%s=%s' % (key, val) for key, val in kwargs.items())) args.append(mountpoint) argv = (c_char_p * len(args))(*args) diff --git a/contrib/snf-pithos-tools/pithos/tools/sh.py b/contrib/snf-pithos-tools/pithos/tools/sh.py index 329871ce9..c57f03723 100755 --- a/contrib/snf-pithos-tools/pithos/tools/sh.py +++ b/contrib/snf-pithos-tools/pithos/tools/sh.py @@ -36,6 +36,7 @@ _cli_commands = {} + def cli_command(*args): def decorator(cls): cls.commands = args @@ -163,7 +164,7 @@ def list_containers(self): print_list(l) def list_objects(self, container): - #prepate params + # prepate params params = {} attrs = ['limit', 'marker', 'prefix', 'delimiter', 'path', 'meta', 'if_modified_since', 'if_unmodified_since', @@ -180,7 +181,7 @@ def list_objects(self, container): return detail = 'json' - #if request with meta quering disable trash filtering + # if request with meta quering disable trash filtering show_trashed = True if self.meta else False l = self.client.list_objects(container, **args) print_list(l, detail=self.detail) @@ -395,7 +396,7 @@ def add_options(self, parser): parser.add_option('--content-disposition', action='store', type='str', dest='content_disposition', default=None, help='provide the presentation style of the object') - #parser.add_option('-S', action='store', + # parser.add_option('-S', action='store', # dest='segment_size', default=False, # help='use for large file support') parser.add_option('--manifest', action='store', @@ -418,7 +419,7 @@ def execute(self, path, *args): if path.find('=') != -1: raise Fault('Missing path argument') - #prepare user defined meta + # prepare user defined meta meta = {} for arg in args: key, sep, val = arg.partition('=') @@ -483,7 +484,7 @@ def execute(self, src, dst, *args): src_container, sep, src_object = src.partition('/') dst_container, sep, dst_object = dst.partition('/') - #prepare user defined meta + # prepare user defined meta meta = {} for arg in args: key, sep, val = arg.partition('=') @@ -509,7 +510,7 @@ class SetMeta(Command): description = 'set account/container/object metadata' def execute(self, path, *args): - #in case of account fix the args + # in case of account fix the args if path.find('=') != -1: args = list(args) args.append(path) @@ -572,7 +573,7 @@ def execute(self, path, *args): if path.find('=') != -1: raise Fault('Missing path argument') - #prepare user defined meta + # prepare user defined meta meta = {} for arg in args: key, sep, val = arg.partition('=') @@ -627,7 +628,7 @@ def execute(self, src, dst, *args): dst_container = src_container dst_object = dst - #prepare user defined meta + # prepare user defined meta meta = {} for arg in args: key, sep, val = arg.partition('=') @@ -648,7 +649,7 @@ class UnsetObject(Command): description = 'delete metadata info' def execute(self, path, *args): - #in case of account fix the args + # in case of account fix the args if len(args) == 0: args = list(args) args.append(path) @@ -805,7 +806,7 @@ def print_dict(d, header='name', f=stdout, detail=True): def print_list(l, verbose=False, f=stdout, detail=True): for elem in l: - #if it's empty string continue + # if it's empty string continue if not elem: continue if isinstance(elem, types.DictionaryType): diff --git a/contrib/snf-pithos-tools/pithos/tools/test.py b/contrib/snf-pithos-tools/pithos/tools/test.py index c2d9b216d..fb5099506 100755 --- a/contrib/snf-pithos-tools/pithos/tools/test.py +++ b/contrib/snf-pithos-tools/pithos/tools/test.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -#coding=utf8 +# coding=utf8 # Copyright (C) 2010-2014 GRNET S.A. # @@ -49,12 +49,13 @@ except: pass + class BaseTestCase(unittest.TestCase): - #TODO unauthorized request + # TODO unauthorized request def setUp(self): self.client = Pithos_Client(get_url(), get_auth(), get_user()) - #keep track of initial containers + # keep track of initial containers self.initial_containers = self.client.list_containers() if self.initial_containers == '': self.initial_containers = [] @@ -62,20 +63,20 @@ def setUp(self): self._clean_account() self.invalid_client = Pithos_Client(get_url(), get_auth(), 'invalid') - #keep track of initial account groups + # keep track of initial account groups self.initial_groups = self.client.retrieve_account_groups() - #keep track of initial account meta + # keep track of initial account meta self.initial_meta = self.client.retrieve_account_metadata(restricted=True) self.extended = { - 'container':( + 'container': ( 'name', 'count', 'bytes', 'last_modified', 'x_container_policy'), - 'object':( + 'object': ( 'name', 'hash', 'bytes', @@ -85,14 +86,14 @@ def setUp(self): self.return_codes = (400, 401, 403, 404, 503,) def tearDown(self): - #delete additionally created meta + # delete additionally created meta l = [] for m in self.client.retrieve_account_metadata(restricted=True): if m not in self.initial_meta: l.append(m) self.client.delete_account_metadata(l) - #delete additionally created groups + # delete additionally created groups l = [] for g in self.client.retrieve_account_groups(): if g not in self.initial_groups: @@ -102,7 +103,7 @@ def tearDown(self): def _clean_account(self): for c in self.client.list_containers(): -# if c not in self.initial_containers: + # if c not in self.initial_containers: self.client.delete_container(c, delimiter='/') self.client.delete_container(c) @@ -241,6 +242,7 @@ def upload_data(self, container, name, data, type=None, enc=None, etag=None, except IOError: return + class AccountHead(BaseTestCase): def setUp(self): BaseTestCase.setUp(self) @@ -250,9 +252,9 @@ def setUp(self): for item in self.containers: self.client.create_container(item) - meta = {'foo':'bar'} + meta = {'foo': 'bar'} self.client.update_account_metadata(**meta) - #self.updated_meta = self.initial_meta.update(meta) + # self.updated_meta = self.initial_meta.update(meta) def test_get_account_meta(self): meta = self.client.retrieve_account_metadata() @@ -280,7 +282,7 @@ def test_get_account_meta_until(self): past = t - datetime.timedelta(minutes=15) past = int(_time.mktime(past.timetuple())) - meta = {'premium':True} + meta = {'premium': True} self.client.update_account_metadata(**meta) meta = self.client.retrieve_account_metadata(restricted=True, until=past) @@ -290,16 +292,17 @@ def test_get_account_meta_until(self): self.assertTrue('premium' in meta) def test_get_account_meta_until_invalid_date(self): - meta = {'premium':True} + meta = {'premium': True} self.client.update_account_metadata(**meta) meta = self.client.retrieve_account_metadata(restricted=True, until='kshfksfh') self.assertTrue('premium' in meta) + class AccountGet(BaseTestCase): def setUp(self): BaseTestCase.setUp(self) - #create some containers + # create some containers self.containers = list(set(self.initial_containers + ['apples', 'bananas', 'kiwis', 'oranges', 'pears'])) self.containers.sort() @@ -307,7 +310,7 @@ def setUp(self): self.client.create_container(item) def test_list(self): - #list containers + # list containers containers = self.client.list_containers() self.assertEquals(self.containers, containers) @@ -325,12 +328,12 @@ def test_list_with_marker(self): m = 'bananas' containers = self.client.list_containers(limit=l, marker=m) i = self.containers.index(m) + 1 - self.assertEquals(self.containers[i:(i+l)], containers) + self.assertEquals(self.containers[i:(i + l)], containers) m = 'oranges' containers = self.client.list_containers(limit=l, marker=m) i = self.containers.index(m) + 1 - self.assertEquals(self.containers[i:(i+l)], containers) + self.assertEquals(self.containers[i:(i + l)], containers) def test_list_json_with_marker(self): l = 2 @@ -354,7 +357,7 @@ def test_if_modified_since(self): t = datetime.datetime.utcnow() t2 = t - datetime.timedelta(minutes=10) - #add a new container + # add a new container self.client.create_container('dummy') for f in DATE_FORMATS: @@ -363,7 +366,7 @@ def test_if_modified_since(self): c = self.client.list_containers(if_modified_since=past) self.assertEqual(len(c), len(self.containers) + 1) except Fault, f: - self.failIf(f.status == 304) #fail if not modified + self.failIf(f.status == 304) # fail if not modified def test_if_modified_since_invalid_date(self): c = self.client.list_containers(if_modified_since='') @@ -374,9 +377,9 @@ def test_if_not_modified_since(self): since = now + datetime.timedelta(1) for f in DATE_FORMATS: - args = {'if_modified_since':'%s' %since.strftime(f)} + args = {'if_modified_since': '%s' % since.strftime(f)} - #assert not modified + # assert not modified self.assert_raises_fault(304, self.client.list_containers, **args) def test_if_unmodified_since(self): @@ -386,24 +389,25 @@ def test_if_unmodified_since(self): for f in DATE_FORMATS: c = self.client.list_containers(if_unmodified_since=since.strftime(f)) - #assert success + # assert success self.assertEqual(self.containers, c) def test_if_unmodified_since_precondition_failed(self): t = datetime.datetime.utcnow() t2 = t - datetime.timedelta(minutes=10) - #add a new container + # add a new container self.client.create_container('dummy') for f in DATE_FORMATS: past = t2.strftime(f) - args = {'if_unmodified_since':'%s' %past} + args = {'if_unmodified_since': '%s' % past} - #assert precondition failed + # assert precondition failed self.assert_raises_fault(412, self.client.list_containers, **args) + class AccountPost(BaseTestCase): def setUp(self): BaseTestCase.setUp(self) @@ -413,39 +417,37 @@ def setUp(self): for item in self.containers: self.client.create_container(item) - meta = {'foo':'bar'} + meta = {'foo': 'bar'} self.client.update_account_metadata(**meta) self.updated_meta = self.initial_meta.update(meta) def test_update_meta(self): with AssertMappingInvariant(self.client.retrieve_account_groups): - meta = {'test':'test', 'tost':'tost'} + meta = {'test': 'test', 'tost': 'tost'} self.client.update_account_metadata(**meta) meta.update(self.initial_meta) - self.assertEqual(meta, - self.client.retrieve_account_metadata( - restricted=True)) + self.assertEqual(meta, self.client.retrieve_account_metadata(restricted=True)) def test_invalid_account_update_meta(self): - meta = {'test':'test', 'tost':'tost'} + meta = {'test': 'test', 'tost': 'tost'} self.assert_raises_fault(403, self.invalid_client.update_account_metadata, **meta) def test_reset_meta(self): with AssertMappingInvariant(self.client.retrieve_account_groups): - meta = {'test':'test', 'tost':'tost'} + meta = {'test': 'test', 'tost': 'tost'} self.client.update_account_metadata(**meta) - meta = {'test':'test33'} + meta = {'test': 'test33'} self.client.reset_account_metadata(**meta) self.assertEqual(meta, self.client.retrieve_account_metadata(restricted=True)) def test_delete_meta(self): with AssertMappingInvariant(self.client.retrieve_account_groups): - meta = {'test':'test', 'tost':'tost'} + meta = {'test': 'test', 'tost': 'tost'} self.client.update_account_metadata(**meta) self.client.delete_account_metadata(meta.keys()) @@ -456,13 +458,13 @@ def test_delete_meta(self): def test_set_account_groups(self): with AssertMappingInvariant(self.client.retrieve_account_metadata): - groups = {'pithosdev':'verigak,gtsouk,chazapis'} + groups = {'pithosdev': 'verigak,gtsouk,chazapis'} self.client.set_account_groups(**groups) self.assertEqual(set(groups['pithosdev']), set(self.client.retrieve_account_groups()['pithosdev'])) - more_groups = {'clientsdev':'pkanavos,mvasilak'} + more_groups = {'clientsdev': 'pkanavos,mvasilak'} self.client.set_account_groups(**more_groups) groups.update(more_groups) @@ -471,8 +473,8 @@ def test_set_account_groups(self): def test_reset_account_groups(self): with AssertMappingInvariant(self.client.retrieve_account_metadata): - groups = {'pithosdev':'verigak,gtsouk,chazapis', - 'clientsdev':'pkanavos,mvasilak'} + groups = {'pithosdev': 'verigak,gtsouk,chazapis', + 'clientsdev': 'pkanavos,mvasilak'} self.client.set_account_groups(**groups) self.assertEqual(set(groups['pithosdev'].split(',')), @@ -480,7 +482,7 @@ def test_reset_account_groups(self): self.assertEqual(set(groups['clientsdev'].split(',')), set(self.client.retrieve_account_groups()['clientsdev'].split(','))) - groups = {'pithosdev':'verigak,gtsouk,chazapis,papagian'} + groups = {'pithosdev': 'verigak,gtsouk,chazapis,papagian'} self.client.reset_account_groups(**groups) self.assertEqual(set(groups['pithosdev'].split(',')), @@ -488,14 +490,15 @@ def test_reset_account_groups(self): def test_delete_account_groups(self): with AssertMappingInvariant(self.client.retrieve_account_metadata): - groups = {'pithosdev':'verigak,gtsouk,chazapis', - 'clientsdev':'pkanavos,mvasilak'} + groups = {'pithosdev': 'verigak,gtsouk,chazapis', + 'clientsdev': 'pkanavos,mvasilak'} self.client.set_account_groups(**groups) self.client.unset_account_groups(groups.keys()) self.assertEqual({}, self.client.retrieve_account_groups()) + class ContainerHead(BaseTestCase): def setUp(self): BaseTestCase.setUp(self) @@ -503,7 +506,7 @@ def setUp(self): self.client.create_container(self.container) def test_get_meta(self): - meta = {'trash':'true'} + meta = {'trash': 'true'} t1 = datetime.datetime.utcnow() o = self.upload_random_data(self.container, o_names[0], **meta) if o: @@ -517,6 +520,7 @@ def test_get_meta(self): self.assertTrue(headers['x-container-object-meta']) self.assertTrue('Trash' in headers['x-container-object-meta']) + class ContainerGet(BaseTestCase): def setUp(self): BaseTestCase.setUp(self) @@ -586,7 +590,6 @@ def test_list_public(self): account=get_user() ) - def test_list_shared_public(self): token = OTHER_ACCOUNTS.keys()[0] account = OTHER_ACCOUNTS[token] @@ -665,7 +668,7 @@ def test_list_objects_with_limit_marker(self): end = end if len(l) >= end else len(l) self.assertEqual(objects, l[start:end]) - #takes too long + # takes too long def _test_list_limit_exceeds(self): self.client.create_container('pithos') @@ -717,7 +720,7 @@ def test_extended_list_xml(self): self.assertEqual(objects[0].childNodes[0].data, 'photos/me.jpg') def test_list_meta_double_matching(self): - meta = {'quality':'aaa', 'stock':'true'} + meta = {'quality': 'aaa', 'stock': 'true'} self.client.update_object_metadata(self.container[0], self.obj[0]['name'], **meta) obj = self.client.list_objects(self.container[0], meta='Quality,Stock') @@ -725,11 +728,11 @@ def test_list_meta_double_matching(self): self.assertTrue(obj, self.obj[0]['name']) def test_list_using_meta(self): - meta = {'quality':'aaa'} + meta = {'quality': 'aaa'} for o in self.obj[:2]: self.client.update_object_metadata(self.container[0], o['name'], **meta) - meta = {'stock':'true'} + meta = {'stock': 'true'} for o in self.obj[3:5]: self.client.update_object_metadata(self.container[0], o['name'], **meta) @@ -757,21 +760,19 @@ def test_if_modified_since(self): t = datetime.datetime.utcnow() t2 = t - datetime.timedelta(minutes=10) - #add a new object + # add a new object self.upload_random_data(self.container[0], o_names[0]) for f in DATE_FORMATS: past = t2.strftime(f) try: - o = self.client.list_objects(self.container[0], - if_modified_since=past) - self.assertEqual(o, - self.client.list_objects(self.container[0])) + o = self.client.list_objects(self.container[0], if_modified_since=past) + self.assertEqual(o, self.client.list_objects(self.container[0])) except Fault, f: - self.failIf(f.status == 304) #fail if not modified + self.failIf(f.status == 304) # fail if not modified def test_if_modified_since_invalid_date(self): - headers = {'if-modified-since':''} + headers = {'if-modified-since': ''} o = self.client.list_objects(self.container[0], if_modified_since='') self.assertEqual(o, self.client.list_objects(self.container[0])) @@ -780,9 +781,9 @@ def test_if_not_modified_since(self): since = now + datetime.timedelta(1) for f in DATE_FORMATS: - args = {'if_modified_since':'%s' %since.strftime(f)} + args = {'if_modified_since': '%s' % since.strftime(f)} - #assert not modified + # assert not modified self.assert_raises_fault(304, self.client.list_objects, self.container[0], **args) @@ -794,25 +795,26 @@ def test_if_unmodified_since(self): obj = self.client.list_objects(self.container[0], if_unmodified_since=since.strftime(f)) - #assert unmodified + # assert unmodified self.assertEqual(obj, self.client.list_objects(self.container[0])) def test_if_unmodified_since_precondition_failed(self): t = datetime.datetime.utcnow() t2 = t - datetime.timedelta(minutes=10) - #add a new container + # add a new container self.client.create_container('dummy') for f in DATE_FORMATS: past = t2.strftime(f) - args = {'if_unmodified_since':'%s' %past} + args = {'if_unmodified_since': '%s' % past} - #assert precondition failed + # assert precondition failed self.assert_raises_fault(412, self.client.list_objects, self.container[0], **args) + class ContainerPut(BaseTestCase): def setUp(self): BaseTestCase.setUp(self) @@ -832,7 +834,7 @@ def test_create_twice(self): def test_quota(self): self.client.create_container(self.containers[0]) - policy = {'quota':100} + policy = {'quota': 100} self.client.set_container_policies(self.containers[0], **policy) meta = self.client.retrieve_container_metadata(self.containers[0]) @@ -840,13 +842,14 @@ def test_quota(self): self.assertEqual(meta['x-container-policy-quota'], '100') args = [self.containers[0], 'o1'] - kwargs = {'length':101} + kwargs = {'length': 101} self.assert_raises_fault(413, self.upload_random_data, *args, **kwargs) - #reset quota - policy = {'quota':0} + # reset quota + policy = {'quota': 0} self.client.set_container_policies(self.containers[0], **policy) + class ContainerPost(BaseTestCase): def setUp(self): BaseTestCase.setUp(self) @@ -854,15 +857,16 @@ def setUp(self): self.client.create_container(self.container) def test_update_meta(self): - meta = {'test':'test33', - 'tost':'tost22'} + meta = {'test': 'test33', + 'tost': 'tost22'} self.client.update_container_metadata(self.container, **meta) headers = self.client.retrieve_container_metadata(self.container) - for k,v in meta.items(): + for k, v in meta.items(): k = 'x-container-meta-%s' % k self.assertTrue(headers[k]) self.assertEqual(headers[k], v) + class ContainerDelete(BaseTestCase): def setUp(self): BaseTestCase.setUp(self) @@ -896,17 +900,18 @@ def test_delete_contents(self): self.assert_object_not_exists(self.containers[0], o) self.assert_container_exists(self.containers[0]) + class ObjectGet(BaseTestCase): def setUp(self): BaseTestCase.setUp(self) self.containers = list(set(self.initial_containers + ['c1', 'c2'])) self.containers.sort() - #create some containers + # create some containers for c in self.containers: self.client.create_container(c) - #upload a file + # upload a file names = ('obj1', 'obj2') self.objects = [] for n in names: @@ -918,40 +923,40 @@ def test_versions(self): b = self.client.retrieve_object_versionlist(c, o['name'])['versions'] self.assert_versionlist_structure(b) - #update meta - meta = {'quality':'AAA', 'stock':True} + # update meta + meta = {'quality': 'AAA', 'stock': True} self.client.update_object_metadata(c, o['name'], **meta) a = self.client.retrieve_object_versionlist(c, o['name'])['versions'] self.assert_versionlist_structure(a) - self.assertEqual(len(b)+1, len(a)) + self.assertEqual(len(b) + 1, len(a)) self.assertEqual(b, a[:-1]) - #get exact previous version metadata + # get exact previous version metadata v = a[-2][0] v_meta = self.client.retrieve_object_metadata(c, o['name'], restricted=True, version=v) (self.assertTrue(k not in v_meta) for k in meta.keys()) - #update obejct + # update obejct data = get_random_data() self.client.update_object(c, o['name'], StringIO(data)) aa = self.client.retrieve_object_versionlist(c, o['name'])['versions'] self.assert_versionlist_structure(aa) - self.assertEqual(len(a)+1, len(aa)) + self.assertEqual(len(a) + 1, len(aa)) self.assertEqual(a, aa[:-1]) - #get exact previous version + # get exact previous version v = aa[-3][0] v_data = self.client.retrieve_object_version(c, o['name'], version=v) self.assertEqual(o['data'], v_data) self.assertEqual(self.client.retrieve_object(c, o['name']), - '%s%s' %(v_data, data)) + '%s%s' % (v_data, data)) def test_get(self): - #perform get + # perform get o = self.client.retrieve_object(self.containers[1], self.objects[0]['name'], self.objects[0]['meta']) @@ -959,97 +964,95 @@ def test_get(self): def test_objects_with_trailing_spaces(self): self.client.create_container('test') - #create 'a' object + # create 'a' object self.upload_random_data('test', 'a') - #look for 'a ' object + # look for 'a ' object self.assert_raises_fault(404, self.client.retrieve_object, 'test', 'a ') - #delete 'a' object + # delete 'a' object self.client.delete_object('test', 'a') - self.assert_raises_fault(404, self.client.retrieve_object, - 'test', 'a') + self.assert_raises_fault(404, self.client.retrieve_object, 'test', 'a') - #create 'a ' object + # create 'a ' object self.upload_random_data('test', 'a ') - #look for 'a' object - self.assert_raises_fault(404, self.client.retrieve_object, - 'test', 'a') + # look for 'a' object + self.assert_raises_fault(404, self.client.retrieve_object, 'test', 'a') def test_get_invalid(self): self.assert_raises_fault(404, self.client.retrieve_object, self.containers[0], self.objects[0]['name']) def test_get_partial(self): - #perform get with range + # perform get with range status, headers, data = self.client.request_object(self.containers[1], - self.objects[0]['name'], - range='bytes=0-499') + self.objects[0]['name'], + range='bytes=0-499') - #assert successful partial content + # assert successful partial content self.assertEqual(status, 206) - #assert content-type + # assert content-type self.assertEqual(headers['content-type'], self.objects[0]['meta']['content_type']) - #assert content length + # assert content length self.assertEqual(int(headers['content-length']), 500) - #assert content + # assert content self.assertEqual(self.objects[0]['data'][:500], data) def test_get_final_500(self): - #perform get with range - headers = {'range':'bytes=-500'} + # perform get with range + headers = {'range': 'bytes=-500'} status, headers, data = self.client.request_object(self.containers[1], - self.objects[0]['name'], - range='bytes=-500') + self.objects[0]['name'], + range='bytes=-500') - #assert successful partial content + # assert successful partial content self.assertEqual(status, 206) - #assert content-type + # assert content-type self.assertEqual(headers['content-type'], self.objects[0]['meta']['content_type']) - #assert content length + # assert content length self.assertEqual(int(headers['content-length']), 500) - #assert content + # assert content self.assertTrue(self.objects[0]['data'][-500:], data) def test_get_rest(self): - #perform get with range + # perform get with range offset = len(self.objects[0]['data']) - 500 status, headers, data = self.client.request_object(self.containers[1], - self.objects[0]['name'], - range='bytes=%s-' %offset) + self.objects[0]['name'], + range='bytes=%s-' % offset) - #assert successful partial content + # assert successful partial content self.assertEqual(status, 206) - #assert content-type + # assert content-type self.assertEqual(headers['content-type'], self.objects[0]['meta']['content_type']) - #assert content length + # assert content length self.assertEqual(int(headers['content-length']), 500) - #assert content + # assert content self.assertTrue(self.objects[0]['data'][-500:], data) def test_get_range_not_satisfiable(self): - #perform get with range + # perform get with range offset = len(self.objects[0]['data']) + 1 - #assert range not satisfiable + # assert range not satisfiable self.assert_raises_fault(416, self.client.retrieve_object, self.containers[1], self.objects[0]['name'], - range='bytes=0-%s' %offset) + range='bytes=0-%s' % offset) def test_multiple_range(self): - #perform get with multiple range + # perform get with multiple range ranges = ['0-499', '-500', '1000-'] bytes = 'bytes=%s' % ','.join(ranges) status, headers, data = self.client.request_object(self.containers[1], @@ -1064,7 +1067,7 @@ def test_multiple_range(self): content_type_parts = headers['content-type'].split() self.assertEqual(content_type_parts[0], ('multipart/byteranges;')) - boundary = '--%s' %content_type_parts[1].split('=')[-1:][0] + boundary = '--%s' % content_type_parts[1].split('=')[-1:][0] cparts = data.split(boundary)[1:-1] # assert content parts are exactly 2 @@ -1094,12 +1097,12 @@ def test_multiple_range(self): sdata = '\r\n'.join(content[4:-1]) self.assertEqual(len(fdata), len(sdata)) self.assertEquals(fdata, sdata) - i+=1 + i += 1 def test_multiple_range_not_satisfiable(self): - #perform get with multiple range + # perform get with multiple range out_of_range = len(self.objects[0]['data']) + 1 - ranges = ['0-499', '-500', '%d-' %out_of_range] + ranges = ['0-499', '-500', '%d-' % out_of_range] bytes = 'bytes=%s' % ','.join(ranges) # assert partial content @@ -1108,86 +1111,86 @@ def test_multiple_range_not_satisfiable(self): self.objects[0]['name'], range=bytes) def test_get_with_if_match(self): - #perform get with If-Match + # perform get with If-Match etag = self.objects[0]['hash'] status, headers, data = self.client.request_object(self.containers[1], self.objects[0]['name'], if_match=etag) - #assert get success + # assert get success self.assertEqual(status, 200) - #assert content-type + # assert content-type self.assertEqual(headers['content-type'], self.objects[0]['meta']['content_type']) - #assert response content + # assert response content self.assertEqual(self.objects[0]['data'], data) def test_get_with_if_match_star(self): - #perform get with If-Match * - headers = {'if-match':'*'} + # perform get with If-Match * + headers = {'if-match': '*'} status, headers, data = self.client.request_object(self.containers[1], - self.objects[0]['name'], - **headers) - #assert get success + self.objects[0]['name'], + **headers) + # assert get success self.assertEqual(status, 200) - #assert content-type + # assert content-type self.assertEqual(headers['content-type'], self.objects[0]['meta']['content_type']) - #assert response content + # assert response content self.assertEqual(self.objects[0]['data'], data) def test_get_with_multiple_if_match(self): - #perform get with If-Match + # perform get with If-Match etags = [i['hash'] for i in self.objects if i] etags = ','.join('"%s"' % etag for etag in etags) status, headers, data = self.client.request_object(self.containers[1], self.objects[0]['name'], if_match=etags) - #assert get success + # assert get success self.assertEqual(status, 200) - #assert content-type + # assert content-type self.assertEqual(headers['content-type'], self.objects[0]['meta']['content_type']) - #assert content-type + # assert content-type self.assertEqual(headers['content-type'], self.objects[0]['meta']['content_type']) - #assert response content + # assert response content self.assertEqual(self.objects[0]['data'], data) def test_if_match_precondition_failed(self): - #assert precondition failed + # assert precondition failed self.assert_raises_fault(412, self.client.retrieve_object, self.containers[1], self.objects[0]['name'], if_match='123') def test_if_none_match(self): - #perform get with If-None-Match + # perform get with If-None-Match status, headers, data = self.client.request_object(self.containers[1], self.objects[0]['name'], if_none_match='123') - #assert get success + # assert get success self.assertEqual(status, 200) - #assert content-type + # assert content-type self.assertEqual(headers['content_type'], self.objects[0]['meta']['content_type']) def test_if_none_match(self): - #perform get with If-None-Match * and assert not modified + # perform get with If-None-Match * and assert not modified self.assert_raises_fault(304, self.client.retrieve_object, self.containers[1], self.objects[0]['name'], if_none_match='*') def test_if_none_match_not_modified(self): - #perform get with If-None-Match and assert not modified + # perform get with If-None-Match and assert not modified self.assert_raises_fault(304, self.client.retrieve_object, self.containers[1], self.objects[0]['name'], @@ -1201,15 +1204,15 @@ def test_if_modified_since(self): t = datetime.datetime.utcnow() t2 = t - datetime.timedelta(minutes=10) - #modify the object + # modify the object self.upload_data(self.containers[1], - self.objects[0]['name'], - self.objects[0]['data'][:200]) + self.objects[0]['name'], + self.objects[0]['data'][:200]) for f in DATE_FORMATS: past = t2.strftime(f) - headers = {'if-modified-since':'%s' %past} + headers = {'if-modified-since': '%s' % past} try: o = self.client.retrieve_object(self.containers[1], self.objects[0]['name'], @@ -1232,7 +1235,7 @@ def test_if_not_modified_since(self): since = now + datetime.timedelta(1) for f in DATE_FORMATS: - #assert not modified + # assert not modified self.assert_raises_fault(304, self.client.retrieve_object, self.containers[1], self.objects[0]['name'], if_modified_since=since.strftime(f)) @@ -1246,11 +1249,11 @@ def test_if_unmodified_since(self): status, headers, data = self.client.request_object(self.containers[1], self.objects[0]['name'], if_unmodified_since=t) - #assert success + # assert success self.assertEqual(status, 200) self.assertEqual(self.objects[0]['data'], data) - #assert content-type + # assert content-type self.assertEqual(headers['content-type'], self.objects[0]['meta']['content_type']) @@ -1258,14 +1261,14 @@ def test_if_unmodified_since_precondition_failed(self): t = datetime.datetime.utcnow() t2 = t - datetime.timedelta(minutes=10) - #modify the object + # modify the object self.upload_data(self.containers[1], - self.objects[0]['name'], - self.objects[0]['data'][:200]) + self.objects[0]['name'], + self.objects[0]['data'][:200]) for f in DATE_FORMATS: past = t2.strftime(f) - #assert precondition failed + # assert precondition failed self.assert_raises_fault(412, self.client.retrieve_object, self.containers[1], self.objects[0]['name'], if_unmodified_since=past) @@ -1280,7 +1283,7 @@ def test_hashes(self): hashes = body['hashes'] block_size = body['block_size'] block_hash = body['block_hash'] - block_num = l/block_size if l/block_size == 0 else l/block_size + 1 + block_num = l / block_size if l / block_size == 0 else l / block_size + 1 self.assertTrue(len(hashes), block_num) i = 0 for h in hashes: @@ -1290,6 +1293,7 @@ def test_hashes(self): self.assertEqual(h, hash) i += 1 + class ObjectPut(BaseTestCase): def setUp(self): BaseTestCase.setUp(self) @@ -1298,7 +1302,7 @@ def setUp(self): def test_upload(self): name = o_names[0] - meta = {'test':'test1'} + meta = {'test': 'test1'} o = self.upload_random_data(self.container, name, **meta) headers = self.client.retrieve_object_metadata(self.container, @@ -1307,25 +1311,25 @@ def test_upload(self): self.assertTrue('test' in headers.keys()) self.assertEqual(headers['test'], meta['test']) - #assert uploaded content + # assert uploaded content status, h, data = self.client.request_object(self.container, name) self.assertEqual(len(o['data']), int(h['content-length'])) self.assertEqual(o['data'], data) - #assert content-type + # assert content-type self.assertEqual(h['content-type'], o['meta']['content_type']) def _test_maximum_upload_size_exceeds(self): name = o_names[0] - meta = {'test':'test1'} - #upload 5GB - length= 5 * (1024 * 1024 * 1024) + 1 + meta = {'test': 'test1'} + # upload 5GB + length = 5 * (1024 * 1024 * 1024) + 1 self.assert_raises_fault(400, self.upload_random_data, self.container, name, length, **meta) def test_upload_with_name_containing_slash(self): name = '/%s' % o_names[0] - meta = {'test':'test1'} + meta = {'test': 'test1'} o = self.upload_random_data(self.container, name, **meta) self.assertEqual(o['data'], @@ -1340,9 +1344,9 @@ def test_create_directory_marker(self): self.assertEqual(meta['content-type'], 'application/directory') def test_upload_unprocessable_entity(self): - meta={'etag':'123', 'test':'test1'} + meta = {'etag': '123', 'test': 'test1'} - #assert unprocessable entity + # assert unprocessable entity self.assert_raises_fault(422, self.upload_random_data, self.container, o_names[0], **meta) @@ -1359,26 +1363,26 @@ def test_manifestation(self): prefix = 'myobject/' data = '' for i in range(5): - part = '%s%d' %(prefix, i) + part = '%s%d' % (prefix, i) o = self.upload_random_data(self.container, part) data += o['data'] - manifest = '%s/%s' %(self.container, prefix) + manifest = '%s/%s' % (self.container, prefix) self.client.create_manifestation(self.container, 'large-object', manifest) self.assert_object_exists(self.container, 'large-object') self.assertEqual(data, self.client.retrieve_object(self.container, 'large-object')) - r = self.client.retrieve_object_hashmap(self.container,'large-object') + r = self.client.retrieve_object_hashmap(self.container, 'large-object') hashes = r['hashes'] block_size = int(r['block_size']) block_hash = r['block_hash'] l = len(data) - block_num = l/block_size if l/block_size != 0 else l/block_size + 1 + block_num = l / block_size if l / block_size != 0 else l / block_size + 1 self.assertEqual(block_num, len(hashes)) - #wrong manifestation + # wrong manifestation self.client.create_manifestation(self.container, 'large-object', '%s/invalid' % self.container) self.assertEqual('', self.client.retrieve_object(self.container, @@ -1409,6 +1413,7 @@ def test_create_object_by_hashmap(self): self.assertEqual(self.client.retrieve_object(c, o), self.client.retrieve_object(c, o)) + class ObjectCopy(BaseTestCase): def setUp(self): BaseTestCase.setUp(self) @@ -1421,34 +1426,34 @@ def setUp(self): def test_copy(self): with AssertMappingInvariant(self.client.retrieve_object_metadata, - self.containers[0], self.obj['name']): - #perform copy - meta = {'test':'testcopy'} + self.containers[0], self.obj['name']): + # perform copy + meta = {'test': 'testcopy'} status = self.client.copy_object(self.containers[0], - self.obj['name'], - self.containers[0], - 'testcopy', - meta)[0] + self.obj['name'], + self.containers[0], + 'testcopy', + meta)[0] - #assert copy success + # assert copy success self.assertEqual(status, 201) - #assert access the new object + # assert access the new object headers = self.client.retrieve_object_metadata(self.containers[0], 'testcopy') self.assertTrue('x-object-meta-test' in headers.keys()) self.assertTrue(headers['x-object-meta-test'], 'testcopy') - #assert etag is the same + # assert etag is the same self.assertEqual(headers['etag'], self.obj['hash']) - #assert src object still exists + # assert src object still exists self.assert_object_exists(self.containers[0], self.obj['name']) def test_copy_from_different_container(self): with AssertMappingInvariant(self.client.retrieve_object_metadata, - self.containers[0], self.obj['name']): - meta = {'test':'testcopy'} + self.containers[0], self.obj['name']): + meta = {'test': 'testcopy'} status = self.client.copy_object(self.containers[0], self.obj['name'], self.containers[1], @@ -1458,22 +1463,22 @@ def test_copy_from_different_container(self): # assert updated metadata meta = self.client.retrieve_object_metadata(self.containers[1], - 'testcopy', - restricted=True) + 'testcopy', + restricted=True) self.assertTrue('test' in meta.keys()) self.assertTrue(meta['test'], 'testcopy') - #assert src object still exists + # assert src object still exists self.assert_object_exists(self.containers[0], self.obj['name']) def test_copy_invalid(self): - #copy from invalid object - meta = {'test':'testcopy'} + # copy from invalid object + meta = {'test': 'testcopy'} self.assert_raises_fault(404, self.client.copy_object, self.containers[0], 'test.py', self.containers[1], 'testcopy', meta) - #copy from invalid container - meta = {'test':'testcopy'} + # copy from invalid container + meta = {'test': 'testcopy'} self.assert_raises_fault(404, self.client.copy_object, self.containers[1], self.obj['name'], self.containers[1], 'testcopy', meta) @@ -1482,7 +1487,7 @@ def test_copy_dir(self): self.client.create_folder(self.containers[0], 'dir') self.client.create_folder(self.containers[0], 'dir/subdir') self.upload_random_data(self.containers[0], 'dir/object1.jpg', length=1024) - self.upload_random_data(self.containers[0], 'dir/subdir/object2.pdf', length=2*1024) + self.upload_random_data(self.containers[0], 'dir/subdir/object2.pdf', length=2 * 1024) self.client.create_folder(self.containers[0], 'dirs') objects = self.client.list_objects(self.containers[0], prefix='dir') @@ -1496,6 +1501,7 @@ def test_copy_dir(self): (self.assertEqual(meta0[elem], meta1[elem]) for elem in t) self.assert_object_not_exists(self.containers[1], objects[-1]) + class ObjectMove(BaseTestCase): def setUp(self): BaseTestCase.setUp(self) @@ -1512,29 +1518,28 @@ def test_move(self): self.assertTrue('x-object-uuid' in meta) uuid = meta['x-object-uuid'] - #perform move - meta = {'test':'testcopy'} + # perform move + meta = {'test': 'testcopy'} src_path = '/'.join(('/', self.containers[0], self.obj['name'])) status = self.client.move_object(self.containers[0], self.obj['name'], self.containers[0], 'testcopy', meta)[0] - #assert successful move + # assert successful move self.assertEqual(status, 201) - #assert updated metadata + # assert updated metadata meta = self.client.retrieve_object_metadata(self.containers[0], 'testcopy') self.assertTrue('x-object-meta-test' in meta.keys()) self.assertTrue(meta['x-object-meta-test'], 'testcopy') - #assert same uuid + # assert same uuid self.assertTrue(meta['x-object-uuid'], uuid) - #assert src object no more exists + # assert src object no more exists self.assert_object_not_exists(self.containers[0], self.obj['name']) - def test_move_dir(self): meta = {} self.client.create_folder(self.containers[0], 'dir') @@ -1543,7 +1548,7 @@ def test_move_dir(self): meta['dir/subdir'] = self.client.retrieve_object_metadata(self.containers[0], 'dir/subdir') self.upload_random_data(self.containers[0], 'dir/object1.jpg', length=1024) meta['dir/object1.jpg'] = self.client.retrieve_object_metadata(self.containers[0], 'dir/object1.jpg') - self.upload_random_data(self.containers[0], 'dir/subdir/object2.pdf', length=2*1024) + self.upload_random_data(self.containers[0], 'dir/subdir/object2.pdf', length=2 * 1024) meta['dir/subdir/object2.pdf'] = self.client.retrieve_object_metadata(self.containers[0], 'dir/subdir/object2.pdf') self.client.create_folder(self.containers[0], 'dirs') meta['dirs'] = self.client.retrieve_object_metadata(self.containers[0], 'dirs') @@ -1559,6 +1564,7 @@ def test_move_dir(self): self.assert_object_exists(self.containers[0], objects[-1]) self.assert_object_not_exists(self.containers[1], objects[-1]) + class ObjectPost(BaseTestCase): def setUp(self): BaseTestCase.setUp(self) @@ -1575,88 +1581,86 @@ def test_update_meta(self): with AssertUUidInvariant(self.client.retrieve_object_metadata, self.containers[0], self.obj[0]['name']): - #perform update metadata + # perform update metadata more = {'foo': 'foo', 'bar': 'bar', 'f' * 114: 'b' * 256} status = self.client.update_object_metadata(self.containers[0], self.obj[0]['name'], **more)[0] - #assert request accepted + # assert request accepted self.assertEqual(status, 202) - #assert old metadata are still there + # assert old metadata are still there headers = self.client.retrieve_object_metadata(self.containers[0], self.obj[0]['name'], restricted=True) - #assert new metadata have been updated - for k,v in more.items(): + # assert new metadata have been updated + for k, v in more.items(): self.assertTrue(k in headers.keys()) self.assertTrue(headers[k], v) - #out of limits + # out of limits more = {'f' * 114: 'b' * 257} self.assert_raises_fault(400, self.client.update_object_metadata, - self.containers[0], - self.obj[0]['name'], - **more) + self.containers[0], self.obj[0]['name'], + **more) - #perform update metadata + # perform update metadata more = {'α': 'β' * 256} status = self.client.update_object_metadata(self.containers[0], self.obj[0]['name'], **more)[0] - #assert request accepted + # assert request accepted self.assertEqual(status, 202) - #assert old metadata are still there + # assert old metadata are still there headers = self.client.retrieve_object_metadata(self.containers[0], self.obj[0]['name'], restricted=True) - #assert new metadata have been updated - for k,v in more.items(): + # assert new metadata have been updated + for k, v in more.items(): self.assertTrue(k in headers.keys()) self.assertTrue(headers[k], v) - #out of limits + # out of limits more = {'α': 'β' * 257} self.assert_raises_fault(400, self.client.update_object_metadata, - self.containers[0], - self.obj[0]['name'], - **more) + self.containers[0], self.obj[0]['name'], + **more) def test_update_object(self, first_byte_pos=0, last_byte_pos=499, - instance_length = True, - content_length = 500): + instance_length=True, + content_length=500): with AssertUUidInvariant(self.client.retrieve_object_metadata, self.containers[0], self.obj[0]['name']): l = len(self.obj[0]['data']) - range = 'bytes %d-%d/%s' %(first_byte_pos, - last_byte_pos, - l if instance_length else '*') + range = 'bytes %d-%d/%s' % (first_byte_pos, + last_byte_pos, + l if instance_length else '*') partial = last_byte_pos - first_byte_pos + 1 length = first_byte_pos + partial data = get_random_data(partial) - args = {'content_type':'application/octet-stream', - 'content_range':'%s' %range} + args = {'content_type': 'application/octet-stream', + 'content_range': '%s' % range} if content_length: args['content_length'] = content_length r = self.client.update_object(self.containers[0], self.obj[0]['name'], - StringIO(data), **args) + StringIO(data), **args) status = r[0] etag = r[1]['etag'] if partial < 0 or (instance_length and l <= last_byte_pos): self.assertEqual(status, 202) else: self.assertEqual(status, 204) - #check modified object + # check modified object content = self.client.retrieve_object(self.containers[0], - self.obj[0]['name']) + self.obj[0]['name']) self.assertEqual(content[:first_byte_pos], self.obj[0]['data'][:first_byte_pos]) - self.assertEqual(content[first_byte_pos:last_byte_pos+1], data) - self.assertEqual(content[last_byte_pos+1:], self.obj[0]['data'][last_byte_pos+1:]) + self.assertEqual(content[first_byte_pos:last_byte_pos + 1], data) + self.assertEqual(content[last_byte_pos + 1:], self.obj[0]['data'][last_byte_pos + 1:]) self.assertEqual(etag, compute_md5_hash(content)) def test_update_object_lt_blocksize(self): @@ -1664,46 +1668,46 @@ def test_update_object_lt_blocksize(self): def test_update_object_gt_blocksize(self): o = self.upload_random_data(self.containers[0], o_names[1], - length=4*1024*1024+5) + length=4*1024*1024+5) c = self.containers[0] o_name = o['name'] o_data = o['data'] - first_byte_pos = 4*1024*1024+1 - last_byte_pos = 4*1024*1024+4 + first_byte_pos = 4 * 1024 * 1024 + 1 + last_byte_pos = 4 * 1024 * 1024 + 4 l = last_byte_pos - first_byte_pos + 1 data = get_random_data(l) - range = 'bytes %d-%d/*' %(first_byte_pos, last_byte_pos) + range = 'bytes %d-%d/*' % (first_byte_pos, last_byte_pos) self.client.update_object(c, o_name, StringIO(data), content_range=range) content = self.client.retrieve_object(c, o_name) self.assertEqual(content[:first_byte_pos], o_data[:first_byte_pos]) - self.assertEqual(content[first_byte_pos:last_byte_pos+1], data) - self.assertEqual(content[last_byte_pos+1:], o_data[last_byte_pos+1:]) + self.assertEqual(content[first_byte_pos:last_byte_pos + 1], data) + self.assertEqual(content[last_byte_pos + 1:], o_data[last_byte_pos + 1:]) def test_update_object_divided_by_blocksize(self): o = self.upload_random_data(self.containers[0], o_names[1], - length=4*1024*1024+5) + length=4*1024*1024+5) c = self.containers[0] o_name = o['name'] o_data = o['data'] - first_byte_pos = 4*1024*1024 - last_byte_pos = 5*1024*1024 + first_byte_pos = 4 * 1024 * 1024 + last_byte_pos = 5 * 1024 * 1024 l = last_byte_pos - first_byte_pos + 1 data = get_random_data(l) - range = 'bytes %d-%d/*' %(first_byte_pos, last_byte_pos) + range = 'bytes %d-%d/*' % (first_byte_pos, last_byte_pos) self.client.update_object(c, o_name, StringIO(data), content_range=range) content = self.client.retrieve_object(c, o_name) self.assertEqual(content[:first_byte_pos], o_data[:first_byte_pos]) - self.assertEqual(content[first_byte_pos:last_byte_pos+1], data) - self.assertEqual(content[last_byte_pos+1:], o_data[last_byte_pos+1:]) + self.assertEqual(content[first_byte_pos:last_byte_pos + 1], data) + self.assertEqual(content[last_byte_pos + 1:], o_data[last_byte_pos + 1:]) def test_update_object_no_content_length(self): - self.test_update_object(content_length = None) + self.test_update_object(content_length=None) def test_update_object_invalid_content_length(self): with AssertContentInvariant(self.client.retrieve_object, self.containers[0], self.obj[0]['name']): self.assert_raises_fault(400, self.test_update_object, - content_length = 1000) + content_length=1000) def test_update_object_invalid_range(self): with AssertContentInvariant(self.client.retrieve_object, @@ -1720,13 +1724,13 @@ def test_update_object_invalid_range_with_no_content_length(self): with AssertContentInvariant(self.client.retrieve_object, self.containers[0], self.obj[0]['name']): self.assert_raises_fault(416, self.test_update_object, 499, 0, True, - content_length = None) + content_length=None) def test_update_object_out_of_limits(self): with AssertContentInvariant(self.client.retrieve_object, self.containers[0], self.obj[0]['name']): l = len(self.obj[0]['data']) - self.assert_raises_fault(416, self.test_update_object, 0, l+1, True) + self.assert_raises_fault(416, self.test_update_object, 0, l + 1, True) def test_append(self): data = get_random_data(500) @@ -1751,7 +1755,7 @@ def test_update_with_chunked_transfer(self): offset=0, content_type='application/octet-stream') - #check modified object + # check modified object content = self.client.retrieve_object(self.containers[0], self.obj[0]['name']) self.assertEqual(content[0:dl], data) @@ -1766,7 +1770,7 @@ def test_update_from_other_object(self): source_meta = self.client.retrieve_object_metadata(c, src) source_hash = self.client.retrieve_object_hashmap(c, src)["hashes"] - #update zero length object + # update zero length object self.client.create_zero_length_object(c, dest) source_object = '/%s/%s' % (c, src) self.client.update_from_other_source(c, dest, source_object) @@ -1776,7 +1780,7 @@ def test_update_from_other_object(self): self.assertEqual(source_data, dest_data) self.assertEqual(source_hash, dest_hash) - #test append + # test append self.client.update_from_other_source(c, dest, source_object) content = self.client.retrieve_object(c, dest) self.assertEqual(source_data * 2, content) @@ -1785,43 +1789,42 @@ def test_update_range_from_other_object(self): c = self.containers[0] dest = 'object' - #test update range + # test update range src = self.obj[1]['name'] src_data = self.client.retrieve_object(c, src) - #update zero length object + # update zero length object prev_data = self.upload_random_data(c, dest, length=4*1024*1024+10)['data'] source_object = '/%s/%s' % (c, src) - first_byte_pos = 4*1024*1024+1 - last_byte_pos = 4*1024*1024+4 - range = 'bytes %d-%d/*' %(first_byte_pos, last_byte_pos) + first_byte_pos = 4 * 1024 * 1024 + 1 + last_byte_pos = 4 * 1024 * 1024 + 4 + range = 'bytes %d-%d/*' % (first_byte_pos, last_byte_pos) self.client.update_from_other_source(c, dest, source_object, content_range=range) content = self.client.retrieve_object(c, dest) self.assertEqual(content[:first_byte_pos], prev_data[:first_byte_pos]) - self.assertEqual(content[first_byte_pos:last_byte_pos+1], src_data[:last_byte_pos - first_byte_pos + 1]) - self.assertEqual(content[last_byte_pos+1:], prev_data[last_byte_pos+1:]) + self.assertEqual(content[first_byte_pos:last_byte_pos + 1], src_data[:last_byte_pos - first_byte_pos + 1]) + self.assertEqual(content[last_byte_pos + 1:], prev_data[last_byte_pos + 1:]) def test_update_hashes_from_other_object(self): c = self.containers[0] dest = 'object' - #test update range + # test update range src_data = self.upload_random_data(c, o_names[0], length=1024*1024+10)['data'] - #update zero length object + # update zero length object prev_data = self.upload_random_data(c, dest, length=5*1024*1024+10)['data'] source_object = '/%s/%s' % (c, o_names[0]) - first_byte_pos = 4*1024*1024 - last_byte_pos = 5*1024*1024 - range = 'bytes %d-%d/*' %(first_byte_pos, last_byte_pos) + first_byte_pos = 4 * 1024 * 1024 + last_byte_pos = 5 * 1024 * 1024 + range = 'bytes %d-%d/*' % (first_byte_pos, last_byte_pos) self.client.update_from_other_source(c, dest, source_object, content_range=range) content = self.client.retrieve_object(c, dest) self.assertEqual(content[:first_byte_pos], prev_data[:first_byte_pos]) - self.assertEqual(content[first_byte_pos:last_byte_pos+1], src_data[:last_byte_pos - first_byte_pos + 1]) - self.assertEqual(content[last_byte_pos+1:], prev_data[last_byte_pos+1:]) - + self.assertEqual(content[first_byte_pos:last_byte_pos + 1], src_data[:last_byte_pos - first_byte_pos + 1]) + self.assertEqual(content[last_byte_pos + 1:], prev_data[last_byte_pos + 1:]) def test_update_zero_length_object(self): c = self.containers[0] @@ -1839,6 +1842,7 @@ def test_update_zero_length_object(self): self.assertEqual(self.client.retrieve_object_hashmap(c, o)["hashes"], self.client.retrieve_object_hashmap(c, other)["hashes"]) + class ObjectDelete(BaseTestCase): def setUp(self): BaseTestCase.setUp(self) @@ -1850,11 +1854,11 @@ def setUp(self): self.obj = self.upload_random_data(self.containers[0], o_names[0]) def test_delete(self): - #perform delete object + # perform delete object self.client.delete_object(self.containers[0], self.obj['name'])[0] def test_delete_invalid(self): - #assert item not found + # assert item not found self.assert_raises_fault(404, self.client.delete_object, self.containers[1], self.obj['name']) @@ -1871,14 +1875,15 @@ def test_delete_dir(self): self.assert_object_not_exists(self.containers[0], object) self.assert_object_exists(self.containers[0], objects[-1]) + class ListSharing(BaseTestCase): def setUp(self): BaseTestCase.setUp(self) for i in range(2): - self.client.create_container('c%s' %i) + self.client.create_container('c%s' % i) self.client.create_container('c') for i in range(2): - self.upload_random_data('c1', 'o%s' %i) + self.upload_random_data('c1', 'o%s' % i) if not OTHER_ACCOUNTS: raise Warning('No other accounts avalaible for running this test.') for token, account in OTHER_ACCOUNTS.items(): @@ -1888,8 +1893,8 @@ def setUp(self): def test_list_other_shared(self): self.other = Pithos_Client(get_url(), - self.o1_sharing[0], - self.o1_sharing[1]) + self.o1_sharing[0], + self.o1_sharing[1]) self.assertTrue(get_user() in self.other.list_shared_with_me()) def test_list_my_shared(self): @@ -1901,6 +1906,7 @@ def test_list_my_shared(self): self.assertTrue('o1' in my_shared_objects) self.assertTrue('o2' not in my_shared_objects) + class List(BaseTestCase): def setUp(self): BaseTestCase.setUp(self) @@ -1912,87 +1918,88 @@ def setUp(self): self.upload_random_data(c, o) if i < 3: self.client.share_object(c, 'o1', ['papagian'], read=True) - if i%2 != 0: + if i % 2 != 0: self.client.publish_object(c, 'o2') def test_shared_public(self): diff = lambda l: set(l) - set(self.initial_containers) - func, kwargs = self.client.list_containers, {'shared':True} + func, kwargs = self.client.list_containers, {'shared': True} l = func(**kwargs) self.assertEqual(set(['c1', 'c2']), diff(l)) self.assertEqual(l, [e['name'] for e in func(format='json', **kwargs)]) - func, kwargs = self.client.list_containers, {'public':True} + func, kwargs = self.client.list_containers, {'public': True} l = func(**kwargs) self.assertEqual(set(['c1', 'c3']), diff(l)) self.assertEqual(l, [e['name'] for e in func(format='json', **kwargs)]) - func, kwargs = self.client.list_containers, {'shared':True, 'public':True} + func, kwargs = self.client.list_containers, {'shared': True, 'public': True} l = func(**kwargs) self.assertEqual(set(['c1', 'c2', 'c3']), diff(l)) self.assertEqual(l, [e['name'] for e in func(format='json', **kwargs)]) - func, args, kwargs = self.client.list_objects, ['c1'], {'shared':True} + func, args, kwargs = self.client.list_objects, ['c1'], {'shared': True} l = func(*args, **kwargs) self.assertEqual(l, ['o1']) self.assertEqual(l, [e['name'] for e in func(*args, format='json', **kwargs)]) - func, args, kwargs = self.client.list_objects, ['c1'], {'public':True} + func, args, kwargs = self.client.list_objects, ['c1'], {'public': True} l = func(*args, **kwargs) self.assertEqual(l, ['o2']) self.assertEqual(l, [e['name'] for e in func(*args, format='json', **kwargs)]) - func, args, kwargs = self.client.list_objects, ['c1'], {'shared':True, 'public':True} + func, args, kwargs = self.client.list_objects, ['c1'], {'shared': True, 'public': True} l = func(*args, **kwargs) self.assertEqual(l, ['o1', 'o2']) self.assertEqual(l, [e['name'] for e in func(*args, format='json', **kwargs)]) - func, args, kwargs = self.client.list_objects, ['c2'], {'shared':True} + func, args, kwargs = self.client.list_objects, ['c2'], {'shared': True} l = func(*args, **kwargs) self.assertEqual(l, ['o1']) self.assertEqual(l, [e['name'] for e in func(*args, format='json', **kwargs)]) - func, args, kwargs = self.client.list_objects, ['c2'], {'public':True} + func, args, kwargs = self.client.list_objects, ['c2'], {'public': True} l = func(*args, **kwargs) self.assertEqual(l, '') self.assertEqual([], func(*args, format='json', **kwargs)) - func, args, kwargs = self.client.list_objects, ['c2'], {'shared':True, 'public':True} + func, args, kwargs = self.client.list_objects, ['c2'], {'shared': True, 'public': True} l = func(*args, **kwargs) self.assertEqual(l, ['o1']) self.assertEqual(l, [e['name'] for e in func(*args, format='json', **kwargs)]) - func, args, kwargs = self.client.list_objects, ['c3'], {'shared':True} + func, args, kwargs = self.client.list_objects, ['c3'], {'shared': True} l = func(*args, **kwargs) self.assertEqual(l, '') self.assertEqual([], func(*args, format='json', **kwargs)) - func, args, kwargs = self.client.list_objects, ['c3'], {'public':True} + func, args, kwargs = self.client.list_objects, ['c3'], {'public': True} l = func(*args, **kwargs) self.assertEqual(l, ['o2']) self.assertEqual(l, [e['name'] for e in func(*args, format='json', **kwargs)]) - func, args, kwargs = self.client.list_objects, ['c3'], {'shared':True, 'public':True} + func, args, kwargs = self.client.list_objects, ['c3'], {'shared': True, 'public': True} l = func(*args, **kwargs) self.assertEqual(l, ['o2']) self.assertEqual(l, [e['name'] for e in func(*args, format='json', **kwargs)]) - func, args, kwargs = self.client.list_objects, ['c4'], {'shared':True} + func, args, kwargs = self.client.list_objects, ['c4'], {'shared': True} l = func(*args, **kwargs) self.assertEqual(l, '') self.assertEqual([], func(*args, format='json', **kwargs)) - func, args, kwargs = self.client.list_objects, ['c4'], {'public':True} + func, args, kwargs = self.client.list_objects, ['c4'], {'public': True} l = func(*args, **kwargs) self.assertEqual(l, '') self.assertEqual([], func(*args, format='json', **kwargs)) - func, args, kwargs = self.client.list_objects, ['c4'], {'shared':True, 'public':True} + func, args, kwargs = self.client.list_objects, ['c4'], {'shared': True, 'public': True} l = func(*args, **kwargs) self.assertEqual(l, '') self.assertEqual([], func(*args, format='json', **kwargs)) + class TestUTF8(BaseTestCase): def test_create_container(self): self.client.create_container('φάκελος') @@ -2059,14 +2066,14 @@ def test_delete_container(self): self.assertTrue('φάκελος' not in self.client.list_containers()) def test_account_meta(self): - meta = {'ποιότητα':'ΑΑΑ'} + meta = {'ποιότητα': 'ΑΑΑ'} self.client.update_account_metadata(**meta) meta = self.client.retrieve_account_metadata(restricted=True) self.assertTrue('ποιότητα' in meta.keys()) self.assertEqual(meta['ποιότητα'], 'ΑΑΑ') def test_container_meta(self): - meta = {'ποιότητα':'ΑΑΑ'} + meta = {'ποιότητα': 'ΑΑΑ'} self.client.create_container('φάκελος', meta=meta) meta = self.client.retrieve_container_metadata('φάκελος', restricted=True) @@ -2075,7 +2082,7 @@ def test_container_meta(self): def test_object_meta(self): self.client.create_container('φάκελος') - meta = {'ποιότητα':'ΑΑΑ'} + meta = {'ποιότητα': 'ΑΑΑ'} self.upload_random_data('φάκελος', 'αντικείμενο', **meta) meta = self.client.retrieve_object_metadata('φάκελος', 'αντικείμενο', @@ -2085,12 +2092,12 @@ def test_object_meta(self): def test_list_meta_filtering(self): self.client.create_container('φάκελος') - meta = {'ποιότητα':'ΑΑΑ'} + meta = {'ποιότητα': 'ΑΑΑ'} self.upload_random_data('φάκελος', 'ο1', **meta) self.upload_random_data('φάκελος', 'ο2') self.upload_random_data('φάκελος', 'ο3') - meta = {'ποσότητα':'μεγάλη'} + meta = {'ποσότητα': 'μεγάλη'} self.client.update_object_metadata('φάκελος', 'ο2', **meta) objects = self.client.list_objects('φάκελος', meta='ποιότητα, ποσότητα') self.assertEquals(objects, ['ο1', 'ο2']) @@ -2101,16 +2108,16 @@ def test_list_meta_filtering(self): objects = self.client.list_objects('φάκελος', meta='!ποιότητα, !ποσότητα') self.assertEquals(objects, ['ο3']) - meta = {'ποιότητα':'ΑΒ'} + meta = {'ποιότητα': 'ΑΒ'} self.client.update_object_metadata('φάκελος', 'ο2', **meta) objects = self.client.list_objects('φάκελος', meta='ποιότητα=ΑΑΑ') self.assertEquals(objects, ['ο1']) objects = self.client.list_objects('φάκελος', meta='ποιότητα!=ΑΑΑ') self.assertEquals(objects, ['ο2']) - meta = {'έτος':'2011'} + meta = {'έτος': '2011'} self.client.update_object_metadata('φάκελος', 'ο3', **meta) - meta = {'έτος':'2012'} + meta = {'έτος': '2012'} self.client.update_object_metadata('φάκελος', 'ο2', **meta) objects = self.client.list_objects('φάκελος', meta='έτος<2012') self.assertEquals(objects, ['ο3']) @@ -2120,26 +2127,26 @@ def test_list_meta_filtering(self): self.assertEquals(objects, '') def test_groups(self): - #create a group - groups = {'γκρουπ':'chazapis,διογένης'} + # create a group + groups = {'γκρουπ': 'chazapis,διογένης'} self.client.set_account_groups(**groups) groups.update(self.initial_groups) self.assertEqual(groups['γκρουπ'], self.client.retrieve_account_groups()['γκρουπ']) - #check read access + # check read access self.client.create_container('φάκελος') o = self.upload_random_data('φάκελος', 'ο1') self.client.share_object('φάκελος', 'ο1', ['%s:γκρουπ' % get_user()]) if 'διογένης' not in OTHER_ACCOUNTS.values(): raise Warning('No such an account exists for running this test.') chef = Pithos_Client(get_url(), - '0009', - 'διογένης') + '0009', + 'διογένης') self.assert_not_raises_fault(403, chef.retrieve_object_metadata, 'φάκελος', 'ο1', account=get_user()) - #check write access + # check write access self.client.share_object('φάκελος', 'ο1', ['διογένης'], read=False) new_data = get_random_data() self.assert_not_raises_fault(403, chef.update_object, @@ -2155,19 +2162,19 @@ def test_manifestation(self): prefix = 'μέρη/' data = '' for i in range(5): - part = '%s%d' %(prefix, i) + part = '%s%d' % (prefix, i) o = self.upload_random_data('κουβάς', part) data += o['data'] self.client.create_container('φάκελος') - manifest = '%s/%s' %('κουβάς', prefix) + manifest = '%s/%s' % ('κουβάς', prefix) self.client.create_manifestation('φάκελος', 'άπαντα', manifest) self.assert_object_exists('φάκελος', 'άπαντα') self.assertEqual(data, self.client.retrieve_object('φάκελος', 'άπαντα')) - #wrong manifestation + # wrong manifestation self.client.create_manifestation('φάκελος', 'άπαντα', 'κουβάς/άκυρο') self.assertEqual('', self.client.retrieve_object('φάκελος', 'άπαντα')) @@ -2182,6 +2189,7 @@ def test_update_from_another_object(self): self.client.retrieve_object('κουβάς', 'νέο'), '%s%s' % (initial_data, self.client.retrieve_object('κουβάς', 'πηγή'))) + class TestPermissions(BaseTestCase): def setUp(self): BaseTestCase.setUp(self) @@ -2189,19 +2197,19 @@ def setUp(self): if not OTHER_ACCOUNTS: raise Warning('No other accounts avalaible for running this test.') - #create a group + # create a group self.authorized = ['chazapis', 'verigak', 'gtsouk'] - groups = {'pithosdev':','.join(self.authorized)} + groups = {'pithosdev': ','.join(self.authorized)} self.client.set_account_groups(**groups) self.container = 'c' self.object = 'o' self.client.create_container(self.container) self.upload_random_data(self.container, self.object) - self.upload_random_data(self.container, self.object+'/') - self.upload_random_data(self.container, self.object+'/a') - self.upload_random_data(self.container, self.object+'a') - self.upload_random_data(self.container, self.object+'a/') + self.upload_random_data(self.container, self.object + '/') + self.upload_random_data(self.container, self.object + '/a') + self.upload_random_data(self.container, self.object + 'a') + self.upload_random_data(self.container, self.object + 'a/') self.dir_content_types = ('application/directory', 'application/folder') def assert_read(self, authorized=None, any=False, depth=0): @@ -2217,24 +2225,24 @@ def assert_read(self, authorized=None, any=False, depth=0): self.container, self.object, account=get_user()) - #check inheritance + # check inheritance meta = self.client.retrieve_object_metadata(self.container, self.object) type = meta['content-type'] derivatives = self.client.list_objects(self.container, prefix=self.object) - #exclude the self.object + # exclude the self.object del derivatives[derivatives.index(self.object)] for o in derivatives: for token, account in OTHER_ACCOUNTS.items(): cl = Pithos_Client(get_url(), token, account) - prefix = self.object if self.object.endswith('/') else self.object+'/' + prefix = self.object if self.object.endswith('/') else self.object + '/' if (account in authorized or any) and \ - (type in self.dir_content_types) and \ - o.startswith(prefix): + (type in self.dir_content_types) and \ + o.startswith(prefix): self.assert_not_raises_fault(403, cl.retrieve_object_metadata, - self.container, o, account=get_user()) + self.container, o, account=get_user()) else: self.assert_raises_fault(403, cl.retrieve_object_metadata, - self.container, o, account=get_user()) + self.container, o, account=get_user()) def assert_write(self, authorized=None, any=False): authorized = authorized or [] @@ -2257,22 +2265,22 @@ def assert_write(self, authorized=None, any=False): self.failIf(f.status == 403) else: self.assert_raises_fault(403, cl.update_object, - self.container, self.object, StringIO(new_data), - account=get_user()) - #check inheritance + self.container, self.object, StringIO(new_data), + account=get_user()) + # check inheritance meta = self.client.retrieve_object_metadata(self.container, self.object) type = meta['content-type'] derivatives = self.client.list_objects(self.container, prefix=self.object) - #exclude the object + # exclude the object del derivatives[derivatives.index(self.object)] for o in derivatives: for token, account in OTHER_ACCOUNTS.items(): - prefix = self.object if self.object.endswith('/') else self.object+'/' + prefix = self.object if self.object.endswith('/') else self.object + '/' cl = Pithos_Client(get_url(), token, account) new_data = get_random_data() if (account in authorized or any) and \ - (type in self.dir_content_types) and \ - o.startswith(prefix): + (type in self.dir_content_types) and \ + o.startswith(prefix): # test write access self.assert_not_raises_fault(403, cl.update_object, self.container, o, @@ -2285,9 +2293,9 @@ def assert_write(self, authorized=None, any=False): self.failIf(f.status == 403) else: self.assert_raises_fault(403, cl.update_object, - self.container, o, - StringIO(new_data), - account=get_user()) + self.container, o, + StringIO(new_data), + account=get_user()) def test_group_read(self): self.client.share_object(self.container, self.object, ['%s:pithosdev' % get_user()]) @@ -2303,7 +2311,7 @@ def test_read_by_everyone(self): def test_read_directory(self): for type in self.dir_content_types: - #change content type + # change content type self.client.move_object(self.container, self.object, self.container, self.object, content_type=type) self.client.share_object(self.container, self.object, ['*']) self.assert_read(any=True) @@ -2327,8 +2335,9 @@ def test_write_by_everyone(self): def test_write_directory(self): dir_content_types = ('application/directory', 'application/foler') for type in dir_content_types: - #change content type - self.client.move_object(self.container, self.object, self.container, self.object, content_type='application/folder') + # change content type + self.client.move_object(self.container, self.object, self.container, self.object, + content_type='application/folder') self.client.share_object(self.container, self.object, ['*'], read=False) self.assert_write(any=True) self.client.share_object(self.container, self.object, self.authorized, read=False) @@ -2346,8 +2355,9 @@ def test_shared_listing(self): dir_content_types = ('application/directory', 'application/foler') for type in dir_content_types: - #change content type - self.client.move_object(self.container, self.object, self.container, self.object, content_type='application/folder') + # change content type + self.client.move_object(self.container, self.object, self.container, self.object, + content_type='application/folder') my_shared_objects = self.client.list_objects('c', shared=True) self.assertEqual(['o', 'o/', 'o/a'], my_shared_objects) @@ -2356,6 +2366,7 @@ def test_shared_listing(self): self.other = Pithos_Client(get_url(), token, account) self.assertTrue(get_user() in self.other.list_shared_with_me()) + class TestPublish(BaseTestCase): def test_publish(self): self.client.create_container('c') @@ -2387,9 +2398,10 @@ def test_publish(self): meta = cl.retrieve_object_metadata('c', 'o', account=get_user()) self.assertTrue('x-object-public' not in meta) + class TestPolicies(BaseTestCase): def test_none_versioning(self): - self.client.create_container('c', policies={'versioning':'none'}) + self.client.create_container('c', policies={'versioning': 'none'}) o = self.upload_random_data('c', 'o') meta = self.client.retrieve_object_metadata('c', 'o') v = meta['x-object-version'] @@ -2404,18 +2416,19 @@ def test_none_versioning(self): self.assertEqual(data[end:], more_data) def test_quota(self): - self.client.create_container('c', policies={'quota':'1'}) + self.client.create_container('c', policies={'quota': '1'}) meta = self.client.retrieve_container_metadata('c') self.assertEqual(meta['x-container-policy-quota'], '1') self.assert_raises_fault(413, self.upload_random_data, 'c', 'o', length=1024*1024+1) def test_quota_none(self): - self.client.create_container('c', policies={'quota':'0'}) + self.client.create_container('c', policies={'quota': '0'}) meta = self.client.retrieve_container_metadata('c') self.assertEqual(meta['x-container-policy-quota'], '0') self.assert_not_raises_fault(413, self.upload_random_data, 'c', 'o', - length=1024*1024+1) + length=1024*1024+1) + class TestUsageFreeVersioningAutoContainerPolicy(BaseTestCase): """ Challenge free version accounting @@ -2448,8 +2461,8 @@ def setUp(self): print 'Current account usage: %d' % self.initial_usage self.usage = self.initial_usage - #self.mtime = {} - l = (50, 100, 150, 70, 80) + # self.mtime = {} + l = (50, 100, 150, 70, 80) self.curr_acc_usage = self.initial_usage for i, length in list(enumerate(l)): self.upload_random_data('container', 'object', length=length) @@ -2459,8 +2472,8 @@ def setUp(self): self.curr_acc_usage = self.initial_usage + length self.assertEqual(self.usage, self.curr_acc_usage) - #t = datetime.datetime.utcnow() - #self.mtime[i] = int(_time.mktime(t.timetuple())) + # t = datetime.datetime.utcnow() + # self.mtime[i] = int(_time.mktime(t.timetuple())) _time.sleep(1) versions = self.client.retrieve_object_versionlist( @@ -2597,7 +2610,7 @@ def _test_purge_container_delete_object(self): meta = self.client.retrieve_account_metadata() self.usage = int(meta['x-account-bytes-used']) print 'Current account usage: %d' % self.usage - self.assertEqual( self.usage, self.curr_acc_usage) + self.assertEqual(self.usage, self.curr_acc_usage) self.client.delete_object('container', 'object') meta = self.client.retrieve_account_metadata() @@ -2754,8 +2767,8 @@ class TestUsageFreeVersioningNoneContainerPolicy( enforce all test cases to return immediately """ def create_container(self, cname): - self.client.create_container(cname, - policies={'versioning':'none'}) + self.client.create_container(cname, policies={'versioning': 'none'}) + class TestUsageDebitVersioningAutoContainerPolicy(BaseTestCase): """ Challenge debit version accounting @@ -2945,7 +2958,6 @@ def _test_purge_container_delete_object(self): print 'Current account usage: %d' % self.usage self.assertEqual(self.usage, self.curr_acc_usage - sum(self.l[:i])) - self.client.delete_container('container') meta = self.client.retrieve_account_metadata() self.usage = int(meta['x-account-bytes-used']) @@ -3095,6 +3107,7 @@ def _test_delete_container_content(self): print 'Current account usage: %d' % self.usage self.assertEqual(self.usage, self.initial_usage) + class TestUsageDebitVersioningNoneContainerPolicy(BaseTestCase): """ Challenge debit version accounting in a container with none versioning policy @@ -3124,7 +3137,7 @@ def setUp(self): self.initial_usage = int(meta['x-account-bytes-used']) print 'Current account usage: %d' % self.initial_usage - l = (50, 100, 150, 70, 80) + l = (50, 100, 150, 70, 80) self.curr_acc_usage = self.initial_usage for i, length in list(enumerate(l)): self.upload_random_data('container', 'object', length=length) @@ -3141,8 +3154,7 @@ def setUp(self): self.mtime = [int(i[1]) for i in versions] def create_container(self, cname): - self.client.create_container(cname, - policies={'versioning':'none'}) + self.client.create_container(cname, policies={'versioning': 'none'}) def _test_delete_object_container(self): """ @@ -3395,6 +3407,7 @@ def _test_delete_container_content(self): print 'Current account usage: %d' % self.usage self.assertEqual(self.usage, self.initial_usage) + class AssertUUidInvariant(object): def __init__(self, callable, *args, **kwargs): self.callable = callable @@ -3413,6 +3426,7 @@ def __exit__(self, type, value, tb): uuid = map['x-object-uuid'] assert(uuid == self.uuid) + class AssertMappingInvariant(object): def __init__(self, callable, *args, **kwargs): self.callable = callable @@ -3431,6 +3445,7 @@ def __exit__(self, type, value, tb): assert(k in map) assert v == map[k] + class AssertContentInvariant(object): def __init__(self, callable, *args, **kwargs): self.callable = callable @@ -3445,25 +3460,30 @@ def __exit__(self, type, value, tb): content = self.callable(*self.args, **self.kwargs)[2] assert self.content == content + def get_content_splitted(response): if response: return response.content.split('\n') + def compute_md5_hash(data): md5 = hashlib.md5() offset = 0 md5.update(data) return md5.hexdigest().lower() + def compute_block_hash(data, algorithm): h = hashlib.new(algorithm) h.update(data.rstrip('\x00')) return h.hexdigest() + def get_random_data(length=500): char_set = string.ascii_uppercase + string.digits return ''.join(random.choice(char_set) for x in xrange(length)) + def is_date(date): MONTHS = 'jan feb mar apr may jun jul aug sep oct nov dec'.split() __D = r'(?P\d{2})' @@ -3481,24 +3501,25 @@ def is_date(date): return True return False + def strnextling(prefix): """Return the first unicode string greater than but not starting with given prefix. strnextling('hello') -> 'hellp' """ if not prefix: - ## all strings start with the null string, - ## therefore we have to approximate strnextling('') - ## with the last unicode character supported by python - ## 0x10ffff for wide (32-bit unicode) python builds - ## 0x00ffff for narrow (16-bit unicode) python builds - ## We will not autodetect. 0xffff is safe enough. + # all strings start with the null string, + # therefore we have to approximate strnextling('') + # with the last unicode character supported by python + # 0x10ffff for wide (32-bit unicode) python builds + # 0x00ffff for narrow (16-bit unicode) python builds + # We will not autodetect. 0xffff is safe enough. return unichr(0xffff) s = prefix[:-1] c = ord(prefix[-1]) if c >= 0xffff: raise RuntimeError - s += unichr(c+1) + s += unichr(c + 1) return s o_names = ['kate.jpg', @@ -3527,4 +3548,3 @@ def main(): if __name__ == "__main__": main() - From c2c090e038da7a090b59c62a985a903c79cab372 Mon Sep 17 00:00:00 2001 From: indorilftw Date: Wed, 12 Nov 2014 11:41:40 +0200 Subject: [PATCH 04/43] PEP8 fixes on contrib directory --- contrib/migrate.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/migrate.py b/contrib/migrate.py index 452e8272e..f5f66a534 100644 --- a/contrib/migrate.py +++ b/contrib/migrate.py @@ -28,7 +28,7 @@ class Migration(object): def __init__(self, db): self.engine = create_engine(db) self.metadata = MetaData(self.engine) - #self.engine.echo = True + # self.engine.echo = True self.conn = self.engine.connect() options = getattr(settings, 'BACKEND', None)[1] From 4a0c07e3597e2f9b409fd1758ef17b75fe40f3c2 Mon Sep 17 00:00:00 2001 From: indorilftw Date: Wed, 12 Nov 2014 11:42:21 +0200 Subject: [PATCH 05/43] PEP8 fixes on conf directory --- docs/conf.py | 49 +++++++++++++++++++++++++------------------------ 1 file changed, 25 insertions(+), 24 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index 0ec07f4a4..d694c1eec 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -1,4 +1,5 @@ -import sys, os +import sys +import os sys.path.insert(0, os.path.abspath('../snf-cyclades-app')) import synnefo @@ -20,34 +21,34 @@ pygments_style = 'sphinx' html_theme = 'default' html_theme_options = { - 'sidebarwidth': '300', - 'collapsiblesidebar': 'true', - 'footerbgcolor': '#55b577', - 'footertextcolor': '#000000', - 'sidebarbgcolor': '#ffffff', - 'sidebarbtncolor': '#f2f2f2', - 'sidebartextcolor': '#000000', - 'sidebarlinkcolor': '#328e4a', - 'relbarbgcolor': '#55b577', - 'relbartextcolor': '#ffffff', - 'relbarlinkcolor': '#ffffff', - 'bgcolor': '#ffffff', - 'textcolor': '#000000', - 'headbgcolor': '#ffffff', - 'headtextcolor': '#000000', - 'headlinkcolor': '#c60f0f', - 'linkcolor': '#328e4a', - 'visitedlinkcolor': '#63409b', - 'codebgcolor': '#eeffcc', - 'codetextcolor': '#333333' + 'sidebarwidth': '300', + 'collapsiblesidebar': 'true', + 'footerbgcolor': '#55b577', + 'footertextcolor': '#000000', + 'sidebarbgcolor': '#ffffff', + 'sidebarbtncolor': '#f2f2f2', + 'sidebartextcolor': '#000000', + 'sidebarlinkcolor': '#328e4a', + 'relbarbgcolor': '#55b577', + 'relbartextcolor': '#ffffff', + 'relbarlinkcolor': '#ffffff', + 'bgcolor': '#ffffff', + 'textcolor': '#000000', + 'headbgcolor': '#ffffff', + 'headtextcolor': '#000000', + 'headlinkcolor': '#c60f0f', + 'linkcolor': '#328e4a', + 'visitedlinkcolor': '#63409b', + 'codebgcolor': '#eeffcc', + 'codetextcolor': '#333333' } htmlhelp_basename = 'synnefodoc' intersphinx_mapping = { - 'python': ('http://docs.python.org/', None), - 'django': ('https://docs.djangoproject.com/en/dev/', - 'https://docs.djangoproject.com/en/dev/_objects/') + 'python': ('http://docs.python.org/', None), + 'django': ('https://docs.djangoproject.com/en/dev/', + 'https://docs.djangoproject.com/en/dev/_objects/') } SYNNEFO_PROJECTS = ['synnefo', 'archipelago', 'kamaki', 'snf-image', From ac01bdbcf67258d165e20a68bd8f9f98be6f5c58 Mon Sep 17 00:00:00 2001 From: indorilftw Date: Wed, 12 Nov 2014 11:44:22 +0200 Subject: [PATCH 06/43] PEP8 fixes on snf-admin-app directory --- snf-admin-app/distribute_setup.py | 34 ++++++++++++------- snf-admin-app/setup.py | 24 ++++++------- .../admin/resources/auth_providers/filters.py | 1 - .../admin/resources/auth_providers/utils.py | 1 - .../admin/resources/groups/filters.py | 1 - .../admin/resources/groups/utils.py | 1 - .../admin/templatetags/admin_tags.py | 4 +-- .../synnefo_admin/admin/tests/projects.py | 2 +- .../synnefo_admin/admin/tests/users.py | 2 +- snf-admin-app/synnefo_admin/admin/views.py | 2 +- snf-admin-app/synnefo_admin/admin_settings.py | 2 +- 11 files changed, 38 insertions(+), 36 deletions(-) diff --git a/snf-admin-app/distribute_setup.py b/snf-admin-app/distribute_setup.py index 10d66840a..c933b1d0b 100644 --- a/snf-admin-app/distribute_setup.py +++ b/snf-admin-app/distribute_setup.py @@ -144,17 +144,17 @@ def use_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL, except ImportError: return _do_download(version, download_base, to_dir, download_delay) try: - pkg_resources.require("distribute>="+version) + pkg_resources.require("distribute>=" + version) return except pkg_resources.VersionConflict: e = sys.exc_info()[1] if was_imported: sys.stderr.write( - "The required version of distribute (>=%s) is not available,\n" - "and can't be installed while this script is running. Please\n" - "install a more recent version first, using\n" - "'easy_install -U distribute'." - "\n\n(Currently using %r)\n" % (version, e.args[0])) + "The required version of distribute (>=%s) is not available,\n" + "and can't be installed while this script is running. Please\n" + "install a more recent version first, using\n" + "'easy_install -U distribute'." + "\n\n(Currently using %r)\n" % (version, e.args[0])) sys.exit(2) else: del pkg_resources, sys.modules['pkg_resources'] # reload ok @@ -167,6 +167,7 @@ def use_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL, if not no_fake: _create_fake_setuptools_pkg_info(to_dir) + def download_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL, to_dir=os.curdir, delay=15): """Download distribute from a specified location and return its filename @@ -203,6 +204,7 @@ def download_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL, dst.close() return os.path.realpath(saveto) + def _no_sandbox(function): def __no_sandbox(*args, **kw): try: @@ -227,6 +229,7 @@ def violation(*args): return __no_sandbox + def _patch_file(path, content): """Will backup the file then patch it""" existing_content = open(path).read() @@ -245,15 +248,18 @@ def _patch_file(path, content): _patch_file = _no_sandbox(_patch_file) + def _same_content(path, content): return open(path).read() == content + def _rename_path(path): new_name = path + '.OLD.%s' % time.time() log.warn('Renaming %s into %s', path, new_name) os.rename(path, new_name) return new_name + def _remove_flat_installation(placeholder): if not os.path.isdir(placeholder): log.warn('Unkown installation at %s', placeholder) @@ -289,18 +295,19 @@ def _remove_flat_installation(placeholder): _remove_flat_installation = _no_sandbox(_remove_flat_installation) + def _after_install(dist): log.warn('After install bootstrap.') placeholder = dist.get_command_obj('install').install_purelib _create_fake_setuptools_pkg_info(placeholder) + def _create_fake_setuptools_pkg_info(placeholder): if not placeholder or not os.path.exists(placeholder): log.warn('Could not find the install location') return pyver = '%s.%s' % (sys.version_info[0], sys.version_info[1]) - setuptools_file = 'setuptools-%s-py%s.egg-info' % \ - (SETUPTOOLS_FAKED_VERSION, pyver) + setuptools_file = 'setuptools-%s-py%s.egg-info' % (SETUPTOOLS_FAKED_VERSION, pyver) pkg_info = os.path.join(placeholder, setuptools_file) if os.path.exists(pkg_info): log.warn('%s already exists', pkg_info) @@ -323,6 +330,7 @@ def _create_fake_setuptools_pkg_info(placeholder): _create_fake_setuptools_pkg_info = _no_sandbox(_create_fake_setuptools_pkg_info) + def _patch_egg_dir(path): # let's check if it's already patched pkg_info = os.path.join(path, 'EGG-INFO', 'PKG-INFO') @@ -343,6 +351,7 @@ def _patch_egg_dir(path): _patch_egg_dir = _no_sandbox(_patch_egg_dir) + def _before_install(): log.warn('Before install bootstrap.') _fake_setuptools() @@ -351,7 +360,7 @@ def _before_install(): def _under_prefix(location): if 'install' not in sys.argv: return True - args = sys.argv[sys.argv.index('install')+1:] + args = sys.argv[sys.argv.index('install') + 1:] for index, arg in enumerate(args): for option in ('--root', '--prefix'): if arg.startswith('%s=' % option): @@ -359,7 +368,7 @@ def _under_prefix(location): return location.startswith(top_dir) elif arg == option: if len(args) > index: - top_dir = args[index+1] + top_dir = args[index + 1] return location.startswith(top_dir) if arg == '--user' and USER_SITE is not None: return location.startswith(USER_SITE) @@ -405,8 +414,7 @@ def _fake_setuptools(): else: log.warn('Egg installation') pkg_info = os.path.join(setuptools_location, 'EGG-INFO', 'PKG-INFO') - if (os.path.exists(pkg_info) and - _same_content(pkg_info, SETUPTOOLS_PKG_INFO)): + if (os.path.exists(pkg_info) and _same_content(pkg_info, SETUPTOOLS_PKG_INFO)): log.warn('Already patched.') return log.warn('Patching...') @@ -448,7 +456,7 @@ def _extractall(self, path=".", members=None): # Extract directories with a safe mode. directories.append(tarinfo) tarinfo = copy.copy(tarinfo) - tarinfo.mode = 448 # decimal for oct 0700 + tarinfo.mode = 448 # decimal for oct 0700 self.extract(tarinfo, path) # Reverse sort directories. diff --git a/snf-admin-app/setup.py b/snf-admin-app/setup.py index fd2170412..0b73d5760 100644 --- a/snf-admin-app/setup.py +++ b/snf-admin-app/setup.py @@ -54,18 +54,19 @@ ".*", "CVS", "_darcs", "./build", "./dist", "EGG-INFO", "*.egg-info", "snf-0.7" ] + # (c) 2005 Ian Bicking and contributors; written for Paste (http://pythonpaste.org) # Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php # Note: you may want to copy this into your setup.py file verbatim, as # you can't import this from another package, when you don't know if # that package is installed yet. def find_package_data( - where=".", - package="", - exclude=standard_exclude, - exclude_directories=standard_exclude_directories, - only_in_packages=True, - show_ignored=False): + where=".", + package="", + exclude=standard_exclude, + exclude_directories=standard_exclude_directories, + only_in_packages=True, + show_ignored=False): """ Return a dictionary suitable for use in ``package_data`` in a distutils ``setup.py`` file. @@ -101,8 +102,7 @@ def find_package_data( if os.path.isdir(fn): bad_name = False for pattern in exclude_directories: - if (fnmatchcase(name, pattern) - or fn.lower() == pattern.lower()): + if (fnmatchcase(name, pattern) or fn.lower() == pattern.lower()): bad_name = True if show_ignored: print >> sys.stderr, ( @@ -111,8 +111,7 @@ def find_package_data( break if bad_name: continue - if (os.path.isfile(os.path.join(fn, "__init__.py")) - and not prefix): + if (os.path.isfile(os.path.join(fn, "__init__.py")) and not prefix): if not package: new_package = name else: @@ -124,8 +123,7 @@ def find_package_data( # is a file bad_name = False for pattern in exclude: - if (fnmatchcase(name, pattern) - or fn.lower() == pattern.lower()): + if (fnmatchcase(name, pattern) or fn.lower() == pattern.lower()): bad_name = True if show_ignored: print >> sys.stderr, ( @@ -134,7 +132,7 @@ def find_package_data( break if bad_name: continue - out.setdefault(package, []).append(prefix+name) + out.setdefault(package, []).append(prefix + name) return out setup( diff --git a/snf-admin-app/synnefo_admin/admin/resources/auth_providers/filters.py b/snf-admin-app/synnefo_admin/admin/resources/auth_providers/filters.py index 16b971ec0..eb2130c4c 100644 --- a/snf-admin-app/synnefo_admin/admin/resources/auth_providers/filters.py +++ b/snf-admin-app/synnefo_admin/admin/resources/auth_providers/filters.py @@ -12,4 +12,3 @@ # # You should have received a copy of the GNU General Public License # along with this program. If not, see . - diff --git a/snf-admin-app/synnefo_admin/admin/resources/auth_providers/utils.py b/snf-admin-app/synnefo_admin/admin/resources/auth_providers/utils.py index 16b971ec0..eb2130c4c 100644 --- a/snf-admin-app/synnefo_admin/admin/resources/auth_providers/utils.py +++ b/snf-admin-app/synnefo_admin/admin/resources/auth_providers/utils.py @@ -12,4 +12,3 @@ # # You should have received a copy of the GNU General Public License # along with this program. If not, see . - diff --git a/snf-admin-app/synnefo_admin/admin/resources/groups/filters.py b/snf-admin-app/synnefo_admin/admin/resources/groups/filters.py index 16b971ec0..eb2130c4c 100644 --- a/snf-admin-app/synnefo_admin/admin/resources/groups/filters.py +++ b/snf-admin-app/synnefo_admin/admin/resources/groups/filters.py @@ -12,4 +12,3 @@ # # You should have received a copy of the GNU General Public License # along with this program. If not, see . - diff --git a/snf-admin-app/synnefo_admin/admin/resources/groups/utils.py b/snf-admin-app/synnefo_admin/admin/resources/groups/utils.py index 16b971ec0..eb2130c4c 100644 --- a/snf-admin-app/synnefo_admin/admin/resources/groups/utils.py +++ b/snf-admin-app/synnefo_admin/admin/resources/groups/utils.py @@ -12,4 +12,3 @@ # # You should have received a copy of the GNU General Public License # along with this program. If not, see . - diff --git a/snf-admin-app/synnefo_admin/admin/templatetags/admin_tags.py b/snf-admin-app/synnefo_admin/admin/templatetags/admin_tags.py index a0e0425e4..0d46b3404 100644 --- a/snf-admin-app/synnefo_admin/admin/templatetags/admin_tags.py +++ b/snf-admin-app/synnefo_admin/admin/templatetags/admin_tags.py @@ -150,9 +150,9 @@ def image_info(vm): # TODO: Add this code when deferred loading works. # Try to retrieve Image info using Plankton. - #try: + # try: # image_info = get_image(vm.imageid, vm.userid) - #except faults.ItemNotFound: + # except faults.ItemNotFound: # Check if Cyclades DB has any info about this Image. try: diff --git a/snf-admin-app/synnefo_admin/admin/tests/projects.py b/snf-admin-app/synnefo_admin/admin/tests/projects.py index 25b6a81bb..db5f10546 100644 --- a/snf-admin-app/synnefo_admin/admin/tests/projects.py +++ b/snf-admin-app/synnefo_admin/admin/tests/projects.py @@ -14,7 +14,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -#import logging +# import logging from astakos.im.models import Resource from synnefo_admin.admin.resources.projects.utils import get_project_quota_category diff --git a/snf-admin-app/synnefo_admin/admin/tests/users.py b/snf-admin-app/synnefo_admin/admin/tests/users.py index c9338dab7..04dcbca37 100644 --- a/snf-admin-app/synnefo_admin/admin/tests/users.py +++ b/snf-admin-app/synnefo_admin/admin/tests/users.py @@ -14,7 +14,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -#import logging +# import logging from django.core.urlresolvers import reverse from astakos.im.models import ProjectMembership, Resource diff --git a/snf-admin-app/synnefo_admin/admin/views.py b/snf-admin-app/synnefo_admin/admin/views.py index 57fc2a02e..e7fd53563 100644 --- a/snf-admin-app/synnefo_admin/admin/views.py +++ b/snf-admin-app/synnefo_admin/admin/views.py @@ -106,7 +106,7 @@ def get_token_from_cookie(request, cookiename): # Security functions ### -def admin_user_required(func, permitted_groups=admin_settings.\ +def admin_user_required(func, permitted_groups=admin_settings. ADMIN_PERMITTED_GROUPS): """ Django view wrapper that checks if identified request user has admin diff --git a/snf-admin-app/synnefo_admin/admin_settings.py b/snf-admin-app/synnefo_admin/admin_settings.py index 7658de486..01b716b93 100644 --- a/snf-admin-app/synnefo_admin/admin_settings.py +++ b/snf-admin-app/synnefo_admin/admin_settings.py @@ -48,7 +48,7 @@ 'ip_log': {'label': 'IP History'}, 'project': {'label': 'Projects'}, 'group': {'label': 'User Groups'}, - #'auth_provider': {'label': 'User Auth Providers'}, + # 'auth_provider': {'label': 'User Auth Providers'}, } # A list with the appropriate appearance order of the above views in the UI. DEFAULT_ADMIN_VIEWS_ORDER = ['user', 'vm', 'volume', 'network', 'ip', 'ip_log', From fa80446c6472204ff02cc42d4a0cf8e85f63f2a9 Mon Sep 17 00:00:00 2001 From: indorilftw Date: Wed, 12 Nov 2014 11:45:14 +0200 Subject: [PATCH 07/43] PEP8 fixes on snf-astakos-app/astakos/im/migrations directory --- ...add_projectmembership__add_unique_projec.py | 3 +-- .../0016_auth_providers_and_projects.py | 18 ++++++++---------- ...it__chg_field_astakosuserquota_capacity_.py | 7 +++---- ...date__chg_field_project_creation_date__c.py | 7 +++---- .../0019_clear_service_auth_token.py | 2 +- .../astakos/im/migrations/0020_auto.py | 7 +++---- .../0021_auto__chg_field_project_name.py | 7 +++---- ...t_id__chg_field_projectapplication_chain.py | 3 +-- ...ing__add_unique_usersetting_user_setting.py | 7 +++---- ...o__add_field_projectapplication_response.py | 7 +++---- ...0025_auto__add_authproviderpolicyprofile.py | 7 +++---- ...l_field_astakosuserquota_import_limit__d.py | 7 +++---- .../0027_rename_services_resources.py | 3 +-- ...to__add_field_resource_allow_in_projects.py | 7 +++---- ...hip_request_date__chg_field_projectmembe.py | 7 +++---- ...ovider__del_field_astakosuser_third_part.py | 7 +++---- .../im/migrations/0031_new_user_fields.py | 3 +-- .../0032_auto__add_field_service_type.py | 7 +++---- .../astakos/im/migrations/0033_service_type.py | 2 +- ...mponent__add_field_resource_service_type.py | 6 ++---- .../astakos/im/migrations/0035_components.py | 4 ++-- ..._del_service__del_field_resource_service.py | 7 +++---- ...ique_endpointdata_endpoint_key__add_serv.py | 7 +++---- .../astakos/im/migrations/0038_auth_tokens.py | 2 +- ...uth_token__add_unique_component_auth_tok.py | 7 +++---- ...th_token__chg_field_component_auth_token.py | 7 +++---- ..._auto__add_field_resource_service_origin.py | 7 +++---- .../im/migrations/0042_service_origin.py | 3 +-- .../migrations/0043_uninitialized_projects.py | 1 + ...tapplication_chain__chg_field_project_id.py | 15 +++++++-------- ...projectapplication_precursor_application.py | 15 +++++++-------- .../0046_auto__add_projectmembershiplog.py | 7 +++---- .../im/migrations/0047_membership_logs.py | 14 +++++++------- ...tory__del_field_projectmembership_reques.py | 7 +++---- ...d_projectapplication_response_actor__add.py | 7 +++---- .../astakos/im/migrations/0050_project_logs.py | 14 +++++++------- ...pproval_date__del_field_project_deactiva.py | 7 +++---- .../0052_auto__del_serial__add_projectlock.py | 7 +++---- .../0053_auto__add_field_component_base_url.py | 7 +++---- .../im/migrations/0054_reduce_bigint.py | 1 + ...it__chg_field_astakosuserquota_capacity_.py | 2 +- .../astakos/im/migrations/0056_user_quota.py | 5 +++-- ..._in_projects__add_field_resource_ui_visi.py | 2 -- .../im/migrations/0058_moderation_fix.py | 1 + .../astakos/im/migrations/0059_sign_terms.py | 1 + .../0061_auto__chg_field_astakosuser_uuid.py | 2 +- .../im/migrations/0062_accept_with_usage.py | 5 ++--- ...to__add_field_projectapplication_private.py | 4 +--- .../0064_auto__add_field_project_uuid.py | 4 +--- .../0066_auto__chg_field_project_uuid.py | 2 +- .../im/migrations/0067_set_project_capacity.py | 2 +- ...auto__add_field_resource_project_default.py | 7 +++---- .../0069_resource_project_defaults.py | 3 +-- ...ojectapplication_limit_on_members_number.py | 7 +++---- .../im/migrations/0071_inf_max_members.py | 3 +-- ...__add_unique_projectresourcequota_resour.py | 7 +++---- .../im/migrations/0073_project_fields.py | 9 ++++----- ...ation__chg_field_project_limit_on_member.py | 7 +++---- ...egrant_project_capacity__chg_field_proje.py | 7 +++---- ...base__add_field_astakosuser_base_project.py | 7 +++---- .../im/migrations/0077_base_projects.py | 2 +- ...auto__chg_field_astakosuser_base_project.py | 3 +-- ..._add_field_projectmembership_initialized.py | 7 +++---- .../migrations/0080_initialized_memberships.py | 2 +- ...ld_astakosuserauthprovider_last_login_at.py | 2 -- 65 files changed, 162 insertions(+), 211 deletions(-) diff --git a/snf-astakos-app/astakos/im/migrations/0015_auto__add_chain__add_project__add_projectmembership__add_unique_projec.py b/snf-astakos-app/astakos/im/migrations/0015_auto__add_chain__add_project__add_projectmembership__add_unique_projec.py index c113196f9..d3718c4ff 100644 --- a/snf-astakos-app/astakos/im/migrations/0015_auto__add_chain__add_project__add_projectmembership__add_unique_projec.py +++ b/snf-astakos-app/astakos/im/migrations/0015_auto__add_chain__add_project__add_projectmembership__add_unique_projec.py @@ -4,6 +4,7 @@ from south.v2 import SchemaMigration from django.db import models + class Migration(SchemaMigration): def forwards(self, orm): @@ -223,7 +224,6 @@ def forwards(self, orm): # Changin field 'auth_user.username' db.alter_column('auth_user', 'username', models.CharField(max_length=75)) - def backwards(self, orm): # Removing index on 'Service', fields ['name'] @@ -317,7 +317,6 @@ def backwards(self, orm): # Changin field 'auth_user.username' db.alter_column('auth_user', 'username', models.CharField(max_length=30)) - models = { 'auth.group': { 'Meta': {'object_name': 'Group'}, diff --git a/snf-astakos-app/astakos/im/migrations/0016_auth_providers_and_projects.py b/snf-astakos-app/astakos/im/migrations/0016_auth_providers_and_projects.py index 5f524a67a..337e43e76 100644 --- a/snf-astakos-app/astakos/im/migrations/0016_auth_providers_and_projects.py +++ b/snf-astakos-app/astakos/im/migrations/0016_auth_providers_and_projects.py @@ -9,6 +9,7 @@ from django.conf import settings + class Migration(DataMigration): def forwards(self, orm): @@ -21,7 +22,7 @@ def forwards(self, orm): user.save() while not user.uuid: - uuid_val = str(uuid.uuid4()) + uuid_val = str(uuid.uuid4()) try: orm.AstakosUser.objects.get(uuid=uuid_val) except orm.AstakosUser.DoesNotExist, e: @@ -55,16 +56,15 @@ def forwards(self, orm): if orm.AstakosUser.objects.filter(email__iexact=u.email).count() == 1: msg = ("You requested user with duplicate email %s and id (%d) to" - " be removed, but it seems that only one user exists with this" - " email in the database.") % (u.email , pk) + " be removed, but it seems that only one user exists with this" + " email in the database.") % (u.email, pk) raise Exception(msg) else: orm.AstakosUser.objects.filter(pk=int(pk)).delete() for u in orm.AstakosUser.objects.all(): if orm.AstakosUser.objects.filter(email__iexact=u.email).count() > 1: - existing = orm.AstakosUser.objects.filter( - email__iexact=u.email) + existing = orm.AstakosUser.objects.filter(email__iexact=u.email) print "Duplicate email found in database" for e in existing: print "%d: %s (is_active: %s)" % (e.pk, e.email, e.is_active) @@ -73,8 +73,8 @@ def forwards(self, orm): for e in existing.exclude(pk=int(keep)): e.delete() else: - raise Exception("Email %s is not unique %r. Please resolve conflicts and run migrate again." % (u.email, - existing)) + raise Exception("Email %s is not unique %r. Please resolve conflicts and run migrate again." % + (u.email, existing)) u = orm.AstakosUser.objects.get(email__iexact=u.email) save = False if not email_re.match(u.username): @@ -83,7 +83,6 @@ def forwards(self, orm): if save: u.save() - def backwards(self, orm): # set third_party_identifier for user in orm.AstakosUser.objects.all(): @@ -102,13 +101,12 @@ def backwards(self, orm): while not username: username_val = uuid.uuid4().hex[:30] try: - orm.AstakosUser.objects.get(username = username_val) + orm.AstakosUser.objects.get(username=username_val) except orm.AstakosUser.DoesNotExist, e: username = username_val u.username = username u.save() - models = { 'auth.group': { 'Meta': {'object_name': 'Group'}, diff --git a/snf-astakos-app/astakos/im/migrations/0017_auto__add_field_resource_uplimit__chg_field_astakosuserquota_capacity_.py b/snf-astakos-app/astakos/im/migrations/0017_auto__add_field_resource_uplimit__chg_field_astakosuserquota_capacity_.py index 32cd1cea6..4a8a6317b 100644 --- a/snf-astakos-app/astakos/im/migrations/0017_auto__add_field_resource_uplimit__chg_field_astakosuserquota_capacity_.py +++ b/snf-astakos-app/astakos/im/migrations/0017_auto__add_field_resource_uplimit__chg_field_astakosuserquota_capacity_.py @@ -4,10 +4,11 @@ from south.v2 import SchemaMigration from django.db import models + class Migration(SchemaMigration): def forwards(self, orm): - + # Adding field 'Resource.uplimit' db.add_column('im_resource', 'uplimit', self.gf('snf_django.lib.db.fields.IntDecimalField')(default=0, max_digits=38, decimal_places=0), keep_default=False) @@ -23,9 +24,8 @@ def forwards(self, orm): # Changing field 'AstakosUserQuota.quantity' db.alter_column('im_astakosuserquota', 'quantity', self.gf('snf_django.lib.db.fields.IntDecimalField')(max_digits=38, decimal_places=0)) - def backwards(self, orm): - + # Deleting field 'Resource.uplimit' db.delete_column('im_resource', 'uplimit') @@ -41,7 +41,6 @@ def backwards(self, orm): # Changing field 'AstakosUserQuota.quantity' db.alter_column('im_astakosuserquota', 'quantity', self.gf('django.db.models.fields.BigIntegerField')(null=True)) - models = { 'auth.group': { 'Meta': {'object_name': 'Group'}, diff --git a/snf-astakos-app/astakos/im/migrations/0018_auto__chg_field_approvalterms_date__chg_field_project_creation_date__c.py b/snf-astakos-app/astakos/im/migrations/0018_auto__chg_field_approvalterms_date__chg_field_project_creation_date__c.py index 64fb91a9d..e020d1a21 100644 --- a/snf-astakos-app/astakos/im/migrations/0018_auto__chg_field_approvalterms_date__chg_field_project_creation_date__c.py +++ b/snf-astakos-app/astakos/im/migrations/0018_auto__chg_field_approvalterms_date__chg_field_project_creation_date__c.py @@ -4,10 +4,11 @@ from south.v2 import SchemaMigration from django.db import models + class Migration(SchemaMigration): def forwards(self, orm): - + # Removing unique constraint on 'ProjectApplication', fields ['precursor_application'] db.delete_unique('im_projectapplication', ['precursor_application_id']) @@ -35,9 +36,8 @@ def forwards(self, orm): # Changing field 'ProjectApplication.precursor_application' db.alter_column('im_projectapplication', 'precursor_application_id', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['im.ProjectApplication'], null=True)) - def backwards(self, orm): - + # Changing field 'ApprovalTerms.date' db.alter_column('im_approvalterms', 'date', self.gf('django.db.models.fields.DateTimeField')()) @@ -65,7 +65,6 @@ def backwards(self, orm): # Adding unique constraint on 'ProjectApplication', fields ['precursor_application'] db.create_unique('im_projectapplication', ['precursor_application_id']) - models = { 'auth.group': { 'Meta': {'object_name': 'Group'}, diff --git a/snf-astakos-app/astakos/im/migrations/0019_clear_service_auth_token.py b/snf-astakos-app/astakos/im/migrations/0019_clear_service_auth_token.py index 2e0b341e4..54ec28e6a 100644 --- a/snf-astakos-app/astakos/im/migrations/0019_clear_service_auth_token.py +++ b/snf-astakos-app/astakos/im/migrations/0019_clear_service_auth_token.py @@ -4,6 +4,7 @@ from south.v2 import DataMigration from django.db import models + class Migration(DataMigration): def forwards(self, orm): @@ -16,7 +17,6 @@ def forwards(self, orm): def backwards(self, orm): "Write your backwards methods here." - models = { 'auth.group': { 'Meta': {'object_name': 'Group'}, diff --git a/snf-astakos-app/astakos/im/migrations/0020_auto.py b/snf-astakos-app/astakos/im/migrations/0020_auto.py index f0e0ea063..ea76adb8a 100644 --- a/snf-astakos-app/astakos/im/migrations/0020_auto.py +++ b/snf-astakos-app/astakos/im/migrations/0020_auto.py @@ -4,20 +4,19 @@ from south.v2 import SchemaMigration from django.db import models + class Migration(SchemaMigration): def forwards(self, orm): - + # Adding index on 'ProjectApplication', fields ['state'] db.create_index('im_projectapplication', ['state']) - def backwards(self, orm): - + # Removing index on 'ProjectApplication', fields ['state'] db.delete_index('im_projectapplication', ['state']) - models = { 'auth.group': { 'Meta': {'object_name': 'Group'}, diff --git a/snf-astakos-app/astakos/im/migrations/0021_auto__chg_field_project_name.py b/snf-astakos-app/astakos/im/migrations/0021_auto__chg_field_project_name.py index 807b39ef6..a37b77e7b 100644 --- a/snf-astakos-app/astakos/im/migrations/0021_auto__chg_field_project_name.py +++ b/snf-astakos-app/astakos/im/migrations/0021_auto__chg_field_project_name.py @@ -4,20 +4,19 @@ from south.v2 import SchemaMigration from django.db import models + class Migration(SchemaMigration): def forwards(self, orm): - + # Changing field 'Project.name' db.alter_column('im_project', 'name', self.gf('django.db.models.fields.CharField')(max_length=80, unique=True, null=True)) - def backwards(self, orm): - + # Changing field 'Project.name' db.alter_column('im_project', 'name', self.gf('django.db.models.fields.CharField')(default='', max_length=80, unique=True)) - models = { 'auth.group': { 'Meta': {'object_name': 'Group'}, diff --git a/snf-astakos-app/astakos/im/migrations/0022_auto__chg_field_project_id__chg_field_projectapplication_chain.py b/snf-astakos-app/astakos/im/migrations/0022_auto__chg_field_project_id__chg_field_projectapplication_chain.py index 03e4fbd20..4689d26b9 100644 --- a/snf-astakos-app/astakos/im/migrations/0022_auto__chg_field_project_id__chg_field_projectapplication_chain.py +++ b/snf-astakos-app/astakos/im/migrations/0022_auto__chg_field_project_id__chg_field_projectapplication_chain.py @@ -4,6 +4,7 @@ from south.v2 import SchemaMigration from django.db import models + class Migration(SchemaMigration): def forwards(self, orm): @@ -26,7 +27,6 @@ def forwards(self, orm): # Adding index on 'ProjectApplication', fields ['chain'] db.create_index('im_projectapplication', ['chain']) - def backwards(self, orm): # Removing index on 'ProjectApplication', fields ['chain'] @@ -41,7 +41,6 @@ def backwards(self, orm): # Changing field 'ProjectApplication.chain' db.alter_column('im_projectapplication', 'chain', self.gf('django.db.models.fields.IntegerField')()) - models = { 'auth.group': { 'Meta': {'object_name': 'Group'}, diff --git a/snf-astakos-app/astakos/im/migrations/0023_auto__add_usersetting__add_unique_usersetting_user_setting.py b/snf-astakos-app/astakos/im/migrations/0023_auto__add_usersetting__add_unique_usersetting_user_setting.py index b05054434..831a1813f 100644 --- a/snf-astakos-app/astakos/im/migrations/0023_auto__add_usersetting__add_unique_usersetting_user_setting.py +++ b/snf-astakos-app/astakos/im/migrations/0023_auto__add_usersetting__add_unique_usersetting_user_setting.py @@ -4,10 +4,11 @@ from south.v2 import SchemaMigration from django.db import models + class Migration(SchemaMigration): def forwards(self, orm): - + # Adding model 'UserSetting' db.create_table('im_usersetting', ( ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), @@ -20,16 +21,14 @@ def forwards(self, orm): # Adding unique constraint on 'UserSetting', fields ['user', 'setting'] db.create_unique('im_usersetting', ['user_id', 'setting']) - def backwards(self, orm): - + # Removing unique constraint on 'UserSetting', fields ['user', 'setting'] db.delete_unique('im_usersetting', ['user_id', 'setting']) # Deleting model 'UserSetting' db.delete_table('im_usersetting') - models = { 'auth.group': { 'Meta': {'object_name': 'Group'}, diff --git a/snf-astakos-app/astakos/im/migrations/0024_auto__add_field_projectapplication_response.py b/snf-astakos-app/astakos/im/migrations/0024_auto__add_field_projectapplication_response.py index 258b170ce..22a05ad96 100644 --- a/snf-astakos-app/astakos/im/migrations/0024_auto__add_field_projectapplication_response.py +++ b/snf-astakos-app/astakos/im/migrations/0024_auto__add_field_projectapplication_response.py @@ -4,20 +4,19 @@ from south.v2 import SchemaMigration from django.db import models + class Migration(SchemaMigration): def forwards(self, orm): - + # Adding field 'ProjectApplication.response' db.add_column('im_projectapplication', 'response', self.gf('django.db.models.fields.TextField')(null=True, blank=True), keep_default=False) - def backwards(self, orm): - + # Deleting field 'ProjectApplication.response' db.delete_column('im_projectapplication', 'response') - models = { 'auth.group': { 'Meta': {'object_name': 'Group'}, diff --git a/snf-astakos-app/astakos/im/migrations/0025_auto__add_authproviderpolicyprofile.py b/snf-astakos-app/astakos/im/migrations/0025_auto__add_authproviderpolicyprofile.py index 853b12e09..bd9f5e591 100644 --- a/snf-astakos-app/astakos/im/migrations/0025_auto__add_authproviderpolicyprofile.py +++ b/snf-astakos-app/astakos/im/migrations/0025_auto__add_authproviderpolicyprofile.py @@ -4,10 +4,11 @@ from south.v2 import SchemaMigration from django.db import models + class Migration(SchemaMigration): def forwards(self, orm): - + # Adding model 'AuthProviderPolicyProfile' db.create_table('im_authproviderpolicyprofile', ( ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), @@ -43,9 +44,8 @@ def forwards(self, orm): )) db.create_unique('im_authproviderpolicyprofile_users', ['authproviderpolicyprofile_id', 'astakosuser_id']) - def backwards(self, orm): - + # Deleting model 'AuthProviderPolicyProfile' db.delete_table('im_authproviderpolicyprofile') @@ -55,7 +55,6 @@ def backwards(self, orm): # Removing M2M table for field users on 'AuthProviderPolicyProfile' db.delete_table('im_authproviderpolicyprofile_users') - models = { 'auth.group': { 'Meta': {'object_name': 'Group'}, diff --git a/snf-astakos-app/astakos/im/migrations/0026_auto__del_resourcemetadata__del_field_astakosuserquota_import_limit__d.py b/snf-astakos-app/astakos/im/migrations/0026_auto__del_resourcemetadata__del_field_astakosuserquota_import_limit__d.py index 63c1fdad5..04db4a7d5 100644 --- a/snf-astakos-app/astakos/im/migrations/0026_auto__del_resourcemetadata__del_field_astakosuserquota_import_limit__d.py +++ b/snf-astakos-app/astakos/im/migrations/0026_auto__del_resourcemetadata__del_field_astakosuserquota_import_limit__d.py @@ -4,10 +4,11 @@ from south.v2 import SchemaMigration from django.db import models + class Migration(SchemaMigration): def forwards(self, orm): - + # Removing unique constraint on 'Resource', fields ['name', 'service'] db.delete_unique('im_resource', ['name', 'service_id']) @@ -80,9 +81,8 @@ def forwards(self, orm): # Changing field 'ProjectResourceGrant.project_capacity' db.alter_column('im_projectresourcegrant', 'project_capacity', self.gf('snf_django.lib.db.fields.IntDecimalField')(null=True, max_digits=38, decimal_places=0)) - def backwards(self, orm): - + # Removing unique constraint on 'Resource', fields ['name'] db.delete_unique('im_resource', ['name']) @@ -165,7 +165,6 @@ def backwards(self, orm): # Changing field 'ProjectResourceGrant.project_capacity' db.alter_column('im_projectresourcegrant', 'project_capacity', self.gf('snf_django.lib.db.fields.IntDecimalField')(max_digits=38, decimal_places=0)) - models = { 'auth.group': { 'Meta': {'object_name': 'Group'}, diff --git a/snf-astakos-app/astakos/im/migrations/0027_rename_services_resources.py b/snf-astakos-app/astakos/im/migrations/0027_rename_services_resources.py index 38c25fb1f..1e4b52b4e 100644 --- a/snf-astakos-app/astakos/im/migrations/0027_rename_services_resources.py +++ b/snf-astakos-app/astakos/im/migrations/0027_rename_services_resources.py @@ -4,6 +4,7 @@ from south.v2 import DataMigration from django.db import models + class Migration(DataMigration): def forwards(self, orm): @@ -28,7 +29,6 @@ def forwards(self, orm): resource.name = prefix + resource_name resource.save() - def backwards(self, orm): # Prefix resource names resources = orm.Resource.objects.all().select_related() @@ -51,7 +51,6 @@ def backwards(self, orm): s.name = 'pithos+' s.save() - models = { 'auth.group': { 'Meta': {'object_name': 'Group'}, diff --git a/snf-astakos-app/astakos/im/migrations/0028_auto__add_field_resource_allow_in_projects.py b/snf-astakos-app/astakos/im/migrations/0028_auto__add_field_resource_allow_in_projects.py index be8b3ef5a..055f2a797 100644 --- a/snf-astakos-app/astakos/im/migrations/0028_auto__add_field_resource_allow_in_projects.py +++ b/snf-astakos-app/astakos/im/migrations/0028_auto__add_field_resource_allow_in_projects.py @@ -4,20 +4,19 @@ from south.v2 import SchemaMigration from django.db import models + class Migration(SchemaMigration): def forwards(self, orm): - + # Adding field 'Resource.allow_in_projects' db.add_column('im_resource', 'allow_in_projects', self.gf('django.db.models.fields.BooleanField')(default=True), keep_default=False) - def backwards(self, orm): - + # Deleting field 'Resource.allow_in_projects' db.delete_column('im_resource', 'allow_in_projects') - models = { 'auth.group': { 'Meta': {'object_name': 'Group'}, diff --git a/snf-astakos-app/astakos/im/migrations/0029_auto__chg_field_projectmembership_request_date__chg_field_projectmembe.py b/snf-astakos-app/astakos/im/migrations/0029_auto__chg_field_projectmembership_request_date__chg_field_projectmembe.py index 289ee1ad4..50f1a799a 100644 --- a/snf-astakos-app/astakos/im/migrations/0029_auto__chg_field_projectmembership_request_date__chg_field_projectmembe.py +++ b/snf-astakos-app/astakos/im/migrations/0029_auto__chg_field_projectmembership_request_date__chg_field_projectmembe.py @@ -4,10 +4,11 @@ from south.v2 import SchemaMigration from django.db import models + class Migration(SchemaMigration): def forwards(self, orm): - + # Changing field 'ProjectMembership.request_date' db.alter_column('im_projectmembership', 'request_date', self.gf('django.db.models.fields.DateTimeField')(auto_now_add=True)) @@ -20,9 +21,8 @@ def forwards(self, orm): # Changing field 'ProjectMembershipHistory.date' db.alter_column('im_projectmembershiphistory', 'date', self.gf('django.db.models.fields.DateTimeField')(auto_now_add=True)) - def backwards(self, orm): - + # Changing field 'ProjectMembership.request_date' db.alter_column('im_projectmembership', 'request_date', self.gf('django.db.models.fields.DateField')(auto_now_add=True)) @@ -35,7 +35,6 @@ def backwards(self, orm): # Changing field 'ProjectMembershipHistory.date' db.alter_column('im_projectmembershiphistory', 'date', self.gf('django.db.models.fields.DateField')(auto_now_add=True)) - models = { 'auth.group': { 'Meta': {'object_name': 'Group'}, diff --git a/snf-astakos-app/astakos/im/migrations/0030_auto__del_field_astakosuser_provider__del_field_astakosuser_third_part.py b/snf-astakos-app/astakos/im/migrations/0030_auto__del_field_astakosuser_provider__del_field_astakosuser_third_part.py index 6e56577c7..be01d72d7 100644 --- a/snf-astakos-app/astakos/im/migrations/0030_auto__del_field_astakosuser_provider__del_field_astakosuser_third_part.py +++ b/snf-astakos-app/astakos/im/migrations/0030_auto__del_field_astakosuser_provider__del_field_astakosuser_third_part.py @@ -4,10 +4,11 @@ from south.v2 import SchemaMigration from django.db import models + class Migration(SchemaMigration): def forwards(self, orm): - + # Deleting field 'AstakosUser.provider' db.delete_column('im_astakosuser', 'provider') @@ -47,9 +48,8 @@ def forwards(self, orm): # Adding field 'AstakosUser.accepted_email' db.add_column('im_astakosuser', 'accepted_email', self.gf('django.db.models.fields.EmailField')(default=None, max_length=75, null=True, blank=True), keep_default=False) - def backwards(self, orm): - + # Adding field 'AstakosUser.provider' db.add_column('im_astakosuser', 'provider', self.gf('django.db.models.fields.CharField')(max_length=255, null=True, blank=True), keep_default=False) @@ -89,7 +89,6 @@ def backwards(self, orm): # Deleting field 'AstakosUser.accepted_email' db.delete_column('im_astakosuser', 'accepted_email') - models = { 'auth.group': { 'Meta': {'object_name': 'Group'}, diff --git a/snf-astakos-app/astakos/im/migrations/0031_new_user_fields.py b/snf-astakos-app/astakos/im/migrations/0031_new_user_fields.py index 1c375dfdd..f7d3b4c54 100644 --- a/snf-astakos-app/astakos/im/migrations/0031_new_user_fields.py +++ b/snf-astakos-app/astakos/im/migrations/0031_new_user_fields.py @@ -5,6 +5,7 @@ from south.v2 import DataMigration from django.db import models + class Migration(DataMigration): def forwards(self, orm): @@ -52,11 +53,9 @@ def forwards(self, orm): user.save() - def backwards(self, orm): "Write your backwards methods here." - models = { 'auth.group': { 'Meta': {'object_name': 'Group'}, diff --git a/snf-astakos-app/astakos/im/migrations/0032_auto__add_field_service_type.py b/snf-astakos-app/astakos/im/migrations/0032_auto__add_field_service_type.py index 49507a3d5..ab6901d29 100644 --- a/snf-astakos-app/astakos/im/migrations/0032_auto__add_field_service_type.py +++ b/snf-astakos-app/astakos/im/migrations/0032_auto__add_field_service_type.py @@ -4,20 +4,19 @@ from south.v2 import SchemaMigration from django.db import models + class Migration(SchemaMigration): def forwards(self, orm): - + # Adding field 'Service.type' db.add_column('im_service', 'type', self.gf('django.db.models.fields.CharField')(max_length=255, null=True, blank='True'), keep_default=False) - def backwards(self, orm): - + # Deleting field 'Service.type' db.delete_column('im_service', 'type') - models = { 'auth.group': { 'Meta': {'object_name': 'Group'}, diff --git a/snf-astakos-app/astakos/im/migrations/0033_service_type.py b/snf-astakos-app/astakos/im/migrations/0033_service_type.py index 158778ffc..6097fefe4 100644 --- a/snf-astakos-app/astakos/im/migrations/0033_service_type.py +++ b/snf-astakos-app/astakos/im/migrations/0033_service_type.py @@ -4,6 +4,7 @@ from south.v2 import DataMigration from django.db import models + class Migration(DataMigration): def forwards(self, orm): @@ -26,7 +27,6 @@ def forwards(self, orm): def backwards(self, orm): "Write your backwards methods here." - models = { 'auth.group': { 'Meta': {'object_name': 'Group'}, diff --git a/snf-astakos-app/astakos/im/migrations/0034_auto__add_component__add_field_resource_service_type.py b/snf-astakos-app/astakos/im/migrations/0034_auto__add_component__add_field_resource_service_type.py index 82f3bd0d3..6dd81eb0c 100644 --- a/snf-astakos-app/astakos/im/migrations/0034_auto__add_component__add_field_resource_service_type.py +++ b/snf-astakos-app/astakos/im/migrations/0034_auto__add_component__add_field_resource_service_type.py @@ -4,10 +4,10 @@ from south.v2 import SchemaMigration from django.db import models + class Migration(SchemaMigration): def forwards(self, orm): - # Adding model 'Component' db.create_table('im_component', ( ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), @@ -22,16 +22,14 @@ def forwards(self, orm): # Adding field 'Resource.service_type' db.add_column('im_resource', 'service_type', self.gf('django.db.models.fields.CharField')(default='', max_length=255), keep_default=False) - def backwards(self, orm): - + # Deleting model 'Component' db.delete_table('im_component') # Deleting field 'Resource.service_type' db.delete_column('im_resource', 'service_type') - models = { 'auth.group': { 'Meta': {'object_name': 'Group'}, diff --git a/snf-astakos-app/astakos/im/migrations/0035_components.py b/snf-astakos-app/astakos/im/migrations/0035_components.py index df825283a..9e2cedc1b 100644 --- a/snf-astakos-app/astakos/im/migrations/0035_components.py +++ b/snf-astakos-app/astakos/im/migrations/0035_components.py @@ -4,6 +4,7 @@ from south.v2 import DataMigration from django.db import models + class Migration(DataMigration): def forwards(self, orm): @@ -11,7 +12,7 @@ def forwards(self, orm): 'astakos': 'account', # astakos.pending_app is account-related 'cyclades': 'compute', 'pithos': 'object-store', - } + } services = orm.Service.objects.all() for service in services: @@ -31,7 +32,6 @@ def forwards(self, orm): def backwards(self, orm): "Write your backwards methods here." - models = { 'auth.group': { 'Meta': {'object_name': 'Group'}, diff --git a/snf-astakos-app/astakos/im/migrations/0036_auto__del_service__del_field_resource_service.py b/snf-astakos-app/astakos/im/migrations/0036_auto__del_service__del_field_resource_service.py index 3ef90b32f..c7224eeaf 100644 --- a/snf-astakos-app/astakos/im/migrations/0036_auto__del_service__del_field_resource_service.py +++ b/snf-astakos-app/astakos/im/migrations/0036_auto__del_service__del_field_resource_service.py @@ -4,19 +4,19 @@ from south.v2 import SchemaMigration from django.db import models + class Migration(SchemaMigration): def forwards(self, orm): - + # Deleting model 'Service' db.delete_table('im_service') # Deleting field 'Resource.service' db.delete_column('im_resource', 'service_id') - def backwards(self, orm): - + # Adding model 'Service' db.create_table('im_service', ( ('api_url', self.gf('django.db.models.fields.CharField')(max_length=255, null=True)), @@ -33,7 +33,6 @@ def backwards(self, orm): # User chose to not deal with backwards NULL issues for 'Resource.service' raise RuntimeError("Cannot reverse this migration. 'Resource.service' and its values cannot be restored.") - models = { 'auth.group': { 'Meta': {'object_name': 'Group'}, diff --git a/snf-astakos-app/astakos/im/migrations/0037_auto__add_endpointdata__add_unique_endpointdata_endpoint_key__add_serv.py b/snf-astakos-app/astakos/im/migrations/0037_auto__add_endpointdata__add_unique_endpointdata_endpoint_key__add_serv.py index 25e7a1203..9e84d514b 100644 --- a/snf-astakos-app/astakos/im/migrations/0037_auto__add_endpointdata__add_unique_endpointdata_endpoint_key__add_serv.py +++ b/snf-astakos-app/astakos/im/migrations/0037_auto__add_endpointdata__add_unique_endpointdata_endpoint_key__add_serv.py @@ -4,10 +4,11 @@ from south.v2 import SchemaMigration from django.db import models + class Migration(SchemaMigration): def forwards(self, orm): - + # Adding model 'EndpointData' db.create_table('im_endpointdata', ( ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), @@ -36,9 +37,8 @@ def forwards(self, orm): )) db.send_create_signal('im', ['Endpoint']) - def backwards(self, orm): - + # Removing unique constraint on 'EndpointData', fields ['endpoint', 'key'] db.delete_unique('im_endpointdata', ['endpoint_id', 'key']) @@ -51,7 +51,6 @@ def backwards(self, orm): # Deleting model 'Endpoint' db.delete_table('im_endpoint') - models = { 'auth.group': { 'Meta': {'object_name': 'Group'}, diff --git a/snf-astakos-app/astakos/im/migrations/0038_auth_tokens.py b/snf-astakos-app/astakos/im/migrations/0038_auth_tokens.py index 6ffda84c1..b717530d1 100644 --- a/snf-astakos-app/astakos/im/migrations/0038_auth_tokens.py +++ b/snf-astakos-app/astakos/im/migrations/0038_auth_tokens.py @@ -4,6 +4,7 @@ from south.v2 import DataMigration from django.db import models + class Migration(DataMigration): def forwards(self, orm): @@ -32,7 +33,6 @@ def forwards(self, orm): def backwards(self, orm): "Write your backwards methods here." - models = { 'auth.group': { 'Meta': {'object_name': 'Group'}, diff --git a/snf-astakos-app/astakos/im/migrations/0039_auto__add_unique_astakosuser_auth_token__add_unique_component_auth_tok.py b/snf-astakos-app/astakos/im/migrations/0039_auto__add_unique_astakosuser_auth_token__add_unique_component_auth_tok.py index d7defb685..ad39d417a 100644 --- a/snf-astakos-app/astakos/im/migrations/0039_auto__add_unique_astakosuser_auth_token__add_unique_component_auth_tok.py +++ b/snf-astakos-app/astakos/im/migrations/0039_auto__add_unique_astakosuser_auth_token__add_unique_component_auth_tok.py @@ -4,26 +4,25 @@ from south.v2 import SchemaMigration from django.db import models + class Migration(SchemaMigration): def forwards(self, orm): - + # Adding unique constraint on 'AstakosUser', fields ['auth_token'] db.create_unique('im_astakosuser', ['auth_token']) # Adding unique constraint on 'Component', fields ['auth_token'] db.create_unique('im_component', ['auth_token']) - def backwards(self, orm): - + # Removing unique constraint on 'Component', fields ['auth_token'] db.delete_unique('im_component', ['auth_token']) # Removing unique constraint on 'AstakosUser', fields ['auth_token'] db.delete_unique('im_astakosuser', ['auth_token']) - models = { 'auth.group': { 'Meta': {'object_name': 'Group'}, diff --git a/snf-astakos-app/astakos/im/migrations/0040_auto__chg_field_astakosuser_auth_token__chg_field_component_auth_token.py b/snf-astakos-app/astakos/im/migrations/0040_auto__chg_field_astakosuser_auth_token__chg_field_component_auth_token.py index 746f93944..922360a4f 100644 --- a/snf-astakos-app/astakos/im/migrations/0040_auto__chg_field_astakosuser_auth_token__chg_field_component_auth_token.py +++ b/snf-astakos-app/astakos/im/migrations/0040_auto__chg_field_astakosuser_auth_token__chg_field_component_auth_token.py @@ -4,26 +4,25 @@ from south.v2 import SchemaMigration from django.db import models + class Migration(SchemaMigration): def forwards(self, orm): - + # Changing field 'AstakosUser.auth_token' db.alter_column('im_astakosuser', 'auth_token', self.gf('django.db.models.fields.CharField')(max_length=64, unique=True, null=True)) # Changing field 'Component.auth_token' db.alter_column('im_component', 'auth_token', self.gf('django.db.models.fields.CharField')(max_length=64, unique=True, null=True)) - def backwards(self, orm): - + # Changing field 'AstakosUser.auth_token' db.alter_column('im_astakosuser', 'auth_token', self.gf('django.db.models.fields.CharField')(unique=True, max_length=32, null=True)) # Changing field 'Component.auth_token' db.alter_column('im_component', 'auth_token', self.gf('django.db.models.fields.CharField')(unique=True, max_length=32, null=True)) - models = { 'auth.group': { 'Meta': {'object_name': 'Group'}, diff --git a/snf-astakos-app/astakos/im/migrations/0041_auto__add_field_resource_service_origin.py b/snf-astakos-app/astakos/im/migrations/0041_auto__add_field_resource_service_origin.py index 028c8f43f..8c91c44d3 100644 --- a/snf-astakos-app/astakos/im/migrations/0041_auto__add_field_resource_service_origin.py +++ b/snf-astakos-app/astakos/im/migrations/0041_auto__add_field_resource_service_origin.py @@ -4,20 +4,19 @@ from south.v2 import SchemaMigration from django.db import models + class Migration(SchemaMigration): def forwards(self, orm): - + # Adding field 'Resource.service_origin' db.add_column('im_resource', 'service_origin', self.gf('django.db.models.fields.CharField')(default='', max_length=255, db_index=True), keep_default=False) - def backwards(self, orm): - + # Deleting field 'Resource.service_origin' db.delete_column('im_resource', 'service_origin') - models = { 'auth.group': { 'Meta': {'object_name': 'Group'}, diff --git a/snf-astakos-app/astakos/im/migrations/0042_service_origin.py b/snf-astakos-app/astakos/im/migrations/0042_service_origin.py index 3f1c73419..698fc85ca 100644 --- a/snf-astakos-app/astakos/im/migrations/0042_service_origin.py +++ b/snf-astakos-app/astakos/im/migrations/0042_service_origin.py @@ -4,6 +4,7 @@ from south.v2 import DataMigration from django.db import models + class Migration(DataMigration): def forwards(self, orm): @@ -18,11 +19,9 @@ def forwards(self, orm): resource.service_origin = service_origin resource.save() - def backwards(self, orm): "Write your backwards methods here." - models = { 'auth.group': { 'Meta': {'object_name': 'Group'}, diff --git a/snf-astakos-app/astakos/im/migrations/0043_uninitialized_projects.py b/snf-astakos-app/astakos/im/migrations/0043_uninitialized_projects.py index 21eb098bd..09142d58a 100644 --- a/snf-astakos-app/astakos/im/migrations/0043_uninitialized_projects.py +++ b/snf-astakos-app/astakos/im/migrations/0043_uninitialized_projects.py @@ -4,6 +4,7 @@ from south.v2 import DataMigration from django.db import models + class Migration(DataMigration): def forwards(self, orm): diff --git a/snf-astakos-app/astakos/im/migrations/0044_auto__chg_field_projectapplication_chain__chg_field_project_id.py b/snf-astakos-app/astakos/im/migrations/0044_auto__chg_field_projectapplication_chain__chg_field_project_id.py index ba9affc7b..6bd0f92e9 100644 --- a/snf-astakos-app/astakos/im/migrations/0044_auto__chg_field_projectapplication_chain__chg_field_project_id.py +++ b/snf-astakos-app/astakos/im/migrations/0044_auto__chg_field_projectapplication_chain__chg_field_project_id.py @@ -4,10 +4,11 @@ from south.v2 import SchemaMigration from django.db import models + class Migration(SchemaMigration): - + def forwards(self, orm): - + # Changing field 'ProjectApplication.chain' db.alter_column('im_projectapplication', 'chain', self.gf('django.db.models.fields.related.ForeignKey')(db_column='chain', to=orm['im.Project'])) @@ -17,10 +18,9 @@ def forwards(self, orm): if db.backend_name != 'sqlite3': # Removing index on 'Project', fields ['id'] db.delete_index('im_project', ['id']) - - + def backwards(self, orm): - + # Changing field 'ProjectApplication.chain' db.alter_column('im_projectapplication', 'chain', self.gf('django.db.models.fields.related.ForeignKey')(db_column='chain', to=orm['im.Chain'])) @@ -29,8 +29,7 @@ def backwards(self, orm): # Adding index on 'Project', fields ['id'] db.create_index('im_project', ['id']) - - + models = { 'auth.group': { 'Meta': {'object_name': 'Group'}, @@ -304,5 +303,5 @@ def backwards(self, orm): 'value': ('django.db.models.fields.IntegerField', [], {}) } } - + complete_apps = ['im'] diff --git a/snf-astakos-app/astakos/im/migrations/0045_auto__del_field_projectapplication_precursor_application.py b/snf-astakos-app/astakos/im/migrations/0045_auto__del_field_projectapplication_precursor_application.py index 380967d06..5a09d5447 100644 --- a/snf-astakos-app/astakos/im/migrations/0045_auto__del_field_projectapplication_precursor_application.py +++ b/snf-astakos-app/astakos/im/migrations/0045_auto__del_field_projectapplication_precursor_application.py @@ -4,20 +4,19 @@ from south.v2 import SchemaMigration from django.db import models + class Migration(SchemaMigration): - + def forwards(self, orm): - + # Deleting field 'ProjectApplication.precursor_application' db.delete_column('im_projectapplication', 'precursor_application_id') - - + def backwards(self, orm): - + # Adding field 'ProjectApplication.precursor_application' db.add_column('im_projectapplication', 'precursor_application', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['im.ProjectApplication'], null=True, blank=True), keep_default=False) - - + models = { 'auth.group': { 'Meta': {'object_name': 'Group'}, @@ -290,5 +289,5 @@ def backwards(self, orm): 'value': ('django.db.models.fields.IntegerField', [], {}) } } - + complete_apps = ['im'] diff --git a/snf-astakos-app/astakos/im/migrations/0046_auto__add_projectmembershiplog.py b/snf-astakos-app/astakos/im/migrations/0046_auto__add_projectmembershiplog.py index af6abb4b6..3fcffdfea 100644 --- a/snf-astakos-app/astakos/im/migrations/0046_auto__add_projectmembershiplog.py +++ b/snf-astakos-app/astakos/im/migrations/0046_auto__add_projectmembershiplog.py @@ -4,10 +4,11 @@ from south.v2 import SchemaMigration from django.db import models + class Migration(SchemaMigration): def forwards(self, orm): - + # Adding model 'ProjectMembershipLog' db.create_table('im_projectmembershiplog', ( ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), @@ -21,13 +22,11 @@ def forwards(self, orm): )) db.send_create_signal('im', ['ProjectMembershipLog']) - def backwards(self, orm): - + # Deleting model 'ProjectMembershipLog' db.delete_table('im_projectmembershiplog') - models = { 'auth.group': { 'Meta': {'object_name': 'Group'}, diff --git a/snf-astakos-app/astakos/im/migrations/0047_membership_logs.py b/snf-astakos-app/astakos/im/migrations/0047_membership_logs.py index 3945093c6..455ad7504 100644 --- a/snf-astakos-app/astakos/im/migrations/0047_membership_logs.py +++ b/snf-astakos-app/astakos/im/migrations/0047_membership_logs.py @@ -4,6 +4,7 @@ from south.v2 import DataMigration from django.db import models + def _partition_by(f, l): d = {} for x in l: @@ -53,13 +54,13 @@ def forwards(self, orm): logs = [] for m in memberships: logs.append(orm.ProjectMembershipLog( - membership=m, date=m.request_date, - from_state=None, to_state=REQUESTED)) + membership=m, date=m.request_date, + from_state=None, to_state=REQUESTED)) if m.leave_request_date: logs.append(orm.ProjectMembershipLog( - membership=m, date=m.leave_request_date, - from_state=ACCEPTED, to_state=LEAVE_REQUESTED)) + membership=m, date=m.leave_request_date, + from_state=ACCEPTED, to_state=LEAVE_REQUESTED)) orm.ProjectMembershipLog.objects.bulk_create(logs) @@ -91,15 +92,14 @@ def forwards(self, orm): to_state = H2S[mh.reason] from_state = ASSUMED_PRED[to_state] logs.append(orm.ProjectMembershipLog( - membership=m, date=mh.date, - from_state=from_state, to_state=to_state)) + membership=m, date=mh.date, + from_state=from_state, to_state=to_state)) orm.ProjectMembershipLog.objects.bulk_create(logs) def backwards(self, orm): "Write your backwards methods here." - models = { 'auth.group': { 'Meta': {'object_name': 'Group'}, diff --git a/snf-astakos-app/astakos/im/migrations/0048_auto__del_projectmembershiphistory__del_field_projectmembership_reques.py b/snf-astakos-app/astakos/im/migrations/0048_auto__del_projectmembershiphistory__del_field_projectmembership_reques.py index cadbd6777..7513313d6 100644 --- a/snf-astakos-app/astakos/im/migrations/0048_auto__del_projectmembershiphistory__del_field_projectmembership_reques.py +++ b/snf-astakos-app/astakos/im/migrations/0048_auto__del_projectmembershiphistory__del_field_projectmembership_reques.py @@ -4,10 +4,11 @@ from south.v2 import SchemaMigration from django.db import models + class Migration(SchemaMigration): def forwards(self, orm): - + # Deleting model 'ProjectMembershipHistory' db.delete_table('im_projectmembershiphistory') @@ -20,9 +21,8 @@ def forwards(self, orm): # Deleting field 'ProjectMembership.acceptance_date' db.delete_column('im_projectmembership', 'acceptance_date') - def backwards(self, orm): - + # Adding model 'ProjectMembershipHistory' db.create_table('im_projectmembershiphistory', ( ('project', self.gf('django.db.models.fields.BigIntegerField')()), @@ -43,7 +43,6 @@ def backwards(self, orm): # Adding field 'ProjectMembership.acceptance_date' db.add_column('im_projectmembership', 'acceptance_date', self.gf('django.db.models.fields.DateTimeField')(null=True, db_index=True), keep_default=False) - models = { 'auth.group': { 'Meta': {'object_name': 'Group'}, diff --git a/snf-astakos-app/astakos/im/migrations/0049_auto__add_projectlog__add_field_projectapplication_response_actor__add.py b/snf-astakos-app/astakos/im/migrations/0049_auto__add_projectlog__add_field_projectapplication_response_actor__add.py index c769741dc..53580897c 100644 --- a/snf-astakos-app/astakos/im/migrations/0049_auto__add_projectlog__add_field_projectapplication_response_actor__add.py +++ b/snf-astakos-app/astakos/im/migrations/0049_auto__add_projectlog__add_field_projectapplication_response_actor__add.py @@ -4,10 +4,11 @@ from south.v2 import SchemaMigration from django.db import models + class Migration(SchemaMigration): def forwards(self, orm): - + # Adding model 'ProjectLog' db.create_table('im_projectlog', ( ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), @@ -33,9 +34,8 @@ def forwards(self, orm): # Adding field 'ProjectApplication.waive_actor' db.add_column('im_projectapplication', 'waive_actor', self.gf('django.db.models.fields.related.ForeignKey')(related_name='waived_apps', null=True, to=orm['im.AstakosUser']), keep_default=False) - def backwards(self, orm): - + # Deleting model 'ProjectLog' db.delete_table('im_projectlog') @@ -51,7 +51,6 @@ def backwards(self, orm): # Deleting field 'ProjectApplication.waive_actor' db.delete_column('im_projectapplication', 'waive_actor_id') - models = { 'auth.group': { 'Meta': {'object_name': 'Group'}, diff --git a/snf-astakos-app/astakos/im/migrations/0050_project_logs.py b/snf-astakos-app/astakos/im/migrations/0050_project_logs.py index 05f56072b..4c636ec10 100644 --- a/snf-astakos-app/astakos/im/migrations/0050_project_logs.py +++ b/snf-astakos-app/astakos/im/migrations/0050_project_logs.py @@ -8,6 +8,7 @@ SUSPENDED = 10 TERMINATED = 100 + class Migration(DataMigration): def forwards(self, orm): @@ -16,23 +17,22 @@ def forwards(self, orm): suspended = orm.Project.objects.filter(state=SUSPENDED) for project in suspended: logs.append(orm.ProjectLog( - project=project, date=project.deactivation_date, - reason=project.deactivation_reason, - from_state=NORMAL, to_state=SUSPENDED)) + project=project, date=project.deactivation_date, + reason=project.deactivation_reason, + from_state=NORMAL, to_state=SUSPENDED)) terminated = orm.Project.objects.filter(state=TERMINATED) for project in terminated: logs.append(orm.ProjectLog( - project=project, date=project.deactivation_date, - reason=project.deactivation_reason, - from_state=NORMAL, to_state=TERMINATED)) + project=project, date=project.deactivation_date, + reason=project.deactivation_reason, + from_state=NORMAL, to_state=TERMINATED)) orm.ProjectLog.objects.bulk_create(logs) def backwards(self, orm): "Write your backwards methods here." - models = { 'auth.group': { 'Meta': {'object_name': 'Group'}, diff --git a/snf-astakos-app/astakos/im/migrations/0051_auto__del_field_project_last_approval_date__del_field_project_deactiva.py b/snf-astakos-app/astakos/im/migrations/0051_auto__del_field_project_last_approval_date__del_field_project_deactiva.py index de67cc9fa..e78a61744 100644 --- a/snf-astakos-app/astakos/im/migrations/0051_auto__del_field_project_last_approval_date__del_field_project_deactiva.py +++ b/snf-astakos-app/astakos/im/migrations/0051_auto__del_field_project_last_approval_date__del_field_project_deactiva.py @@ -4,10 +4,11 @@ from south.v2 import SchemaMigration from django.db import models + class Migration(SchemaMigration): def forwards(self, orm): - + # Deleting field 'Project.last_approval_date' db.delete_column('im_project', 'last_approval_date') @@ -17,9 +18,8 @@ def forwards(self, orm): # Deleting field 'Project.deactivation_reason' db.delete_column('im_project', 'deactivation_reason') - def backwards(self, orm): - + # Adding field 'Project.last_approval_date' db.add_column('im_project', 'last_approval_date', self.gf('django.db.models.fields.DateTimeField')(null=True), keep_default=False) @@ -29,7 +29,6 @@ def backwards(self, orm): # Adding field 'Project.deactivation_reason' db.add_column('im_project', 'deactivation_reason', self.gf('django.db.models.fields.CharField')(max_length=255, null=True), keep_default=False) - models = { 'auth.group': { 'Meta': {'object_name': 'Group'}, diff --git a/snf-astakos-app/astakos/im/migrations/0052_auto__del_serial__add_projectlock.py b/snf-astakos-app/astakos/im/migrations/0052_auto__del_serial__add_projectlock.py index 6d1752413..6e6bed68e 100644 --- a/snf-astakos-app/astakos/im/migrations/0052_auto__del_serial__add_projectlock.py +++ b/snf-astakos-app/astakos/im/migrations/0052_auto__del_serial__add_projectlock.py @@ -4,10 +4,11 @@ from south.v2 import SchemaMigration from django.db import models + class Migration(SchemaMigration): def forwards(self, orm): - + # Deleting model 'Serial' db.delete_table('im_serial') @@ -17,9 +18,8 @@ def forwards(self, orm): )) db.send_create_signal('im', ['ProjectLock']) - def backwards(self, orm): - + # Adding model 'Serial' db.create_table('im_serial', ( ('serial', self.gf('django.db.models.fields.AutoField')(primary_key=True)), @@ -29,7 +29,6 @@ def backwards(self, orm): # Deleting model 'ProjectLock' db.delete_table('im_projectlock') - models = { 'auth.group': { 'Meta': {'object_name': 'Group'}, diff --git a/snf-astakos-app/astakos/im/migrations/0053_auto__add_field_component_base_url.py b/snf-astakos-app/astakos/im/migrations/0053_auto__add_field_component_base_url.py index 363eda60e..b1dd45b9a 100644 --- a/snf-astakos-app/astakos/im/migrations/0053_auto__add_field_component_base_url.py +++ b/snf-astakos-app/astakos/im/migrations/0053_auto__add_field_component_base_url.py @@ -4,20 +4,19 @@ from south.v2 import SchemaMigration from django.db import models + class Migration(SchemaMigration): def forwards(self, orm): - + # Adding field 'Component.base_url' db.add_column('im_component', 'base_url', self.gf('django.db.models.fields.CharField')(max_length=1024, null=True), keep_default=False) - def backwards(self, orm): - + # Deleting field 'Component.base_url' db.delete_column('im_component', 'base_url') - models = { 'auth.group': { 'Meta': {'object_name': 'Group'}, diff --git a/snf-astakos-app/astakos/im/migrations/0054_reduce_bigint.py b/snf-astakos-app/astakos/im/migrations/0054_reduce_bigint.py index b0d880fd2..51d3b8b9b 100644 --- a/snf-astakos-app/astakos/im/migrations/0054_reduce_bigint.py +++ b/snf-astakos-app/astakos/im/migrations/0054_reduce_bigint.py @@ -6,6 +6,7 @@ MAX = 2**63 - 1 + class Migration(DataMigration): def forwards(self, orm): diff --git a/snf-astakos-app/astakos/im/migrations/0055_auto__chg_field_resource_uplimit__chg_field_astakosuserquota_capacity_.py b/snf-astakos-app/astakos/im/migrations/0055_auto__chg_field_resource_uplimit__chg_field_astakosuserquota_capacity_.py index bfaca487b..f6f122269 100644 --- a/snf-astakos-app/astakos/im/migrations/0055_auto__chg_field_resource_uplimit__chg_field_astakosuserquota_capacity_.py +++ b/snf-astakos-app/astakos/im/migrations/0055_auto__chg_field_resource_uplimit__chg_field_astakosuserquota_capacity_.py @@ -320,4 +320,4 @@ def backwards(self, orm): } } - complete_apps = ['im'] \ No newline at end of file + complete_apps = ['im'] diff --git a/snf-astakos-app/astakos/im/migrations/0056_user_quota.py b/snf-astakos-app/astakos/im/migrations/0056_user_quota.py index 133da3c88..e3ae34d70 100644 --- a/snf-astakos-app/astakos/im/migrations/0056_user_quota.py +++ b/snf-astakos-app/astakos/im/migrations/0056_user_quota.py @@ -4,11 +4,12 @@ from south.v2 import DataMigration from django.db import models + class Migration(DataMigration): def forwards(self, orm): - custom = set(orm.AstakosUserQuota.objects.all().\ - values_list("user__uuid", "resource__name")) + custom = set(orm.AstakosUserQuota.objects.all(). + values_list("user__uuid", "resource__name")) users = orm.AstakosUser.objects.filter( moderated=True, is_rejected=False) diff --git a/snf-astakos-app/astakos/im/migrations/0057_auto__del_field_resource_allow_in_projects__add_field_resource_ui_visi.py b/snf-astakos-app/astakos/im/migrations/0057_auto__del_field_resource_allow_in_projects__add_field_resource_ui_visi.py index 524919445..d120d3a5f 100644 --- a/snf-astakos-app/astakos/im/migrations/0057_auto__del_field_resource_allow_in_projects__add_field_resource_ui_visi.py +++ b/snf-astakos-app/astakos/im/migrations/0057_auto__del_field_resource_allow_in_projects__add_field_resource_ui_visi.py @@ -15,14 +15,12 @@ def forwards(self, orm): self.gf('django.db.models.fields.BooleanField')(default=True), keep_default=False) - def backwards(self, orm): db.rename_column('im_resource', 'ui_visible', 'allow_in_projects') # Deleting field 'Resource.api_visible' db.delete_column('im_resource', 'api_visible') - models = { 'auth.group': { 'Meta': {'object_name': 'Group'}, diff --git a/snf-astakos-app/astakos/im/migrations/0058_moderation_fix.py b/snf-astakos-app/astakos/im/migrations/0058_moderation_fix.py index ef0f6982b..f7d38b359 100644 --- a/snf-astakos-app/astakos/im/migrations/0058_moderation_fix.py +++ b/snf-astakos-app/astakos/im/migrations/0058_moderation_fix.py @@ -4,6 +4,7 @@ from south.v2 import DataMigration from django.db import models + class Migration(DataMigration): def forwards(self, orm): diff --git a/snf-astakos-app/astakos/im/migrations/0059_sign_terms.py b/snf-astakos-app/astakos/im/migrations/0059_sign_terms.py index 521bf7d91..52accd0a3 100644 --- a/snf-astakos-app/astakos/im/migrations/0059_sign_terms.py +++ b/snf-astakos-app/astakos/im/migrations/0059_sign_terms.py @@ -4,6 +4,7 @@ from south.v2 import DataMigration from django.db import models + class Migration(DataMigration): def forwards(self, orm): diff --git a/snf-astakos-app/astakos/im/migrations/0061_auto__chg_field_astakosuser_uuid.py b/snf-astakos-app/astakos/im/migrations/0061_auto__chg_field_astakosuser_uuid.py index 4bc10e108..098f98607 100644 --- a/snf-astakos-app/astakos/im/migrations/0061_auto__chg_field_astakosuser_uuid.py +++ b/snf-astakos-app/astakos/im/migrations/0061_auto__chg_field_astakosuser_uuid.py @@ -303,4 +303,4 @@ def backwards(self, orm): } } - complete_apps = ['im'] \ No newline at end of file + complete_apps = ['im'] diff --git a/snf-astakos-app/astakos/im/migrations/0062_accept_with_usage.py b/snf-astakos-app/astakos/im/migrations/0062_accept_with_usage.py index 79a7d3705..9e35f96c3 100644 --- a/snf-astakos-app/astakos/im/migrations/0062_accept_with_usage.py +++ b/snf-astakos-app/astakos/im/migrations/0062_accept_with_usage.py @@ -4,11 +4,10 @@ from south.v2 import DataMigration from django.db import models + class Migration(DataMigration): - depends_on = ( - ("quotaholder_app", "0010_non_accepted.py"), - ) + depends_on = (("quotaholder_app", "0010_non_accepted.py"),) def forwards(self, orm): Holding = orm["quotaholder_app.holding"] diff --git a/snf-astakos-app/astakos/im/migrations/0063_auto__add_field_projectapplication_private.py b/snf-astakos-app/astakos/im/migrations/0063_auto__add_field_projectapplication_private.py index 4fe8d705a..853ae2116 100644 --- a/snf-astakos-app/astakos/im/migrations/0063_auto__add_field_projectapplication_private.py +++ b/snf-astakos-app/astakos/im/migrations/0063_auto__add_field_projectapplication_private.py @@ -13,12 +13,10 @@ def forwards(self, orm): self.gf('django.db.models.fields.BooleanField')(default=False), keep_default=False) - def backwards(self, orm): # Deleting field 'ProjectApplication.private' db.delete_column('im_projectapplication', 'private') - models = { 'auth.group': { 'Meta': {'object_name': 'Group'}, @@ -306,4 +304,4 @@ def backwards(self, orm): } } - complete_apps = ['im'] \ No newline at end of file + complete_apps = ['im'] diff --git a/snf-astakos-app/astakos/im/migrations/0064_auto__add_field_project_uuid.py b/snf-astakos-app/astakos/im/migrations/0064_auto__add_field_project_uuid.py index 40b760740..a70508e7f 100644 --- a/snf-astakos-app/astakos/im/migrations/0064_auto__add_field_project_uuid.py +++ b/snf-astakos-app/astakos/im/migrations/0064_auto__add_field_project_uuid.py @@ -13,12 +13,10 @@ def forwards(self, orm): self.gf('django.db.models.fields.CharField')(max_length=255, unique=True, null=True), keep_default=False) - def backwards(self, orm): # Deleting field 'Project.uuid' db.delete_column('im_project', 'uuid') - models = { 'auth.group': { 'Meta': {'object_name': 'Group'}, @@ -307,4 +305,4 @@ def backwards(self, orm): } } - complete_apps = ['im'] \ No newline at end of file + complete_apps = ['im'] diff --git a/snf-astakos-app/astakos/im/migrations/0066_auto__chg_field_project_uuid.py b/snf-astakos-app/astakos/im/migrations/0066_auto__chg_field_project_uuid.py index 1373cfbf0..77fa5e74b 100644 --- a/snf-astakos-app/astakos/im/migrations/0066_auto__chg_field_project_uuid.py +++ b/snf-astakos-app/astakos/im/migrations/0066_auto__chg_field_project_uuid.py @@ -305,4 +305,4 @@ def backwards(self, orm): } } - complete_apps = ['im'] \ No newline at end of file + complete_apps = ['im'] diff --git a/snf-astakos-app/astakos/im/migrations/0067_set_project_capacity.py b/snf-astakos-app/astakos/im/migrations/0067_set_project_capacity.py index 3f4732d80..216b3c20f 100644 --- a/snf-astakos-app/astakos/im/migrations/0067_set_project_capacity.py +++ b/snf-astakos-app/astakos/im/migrations/0067_set_project_capacity.py @@ -6,7 +6,7 @@ APPROVED = 1 ACTUALLY_ACCEPTED = [1, 5] -MAX = 2**63 - 1 +MAX = 2 ** 63 - 1 class Migration(DataMigration): diff --git a/snf-astakos-app/astakos/im/migrations/0068_auto__add_field_resource_project_default.py b/snf-astakos-app/astakos/im/migrations/0068_auto__add_field_resource_project_default.py index fcdb6a79c..566267607 100644 --- a/snf-astakos-app/astakos/im/migrations/0068_auto__add_field_resource_project_default.py +++ b/snf-astakos-app/astakos/im/migrations/0068_auto__add_field_resource_project_default.py @@ -4,20 +4,19 @@ from south.v2 import SchemaMigration from django.db import models + class Migration(SchemaMigration): def forwards(self, orm): - + # Adding field 'Resource.project_default' db.add_column('im_resource', 'project_default', self.gf('django.db.models.fields.BigIntegerField')(default=0), keep_default=False) - def backwards(self, orm): - + # Deleting field 'Resource.project_default' db.delete_column('im_resource', 'project_default') - models = { 'auth.group': { 'Meta': {'object_name': 'Group'}, diff --git a/snf-astakos-app/astakos/im/migrations/0069_resource_project_defaults.py b/snf-astakos-app/astakos/im/migrations/0069_resource_project_defaults.py index d333118eb..95b515d1c 100644 --- a/snf-astakos-app/astakos/im/migrations/0069_resource_project_defaults.py +++ b/snf-astakos-app/astakos/im/migrations/0069_resource_project_defaults.py @@ -4,7 +4,7 @@ from south.v2 import DataMigration from django.db import models -MAX = 2**63 - 1 +MAX = 2 ** 63 - 1 class Migration(DataMigration): @@ -19,7 +19,6 @@ def forwards(self, orm): def backwards(self, orm): "Write your backwards methods here." - models = { 'auth.group': { 'Meta': {'object_name': 'Group'}, diff --git a/snf-astakos-app/astakos/im/migrations/0070_auto__chg_field_projectapplication_limit_on_members_number.py b/snf-astakos-app/astakos/im/migrations/0070_auto__chg_field_projectapplication_limit_on_members_number.py index 2f51907af..dd93dc0d0 100644 --- a/snf-astakos-app/astakos/im/migrations/0070_auto__chg_field_projectapplication_limit_on_members_number.py +++ b/snf-astakos-app/astakos/im/migrations/0070_auto__chg_field_projectapplication_limit_on_members_number.py @@ -4,20 +4,19 @@ from south.v2 import SchemaMigration from django.db import models + class Migration(SchemaMigration): def forwards(self, orm): - + # Changing field 'ProjectApplication.limit_on_members_number' db.alter_column('im_projectapplication', 'limit_on_members_number', self.gf('django.db.models.fields.BigIntegerField')(null=True)) - def backwards(self, orm): - + # Changing field 'ProjectApplication.limit_on_members_number' db.alter_column('im_projectapplication', 'limit_on_members_number', self.gf('django.db.models.fields.PositiveIntegerField')(null=True)) - models = { 'auth.group': { 'Meta': {'object_name': 'Group'}, diff --git a/snf-astakos-app/astakos/im/migrations/0071_inf_max_members.py b/snf-astakos-app/astakos/im/migrations/0071_inf_max_members.py index ee1594daa..3d9bf6cd9 100644 --- a/snf-astakos-app/astakos/im/migrations/0071_inf_max_members.py +++ b/snf-astakos-app/astakos/im/migrations/0071_inf_max_members.py @@ -4,7 +4,7 @@ from south.v2 import DataMigration from django.db import models -MAX = 2**63 - 1 +MAX = 2 ** 63 - 1 class Migration(DataMigration): @@ -21,7 +21,6 @@ def forwards(self, orm): def backwards(self, orm): "Write your backwards methods here." - models = { 'auth.group': { 'Meta': {'object_name': 'Group'}, diff --git a/snf-astakos-app/astakos/im/migrations/0072_auto__add_projectresourcequota__add_unique_projectresourcequota_resour.py b/snf-astakos-app/astakos/im/migrations/0072_auto__add_projectresourcequota__add_unique_projectresourcequota_resour.py index 332a21fb0..34940fc9c 100644 --- a/snf-astakos-app/astakos/im/migrations/0072_auto__add_projectresourcequota__add_unique_projectresourcequota_resour.py +++ b/snf-astakos-app/astakos/im/migrations/0072_auto__add_projectresourcequota__add_unique_projectresourcequota_resour.py @@ -4,10 +4,11 @@ from south.v2 import SchemaMigration from django.db import models + class Migration(SchemaMigration): def forwards(self, orm): - + # Adding model 'ProjectResourceQuota' db.create_table('im_projectresourcequota', ( ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), @@ -69,9 +70,8 @@ def forwards(self, orm): # Adding field 'Project.private' db.add_column('im_project', 'private', self.gf('django.db.models.fields.BooleanField')(default=False), keep_default=False) - def backwards(self, orm): - + # Removing unique constraint on 'ProjectResourceQuota', fields ['resource', 'project'] db.delete_unique('im_projectresourcequota', ['resource_id', 'project_id']) @@ -126,7 +126,6 @@ def backwards(self, orm): # Deleting field 'Project.private' db.delete_column('im_project', 'private') - models = { 'auth.group': { 'Meta': {'object_name': 'Group'}, diff --git a/snf-astakos-app/astakos/im/migrations/0073_project_fields.py b/snf-astakos-app/astakos/im/migrations/0073_project_fields.py index 520c6a503..4c9005837 100644 --- a/snf-astakos-app/astakos/im/migrations/0073_project_fields.py +++ b/snf-astakos-app/astakos/im/migrations/0073_project_fields.py @@ -63,10 +63,10 @@ def forwards(self, orm): for grant in grants: project = grant.project_application.project quotas.append(orm.ProjectResourceQuota( - resource=grant.resource, - project=project, - project_capacity=grant.project_capacity, - member_capacity=grant.member_capacity)) + resource=grant.resource, + project=project, + project_capacity=grant.project_capacity, + member_capacity=grant.member_capacity)) orm.ProjectResourceQuota.objects.bulk_create(quotas) @@ -93,7 +93,6 @@ def forwards(self, orm): def backwards(self, orm): "Write your backwards methods here." - models = { 'auth.group': { 'Meta': {'object_name': 'Group'}, diff --git a/snf-astakos-app/astakos/im/migrations/0074_auto__del_field_project_application__chg_field_project_limit_on_member.py b/snf-astakos-app/astakos/im/migrations/0074_auto__del_field_project_application__chg_field_project_limit_on_member.py index 7a8f24a06..9c4fe68bb 100644 --- a/snf-astakos-app/astakos/im/migrations/0074_auto__del_field_project_application__chg_field_project_limit_on_member.py +++ b/snf-astakos-app/astakos/im/migrations/0074_auto__del_field_project_application__chg_field_project_limit_on_member.py @@ -4,10 +4,11 @@ from south.v2 import SchemaMigration from django.db import models + class Migration(SchemaMigration): def forwards(self, orm): - + # Deleting field 'Project.application' db.delete_column('im_project', 'application_id') @@ -32,9 +33,8 @@ def forwards(self, orm): # Changing field 'Project.description' db.alter_column('im_project', 'description', self.gf('django.db.models.fields.TextField')(default='')) - def backwards(self, orm): - + # Adding field 'Project.application' db.add_column('im_project', 'application', self.gf('django.db.models.fields.related.OneToOneField')(default=None, related_name='project', unique=True, to=orm['im.ProjectApplication']), keep_default=False) @@ -59,7 +59,6 @@ def backwards(self, orm): # Changing field 'Project.description' db.alter_column('im_project', 'description', self.gf('django.db.models.fields.TextField')(null=True)) - models = { 'auth.group': { 'Meta': {'object_name': 'Group'}, diff --git a/snf-astakos-app/astakos/im/migrations/0075_auto__chg_field_projectresourcegrant_project_capacity__chg_field_proje.py b/snf-astakos-app/astakos/im/migrations/0075_auto__chg_field_projectresourcegrant_project_capacity__chg_field_proje.py index 1e8eb4a7c..9404f2d08 100644 --- a/snf-astakos-app/astakos/im/migrations/0075_auto__chg_field_projectresourcegrant_project_capacity__chg_field_proje.py +++ b/snf-astakos-app/astakos/im/migrations/0075_auto__chg_field_projectresourcegrant_project_capacity__chg_field_proje.py @@ -4,26 +4,25 @@ from south.v2 import SchemaMigration from django.db import models + class Migration(SchemaMigration): def forwards(self, orm): - + # Changing field 'ProjectResourceGrant.project_capacity' db.alter_column('im_projectresourcegrant', 'project_capacity', self.gf('django.db.models.fields.BigIntegerField')(default=0)) # Changing field 'ProjectResourceGrant.project_application' db.alter_column('im_projectresourcegrant', 'project_application_id', self.gf('django.db.models.fields.related.ForeignKey')(default=None, to=orm['im.ProjectApplication'])) - def backwards(self, orm): - + # Changing field 'ProjectResourceGrant.project_capacity' db.alter_column('im_projectresourcegrant', 'project_capacity', self.gf('django.db.models.fields.BigIntegerField')(null=True)) # Changing field 'ProjectResourceGrant.project_application' db.alter_column('im_projectresourcegrant', 'project_application_id', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['im.ProjectApplication'], null=True)) - models = { 'auth.group': { 'Meta': {'object_name': 'Group'}, diff --git a/snf-astakos-app/astakos/im/migrations/0076_auto__add_field_project_is_base__add_field_astakosuser_base_project.py b/snf-astakos-app/astakos/im/migrations/0076_auto__add_field_project_is_base__add_field_astakosuser_base_project.py index 7f7b33d9b..a93bdd724 100644 --- a/snf-astakos-app/astakos/im/migrations/0076_auto__add_field_project_is_base__add_field_astakosuser_base_project.py +++ b/snf-astakos-app/astakos/im/migrations/0076_auto__add_field_project_is_base__add_field_astakosuser_base_project.py @@ -4,26 +4,25 @@ from south.v2 import SchemaMigration from django.db import models + class Migration(SchemaMigration): def forwards(self, orm): - + # Adding field 'Project.is_base' db.add_column('im_project', 'is_base', self.gf('django.db.models.fields.BooleanField')(default=False), keep_default=False) # Adding field 'AstakosUser.base_project' db.add_column('im_astakosuser', 'base_project', self.gf('django.db.models.fields.related.ForeignKey')(related_name='base_user', null=True, to=orm['im.Project']), keep_default=False) - def backwards(self, orm): - + # Deleting field 'Project.is_base' db.delete_column('im_project', 'is_base') # Deleting field 'AstakosUser.base_project' db.delete_column('im_astakosuser', 'base_project_id') - models = { 'auth.group': { 'Meta': {'object_name': 'Group'}, diff --git a/snf-astakos-app/astakos/im/migrations/0077_base_projects.py b/snf-astakos-app/astakos/im/migrations/0077_base_projects.py index fc0f6b705..e634def1f 100644 --- a/snf-astakos-app/astakos/im/migrations/0077_base_projects.py +++ b/snf-astakos-app/astakos/im/migrations/0077_base_projects.py @@ -8,6 +8,7 @@ CLOSED_POLICY = 3 ACTIVATED = 1 + class Migration(DataMigration): def new_chain(self, orm): @@ -81,7 +82,6 @@ def forwards(self, orm): def backwards(self, orm): "Write your backwards methods here." - models = { 'auth.group': { 'Meta': {'object_name': 'Group'}, diff --git a/snf-astakos-app/astakos/im/migrations/0078_auto__chg_field_astakosuser_base_project.py b/snf-astakos-app/astakos/im/migrations/0078_auto__chg_field_astakosuser_base_project.py index 5cedf3df9..66c7a6589 100644 --- a/snf-astakos-app/astakos/im/migrations/0078_auto__chg_field_astakosuser_base_project.py +++ b/snf-astakos-app/astakos/im/migrations/0078_auto__chg_field_astakosuser_base_project.py @@ -4,16 +4,15 @@ from south.v2 import SchemaMigration from django.db import models + class Migration(SchemaMigration): def forwards(self, orm): pass - def backwards(self, orm): pass - models = { 'auth.group': { 'Meta': {'object_name': 'Group'}, diff --git a/snf-astakos-app/astakos/im/migrations/0079_auto__add_field_projectmembership_initialized.py b/snf-astakos-app/astakos/im/migrations/0079_auto__add_field_projectmembership_initialized.py index c18f4ae1d..54e730964 100644 --- a/snf-astakos-app/astakos/im/migrations/0079_auto__add_field_projectmembership_initialized.py +++ b/snf-astakos-app/astakos/im/migrations/0079_auto__add_field_projectmembership_initialized.py @@ -4,20 +4,19 @@ from south.v2 import SchemaMigration from django.db import models + class Migration(SchemaMigration): def forwards(self, orm): - + # Adding field 'ProjectMembership.initialized' db.add_column('im_projectmembership', 'initialized', self.gf('django.db.models.fields.BooleanField')(default=False), keep_default=False) - def backwards(self, orm): - + # Deleting field 'ProjectMembership.initialized' db.delete_column('im_projectmembership', 'initialized') - models = { 'auth.group': { 'Meta': {'object_name': 'Group'}, diff --git a/snf-astakos-app/astakos/im/migrations/0080_initialized_memberships.py b/snf-astakos-app/astakos/im/migrations/0080_initialized_memberships.py index e7a6ce10b..6667a1bf8 100644 --- a/snf-astakos-app/astakos/im/migrations/0080_initialized_memberships.py +++ b/snf-astakos-app/astakos/im/migrations/0080_initialized_memberships.py @@ -6,6 +6,7 @@ ACCEPTED_STATES = [1, 5, 10] + class Migration(DataMigration): def forwards(self, orm): @@ -20,7 +21,6 @@ def forwards(self, orm): def backwards(self, orm): "Write your backwards methods here." - models = { 'auth.group': { 'Meta': {'object_name': 'Group'}, diff --git a/snf-astakos-app/astakos/im/migrations/0081_auto__add_field_astakosuserauthprovider_last_login_at.py b/snf-astakos-app/astakos/im/migrations/0081_auto__add_field_astakosuserauthprovider_last_login_at.py index e25a6469a..0d2ab666f 100644 --- a/snf-astakos-app/astakos/im/migrations/0081_auto__add_field_astakosuserauthprovider_last_login_at.py +++ b/snf-astakos-app/astakos/im/migrations/0081_auto__add_field_astakosuserauthprovider_last_login_at.py @@ -13,12 +13,10 @@ def forwards(self, orm): self.gf('django.db.models.fields.DateTimeField')(default=None, null=True), keep_default=False) - def backwards(self, orm): # Deleting field 'AstakosUserAuthProvider.last_login_at' db.delete_column('im_astakosuserauthprovider', 'last_login_at') - models = { 'auth.group': { 'Meta': {'object_name': 'Group'}, From 161d6ac4e0b1e381482912e5856e9eb05e708c8a Mon Sep 17 00:00:00 2001 From: indorilftw Date: Wed, 12 Nov 2014 11:46:48 +0200 Subject: [PATCH 08/43] PEP8 fixes on snf-astakos-app/astakos/admin directory --- snf-astakos-app/astakos/admin/views.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/snf-astakos-app/astakos/admin/views.py b/snf-astakos-app/astakos/admin/views.py index e9e9f451f..6300aefb0 100644 --- a/snf-astakos-app/astakos/admin/views.py +++ b/snf-astakos-app/astakos/admin/views.py @@ -36,7 +36,7 @@ try: AUTH_URL = settings.astakos_services \ - ["astakos_identity"]["endpoints"][0]["publicURL"] + ["astakos_identity"]["endpoints"][0]["publicURL"] except (IndexError, KeyError) as e: logger.error("Failed to load Astakos Auth URL: %s", e) AUTH_URL = None @@ -60,4 +60,3 @@ def get_astakos_stats(request): _stats = stats.get_astakos_stats() data = json.dumps(_stats) return http.HttpResponse(data, status=200, content_type='application/json') - From c7a2b073b659eeb5c7d18a40396f5034516fbd52 Mon Sep 17 00:00:00 2001 From: indorilftw Date: Wed, 12 Nov 2014 11:47:08 +0200 Subject: [PATCH 09/43] PEP8 fixes on snf-astakos-app/astakos/api directory --- snf-astakos-app/astakos/api/user.py | 1 + 1 file changed, 1 insertion(+) diff --git a/snf-astakos-app/astakos/api/user.py b/snf-astakos-app/astakos/api/user.py index 4b5a18dee..3badc0351 100644 --- a/snf-astakos-app/astakos/api/user.py +++ b/snf-astakos-app/astakos/api/user.py @@ -44,6 +44,7 @@ logger = logging.getLogger(__name__) + @csrf_exempt @api.api_method(http_method="POST", token_required=True, user_required=False, logger=logger) From 0cce468719caf631bc41c988c1904fe4f76e968a Mon Sep 17 00:00:00 2001 From: indorilftw Date: Wed, 12 Nov 2014 11:47:48 +0200 Subject: [PATCH 10/43] PEP8 fixes on snf-astakos-app/astakos/im directory --- snf-astakos-app/astakos/im/fields.py | 12 +++---- snf-astakos-app/astakos/im/forms.py | 17 ++++------ snf-astakos-app/astakos/im/functions.py | 2 +- .../im/management/commands/user-list.py | 2 +- .../im/management/commands/user-show.py | 2 +- snf-astakos-app/astakos/im/models.py | 18 +++++----- snf-astakos-app/astakos/im/tables.py | 10 +++--- .../astakos/im/templatetags/filters.py | 10 +++--- snf-astakos-app/astakos/im/tests/api.py | 2 +- snf-astakos-app/astakos/im/tests/auth.py | 18 +++++----- snf-astakos-app/astakos/im/tests/projects.py | 33 ++++++++++--------- .../astakos/im/views/decorators.py | 2 +- snf-astakos-app/astakos/im/views/projects.py | 12 +++---- .../astakos/im/views/target/shibboleth.py | 2 +- snf-astakos-app/astakos/im/views/util.py | 1 - 15 files changed, 68 insertions(+), 75 deletions(-) diff --git a/snf-astakos-app/astakos/im/fields.py b/snf-astakos-app/astakos/im/fields.py index f2bd641a9..d66c6c64c 100644 --- a/snf-astakos-app/astakos/im/fields.py +++ b/snf-astakos-app/astakos/im/fields.py @@ -34,7 +34,7 @@ class EmailValidator(object): code = 'invalid' user_regex = re.compile( r"(^[-!#$%&'*+/=?^_`{}|~0-9A-Z]+(\.[-!#$%&'*+/=?^_`{}|~0-9A-Z]+)*$" # dot-atom - r'|^"([\001-\010\013\014\016-\037!#-\[\]-\177]|\\[\001-\011\013\014\016-\177])*"$)', # quoted-string + r'|^"([\001-\010\013\014\016-\037!#-\[\]-\177]|\\[\001-\011\013\014\016-\177])*"$)', # quoted-string re.IGNORECASE) domain_regex = re.compile( r'(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+(?:[A-Z]{2,6}|[A-Z0-9-]{2,})$' # domain @@ -115,9 +115,9 @@ def render(self, *args, **kwargs): }); """ % ({ - 'id': attrs.get("id"), - 'html': out -})) + 'id': attrs.get("id"), + 'html': out + })) def decompress(self, value): if not value: @@ -152,7 +152,7 @@ class InfiniteChoiceField(forms.ChoiceField): INFINITE_VALUES = ['Unlimited'] widget = CustomChoiceWidget - default_validators=[validators.MinValueValidator(0)] + default_validators = [validators.MinValueValidator(0)] def _get_choices(self): return self._choices @@ -160,7 +160,7 @@ def _get_choices(self): def _set_choices(self, value): self._choices = self.widget.choices = \ self.widget.widgets[0].choices = \ - list(value) + [("custom", "Other")] + list(value) + [("custom", "Other")] choices = property(_get_choices, _set_choices) diff --git a/snf-astakos-app/astakos/im/forms.py b/snf-astakos-app/astakos/im/forms.py index f589924be..e2ff8802b 100644 --- a/snf-astakos-app/astakos/im/forms.py +++ b/snf-astakos-app/astakos/im/forms.py @@ -52,13 +52,12 @@ import logging import hashlib import recaptcha.client.captcha as captcha -import re logger = logging.getLogger(__name__) BASE_PROJECT_NAME_REGEX = re.compile( r'^system:[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[89aAbB][a-f0-9]{3}-' - '[a-f0-9]{12}$') + '[a-f0-9]{12}$') DOMAIN_VALUE_REGEX = re.compile( r'^([a-zA-Z0-9]([a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,6}$', re.IGNORECASE) @@ -738,7 +737,7 @@ def __init__(self, *args, **kwargs): name_field = self.fields['name'] name_field.validators = [base_app_name_validator] if self.initial['limit_on_members_number'] == \ - units.PRACTICALLY_INFINITE: + units.PRACTICALLY_INFINITE: self.initial['limit_on_members_number'] = 'Unlimited' def clean_limit_on_members_number(self): @@ -846,8 +845,7 @@ def resource_policies(self): resource.name) # keep only resource limits for selected resource groups - if data.get('is_selected_%s' % \ - resource.group, "0") == "1": + if data.get('is_selected_%s' % resource.group, "0") == "1": if not resource.ui_visible: raise forms.ValidationError("Invalid resource %s" % resource.name) @@ -915,8 +913,7 @@ def resource_policies(self): if not handled: d.update(dict(resource=prefix, m_uplimit=0, - display_m_uplimit=units.show(0, - resource.unit))) + display_m_uplimit=units.show(0, resource.unit))) else: d.update(dict(resource=prefix, m_uplimit=uplimit, display_m_uplimit=display)) @@ -926,8 +923,7 @@ def resource_policies(self): if not handled: d.update(dict(resource=prefix, p_uplimit=0, - display_p_uplimit=units.show(0, - resource.unit))) + display_p_uplimit=units.show(0, resource.unit))) if resource_indexes.get(prefix, None) is not None: # already included in policies @@ -992,8 +988,7 @@ def get_api_data(self): instance = Project.objects.get(pk=self.instance.pk) for key in [dkey for dkey in data.keys() if not dkey in exclude_keys]: - if not is_new and \ - (getattr(instance, key) == data.get(key)): + if not is_new and (getattr(instance, key) == data.get(key)): del data[key] resources = self.cleaned_resource_policies() diff --git a/snf-astakos-app/astakos/im/functions.py b/snf-astakos-app/astakos/im/functions.py index 4926ef48b..7cf83d32a 100644 --- a/snf-astakos-app/astakos/im/functions.py +++ b/snf-astakos-app/astakos/im/functions.py @@ -482,7 +482,7 @@ def join_project(project_id, request_user, reason=None): MEMBERSHIP_ACTION_CHECKS = { - "leave": leave_project_checks, + "leave": leave_project_checks, "cancel": cancel_membership_checks, "accept": accept_membership_checks, "reject": reject_membership_checks, diff --git a/snf-astakos-app/astakos/im/management/commands/user-list.py b/snf-astakos-app/astakos/im/management/commands/user-list.py index 4143f600a..433ed3fb0 100644 --- a/snf-astakos-app/astakos/im/management/commands/user-list.py +++ b/snf-astakos-app/astakos/im/management/commands/user-list.py @@ -51,7 +51,7 @@ class Command(ListCommand): 'displayname': ('username', 'The display name of the user'), 'groups': (get_groups, 'The groups of the user'), 'last_login_details': ('last_login_info_display', - 'User last login dates for each login method'), + 'User last login dates for each login method'), 'last_login': ('last_login', 'User last login date') } diff --git a/snf-astakos-app/astakos/im/management/commands/user-show.py b/snf-astakos-app/astakos/im/management/commands/user-show.py index e400468be..6f245d658 100644 --- a/snf-astakos-app/astakos/im/management/commands/user-show.py +++ b/snf-astakos-app/astakos/im/management/commands/user-show.py @@ -79,7 +79,7 @@ def handle(self, *args, **options): ('last login', user.last_login), ('date joined', user.date_joined), ('last update', user.updated), - #('token', user.auth_token), + # ('token', user.auth_token), ('token expiration', user.auth_token_expires), ('providers', user.auth_providers_display), ('groups', [elem.name for elem in user.groups.all()]), diff --git a/snf-astakos-app/astakos/im/models.py b/snf-astakos-app/astakos/im/models.py index 2078eb1fe..11af1ce54 100644 --- a/snf-astakos-app/astakos/im/models.py +++ b/snf-astakos-app/astakos/im/models.py @@ -56,7 +56,7 @@ _content_type = None SYSTEM_PROJECT_NAME_TPL = getattr(astakos_settings, "SYSTEM_PROJECT_NAME_TPL", - u"[system] %s") + u"[system] %s") def get_content_type(): @@ -375,7 +375,7 @@ class AstakosUser(User): affiliation = models.CharField(_('Affiliation'), max_length=255, blank=True, null=True) - #for invitations + # for invitations user_level = astakos_settings.DEFAULT_USER_LEVEL level = models.IntegerField(_('Inviter level'), default=user_level) invitations = models.IntegerField( @@ -769,7 +769,7 @@ def get_inactive_message(self, provider_module, identifier=None): msg_inactive = provider.get_account_inactive_msg msg_pending = provider.get_pending_activation_msg msg_pending_help = _(astakos_messages.ACCOUNT_PENDING_ACTIVATION_HELP) - #msg_resend_prompt = _(astakos_messages.ACCOUNT_RESEND_ACTIVATION) + # msg_resend_prompt = _(astakos_messages.ACCOUNT_RESEND_ACTIVATION) msg_pending_mod = provider.get_pending_moderation_msg msg_rejected = _(astakos_messages.ACCOUNT_REJECTED) msg_resend = _(astakos_messages.ACCOUNT_RESEND_ACTIVATION) @@ -860,7 +860,6 @@ def last_login_info_display(self): return ", ".join(display) - class AstakosUserAuthProviderManager(models.Manager): def active(self, **filters): @@ -1564,7 +1563,7 @@ def display_project_diff(self): def disp(v, disp_func=None): if not disp_func: - disp_func = lambda : '' + disp_func = lambda: '' if v == 0: return '' @@ -1642,7 +1641,6 @@ def has_infinite_members_limit(self): return self.limit_on_members_number == units.PRACTICALLY_INFINITE - class Project(models.Model): id = models.BigIntegerField(db_column='id', primary_key=True) @@ -1740,12 +1738,12 @@ def __unicode__(self): None: O_UNINITIALIZED, ProjectApplication.PENDING: O_PENDING, ProjectApplication.DENIED: O_DENIED, - } + } O_STATE_DELETED = { None: O_DELETED, ProjectApplication.DISMISSED: O_DISMISSED, ProjectApplication.CANCELLED: O_CANCELLED, - } + } OVERALL_STATE = { NORMAL: lambda app_state: Project.O_ACTIVE, @@ -1755,7 +1753,7 @@ def __unicode__(self): app_state, None), SUSPENDED: lambda app_state: Project.O_SUSPENDED, TERMINATED: lambda app_state: Project.O_TERMINATED, - } + } def display_name_for_user(self, user): if not self.is_base: @@ -2105,7 +2103,7 @@ def user_friendly_state_display(self): class Meta: unique_together = ("person", "project") - #index_together = [["project", "state"]] + # index_together = [["project", "state"]] def __unicode__(self): return (_("<'%s' membership in '%s'>") % diff --git a/snf-astakos-app/astakos/im/tables.py b/snf-astakos-app/astakos/im/tables.py index 4c3574bac..8aef7f60b 100644 --- a/snf-astakos-app/astakos/im/tables.py +++ b/snf-astakos-app/astakos/im/tables.py @@ -263,11 +263,11 @@ def __init__(self, *args, **kwargs): caption = _('My projects') name = ProjectNameColumn('project_detail', - coerce=lambda x: truncatename(x, 25), - append=project_name_append, - args=(A('uuid'),), - orderable=False, - accessor='display_name') + coerce=lambda x: truncatename(x, 25), + append=project_name_append, + args=(A('uuid'),), + orderable=False, + accessor='display_name') creation_date = tables.DateColumn(verbose_name=_('Application'), format=DEFAULT_DATE_FORMAT, diff --git a/snf-astakos-app/astakos/im/templatetags/filters.py b/snf-astakos-app/astakos/im/templatetags/filters.py index 6fb7ab6aa..66fe67781 100644 --- a/snf-astakos-app/astakos/im/templatetags/filters.py +++ b/snf-astakos-app/astakos/im/templatetags/filters.py @@ -197,7 +197,7 @@ def resource_grants(project_or_app): grants = project_or_app.resource_set grants = grants.values_list( 'resource__name', 'member_capacity', 'project_capacity') - return dict((e[0], {'member':e[1], 'project':e[2]}) for e in grants) + return dict((e[0], {'member': e[1], 'project': e[2]}) for e in grants) except: return {} @@ -231,7 +231,7 @@ def resource_diff(r, member_or_project): project, member = r.display_project_diff() diff = dict(zip(['project', 'member'], - r.display_project_diff())).get(member_or_project) + r.display_project_diff())).get(member_or_project) diff_disp = '' if diff != '': @@ -271,7 +271,7 @@ def display_resource_usage_for_project(resource, project): usage_perc_display = "%s%%" % usage_perc resp = """%s (%s)""" % \ - (cls, usage_perc_display, usage_display) + (cls, usage_perc_display, usage_display) return mark_safe(resp) @@ -372,8 +372,8 @@ def display_modification_param(form_or_app, param, formatter=None): changed_prefix = "current: " if formatter: app_value, changed, cls, prefix = formatter(form_or_app, - app_value, changed, - **formatter_params) + app_value, changed, + **formatter_params) if cls: changed_cls = cls diff --git a/snf-astakos-app/astakos/im/tests/api.py b/snf-astakos-app/astakos/im/tests/api.py index 7887d8a29..daf009fdc 100644 --- a/snf-astakos-app/astakos/im/tests/api.py +++ b/snf-astakos-app/astakos/im/tests/api.py @@ -25,7 +25,7 @@ from datetime import date -#from xml.dom import minidom +# from xml.dom import minidom import json import time diff --git a/snf-astakos-app/astakos/im/tests/auth.py b/snf-astakos-app/astakos/im/tests/auth.py index 226fca6d0..53c6e1dbf 100644 --- a/snf-astakos-app/astakos/im/tests/auth.py +++ b/snf-astakos-app/astakos/im/tests/auth.py @@ -61,7 +61,7 @@ def test_create_account(self): # shibboleth logged us in client.set_tokens(mail="kpap@synnefo.org", remote_user="kpapeppn", - cn="Kostas Papadimitriou" + 30*"*", + cn="Kostas Papadimitriou" + 30 * "*", ep_affiliation="Test Affiliation") r = client.get(ui_url('login/shibboleth?'), follow=True, **{'HTTP_SHIB_CUSTOM_IDP_KEY': 'test'}) @@ -217,7 +217,6 @@ def test_create_account(self): backend.send_result_notifications(activation_result, u) self.assertEqual(u.is_active, True) - # we visit our profile view r = client.get(ui_url("login/shibboleth?"), follow=True) user = r.context['request'].user @@ -986,8 +985,8 @@ def test_user(self): self.assertRedirects(r, ui_url('landing')) helpdesk_email = astakos_settings.HELPDESK[0][1] self.assertEqual(len(get_mailbox(helpdesk_email)), 1) - self.assertTrue(u'AstakosUser: Academic γιούνικοουντ' in \ - get_mailbox(helpdesk_email)[0].body) + self.assertTrue(u'AstakosUser: Academic γιούνικοουντ' in + get_mailbox(helpdesk_email)[0].body) newuser = User.objects.get(email="newuser@synnefo.org") self.assertEqual(newuser.is_active, True) self.assertEqual(newuser.email_verified, True) @@ -1084,7 +1083,7 @@ def test_create(self): module = 'local' identifier = None provider_params = {'auth_backend': 'ldap', 'info': - {'office': 'A1'}} + {'office': 'A1'}} provider = auth.get_provider(module, user, identifier, **provider_params) provider.add_to_user() @@ -1302,7 +1301,6 @@ def test_messages(self): self.assertEqual(provider.get_method_details_msg, u'Account: kpap@s\u1e6bynnefo.org') self.assertEqual(provider.get_username_msg, u'kpap@s\u1e6bynnefo.org') - @im_settings(IM_MODULES=['local', 'shibboleth']) @shibboleth_settings(LIMIT_POLICY=2) def test_templates(self): @@ -1359,8 +1357,8 @@ def test_policies(self): MANAGERS=MANAGERS, HELPDESK=HELPDESK, ADMINS=ADMINS, - ACCOUNT_PENDING_MODERATION_RECIPIENTS=MANAGERS+HELPDESK+ADMINS, - ACCOUNT_ACTIVATED_RECIPIENTS=MANAGERS+HELPDESK+ADMINS) + ACCOUNT_PENDING_MODERATION_RECIPIENTS=MANAGERS + HELPDESK + ADMINS, + ACCOUNT_ACTIVATED_RECIPIENTS=MANAGERS + HELPDESK + ADMINS) def test_without_moderation(self): backend = activation_backends.get_backend() form = backend.get_signup_form('local') @@ -1413,8 +1411,8 @@ def test_without_moderation(self): MANAGERS=MANAGERS, HELPDESK=HELPDESK, ADMINS=ADMINS, - ACCOUNT_PENDING_MODERATION_RECIPIENTS=HELPDESK+MANAGERS+ADMINS, - ACCOUNT_ACTIVATED_RECIPIENTS=HELPDESK+MANAGERS+ADMINS) + ACCOUNT_PENDING_MODERATION_RECIPIENTS=HELPDESK + MANAGERS + ADMINS, + ACCOUNT_ACTIVATED_RECIPIENTS=HELPDESK + MANAGERS + ADMINS) def test_with_moderation(self): backend = activation_backends.get_backend() diff --git a/snf-astakos-app/astakos/im/tests/projects.py b/snf-astakos-app/astakos/im/tests/projects.py index e210371f2..681ca933b 100644 --- a/snf-astakos-app/astakos/im/tests/projects.py +++ b/snf-astakos-app/astakos/im/tests/projects.py @@ -543,7 +543,6 @@ def test_projects(self): action, content_type="application/json", **h_owner) self.assertEqual(r.status_code, 400) - ap_base = { "owner": self.user1.uuid, "name": "domain.name", @@ -556,8 +555,8 @@ def test_projects(self): u"σέρβις1.ρίσορς11": { "member_capacity": 512, "project_capacity": 1024} - }, - } + }, + } status, body = self.create(ap_base, h_owner) project_b_id = body["id"] app_b_id = body["application"] @@ -620,7 +619,7 @@ def test_projects(self): self.assertEqual(status, 400) ap = copy.deepcopy(ap_base) - ap["max_members"] = 2**63 + ap["max_members"] = 2 ** 63 status, body = self.create(ap, h_owner) self.assertEqual(status, 400) @@ -640,14 +639,18 @@ def test_projects(self): self.assertEqual(status, 400) ap = copy.deepcopy(ap_base) - ap["resources"] = {u"σέρβις1.ρίσορς11": {"member_capacity": -512, - "project_capacity": 256}} + ap["resources"] = {u"σέρβις1.ρίσορς11": { + "member_capacity": -512, + "project_capacity": 256} + } status, body = self.create(ap, h_owner) self.assertEqual(status, 400) ap = copy.deepcopy(ap_base) - ap["resources"] = {u"σέρβις1.ρίσορς11": {"member_capacity": 512, - "project_capacity": 256}} + ap["resources"] = {u"σέρβις1.ρίσορς11": { + "member_capacity": 512, + "project_capacity": 256} + } status, body = self.create(ap, h_owner) self.assertEqual(status, 400) @@ -713,15 +716,15 @@ def test_projects(self): admin_pa1 = get_pending_apps(self.user2) owner_pa1 = get_pending_apps(self.user1) - self.assertEqual(admin_pa1, admin_pa0+1) + self.assertEqual(admin_pa1, admin_pa0 + 1) self.assertEqual(owner_pa1, owner_pa0) status, body = self.modify(app, project_id, h_owner) self.assertEqual(status, 201) admin_pa2 = get_pending_apps(self.user2) owner_pa2 = get_pending_apps(self.user1) - self.assertEqual(admin_pa2, admin_pa1-1) - self.assertEqual(owner_pa2, owner_pa1+1) + self.assertEqual(admin_pa2, admin_pa1 - 1) + self.assertEqual(owner_pa2, owner_pa1 + 1) status, body = self.modify(app, project_id, h_owner) self.assertEqual(status, 201) @@ -821,8 +824,8 @@ def test_applications(self): "astakos.pending_app": { "member_capacity": 2, "project_capacity": 2} - } } + } functions.modify_project(self.user.uuid, request) r = self.user_client.get(reverse('project_add'), follow=True) @@ -886,12 +889,12 @@ def test_applications(self): # admin approves r = self.admin_client.post(reverse('project_app_approve', kwargs={ - 'application_id': app1_id, - 'project_uuid': app1.chain.uuid}), + 'application_id': app1_id, + 'project_uuid': app1.chain.uuid}), follow=True) self.assertEqual(r.status_code, 200) self.assertEqual(Project.objects.filter(is_base=False, - state=Project.O_ACTIVE).count(), 1) + state=Project.O_ACTIVE).count(), 1) # login self.member_client.get(reverse("edit_profile")) diff --git a/snf-astakos-app/astakos/im/views/decorators.py b/snf-astakos-app/astakos/im/views/decorators.py index 7e0021150..7be860948 100644 --- a/snf-astakos-app/astakos/im/views/decorators.py +++ b/snf-astakos-app/astakos/im/views/decorators.py @@ -109,7 +109,7 @@ def wrapper(request, *args, **kwargs): for pkey, value in perms.iteritems(): attr = 'get_%s_policy' % pkey.lower() if getattr(provider, attr) != value: - #TODO: add session message + # TODO: add session message return HttpResponseRedirect(reverse('login')) return func(request, *args) return wrapper diff --git a/snf-astakos-app/astakos/im/views/projects.py b/snf-astakos-app/astakos/im/views/projects.py index 6fe931536..c14aaa728 100644 --- a/snf-astakos-app/astakos/im/views/projects.py +++ b/snf-astakos-app/astakos/im/views/projects.py @@ -112,8 +112,8 @@ def project_list(request, template_name="im/projects/project_list.html"): # exclude base projects by default for admin users if not show_base and request.user.is_project_admin(): - query = query & ~Q(Q(is_base=True) & \ - ~Q(realname="system:%s" % request.user.uuid)) + query = query & ~Q(Q(is_base=True) & + ~Q(realname="system:%s" % request.user.uuid)) query = query & ~Q(state=Project.DELETED) mode = "default" @@ -277,7 +277,7 @@ def project_or_app_detail(request, project_uuid, app_id=None): user = request.user owns_base = False if project and project.is_base and \ - project.realname == "system:%s" % request.user.uuid: + project.realname == "system:%s" % request.user.uuid: owns_base = True is_project_admin = user.is_project_admin() is_owner = user.owns_project(project) @@ -285,7 +285,7 @@ def project_or_app_detail(request, project_uuid, app_id=None): last_pending_app = project.last_pending_application() if last_pending_app: is_applicant = last_pending_app and \ - last_pending_app.applicant.pk == user.pk + last_pending_app.applicant.pk == user.pk if not (is_owner or is_project_admin) and \ not user.non_owner_can_view(project): @@ -302,7 +302,7 @@ def project_or_app_detail(request, project_uuid, app_id=None): can_join_req = can_join_request(project, user) if project else False can_leave_req = can_leave_request(project, user) if project else False can_cancel_req = \ - can_cancel_join_request(project, user) if project else False + can_cancel_join_request(project, user) if project else False is_modification = application.is_modification() if application else False @@ -319,7 +319,7 @@ def project_or_app_detail(request, project_uuid, app_id=None): display_usage = False if (owns_base or is_owner or membership or is_project_admin) \ - and not app_id: + and not app_id: display_usage = True return object_detail( diff --git a/snf-astakos-app/astakos/im/views/target/shibboleth.py b/snf-astakos-app/astakos/im/views/target/shibboleth.py index 9c036f1fd..e43f283a6 100644 --- a/snf-astakos-app/astakos/im/views/target/shibboleth.py +++ b/snf-astakos-app/astakos/im/views/target/shibboleth.py @@ -140,7 +140,7 @@ def login(request, fullname = '%s %s' % (first_name, last_name) if not any([first_name, last_name]) and \ - settings.SHIBBOLETH_REQUIRE_NAME_INFO: + settings.SHIBBOLETH_REQUIRE_NAME_INFO: raise KeyError(_(astakos_messages.SHIBBOLETH_MISSING_NAME)) except KeyError, e: diff --git a/snf-astakos-app/astakos/im/views/util.py b/snf-astakos-app/astakos/im/views/util.py index 31e4af418..ccd32678e 100644 --- a/snf-astakos-app/astakos/im/views/util.py +++ b/snf-astakos-app/astakos/im/views/util.py @@ -315,4 +315,3 @@ def redirect_to_next(request, default_resolve, *args, **kwargs): next = restrict_next(next, domain=settings.COOKIE_DOMAIN) return redirect(next) - From e4cd1aead65701567d14bd0e767cd1f6b378627c Mon Sep 17 00:00:00 2001 From: indorilftw Date: Wed, 12 Nov 2014 11:48:10 +0200 Subject: [PATCH 11/43] PEP8 fixes on snf-astakos-app/astakos/oa2 directory --- snf-astakos-app/astakos/oa2/backends/base.py | 28 +++++++++---------- .../astakos/oa2/backends/djangobackend.py | 2 +- .../astakos/oa2/migrations/0001_initial.py | 4 +-- ...hg_field_authorizationcode_redirect_uri.py | 2 +- ...de_access_token__add_field_token_access.py | 4 +-- ...__del_unique_redirecturl_url__chg_field.py | 4 +-- .../astakos/oa2/tests/djangobackend.py | 12 ++++---- snf-astakos-app/astakos/oa2/urls.py | 9 ++---- snf-astakos-app/astakos/oa2/views.py | 2 ++ 9 files changed, 30 insertions(+), 37 deletions(-) diff --git a/snf-astakos-app/astakos/oa2/backends/base.py b/snf-astakos-app/astakos/oa2/backends/base.py index 84e85d8ad..db95891c8 100644 --- a/snf-astakos-app/astakos/oa2/backends/base.py +++ b/snf-astakos-app/astakos/oa2/backends/base.py @@ -193,8 +193,8 @@ class BackendBase(type): def __new__(cls, name, bases, attrs): super_new = super(BackendBase, cls).__new__ - #parents = [b for b in bases if isinstance(b, BackendBase)] - #meta = attrs.pop('Meta', None) + # parents = [b for b in bases if isinstance(b, BackendBase)] + # meta = attrs.pop('Meta', None) return super_new(cls, name, bases, attrs) @classmethod @@ -298,8 +298,8 @@ def create_token(self, value, token_type, authorization, scope, logger.info(u'%r created' % token) return token -# def delete_authorization_code(self, code): -# del self.code_model.ENTRIES[code] + # def delete_authorization_code(self, code): + # del self.code_model.ENTRIES[code] def get_client_by_id(self, client_id): return self.client_model.get(client_id) @@ -365,7 +365,7 @@ def add_token_for_client(self, token_type, authorization, refresh=False): def grant_accept_response(self, client, redirect_uri, scope, state): context = {'client': client.get_id(), 'redirect_uri': redirect_uri, 'scope': scope, 'state': state, - #'url': url, + # 'url': url, } json_content = json.dumps(context) return self.response_cls(status=200, body=json_content) @@ -383,7 +383,7 @@ def redirect_to_login_response(self, request, params): parts[2] = self.get_login_uri() parts[3] = self.urlencode(query) - return Response(302, headers={'Location': urlparse.urlunsplit(parts)}) + return Response(302, headers={'Location': urlparse.urlunsplit(parts)}) def redirect_to_uri(self, redirect_uri, code, state=None): parts = list(urlparse.urlsplit(redirect_uri)) @@ -551,7 +551,7 @@ def validate_redirect_uri(self, client, params, headers, def validate_state(self, client, params, headers): return params.get('state') - #raise OA2Error("Invalid state") + # raise OA2Error("Invalid state") def validate_scope(self, client, params, headers): scope = params.get('scope') @@ -622,10 +622,10 @@ def authorize(self, request, **extra): self.validate_code_request(params, request.META) elif auth_type == 'token': raise OA2Error("Unsupported authorization type") -# client, uri, scope, state = \ -# self.validate_token_request(params, request.META) + # client, uri, scope, state = \ + # self.validate_token_request(params, request.META) else: - #TODO: handle custom type + # TODO: handle custom type raise OA2Error("Invalid authorization type") user = getattr(request, 'user', None) @@ -638,10 +638,10 @@ def authorize(self, request, **extra): state) elif auth_type == 'token': raise OA2Error("Unsupported response type") -# return self.process_token_request(user, client, uri, scope, -# state) + # return self.process_token_request(user, client, uri, scope, + # state) else: - #TODO: handle custom type + # TODO: handle custom type raise OA2Error("Invalid authorization type") else: if client.is_trusted: @@ -672,7 +672,7 @@ def grant_token(self, request, **extra): self.is_uri(grant_type)): raise OA2Error("Unsupported grant type") else: - #TODO: handle custom type + # TODO: handle custom type raise OA2Error("Invalid grant type") @staticmethod diff --git a/snf-astakos-app/astakos/oa2/backends/djangobackend.py b/snf-astakos-app/astakos/oa2/backends/djangobackend.py index 54d2454ec..0310fb8c8 100644 --- a/snf-astakos-app/astakos/oa2/backends/djangobackend.py +++ b/snf-astakos-app/astakos/oa2/backends/djangobackend.py @@ -117,7 +117,7 @@ def build_request(self, django_request): 'POST': django_request.POST, 'META': django_request.META, 'secure': settings.DEBUG or django_request.is_secure(), - #'secure': django_request.is_secure(), + # 'secure': django_request.is_secure(), } # TODO: check for valid astakos user if django_request.user.is_authenticated(): diff --git a/snf-astakos-app/astakos/oa2/migrations/0001_initial.py b/snf-astakos-app/astakos/oa2/migrations/0001_initial.py index 9bd720387..36b6de61c 100644 --- a/snf-astakos-app/astakos/oa2/migrations/0001_initial.py +++ b/snf-astakos-app/astakos/oa2/migrations/0001_initial.py @@ -61,7 +61,6 @@ def forwards(self, orm): )) db.send_create_signal('oa2', ['Token']) - def backwards(self, orm): # Removing unique constraint on 'RedirectUrl', fields ['client', 'url'] db.delete_unique('oa2_redirecturl', ['client_id', 'url']) @@ -78,7 +77,6 @@ def backwards(self, orm): # Deleting model 'Token' db.delete_table('oa2_token') - models = { 'auth.group': { 'Meta': {'object_name': 'Group'}, @@ -209,4 +207,4 @@ def backwards(self, orm): } } - complete_apps = ['oa2'] \ No newline at end of file + complete_apps = ['oa2'] diff --git a/snf-astakos-app/astakos/oa2/migrations/0002_auto__chg_field_authorizationcode_redirect_uri.py b/snf-astakos-app/astakos/oa2/migrations/0002_auto__chg_field_authorizationcode_redirect_uri.py index 2d8c40c48..74641a939 100644 --- a/snf-astakos-app/astakos/oa2/migrations/0002_auto__chg_field_authorizationcode_redirect_uri.py +++ b/snf-astakos-app/astakos/oa2/migrations/0002_auto__chg_field_authorizationcode_redirect_uri.py @@ -147,4 +147,4 @@ def backwards(self, orm): } } - complete_apps = ['oa2'] \ No newline at end of file + complete_apps = ['oa2'] diff --git a/snf-astakos-app/astakos/oa2/migrations/0003_auto__add_field_authorizationcode_access_token__add_field_token_access.py b/snf-astakos-app/astakos/oa2/migrations/0003_auto__add_field_authorizationcode_access_token__add_field_token_access.py index d6580676c..e6e2ba946 100644 --- a/snf-astakos-app/astakos/oa2/migrations/0003_auto__add_field_authorizationcode_access_token__add_field_token_access.py +++ b/snf-astakos-app/astakos/oa2/migrations/0003_auto__add_field_authorizationcode_access_token__add_field_token_access.py @@ -18,7 +18,6 @@ def forwards(self, orm): self.gf('django.db.models.fields.CharField')(default='online', max_length=100), keep_default=False) - def backwards(self, orm): # Deleting field 'AuthorizationCode.access_token' db.delete_column('oa2_authorizationcode', 'access_token') @@ -26,7 +25,6 @@ def backwards(self, orm): # Deleting field 'Token.access_token' db.delete_column('oa2_token', 'access_token') - models = { 'auth.group': { 'Meta': {'object_name': 'Group'}, @@ -160,4 +158,4 @@ def backwards(self, orm): } } - complete_apps = ['oa2'] \ No newline at end of file + complete_apps = ['oa2'] diff --git a/snf-astakos-app/astakos/oa2/migrations/0004_auto__chg_field_redirecturl_url__del_unique_redirecturl_url__chg_field.py b/snf-astakos-app/astakos/oa2/migrations/0004_auto__chg_field_redirecturl_url__del_unique_redirecturl_url__chg_field.py index d9f7c68ff..8a944a4ec 100644 --- a/snf-astakos-app/astakos/oa2/migrations/0004_auto__chg_field_redirecturl_url__del_unique_redirecturl_url__chg_field.py +++ b/snf-astakos-app/astakos/oa2/migrations/0004_auto__chg_field_redirecturl_url__del_unique_redirecturl_url__chg_field.py @@ -11,7 +11,6 @@ def forwards(self, orm): # Removing unique constraint on 'RedirectUrl', fields ['url'] db.delete_unique('oa2_redirecturl', ['url']) - # Changing field 'RedirectUrl.url' db.alter_column('oa2_redirecturl', 'url', self.gf('django.db.models.fields.TextField')()) @@ -28,7 +27,6 @@ def backwards(self, orm): # Adding unique constraint on 'RedirectUrl', fields ['url'] db.create_unique('oa2_redirecturl', ['url']) - # Changing field 'AuthorizationCode.redirect_uri' db.alter_column('oa2_authorizationcode', 'redirect_uri', self.gf('django.db.models.fields.CharField')(max_length=255, null=True)) @@ -168,4 +166,4 @@ def backwards(self, orm): } } - complete_apps = ['oa2'] \ No newline at end of file + complete_apps = ['oa2'] diff --git a/snf-astakos-app/astakos/oa2/tests/djangobackend.py b/snf-astakos-app/astakos/oa2/tests/djangobackend.py index 9e353d16a..e1393df9f 100644 --- a/snf-astakos-app/astakos/oa2/tests/djangobackend.py +++ b/snf-astakos-app/astakos/oa2/tests/djangobackend.py @@ -107,8 +107,8 @@ def __init__(self, baseurl, *args, **kwargs): return super(OA2Client, self).__init__(*args, **kwargs) def request(self, *args, **kwargs): - #print kwargs.get('PATH_INFO') + '?' + kwargs.get('QUERY_STRING'), \ - #kwargs.get('HTTP_AUTHORIZATION', None) + # print kwargs.get('PATH_INFO') + '?' + kwargs.get('QUERY_STRING'), \ + # kwargs.get('HTTP_AUTHORIZATION', None) return super(OA2Client, self).request(*args, **kwargs) def get_url(self, token_or_auth, **params): @@ -199,7 +199,7 @@ def assert_access_token_response(self, r, expected): datetime.timedelta(seconds=expires_in)) self.assertEqual(token.token_type, token_type) self.assertEqual(token.grant_type, 'authorization_code') - #self.assertEqual(token.user, expected.get('user')) + # self.assertEqual(token.user, expected.get('user')) self.assertEqual(smart_str(token.redirect_uri), smart_str(expected.get('redirect_uri'))) self.assertEqual(smart_str(token.scope), @@ -310,7 +310,7 @@ def test_code_authorization(self): self.assertPath(redirect, "/handle_code") code = AuthorizationCode.objects.get(code=redirect.params['code'][0]) - #self.assertEqual(code.state, '') + # self.assertEqual(code.state, '') self.assertEqual(code.state, None) self.assertEqual(normalize(iri_to_uri(code.redirect_uri)), normalize(iri_to_uri(self.client1_redirect_uri))) @@ -376,7 +376,7 @@ def test_code_authorization(self): # redirect uri descendant redirect_uri = '%s/' % self.client3_redirect_uri rest = settings.MAXIMUM_ALLOWED_REDIRECT_URI_LENGTH - len(redirect_uri) - redirect_uri = '%s%s' % (redirect_uri, 'a'*rest) + redirect_uri = '%s%s' % (redirect_uri, 'a' * rest) params['redirect_uri'] = redirect_uri self.client.set_credentials('client3', 'secret') r = self.client.authorize_code('client3', urlparams=params) @@ -514,7 +514,7 @@ def test_get_token(self): # generate authorization code with too long redirect_uri redirect_uri = '%s/' % self.client3_redirect_uri rest = settings.MAXIMUM_ALLOWED_REDIRECT_URI_LENGTH - len(redirect_uri) - redirect_uri = '%s%s' % (redirect_uri, 'a'*rest) + redirect_uri = '%s%s' % (redirect_uri, 'a' * rest) params = {'redirect_uri': redirect_uri} r = self.client.authorize_code('client3', urlparams=params) self.assertCount(AuthorizationCode, 1) diff --git a/snf-astakos-app/astakos/oa2/urls.py b/snf-astakos-app/astakos/oa2/urls.py index ca0d20879..d9c24a61d 100644 --- a/snf-astakos-app/astakos/oa2/urls.py +++ b/snf-astakos-app/astakos/oa2/urls.py @@ -21,10 +21,7 @@ token_endpoint=settings.TOKEN_ENDPOINT, token_length=settings.TOKEN_LENGTH, token_expires=settings.TOKEN_EXPIRES, - authorization_endpoint= - settings.AUTHORIZATION_ENDPOINT, - authorization_code_length= - settings.AUTHORIZATION_CODE_LENGTH, - redirect_uri_limit= - settings.MAXIMUM_ALLOWED_REDIRECT_URI_LENGTH) + authorization_endpoint=settings.AUTHORIZATION_ENDPOINT, + authorization_code_length=settings.AUTHORIZATION_CODE_LENGTH, + redirect_uri_limit=settings.MAXIMUM_ALLOWED_REDIRECT_URI_LENGTH) urlpatterns = oa2_backend.get_url_patterns() diff --git a/snf-astakos-app/astakos/oa2/views.py b/snf-astakos-app/astakos/oa2/views.py index e8315932c..55974ce03 100644 --- a/snf-astakos-app/astakos/oa2/views.py +++ b/snf-astakos-app/astakos/oa2/views.py @@ -14,8 +14,10 @@ def auth_methods(self): def authorize(request): pass + def token(request): pass + def redirect(request): pass From 0c2ddb1ea03efeb183f487d273f74cef74d7ae1a Mon Sep 17 00:00:00 2001 From: indorilftw Date: Wed, 12 Nov 2014 11:48:34 +0200 Subject: [PATCH 12/43] PEP8 fixes on snf-astakos-app/astakos/quotaholder_app directory --- .../quotaholder_app/migrations/0001_initial.py | 7 +++---- ...g_holder__add_field_provisionlog_limit__add.py | 7 +++---- .../quotaholder_app/migrations/0003_data.py | 15 +++++++-------- ...erial__del_unique_callserial_serial_clientk.py | 7 +++---- ...5_auto__add_field_commission_issue_datetime.py | 7 +++---- .../quotaholder_app/migrations/0006_datetime.py | 2 +- .../0007_auto__del_field_commission_issue_time.py | 7 +++---- .../migrations/0008_reduce_bigint.py | 3 ++- ...uantity__chg_field_holding_usage_min__chg_f.py | 2 +- .../migrations/0010_non_accepted.py | 1 + .../migrations/0011_delete_unused_holdings.py | 3 ++- .../migrations/0012_project_holdings.py | 1 + 12 files changed, 30 insertions(+), 32 deletions(-) diff --git a/snf-astakos-app/astakos/quotaholder_app/migrations/0001_initial.py b/snf-astakos-app/astakos/quotaholder_app/migrations/0001_initial.py index 5359f42dc..8bb13b1f8 100644 --- a/snf-astakos-app/astakos/quotaholder_app/migrations/0001_initial.py +++ b/snf-astakos-app/astakos/quotaholder_app/migrations/0001_initial.py @@ -4,10 +4,11 @@ from south.v2 import SchemaMigration from django.db import models + class Migration(SchemaMigration): def forwards(self, orm): - + # Adding model 'Holder' db.create_table('quotaholder_app_holder', ( ('attribute', self.gf('django.db.models.fields.CharField')(max_length=4096, primary_key=True)), @@ -117,9 +118,8 @@ def forwards(self, orm): # Adding unique constraint on 'CallSerial', fields ['serial', 'clientkey'] db.create_unique('quotaholder_app_callserial', ['serial', 'clientkey']) - def backwards(self, orm): - + # Removing unique constraint on 'CallSerial', fields ['serial', 'clientkey'] db.delete_unique('quotaholder_app_callserial', ['serial', 'clientkey']) @@ -150,7 +150,6 @@ def backwards(self, orm): # Deleting model 'CallSerial' db.delete_table('quotaholder_app_callserial') - models = { 'quotaholder_app.callserial': { 'Meta': {'unique_together': "(('serial', 'clientkey'),)", 'object_name': 'CallSerial'}, diff --git a/snf-astakos-app/astakos/quotaholder_app/migrations/0002_auto__add_field_provisionlog_holder__add_field_provisionlog_limit__add.py b/snf-astakos-app/astakos/quotaholder_app/migrations/0002_auto__add_field_provisionlog_holder__add_field_provisionlog_limit__add.py index b645a8200..a26e43253 100644 --- a/snf-astakos-app/astakos/quotaholder_app/migrations/0002_auto__add_field_provisionlog_holder__add_field_provisionlog_limit__add.py +++ b/snf-astakos-app/astakos/quotaholder_app/migrations/0002_auto__add_field_provisionlog_holder__add_field_provisionlog_limit__add.py @@ -4,10 +4,11 @@ from south.v2 import SchemaMigration from django.db import models + class Migration(SchemaMigration): def forwards(self, orm): - + # Adding field 'ProvisionLog.holder' db.add_column('quotaholder_app_provisionlog', 'holder', self.gf('django.db.models.fields.CharField')(default='', max_length=4096), keep_default=False) @@ -41,9 +42,8 @@ def forwards(self, orm): # Adding field 'Provision.source' db.add_column('quotaholder_app_provision', 'source', self.gf('django.db.models.fields.CharField')(max_length=4096, null=True), keep_default=False) - def backwards(self, orm): - + # Deleting field 'ProvisionLog.holder' db.delete_column('quotaholder_app_provisionlog', 'holder') @@ -77,7 +77,6 @@ def backwards(self, orm): # Deleting field 'Provision.source' db.delete_column('quotaholder_app_provision', 'source') - models = { 'quotaholder_app.callserial': { 'Meta': {'unique_together': "(('serial', 'clientkey'),)", 'object_name': 'CallSerial'}, diff --git a/snf-astakos-app/astakos/quotaholder_app/migrations/0003_data.py b/snf-astakos-app/astakos/quotaholder_app/migrations/0003_data.py index 178244ad1..496b45add 100644 --- a/snf-astakos-app/astakos/quotaholder_app/migrations/0003_data.py +++ b/snf-astakos-app/astakos/quotaholder_app/migrations/0003_data.py @@ -5,6 +5,7 @@ from django.db import models from django.db.models import F + class Migration(DataMigration): def forwards(self, orm): @@ -15,10 +16,10 @@ def forwards(self, orm): # Populate new fields holdings = orm.Holding.objects.all().select_related() holdings.update(source="system") - holdings.update(usage_min=F('imported')-F('exporting')+ - F('returned')-F('releasing')) - holdings.update(usage_max=F('importing')-F('exported')+ - F('returning')-F('released')) + holdings.update(usage_min=F('imported') - F('exporting') + + F('returned') - F('releasing')) + holdings.update(usage_max=F('importing') - F('exported') + + F('returning') - F('released')) for holding in holdings: holding.holder = holding.entity.entity @@ -42,18 +43,16 @@ def forwards(self, orm): plogs.update(holder=F('target')) plogs.update(source="system") plogs.update(limit=F('target_capacity')) - plogs.update(usage_min=F('target_imported')-F('target_exported')+ - F('target_returned')-F('target_released')) + plogs.update(usage_min=F('target_imported') - F('target_exported') + + F('target_returned') - F('target_released')) plogs.update(usage_max=F('usage_min')) pl_pith = orm.ProvisionLog.objects.filter(resource="pithos+.diskspace") pl_pith.update(resource="pithos.diskspace") - def backwards(self, orm): "Write your backwards methods here." - models = { 'quotaholder_app.callserial': { 'Meta': {'unique_together': "(('serial', 'clientkey'),)", 'object_name': 'CallSerial'}, diff --git a/snf-astakos-app/astakos/quotaholder_app/migrations/0004_auto__del_holder__del_callserial__del_unique_callserial_serial_clientk.py b/snf-astakos-app/astakos/quotaholder_app/migrations/0004_auto__del_holder__del_callserial__del_unique_callserial_serial_clientk.py index 07efbefbe..2f69eee7e 100644 --- a/snf-astakos-app/astakos/quotaholder_app/migrations/0004_auto__del_holder__del_callserial__del_unique_callserial_serial_clientk.py +++ b/snf-astakos-app/astakos/quotaholder_app/migrations/0004_auto__del_holder__del_callserial__del_unique_callserial_serial_clientk.py @@ -4,10 +4,11 @@ from south.v2 import SchemaMigration from django.db import models + class Migration(SchemaMigration): def forwards(self, orm): - + # Removing unique constraint on 'Holding', fields ['resource', 'entity'] db.delete_unique('quotaholder_app_holding', ['resource', 'entity_id']) @@ -125,9 +126,8 @@ def forwards(self, orm): # Deleting field 'Provision.entity' db.delete_column('quotaholder_app_provision', 'entity_id') - def backwards(self, orm): - + # Removing unique constraint on 'Holding', fields ['resource', 'source', 'holder'] db.delete_unique('quotaholder_app_holding', ['resource', 'source', 'holder']) @@ -267,7 +267,6 @@ def backwards(self, orm): # User chose to not deal with backwards NULL issues for 'Provision.entity' raise RuntimeError("Cannot reverse this migration. 'Provision.entity' and its values cannot be restored.") - models = { 'quotaholder_app.commission': { 'Meta': {'object_name': 'Commission'}, diff --git a/snf-astakos-app/astakos/quotaholder_app/migrations/0005_auto__add_field_commission_issue_datetime.py b/snf-astakos-app/astakos/quotaholder_app/migrations/0005_auto__add_field_commission_issue_datetime.py index 2da738d64..2d9752887 100644 --- a/snf-astakos-app/astakos/quotaholder_app/migrations/0005_auto__add_field_commission_issue_datetime.py +++ b/snf-astakos-app/astakos/quotaholder_app/migrations/0005_auto__add_field_commission_issue_datetime.py @@ -4,20 +4,19 @@ from south.v2 import SchemaMigration from django.db import models + class Migration(SchemaMigration): def forwards(self, orm): - + # Adding field 'Commission.issue_datetime' db.add_column('quotaholder_app_commission', 'issue_datetime', self.gf('django.db.models.fields.DateTimeField')(default=datetime.datetime(2013, 1, 1, 0, 0, 0)), keep_default=False) - def backwards(self, orm): - + # Deleting field 'Commission.issue_datetime' db.delete_column('quotaholder_app_commission', 'issue_datetime') - models = { 'quotaholder_app.commission': { 'Meta': {'object_name': 'Commission'}, diff --git a/snf-astakos-app/astakos/quotaholder_app/migrations/0006_datetime.py b/snf-astakos-app/astakos/quotaholder_app/migrations/0006_datetime.py index 5a7065c73..50e80aee3 100644 --- a/snf-astakos-app/astakos/quotaholder_app/migrations/0006_datetime.py +++ b/snf-astakos-app/astakos/quotaholder_app/migrations/0006_datetime.py @@ -4,6 +4,7 @@ from south.v2 import DataMigration from django.db import models + class Migration(DataMigration): def forwards(self, orm): @@ -18,7 +19,6 @@ def forwards(self, orm): def backwards(self, orm): "Write your backwards methods here." - models = { 'quotaholder_app.commission': { 'Meta': {'object_name': 'Commission'}, diff --git a/snf-astakos-app/astakos/quotaholder_app/migrations/0007_auto__del_field_commission_issue_time.py b/snf-astakos-app/astakos/quotaholder_app/migrations/0007_auto__del_field_commission_issue_time.py index 0a8855bf4..b06e82161 100644 --- a/snf-astakos-app/astakos/quotaholder_app/migrations/0007_auto__del_field_commission_issue_time.py +++ b/snf-astakos-app/astakos/quotaholder_app/migrations/0007_auto__del_field_commission_issue_time.py @@ -4,20 +4,19 @@ from south.v2 import SchemaMigration from django.db import models + class Migration(SchemaMigration): def forwards(self, orm): - + # Deleting field 'Commission.issue_time' db.delete_column('quotaholder_app_commission', 'issue_time') - def backwards(self, orm): - + # User chose to not deal with backwards NULL issues for 'Commission.issue_time' raise RuntimeError("Cannot reverse this migration. 'Commission.issue_time' and its values cannot be restored.") - models = { 'quotaholder_app.commission': { 'Meta': {'object_name': 'Commission'}, diff --git a/snf-astakos-app/astakos/quotaholder_app/migrations/0008_reduce_bigint.py b/snf-astakos-app/astakos/quotaholder_app/migrations/0008_reduce_bigint.py index ac8f36c74..02a519feb 100644 --- a/snf-astakos-app/astakos/quotaholder_app/migrations/0008_reduce_bigint.py +++ b/snf-astakos-app/astakos/quotaholder_app/migrations/0008_reduce_bigint.py @@ -4,7 +4,8 @@ from south.v2 import DataMigration from django.db import models -MAX = 2**63 - 1 +MAX = 2 ** 63 - 1 + class Migration(DataMigration): diff --git a/snf-astakos-app/astakos/quotaholder_app/migrations/0009_auto__chg_field_provision_quantity__chg_field_holding_usage_min__chg_f.py b/snf-astakos-app/astakos/quotaholder_app/migrations/0009_auto__chg_field_provision_quantity__chg_field_holding_usage_min__chg_f.py index ddd248b29..fdf6f63b9 100644 --- a/snf-astakos-app/astakos/quotaholder_app/migrations/0009_auto__chg_field_provision_quantity__chg_field_holding_usage_min__chg_f.py +++ b/snf-astakos-app/astakos/quotaholder_app/migrations/0009_auto__chg_field_provision_quantity__chg_field_holding_usage_min__chg_f.py @@ -104,4 +104,4 @@ def backwards(self, orm): } } - complete_apps = ['quotaholder_app'] \ No newline at end of file + complete_apps = ['quotaholder_app'] diff --git a/snf-astakos-app/astakos/quotaholder_app/migrations/0010_non_accepted.py b/snf-astakos-app/astakos/quotaholder_app/migrations/0010_non_accepted.py index 4e275ef7c..a2037fa81 100644 --- a/snf-astakos-app/astakos/quotaholder_app/migrations/0010_non_accepted.py +++ b/snf-astakos-app/astakos/quotaholder_app/migrations/0010_non_accepted.py @@ -4,6 +4,7 @@ from south.v2 import DataMigration from django.db import models + class Migration(DataMigration): depends_on = ( diff --git a/snf-astakos-app/astakos/quotaholder_app/migrations/0011_delete_unused_holdings.py b/snf-astakos-app/astakos/quotaholder_app/migrations/0011_delete_unused_holdings.py index 790769517..5fb2f807c 100644 --- a/snf-astakos-app/astakos/quotaholder_app/migrations/0011_delete_unused_holdings.py +++ b/snf-astakos-app/astakos/quotaholder_app/migrations/0011_delete_unused_holdings.py @@ -4,11 +4,12 @@ from south.v2 import DataMigration from django.db import models + class Migration(DataMigration): depends_on = ( ("im", "0062_accept_with_usage.py"), - ) + ) def forwards(self, orm): AstakosUser = orm["im.astakosuser"] diff --git a/snf-astakos-app/astakos/quotaholder_app/migrations/0012_project_holdings.py b/snf-astakos-app/astakos/quotaholder_app/migrations/0012_project_holdings.py index 24f7c54cd..2b726973a 100644 --- a/snf-astakos-app/astakos/quotaholder_app/migrations/0012_project_holdings.py +++ b/snf-astakos-app/astakos/quotaholder_app/migrations/0012_project_holdings.py @@ -4,6 +4,7 @@ from south.v2 import DataMigration from django.db import models + def _partition_by(f, l): d = {} for x in l: From 5d61b92cb2c12f28df99c2bf4b8772cac3218d8c Mon Sep 17 00:00:00 2001 From: indorilftw Date: Wed, 12 Nov 2014 11:49:10 +0200 Subject: [PATCH 13/43] PEP8 fixes on snf-astakos-app/astakos directory --- snf-astakos-app/astakos/synnefo_settings.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snf-astakos-app/astakos/synnefo_settings.py b/snf-astakos-app/astakos/synnefo_settings.py index 27f16ac5a..46527e1d2 100644 --- a/snf-astakos-app/astakos/synnefo_settings.py +++ b/snf-astakos-app/astakos/synnefo_settings.py @@ -69,7 +69,7 @@ CUSTOM_USER_MODEL = 'astakos.im.AstakosUser' -#SOUTH_TESTS_MIGRATE = False +# SOUTH_TESTS_MIGRATE = False BROKER_URL = '' From cbbc3da5dc0709f831d2a9628726d8c475b4a767 Mon Sep 17 00:00:00 2001 From: indorilftw Date: Wed, 12 Nov 2014 11:50:36 +0200 Subject: [PATCH 14/43] PEP8 fixes on snf-branding directory --- snf-branding/distribute_setup.py | 32 ++++++++++++------- snf-branding/setup.py | 31 +++++++++--------- .../synnefo_branding/context_processors.py | 3 +- snf-branding/synnefo_branding/settings.py | 18 +++++------ .../synnefo_branding/synnefo_settings.py | 4 +-- 5 files changed, 49 insertions(+), 39 deletions(-) diff --git a/snf-branding/distribute_setup.py b/snf-branding/distribute_setup.py index 10d66840a..14c8b0b11 100644 --- a/snf-branding/distribute_setup.py +++ b/snf-branding/distribute_setup.py @@ -144,17 +144,17 @@ def use_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL, except ImportError: return _do_download(version, download_base, to_dir, download_delay) try: - pkg_resources.require("distribute>="+version) + pkg_resources.require("distribute>=" + version) return except pkg_resources.VersionConflict: e = sys.exc_info()[1] if was_imported: sys.stderr.write( - "The required version of distribute (>=%s) is not available,\n" - "and can't be installed while this script is running. Please\n" - "install a more recent version first, using\n" - "'easy_install -U distribute'." - "\n\n(Currently using %r)\n" % (version, e.args[0])) + "The required version of distribute (>=%s) is not available,\n" + "and can't be installed while this script is running. Please\n" + "install a more recent version first, using\n" + "'easy_install -U distribute'." + "\n\n(Currently using %r)\n" % (version, e.args[0])) sys.exit(2) else: del pkg_resources, sys.modules['pkg_resources'] # reload ok @@ -167,6 +167,7 @@ def use_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL, if not no_fake: _create_fake_setuptools_pkg_info(to_dir) + def download_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL, to_dir=os.curdir, delay=15): """Download distribute from a specified location and return its filename @@ -203,6 +204,7 @@ def download_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL, dst.close() return os.path.realpath(saveto) + def _no_sandbox(function): def __no_sandbox(*args, **kw): try: @@ -227,6 +229,7 @@ def violation(*args): return __no_sandbox + def _patch_file(path, content): """Will backup the file then patch it""" existing_content = open(path).read() @@ -245,15 +248,18 @@ def _patch_file(path, content): _patch_file = _no_sandbox(_patch_file) + def _same_content(path, content): return open(path).read() == content + def _rename_path(path): new_name = path + '.OLD.%s' % time.time() log.warn('Renaming %s into %s', path, new_name) os.rename(path, new_name) return new_name + def _remove_flat_installation(placeholder): if not os.path.isdir(placeholder): log.warn('Unkown installation at %s', placeholder) @@ -289,18 +295,20 @@ def _remove_flat_installation(placeholder): _remove_flat_installation = _no_sandbox(_remove_flat_installation) + def _after_install(dist): log.warn('After install bootstrap.') placeholder = dist.get_command_obj('install').install_purelib _create_fake_setuptools_pkg_info(placeholder) + def _create_fake_setuptools_pkg_info(placeholder): if not placeholder or not os.path.exists(placeholder): log.warn('Could not find the install location') return pyver = '%s.%s' % (sys.version_info[0], sys.version_info[1]) setuptools_file = 'setuptools-%s-py%s.egg-info' % \ - (SETUPTOOLS_FAKED_VERSION, pyver) + (SETUPTOOLS_FAKED_VERSION, pyver) pkg_info = os.path.join(placeholder, setuptools_file) if os.path.exists(pkg_info): log.warn('%s already exists', pkg_info) @@ -323,6 +331,7 @@ def _create_fake_setuptools_pkg_info(placeholder): _create_fake_setuptools_pkg_info = _no_sandbox(_create_fake_setuptools_pkg_info) + def _patch_egg_dir(path): # let's check if it's already patched pkg_info = os.path.join(path, 'EGG-INFO', 'PKG-INFO') @@ -343,6 +352,7 @@ def _patch_egg_dir(path): _patch_egg_dir = _no_sandbox(_patch_egg_dir) + def _before_install(): log.warn('Before install bootstrap.') _fake_setuptools() @@ -351,7 +361,7 @@ def _before_install(): def _under_prefix(location): if 'install' not in sys.argv: return True - args = sys.argv[sys.argv.index('install')+1:] + args = sys.argv[sys.argv.index('install') + 1:] for index, arg in enumerate(args): for option in ('--root', '--prefix'): if arg.startswith('%s=' % option): @@ -359,7 +369,7 @@ def _under_prefix(location): return location.startswith(top_dir) elif arg == option: if len(args) > index: - top_dir = args[index+1] + top_dir = args[index + 1] return location.startswith(top_dir) if arg == '--user' and USER_SITE is not None: return location.startswith(USER_SITE) @@ -406,7 +416,7 @@ def _fake_setuptools(): log.warn('Egg installation') pkg_info = os.path.join(setuptools_location, 'EGG-INFO', 'PKG-INFO') if (os.path.exists(pkg_info) and - _same_content(pkg_info, SETUPTOOLS_PKG_INFO)): + _same_content(pkg_info, SETUPTOOLS_PKG_INFO)): log.warn('Already patched.') return log.warn('Patching...') @@ -448,7 +458,7 @@ def _extractall(self, path=".", members=None): # Extract directories with a safe mode. directories.append(tarinfo) tarinfo = copy.copy(tarinfo) - tarinfo.mode = 448 # decimal for oct 0700 + tarinfo.mode = 448 # decimal for oct 0700 self.extract(tarinfo, path) # Reverse sort directories. diff --git a/snf-branding/setup.py b/snf-branding/setup.py index f9977468e..ee28e2e99 100644 --- a/snf-branding/setup.py +++ b/snf-branding/setup.py @@ -54,13 +54,15 @@ # Note: you may want to copy this into your setup.py file verbatim, as # you can't import this from another package, when you don't know if # that package is installed yet. + + def find_package_data( - where=".", - package="", - exclude=standard_exclude, - exclude_directories=standard_exclude_directories, - only_in_packages=True, - show_ignored=False): + where=".", + package="", + exclude=standard_exclude, + exclude_directories=standard_exclude_directories, + only_in_packages=True, + show_ignored=False): """ Return a dictionary suitable for use in ``package_data`` in a distutils ``setup.py`` file. @@ -96,8 +98,7 @@ def find_package_data( if os.path.isdir(fn): bad_name = False for pattern in exclude_directories: - if (fnmatchcase(name, pattern) - or fn.lower() == pattern.lower()): + if (fnmatchcase(name, pattern) or fn.lower() == pattern.lower()): bad_name = True if show_ignored: print >> sys.stderr, ( @@ -106,8 +107,7 @@ def find_package_data( break if bad_name: continue - if (os.path.isfile(os.path.join(fn, "__init__.py")) - and not prefix): + if (os.path.isfile(os.path.join(fn, "__init__.py")) and not prefix): if not package: new_package = name else: @@ -119,8 +119,7 @@ def find_package_data( # is a file bad_name = False for pattern in exclude: - if (fnmatchcase(name, pattern) - or fn.lower() == pattern.lower()): + if (fnmatchcase(name, pattern) or fn.lower() == pattern.lower()): bad_name = True if show_ignored: print >> sys.stderr, ( @@ -129,7 +128,7 @@ def find_package_data( break if bad_name: continue - out.setdefault(package, []).append(prefix+name) + out.setdefault(package, []).append(prefix + name) return out setup( name='snf-branding', @@ -155,9 +154,9 @@ def find_package_data( dependency_links=['http://docs.dev.grnet.gr/pypi'], entry_points={ 'synnefo': [ - 'web_apps = synnefo_branding.synnefo_settings:installed_apps', - 'web_context_processors = synnefo_branding.synnefo_settings:context_processors', - 'web_static = synnefo_branding.synnefo_settings:static_files', + 'web_apps = synnefo_branding.synnefo_settings:installed_apps', + 'web_context_processors = synnefo_branding.synnefo_settings:context_processors', + 'web_static = synnefo_branding.synnefo_settings:static_files', ] } ) diff --git a/snf-branding/synnefo_branding/context_processors.py b/snf-branding/synnefo_branding/context_processors.py index 6649f5fa4..027066129 100644 --- a/snf-branding/synnefo_branding/context_processors.py +++ b/snf-branding/synnefo_branding/context_processors.py @@ -15,5 +15,6 @@ from synnefo_branding import utils + def branding(request): - return utils.get_branding_dict("BRANDING") \ No newline at end of file + return utils.get_branding_dict("BRANDING") diff --git a/snf-branding/synnefo_branding/settings.py b/snf-branding/synnefo_branding/settings.py index ddc1b698f..6634e7320 100644 --- a/snf-branding/synnefo_branding/settings.py +++ b/snf-branding/synnefo_branding/settings.py @@ -2,7 +2,7 @@ from synnefo.util.version import get_component_version import datetime -## Service and company names/urls +# Service and company names/urls ###################### SERVICE_NAME = getattr(settings, 'BRANDING_SERVICE_NAME', 'Synnefo') @@ -13,30 +13,30 @@ 'https://www.grnet.gr/en/') -## Images +# Images ###################### # The default path to the folder that contains all branding images IMAGE_MEDIA_URL = getattr(settings, 'BRANDING_IMAGE_MEDIA_URL', - settings.MEDIA_URL+'branding/images/') + settings.MEDIA_URL + 'branding/images/') # The service favicon FAVICON_URL = getattr(settings, 'BRANDING_FAVICON_URL', - IMAGE_MEDIA_URL+'favicon.ico') + IMAGE_MEDIA_URL + 'favicon.ico') # Logo used in Dashboard pages (Astakos) DASHBOARD_LOGO_URL = getattr(settings, 'BRANDING_DASHBOARD_LOGO_URL', - IMAGE_MEDIA_URL+'dashboard_logo.png') + IMAGE_MEDIA_URL + 'dashboard_logo.png') # Logo used in Compute pages (Cyclades) COMPUTE_LOGO_URL = getattr(settings, 'BRANDING_COMPUTE_LOGO_URL', - IMAGE_MEDIA_URL+'compute_logo.png') + IMAGE_MEDIA_URL + 'compute_logo.png') # Logo used in Console page for VM (Cyclades) CONSOLE_LOGO_URL = getattr(settings, 'BRANDING_CONSOLE_LOGO_URL', - IMAGE_MEDIA_URL+'console_logo.png') + IMAGE_MEDIA_URL + 'console_logo.png') # Logo used in Storage pages (Pithos) STORAGE_LOGO_URL = getattr(settings, 'BRANDING_STORAGE_LOGO_URL', - IMAGE_MEDIA_URL+'storage_logo.png') + IMAGE_MEDIA_URL + 'storage_logo.png') -## Copyright and footer options +# Copyright and footer options ###################### # If True, Copyright message will appear at the footer of the Compute and diff --git a/snf-branding/synnefo_branding/synnefo_settings.py b/snf-branding/synnefo_branding/synnefo_settings.py index 660ab592c..15ef26949 100644 --- a/snf-branding/synnefo_branding/synnefo_settings.py +++ b/snf-branding/synnefo_branding/synnefo_settings.py @@ -19,6 +19,6 @@ Django settings metadata. To be used in setup.py snf-webproject entry points. """ -installed_apps = ['synnefo_branding'] +installed_apps = ['synnefo_branding'] context_processors = ['synnefo_branding.context_processors.branding'] -static_files = {'synnefo_branding': ''} \ No newline at end of file +static_files = {'synnefo_branding': ''} From 194284e8a25188660de7b8c72be2e19030c96cc4 Mon Sep 17 00:00:00 2001 From: indorilftw Date: Wed, 12 Nov 2014 11:52:19 +0200 Subject: [PATCH 15/43] PEP8 fixes on snf-common directory --- snf-common/distribute_setup.py | 34 ++++--- snf-common/synnefo/lib/amqp/amqp_haigha.py | 2 +- snf-common/synnefo/lib/dictconfig.py | 107 +++++++++++---------- snf-common/synnefo/lib/ordereddict.py | 3 +- snf-common/synnefo/util/urltools.py | 24 ++--- 5 files changed, 90 insertions(+), 80 deletions(-) diff --git a/snf-common/distribute_setup.py b/snf-common/distribute_setup.py index 10d66840a..c933b1d0b 100644 --- a/snf-common/distribute_setup.py +++ b/snf-common/distribute_setup.py @@ -144,17 +144,17 @@ def use_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL, except ImportError: return _do_download(version, download_base, to_dir, download_delay) try: - pkg_resources.require("distribute>="+version) + pkg_resources.require("distribute>=" + version) return except pkg_resources.VersionConflict: e = sys.exc_info()[1] if was_imported: sys.stderr.write( - "The required version of distribute (>=%s) is not available,\n" - "and can't be installed while this script is running. Please\n" - "install a more recent version first, using\n" - "'easy_install -U distribute'." - "\n\n(Currently using %r)\n" % (version, e.args[0])) + "The required version of distribute (>=%s) is not available,\n" + "and can't be installed while this script is running. Please\n" + "install a more recent version first, using\n" + "'easy_install -U distribute'." + "\n\n(Currently using %r)\n" % (version, e.args[0])) sys.exit(2) else: del pkg_resources, sys.modules['pkg_resources'] # reload ok @@ -167,6 +167,7 @@ def use_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL, if not no_fake: _create_fake_setuptools_pkg_info(to_dir) + def download_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL, to_dir=os.curdir, delay=15): """Download distribute from a specified location and return its filename @@ -203,6 +204,7 @@ def download_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL, dst.close() return os.path.realpath(saveto) + def _no_sandbox(function): def __no_sandbox(*args, **kw): try: @@ -227,6 +229,7 @@ def violation(*args): return __no_sandbox + def _patch_file(path, content): """Will backup the file then patch it""" existing_content = open(path).read() @@ -245,15 +248,18 @@ def _patch_file(path, content): _patch_file = _no_sandbox(_patch_file) + def _same_content(path, content): return open(path).read() == content + def _rename_path(path): new_name = path + '.OLD.%s' % time.time() log.warn('Renaming %s into %s', path, new_name) os.rename(path, new_name) return new_name + def _remove_flat_installation(placeholder): if not os.path.isdir(placeholder): log.warn('Unkown installation at %s', placeholder) @@ -289,18 +295,19 @@ def _remove_flat_installation(placeholder): _remove_flat_installation = _no_sandbox(_remove_flat_installation) + def _after_install(dist): log.warn('After install bootstrap.') placeholder = dist.get_command_obj('install').install_purelib _create_fake_setuptools_pkg_info(placeholder) + def _create_fake_setuptools_pkg_info(placeholder): if not placeholder or not os.path.exists(placeholder): log.warn('Could not find the install location') return pyver = '%s.%s' % (sys.version_info[0], sys.version_info[1]) - setuptools_file = 'setuptools-%s-py%s.egg-info' % \ - (SETUPTOOLS_FAKED_VERSION, pyver) + setuptools_file = 'setuptools-%s-py%s.egg-info' % (SETUPTOOLS_FAKED_VERSION, pyver) pkg_info = os.path.join(placeholder, setuptools_file) if os.path.exists(pkg_info): log.warn('%s already exists', pkg_info) @@ -323,6 +330,7 @@ def _create_fake_setuptools_pkg_info(placeholder): _create_fake_setuptools_pkg_info = _no_sandbox(_create_fake_setuptools_pkg_info) + def _patch_egg_dir(path): # let's check if it's already patched pkg_info = os.path.join(path, 'EGG-INFO', 'PKG-INFO') @@ -343,6 +351,7 @@ def _patch_egg_dir(path): _patch_egg_dir = _no_sandbox(_patch_egg_dir) + def _before_install(): log.warn('Before install bootstrap.') _fake_setuptools() @@ -351,7 +360,7 @@ def _before_install(): def _under_prefix(location): if 'install' not in sys.argv: return True - args = sys.argv[sys.argv.index('install')+1:] + args = sys.argv[sys.argv.index('install') + 1:] for index, arg in enumerate(args): for option in ('--root', '--prefix'): if arg.startswith('%s=' % option): @@ -359,7 +368,7 @@ def _under_prefix(location): return location.startswith(top_dir) elif arg == option: if len(args) > index: - top_dir = args[index+1] + top_dir = args[index + 1] return location.startswith(top_dir) if arg == '--user' and USER_SITE is not None: return location.startswith(USER_SITE) @@ -405,8 +414,7 @@ def _fake_setuptools(): else: log.warn('Egg installation') pkg_info = os.path.join(setuptools_location, 'EGG-INFO', 'PKG-INFO') - if (os.path.exists(pkg_info) and - _same_content(pkg_info, SETUPTOOLS_PKG_INFO)): + if (os.path.exists(pkg_info) and _same_content(pkg_info, SETUPTOOLS_PKG_INFO)): log.warn('Already patched.') return log.warn('Patching...') @@ -448,7 +456,7 @@ def _extractall(self, path=".", members=None): # Extract directories with a safe mode. directories.append(tarinfo) tarinfo = copy.copy(tarinfo) - tarinfo.mode = 448 # decimal for oct 0700 + tarinfo.mode = 448 # decimal for oct 0700 self.extract(tarinfo, path) # Reverse sort directories. diff --git a/snf-common/synnefo/lib/amqp/amqp_haigha.py b/snf-common/synnefo/lib/amqp/amqp_haigha.py index fc1b1002a..54296003e 100644 --- a/snf-common/synnefo/lib/amqp/amqp_haigha.py +++ b/snf-common/synnefo/lib/amqp/amqp_haigha.py @@ -78,7 +78,7 @@ def connect(self, retries=0): host = self.hosts.pop() self.hosts.insert(0, host) - #Patch gevent + # Patch gevent monkey.patch_all() try: diff --git a/snf-common/synnefo/lib/dictconfig.py b/snf-common/synnefo/lib/dictconfig.py index 167831bc1..8d9a35156 100644 --- a/snf-common/synnefo/lib/dictconfig.py +++ b/snf-common/synnefo/lib/dictconfig.py @@ -25,6 +25,7 @@ IDENTIFIER = re.compile('^[a-z_][a-z0-9_]*$', re.I) + def valid_ident(s): m = IDENTIFIER.match(s) if not m: @@ -58,13 +59,14 @@ def _checkLevel(level): # Each wrapper should have a configurator attribute holding the actual # configurator to use for conversion. + class ConvertingDict(dict): """A converting dictionary wrapper.""" def __getitem__(self, key): value = dict.__getitem__(self, key) result = self.configurator.convert(value) - #If the converted value is different, save for next time + # If the converted value is different, save for next time if value is not result: self[key] = result if type(result) in (ConvertingDict, ConvertingList, @@ -76,7 +78,7 @@ def __getitem__(self, key): def get(self, key, default=None): value = dict.get(self, key, default) result = self.configurator.convert(value) - #If the converted value is different, save for next time + # If the converted value is different, save for next time if value is not result: self[key] = result if type(result) in (ConvertingDict, ConvertingList, @@ -95,12 +97,13 @@ def pop(self, key, default=None): result.key = key return result + class ConvertingList(list): """A converting list wrapper.""" def __getitem__(self, key): value = list.__getitem__(self, key) result = self.configurator.convert(value) - #If the converted value is different, save for next time + # If the converted value is different, save for next time if value is not result: self[key] = result if type(result) in (ConvertingDict, ConvertingList, @@ -118,6 +121,7 @@ def pop(self, idx=-1): result.parent = self return result + class ConvertingTuple(tuple): """A converting tuple wrapper.""" def __getitem__(self, key): @@ -130,6 +134,7 @@ def __getitem__(self, key): result.key = key return result + class BaseConfigurator(object): """ The configurator base class which defines some useful defaults. @@ -143,8 +148,8 @@ class BaseConfigurator(object): DIGIT_PATTERN = re.compile(r'^\d+$') value_converters = { - 'ext' : 'ext_convert', - 'cfg' : 'cfg_convert', + 'ext': 'ext_convert', + 'cfg': 'cfg_convert', } # We might want to use a different one, e.g. importlib @@ -190,7 +195,7 @@ def cfg_convert(self, value): else: rest = rest[m.end():] d = self.config[m.groups()[0]] - #print d, rest + # print d, rest while rest: m = self.DOT_PATTERN.match(rest) if m: @@ -203,7 +208,7 @@ def cfg_convert(self, value): d = d[idx] else: try: - n = int(idx) # try as number first (most likely) + n = int(idx) # try as number first (most likely) d = d[n] except TypeError: d = d[idx] @@ -212,7 +217,7 @@ def cfg_convert(self, value): else: raise ValueError('Unable to convert ' '%r at %r' % (value, rest)) - #rest should be empty + # rest should be empty return d def convert(self, value): @@ -227,11 +232,10 @@ def convert(self, value): elif not isinstance(value, ConvertingList) and isinstance(value, list): value = ConvertingList(value) value.configurator = self - elif not isinstance(value, ConvertingTuple) and\ - isinstance(value, tuple): + elif not isinstance(value, ConvertingTuple) and isinstance(value, tuple): value = ConvertingTuple(value) value.configurator = self - elif isinstance(value, basestring): # str for py3k + elif isinstance(value, basestring): # str for py3k m = self.CONVERT_PATTERN.match(value) if m: d = m.groupdict() @@ -263,6 +267,7 @@ def as_tuple(self, value): value = tuple(value) return value + class DictConfigurator(BaseConfigurator): """ Configure logging using a dictionary-like object to describe the @@ -288,8 +293,7 @@ def configure(self): if sys.version_info[:2] == (2, 7): for name in handlers: if name not in logging._handlers: - raise ValueError('No handler found with ' - 'name %r' % name) + raise ValueError('No handler found with name %r' % name) else: try: handler = logging._handlers[name] @@ -324,8 +328,7 @@ def configure(self): formatters = config.get('formatters', EMPTY_DICT) for name in formatters: try: - formatters[name] = self.configure_formatter( - formatters[name]) + formatters[name] = self.configure_formatter(formatters[name]) except StandardError, e: raise ValueError('Unable to configure ' 'formatter %r: %s' % (name, e)) @@ -352,25 +355,25 @@ def configure(self): '%r: %s' % (name, e)) # Next, do loggers - they refer to handlers and filters - #we don't want to lose the existing loggers, - #since other threads may have pointers to them. - #existing is set to contain all existing loggers, - #and as we go through the new configuration we - #remove any which are configured. At the end, - #what's left in existing is the set of loggers - #which were in the previous configuration but - #which are not in the new configuration. + # we don't want to lose the existing loggers, + # since other threads may have pointers to them. + # existing is set to contain all existing loggers, + # and as we go through the new configuration we + # remove any which are configured. At the end, + # what's left in existing is the set of loggers + # which were in the previous configuration but + # which are not in the new configuration. root = logging.root existing = root.manager.loggerDict.keys() - #The list needs to be sorted so that we can - #avoid disabling child loggers of explicitly - #named loggers. With a sorted list it is easier - #to find the child loggers. + # The list needs to be sorted so that we can + # avoid disabling child loggers of explicitly + # named loggers. With a sorted list it is easier + # to find the child loggers. existing.sort() - #We'll keep the list of existing loggers - #which are children of named loggers here... + # We'll keep the list of existing loggers + # which are children of named loggers here... child_loggers = [] - #now set up the new ones... + # now set up the new ones... loggers = config.get('loggers', EMPTY_DICT) for name in loggers: if name in existing: @@ -378,7 +381,7 @@ def configure(self): prefixed = name + "." pflen = len(prefixed) num_existing = len(existing) - i = i + 1 # look at the entry after name + i = i + 1 # look at the entry after name while (i < num_existing) and\ (existing[i][:pflen] == prefixed): child_loggers.append(existing[i]) @@ -390,11 +393,11 @@ def configure(self): raise ValueError('Unable to configure logger ' '%r: %s' % (name, e)) - #Disable any old loggers. There's no point deleting - #them as other threads may continue to hold references - #and by disabling them, you stop them doing any logging. - #However, don't disable children of named loggers, as that's - #probably not what was intended by the user. + # Disable any old loggers. There's no point deleting + # them as other threads may continue to hold references + # and by disabling them, you stop them doing any logging. + # However, don't disable children of named loggers, as that's + # probably not what was intended by the user. for log in existing: logger = root.manager.loggerDict[log] if log in child_loggers: @@ -418,16 +421,16 @@ def configure(self): def configure_formatter(self, config): """Configure a formatter from a dictionary.""" if '()' in config: - factory = config['()'] # for use in exception handler + factory = config['()'] # for use in exception handler try: result = self.configure_custom(config) except TypeError, te: if "'format'" not in str(te): raise - #Name of parameter changed from fmt to format. - #Retry with old name. - #This is so that code can be used with older Python versions - #(e.g. by Django) + # Name of parameter changed from fmt to format. + # Retry with old name. + # This is so that code can be used with older Python versions + # (e.g. by Django) config['fmt'] = config.pop('format') config['()'] = factory result = self.configure_custom(config) @@ -472,19 +475,16 @@ def configure_handler(self, config): factory = c else: klass = self.resolve(config.pop('class')) - #Special case for handler which refers to another handler - if issubclass(klass, logging.handlers.MemoryHandler) and\ - 'target' in config: + # Special case for handler which refers to another handler + if issubclass(klass, logging.handlers.MemoryHandler) and 'target' in config: try: config['target'] = self.config['handlers'][config['target']] except StandardError, e: raise ValueError('Unable to set target handler ' '%r: %s' % (config['target'], e)) - elif issubclass(klass, logging.handlers.SMTPHandler) and\ - 'mailhost' in config: + elif issubclass(klass, logging.handlers.SMTPHandler) and 'mailhost' in config: config['mailhost'] = self.as_tuple(config['mailhost']) - elif issubclass(klass, logging.handlers.SysLogHandler) and\ - 'address' in config: + elif issubclass(klass, logging.handlers.SysLogHandler) and 'address' in config: config['address'] = self.as_tuple(config['address']) factory = klass kwargs = dict([(k, config[k]) for k in config if valid_ident(k)]) @@ -493,10 +493,10 @@ def configure_handler(self, config): except TypeError, te: if "'stream'" not in str(te): raise - #The argument name changed from strm to stream - #Retry with old name. - #This is so that code can be used with older Python versions - #(e.g. by Django) + # The argument name changed from strm to stream + # Retry with old name. + # This is so that code can be used with older Python versions + # (e.g. by Django) kwargs['strm'] = kwargs.pop('stream') result = factory(**kwargs) if formatter: @@ -523,7 +523,7 @@ def common_logger_config(self, logger, config, incremental=False): if level is not None: logger.setLevel(_checkLevel(level)) if not incremental: - #Remove any existing handlers + # Remove any existing handlers for h in logger.handlers[:]: logger.removeHandler(h) handlers = config.get('handlers', None) @@ -548,6 +548,7 @@ def configure_root(self, config, incremental=False): dictConfigClass = DictConfigurator + def dictConfig(config): """Configure logging using a dictionary.""" dictConfigClass(config).configure() diff --git a/snf-common/synnefo/lib/ordereddict.py b/snf-common/synnefo/lib/ordereddict.py index 706548513..5d917059a 100644 --- a/snf-common/synnefo/lib/ordereddict.py +++ b/snf-common/synnefo/lib/ordereddict.py @@ -22,6 +22,7 @@ from UserDict import DictMixin + # FIXME: Deprecated since Python 2.7. This class must be removed in the next # Synnefo version. class OrderedDict(dict, DictMixin): @@ -119,7 +120,7 @@ def __eq__(self, other): if isinstance(other, OrderedDict): if len(self) != len(other): return False - for p, q in zip(self.items(), other.items()): + for p, q in zip(self.items(), other.items()): if p != q: return False return True diff --git a/snf-common/synnefo/util/urltools.py b/snf-common/synnefo/util/urltools.py index 840ac4f43..fce143c8a 100644 --- a/snf-common/synnefo/util/urltools.py +++ b/snf-common/synnefo/util/urltools.py @@ -32,9 +32,9 @@ "normalize_fragment", "unquote"] -#PSL_URL = 'http://mxr.mozilla.org/mozilla-central/source/netwerk/dns/effective_tld_names.dat?raw=1' -# -#def _get_public_suffix_list(): +# PSL_URL = 'http://mxr.mozilla.org/mozilla-central/source/netwerk/dns/effective_tld_names.dat?raw=1' + +# def _get_public_suffix_list(): # """Get the public suffix list. # """ # local_psl = os.environ.get('PUBLIC_SUFFIX_LIST') @@ -48,8 +48,8 @@ # if item != '' and not item.startswith('//'): # psl.add(item) # return psl -# -#PSL = _get_public_suffix_list() + +# PSL = _get_public_suffix_list() SCHEMES = ['http', 'https', 'ftp', 'sftp', 'file', 'gopher', 'imap', 'mms', @@ -71,8 +71,8 @@ 'fragment': ' +#' } -#_hextochr = {'%02x' % i: chr(i) for i in range(256)} -#_hextochr.update({'%02X' % i: chr(i) for i in range(256)}) +# _hextochr = {'%02x' % i: chr(i) for i in range(256)} +# _hextochr.update({'%02X' % i: chr(i) for i in range(256)}) _hextochr = dict(('%02x' % i, chr(i)) for i in range(256)) _hextochr.update(dict(('%02X' % i, chr(i)) for i in range(256))) _idna_encode = lambda x: x.decode('utf-8').encode('idna') @@ -114,7 +114,7 @@ def normalize(url): return assemble(result) -#def encode(url): +# def encode(url): # """Encode URL # """ # parts = extract(url) @@ -172,7 +172,7 @@ def normalize_port(scheme, port): def normalize_path(path): """Normalize path (collapse etc.) """ - if path in ['//', '/' ,'']: + if path in ['//', '/', '']: return '/' npath = normpath(unquote(path, exceptions=UNQUOTE_EXCEPTIONS['path'])) if path[-1] == '/' and npath != '/': @@ -222,7 +222,7 @@ def unquote(text, exceptions=[]): return ''.join(res) -#def parse(url): +# def parse(url): # """Parse a URL # """ # parts = split(url) @@ -235,7 +235,7 @@ def unquote(text, exceptions=[]): # port, parts.path, parts.query, parts.fragment) -#def extract(url): +# def extract(url): # """Extract as much information from a (relative) URL as possible # """ # parts = split(url) @@ -341,7 +341,7 @@ def split_netloc(netloc): return username, password, host, port -#def split_host(host): +# def split_host(host): # """Use the Public Suffix List to split host into subdomain, domain and tld # """ # if '[' in host: From 5cbf36c7b218952acef8b9a0534eba2235c2259c Mon Sep 17 00:00:00 2001 From: indorilftw Date: Wed, 12 Nov 2014 11:53:02 +0200 Subject: [PATCH 16/43] PEP8 fixes on snf-cyclades-app/synnefo/admin directory --- snf-cyclades-app/synnefo/admin/stats.py | 1 + 1 file changed, 1 insertion(+) diff --git a/snf-cyclades-app/synnefo/admin/stats.py b/snf-cyclades-app/synnefo/admin/stats.py index e62d6865a..b90e7171c 100644 --- a/snf-cyclades-app/synnefo/admin/stats.py +++ b/snf-cyclades-app/synnefo/admin/stats.py @@ -179,6 +179,7 @@ def get_ip_pool_stats(): GROUP BY is_system, osfamily, os """ + def get_image_stats(backend=None): cursor = connection.cursor() cursor.execute(IMAGES_QUERY) From ffc2a65dede16a3edf32f9a5b1bd9f926a37fd29 Mon Sep 17 00:00:00 2001 From: indorilftw Date: Wed, 12 Nov 2014 11:53:27 +0200 Subject: [PATCH 17/43] PEP8 fixes on snf-cyclades-app/synnefo/api directory --- snf-cyclades-app/synnefo/api/floating_ips.py | 18 +- snf-cyclades-app/synnefo/api/ports.py | 15 +- snf-cyclades-app/synnefo/api/subnets.py | 2 +- snf-cyclades-app/synnefo/api/tests/images.py | 246 +++++++++--------- snf-cyclades-app/synnefo/api/tests/ports.py | 40 +-- snf-cyclades-app/synnefo/api/tests/servers.py | 2 +- 6 files changed, 163 insertions(+), 160 deletions(-) diff --git a/snf-cyclades-app/synnefo/api/floating_ips.py b/snf-cyclades-app/synnefo/api/floating_ips.py index b80b15f82..395e1344c 100644 --- a/snf-cyclades-app/synnefo/api/floating_ips.py +++ b/snf-cyclades-app/synnefo/api/floating_ips.py @@ -204,22 +204,22 @@ def release_floating_ip(request, floating_ip_id): def update_floating_ip(request, floating_ip_id): """Update a floating IP.""" raise faults.NotImplemented("Updating a floating IP is not supported.") - #userid = request.user_uniq - #log.info("update_floating_ip '%s'. User '%s'.", floating_ip_id, userid) + # userid = request.user_uniq + # log.info("update_floating_ip '%s'. User '%s'.", floating_ip_id, userid) - #req = utils.get_json_body(request) - #info = api.utils.get_attribute(req, "floatingip", required=True) + # req = utils.get_json_body(request) + # info = api.utils.get_attribute(req, "floatingip", required=True) - #device_id = api.utils.get_attribute(info, "device_id", required=False) + # device_id = api.utils.get_attribute(info, "device_id", required=False) - #floating_ip = util.get_floating_ip_by_id(userid, floating_ip_id, + # floating_ip = util.get_floating_ip_by_id(userid, floating_ip_id, # for_update=True) - #if device_id: + # if device_id: # # attach # vm = util.get_vm(device_id, userid) # nic, floating_ip = servers.create_nic(vm, ipaddress=floating_ip) # backend.connect_to_network(vm, nic) - #else: + # else: # # dettach # nic = floating_ip.nic # if not nic: @@ -227,7 +227,7 @@ def update_floating_ip(request, floating_ip_id): # with any device") # vm = nic.machine # servers.disconnect(vm, nic) - #return HttpResponse(status=202) + # return HttpResponse(status=202) # Floating IP pools diff --git a/snf-cyclades-app/synnefo/api/ports.py b/snf-cyclades-app/synnefo/api/ports.py index 7beea1987..2f2121e90 100644 --- a/snf-cyclades-app/synnefo/api/ports.py +++ b/snf-cyclades-app/synnefo/api/ports.py @@ -13,7 +13,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -#from django.conf import settings +# from django.conf import settings import ipaddr from django.conf.urls import patterns from django.http import HttpResponse @@ -153,7 +153,7 @@ def create_port(request): "security_groups", required=False, attr_type=list) - #validate security groups + # validate security groups # like get security group from db sg_list = [] if security_groups: @@ -200,7 +200,7 @@ def update_port(request, port_id): if security_groups: sg_list = [] - #validate security groups + # validate security groups for gid in security_groups: try: sg = util.get_security_group(int(gid)) @@ -208,10 +208,10 @@ def update_port(request, port_id): raise faults.BadRequest("Invalid 'security_groups' field.") sg_list.append(sg) - #clear the old security groups + # clear the old security groups port.security_groups.clear() - #add the new groups + # add the new groups port.security_groups.add(*sg_list) port.save() @@ -238,9 +238,8 @@ def delete_port(request, port_id): servers.delete_port(port) return HttpResponse(status=204) -#util functions - +# Utility functions def port_to_dict(port, detail=True): d = {'id': str(port.id), 'name': port.name} d['links'] = util.port_to_links(port.id) @@ -263,7 +262,7 @@ def port_to_dict(port, detail=True): d['fixed_ips'].append({"ip_address": ip.address, "subnet": str(ip.subnet_id)}) # Avoid extra queries until security groups are implemented! - #sg_list = list(port.security_groups.values_list('id', flat=True)) + # sg_list = list(port.security_groups.values_list('id', flat=True)) d['security_groups'] = [] return d diff --git a/snf-cyclades-app/synnefo/api/subnets.py b/snf-cyclades-app/synnefo/api/subnets.py index 4a8de2a9c..56d5c920a 100644 --- a/snf-cyclades-app/synnefo/api/subnets.py +++ b/snf-cyclades-app/synnefo/api/subnets.py @@ -191,7 +191,7 @@ def update_subnet(request, sub_id): return HttpResponse(data, status=200) -#Utility functions +# Utility functions def subnet_to_dict(subnet): """Returns a dictionary containing the info of a subnet""" dns = check_empty_lists(subnet.dns_nameservers) diff --git a/snf-cyclades-app/synnefo/api/tests/images.py b/snf-cyclades-app/synnefo/api/tests/images.py index f7ed231ef..7188cce82 100644 --- a/snf-cyclades-app/synnefo/api/tests/images.py +++ b/snf-cyclades-app/synnefo/api/tests/images.py @@ -63,70 +63,71 @@ def test_list_images(self, mimage): @assert_backend_closed def test_list_images_detail(self, mimage): self.maxDiff = None - images = [{'id': 1, - 'name': u'image-1 \u2601', - 'status': 'available', - 'created_at': '2012-11-26 11:52:54', - 'updated_at': '2012-12-26 11:52:54', - 'owner': 'user1', - 'deleted_at': '', - 'is_snapshot': False, - 'is_public': True, - 'properties': {u'foo\u2610': u'bar\u2611'}}, - {'id': 2, - 'name': 'image-2', - 'status': 'deleted', - 'created_at': '2012-11-26 11:52:54', - 'updated_at': '2012-12-26 11:52:54', - 'owner': 'user1', - 'deleted_at': '2012-12-27 11:52:54', - 'is_snapshot': False, - 'is_public': True, - 'properties': ''}, - {'id': 3, - 'name': 'image-3', - 'status': 'available', - 'created_at': '2012-11-26 11:52:54', - 'deleted_at': '', - 'updated_at': '2012-12-26 11:52:54', - 'owner': 'user1', - 'is_snapshot': False, - 'is_public': False, - 'properties': ''}] + images = [ + {'id': 1, + 'name': u'image-1 \u2601', + 'status': 'available', + 'created_at': '2012-11-26 11:52:54', + 'updated_at': '2012-12-26 11:52:54', + 'owner': 'user1', + 'deleted_at': '', + 'is_snapshot': False, + 'is_public': True, + 'properties': {u'foo\u2610': u'bar\u2611'}}, + {'id': 2, + 'name': 'image-2', + 'status': 'deleted', + 'created_at': '2012-11-26 11:52:54', + 'updated_at': '2012-12-26 11:52:54', + 'owner': 'user1', + 'deleted_at': '2012-12-27 11:52:54', + 'is_snapshot': False, + 'is_public': True, + 'properties': ''}, + {'id': 3, + 'name': 'image-3', + 'status': 'available', + 'created_at': '2012-11-26 11:52:54', + 'deleted_at': '', + 'updated_at': '2012-12-26 11:52:54', + 'owner': 'user1', + 'is_snapshot': False, + 'is_public': False, + 'properties': ''}] result_images = [ - {'id': 1, - 'name': u'image-1 \u2601', - 'status': 'ACTIVE', - 'progress': 100, - 'created': '2012-11-26T11:52:54+00:00', - 'updated': '2012-12-26T11:52:54+00:00', - 'user_id': 'user1', - 'tenant_id': 'user1', - 'is_snapshot': False, - 'public': True, - 'metadata': {u'foo\u2610': u'bar\u2611'}}, - {'id': 2, - 'name': 'image-2', - 'status': 'DELETED', - 'progress': 0, - 'user_id': 'user1', - 'tenant_id': 'user1', - 'created': '2012-11-26T11:52:54+00:00', - 'updated': '2012-12-26T11:52:54+00:00', - 'is_snapshot': False, - 'public': True, - 'metadata': {}}, - {'id': 3, - 'name': 'image-3', - 'status': 'ACTIVE', - 'progress': 100, - 'user_id': 'user1', - 'tenant_id': 'user1', - 'created': '2012-11-26T11:52:54+00:00', - 'updated': '2012-12-26T11:52:54+00:00', - 'is_snapshot': False, - 'public': False, - 'metadata': {}}] + {'id': 1, + 'name': u'image-1 \u2601', + 'status': 'ACTIVE', + 'progress': 100, + 'created': '2012-11-26T11:52:54+00:00', + 'updated': '2012-12-26T11:52:54+00:00', + 'user_id': 'user1', + 'tenant_id': 'user1', + 'is_snapshot': False, + 'public': True, + 'metadata': {u'foo\u2610': u'bar\u2611'}}, + {'id': 2, + 'name': 'image-2', + 'status': 'DELETED', + 'progress': 0, + 'user_id': 'user1', + 'tenant_id': 'user1', + 'created': '2012-11-26T11:52:54+00:00', + 'updated': '2012-12-26T11:52:54+00:00', + 'is_snapshot': False, + 'public': True, + 'metadata': {}}, + {'id': 3, + 'name': 'image-3', + 'status': 'ACTIVE', + 'progress': 100, + 'user_id': 'user1', + 'tenant_id': 'user1', + 'created': '2012-11-26T11:52:54+00:00', + 'updated': '2012-12-26T11:52:54+00:00', + 'is_snapshot': False, + 'public': False, + 'metadata': {}}] mimage().__enter__().list_images.return_value = images response = self.get(join_urls(IMAGES_URL, "detail"), 'user') self.assertSuccess(response) @@ -143,28 +144,28 @@ def test_list_images_detail_since(self, mimage): new_time = old_time + timedelta(seconds=0.1) sleep(0.1) images = [ - {'id': 1, - 'name': 'image-1', - 'status': 'available', - 'progress': 100, - 'created_at': old_time.isoformat(), - 'deleted_at': '', - 'updated_at': old_time.isoformat(), - 'owner': 'user1', - 'is_snapshot': False, - 'is_public': True, - 'properties': ''}, - {'id': 2, - 'name': 'image-2', - 'status': 'deleted', - 'progress': 0, - 'owner': 'user2', - 'created_at': new_time.isoformat(), - 'updated_at': new_time.isoformat(), - 'deleted_at': new_time.isoformat(), - 'is_snapshot': False, - 'is_public': False, - 'properties': ''}] + {'id': 1, + 'name': 'image-1', + 'status': 'available', + 'progress': 100, + 'created_at': old_time.isoformat(), + 'deleted_at': '', + 'updated_at': old_time.isoformat(), + 'owner': 'user1', + 'is_snapshot': False, + 'is_public': True, + 'properties': ''}, + {'id': 2, + 'name': 'image-2', + 'status': 'deleted', + 'progress': 0, + 'owner': 'user2', + 'created_at': new_time.isoformat(), + 'updated_at': new_time.isoformat(), + 'deleted_at': new_time.isoformat(), + 'is_snapshot': False, + 'is_public': False, + 'properties': ''}] mimage().__enter__().list_images.return_value = images response =\ self.get(join_urls(IMAGES_URL, 'detail?changes-since=%sUTC' % @@ -176,28 +177,29 @@ def test_list_images_detail_since(self, mimage): @assert_backend_closed def test_get_image_details(self, mimage): self.maxDiff = None - image = {'id': 42, - 'name': 'image-1', - 'status': 'available', - 'created_at': '2012-11-26 11:52:54', - 'updated_at': '2012-12-26 11:52:54', - 'deleted_at': '', - 'owner': 'user1', - 'is_snapshot': False, - 'is_public': True, - 'properties': {'foo': 'bar'}} + image = \ + {'id': 42, + 'name': 'image-1', + 'status': 'available', + 'created_at': '2012-11-26 11:52:54', + 'updated_at': '2012-12-26 11:52:54', + 'deleted_at': '', + 'owner': 'user1', + 'is_snapshot': False, + 'is_public': True, + 'properties': {'foo': 'bar'}} result_image = \ - {'id': 42, - 'name': 'image-1', - 'status': 'ACTIVE', - 'progress': 100, - 'created': '2012-11-26T11:52:54+00:00', - 'updated': '2012-12-26T11:52:54+00:00', - 'user_id': 'user1', - 'tenant_id': 'user1', - 'is_snapshot': False, - 'public': True, - 'metadata': {'foo': 'bar'}} + {'id': 42, + 'name': 'image-1', + 'status': 'ACTIVE', + 'progress': 100, + 'created': '2012-11-26T11:52:54+00:00', + 'updated': '2012-12-26T11:52:54+00:00', + 'user_id': 'user1', + 'tenant_id': 'user1', + 'is_snapshot': False, + 'public': True, + 'metadata': {'foo': 'bar'}} mimage().__enter__().get_image.return_value = image response = self.get(join_urls(IMAGES_URL, "42"), 'user') self.assertSuccess(response) @@ -255,13 +257,14 @@ def test_method_not_allowed(self, *args): @patch('synnefo.plankton.backend.PlanktonBackend') class ImageMetadataAPITest(BaseAPITest): def setUp(self): - self.image = {'id': 42, - 'name': 'image-1', - 'status': 'available', - 'created_at': '2012-11-26 11:52:54', - 'updated_at': '2012-12-26 11:52:54', - 'deleted_at': '', - 'properties': {'foo': 'bar', 'foo2': 'bar2'}} + self.image = \ + {'id': 42, + 'name': 'image-1', + 'status': 'available', + 'created_at': '2012-11-26 11:52:54', + 'updated_at': '2012-12-26 11:52:54', + 'deleted_at': '', + 'properties': {'foo': 'bar', 'foo2': 'bar2'}} self.result_image = \ {'id': 42, 'name': 'image-1', @@ -301,7 +304,7 @@ def test_delete_metadata_item(self, backend): 'user') self.assertEqual(response.status_code, 204) backend().__enter__().update_metadata\ - .assert_called_once_with('42', {'properties': {'foo2': 'bar2'}}) + .assert_called_once_with('42', {'properties': {'foo2': 'bar2'}}) @assert_backend_closed def test_create_metadata_item(self, backend): @@ -310,9 +313,10 @@ def test_create_metadata_item(self, backend): response = self.put(join_urls(IMAGES_URL, '42/metadata/foo3'), 'user', json.dumps(request), 'json') self.assertEqual(response.status_code, 201) - backend().__enter__().update_metadata.assert_called_once_with('42', - {'properties': - {'foo': 'bar', 'foo2': 'bar2', 'foo3': 'bar3'}}) + backend().__enter__().update_metadata\ + .assert_called_once_with('42', {'properties': {'foo': 'bar', + 'foo2': 'bar2', + 'foo3': 'bar3'}}) @assert_backend_closed def test_create_metadata_malformed_1(self, backend): @@ -353,10 +357,10 @@ def test_update_metadata_item(self, backend): response = self.post(join_urls(IMAGES_URL, '42/metadata'), 'user', json.dumps(request), 'json') self.assertEqual(response.status_code, 201) - backend().__enter__().update_metadata.assert_called_once_with('42', - {'properties': - {'foo': 'bar_new', 'foo2': 'bar2', 'foo4': 'bar4'} - }) + backend().__enter__().update_metadata\ + .assert_called_once_with('42', {'properties': {'foo': 'bar_new', + 'foo2': 'bar2', + 'foo4': 'bar4'}}) @assert_backend_closed def test_update_metadata_malformed(self, backend): diff --git a/snf-cyclades-app/synnefo/api/tests/ports.py b/snf-cyclades-app/synnefo/api/tests/ports.py index 7d52cd3b6..08be4d158 100644 --- a/snf-cyclades-app/synnefo/api/tests/ports.py +++ b/snf-cyclades-app/synnefo/api/tests/ports.py @@ -300,7 +300,7 @@ def test_add_nic_to_public_network(self): response = self.post(PORTS_URL, params=json.dumps(request), user=net.userid) self.assertBadRequest(response) - #self.assertFault(response, 403, 'forbidden') + # self.assertFault(response, 403, 'forbidden') def test_add_nic_malformed_2(self): user = 'userr' @@ -333,22 +333,22 @@ def test_add_nic_not_active(self): # Test that returns BuildInProgress self.assertEqual(response.status_code, 409) -# def test_add_nic_full_network(self, mrapi): -# """Test connecting VM to a full network""" -# user = 'userr' -# vm = dbmf.VirtualMachineFactory(name='yo', userid=user, -# operstate="STARTED") -# net = dbmf.NetworkFactory(state='ACTIVE', subnet='10.0.0.0/30', -# userid=user, dhcp=True) -# pool = net.get_pool() -# while not pool.empty(): -# pool.get() -# pool.save() -# pool = net.get_pool() -# self.assertTrue(pool.empty()) -# request = {'add': {'serverRef': vm.id}} -# response = self.mypost('networks/%d/action' % net.id, -# net.userid, json.dumps(request), 'json') -# # Test that returns OverLimit -# self.assertEqual(response.status_code, 413) -# self.assertFalse(mrapi.called) + # def test_add_nic_full_network(self, mrapi): + # """Test connecting VM to a full network""" + # user = 'userr' + # vm = dbmf.VirtualMachineFactory(name='yo', userid=user, + # operstate="STARTED") + # net = dbmf.NetworkFactory(state='ACTIVE', subnet='10.0.0.0/30', + # userid=user, dhcp=True) + # pool = net.get_pool() + # while not pool.empty(): + # pool.get() + # pool.save() + # pool = net.get_pool() + # self.assertTrue(pool.empty()) + # request = {'add': {'serverRef': vm.id}} + # response = self.mypost('networks/%d/action' % net.id, + # net.userid, json.dumps(request), 'json') + # # Test that returns OverLimit + # self.assertEqual(response.status_code, 413) + # self.assertFalse(mrapi.called) diff --git a/snf-cyclades-app/synnefo/api/tests/servers.py b/snf-cyclades-app/synnefo/api/tests/servers.py index f93f44378..9b3d9df15 100644 --- a/snf-cyclades-app/synnefo/api/tests/servers.py +++ b/snf-cyclades-app/synnefo/api/tests/servers.py @@ -196,7 +196,7 @@ def test_server_port_forwarding(self): def _port_from_ip(ip, base): fields = ip.split('.', 4) - return (base + 256*int(fields[2]) + int(fields[3])) + return (base + 256 * int(fields[2]) + int(fields[3])) ports = { 22: lambda ip, id, fqdn, user: From cab279c0d6202443940e43bdcd362cf06f3d3d7e Mon Sep 17 00:00:00 2001 From: indorilftw Date: Wed, 12 Nov 2014 11:53:59 +0200 Subject: [PATCH 18/43] PEP8 fixes on snf-cyclades-app/synnefo/app_settings directory --- snf-cyclades-app/synnefo/app_settings/default/api.py | 4 ++-- snf-cyclades-app/synnefo/app_settings/default/helpdesk.py | 2 +- snf-cyclades-app/synnefo/app_settings/default/plankton.py | 2 +- snf-cyclades-app/synnefo/app_settings/default/tests.py | 5 +++-- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/snf-cyclades-app/synnefo/app_settings/default/api.py b/snf-cyclades-app/synnefo/app_settings/default/api.py index 2d8bdc746..9f39e5707 100644 --- a/snf-cyclades-app/synnefo/app_settings/default/api.py +++ b/snf-cyclades-app/synnefo/app_settings/default/api.py @@ -146,10 +146,10 @@ # the external address 'gate.example.synnefo.org' and port 60000+server_id. # e.g. iptables -t nat -A prerouting -d gate.example.synnefo.org \ # --dport (61000 + $(VM_ID)) -j DNAT --to-destination $(VM_IP):22 -#CYCLADES_PORT_FORWARDING = { +# CYCLADES_PORT_FORWARDING = { # 22: lambda ip_address, server_id, fqdn, user: # ("gate.example.synnefo.org", 61000 + server_id), -#} +# } CYCLADES_PORT_FORWARDING = {} # Extra configuration options required for snf-vncauthproxy (>=1.5). Each dict diff --git a/snf-cyclades-app/synnefo/app_settings/default/helpdesk.py b/snf-cyclades-app/synnefo/app_settings/default/helpdesk.py index c7cc26471..d6bcc7b7c 100644 --- a/snf-cyclades-app/synnefo/app_settings/default/helpdesk.py +++ b/snf-cyclades-app/synnefo/app_settings/default/helpdesk.py @@ -1,4 +1,4 @@ -#Enable the helpdesk application +# Enable the helpdesk application #HELPDESK_ENABLED = True # Which is the cookie name that stores the token, leave it commented out diff --git a/snf-cyclades-app/synnefo/app_settings/default/plankton.py b/snf-cyclades-app/synnefo/app_settings/default/plankton.py index bb62b596c..90c133f82 100644 --- a/snf-cyclades-app/synnefo/app_settings/default/plankton.py +++ b/snf-cyclades-app/synnefo/app_settings/default/plankton.py @@ -28,5 +28,5 @@ # The maximum interval (in seconds) for consequent backend object map checks PITHOS_BACKEND_MAP_CHECK_INTERVAL = 1 -#The maximum allowed number of image metadata +# The maximum allowed number of image metadata PITHOS_RESOURCE_MAX_METADATA = 32 diff --git a/snf-cyclades-app/synnefo/app_settings/default/tests.py b/snf-cyclades-app/synnefo/app_settings/default/tests.py index fa0c2b83f..b5f6e78ab 100644 --- a/snf-cyclades-app/synnefo/app_settings/default/tests.py +++ b/snf-cyclades-app/synnefo/app_settings/default/tests.py @@ -5,9 +5,10 @@ # A quick-n-dirty way which sets settings.TEST # if we're running unit tests. -import sys, os +import sys +import os TEST = False if len(sys.argv) >= 2: if os.path.basename(sys.argv[0]) == 'manage.py' and \ - (sys.argv[1] == 'test' or sys.argv[1] == 'hudson'): + (sys.argv[1] == 'test' or sys.argv[1] == 'hudson'): TEST = True From c14ec94e33c4a10c51a8eac27b6234763f8d4d6c Mon Sep 17 00:00:00 2001 From: indorilftw Date: Wed, 12 Nov 2014 11:54:23 +0200 Subject: [PATCH 19/43] PEP8 fixes on snf-cyclades-app/synnefo/db directory --- .../synnefo/db/migrations/0001_initial.py | 7 +++---- .../synnefo/db/migrations/0002_aai_fields.py | 7 +++---- .../db/migrations/0003_auto__add_network.py | 7 +++---- ...mage_backend_id__add_field_image_format.py | 7 +++---- .../migrations/0005_auto__add_invitations.py | 7 +++---- .../0006_auto__add_networkinterface.py | 7 +++---- ...h_token_expires__chg_field_synnefouser_.py | 7 +++---- ...mage_format__chg_field_image_backend_id.py | 7 +++---- .../0009_auto__chg_field_network_owner.py | 7 +++---- .../migrations/0010_auto__add_networklink.py | 7 +++---- ...1_auto__chg_field_networkinterface_ipv4.py | 7 +++---- ...012_auto__del_field_networklink_network.py | 7 +++---- ...013_auto__add_field_networklink_network.py | 7 +++---- ...dd_field_synnefouser_auth_token_expires.py | 5 +++-- .../0015_auto__add_field_image_public.py | 7 +++---- ...__add_field_synnefouser_max_invitations.py | 1 + .../0017_auto__add_field_invitations_level.py | 7 +++---- ...dd_field_virtualmachine_buildpercentage.py | 7 +++---- .../0019_auto__add_field_synnefouser_state.py | 7 +++---- .../0020_auto__add_field_flavor_deleted.py | 7 +++---- .../0021_auto__add_unique_together.py | 7 +++---- ...22_auto__add_field_flavor_disk_template.py | 7 +++---- ..._auto__add_field_virtualmachine_imageid.py | 7 +++---- .../db/migrations/0024_string_image_ids.py | 1 + ...o__del_field_virtualmachine_sourceimage.py | 7 +++---- ...m_cpu__add_unique_flavor_disk_ram_cpu_d.py | 7 +++---- .../0027_auto__del_legacy_fields.py | 7 +++---- .../0028_auto__del_disk__add_field_userid.py | 7 +++---- .../synnefo/db/migrations/0029_remove_user.py | 7 ++++--- ...d_virtualmachine_owner__del_field_image.py | 7 +++---- ...ique_imagemetadata_meta_key_image__del_.py | 7 +++---- ...m_cpu__add_unique_flavor_disk_ram_cpu_d.py | 3 +-- ...ilable__add_field_virtualmachine_backen.py | 15 +++++++------- ...rtualmachine_backend_hash__add_field_vi.py | 15 +++++++------- .../db/migrations/0035_default_backend.py | 14 +++++-------- ...efixpool__add_field_network_backendtime.py | 15 +++++++------- .../db/migrations/0037_network_migration.py | 8 ++++---- ...d_network_netlink__chg_field_network_li.py | 14 ++++++------- ...ield_network_backendtime__del_field_net.py | 15 +++++++------- ..._auto__chg_field_networkinterface_index.py | 15 +++++++------- ..._auto__add_field_networkinterface_dirty.py | 15 +++++++------- ...ssword__add_field_backend_password_hash.py | 14 ++++++------- .../db/migrations/0043_encrypt_passwords.py | 9 ++++----- ...ork_subnet6__add_field_network_gateway6.py | 15 +++++++------- ...ace_mac__add_field_network_reservations.py | 15 +++++++------- ...6_auto__chg_field_backend_password_hash.py | 15 +++++++------- ...e_mac__add_unique_networkinterface_mac_.py | 20 +++++++++---------- .../db/migrations/0049_not_null_mac_prefix.py | 11 +++++----- ...d_unique_backendnetwork_network_backend.py | 15 +++++++------- ...bridgepooltable__add_macprefixpooltable.py | 15 +++++++------- .../migrations/0052_migrate_pool_entries.py | 20 +++++++++++-------- ...auto__del_bridgepool__del_macprefixpool.py | 15 +++++++------- ...add_ippooltable__add_field_network_pool.py | 15 +++++++------- ...56_auto__del_field_network_reservations.py | 15 +++++++------- ...0057_auto__add_virtualmachinediagnostic.py | 7 +++---- ...e_dirty__chg_field_virtualmachine_delet.py | 7 +++---- ...d_field_virtualmachine_serial__add_fiel.py | 7 +++---- ...dd_field_network_flavor__add_field_netw.py | 7 +++---- .../db/migrations/0061_network_flavors.py | 3 +-- ...e_state__chg_field_networkinterface_mac.py | 7 +++---- ...al_accept__add_field_quotaholderserial_.py | 7 +++---- .../synnefo/db/migrations/0064_serials.py | 3 +-- ...al_rejected__del_field_quotaholderseria.py | 7 +++---- ...0067_auto__add_field_backend_hypervisor.py | 7 +++---- .../0068_auto__add_field_network_drained.py | 7 +++---- ..._virtualmachine_task__add_field_virtual.py | 7 +++---- .../0070_auto__chg_field_network_subnet.py | 7 +++---- ...o__chg_field_virtualmachine_task_job_id.py | 7 +++---- ..._auto__chg_field_networkinterface_index.py | 2 +- ..._auto__add_field_backend_disk_templates.py | 4 +--- ...al__chg_field_virtualmachine_flavor__ch.py | 2 +- ...dd_unique_networkinterface_network_ipv4.py | 4 +--- ...dd_subnet__add_field_ippooltable_subnet.py | 4 +--- .../0077_migrate_networks_to_subnets.py | 1 + ...__del_field_network_subnet__del_field_n.py | 4 +--- ..._ipaddress_network_address__add_securit.py | 4 +--- .../synnefo/db/migrations/0080_nics_to_ips.py | 3 +-- ..._networkinterface_ipv6__del_field_netwo.py | 4 +--- ..._auto__del_field_networkinterface_dirty.py | 4 +--- .../0083_auto__chg_field_subnet_cidr.py | 2 +- .../db/migrations/0084_external_router.py | 1 + .../db/migrations/0085_nic_build_state.py | 1 + .../migrations/0086_auto__add_ipaddresslog.py | 4 +--- .../db/migrations/0087_ip_address_log.py | 1 + ...e_machine__del_unique_ipaddresslog_netw.py | 1 - ...auto__chg_field_networkinterface_userid.py | 2 +- ...t__chg_field_ipaddress_network__chg_fie.py | 2 +- ...ork_address__add_unique_ipaddress_delet.py | 4 +--- ...ubnet_created__add_field_subnet_updated.py | 4 +--- ...093_auto__add_field_ipaddress_ipversion.py | 4 +--- .../migrations/0094_add_ipversion_to_ips.py | 1 + ...095_auto__chg_field_ipaddress_ipversion.py | 2 +- ..._subnet_userid__add_field_subnet_public.py | 4 +--- .../db/migrations/0097_userid_to_subnets.py | 1 + ...098_auto__add_field_flavor_allow_create.py | 4 +--- ...ct__add_field_virtualmachine_project__a.py | 4 +--- .../synnefo/db/migrations/0100_project_ids.py | 1 + ...0101_auto__add_field_network_subnet_ids.py | 2 -- .../db/migrations/0102_subnets_to_network.py | 1 + ...auto__add_field_networkinterface_public.py | 4 +--- .../db/migrations/0104_public_to_nics.py | 1 + ...adata__add_unique_volumemetadata_volume.py | 2 -- .../db/migrations/0106_default_volume.py | 1 + ..._volume_volume_type__add_field_flavor_v.py | 2 -- .../db/migrations/0108_dtemplate_to_vtype.py | 1 + ...plate__chg_field_volume_volume_type__de.py | 8 +------- .../0110_auto__add_field_volume_project.py | 4 +--- .../db/migrations/0111_volume_project.py | 1 + .../0112_auto__add_field_volume_serial.py | 4 +--- ..._add_index_ipaddress_project__add_index.py | 4 +--- .../synnefo/db/migrations/0114_auto.py | 4 +--- ...ersion__add_field_virtualmachine_image_.py | 2 -- ...dd_image__add_unique_image_uuid_version.py | 2 -- .../db/migrations/0117_fix_migration_bug.py | 8 ++++---- snf-cyclades-app/synnefo/db/models_factory.py | 4 ++-- 115 files changed, 324 insertions(+), 426 deletions(-) diff --git a/snf-cyclades-app/synnefo/db/migrations/0001_initial.py b/snf-cyclades-app/synnefo/db/migrations/0001_initial.py index 13464e463..7042bc71d 100644 --- a/snf-cyclades-app/synnefo/db/migrations/0001_initial.py +++ b/snf-cyclades-app/synnefo/db/migrations/0001_initial.py @@ -4,10 +4,11 @@ from south.v2 import SchemaMigration from django.db import models + class Migration(SchemaMigration): def forwards(self, orm): - + # Adding model 'SynnefoUser' db.create_table('db_synnefouser', ( ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), @@ -143,9 +144,8 @@ def forwards(self, orm): )) db.send_create_signal('db', ['Disk']) - def backwards(self, orm): - + # Deleting model 'SynnefoUser' db.delete_table('db_synnefouser') @@ -185,7 +185,6 @@ def backwards(self, orm): # Deleting model 'Disk' db.delete_table('db_disk') - models = { 'db.debit': { 'Meta': {'object_name': 'Debit'}, diff --git a/snf-cyclades-app/synnefo/db/migrations/0002_aai_fields.py b/snf-cyclades-app/synnefo/db/migrations/0002_aai_fields.py index 90d450f39..fa46d0564 100644 --- a/snf-cyclades-app/synnefo/db/migrations/0002_aai_fields.py +++ b/snf-cyclades-app/synnefo/db/migrations/0002_aai_fields.py @@ -4,10 +4,11 @@ from south.v2 import SchemaMigration from django.db import models + class Migration(SchemaMigration): def forwards(self, orm): - + # Adding field 'SynnefoUser.realname' db.add_column('db_synnefouser', 'realname', self.gf('django.db.models.fields.CharField')(default='', max_length=255), keep_default=False) @@ -23,9 +24,8 @@ def forwards(self, orm): # Adding field 'SynnefoUser.type' db.add_column('db_synnefouser', 'type', self.gf('django.db.models.fields.CharField')(default=None, max_length=30), keep_default=False) - def backwards(self, orm): - + # Deleting field 'SynnefoUser.realname' db.delete_column('db_synnefouser', 'realname') @@ -41,7 +41,6 @@ def backwards(self, orm): # Deleting field 'SynnefoUser.type' db.delete_column('db_synnefouser', 'type') - models = { 'db.debit': { 'Meta': {'object_name': 'Debit'}, diff --git a/snf-cyclades-app/synnefo/db/migrations/0003_auto__add_network.py b/snf-cyclades-app/synnefo/db/migrations/0003_auto__add_network.py index 5d9fdb0f3..566796d67 100644 --- a/snf-cyclades-app/synnefo/db/migrations/0003_auto__add_network.py +++ b/snf-cyclades-app/synnefo/db/migrations/0003_auto__add_network.py @@ -4,10 +4,11 @@ from south.v2 import SchemaMigration from django.db import models + class Migration(SchemaMigration): def forwards(self, orm): - + # Adding model 'Network' db.create_table('db_network', ( ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), @@ -26,16 +27,14 @@ def forwards(self, orm): )) db.create_unique('db_network_machines', ['network_id', 'virtualmachine_id']) - def backwards(self, orm): - + # Deleting model 'Network' db.delete_table('db_network') # Removing M2M table for field machines on 'Network' db.delete_table('db_network_machines') - models = { 'db.debit': { 'Meta': {'object_name': 'Debit'}, diff --git a/snf-cyclades-app/synnefo/db/migrations/0004_auto__add_field_image_backend_id__add_field_image_format.py b/snf-cyclades-app/synnefo/db/migrations/0004_auto__add_field_image_backend_id__add_field_image_format.py index 42e830ccb..6fed4446f 100644 --- a/snf-cyclades-app/synnefo/db/migrations/0004_auto__add_field_image_backend_id__add_field_image_format.py +++ b/snf-cyclades-app/synnefo/db/migrations/0004_auto__add_field_image_backend_id__add_field_image_format.py @@ -4,26 +4,25 @@ from south.v2 import SchemaMigration from django.db import models + class Migration(SchemaMigration): def forwards(self, orm): - + # Adding field 'Image.backend_id' db.add_column('db_image', 'backend_id', self.gf('django.db.models.fields.TextField')(default='debian_base'), keep_default=False) # Adding field 'Image.format' db.add_column('db_image', 'format', self.gf('django.db.models.fields.TextField')(default='dump'), keep_default=False) - def backwards(self, orm): - + # Deleting field 'Image.backend_id' db.delete_column('db_image', 'backend_id') # Deleting field 'Image.format' db.delete_column('db_image', 'format') - models = { 'db.debit': { 'Meta': {'object_name': 'Debit'}, diff --git a/snf-cyclades-app/synnefo/db/migrations/0005_auto__add_invitations.py b/snf-cyclades-app/synnefo/db/migrations/0005_auto__add_invitations.py index e0341d8ce..2785882db 100644 --- a/snf-cyclades-app/synnefo/db/migrations/0005_auto__add_invitations.py +++ b/snf-cyclades-app/synnefo/db/migrations/0005_auto__add_invitations.py @@ -4,10 +4,11 @@ from south.v2 import SchemaMigration from django.db import models + class Migration(SchemaMigration): def forwards(self, orm): - + # Adding model 'Invitations' db.create_table('db_invitations', ( ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), @@ -19,13 +20,11 @@ def forwards(self, orm): )) db.send_create_signal('db', ['Invitations']) - def backwards(self, orm): - + # Deleting model 'Invitations' db.delete_table('db_invitations') - models = { 'db.debit': { 'Meta': {'object_name': 'Debit'}, diff --git a/snf-cyclades-app/synnefo/db/migrations/0006_auto__add_networkinterface.py b/snf-cyclades-app/synnefo/db/migrations/0006_auto__add_networkinterface.py index 111692881..602d57bc9 100644 --- a/snf-cyclades-app/synnefo/db/migrations/0006_auto__add_networkinterface.py +++ b/snf-cyclades-app/synnefo/db/migrations/0006_auto__add_networkinterface.py @@ -4,10 +4,11 @@ from south.v2 import SchemaMigration from django.db import models + class Migration(SchemaMigration): def forwards(self, orm): - + # Adding model 'NetworkInterface' db.create_table('db_networkinterface', ( ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), @@ -38,9 +39,8 @@ def forwards(self, orm): # Removing M2M table for field machines on 'Network' db.delete_table('db_network_machines') - def backwards(self, orm): - + # Deleting model 'NetworkInterface' db.delete_table('db_networkinterface') @@ -64,7 +64,6 @@ def backwards(self, orm): )) db.create_unique('db_network_machines', ['network_id', 'virtualmachine_id']) - models = { 'db.debit': { 'Meta': {'object_name': 'Debit'}, diff --git a/snf-cyclades-app/synnefo/db/migrations/0007_auto__add_field_synnefouser_auth_token_expires__chg_field_synnefouser_.py b/snf-cyclades-app/synnefo/db/migrations/0007_auto__add_field_synnefouser_auth_token_expires__chg_field_synnefouser_.py index 4a62cbffc..dfe99d22e 100644 --- a/snf-cyclades-app/synnefo/db/migrations/0007_auto__add_field_synnefouser_auth_token_expires__chg_field_synnefouser_.py +++ b/snf-cyclades-app/synnefo/db/migrations/0007_auto__add_field_synnefouser_auth_token_expires__chg_field_synnefouser_.py @@ -4,26 +4,25 @@ from south.v2 import SchemaMigration from django.db import models + class Migration(SchemaMigration): def forwards(self, orm): - + # Adding field 'SynnefoUser.auth_token_expires' db.add_column('db_synnefouser', 'auth_token_expires', self.gf('django.db.models.fields.DateTimeField')(auto_now_add=True, null=True, blank=True), keep_default=False) # Changing field 'SynnefoUser.auth_token_created' db.alter_column('db_synnefouser', 'auth_token_created', self.gf('django.db.models.fields.DateTimeField')(auto_now_add=True, null=True, blank=True)) - def backwards(self, orm): - + # Deleting field 'SynnefoUser.auth_token_expires' db.delete_column('db_synnefouser', 'auth_token_expires') # Changing field 'SynnefoUser.auth_token_created' db.alter_column('db_synnefouser', 'auth_token_created', self.gf('django.db.models.fields.DateTimeField')(auto_now_add=True, blank=True)) - models = { 'db.debit': { 'Meta': {'object_name': 'Debit'}, diff --git a/snf-cyclades-app/synnefo/db/migrations/0008_auto__chg_field_image_format__chg_field_image_backend_id.py b/snf-cyclades-app/synnefo/db/migrations/0008_auto__chg_field_image_format__chg_field_image_backend_id.py index 70097ff6b..81fbc76a0 100644 --- a/snf-cyclades-app/synnefo/db/migrations/0008_auto__chg_field_image_format__chg_field_image_backend_id.py +++ b/snf-cyclades-app/synnefo/db/migrations/0008_auto__chg_field_image_format__chg_field_image_backend_id.py @@ -4,26 +4,25 @@ from south.v2 import SchemaMigration from django.db import models + class Migration(SchemaMigration): def forwards(self, orm): - + # Changing field 'Image.format' db.alter_column('db_image', 'format', self.gf('django.db.models.fields.CharField')(max_length=30)) # Changing field 'Image.backend_id' db.alter_column('db_image', 'backend_id', self.gf('django.db.models.fields.CharField')(max_length=50)) - def backwards(self, orm): - + # Changing field 'Image.format' db.alter_column('db_image', 'format', self.gf('django.db.models.fields.TextField')()) # Changing field 'Image.backend_id' db.alter_column('db_image', 'backend_id', self.gf('django.db.models.fields.TextField')()) - models = { 'db.debit': { 'Meta': {'object_name': 'Debit'}, diff --git a/snf-cyclades-app/synnefo/db/migrations/0009_auto__chg_field_network_owner.py b/snf-cyclades-app/synnefo/db/migrations/0009_auto__chg_field_network_owner.py index dc7b02053..da2b300a6 100644 --- a/snf-cyclades-app/synnefo/db/migrations/0009_auto__chg_field_network_owner.py +++ b/snf-cyclades-app/synnefo/db/migrations/0009_auto__chg_field_network_owner.py @@ -4,20 +4,19 @@ from south.v2 import SchemaMigration from django.db import models + class Migration(SchemaMigration): def forwards(self, orm): - + # Changing field 'Network.owner' db.alter_column('db_network', 'owner_id', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['db.SynnefoUser'], null=True)) - def backwards(self, orm): - + # Changing field 'Network.owner' db.alter_column('db_network', 'owner_id', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['db.SynnefoUser'])) - models = { 'db.debit': { 'Meta': {'object_name': 'Debit'}, diff --git a/snf-cyclades-app/synnefo/db/migrations/0010_auto__add_networklink.py b/snf-cyclades-app/synnefo/db/migrations/0010_auto__add_networklink.py index 341c3316b..99488f3f8 100644 --- a/snf-cyclades-app/synnefo/db/migrations/0010_auto__add_networklink.py +++ b/snf-cyclades-app/synnefo/db/migrations/0010_auto__add_networklink.py @@ -4,10 +4,11 @@ from south.v2 import SchemaMigration from django.db import models + class Migration(SchemaMigration): def forwards(self, orm): - + # Adding model 'NetworkLink' db.create_table('db_networklink', ( ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), @@ -18,13 +19,11 @@ def forwards(self, orm): )) db.send_create_signal('db', ['NetworkLink']) - def backwards(self, orm): - + # Deleting model 'NetworkLink' db.delete_table('db_networklink') - models = { 'db.debit': { 'Meta': {'object_name': 'Debit'}, diff --git a/snf-cyclades-app/synnefo/db/migrations/0011_auto__chg_field_networkinterface_ipv4.py b/snf-cyclades-app/synnefo/db/migrations/0011_auto__chg_field_networkinterface_ipv4.py index 75c6e6591..55a01f940 100644 --- a/snf-cyclades-app/synnefo/db/migrations/0011_auto__chg_field_networkinterface_ipv4.py +++ b/snf-cyclades-app/synnefo/db/migrations/0011_auto__chg_field_networkinterface_ipv4.py @@ -4,20 +4,19 @@ from south.v2 import SchemaMigration from django.db import models + class Migration(SchemaMigration): def forwards(self, orm): - + # Changing field 'NetworkInterface.ipv4' db.alter_column('db_networkinterface', 'ipv4', self.gf('django.db.models.fields.CharField')(max_length=15, null=True)) - def backwards(self, orm): - + # Changing field 'NetworkInterface.ipv4' db.alter_column('db_networkinterface', 'ipv4', self.gf('django.db.models.fields.IPAddressField')(max_length=15, null=True)) - models = { 'db.debit': { 'Meta': {'object_name': 'Debit'}, diff --git a/snf-cyclades-app/synnefo/db/migrations/0012_auto__del_field_networklink_network.py b/snf-cyclades-app/synnefo/db/migrations/0012_auto__del_field_networklink_network.py index 311db705f..1bf6dc3d8 100644 --- a/snf-cyclades-app/synnefo/db/migrations/0012_auto__del_field_networklink_network.py +++ b/snf-cyclades-app/synnefo/db/migrations/0012_auto__del_field_networklink_network.py @@ -4,20 +4,19 @@ from south.v2 import SchemaMigration from django.db import models + class Migration(SchemaMigration): def forwards(self, orm): - + # Deleting field 'NetworkLink.network' db.delete_column('db_networklink', 'network_id') - def backwards(self, orm): - + # Adding field 'NetworkLink.network' db.add_column('db_networklink', 'network', self.gf('django.db.models.fields.related.OneToOneField')(related_name='link', unique=True, null=True, to=orm['db.Network']), keep_default=False) - models = { 'db.debit': { 'Meta': {'object_name': 'Debit'}, diff --git a/snf-cyclades-app/synnefo/db/migrations/0013_auto__add_field_networklink_network.py b/snf-cyclades-app/synnefo/db/migrations/0013_auto__add_field_networklink_network.py index d9d28ce1a..3bffb86ac 100644 --- a/snf-cyclades-app/synnefo/db/migrations/0013_auto__add_field_networklink_network.py +++ b/snf-cyclades-app/synnefo/db/migrations/0013_auto__add_field_networklink_network.py @@ -4,26 +4,25 @@ from south.v2 import SchemaMigration from django.db import models + class Migration(SchemaMigration): def forwards(self, orm): - + # Adding field 'NetworkLink.network' db.add_column('db_networklink', 'network', self.gf('django.db.models.fields.related.ForeignKey')(related_name='+', null=True, to=orm['db.Network']), keep_default=False) # Adding field 'Network.link' db.add_column('db_network', 'link', self.gf('django.db.models.fields.related.ForeignKey')(default=1, related_name='+', to=orm['db.NetworkLink']), keep_default=False) - def backwards(self, orm): - + # Deleting field 'NetworkLink.network' db.delete_column('db_networklink', 'network_id') # Deleting field 'Network.link' db.delete_column('db_network', 'link_id') - models = { 'db.debit': { 'Meta': {'object_name': 'Debit'}, diff --git a/snf-cyclades-app/synnefo/db/migrations/0014_auto__add_field_synnefouser_auth_token_expires.py b/snf-cyclades-app/synnefo/db/migrations/0014_auto__add_field_synnefouser_auth_token_expires.py index f0630de28..c78a32c99 100644 --- a/snf-cyclades-app/synnefo/db/migrations/0014_auto__add_field_synnefouser_auth_token_expires.py +++ b/snf-cyclades-app/synnefo/db/migrations/0014_auto__add_field_synnefouser_auth_token_expires.py @@ -4,11 +4,12 @@ from south.v2 import SchemaMigration from django.db import models + class Migration(SchemaMigration): def forwards(self, orm): - - # Adding field 'SynnefoUser.tmp_auth_token' + + # Adding field 'SynnefoUser.tmp_auth_token' db.add_column('db_synnefouser', 'tmp_auth_token', self.gf('django.db.models.fields.CharField')(max_length=32, null=True), keep_default=False) # Adding field 'SynnefoUser.tmp_auth_token_expires' diff --git a/snf-cyclades-app/synnefo/db/migrations/0015_auto__add_field_image_public.py b/snf-cyclades-app/synnefo/db/migrations/0015_auto__add_field_image_public.py index d2c62de50..3d82fb893 100644 --- a/snf-cyclades-app/synnefo/db/migrations/0015_auto__add_field_image_public.py +++ b/snf-cyclades-app/synnefo/db/migrations/0015_auto__add_field_image_public.py @@ -4,20 +4,19 @@ from south.v2 import SchemaMigration from django.db import models + class Migration(SchemaMigration): def forwards(self, orm): - + # Adding field 'Image.public' db.add_column('db_image', 'public', self.gf('django.db.models.fields.BooleanField')(default=False, blank=True), keep_default=False) - def backwards(self, orm): - + # Deleting field 'Image.public' db.delete_column('db_image', 'public') - models = { 'db.debit': { 'Meta': {'object_name': 'Debit'}, diff --git a/snf-cyclades-app/synnefo/db/migrations/0016_auto__add_field_synnefouser_max_invitations.py b/snf-cyclades-app/synnefo/db/migrations/0016_auto__add_field_synnefouser_max_invitations.py index 83c647209..ad14845a0 100644 --- a/snf-cyclades-app/synnefo/db/migrations/0016_auto__add_field_synnefouser_max_invitations.py +++ b/snf-cyclades-app/synnefo/db/migrations/0016_auto__add_field_synnefouser_max_invitations.py @@ -4,6 +4,7 @@ from south.v2 import SchemaMigration from django.db import models + class Migration(SchemaMigration): def forwards(self, orm): diff --git a/snf-cyclades-app/synnefo/db/migrations/0017_auto__add_field_invitations_level.py b/snf-cyclades-app/synnefo/db/migrations/0017_auto__add_field_invitations_level.py index 2555d77d0..cecb18aac 100644 --- a/snf-cyclades-app/synnefo/db/migrations/0017_auto__add_field_invitations_level.py +++ b/snf-cyclades-app/synnefo/db/migrations/0017_auto__add_field_invitations_level.py @@ -4,20 +4,19 @@ from south.v2 import SchemaMigration from django.db import models + class Migration(SchemaMigration): def forwards(self, orm): - + # Adding field 'Invitations.level' db.add_column('db_invitations', 'level', self.gf('django.db.models.fields.IntegerField')(null=True), keep_default=False) - def backwards(self, orm): - + # Deleting field 'Invitations.level' db.delete_column('db_invitations', 'level') - models = { 'db.debit': { 'Meta': {'object_name': 'Debit'}, diff --git a/snf-cyclades-app/synnefo/db/migrations/0018_auto__add_field_virtualmachine_buildpercentage.py b/snf-cyclades-app/synnefo/db/migrations/0018_auto__add_field_virtualmachine_buildpercentage.py index 0c99d9799..1532122aa 100644 --- a/snf-cyclades-app/synnefo/db/migrations/0018_auto__add_field_virtualmachine_buildpercentage.py +++ b/snf-cyclades-app/synnefo/db/migrations/0018_auto__add_field_virtualmachine_buildpercentage.py @@ -4,20 +4,19 @@ from south.v2 import SchemaMigration from django.db import models + class Migration(SchemaMigration): def forwards(self, orm): - + # Adding field 'VirtualMachine.buildpercentage' db.add_column('db_virtualmachine', 'buildpercentage', self.gf('django.db.models.fields.IntegerField')(default=0), keep_default=False) - def backwards(self, orm): - + # Deleting field 'VirtualMachine.buildpercentage' db.delete_column('db_virtualmachine', 'buildpercentage') - models = { 'db.debit': { 'Meta': {'object_name': 'Debit'}, diff --git a/snf-cyclades-app/synnefo/db/migrations/0019_auto__add_field_synnefouser_state.py b/snf-cyclades-app/synnefo/db/migrations/0019_auto__add_field_synnefouser_state.py index 1d152017b..f5856b2cd 100644 --- a/snf-cyclades-app/synnefo/db/migrations/0019_auto__add_field_synnefouser_state.py +++ b/snf-cyclades-app/synnefo/db/migrations/0019_auto__add_field_synnefouser_state.py @@ -4,10 +4,11 @@ from south.v2 import SchemaMigration from django.db import models + class Migration(SchemaMigration): def forwards(self, orm): - + # Changing field 'NetworkLink.available' db.alter_column('db_networklink', 'available', self.gf('django.db.models.fields.BooleanField')(blank=True)) @@ -29,9 +30,8 @@ def forwards(self, orm): # Changing field 'Network.public' db.alter_column('db_network', 'public', self.gf('django.db.models.fields.BooleanField')(blank=True)) - def backwards(self, orm): - + # Changing field 'NetworkLink.available' db.alter_column('db_networklink', 'available', self.gf('django.db.models.fields.BooleanField')()) @@ -53,7 +53,6 @@ def backwards(self, orm): # Changing field 'Network.public' db.alter_column('db_network', 'public', self.gf('django.db.models.fields.BooleanField')()) - models = { 'db.debit': { 'Meta': {'object_name': 'Debit'}, diff --git a/snf-cyclades-app/synnefo/db/migrations/0020_auto__add_field_flavor_deleted.py b/snf-cyclades-app/synnefo/db/migrations/0020_auto__add_field_flavor_deleted.py index 094ecaef1..771b8e8eb 100644 --- a/snf-cyclades-app/synnefo/db/migrations/0020_auto__add_field_flavor_deleted.py +++ b/snf-cyclades-app/synnefo/db/migrations/0020_auto__add_field_flavor_deleted.py @@ -4,20 +4,19 @@ from south.v2 import SchemaMigration from django.db import models + class Migration(SchemaMigration): def forwards(self, orm): - + # Adding field 'Flavor.deleted' db.add_column('db_flavor', 'deleted', self.gf('django.db.models.fields.BooleanField')(default=False, blank=True), keep_default=False) - def backwards(self, orm): - + # Deleting field 'Flavor.deleted' db.delete_column('db_flavor', 'deleted') - models = { 'db.debit': { 'Meta': {'object_name': 'Debit'}, diff --git a/snf-cyclades-app/synnefo/db/migrations/0021_auto__add_unique_together.py b/snf-cyclades-app/synnefo/db/migrations/0021_auto__add_unique_together.py index dd7921df2..6d8ea4f71 100644 --- a/snf-cyclades-app/synnefo/db/migrations/0021_auto__add_unique_together.py +++ b/snf-cyclades-app/synnefo/db/migrations/0021_auto__add_unique_together.py @@ -4,26 +4,25 @@ from south.v2 import SchemaMigration from django.db import models + class Migration(SchemaMigration): def forwards(self, orm): - + # Adding unique constraint on 'ImageMetadata', fields ['image', 'meta_key'] db.create_unique('db_imagemetadata', ['image_id', 'meta_key']) # Adding unique constraint on 'VirtualMachineMetadata', fields ['vm', 'meta_key'] db.create_unique('db_virtualmachinemetadata', ['vm_id', 'meta_key']) - def backwards(self, orm): - + # Removing unique constraint on 'VirtualMachineMetadata', fields ['vm', 'meta_key'] db.delete_unique('db_virtualmachinemetadata', ['vm_id', 'meta_key']) # Removing unique constraint on 'ImageMetadata', fields ['image', 'meta_key'] db.delete_unique('db_imagemetadata', ['image_id', 'meta_key']) - models = { 'db.debit': { 'Meta': {'object_name': 'Debit'}, diff --git a/snf-cyclades-app/synnefo/db/migrations/0022_auto__add_field_flavor_disk_template.py b/snf-cyclades-app/synnefo/db/migrations/0022_auto__add_field_flavor_disk_template.py index 915f44d82..0e6052bef 100644 --- a/snf-cyclades-app/synnefo/db/migrations/0022_auto__add_field_flavor_disk_template.py +++ b/snf-cyclades-app/synnefo/db/migrations/0022_auto__add_field_flavor_disk_template.py @@ -4,20 +4,19 @@ from south.v2 import SchemaMigration from django.db import models + class Migration(SchemaMigration): def forwards(self, orm): - + # Adding field 'Flavor.disk_template' db.add_column('db_flavor', 'disk_template', self.gf('django.db.models.fields.CharField')(default='drbd', max_length=32), keep_default=False) - def backwards(self, orm): - + # Deleting field 'Flavor.disk_template' db.delete_column('db_flavor', 'disk_template') - models = { 'db.debit': { 'Meta': {'object_name': 'Debit'}, diff --git a/snf-cyclades-app/synnefo/db/migrations/0023_auto__add_field_virtualmachine_imageid.py b/snf-cyclades-app/synnefo/db/migrations/0023_auto__add_field_virtualmachine_imageid.py index 6e206197f..e7f7a85b1 100644 --- a/snf-cyclades-app/synnefo/db/migrations/0023_auto__add_field_virtualmachine_imageid.py +++ b/snf-cyclades-app/synnefo/db/migrations/0023_auto__add_field_virtualmachine_imageid.py @@ -4,20 +4,19 @@ from south.v2 import SchemaMigration from django.db import models + class Migration(SchemaMigration): def forwards(self, orm): - + # Adding field 'VirtualMachine.imageid' db.add_column('db_virtualmachine', 'imageid', self.gf('django.db.models.fields.CharField')(default='', max_length=100), keep_default=False) - def backwards(self, orm): - + # Deleting field 'VirtualMachine.imageid' db.delete_column('db_virtualmachine', 'imageid') - models = { 'db.debit': { 'Meta': {'object_name': 'Debit'}, diff --git a/snf-cyclades-app/synnefo/db/migrations/0024_string_image_ids.py b/snf-cyclades-app/synnefo/db/migrations/0024_string_image_ids.py index b7b4f3695..167efaaa4 100644 --- a/snf-cyclades-app/synnefo/db/migrations/0024_string_image_ids.py +++ b/snf-cyclades-app/synnefo/db/migrations/0024_string_image_ids.py @@ -4,6 +4,7 @@ from south.v2 import DataMigration from django.db import models + class Migration(DataMigration): def forwards(self, orm): diff --git a/snf-cyclades-app/synnefo/db/migrations/0025_auto__del_field_virtualmachine_sourceimage.py b/snf-cyclades-app/synnefo/db/migrations/0025_auto__del_field_virtualmachine_sourceimage.py index 9b7cb7325..f5824a311 100644 --- a/snf-cyclades-app/synnefo/db/migrations/0025_auto__del_field_virtualmachine_sourceimage.py +++ b/snf-cyclades-app/synnefo/db/migrations/0025_auto__del_field_virtualmachine_sourceimage.py @@ -4,21 +4,20 @@ from south.v2 import SchemaMigration from django.db import models + class Migration(SchemaMigration): def forwards(self, orm): - + # Deleting field 'VirtualMachine.sourceimage' db.delete_column('db_virtualmachine', 'sourceimage_id') - def backwards(self, orm): - + # We cannot add back in field 'VirtualMachine.sourceimage' raise RuntimeError( "Cannot reverse this migration. 'VirtualMachine.sourceimage' and its values cannot be restored.") - models = { 'db.debit': { 'Meta': {'object_name': 'Debit'}, diff --git a/snf-cyclades-app/synnefo/db/migrations/0026_auto__del_unique_flavor_disk_ram_cpu__add_unique_flavor_disk_ram_cpu_d.py b/snf-cyclades-app/synnefo/db/migrations/0026_auto__del_unique_flavor_disk_ram_cpu__add_unique_flavor_disk_ram_cpu_d.py index 505578cca..67a766e78 100644 --- a/snf-cyclades-app/synnefo/db/migrations/0026_auto__del_unique_flavor_disk_ram_cpu__add_unique_flavor_disk_ram_cpu_d.py +++ b/snf-cyclades-app/synnefo/db/migrations/0026_auto__del_unique_flavor_disk_ram_cpu__add_unique_flavor_disk_ram_cpu_d.py @@ -4,26 +4,25 @@ from south.v2 import SchemaMigration from django.db import models + class Migration(SchemaMigration): def forwards(self, orm): - + # Removing unique constraint on 'Flavor', fields ['disk', 'ram', 'cpu'] db.delete_unique('db_flavor', ['disk', 'ram', 'cpu']) # Adding unique constraint on 'Flavor', fields ['disk', 'ram', 'cpu', 'disk_template'] db.create_unique('db_flavor', ['disk', 'ram', 'cpu', 'disk_template']) - def backwards(self, orm): - + # Removing unique constraint on 'Flavor', fields ['disk', 'ram', 'cpu', 'disk_template'] db.delete_unique('db_flavor', ['disk', 'ram', 'cpu', 'disk_template']) # Adding unique constraint on 'Flavor', fields ['disk', 'ram', 'cpu'] db.create_unique('db_flavor', ['disk', 'ram', 'cpu']) - models = { 'db.debit': { 'Meta': {'object_name': 'Debit'}, diff --git a/snf-cyclades-app/synnefo/db/migrations/0027_auto__del_legacy_fields.py b/snf-cyclades-app/synnefo/db/migrations/0027_auto__del_legacy_fields.py index 47aa4ddfb..5b1faf3ea 100644 --- a/snf-cyclades-app/synnefo/db/migrations/0027_auto__del_legacy_fields.py +++ b/snf-cyclades-app/synnefo/db/migrations/0027_auto__del_legacy_fields.py @@ -4,10 +4,11 @@ from south.v2 import SchemaMigration from django.db import models + class Migration(SchemaMigration): def forwards(self, orm): - + # Deleting model 'FlavorCost' db.delete_table('db_flavorcost') @@ -32,9 +33,8 @@ def forwards(self, orm): # Deleting field 'SynnefoUser.max_invitations' db.delete_column('db_synnefouser', 'max_invitations') - def backwards(self, orm): - + # Adding model 'FlavorCost' db.create_table('db_flavorcost', ( ('cost_active', self.gf('django.db.models.fields.PositiveIntegerField')()), @@ -100,7 +100,6 @@ def backwards(self, orm): # Adding field 'SynnefoUser.max_invitations' db.add_column('db_synnefouser', 'max_invitations', self.gf('django.db.models.fields.IntegerField')(null=True), keep_default=False) - models = { 'db.disk': { 'Meta': {'object_name': 'Disk'}, diff --git a/snf-cyclades-app/synnefo/db/migrations/0028_auto__del_disk__add_field_userid.py b/snf-cyclades-app/synnefo/db/migrations/0028_auto__del_disk__add_field_userid.py index ddfb90f00..2bf95483d 100644 --- a/snf-cyclades-app/synnefo/db/migrations/0028_auto__del_disk__add_field_userid.py +++ b/snf-cyclades-app/synnefo/db/migrations/0028_auto__del_disk__add_field_userid.py @@ -4,10 +4,11 @@ from south.v2 import SchemaMigration from django.db import models + class Migration(SchemaMigration): def forwards(self, orm): - + # Deleting model 'Disk' db.delete_table('db_disk') @@ -20,9 +21,8 @@ def forwards(self, orm): # Adding field 'Network.userid' db.add_column('db_network', 'userid', self.gf('django.db.models.fields.CharField')(default='', max_length=100), keep_default=False) - def backwards(self, orm): - + # Adding model 'Disk' db.create_table('db_disk', ( ('vm', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['db.VirtualMachine'], null=True, blank=True)), @@ -44,7 +44,6 @@ def backwards(self, orm): # Deleting field 'Network.userid' db.delete_column('db_network', 'userid') - models = { 'db.flavor': { 'Meta': {'unique_together': "(('cpu', 'ram', 'disk'),)", 'object_name': 'Flavor'}, diff --git a/snf-cyclades-app/synnefo/db/migrations/0029_remove_user.py b/snf-cyclades-app/synnefo/db/migrations/0029_remove_user.py index 6dbf646ac..59c2d862e 100644 --- a/snf-cyclades-app/synnefo/db/migrations/0029_remove_user.py +++ b/snf-cyclades-app/synnefo/db/migrations/0029_remove_user.py @@ -4,21 +4,22 @@ from south.v2 import DataMigration from django.db import models + class Migration(DataMigration): def forwards(self, orm): for image in orm.Image.objects.all(): image.userid = image.owner.uniq if image.owner else '' image.save() - + for vm in orm.VirtualMachine.objects.all(): vm.userid = vm.owner.uniq if vm.owner else '' vm.save() - + for network in orm.Network.objects.all(): network.userid = network.owner.uniq if network.owner else '' network.save() - + def backwards(self, orm): raise RuntimeError("Cannot reverse this migration.") diff --git a/snf-cyclades-app/synnefo/db/migrations/0030_auto__del_synnefouser__del_field_virtualmachine_owner__del_field_image.py b/snf-cyclades-app/synnefo/db/migrations/0030_auto__del_synnefouser__del_field_virtualmachine_owner__del_field_image.py index dc254478d..655e6cd7d 100644 --- a/snf-cyclades-app/synnefo/db/migrations/0030_auto__del_synnefouser__del_field_virtualmachine_owner__del_field_image.py +++ b/snf-cyclades-app/synnefo/db/migrations/0030_auto__del_synnefouser__del_field_virtualmachine_owner__del_field_image.py @@ -4,10 +4,11 @@ from south.v2 import SchemaMigration from django.db import models + class Migration(SchemaMigration): def forwards(self, orm): - + # Deleting model 'SynnefoUser' db.delete_table('db_synnefouser') @@ -26,9 +27,8 @@ def forwards(self, orm): # Changing field 'Network.userid' db.alter_column('db_network', 'userid', self.gf('django.db.models.fields.CharField')(max_length=100, null=True)) - def backwards(self, orm): - + # Adding model 'SynnefoUser' db.create_table('db_synnefouser', ( ('updated', self.gf('django.db.models.fields.DateTimeField')(auto_now=True, blank=True)), @@ -62,7 +62,6 @@ def backwards(self, orm): # Changing field 'Network.userid' db.alter_column('db_network', 'userid', self.gf('django.db.models.fields.CharField')(max_length=100)) - models = { 'db.flavor': { 'Meta': {'unique_together': "(('cpu', 'ram', 'disk'),)", 'object_name': 'Flavor'}, diff --git a/snf-cyclades-app/synnefo/db/migrations/0031_auto__del_imagemetadata__del_unique_imagemetadata_meta_key_image__del_.py b/snf-cyclades-app/synnefo/db/migrations/0031_auto__del_imagemetadata__del_unique_imagemetadata_meta_key_image__del_.py index 5615fa85a..ff80b7cb6 100644 --- a/snf-cyclades-app/synnefo/db/migrations/0031_auto__del_imagemetadata__del_unique_imagemetadata_meta_key_image__del_.py +++ b/snf-cyclades-app/synnefo/db/migrations/0031_auto__del_imagemetadata__del_unique_imagemetadata_meta_key_image__del_.py @@ -4,10 +4,11 @@ from south.v2 import SchemaMigration from django.db import models + class Migration(SchemaMigration): def forwards(self, orm): - + # Removing unique constraint on 'ImageMetadata', fields ['meta_key', 'image'] db.delete_unique('db_imagemetadata', ['meta_key', 'image_id']) @@ -20,9 +21,8 @@ def forwards(self, orm): # Deleting field 'VirtualMachine.charged' db.delete_column('db_virtualmachine', 'charged') - def backwards(self, orm): - + # Adding model 'ImageMetadata' db.create_table('db_imagemetadata', ( ('meta_value', self.gf('django.db.models.fields.CharField')(max_length=500)), @@ -53,7 +53,6 @@ def backwards(self, orm): # Adding field 'VirtualMachine.charged' db.add_column('db_virtualmachine', 'charged', self.gf('django.db.models.fields.DateTimeField')(default=datetime.datetime(2012, 1, 23, 15, 32, 51, 475392)), keep_default=False) - models = { 'db.flavor': { 'Meta': {'unique_together': "(('cpu', 'ram', 'disk'),)", 'object_name': 'Flavor'}, diff --git a/snf-cyclades-app/synnefo/db/migrations/0032_auto__del_unique_flavor_disk_ram_cpu__add_unique_flavor_disk_ram_cpu_d.py b/snf-cyclades-app/synnefo/db/migrations/0032_auto__del_unique_flavor_disk_ram_cpu__add_unique_flavor_disk_ram_cpu_d.py index c8ac20d7e..bf9444c88 100644 --- a/snf-cyclades-app/synnefo/db/migrations/0032_auto__del_unique_flavor_disk_ram_cpu__add_unique_flavor_disk_ram_cpu_d.py +++ b/snf-cyclades-app/synnefo/db/migrations/0032_auto__del_unique_flavor_disk_ram_cpu__add_unique_flavor_disk_ram_cpu_d.py @@ -4,6 +4,7 @@ from south.v2 import SchemaMigration from django.db import models + class Migration(SchemaMigration): def forwards(self, orm): @@ -20,7 +21,6 @@ def forwards(self, orm): except: pass - def backwards(self, orm): try: @@ -35,7 +35,6 @@ def backwards(self, orm): except: pass - models = { 'db.flavor': { 'Meta': {'unique_together': "(('cpu', 'ram', 'disk', 'disk_template'),)", 'object_name': 'Flavor'}, diff --git a/snf-cyclades-app/synnefo/db/migrations/0033_auto__chg_field_networklink_available__add_field_virtualmachine_backen.py b/snf-cyclades-app/synnefo/db/migrations/0033_auto__chg_field_networklink_available__add_field_virtualmachine_backen.py index 451461abf..a31e5a18f 100644 --- a/snf-cyclades-app/synnefo/db/migrations/0033_auto__chg_field_networklink_available__add_field_virtualmachine_backen.py +++ b/snf-cyclades-app/synnefo/db/migrations/0033_auto__chg_field_networklink_available__add_field_virtualmachine_backen.py @@ -4,10 +4,11 @@ from south.v2 import SchemaMigration from django.db import models + class Migration(SchemaMigration): - + def forwards(self, orm): - + # Changing field 'NetworkLink.available' db.alter_column('db_networklink', 'available', self.gf('django.db.models.fields.BooleanField')(blank=True)) @@ -25,10 +26,9 @@ def forwards(self, orm): # Changing field 'Network.public' db.alter_column('db_network', 'public', self.gf('django.db.models.fields.BooleanField')(blank=True)) - - + def backwards(self, orm): - + # Changing field 'NetworkLink.available' db.alter_column('db_networklink', 'available', self.gf('django.db.models.fields.BooleanField')()) @@ -46,8 +46,7 @@ def backwards(self, orm): # Changing field 'Network.public' db.alter_column('db_network', 'public', self.gf('django.db.models.fields.BooleanField')()) - - + models = { 'db.flavor': { 'Meta': {'unique_together': "(('cpu', 'ram', 'disk', 'disk_template'),)", 'object_name': 'Flavor'}, @@ -120,5 +119,5 @@ def backwards(self, orm): 'vm': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'metadata'", 'to': "orm['db.VirtualMachine']"}) } } - + complete_apps = ['db'] diff --git a/snf-cyclades-app/synnefo/db/migrations/0034_auto__add_backend__add_field_virtualmachine_backend_hash__add_field_vi.py b/snf-cyclades-app/synnefo/db/migrations/0034_auto__add_backend__add_field_virtualmachine_backend_hash__add_field_vi.py index b6c35c084..62f3d198a 100644 --- a/snf-cyclades-app/synnefo/db/migrations/0034_auto__add_backend__add_field_virtualmachine_backend_hash__add_field_vi.py +++ b/snf-cyclades-app/synnefo/db/migrations/0034_auto__add_backend__add_field_virtualmachine_backend_hash__add_field_vi.py @@ -4,10 +4,11 @@ from south.v2 import SchemaMigration from django.db import models + class Migration(SchemaMigration): - + def forwards(self, orm): - + # Adding model 'Backend' db.create_table('db_backend', ( ('username', self.gf('django.db.models.fields.CharField')(max_length=64, null=True, blank=True)), @@ -33,10 +34,9 @@ def forwards(self, orm): # Adding field 'VirtualMachine.backend' db.add_column('db_virtualmachine', 'backend', self.gf('django.db.models.fields.related.ForeignKey')(related_name='virtual_machines', null=True, to=orm['db.Backend']), keep_default=False) - - + def backwards(self, orm): - + # Deleting model 'Backend' db.delete_table('db_backend') @@ -45,8 +45,7 @@ def backwards(self, orm): # Deleting field 'VirtualMachine.backend' db.delete_column('db_virtualmachine', 'backend_id') - - + models = { 'db.backend': { 'Meta': {'object_name': 'Backend'}, @@ -139,5 +138,5 @@ def backwards(self, orm): 'vm': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'metadata'", 'to': "orm['db.VirtualMachine']"}) } } - + complete_apps = ['db'] diff --git a/snf-cyclades-app/synnefo/db/migrations/0035_default_backend.py b/snf-cyclades-app/synnefo/db/migrations/0035_default_backend.py index 9468d698f..e0f5a04af 100644 --- a/snf-cyclades-app/synnefo/db/migrations/0035_default_backend.py +++ b/snf-cyclades-app/synnefo/db/migrations/0035_default_backend.py @@ -6,6 +6,7 @@ from django.conf import settings + class Migration(DataMigration): def forwards(self, orm): @@ -18,25 +19,20 @@ def forwards(self, orm): return (ip, port, username, password) = cluster_info - backend = orm.Backend.objects.create(clustername = ip, - port = port, - username = username, - password = password) + backend = orm.Backend.objects.create(clustername=ip, + port=port, + username=username, + password=password) for vm in orm.VirtualMachine.objects.all(): vm.backend = backend vm.save() - - - def backwards(self, orm): "Write your backwards methods here." for vm in orm.VirtualMachine.objects.all(): vm.backend = None vm.save() - - models = { 'db.backend': { 'Meta': {'object_name': 'Backend'}, diff --git a/snf-cyclades-app/synnefo/db/migrations/0036_auto__add_bridgepool__add_macprefixpool__add_field_network_backendtime.py b/snf-cyclades-app/synnefo/db/migrations/0036_auto__add_bridgepool__add_macprefixpool__add_field_network_backendtime.py index bb0647bbf..fcb2707d1 100644 --- a/snf-cyclades-app/synnefo/db/migrations/0036_auto__add_bridgepool__add_macprefixpool__add_field_network_backendtime.py +++ b/snf-cyclades-app/synnefo/db/migrations/0036_auto__add_bridgepool__add_macprefixpool__add_field_network_backendtime.py @@ -4,10 +4,11 @@ from south.v2 import SchemaMigration from django.db import models + class Migration(SchemaMigration): - + def forwards(self, orm): - + # Adding model 'BridgePool' db.create_table('db_bridgepool', ( ('available', self.gf('django.db.models.fields.BooleanField')(default=True, blank=True)), @@ -70,10 +71,9 @@ def forwards(self, orm): # Changing field 'Network.userid' db.alter_column('db_network', 'userid', self.gf('django.db.models.fields.CharField')(max_length=128, null=True)) - - + def backwards(self, orm): - + # Deleting model 'BridgePool' db.delete_table('db_bridgepool') @@ -124,8 +124,7 @@ def backwards(self, orm): # Changing field 'Network.userid' db.alter_column('db_network', 'userid', self.gf('django.db.models.fields.CharField')(max_length=100, null=True)) - - + models = { 'db.backend': { 'Meta': {'object_name': 'Backend'}, @@ -245,5 +244,5 @@ def backwards(self, orm): 'vm': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'metadata'", 'to': "orm['db.VirtualMachine']"}) } } - + complete_apps = ['db'] diff --git a/snf-cyclades-app/synnefo/db/migrations/0037_network_migration.py b/snf-cyclades-app/synnefo/db/migrations/0037_network_migration.py index 454b3fca6..e73bee840 100644 --- a/snf-cyclades-app/synnefo/db/migrations/0037_network_migration.py +++ b/snf-cyclades-app/synnefo/db/migrations/0037_network_migration.py @@ -5,6 +5,7 @@ from django.db import models from django.conf import settings + class Migration(DataMigration): def forwards(self, orm): @@ -30,8 +31,8 @@ def forwards(self, orm): network.netlink = network.link.name try: - # Do NOT import external code as can be depricated when the - # migration will run + # Do NOT import external code as can be depricated when the + # migration will run base = settings.MAC_POOL_BASE assert(len(base) == 7) network.mac_prefix = base @@ -48,7 +49,6 @@ def forwards(self, orm): network.save() - def backwards(self, orm): "Write your backwards methods here." pass @@ -172,5 +172,5 @@ def backwards(self, orm): 'vm': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'metadata'", 'to': "orm['db.VirtualMachine']"}) } } - + complete_apps = ['db'] diff --git a/snf-cyclades-app/synnefo/db/migrations/0038_auto__del_networklink__del_field_network_netlink__chg_field_network_li.py b/snf-cyclades-app/synnefo/db/migrations/0038_auto__del_networklink__del_field_network_netlink__chg_field_network_li.py index ef2e24136..978f5ac6a 100644 --- a/snf-cyclades-app/synnefo/db/migrations/0038_auto__del_networklink__del_field_network_netlink__chg_field_network_li.py +++ b/snf-cyclades-app/synnefo/db/migrations/0038_auto__del_networklink__del_field_network_netlink__chg_field_network_li.py @@ -4,10 +4,11 @@ from south.v2 import SchemaMigration from django.db import models + class Migration(SchemaMigration): - + def forwards(self, orm): - + # Deleting field 'Network.netlink' db.delete_column('db_network', 'link_id') @@ -17,10 +18,8 @@ def forwards(self, orm): # Deleting model 'NetworkLink' db.delete_table('db_networklink') - - def backwards(self, orm): - + # Adding model 'NetworkLink' db.create_table('db_networklink', ( ('available', self.gf('django.db.models.fields.BooleanField')(default=True, blank=True)), @@ -39,8 +38,7 @@ def backwards(self, orm): # Adding index on 'Network', fields ['link'] # db.create_index('db_network', ['link_id']) - - + models = { 'db.backend': { 'Meta': {'object_name': 'Backend'}, @@ -151,5 +149,5 @@ def backwards(self, orm): 'vm': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'metadata'", 'to': "orm['db.VirtualMachine']"}) } } - + complete_apps = ['db'] diff --git a/snf-cyclades-app/synnefo/db/migrations/0039_auto__add_backendnetwork__del_field_network_backendtime__del_field_net.py b/snf-cyclades-app/synnefo/db/migrations/0039_auto__add_backendnetwork__del_field_network_backendtime__del_field_net.py index 048f469a9..f18508b18 100644 --- a/snf-cyclades-app/synnefo/db/migrations/0039_auto__add_backendnetwork__del_field_network_backendtime__del_field_net.py +++ b/snf-cyclades-app/synnefo/db/migrations/0039_auto__add_backendnetwork__del_field_network_backendtime__del_field_net.py @@ -4,10 +4,11 @@ from south.v2 import SchemaMigration from django.db import models + class Migration(SchemaMigration): - + def forwards(self, orm): - + # Adding model 'BackendNetwork' db.create_table('db_backendnetwork', ( ('backendtime', self.gf('django.db.models.fields.DateTimeField')(default=datetime.datetime(1, 1, 1, 0, 0))), @@ -48,10 +49,9 @@ def forwards(self, orm): # Changing field 'Network.action' db.alter_column('db_network', 'action', self.gf('django.db.models.fields.CharField')(max_length=32, null=True)) - - + def backwards(self, orm): - + # Deleting model 'BackendNetwork' db.delete_table('db_backendnetwork') @@ -78,8 +78,7 @@ def backwards(self, orm): # Changing field 'Network.action' db.alter_column('db_network', 'action', self.gf('django.db.models.fields.CharField')(max_length=30, null=True)) - - + models = { 'db.backend': { 'Meta': {'object_name': 'Backend'}, @@ -200,5 +199,5 @@ def backwards(self, orm): 'vm': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'metadata'", 'to': "orm['db.VirtualMachine']"}) } } - + complete_apps = ['db'] diff --git a/snf-cyclades-app/synnefo/db/migrations/0040_auto__chg_field_networkinterface_index.py b/snf-cyclades-app/synnefo/db/migrations/0040_auto__chg_field_networkinterface_index.py index 1c3c40db4..3f4217db9 100644 --- a/snf-cyclades-app/synnefo/db/migrations/0040_auto__chg_field_networkinterface_index.py +++ b/snf-cyclades-app/synnefo/db/migrations/0040_auto__chg_field_networkinterface_index.py @@ -4,20 +4,19 @@ from south.v2 import SchemaMigration from django.db import models + class Migration(SchemaMigration): - + def forwards(self, orm): - + # Changing field 'NetworkInterface.index' db.alter_column('db_networkinterface', 'index', self.gf('django.db.models.fields.IntegerField')()) - - + def backwards(self, orm): - + # Changing field 'NetworkInterface.index' db.alter_column('db_networkinterface', 'index', self.gf('django.db.models.fields.IntegerField')(null=True)) - - + models = { 'db.backend': { 'Meta': {'object_name': 'Backend'}, @@ -138,5 +137,5 @@ def backwards(self, orm): 'vm': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'metadata'", 'to': "orm['db.VirtualMachine']"}) } } - + complete_apps = ['db'] diff --git a/snf-cyclades-app/synnefo/db/migrations/0041_auto__add_field_networkinterface_dirty.py b/snf-cyclades-app/synnefo/db/migrations/0041_auto__add_field_networkinterface_dirty.py index 983c5420e..3597202da 100644 --- a/snf-cyclades-app/synnefo/db/migrations/0041_auto__add_field_networkinterface_dirty.py +++ b/snf-cyclades-app/synnefo/db/migrations/0041_auto__add_field_networkinterface_dirty.py @@ -4,20 +4,19 @@ from south.v2 import SchemaMigration from django.db import models + class Migration(SchemaMigration): - + def forwards(self, orm): - + # Adding field 'NetworkInterface.dirty' db.add_column('db_networkinterface', 'dirty', self.gf('django.db.models.fields.BooleanField')(default=False, blank=True), keep_default=False) - - + def backwards(self, orm): - + # Deleting field 'NetworkInterface.dirty' db.delete_column('db_networkinterface', 'dirty') - - + models = { 'db.backend': { 'Meta': {'object_name': 'Backend'}, @@ -139,5 +138,5 @@ def backwards(self, orm): 'vm': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'metadata'", 'to': "orm['db.VirtualMachine']"}) } } - + complete_apps = ['db'] diff --git a/snf-cyclades-app/synnefo/db/migrations/0042_auto__del_field_backend_password__add_field_backend_password_hash.py b/snf-cyclades-app/synnefo/db/migrations/0042_auto__del_field_backend_password__add_field_backend_password_hash.py index daf59446d..4b7d8bf5d 100644 --- a/snf-cyclades-app/synnefo/db/migrations/0042_auto__del_field_backend_password__add_field_backend_password_hash.py +++ b/snf-cyclades-app/synnefo/db/migrations/0042_auto__del_field_backend_password__add_field_backend_password_hash.py @@ -4,19 +4,19 @@ from south.v2 import SchemaMigration from django.db import models + class Migration(SchemaMigration): - + def forwards(self, orm): - + # Rename field 'Backend.password' to 'Backend.password_hash' db.rename_column('db_backend', 'password', 'password_hash') - + def backwards(self, orm): - + # Rename field 'Backend.password_hash' to 'Backend.password' db.rename_column('db_backend', 'password_hash', 'password') - - + models = { 'db.backend': { 'Meta': {'object_name': 'Backend'}, @@ -138,5 +138,5 @@ def backwards(self, orm): 'vm': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'metadata'", 'to': "orm['db.VirtualMachine']"}) } } - + complete_apps = ['db'] diff --git a/snf-cyclades-app/synnefo/db/migrations/0043_encrypt_passwords.py b/snf-cyclades-app/synnefo/db/migrations/0043_encrypt_passwords.py index ce6686dcc..8ec77c147 100644 --- a/snf-cyclades-app/synnefo/db/migrations/0043_encrypt_passwords.py +++ b/snf-cyclades-app/synnefo/db/migrations/0043_encrypt_passwords.py @@ -13,8 +13,9 @@ encrypt = None decrypt = None + class Migration(DataMigration): - + def forwards(self, orm): "Write your forwards methods here." if encrypt and decrypt: @@ -25,12 +26,10 @@ def forwards(self, orm): backend.save() else: pass - - + def backwards(self, orm): "Write your backwards methods here." pass - models = { 'db.backend': { 'Meta': {'object_name': 'Backend'}, @@ -152,5 +151,5 @@ def backwards(self, orm): 'vm': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'metadata'", 'to': "orm['db.VirtualMachine']"}) } } - + complete_apps = ['db'] diff --git a/snf-cyclades-app/synnefo/db/migrations/0044_auto__add_field_network_subnet6__add_field_network_gateway6.py b/snf-cyclades-app/synnefo/db/migrations/0044_auto__add_field_network_subnet6__add_field_network_gateway6.py index de8ccf407..d7893c76e 100644 --- a/snf-cyclades-app/synnefo/db/migrations/0044_auto__add_field_network_subnet6__add_field_network_gateway6.py +++ b/snf-cyclades-app/synnefo/db/migrations/0044_auto__add_field_network_subnet6__add_field_network_gateway6.py @@ -4,26 +4,25 @@ from south.v2 import SchemaMigration from django.db import models + class Migration(SchemaMigration): - + def forwards(self, orm): - + # Adding field 'Network.subnet6' db.add_column('db_network', 'subnet6', self.gf('django.db.models.fields.CharField')(max_length=64, null=True), keep_default=False) # Adding field 'Network.gateway6' db.add_column('db_network', 'gateway6', self.gf('django.db.models.fields.CharField')(max_length=64, null=True), keep_default=False) - - + def backwards(self, orm): - + # Deleting field 'Network.subnet6' db.delete_column('db_network', 'subnet6') # Deleting field 'Network.gateway6' db.delete_column('db_network', 'gateway6') - - + models = { 'db.backend': { 'Meta': {'object_name': 'Backend'}, @@ -147,5 +146,5 @@ def backwards(self, orm): 'vm': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'metadata'", 'to': "orm['db.VirtualMachine']"}) } } - + complete_apps = ['db'] diff --git a/snf-cyclades-app/synnefo/db/migrations/0045_auto__chg_field_networkinterface_mac__add_field_network_reservations.py b/snf-cyclades-app/synnefo/db/migrations/0045_auto__chg_field_networkinterface_mac__add_field_network_reservations.py index d896edfdb..6660bf168 100644 --- a/snf-cyclades-app/synnefo/db/migrations/0045_auto__chg_field_networkinterface_mac__add_field_network_reservations.py +++ b/snf-cyclades-app/synnefo/db/migrations/0045_auto__chg_field_networkinterface_mac__add_field_network_reservations.py @@ -4,26 +4,25 @@ from south.v2 import SchemaMigration from django.db import models + class Migration(SchemaMigration): - + def forwards(self, orm): - + # Changing field 'NetworkInterface.mac' db.alter_column('db_networkinterface', 'mac', self.gf('django.db.models.fields.CharField')(max_length=32, null=True)) # Adding field 'Network.reservations' db.add_column('db_network', 'reservations', self.gf('django.db.models.fields.TextField')(default=''), keep_default=False) - - + def backwards(self, orm): - + # Changing field 'NetworkInterface.mac' db.alter_column('db_networkinterface', 'mac', self.gf('django.db.models.fields.CharField')(max_length=17, null=True)) # Deleting field 'Network.reservations' db.delete_column('db_network', 'reservations') - - + models = { 'db.backend': { 'Meta': {'object_name': 'Backend'}, @@ -148,5 +147,5 @@ def backwards(self, orm): 'vm': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'metadata'", 'to': "orm['db.VirtualMachine']"}) } } - + complete_apps = ['db'] diff --git a/snf-cyclades-app/synnefo/db/migrations/0046_auto__chg_field_backend_password_hash.py b/snf-cyclades-app/synnefo/db/migrations/0046_auto__chg_field_backend_password_hash.py index 5a913b0ae..135f53f38 100644 --- a/snf-cyclades-app/synnefo/db/migrations/0046_auto__chg_field_backend_password_hash.py +++ b/snf-cyclades-app/synnefo/db/migrations/0046_auto__chg_field_backend_password_hash.py @@ -4,20 +4,19 @@ from south.v2 import SchemaMigration from django.db import models + class Migration(SchemaMigration): - + def forwards(self, orm): - + # Changing field 'Backend.password_hash' db.alter_column('db_backend', 'password_hash', self.gf('django.db.models.fields.CharField')(max_length=128, null=True, blank=True)) - - + def backwards(self, orm): - + # Changing field 'Backend.password_hash' db.alter_column('db_backend', 'password_hash', self.gf('django.db.models.fields.CharField')(max_length=64, null=True, blank=True)) - - + models = { 'db.backend': { 'Meta': {'object_name': 'Backend'}, @@ -142,5 +141,5 @@ def backwards(self, orm): 'vm': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'metadata'", 'to': "orm['db.VirtualMachine']"}) } } - + complete_apps = ['db'] diff --git a/snf-cyclades-app/synnefo/db/migrations/0047_auto__chg_field_networkinterface_mac__add_unique_networkinterface_mac_.py b/snf-cyclades-app/synnefo/db/migrations/0047_auto__chg_field_networkinterface_mac__add_unique_networkinterface_mac_.py index 66ad185f9..b79dd666e 100644 --- a/snf-cyclades-app/synnefo/db/migrations/0047_auto__chg_field_networkinterface_mac__add_unique_networkinterface_mac_.py +++ b/snf-cyclades-app/synnefo/db/migrations/0047_auto__chg_field_networkinterface_mac__add_unique_networkinterface_mac_.py @@ -4,10 +4,11 @@ from south.v2 import SchemaMigration from django.db import models + class Migration(SchemaMigration): - + def forwards(self, orm): - + # Changing field 'NetworkInterface.mac' db.alter_column('db_networkinterface', 'mac', self.gf('django.db.models.fields.CharField')(unique=True, max_length=32)) @@ -18,14 +19,13 @@ def forwards(self, orm): db.add_column('db_backend', 'index', self.gf('django.db.models.fields.PositiveIntegerField')(default=0, unique=True), keep_default=False) # Changing field 'Network.mac_prefix' - db.alter_column('db_network', 'mac_prefix',self.gf('django.db.models.fields.CharField')(default='', max_length=32, null=True)) + db.alter_column('db_network', 'mac_prefix', self.gf('django.db.models.fields.CharField')(default='', max_length=32, null=True)) # Adding field 'BackendNetwork.mac_prefix' db.add_column('db_backendnetwork', 'mac_prefix', self.gf('django.db.models.fields.CharField')(default='', max_length=32), keep_default=False) - - + def backwards(self, orm): - + # Changing field 'NetworkInterface.mac' db.alter_column('db_networkinterface', 'mac', self.gf('django.db.models.fields.CharField')(max_length=32, null=True)) @@ -40,8 +40,7 @@ def backwards(self, orm): # Deleting field 'BackendNetwork.mac_prefix' db.delete_column('db_backendnetwork', 'mac_prefix') - - + models = { 'db.backend': { 'Meta': {'object_name': 'Backend'}, @@ -111,8 +110,7 @@ def backwards(self, orm): 'gateway6': ('django.db.models.fields.CharField', [], {'max_length': '64', 'null': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'link': ('django.db.models.fields.CharField', [], {'max_length': '128', 'null': 'True'}), - 'mac_prefix': ('django.db.models.fields.CharField', [], {'default': - "''", 'max_length': '32', 'null':'True'}), + 'mac_prefix': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '32', 'null': 'True'}), 'machines': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['db.VirtualMachine']", 'through': "orm['db.NetworkInterface']", 'symmetrical': 'False'}), 'name': ('django.db.models.fields.CharField', [], {'max_length': '128'}), 'public': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'blank': 'True'}), @@ -169,5 +167,5 @@ def backwards(self, orm): 'vm': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'metadata'", 'to': "orm['db.VirtualMachine']"}) } } - + complete_apps = ['db'] diff --git a/snf-cyclades-app/synnefo/db/migrations/0049_not_null_mac_prefix.py b/snf-cyclades-app/synnefo/db/migrations/0049_not_null_mac_prefix.py index 295fc63ec..43c3605db 100644 --- a/snf-cyclades-app/synnefo/db/migrations/0049_not_null_mac_prefix.py +++ b/snf-cyclades-app/synnefo/db/migrations/0049_not_null_mac_prefix.py @@ -4,18 +4,17 @@ from south.v2 import SchemaMigration from django.db import models + class Migration(SchemaMigration): - + def forwards(self, orm): # Changing field 'Network.mac_prefix' db.alter_column('db_network', 'mac_prefix', self.gf('django.db.models.fields.CharField')(max_length=32, null=False)) - - + def backwards(self, orm): # Changing field 'Network.mac_prefix' db.alter_column('db_network', 'mac_prefix', self.gf('django.db.models.fields.CharField')(default='', max_length=32, null=True)) - - + models = { 'db.backend': { 'Meta': {'object_name': 'Backend'}, @@ -142,5 +141,5 @@ def backwards(self, orm): 'vm': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'metadata'", 'to': "orm['db.VirtualMachine']"}) } } - + complete_apps = ['db'] diff --git a/snf-cyclades-app/synnefo/db/migrations/0050_auto__add_unique_backendnetwork_network_backend.py b/snf-cyclades-app/synnefo/db/migrations/0050_auto__add_unique_backendnetwork_network_backend.py index a58474cf4..0e4b36bad 100644 --- a/snf-cyclades-app/synnefo/db/migrations/0050_auto__add_unique_backendnetwork_network_backend.py +++ b/snf-cyclades-app/synnefo/db/migrations/0050_auto__add_unique_backendnetwork_network_backend.py @@ -4,20 +4,19 @@ from south.v2 import SchemaMigration from django.db import models + class Migration(SchemaMigration): - + def forwards(self, orm): - + # Adding unique constraint on 'BackendNetwork', fields ['network', 'backend'] db.create_unique('db_backendnetwork', ['network_id', 'backend_id']) - - + def backwards(self, orm): - + # Removing unique constraint on 'BackendNetwork', fields ['network', 'backend'] db.delete_unique('db_backendnetwork', ['network_id', 'backend_id']) - - + models = { 'db.backend': { 'Meta': {'object_name': 'Backend'}, @@ -144,5 +143,5 @@ def backwards(self, orm): 'vm': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'metadata'", 'to': "orm['db.VirtualMachine']"}) } } - + complete_apps = ['db'] diff --git a/snf-cyclades-app/synnefo/db/migrations/0051_auto__add_bridgepooltable__add_macprefixpooltable.py b/snf-cyclades-app/synnefo/db/migrations/0051_auto__add_bridgepooltable__add_macprefixpooltable.py index 3ad1589c6..428557039 100644 --- a/snf-cyclades-app/synnefo/db/migrations/0051_auto__add_bridgepooltable__add_macprefixpooltable.py +++ b/snf-cyclades-app/synnefo/db/migrations/0051_auto__add_bridgepooltable__add_macprefixpooltable.py @@ -4,10 +4,11 @@ from south.v2 import SchemaMigration from django.db import models + class Migration(SchemaMigration): - + def forwards(self, orm): - + # Adding model 'BridgePoolTable' db.create_table('db_bridgepooltable', ( ('reserved_map', self.gf('django.db.models.fields.TextField')(default='')), @@ -29,17 +30,15 @@ def forwards(self, orm): ('size', self.gf('django.db.models.fields.IntegerField')()), )) db.send_create_signal('db', ['MacPrefixPoolTable']) - - + def backwards(self, orm): - + # Deleting model 'BridgePoolTable' db.delete_table('db_bridgepooltable') # Deleting model 'MacPrefixPoolTable' db.delete_table('db_macprefixpooltable') - - + models = { 'db.backend': { 'Meta': {'object_name': 'Backend'}, @@ -184,5 +183,5 @@ def backwards(self, orm): 'vm': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'metadata'", 'to': "orm['db.VirtualMachine']"}) } } - + complete_apps = ['db'] diff --git a/snf-cyclades-app/synnefo/db/migrations/0052_migrate_pool_entries.py b/snf-cyclades-app/synnefo/db/migrations/0052_migrate_pool_entries.py index 2f5318e8e..92be4da18 100644 --- a/snf-cyclades-app/synnefo/db/migrations/0052_migrate_pool_entries.py +++ b/snf-cyclades-app/synnefo/db/migrations/0052_migrate_pool_entries.py @@ -7,19 +7,23 @@ from bitarray import bitarray from base64 import b64encode + def create_empty_pool(size): ba = bitarray(size) ba.setall(True) return ba + def bitarray_to_string(bitarray_): return b64encode(bitarray_.tobytes()) + def validate_mac(value): hex_ = value.replace(":", "") bin_ = bin(int(hex_, 16))[2:].zfill(8) return bin_[6] == '1' and bin_[7] == '0' + def mac_from_index(base, index): """Convert number to mac prefix @@ -28,8 +32,9 @@ def mac_from_index(base, index): mac_prefix = ":".join([a[x:x + 2] for x in xrange(0, len(a), 2)]) return mac_prefix + class Migration(DataMigration): - + def forwards(self, orm): "Write your forwards methods here." @@ -63,7 +68,6 @@ def forwards(self, orm): size=pool_length, base=pool_prefix) - mac_prefixes = orm.MacPrefixPool.objects.all() if mac_prefixes: try: @@ -72,8 +76,8 @@ def forwards(self, orm): macp_base = settings.MAC_POOL_BASE except AttributeError: first = mac_prefixes[0] - first[-1]= '0' - macp_base = first + first[-1] = '0' + macp_base = first try: macp_length = settings.MAC_POOL_LIMIT @@ -96,9 +100,9 @@ def forwards(self, orm): reserved_map = bitarray_to_string(reserved) orm.MacPrefixPoolTable.objects.create(available_map=available_map, - reserved_map=reserved_map, - size=macp_length, - base=macp_base) + reserved_map=reserved_map, + size=macp_length, + base=macp_base) def backwards(self, orm): "Write your backwards methods here." @@ -248,5 +252,5 @@ def backwards(self, orm): 'vm': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'metadata'", 'to': "orm['db.VirtualMachine']"}) } } - + complete_apps = ['db'] diff --git a/snf-cyclades-app/synnefo/db/migrations/0053_auto__del_bridgepool__del_macprefixpool.py b/snf-cyclades-app/synnefo/db/migrations/0053_auto__del_bridgepool__del_macprefixpool.py index fcf384b59..f676c074f 100644 --- a/snf-cyclades-app/synnefo/db/migrations/0053_auto__del_bridgepool__del_macprefixpool.py +++ b/snf-cyclades-app/synnefo/db/migrations/0053_auto__del_bridgepool__del_macprefixpool.py @@ -4,19 +4,19 @@ from south.v2 import SchemaMigration from django.db import models + class Migration(SchemaMigration): - + def forwards(self, orm): - + # Deleting model 'BridgePool' db.delete_table('db_bridgepool') # Deleting model 'MacPrefixPool' db.delete_table('db_macprefixpool') - - + def backwards(self, orm): - + # Adding model 'BridgePool' db.create_table('db_bridgepool', ( ('available', self.gf('django.db.models.fields.BooleanField')(default=True, blank=True)), @@ -34,8 +34,7 @@ def backwards(self, orm): ('value', self.gf('django.db.models.fields.CharField')(max_length=128, unique=True)), )) db.send_create_signal('db', ['MacPrefixPool']) - - + models = { 'db.backend': { 'Meta': {'object_name': 'Backend'}, @@ -166,5 +165,5 @@ def backwards(self, orm): 'vm': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'metadata'", 'to': "orm['db.VirtualMachine']"}) } } - + complete_apps = ['db'] diff --git a/snf-cyclades-app/synnefo/db/migrations/0054_auto__add_ippooltable__add_field_network_pool.py b/snf-cyclades-app/synnefo/db/migrations/0054_auto__add_ippooltable__add_field_network_pool.py index eabbcdce5..ec67f09ae 100644 --- a/snf-cyclades-app/synnefo/db/migrations/0054_auto__add_ippooltable__add_field_network_pool.py +++ b/snf-cyclades-app/synnefo/db/migrations/0054_auto__add_ippooltable__add_field_network_pool.py @@ -4,10 +4,11 @@ from south.v2 import SchemaMigration from django.db import models + class Migration(SchemaMigration): - + def forwards(self, orm): - + # Adding model 'IPPoolTable' db.create_table('db_ippooltable', ( ('reserved_map', self.gf('django.db.models.fields.TextField')(default='')), @@ -21,17 +22,15 @@ def forwards(self, orm): # Adding field 'Network.pool' db.add_column('db_network', 'pool', self.gf('django.db.models.fields.related.OneToOneField')(related_name='network', unique=True, null=True, to=orm['db.IPPoolTable']), keep_default=False) - - + def backwards(self, orm): - + # Deleting model 'IPPoolTable' db.delete_table('db_ippooltable') # Deleting field 'Network.pool' db.delete_column('db_network', 'pool_id') - - + models = { 'db.backend': { 'Meta': {'object_name': 'Backend'}, @@ -172,5 +171,5 @@ def backwards(self, orm): 'vm': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'metadata'", 'to': "orm['db.VirtualMachine']"}) } } - + complete_apps = ['db'] diff --git a/snf-cyclades-app/synnefo/db/migrations/0056_auto__del_field_network_reservations.py b/snf-cyclades-app/synnefo/db/migrations/0056_auto__del_field_network_reservations.py index d38c4868c..82ace486c 100644 --- a/snf-cyclades-app/synnefo/db/migrations/0056_auto__del_field_network_reservations.py +++ b/snf-cyclades-app/synnefo/db/migrations/0056_auto__del_field_network_reservations.py @@ -4,20 +4,19 @@ from south.v2 import SchemaMigration from django.db import models + class Migration(SchemaMigration): - + def forwards(self, orm): - + # Deleting field 'Network.reservations' db.delete_column('db_network', 'reservations') - - + def backwards(self, orm): - + # Adding field 'Network.reservations' db.add_column('db_network', 'reservations', self.gf('django.db.models.fields.TextField')(default=''), keep_default=False) - - + models = { 'db.backend': { 'Meta': {'object_name': 'Backend'}, @@ -157,5 +156,5 @@ def backwards(self, orm): 'vm': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'metadata'", 'to': "orm['db.VirtualMachine']"}) } } - + complete_apps = ['db'] diff --git a/snf-cyclades-app/synnefo/db/migrations/0057_auto__add_virtualmachinediagnostic.py b/snf-cyclades-app/synnefo/db/migrations/0057_auto__add_virtualmachinediagnostic.py index 04ee609de..ca9e4bed6 100644 --- a/snf-cyclades-app/synnefo/db/migrations/0057_auto__add_virtualmachinediagnostic.py +++ b/snf-cyclades-app/synnefo/db/migrations/0057_auto__add_virtualmachinediagnostic.py @@ -4,10 +4,11 @@ from south.v2 import SchemaMigration from django.db import models + class Migration(SchemaMigration): def forwards(self, orm): - + # Adding model 'VirtualMachineDiagnostic' db.create_table('db_virtualmachinediagnostic', ( ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), @@ -21,13 +22,11 @@ def forwards(self, orm): )) db.send_create_signal('db', ['VirtualMachineDiagnostic']) - def backwards(self, orm): - + # Deleting model 'VirtualMachineDiagnostic' db.delete_table('db_virtualmachinediagnostic') - models = { 'db.backend': { 'Meta': {'ordering': "['clustername']", 'object_name': 'Backend'}, diff --git a/snf-cyclades-app/synnefo/db/migrations/0058_auto__chg_field_networkinterface_dirty__chg_field_virtualmachine_delet.py b/snf-cyclades-app/synnefo/db/migrations/0058_auto__chg_field_networkinterface_dirty__chg_field_virtualmachine_delet.py index 67ca24549..7269b665b 100644 --- a/snf-cyclades-app/synnefo/db/migrations/0058_auto__chg_field_networkinterface_dirty__chg_field_virtualmachine_delet.py +++ b/snf-cyclades-app/synnefo/db/migrations/0058_auto__chg_field_networkinterface_dirty__chg_field_virtualmachine_delet.py @@ -4,10 +4,11 @@ from south.v2 import SchemaMigration from django.db import models + class Migration(SchemaMigration): def forwards(self, orm): - + # Changing field 'NetworkInterface.dirty' db.alter_column('db_networkinterface', 'dirty', self.gf('django.db.models.fields.BooleanField')(blank=True)) @@ -53,9 +54,8 @@ def forwards(self, orm): # Changing field 'BackendNetwork.deleted' db.alter_column('db_backendnetwork', 'deleted', self.gf('django.db.models.fields.BooleanField')(blank=True)) - def backwards(self, orm): - + # Changing field 'NetworkInterface.dirty' db.alter_column('db_networkinterface', 'dirty', self.gf('django.db.models.fields.BooleanField')()) @@ -101,7 +101,6 @@ def backwards(self, orm): # Changing field 'BackendNetwork.deleted' db.alter_column('db_backendnetwork', 'deleted', self.gf('django.db.models.fields.BooleanField')()) - models = { 'db.backend': { 'Meta': {'object_name': 'Backend'}, diff --git a/snf-cyclades-app/synnefo/db/migrations/0059_auto__add_quotaholderserial__add_field_virtualmachine_serial__add_fiel.py b/snf-cyclades-app/synnefo/db/migrations/0059_auto__add_quotaholderserial__add_field_virtualmachine_serial__add_fiel.py index 6b98e66b4..4af04aca8 100644 --- a/snf-cyclades-app/synnefo/db/migrations/0059_auto__add_quotaholderserial__add_field_virtualmachine_serial__add_fiel.py +++ b/snf-cyclades-app/synnefo/db/migrations/0059_auto__add_quotaholderserial__add_field_virtualmachine_serial__add_fiel.py @@ -4,10 +4,11 @@ from south.v2 import SchemaMigration from django.db import models + class Migration(SchemaMigration): def forwards(self, orm): - + # Adding model 'QuotaHolderSerial' db.create_table('db_quotaholderserial', ( ('serial', self.gf('django.db.models.fields.BigIntegerField')(primary_key=True, db_index=True)), @@ -23,9 +24,8 @@ def forwards(self, orm): # Adding field 'Network.serial' db.add_column('db_network', 'serial', self.gf('django.db.models.fields.related.ForeignKey')(related_name='network', null=True, to=orm['db.QuotaHolderSerial']), keep_default=False) - def backwards(self, orm): - + # Deleting model 'QuotaHolderSerial' db.delete_table('db_quotaholderserial') @@ -35,7 +35,6 @@ def backwards(self, orm): # Deleting field 'Network.serial' db.delete_column('db_network', 'serial_id') - models = { 'db.backend': { 'Meta': {'object_name': 'Backend'}, diff --git a/snf-cyclades-app/synnefo/db/migrations/0060_auto__del_field_network_type__add_field_network_flavor__add_field_netw.py b/snf-cyclades-app/synnefo/db/migrations/0060_auto__del_field_network_type__add_field_network_flavor__add_field_netw.py index ce3cc110a..5b5374583 100644 --- a/snf-cyclades-app/synnefo/db/migrations/0060_auto__del_field_network_type__add_field_network_flavor__add_field_netw.py +++ b/snf-cyclades-app/synnefo/db/migrations/0060_auto__del_field_network_type__add_field_network_flavor__add_field_netw.py @@ -4,10 +4,11 @@ from south.v2 import SchemaMigration from django.db import models + class Migration(SchemaMigration): def forwards(self, orm): - + # Rename field 'Network.type' to 'Network.flavor' db.rename_column('db_network', 'type', 'flavor') @@ -20,9 +21,8 @@ def forwards(self, orm): # Changing field 'Network.link' db.alter_column('db_network', 'link', self.gf('django.db.models.fields.CharField')(max_length=32, null=True)) - def backwards(self, orm): - + # Rename field 'Network.type' to 'Network.flavor' db.rename_column('db_network', 'flavor', 'type') @@ -35,7 +35,6 @@ def backwards(self, orm): # Changing field 'Network.link' db.alter_column('db_network', 'link', self.gf('django.db.models.fields.CharField')(max_length=128, null=True)) - models = { 'db.backend': { 'Meta': {'object_name': 'Backend'}, diff --git a/snf-cyclades-app/synnefo/db/migrations/0061_network_flavors.py b/snf-cyclades-app/synnefo/db/migrations/0061_network_flavors.py index 47a8c57e5..1d81a9043 100644 --- a/snf-cyclades-app/synnefo/db/migrations/0061_network_flavors.py +++ b/snf-cyclades-app/synnefo/db/migrations/0061_network_flavors.py @@ -4,6 +4,7 @@ from south.v2 import DataMigration from django.db import models + class Migration(DataMigration): def forwards(self, orm): @@ -31,7 +32,6 @@ def forwards(self, orm): net.tags = None net.save() - def backwards(self, orm): "Write your backwards methods here." for net in orm.Network.objects.all(): @@ -47,7 +47,6 @@ def backwards(self, orm): net.flavor = 'PRIVATE_PHYSICAL_VLAN' net.save() - models = { 'db.backend': { 'Meta': {'object_name': 'Backend'}, diff --git a/snf-cyclades-app/synnefo/db/migrations/0062_auto__add_field_networkinterface_state__chg_field_networkinterface_mac.py b/snf-cyclades-app/synnefo/db/migrations/0062_auto__add_field_networkinterface_state__chg_field_networkinterface_mac.py index 0c6ff027a..ddb97baa4 100644 --- a/snf-cyclades-app/synnefo/db/migrations/0062_auto__add_field_networkinterface_state__chg_field_networkinterface_mac.py +++ b/snf-cyclades-app/synnefo/db/migrations/0062_auto__add_field_networkinterface_state__chg_field_networkinterface_mac.py @@ -4,26 +4,25 @@ from south.v2 import SchemaMigration from django.db import models + class Migration(SchemaMigration): def forwards(self, orm): - + # Adding field 'NetworkInterface.state' db.add_column('db_networkinterface', 'state', self.gf('django.db.models.fields.CharField')(default='ACTIVE', max_length=32), keep_default=False) # Changing field 'NetworkInterface.mac' db.alter_column('db_networkinterface', 'mac', self.gf('django.db.models.fields.CharField')(max_length=32, unique=True, null=True)) - def backwards(self, orm): - + # Deleting field 'NetworkInterface.state' db.delete_column('db_networkinterface', 'state') # Changing field 'NetworkInterface.mac' db.alter_column('db_networkinterface', 'mac', self.gf('django.db.models.fields.CharField')(max_length=32, unique=True)) - models = { 'db.backend': { 'Meta': {'object_name': 'Backend'}, diff --git a/snf-cyclades-app/synnefo/db/migrations/0063_auto__add_field_quotaholderserial_accept__add_field_quotaholderserial_.py b/snf-cyclades-app/synnefo/db/migrations/0063_auto__add_field_quotaholderserial_accept__add_field_quotaholderserial_.py index 7e039cd73..9b504eff4 100644 --- a/snf-cyclades-app/synnefo/db/migrations/0063_auto__add_field_quotaholderserial_accept__add_field_quotaholderserial_.py +++ b/snf-cyclades-app/synnefo/db/migrations/0063_auto__add_field_quotaholderserial_accept__add_field_quotaholderserial_.py @@ -4,26 +4,25 @@ from south.v2 import SchemaMigration from django.db import models + class Migration(SchemaMigration): def forwards(self, orm): - + # Adding field 'QuotaHolderSerial.accept' db.add_column('db_quotaholderserial', 'accept', self.gf('django.db.models.fields.BooleanField')(default=False, blank=True), keep_default=False) # Adding field 'QuotaHolderSerial.resolved' db.add_column('db_quotaholderserial', 'resolved', self.gf('django.db.models.fields.BooleanField')(default=False, blank=True), keep_default=False) - def backwards(self, orm): - + # Deleting field 'QuotaHolderSerial.accept' db.delete_column('db_quotaholderserial', 'accept') # Deleting field 'QuotaHolderSerial.resolved' db.delete_column('db_quotaholderserial', 'resolved') - models = { 'db.backend': { 'Meta': {'object_name': 'Backend'}, diff --git a/snf-cyclades-app/synnefo/db/migrations/0064_serials.py b/snf-cyclades-app/synnefo/db/migrations/0064_serials.py index afa169ef2..557ef9ed4 100644 --- a/snf-cyclades-app/synnefo/db/migrations/0064_serials.py +++ b/snf-cyclades-app/synnefo/db/migrations/0064_serials.py @@ -4,6 +4,7 @@ from south.v2 import DataMigration from django.db import models + class Migration(DataMigration): def forwards(self, orm): @@ -14,7 +15,6 @@ def forwards(self, orm): serial.resolved = True serial.save() - def backwards(self, orm): "Write your backwards methods here." for serial in orm.QuotaHolderSerial.objects.filter(pending=False): @@ -24,7 +24,6 @@ def backwards(self, orm): serial.rejected = True serial.save() - models = { 'db.backend': { 'Meta': {'object_name': 'Backend'}, diff --git a/snf-cyclades-app/synnefo/db/migrations/0065_auto__del_field_quotaholderserial_rejected__del_field_quotaholderseria.py b/snf-cyclades-app/synnefo/db/migrations/0065_auto__del_field_quotaholderserial_rejected__del_field_quotaholderseria.py index d2e235441..13483b703 100644 --- a/snf-cyclades-app/synnefo/db/migrations/0065_auto__del_field_quotaholderserial_rejected__del_field_quotaholderseria.py +++ b/snf-cyclades-app/synnefo/db/migrations/0065_auto__del_field_quotaholderserial_rejected__del_field_quotaholderseria.py @@ -4,26 +4,25 @@ from south.v2 import SchemaMigration from django.db import models + class Migration(SchemaMigration): def forwards(self, orm): - + # Deleting field 'QuotaHolderSerial.rejected' db.delete_column('db_quotaholderserial', 'rejected') # Deleting field 'QuotaHolderSerial.accepted' db.delete_column('db_quotaholderserial', 'accepted') - def backwards(self, orm): - + # Adding field 'QuotaHolderSerial.rejected' db.add_column('db_quotaholderserial', 'rejected', self.gf('django.db.models.fields.BooleanField')(default=False, blank=True), keep_default=False) # Adding field 'QuotaHolderSerial.accepted' db.add_column('db_quotaholderserial', 'accepted', self.gf('django.db.models.fields.BooleanField')(default=False, blank=True), keep_default=False) - models = { 'db.backend': { 'Meta': {'object_name': 'Backend'}, diff --git a/snf-cyclades-app/synnefo/db/migrations/0067_auto__add_field_backend_hypervisor.py b/snf-cyclades-app/synnefo/db/migrations/0067_auto__add_field_backend_hypervisor.py index 234fc334f..9e34a3491 100644 --- a/snf-cyclades-app/synnefo/db/migrations/0067_auto__add_field_backend_hypervisor.py +++ b/snf-cyclades-app/synnefo/db/migrations/0067_auto__add_field_backend_hypervisor.py @@ -4,20 +4,19 @@ from south.v2 import SchemaMigration from django.db import models + class Migration(SchemaMigration): def forwards(self, orm): - + # Adding field 'Backend.hypervisor' db.add_column('db_backend', 'hypervisor', self.gf('django.db.models.fields.CharField')(default='kvm', max_length=32), keep_default=False) - def backwards(self, orm): - + # Deleting field 'Backend.hypervisor' db.delete_column('db_backend', 'hypervisor') - models = { 'db.backend': { 'Meta': {'object_name': 'Backend'}, diff --git a/snf-cyclades-app/synnefo/db/migrations/0068_auto__add_field_network_drained.py b/snf-cyclades-app/synnefo/db/migrations/0068_auto__add_field_network_drained.py index 2de748b7f..6a42564ad 100644 --- a/snf-cyclades-app/synnefo/db/migrations/0068_auto__add_field_network_drained.py +++ b/snf-cyclades-app/synnefo/db/migrations/0068_auto__add_field_network_drained.py @@ -4,20 +4,19 @@ from south.v2 import SchemaMigration from django.db import models + class Migration(SchemaMigration): def forwards(self, orm): - + # Adding field 'Network.drained' db.add_column('db_network', 'drained', self.gf('django.db.models.fields.BooleanField')(default=False, blank=True), keep_default=False) - def backwards(self, orm): - + # Deleting field 'Network.drained' db.delete_column('db_network', 'drained') - models = { 'db.backend': { 'Meta': {'object_name': 'Backend'}, diff --git a/snf-cyclades-app/synnefo/db/migrations/0069_auto__add_floatingip__add_field_virtualmachine_task__add_field_virtual.py b/snf-cyclades-app/synnefo/db/migrations/0069_auto__add_floatingip__add_field_virtualmachine_task__add_field_virtual.py index af9e7c89d..5eaa0d049 100644 --- a/snf-cyclades-app/synnefo/db/migrations/0069_auto__add_floatingip__add_field_virtualmachine_task__add_field_virtual.py +++ b/snf-cyclades-app/synnefo/db/migrations/0069_auto__add_floatingip__add_field_virtualmachine_task__add_field_virtual.py @@ -4,10 +4,11 @@ from south.v2 import SchemaMigration from django.db import models + class Migration(SchemaMigration): def forwards(self, orm): - + # Adding model 'FloatingIP' db.create_table('db_floatingip', ( ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), @@ -33,9 +34,8 @@ def forwards(self, orm): # Adding field 'Network.floating_ip_pool' db.add_column('db_network', 'floating_ip_pool', self.gf('django.db.models.fields.BooleanField')(default=False), keep_default=False) - def backwards(self, orm): - + # Deleting model 'FloatingIP' db.delete_table('db_floatingip') @@ -51,7 +51,6 @@ def backwards(self, orm): # Deleting field 'Network.floating_ip_pool' db.delete_column('db_network', 'floating_ip_pool') - models = { 'db.backend': { 'Meta': {'ordering': "['clustername']", 'object_name': 'Backend'}, diff --git a/snf-cyclades-app/synnefo/db/migrations/0070_auto__chg_field_network_subnet.py b/snf-cyclades-app/synnefo/db/migrations/0070_auto__chg_field_network_subnet.py index 7a39730dd..266cad545 100644 --- a/snf-cyclades-app/synnefo/db/migrations/0070_auto__chg_field_network_subnet.py +++ b/snf-cyclades-app/synnefo/db/migrations/0070_auto__chg_field_network_subnet.py @@ -4,20 +4,19 @@ from south.v2 import SchemaMigration from django.db import models + class Migration(SchemaMigration): def forwards(self, orm): - + # Changing field 'Network.subnet' db.alter_column('db_network', 'subnet', self.gf('django.db.models.fields.CharField')(max_length=32, null=True)) - def backwards(self, orm): - + # Changing field 'Network.subnet' db.alter_column('db_network', 'subnet', self.gf('django.db.models.fields.CharField')(max_length=32)) - models = { 'db.backend': { 'Meta': {'ordering': "['clustername']", 'object_name': 'Backend'}, diff --git a/snf-cyclades-app/synnefo/db/migrations/0071_auto__chg_field_virtualmachine_task_job_id.py b/snf-cyclades-app/synnefo/db/migrations/0071_auto__chg_field_virtualmachine_task_job_id.py index cd4ddd205..7a0f42ec5 100644 --- a/snf-cyclades-app/synnefo/db/migrations/0071_auto__chg_field_virtualmachine_task_job_id.py +++ b/snf-cyclades-app/synnefo/db/migrations/0071_auto__chg_field_virtualmachine_task_job_id.py @@ -4,20 +4,19 @@ from south.v2 import SchemaMigration from django.db import models + class Migration(SchemaMigration): def forwards(self, orm): - + # Changing field 'VirtualMachine.task_job_id' db.alter_column('db_virtualmachine', 'task_job_id', self.gf('django.db.models.fields.BigIntegerField')(null=True)) - def backwards(self, orm): - + # Changing field 'VirtualMachine.task_job_id' db.alter_column('db_virtualmachine', 'task_job_id', self.gf('django.db.models.fields.BigIntegerField')(max_length=64, null=True)) - models = { 'db.backend': { 'Meta': {'ordering': "['clustername']", 'object_name': 'Backend'}, diff --git a/snf-cyclades-app/synnefo/db/migrations/0072_auto__chg_field_networkinterface_index.py b/snf-cyclades-app/synnefo/db/migrations/0072_auto__chg_field_networkinterface_index.py index 095d5b853..030d06b57 100644 --- a/snf-cyclades-app/synnefo/db/migrations/0072_auto__chg_field_networkinterface_index.py +++ b/snf-cyclades-app/synnefo/db/migrations/0072_auto__chg_field_networkinterface_index.py @@ -196,4 +196,4 @@ def backwards(self, orm): } } - complete_apps = ['db'] \ No newline at end of file + complete_apps = ['db'] diff --git a/snf-cyclades-app/synnefo/db/migrations/0073_auto__add_field_backend_disk_templates.py b/snf-cyclades-app/synnefo/db/migrations/0073_auto__add_field_backend_disk_templates.py index 34d5c78a0..210bb3b21 100644 --- a/snf-cyclades-app/synnefo/db/migrations/0073_auto__add_field_backend_disk_templates.py +++ b/snf-cyclades-app/synnefo/db/migrations/0073_auto__add_field_backend_disk_templates.py @@ -13,12 +13,10 @@ def forwards(self, orm): self.gf('synnefo.db.fields.SeparatedValuesField')(null=True), keep_default=False) - def backwards(self, orm): # Deleting field 'Backend.disk_templates' db.delete_column('db_backend', 'disk_templates') - models = { 'db.backend': { 'Meta': {'ordering': "['clustername']", 'object_name': 'Backend'}, @@ -199,4 +197,4 @@ def backwards(self, orm): } } - complete_apps = ['db'] \ No newline at end of file + complete_apps = ['db'] diff --git a/snf-cyclades-app/synnefo/db/migrations/0074_auto__chg_field_floatingip_serial__chg_field_virtualmachine_flavor__ch.py b/snf-cyclades-app/synnefo/db/migrations/0074_auto__chg_field_floatingip_serial__chg_field_virtualmachine_flavor__ch.py index ed6d9b8b4..fb31d479c 100644 --- a/snf-cyclades-app/synnefo/db/migrations/0074_auto__chg_field_floatingip_serial__chg_field_virtualmachine_flavor__ch.py +++ b/snf-cyclades-app/synnefo/db/migrations/0074_auto__chg_field_floatingip_serial__chg_field_virtualmachine_flavor__ch.py @@ -227,4 +227,4 @@ def backwards(self, orm): } } - complete_apps = ['db'] \ No newline at end of file + complete_apps = ['db'] diff --git a/snf-cyclades-app/synnefo/db/migrations/0075_auto__add_unique_networkinterface_network_ipv4.py b/snf-cyclades-app/synnefo/db/migrations/0075_auto__add_unique_networkinterface_network_ipv4.py index c3d79c0a4..4324bea88 100644 --- a/snf-cyclades-app/synnefo/db/migrations/0075_auto__add_unique_networkinterface_network_ipv4.py +++ b/snf-cyclades-app/synnefo/db/migrations/0075_auto__add_unique_networkinterface_network_ipv4.py @@ -11,12 +11,10 @@ def forwards(self, orm): # Adding unique constraint on 'NetworkInterface', fields ['network', 'ipv4'] db.create_unique('db_networkinterface', ['network_id', 'ipv4']) - def backwards(self, orm): # Removing unique constraint on 'NetworkInterface', fields ['network', 'ipv4'] db.delete_unique('db_networkinterface', ['network_id', 'ipv4']) - models = { 'db.backend': { 'Meta': {'ordering': "['clustername']", 'object_name': 'Backend'}, @@ -197,4 +195,4 @@ def backwards(self, orm): } } - complete_apps = ['db'] \ No newline at end of file + complete_apps = ['db'] diff --git a/snf-cyclades-app/synnefo/db/migrations/0076_auto__add_subnet__add_field_ippooltable_subnet.py b/snf-cyclades-app/synnefo/db/migrations/0076_auto__add_subnet__add_field_ippooltable_subnet.py index fb915aa54..e93973ca6 100644 --- a/snf-cyclades-app/synnefo/db/migrations/0076_auto__add_subnet__add_field_ippooltable_subnet.py +++ b/snf-cyclades-app/synnefo/db/migrations/0076_auto__add_subnet__add_field_ippooltable_subnet.py @@ -28,7 +28,6 @@ def forwards(self, orm): self.gf('django.db.models.fields.related.ForeignKey')(related_name='ip_pools', null=True, to=orm['db.Subnet']), keep_default=False) - def backwards(self, orm): # Deleting model 'Subnet' db.delete_table('db_subnet') @@ -36,7 +35,6 @@ def backwards(self, orm): # Deleting field 'IPPoolTable.subnet' db.delete_column('db_ippooltable', 'subnet_id') - models = { 'db.backend': { 'Meta': {'ordering': "['clustername']", 'object_name': 'Backend'}, @@ -231,4 +229,4 @@ def backwards(self, orm): } } - complete_apps = ['db'] \ No newline at end of file + complete_apps = ['db'] diff --git a/snf-cyclades-app/synnefo/db/migrations/0077_migrate_networks_to_subnets.py b/snf-cyclades-app/synnefo/db/migrations/0077_migrate_networks_to_subnets.py index 3d3f591fb..d61ea78b4 100644 --- a/snf-cyclades-app/synnefo/db/migrations/0077_migrate_networks_to_subnets.py +++ b/snf-cyclades-app/synnefo/db/migrations/0077_migrate_networks_to_subnets.py @@ -5,6 +5,7 @@ from django.db import models import ipaddr + class Migration(DataMigration): def forwards(self, orm): diff --git a/snf-cyclades-app/synnefo/db/migrations/0078_auto__del_field_network_subnet6__del_field_network_subnet__del_field_n.py b/snf-cyclades-app/synnefo/db/migrations/0078_auto__del_field_network_subnet6__del_field_network_subnet__del_field_n.py index f1bb1f2f6..869c7a5eb 100644 --- a/snf-cyclades-app/synnefo/db/migrations/0078_auto__del_field_network_subnet6__del_field_network_subnet__del_field_n.py +++ b/snf-cyclades-app/synnefo/db/migrations/0078_auto__del_field_network_subnet6__del_field_network_subnet__del_field_n.py @@ -31,7 +31,6 @@ def forwards(self, orm): self.gf('django.db.models.fields.BooleanField')(default=False), keep_default=False) - def backwards(self, orm): # Adding field 'Network.subnet6' db.add_column('db_network', 'subnet6', @@ -66,7 +65,6 @@ def backwards(self, orm): # Deleting field 'Network.external_router' db.delete_column('db_network', 'external_router') - models = { 'db.backend': { 'Meta': {'ordering': "['clustername']", 'object_name': 'Backend'}, @@ -256,4 +254,4 @@ def backwards(self, orm): } } - complete_apps = ['db'] \ No newline at end of file + complete_apps = ['db'] diff --git a/snf-cyclades-app/synnefo/db/migrations/0079_auto__add_ipaddress__add_unique_ipaddress_network_address__add_securit.py b/snf-cyclades-app/synnefo/db/migrations/0079_auto__add_ipaddress__add_unique_ipaddress_network_address__add_securit.py index 97c4f6f67..1f7b7dea8 100644 --- a/snf-cyclades-app/synnefo/db/migrations/0079_auto__add_ipaddress__add_unique_ipaddress_network_address__add_securit.py +++ b/snf-cyclades-app/synnefo/db/migrations/0079_auto__add_ipaddress__add_unique_ipaddress_network_address__add_securit.py @@ -60,7 +60,6 @@ def forwards(self, orm): )) db.create_unique('db_networkinterface_security_groups', ['networkinterface_id', 'securitygroup_id']) - def backwards(self, orm): # Removing unique constraint on 'IPAddress', fields ['network', 'address'] db.delete_unique('db_ipaddress', ['network_id', 'address']) @@ -86,7 +85,6 @@ def backwards(self, orm): # Adding unique constraint on 'NetworkInterface', fields ['network', 'ipv4'] db.create_unique('db_networkinterface', ['network_id', 'ipv4']) - models = { 'db.backend': { 'Meta': {'ordering': "['clustername']", 'object_name': 'Backend'}, @@ -299,4 +297,4 @@ def backwards(self, orm): } } - complete_apps = ['db'] \ No newline at end of file + complete_apps = ['db'] diff --git a/snf-cyclades-app/synnefo/db/migrations/0080_nics_to_ips.py b/snf-cyclades-app/synnefo/db/migrations/0080_nics_to_ips.py index 4be5fd4e6..c266d832c 100644 --- a/snf-cyclades-app/synnefo/db/migrations/0080_nics_to_ips.py +++ b/snf-cyclades-app/synnefo/db/migrations/0080_nics_to_ips.py @@ -4,6 +4,7 @@ from south.v2 import DataMigration from django.db import models + class Migration(DataMigration): def forwards(self, orm): @@ -28,7 +29,6 @@ def forwards(self, orm): userid=userid, address=address) - def backwards(self, orm): "Write your backwards methods here." for ip in orm.IPAddress.objects.filter(deleted=False): @@ -37,7 +37,6 @@ def backwards(self, orm): setattr(nic, attr, ip.address) nic.save() - models = { 'db.backend': { 'Meta': {'ordering': "['clustername']", 'object_name': 'Backend'}, diff --git a/snf-cyclades-app/synnefo/db/migrations/0081_auto__del_floatingip__del_field_networkinterface_ipv6__del_field_netwo.py b/snf-cyclades-app/synnefo/db/migrations/0081_auto__del_floatingip__del_field_networkinterface_ipv6__del_field_netwo.py index 829211abd..aacaa1c21 100644 --- a/snf-cyclades-app/synnefo/db/migrations/0081_auto__del_floatingip__del_field_networkinterface_ipv6__del_field_netwo.py +++ b/snf-cyclades-app/synnefo/db/migrations/0081_auto__del_floatingip__del_field_networkinterface_ipv6__del_field_netwo.py @@ -17,7 +17,6 @@ def forwards(self, orm): # Deleting field 'NetworkInterface.ipv4' db.delete_column('db_networkinterface', 'ipv4') - def backwards(self, orm): # Adding model 'FloatingIP' db.create_table('db_floatingip', ( @@ -42,7 +41,6 @@ def backwards(self, orm): self.gf('django.db.models.fields.CharField')(max_length=15, null=True), keep_default=False) - models = { 'db.backend': { 'Meta': {'ordering': "['clustername']", 'object_name': 'Backend'}, @@ -242,4 +240,4 @@ def backwards(self, orm): } } - complete_apps = ['db'] \ No newline at end of file + complete_apps = ['db'] diff --git a/snf-cyclades-app/synnefo/db/migrations/0082_auto__del_field_networkinterface_dirty.py b/snf-cyclades-app/synnefo/db/migrations/0082_auto__del_field_networkinterface_dirty.py index aa5b988db..4bb0b1e06 100644 --- a/snf-cyclades-app/synnefo/db/migrations/0082_auto__del_field_networkinterface_dirty.py +++ b/snf-cyclades-app/synnefo/db/migrations/0082_auto__del_field_networkinterface_dirty.py @@ -11,14 +11,12 @@ def forwards(self, orm): # Deleting field 'NetworkInterface.dirty' db.delete_column('db_networkinterface', 'dirty') - def backwards(self, orm): # Adding field 'NetworkInterface.dirty' db.add_column('db_networkinterface', 'dirty', self.gf('django.db.models.fields.BooleanField')(default=False), keep_default=False) - models = { 'db.backend': { 'Meta': {'ordering': "['clustername']", 'object_name': 'Backend'}, @@ -217,4 +215,4 @@ def backwards(self, orm): } } - complete_apps = ['db'] \ No newline at end of file + complete_apps = ['db'] diff --git a/snf-cyclades-app/synnefo/db/migrations/0083_auto__chg_field_subnet_cidr.py b/snf-cyclades-app/synnefo/db/migrations/0083_auto__chg_field_subnet_cidr.py index f4d8d7fa8..1727c6625 100644 --- a/snf-cyclades-app/synnefo/db/migrations/0083_auto__chg_field_subnet_cidr.py +++ b/snf-cyclades-app/synnefo/db/migrations/0083_auto__chg_field_subnet_cidr.py @@ -215,4 +215,4 @@ def backwards(self, orm): } } - complete_apps = ['db'] \ No newline at end of file + complete_apps = ['db'] diff --git a/snf-cyclades-app/synnefo/db/migrations/0084_external_router.py b/snf-cyclades-app/synnefo/db/migrations/0084_external_router.py index 7302e2611..13f039b33 100644 --- a/snf-cyclades-app/synnefo/db/migrations/0084_external_router.py +++ b/snf-cyclades-app/synnefo/db/migrations/0084_external_router.py @@ -4,6 +4,7 @@ from south.v2 import DataMigration from django.db import models + class Migration(DataMigration): def forwards(self, orm): diff --git a/snf-cyclades-app/synnefo/db/migrations/0085_nic_build_state.py b/snf-cyclades-app/synnefo/db/migrations/0085_nic_build_state.py index 583abaf71..494f53dd2 100644 --- a/snf-cyclades-app/synnefo/db/migrations/0085_nic_build_state.py +++ b/snf-cyclades-app/synnefo/db/migrations/0085_nic_build_state.py @@ -4,6 +4,7 @@ from south.v2 import DataMigration from django.db import models + class Migration(DataMigration): def forwards(self, orm): diff --git a/snf-cyclades-app/synnefo/db/migrations/0086_auto__add_ipaddresslog.py b/snf-cyclades-app/synnefo/db/migrations/0086_auto__add_ipaddresslog.py index 26070b43a..4a9355f0a 100644 --- a/snf-cyclades-app/synnefo/db/migrations/0086_auto__add_ipaddresslog.py +++ b/snf-cyclades-app/synnefo/db/migrations/0086_auto__add_ipaddresslog.py @@ -20,12 +20,10 @@ def forwards(self, orm): )) db.send_create_signal('db', ['IPAddressLog']) - def backwards(self, orm): # Deleting model 'IPAddressLog' db.delete_table('db_ipaddresslog') - models = { 'db.backend': { 'Meta': {'ordering': "['clustername']", 'object_name': 'Backend'}, @@ -234,4 +232,4 @@ def backwards(self, orm): } } - complete_apps = ['db'] \ No newline at end of file + complete_apps = ['db'] diff --git a/snf-cyclades-app/synnefo/db/migrations/0087_ip_address_log.py b/snf-cyclades-app/synnefo/db/migrations/0087_ip_address_log.py index ec506d173..a7137b274 100644 --- a/snf-cyclades-app/synnefo/db/migrations/0087_ip_address_log.py +++ b/snf-cyclades-app/synnefo/db/migrations/0087_ip_address_log.py @@ -4,6 +4,7 @@ from south.v2 import DataMigration from django.db import models + class Migration(DataMigration): def forwards(self, orm): diff --git a/snf-cyclades-app/synnefo/db/migrations/0088_auto__chg_field_networkinterface_machine__del_unique_ipaddresslog_netw.py b/snf-cyclades-app/synnefo/db/migrations/0088_auto__chg_field_networkinterface_machine__del_unique_ipaddresslog_netw.py index 1e0704f32..81b32ef82 100644 --- a/snf-cyclades-app/synnefo/db/migrations/0088_auto__chg_field_networkinterface_machine__del_unique_ipaddresslog_netw.py +++ b/snf-cyclades-app/synnefo/db/migrations/0088_auto__chg_field_networkinterface_machine__del_unique_ipaddresslog_netw.py @@ -16,7 +16,6 @@ def backwards(self, orm): # User chose to not deal with backwards NULL issues for 'NetworkInterface.machine' raise RuntimeError("Cannot reverse this migration. 'NetworkInterface.machine' and its values cannot be restored.") - models = { 'db.backend': { 'Meta': {'ordering': "['clustername']", 'object_name': 'Backend'}, diff --git a/snf-cyclades-app/synnefo/db/migrations/0089_auto__chg_field_networkinterface_userid.py b/snf-cyclades-app/synnefo/db/migrations/0089_auto__chg_field_networkinterface_userid.py index 43571fee2..64cba354d 100644 --- a/snf-cyclades-app/synnefo/db/migrations/0089_auto__chg_field_networkinterface_userid.py +++ b/snf-cyclades-app/synnefo/db/migrations/0089_auto__chg_field_networkinterface_userid.py @@ -225,4 +225,4 @@ def backwards(self, orm): } } - complete_apps = ['db'] \ No newline at end of file + complete_apps = ['db'] diff --git a/snf-cyclades-app/synnefo/db/migrations/0090_auto__chg_field_ipaddress_subnet__chg_field_ipaddress_network__chg_fie.py b/snf-cyclades-app/synnefo/db/migrations/0090_auto__chg_field_ipaddress_subnet__chg_field_ipaddress_network__chg_fie.py index ecf54ede7..f223b5af2 100644 --- a/snf-cyclades-app/synnefo/db/migrations/0090_auto__chg_field_ipaddress_subnet__chg_field_ipaddress_network__chg_fie.py +++ b/snf-cyclades-app/synnefo/db/migrations/0090_auto__chg_field_ipaddress_subnet__chg_field_ipaddress_network__chg_fie.py @@ -261,4 +261,4 @@ def backwards(self, orm): } } - complete_apps = ['db'] \ No newline at end of file + complete_apps = ['db'] diff --git a/snf-cyclades-app/synnefo/db/migrations/0091_auto__del_unique_ipaddress_network_address__add_unique_ipaddress_delet.py b/snf-cyclades-app/synnefo/db/migrations/0091_auto__del_unique_ipaddress_network_address__add_unique_ipaddress_delet.py index d7472fbdd..cdae7ff87 100644 --- a/snf-cyclades-app/synnefo/db/migrations/0091_auto__del_unique_ipaddress_network_address__add_unique_ipaddress_delet.py +++ b/snf-cyclades-app/synnefo/db/migrations/0091_auto__del_unique_ipaddress_network_address__add_unique_ipaddress_delet.py @@ -14,7 +14,6 @@ def forwards(self, orm): # Adding unique constraint on 'IPAddress', fields ['deleted', 'network', 'address'] db.create_unique('db_ipaddress', ['deleted', 'network_id', 'address']) - def backwards(self, orm): # Removing unique constraint on 'IPAddress', fields ['deleted', 'network', 'address'] db.delete_unique('db_ipaddress', ['deleted', 'network_id', 'address']) @@ -22,7 +21,6 @@ def backwards(self, orm): # Adding unique constraint on 'IPAddress', fields ['network', 'address'] db.create_unique('db_ipaddress', ['network_id', 'address']) - models = { 'db.backend': { 'Meta': {'ordering': "['clustername']", 'object_name': 'Backend'}, @@ -231,4 +229,4 @@ def backwards(self, orm): } } - complete_apps = ['db'] \ No newline at end of file + complete_apps = ['db'] diff --git a/snf-cyclades-app/synnefo/db/migrations/0092_auto__add_field_subnet_created__add_field_subnet_updated.py b/snf-cyclades-app/synnefo/db/migrations/0092_auto__add_field_subnet_created__add_field_subnet_updated.py index 10537a7e4..f192f4d80 100644 --- a/snf-cyclades-app/synnefo/db/migrations/0092_auto__add_field_subnet_created__add_field_subnet_updated.py +++ b/snf-cyclades-app/synnefo/db/migrations/0092_auto__add_field_subnet_created__add_field_subnet_updated.py @@ -18,7 +18,6 @@ def forwards(self, orm): self.gf('django.db.models.fields.DateTimeField')(auto_now=True, default=datetime.datetime(2013, 12, 17, 0, 0), blank=True), keep_default=False) - def backwards(self, orm): # Deleting field 'Subnet.created' db.delete_column('db_subnet', 'created') @@ -26,7 +25,6 @@ def backwards(self, orm): # Deleting field 'Subnet.updated' db.delete_column('db_subnet', 'updated') - models = { 'db.backend': { 'Meta': {'ordering': "['clustername']", 'object_name': 'Backend'}, @@ -237,4 +235,4 @@ def backwards(self, orm): } } - complete_apps = ['db'] \ No newline at end of file + complete_apps = ['db'] diff --git a/snf-cyclades-app/synnefo/db/migrations/0093_auto__add_field_ipaddress_ipversion.py b/snf-cyclades-app/synnefo/db/migrations/0093_auto__add_field_ipaddress_ipversion.py index 47154b056..b9baf54bb 100644 --- a/snf-cyclades-app/synnefo/db/migrations/0093_auto__add_field_ipaddress_ipversion.py +++ b/snf-cyclades-app/synnefo/db/migrations/0093_auto__add_field_ipaddress_ipversion.py @@ -13,12 +13,10 @@ def forwards(self, orm): self.gf('django.db.models.fields.IntegerField')(null=True), keep_default=False) - def backwards(self, orm): # Deleting field 'IPAddress.ipversion' db.delete_column('db_ipaddress', 'ipversion') - models = { 'db.backend': { 'Meta': {'ordering': "['clustername']", 'object_name': 'Backend'}, @@ -230,4 +228,4 @@ def backwards(self, orm): } } - complete_apps = ['db'] \ No newline at end of file + complete_apps = ['db'] diff --git a/snf-cyclades-app/synnefo/db/migrations/0094_add_ipversion_to_ips.py b/snf-cyclades-app/synnefo/db/migrations/0094_add_ipversion_to_ips.py index ad9734eea..bf77f81f6 100644 --- a/snf-cyclades-app/synnefo/db/migrations/0094_add_ipversion_to_ips.py +++ b/snf-cyclades-app/synnefo/db/migrations/0094_add_ipversion_to_ips.py @@ -4,6 +4,7 @@ from south.v2 import DataMigration from django.db import models + class Migration(DataMigration): def forwards(self, orm): diff --git a/snf-cyclades-app/synnefo/db/migrations/0095_auto__chg_field_ipaddress_ipversion.py b/snf-cyclades-app/synnefo/db/migrations/0095_auto__chg_field_ipaddress_ipversion.py index 68654cb94..c493ea55c 100644 --- a/snf-cyclades-app/synnefo/db/migrations/0095_auto__chg_field_ipaddress_ipversion.py +++ b/snf-cyclades-app/synnefo/db/migrations/0095_auto__chg_field_ipaddress_ipversion.py @@ -228,4 +228,4 @@ def backwards(self, orm): } } - complete_apps = ['db'] \ No newline at end of file + complete_apps = ['db'] diff --git a/snf-cyclades-app/synnefo/db/migrations/0096_auto__add_field_subnet_userid__add_field_subnet_public.py b/snf-cyclades-app/synnefo/db/migrations/0096_auto__add_field_subnet_userid__add_field_subnet_public.py index 9cbb78b51..035a23d81 100644 --- a/snf-cyclades-app/synnefo/db/migrations/0096_auto__add_field_subnet_userid__add_field_subnet_public.py +++ b/snf-cyclades-app/synnefo/db/migrations/0096_auto__add_field_subnet_userid__add_field_subnet_public.py @@ -18,7 +18,6 @@ def forwards(self, orm): self.gf('django.db.models.fields.BooleanField')(default=False, db_index=True), keep_default=False) - def backwards(self, orm): # Deleting field 'Subnet.userid' db.delete_column('db_subnet', 'userid') @@ -26,7 +25,6 @@ def backwards(self, orm): # Deleting field 'Subnet.public' db.delete_column('db_subnet', 'public') - models = { 'db.backend': { 'Meta': {'ordering': "['clustername']", 'object_name': 'Backend'}, @@ -240,4 +238,4 @@ def backwards(self, orm): } } - complete_apps = ['db'] \ No newline at end of file + complete_apps = ['db'] diff --git a/snf-cyclades-app/synnefo/db/migrations/0097_userid_to_subnets.py b/snf-cyclades-app/synnefo/db/migrations/0097_userid_to_subnets.py index 7754e34fe..0180b9326 100644 --- a/snf-cyclades-app/synnefo/db/migrations/0097_userid_to_subnets.py +++ b/snf-cyclades-app/synnefo/db/migrations/0097_userid_to_subnets.py @@ -4,6 +4,7 @@ from south.v2 import DataMigration from django.db import models + class Migration(DataMigration): def forwards(self, orm): diff --git a/snf-cyclades-app/synnefo/db/migrations/0098_auto__add_field_flavor_allow_create.py b/snf-cyclades-app/synnefo/db/migrations/0098_auto__add_field_flavor_allow_create.py index f41aa952c..94d4b163b 100644 --- a/snf-cyclades-app/synnefo/db/migrations/0098_auto__add_field_flavor_allow_create.py +++ b/snf-cyclades-app/synnefo/db/migrations/0098_auto__add_field_flavor_allow_create.py @@ -13,12 +13,10 @@ def forwards(self, orm): self.gf('django.db.models.fields.BooleanField')(default=True), keep_default=False) - def backwards(self, orm): # Deleting field 'Flavor.allow_create' db.delete_column('db_flavor', 'allow_create') - models = { 'db.backend': { 'Meta': {'ordering': "['clustername']", 'object_name': 'Backend'}, @@ -233,4 +231,4 @@ def backwards(self, orm): } } - complete_apps = ['db'] \ No newline at end of file + complete_apps = ['db'] diff --git a/snf-cyclades-app/synnefo/db/migrations/0099_auto__add_field_ipaddress_project__add_field_virtualmachine_project__a.py b/snf-cyclades-app/synnefo/db/migrations/0099_auto__add_field_ipaddress_project__add_field_virtualmachine_project__a.py index 3fec8d06c..95df6a461 100644 --- a/snf-cyclades-app/synnefo/db/migrations/0099_auto__add_field_ipaddress_project__add_field_virtualmachine_project__a.py +++ b/snf-cyclades-app/synnefo/db/migrations/0099_auto__add_field_ipaddress_project__add_field_virtualmachine_project__a.py @@ -23,7 +23,6 @@ def forwards(self, orm): self.gf('django.db.models.fields.CharField')(max_length=255, null=True), keep_default=False) - def backwards(self, orm): # Deleting field 'IPAddress.project' db.delete_column('db_ipaddress', 'project') @@ -34,7 +33,6 @@ def backwards(self, orm): # Deleting field 'Network.project' db.delete_column('db_network', 'project') - models = { 'db.backend': { 'Meta': {'ordering': "['clustername']", 'object_name': 'Backend'}, @@ -252,4 +250,4 @@ def backwards(self, orm): } } - complete_apps = ['db'] \ No newline at end of file + complete_apps = ['db'] diff --git a/snf-cyclades-app/synnefo/db/migrations/0100_project_ids.py b/snf-cyclades-app/synnefo/db/migrations/0100_project_ids.py index 7a508b73c..dd4ca159d 100644 --- a/snf-cyclades-app/synnefo/db/migrations/0100_project_ids.py +++ b/snf-cyclades-app/synnefo/db/migrations/0100_project_ids.py @@ -4,6 +4,7 @@ from south.v2 import DataMigration from django.db import models + class Migration(DataMigration): def forwards(self, orm): diff --git a/snf-cyclades-app/synnefo/db/migrations/0101_auto__add_field_network_subnet_ids.py b/snf-cyclades-app/synnefo/db/migrations/0101_auto__add_field_network_subnet_ids.py index ff5227fed..30e914390 100644 --- a/snf-cyclades-app/synnefo/db/migrations/0101_auto__add_field_network_subnet_ids.py +++ b/snf-cyclades-app/synnefo/db/migrations/0101_auto__add_field_network_subnet_ids.py @@ -13,12 +13,10 @@ def forwards(self, orm): self.gf('synnefo.db.fields.SeparatedValuesField')(null=True), keep_default=False) - def backwards(self, orm): # Deleting field 'Network.subnet_ids' db.delete_column('db_network', 'subnet_ids') - models = { 'db.backend': { 'Meta': {'ordering': "['clustername']", 'object_name': 'Backend'}, diff --git a/snf-cyclades-app/synnefo/db/migrations/0102_subnets_to_network.py b/snf-cyclades-app/synnefo/db/migrations/0102_subnets_to_network.py index 6c4869c64..2128568df 100644 --- a/snf-cyclades-app/synnefo/db/migrations/0102_subnets_to_network.py +++ b/snf-cyclades-app/synnefo/db/migrations/0102_subnets_to_network.py @@ -4,6 +4,7 @@ from south.v2 import DataMigration from django.db import models + class Migration(DataMigration): def forwards(self, orm): diff --git a/snf-cyclades-app/synnefo/db/migrations/0103_auto__add_field_networkinterface_public.py b/snf-cyclades-app/synnefo/db/migrations/0103_auto__add_field_networkinterface_public.py index fb238ecef..3ab10b9f2 100644 --- a/snf-cyclades-app/synnefo/db/migrations/0103_auto__add_field_networkinterface_public.py +++ b/snf-cyclades-app/synnefo/db/migrations/0103_auto__add_field_networkinterface_public.py @@ -13,12 +13,10 @@ def forwards(self, orm): self.gf('django.db.models.fields.BooleanField')(default=False), keep_default=False) - def backwards(self, orm): # Deleting field 'NetworkInterface.public' db.delete_column('db_networkinterface', 'public') - models = { 'db.backend': { 'Meta': {'ordering': "['clustername']", 'object_name': 'Backend'}, @@ -238,4 +236,4 @@ def backwards(self, orm): } } - complete_apps = ['db'] \ No newline at end of file + complete_apps = ['db'] diff --git a/snf-cyclades-app/synnefo/db/migrations/0104_public_to_nics.py b/snf-cyclades-app/synnefo/db/migrations/0104_public_to_nics.py index 478c98c4a..684427420 100644 --- a/snf-cyclades-app/synnefo/db/migrations/0104_public_to_nics.py +++ b/snf-cyclades-app/synnefo/db/migrations/0104_public_to_nics.py @@ -4,6 +4,7 @@ from south.v2 import DataMigration from django.db import models + class Migration(DataMigration): def forwards(self, orm): diff --git a/snf-cyclades-app/synnefo/db/migrations/0105_auto__add_volume__add_volumemetadata__add_unique_volumemetadata_volume.py b/snf-cyclades-app/synnefo/db/migrations/0105_auto__add_volume__add_volumemetadata__add_unique_volumemetadata_volume.py index e17cda53d..5f6e84b6c 100644 --- a/snf-cyclades-app/synnefo/db/migrations/0105_auto__add_volume__add_volumemetadata__add_unique_volumemetadata_volume.py +++ b/snf-cyclades-app/synnefo/db/migrations/0105_auto__add_volume__add_volumemetadata__add_unique_volumemetadata_volume.py @@ -42,7 +42,6 @@ def forwards(self, orm): # Adding unique constraint on 'VolumeMetadata', fields ['volume', 'key'] db.create_unique('db_volumemetadata', ['volume_id', 'key']) - def backwards(self, orm): # Removing unique constraint on 'VolumeMetadata', fields ['volume', 'key'] db.delete_unique('db_volumemetadata', ['volume_id', 'key']) @@ -53,7 +52,6 @@ def backwards(self, orm): # Deleting model 'VolumeMetadata' db.delete_table('db_volumemetadata') - models = { 'db.backend': { 'Meta': {'ordering': "['clustername']", 'object_name': 'Backend'}, diff --git a/snf-cyclades-app/synnefo/db/migrations/0106_default_volume.py b/snf-cyclades-app/synnefo/db/migrations/0106_default_volume.py index d31146ca4..e3c9cd34e 100644 --- a/snf-cyclades-app/synnefo/db/migrations/0106_default_volume.py +++ b/snf-cyclades-app/synnefo/db/migrations/0106_default_volume.py @@ -4,6 +4,7 @@ from south.v2 import DataMigration from django.db import models + class Migration(DataMigration): def forwards(self, orm): diff --git a/snf-cyclades-app/synnefo/db/migrations/0107_auto__add_volumetype__add_field_volume_volume_type__add_field_flavor_v.py b/snf-cyclades-app/synnefo/db/migrations/0107_auto__add_volumetype__add_field_volume_volume_type__add_field_flavor_v.py index 271e2dd80..056554576 100644 --- a/snf-cyclades-app/synnefo/db/migrations/0107_auto__add_volumetype__add_field_volume_volume_type__add_field_flavor_v.py +++ b/snf-cyclades-app/synnefo/db/migrations/0107_auto__add_volumetype__add_field_volume_volume_type__add_field_flavor_v.py @@ -27,7 +27,6 @@ def forwards(self, orm): self.gf('django.db.models.fields.related.ForeignKey')(related_name='flavors', null=True, on_delete=models.PROTECT, to=orm['db.VolumeType']), keep_default=False) - def backwards(self, orm): # Deleting model 'VolumeType' db.delete_table('db_volumetype') @@ -38,7 +37,6 @@ def backwards(self, orm): # Deleting field 'Flavor.volume_type' db.delete_column('db_flavor', 'volume_type_id') - models = { 'db.backend': { 'Meta': {'ordering': "['clustername']", 'object_name': 'Backend'}, diff --git a/snf-cyclades-app/synnefo/db/migrations/0108_dtemplate_to_vtype.py b/snf-cyclades-app/synnefo/db/migrations/0108_dtemplate_to_vtype.py index d64d8b76b..b4d2e73dc 100644 --- a/snf-cyclades-app/synnefo/db/migrations/0108_dtemplate_to_vtype.py +++ b/snf-cyclades-app/synnefo/db/migrations/0108_dtemplate_to_vtype.py @@ -4,6 +4,7 @@ from south.v2 import DataMigration from django.db import models + class Migration(DataMigration): def forwards(self, orm): diff --git a/snf-cyclades-app/synnefo/db/migrations/0109_auto__del_field_volume_disk_template__chg_field_volume_volume_type__de.py b/snf-cyclades-app/synnefo/db/migrations/0109_auto__del_field_volume_disk_template__chg_field_volume_volume_type__de.py index 9697e26c3..a0448722c 100644 --- a/snf-cyclades-app/synnefo/db/migrations/0109_auto__del_field_volume_disk_template__chg_field_volume_volume_type__de.py +++ b/snf-cyclades-app/synnefo/db/migrations/0109_auto__del_field_volume_disk_template__chg_field_volume_volume_type__de.py @@ -14,19 +14,16 @@ def forwards(self, orm): # Deleting field 'Volume.disk_template' db.delete_column('db_volume', 'disk_template') - # Changing field 'Volume.volume_type' db.alter_column('db_volume', 'volume_type_id', self.gf('django.db.models.fields.related.ForeignKey')(default=1, on_delete=models.PROTECT, to=orm['db.VolumeType'])) # Deleting field 'Flavor.disk_template' db.delete_column('db_flavor', 'disk_template') - # Changing field 'Flavor.volume_type' db.alter_column('db_flavor', 'volume_type_id', self.gf('django.db.models.fields.related.ForeignKey')(default=1, on_delete=models.PROTECT, to=orm['db.VolumeType'])) # Adding unique constraint on 'Flavor', fields ['disk', 'ram', 'cpu', 'volume_type'] db.create_unique('db_flavor', ['disk', 'ram', 'cpu', 'volume_type_id']) - def backwards(self, orm): # Removing unique constraint on 'Flavor', fields ['disk', 'ram', 'cpu', 'volume_type'] db.delete_unique('db_flavor', ['disk', 'ram', 'cpu', 'volume_type_id']) @@ -36,7 +33,6 @@ def backwards(self, orm): self.gf('django.db.models.fields.CharField')(default='none', max_length=32), keep_default=False) - # Changing field 'Volume.volume_type' db.alter_column('db_volume', 'volume_type_id', self.gf('django.db.models.fields.related.ForeignKey')(null=True, on_delete=models.PROTECT, to=orm['db.VolumeType'])) # Adding field 'Flavor.disk_template' @@ -44,13 +40,11 @@ def backwards(self, orm): self.gf('django.db.models.fields.CharField')(default='none', max_length=32), keep_default=False) - # Changing field 'Flavor.volume_type' db.alter_column('db_flavor', 'volume_type_id', self.gf('django.db.models.fields.related.ForeignKey')(null=True, on_delete=models.PROTECT, to=orm['db.VolumeType'])) # Adding unique constraint on 'Flavor', fields ['disk', 'ram', 'cpu', 'disk_template'] db.create_unique('db_flavor', ['disk', 'ram', 'cpu', 'disk_template']) - models = { 'db.backend': { 'Meta': {'ordering': "['clustername']", 'object_name': 'Backend'}, @@ -304,4 +298,4 @@ def backwards(self, orm): } } - complete_apps = ['db'] \ No newline at end of file + complete_apps = ['db'] diff --git a/snf-cyclades-app/synnefo/db/migrations/0110_auto__add_field_volume_project.py b/snf-cyclades-app/synnefo/db/migrations/0110_auto__add_field_volume_project.py index 83cba3d74..3f8bb5af6 100644 --- a/snf-cyclades-app/synnefo/db/migrations/0110_auto__add_field_volume_project.py +++ b/snf-cyclades-app/synnefo/db/migrations/0110_auto__add_field_volume_project.py @@ -13,12 +13,10 @@ def forwards(self, orm): self.gf('django.db.models.fields.CharField')(max_length=255, null=True), keep_default=False) - def backwards(self, orm): # Deleting field 'Volume.project' db.delete_column('db_volume', 'project') - models = { 'db.backend': { 'Meta': {'ordering': "['clustername']", 'object_name': 'Backend'}, @@ -273,4 +271,4 @@ def backwards(self, orm): } } - complete_apps = ['db'] \ No newline at end of file + complete_apps = ['db'] diff --git a/snf-cyclades-app/synnefo/db/migrations/0111_volume_project.py b/snf-cyclades-app/synnefo/db/migrations/0111_volume_project.py index 106d7af15..4057426d3 100644 --- a/snf-cyclades-app/synnefo/db/migrations/0111_volume_project.py +++ b/snf-cyclades-app/synnefo/db/migrations/0111_volume_project.py @@ -4,6 +4,7 @@ from south.v2 import DataMigration from django.db import models + class Migration(DataMigration): def forwards(self, orm): diff --git a/snf-cyclades-app/synnefo/db/migrations/0112_auto__add_field_volume_serial.py b/snf-cyclades-app/synnefo/db/migrations/0112_auto__add_field_volume_serial.py index ab2be19c1..b747b478c 100644 --- a/snf-cyclades-app/synnefo/db/migrations/0112_auto__add_field_volume_serial.py +++ b/snf-cyclades-app/synnefo/db/migrations/0112_auto__add_field_volume_serial.py @@ -13,12 +13,10 @@ def forwards(self, orm): self.gf('django.db.models.fields.related.ForeignKey')(related_name='volume', null=True, on_delete=models.SET_NULL, to=orm['db.QuotaHolderSerial']), keep_default=False) - def backwards(self, orm): # Deleting field 'Volume.serial' db.delete_column('db_volume', 'serial_id') - models = { 'db.backend': { 'Meta': {'ordering': "['clustername']", 'object_name': 'Backend'}, @@ -274,4 +272,4 @@ def backwards(self, orm): } } - complete_apps = ['db'] \ No newline at end of file + complete_apps = ['db'] diff --git a/snf-cyclades-app/synnefo/db/migrations/0113_auto__add_index_volume_project__add_index_ipaddress_project__add_index.py b/snf-cyclades-app/synnefo/db/migrations/0113_auto__add_index_volume_project__add_index_ipaddress_project__add_index.py index d89686934..095fed6c6 100644 --- a/snf-cyclades-app/synnefo/db/migrations/0113_auto__add_index_volume_project__add_index_ipaddress_project__add_index.py +++ b/snf-cyclades-app/synnefo/db/migrations/0113_auto__add_index_volume_project__add_index_ipaddress_project__add_index.py @@ -20,7 +20,6 @@ def forwards(self, orm): # Adding index on 'Network', fields ['project'] db.create_index('db_network', ['project']) - def backwards(self, orm): # Removing index on 'Network', fields ['project'] db.delete_index('db_network', ['project']) @@ -34,7 +33,6 @@ def backwards(self, orm): # Removing index on 'Volume', fields ['project'] db.delete_index('db_volume', ['project']) - models = { 'db.backend': { 'Meta': {'ordering': "['clustername']", 'object_name': 'Backend'}, @@ -290,4 +288,4 @@ def backwards(self, orm): } } - complete_apps = ['db'] \ No newline at end of file + complete_apps = ['db'] diff --git a/snf-cyclades-app/synnefo/db/migrations/0114_auto.py b/snf-cyclades-app/synnefo/db/migrations/0114_auto.py index 2ca5e59dd..a5303c74b 100644 --- a/snf-cyclades-app/synnefo/db/migrations/0114_auto.py +++ b/snf-cyclades-app/synnefo/db/migrations/0114_auto.py @@ -11,12 +11,10 @@ def forwards(self, orm): # Adding index on 'Volume', fields ['deleted'] db.create_index('db_volume', ['deleted']) - def backwards(self, orm): # Removing index on 'Volume', fields ['deleted'] db.delete_index('db_volume', ['deleted']) - models = { 'db.backend': { 'Meta': {'ordering': "['clustername']", 'object_name': 'Backend'}, @@ -272,4 +270,4 @@ def backwards(self, orm): } } - complete_apps = ['db'] \ No newline at end of file + complete_apps = ['db'] diff --git a/snf-cyclades-app/synnefo/db/migrations/0115_auto__add_field_volume_source_version__add_field_virtualmachine_image_.py b/snf-cyclades-app/synnefo/db/migrations/0115_auto__add_field_volume_source_version__add_field_virtualmachine_image_.py index bc6b593b6..ff42f4606 100644 --- a/snf-cyclades-app/synnefo/db/migrations/0115_auto__add_field_volume_source_version__add_field_virtualmachine_image_.py +++ b/snf-cyclades-app/synnefo/db/migrations/0115_auto__add_field_volume_source_version__add_field_virtualmachine_image_.py @@ -18,7 +18,6 @@ def forwards(self, orm): self.gf('django.db.models.fields.IntegerField')(null=True), keep_default=False) - def backwards(self, orm): # Deleting field 'Volume.source_version' db.delete_column('db_volume', 'source_version') @@ -26,7 +25,6 @@ def backwards(self, orm): # Deleting field 'VirtualMachine.image_version' db.delete_column('db_virtualmachine', 'image_version') - models = { 'db.backend': { 'Meta': {'ordering': "['clustername']", 'object_name': 'Backend'}, diff --git a/snf-cyclades-app/synnefo/db/migrations/0116_auto__add_image__add_unique_image_uuid_version.py b/snf-cyclades-app/synnefo/db/migrations/0116_auto__add_image__add_unique_image_uuid_version.py index 9d4c35a5e..0caf02005 100644 --- a/snf-cyclades-app/synnefo/db/migrations/0116_auto__add_image__add_unique_image_uuid_version.py +++ b/snf-cyclades-app/synnefo/db/migrations/0116_auto__add_image__add_unique_image_uuid_version.py @@ -28,7 +28,6 @@ def forwards(self, orm): # Adding unique constraint on 'Image', fields ['uuid', 'version'] db.create_unique('db_image', ['uuid', 'version']) - def backwards(self, orm): # Removing unique constraint on 'Image', fields ['uuid', 'version'] db.delete_unique('db_image', ['uuid', 'version']) @@ -36,7 +35,6 @@ def backwards(self, orm): # Deleting model 'Image' db.delete_table('db_image') - models = { 'db.backend': { 'Meta': {'ordering': "['clustername']", 'object_name': 'Backend'}, diff --git a/snf-cyclades-app/synnefo/db/migrations/0117_fix_migration_bug.py b/snf-cyclades-app/synnefo/db/migrations/0117_fix_migration_bug.py index 24f7ce22e..b5622dcdd 100644 --- a/snf-cyclades-app/synnefo/db/migrations/0117_fix_migration_bug.py +++ b/snf-cyclades-app/synnefo/db/migrations/0117_fix_migration_bug.py @@ -4,6 +4,7 @@ from south.v2 import DataMigration from django.db import models + class Migration(DataMigration): def forwards(self, orm): @@ -14,14 +15,13 @@ def forwards(self, orm): n_subs = {} for (subnet_id, network_id) in orm.Subnet.objects.values_list("id", "network_id"): if (network_id not in networks or - str(subnet_id) != str(networks[network_id])): - subnet_ids = n_subs.setdefault(network_id, []) - subnet_ids.append(subnet_id) + str(subnet_id) != str(networks[network_id])): + subnet_ids = n_subs.setdefault(network_id, []) + subnet_ids.append(subnet_id) for network_id, subnet_ids in n_subs.items(): updated = orm.Network.objects.filter(id=network_id).update(subnet_ids=subnet_ids) assert(updated == 1) - def backwards(self, orm): "Write your backwards methods here." diff --git a/snf-cyclades-app/synnefo/db/models_factory.py b/snf-cyclades-app/synnefo/db/models_factory.py index f1df537c2..cdee21fa6 100644 --- a/snf-cyclades-app/synnefo/db/models_factory.py +++ b/snf-cyclades-app/synnefo/db/models_factory.py @@ -101,7 +101,7 @@ class VirtualMachineFactory(factory.DjangoModelFactory): flavor = factory.SubFactory(FlavorFactory) deleted = False suspended = False - #operstate = factory.Sequence(round_seq_first(FACTORY_FOR.OPER_STATES)) + # operstate = factory.Sequence(round_seq_first(FACTORY_FOR.OPER_STATES)) operstate = "STARTED" project = factory.LazyAttribute(lambda a: a.userid) @@ -110,7 +110,7 @@ class VolumeFactory(factory.DjangoModelFactory): FACTORY_FOR = models.Volume userid = factory.Sequence(user_seq()) size = factory.Sequence(lambda x: x, type=int) - name = factory.Sequence(lambda x: "volume-name-"+x, type=str) + name = factory.Sequence(lambda x: "volume-name-" + x, type=str) machine = factory.SubFactory(VirtualMachineFactory, userid=factory.SelfAttribute('..userid')) volume_type = factory.SubFactory(VolumeTypeFactory) From e3c21dd27eb85d53fd3d6b6c98454b094bf16352 Mon Sep 17 00:00:00 2001 From: indorilftw Date: Wed, 12 Nov 2014 11:54:52 +0200 Subject: [PATCH 20/43] PEP8 fixes on snf-cyclades-app/synnefo/helpdesk directory --- .../helpdesk/templatetags/helpdesk_tags.py | 14 +++++++------- snf-cyclades-app/synnefo/helpdesk/tests.py | 18 +++++++++--------- snf-cyclades-app/synnefo/helpdesk/views.py | 2 +- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/snf-cyclades-app/synnefo/helpdesk/templatetags/helpdesk_tags.py b/snf-cyclades-app/synnefo/helpdesk/templatetags/helpdesk_tags.py index 90119469f..26a18e0e0 100644 --- a/snf-cyclades-app/synnefo/helpdesk/templatetags/helpdesk_tags.py +++ b/snf-cyclades-app/synnefo/helpdesk/templatetags/helpdesk_tags.py @@ -31,13 +31,13 @@ def vm_public_ip(vm): VM_STATE_CSS_MAP = { - 'BUILD': 'warning', - 'PENDING': 'warning', - 'ERROR': 'important', - 'STOPPED': 'notice', - 'STARTED': 'success', - 'ACTIVE': 'success', - 'DESTROYED': 'inverse' + 'BUILD': 'warning', + 'PENDING': 'warning', + 'ERROR': 'important', + 'STOPPED': 'notice', + 'STARTED': 'success', + 'ACTIVE': 'success', + 'DESTROYED': 'inverse' } diff --git a/snf-cyclades-app/synnefo/helpdesk/tests.py b/snf-cyclades-app/synnefo/helpdesk/tests.py index f8b693f37..aeefa6bc5 100644 --- a/snf-cyclades-app/synnefo/helpdesk/tests.py +++ b/snf-cyclades-app/synnefo/helpdesk/tests.py @@ -72,8 +72,8 @@ def get_user_mock(request, *args, **kwargs): "tenant": { "id": "test", "name": "Firstname Lastname" - } - }, + } + }, "serviceCatalog": [], "user": { "roles_links": [], @@ -91,8 +91,8 @@ def get_user_mock(request, *args, **kwargs): "tenant": { "id": "test", "name": "Firstname Lastname" - } - }, + } + }, "serviceCatalog": [], "user": { "roles_links": [], @@ -137,10 +137,10 @@ def setUp(self): network__userid=None, address="195.251.222.211") ipv6 = mfactory.IPv4AddressFactory(nic__machine=vm1u1, - userid=vm1u1.userid, - network__public=True, - network__userid=None, - address="2001:648:2ffc:200::184") + userid=vm1u1.userid, + network__public=True, + network__userid=None, + address="2001:648:2ffc:200::184") mfactory.IPAddressLogFactory(address=ip2.address, server_id=vm1u1.id, network_id=ip2.network.id, @@ -179,7 +179,7 @@ def test_ip_lookup(self): # ipv6 matched r = self.client.get(reverse('helpdesk-details', args=["2001:648:2ffc:200::184"]), - user_token='0001') + user_token='0001') self.assertTrue(r.context["ip_exists"]) ips = r.context["ips"] for ip in ips: diff --git a/snf-cyclades-app/synnefo/helpdesk/views.py b/snf-cyclades-app/synnefo/helpdesk/views.py index cc66ecdc7..ad7219839 100644 --- a/snf-cyclades-app/synnefo/helpdesk/views.py +++ b/snf-cyclades-app/synnefo/helpdesk/views.py @@ -171,7 +171,7 @@ def account(request, search_query): vms = [] networks = [] is_ip = IP_SEARCH_REGEX.match(search_query) or \ - IP_V6_SEARCH_REGEX.match(search_query) + IP_V6_SEARCH_REGEX.match(search_query) is_uuid = UUID_SEARCH_REGEX.match(search_query) is_vm = VM_SEARCH_REGEX.match(search_query) account_name = search_query From 669c7339cb877e7998387d133ee773d6f2b66b98 Mon Sep 17 00:00:00 2001 From: indorilftw Date: Wed, 12 Nov 2014 11:55:48 +0200 Subject: [PATCH 21/43] PEP8 fixes on snf-cyclades-app/synnefo/logic directory --- .../commands/cyclades-astakos-migrate-013.py | 16 +-- .../management/commands/floating-ip-attach.py | 2 +- .../management/commands/floating-ip-detach.py | 4 +- .../management/commands/floating-ip-remove.py | 2 +- .../logic/management/commands/port-create.py | 6 +- .../management/commands/subnet-inspect.py | 2 +- snf-cyclades-app/synnefo/logic/queues.py | 2 +- snf-cyclades-app/synnefo/logic/subnets.py | 2 +- .../synnefo/logic/tests/networks.py | 2 +- .../synnefo/logic/tests/reconciliation.py | 106 +++++++++--------- .../synnefo/logic/tests/servers.py | 10 +- 11 files changed, 78 insertions(+), 76 deletions(-) diff --git a/snf-cyclades-app/synnefo/logic/management/commands/cyclades-astakos-migrate-013.py b/snf-cyclades-app/synnefo/logic/management/commands/cyclades-astakos-migrate-013.py index 1df1494b3..f8dc1bbdf 100644 --- a/snf-cyclades-app/synnefo/logic/management/commands/cyclades-astakos-migrate-013.py +++ b/snf-cyclades-app/synnefo/logic/management/commands/cyclades-astakos-migrate-013.py @@ -30,17 +30,19 @@ from snf_django.lib import astakos + def warn(*msgs): print "WARNING: %s" % ' '.join(msgs) get_displayname = functools.partial(astakos.get_displayname, - settings.CYCLADES_SERVICE_TOKEN, - url=settings.ASTAKOS_URL.replace('im/authenticate', - 'service/api/user_catalogs')) + settings.CYCLADES_SERVICE_TOKEN, + url=settings.ASTAKOS_URL.replace('im/authenticate', + 'service/api/user_catalogs')) get_user_uuid = functools.partial(astakos.get_user_uuid, - settings.CYCLADES_SERVICE_TOKEN, - url=settings.ASTAKOS_URL.replace('im/authenticate', - 'service/api/user_catalogs')) + settings.CYCLADES_SERVICE_TOKEN, + url=settings.ASTAKOS_URL.replace('im/authenticate', + 'service/api/user_catalogs')) + def _validate_db_state(usernames): @@ -50,7 +52,7 @@ def _validate_db_state(usernames): invalid_case_users.append(invalid_case_users[0].lower()) raise CommandError("Duplicate case insensitive user identifiers exist %r" % invalid_case_users) - uuidusers = filter(lambda uid:'@' in uid or uid == None, usernames) + uuidusers = filter(lambda uid: '@' in uid or uid == None, usernames) if len(uuidusers) != len(usernames): warn('It seems that mixed uuid/email user identifiers exist in database.') return False diff --git a/snf-cyclades-app/synnefo/logic/management/commands/floating-ip-attach.py b/snf-cyclades-app/synnefo/logic/management/commands/floating-ip-attach.py index e3a7541d7..c5d8f1997 100644 --- a/snf-cyclades-app/synnefo/logic/management/commands/floating-ip-attach.py +++ b/snf-cyclades-app/synnefo/logic/management/commands/floating-ip-attach.py @@ -45,7 +45,7 @@ def handle(self, *args, **options): if not device: raise CommandError('Please give either a server or a router id') - #get the vm + # get the vm vm = common.get_resource("server", device, for_update=True) floating_ip = common.get_resource("floating-ip", floating_ip_id, for_update=True) diff --git a/snf-cyclades-app/synnefo/logic/management/commands/floating-ip-detach.py b/snf-cyclades-app/synnefo/logic/management/commands/floating-ip-detach.py index d2e9df344..378b0201b 100644 --- a/snf-cyclades-app/synnefo/logic/management/commands/floating-ip-detach.py +++ b/snf-cyclades-app/synnefo/logic/management/commands/floating-ip-detach.py @@ -13,7 +13,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -#from optparse import make_option +# from optparse import make_option from django.core.management.base import CommandError @@ -33,7 +33,7 @@ def handle(self, *args, **options): floating_ip_id = args[0] - #get the floating-ip + # get the floating-ip floating_ip = common.get_resource("floating-ip", floating_ip_id, for_update=True) diff --git a/snf-cyclades-app/synnefo/logic/management/commands/floating-ip-remove.py b/snf-cyclades-app/synnefo/logic/management/commands/floating-ip-remove.py index 6cd46dd32..0c4513f41 100644 --- a/snf-cyclades-app/synnefo/logic/management/commands/floating-ip-remove.py +++ b/snf-cyclades-app/synnefo/logic/management/commands/floating-ip-remove.py @@ -13,7 +13,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -#from optparse import make_option +# from optparse import make_option from synnefo.db import transaction from django.core.management.base import CommandError diff --git a/snf-cyclades-app/synnefo/logic/management/commands/port-create.py b/snf-cyclades-app/synnefo/logic/management/commands/port-create.py index cb75b9340..8209b568c 100644 --- a/snf-cyclades-app/synnefo/logic/management/commands/port-create.py +++ b/snf-cyclades-app/synnefo/logic/management/commands/port-create.py @@ -55,7 +55,7 @@ class Command(SynnefoCommand): dest="server_id", default=None, help="The ID of the server that the port will be connected to."), - #make_option( + # make_option( # "--router", # dest="router_id", # default=None, @@ -94,7 +94,7 @@ def handle(self, *args, **options): user_id = options["user_id"] network_id = options["network_id"] server_id = options["server_id"] - #router_id = options["router_id"] + # router_id = options["router_id"] router_id = None # assume giving security groups comma separated security_group_ids = options["security-groups"] @@ -111,7 +111,7 @@ def handle(self, *args, **options): if server_id: owner = "vm" vm = common.get_resource("server", server_id, for_update=True) - #if vm.router: + # if vm.router: # raise CommandError("Server '%s' does not exist." % server_id) elif router_id: owner = "router" diff --git a/snf-cyclades-app/synnefo/logic/management/commands/subnet-inspect.py b/snf-cyclades-app/synnefo/logic/management/commands/subnet-inspect.py index fa2530981..49d9c8776 100644 --- a/snf-cyclades-app/synnefo/logic/management/commands/subnet-inspect.py +++ b/snf-cyclades-app/synnefo/logic/management/commands/subnet-inspect.py @@ -13,7 +13,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -#from optparse import make_option +# from optparse import make_option from django.core.management.base import CommandError diff --git a/snf-cyclades-app/synnefo/logic/queues.py b/snf-cyclades-app/synnefo/logic/queues.py index fbbc9a957..fc9b4e059 100644 --- a/snf-cyclades-app/synnefo/logic/queues.py +++ b/snf-cyclades-app/synnefo/logic/queues.py @@ -56,7 +56,7 @@ ) -## Extra for DEBUG: +# Extra for DEBUG: if DEBUG is True: # Debug queue, retrieves all messages QUEUE_DEBUG = "%s-debug" % prefix diff --git a/snf-cyclades-app/synnefo/logic/subnets.py b/snf-cyclades-app/synnefo/logic/subnets.py index 265ba2ff9..a9216126a 100644 --- a/snf-cyclades-app/synnefo/logic/subnets.py +++ b/snf-cyclades-app/synnefo/logic/subnets.py @@ -186,7 +186,7 @@ def update_subnet(sub_id, name, user_id): return subnet -#Utility functions +# Utility functions def create_ip_pools(pools, cidr, subnet): """Create IP Pools in the database""" return [_create_ip_pool(pool, cidr, subnet) for pool in pools] diff --git a/snf-cyclades-app/synnefo/logic/tests/networks.py b/snf-cyclades-app/synnefo/logic/tests/networks.py index 46dd29425..2fc70e9ce 100644 --- a/snf-cyclades-app/synnefo/logic/tests/networks.py +++ b/snf-cyclades-app/synnefo/logic/tests/networks.py @@ -25,7 +25,7 @@ from copy import copy -#@patch("synnefo.logic.rapi_pool.GanetiRapiClient") +# @patch("synnefo.logic.rapi_pool.GanetiRapiClient") class NetworkTest(TestCase): def test_create(self): kwargs = { diff --git a/snf-cyclades-app/synnefo/logic/tests/reconciliation.py b/snf-cyclades-app/synnefo/logic/tests/reconciliation.py index 1ec64bca4..fb4aaaa54 100644 --- a/snf-cyclades-app/synnefo/logic/tests/reconciliation.py +++ b/snf-cyclades-app/synnefo/logic/tests/reconciliation.py @@ -104,19 +104,19 @@ def test_orphan_server(self, mrapi): cmrapi = self.reconciler.client mrapi().GetInstances.return_value =\ [{"name": "%s22" % settings.BACKEND_PREFIX_ID, - "beparams": {"maxmem": 1024, - "minmem": 1024, - "vcpus": 4}, - "oper_state": True, - "mtime": time(), - "disk.sizes": [], - "disk.names": [], - "disk.uuids": [], - "nic.ips": [], - "nic.names": [], - "nic.macs": [], - "nic.networks.names": [], - "tags": []}] + "beparams": {"maxmem": 1024, + "minmem": 1024, + "vcpus": 4}, + "oper_state": True, + "mtime": time(), + "disk.sizes": [], + "disk.names": [], + "disk.uuids": [], + "nic.ips": [], + "nic.names": [], + "nic.macs": [], + "nic.networks.names": [], + "tags": []}] self.reconciler.reconcile() cmrapi.DeleteInstance\ .assert_called_once_with("%s22" % settings.BACKEND_PREFIX_ID) @@ -127,19 +127,19 @@ def test_unsynced_operstate(self, mrapi): operstate="STOPPED") mrapi().GetInstances.return_value =\ [{"name": vm1.backend_vm_id, - "beparams": {"maxmem": 1024, - "minmem": 1024, - "vcpus": 4}, - "oper_state": True, - "mtime": time(), - "disk.sizes": [], - "disk.names": [], - "disk.uuids": [], - "nic.ips": [], - "nic.names": [], - "nic.macs": [], - "nic.networks.names": [], - "tags": []}] + "beparams": {"maxmem": 1024, + "minmem": 1024, + "vcpus": 4}, + "oper_state": True, + "mtime": time(), + "disk.sizes": [], + "disk.names": [], + "disk.uuids": [], + "nic.ips": [], + "nic.names": [], + "nic.macs": [], + "nic.networks.names": [], + "tags": []}] with mocked_quotaholder(): self.reconciler.reconcile() vm1 = VirtualMachine.objects.get(id=vm1.id) @@ -156,19 +156,19 @@ def test_unsynced_flavor(self, mrapi): operstate="STARTED") mrapi().GetInstances.return_value =\ [{"name": vm1.backend_vm_id, - "beparams": {"maxmem": 2048, - "minmem": 2048, - "vcpus": 4}, - "oper_state": True, - "mtime": time(), - "disk.sizes": [], - "disk.names": [], - "disk.uuids": [], - "nic.ips": [], - "nic.names": [], - "nic.macs": [], - "nic.networks.names": [], - "tags": []}] + "beparams": {"maxmem": 2048, + "minmem": 2048, + "vcpus": 4}, + "oper_state": True, + "mtime": time(), + "disk.sizes": [], + "disk.names": [], + "disk.uuids": [], + "nic.ips": [], + "nic.names": [], + "nic.macs": [], + "nic.networks.names": [], + "tags": []}] with mocked_quotaholder(): self.reconciler.reconcile() vm1 = VirtualMachine.objects.get(id=vm1.id) @@ -190,19 +190,19 @@ def test_unsynced_nics(self, mrapi): nic = ip.nic mrapi().GetInstances.return_value =\ [{"name": vm1.backend_vm_id, - "beparams": {"maxmem": 2048, - "minmem": 2048, - "vcpus": 4}, - "oper_state": True, - "mtime": time(), - "disk.sizes": [], - "disk.names": [], - "disk.uuids": [], - "nic.names": [nic.backend_uuid], - "nic.ips": ["192.168.2.5"], - "nic.macs": ["aa:00:bb:cc:dd:ee"], - "nic.networks.names": [network2.backend_id], - "tags": []}] + "beparams": {"maxmem": 2048, + "minmem": 2048, + "vcpus": 4}, + "oper_state": True, + "mtime": time(), + "disk.sizes": [], + "disk.names": [], + "disk.uuids": [], + "nic.names": [nic.backend_uuid], + "nic.ips": ["192.168.2.5"], + "nic.macs": ["aa:00:bb:cc:dd:ee"], + "nic.networks.names": [network2.backend_id], + "tags": []}] with mocked_quotaholder(): self.reconciler.reconcile() vm1 = VirtualMachine.objects.get(id=vm1.id) @@ -275,7 +275,7 @@ def test_missing_network(self, mrapi): self.reconciler.reconcile_networks() self.assertEqual(len(mrapi().CreateNetwork.mock_calls), 1) - #def test_hanging_networks(self, mrapi): + # def test_hanging_networks(self, mrapi): # pass def test_unsynced_networks(self, mrapi): diff --git a/snf-cyclades-app/synnefo/logic/tests/servers.py b/snf-cyclades-app/synnefo/logic/tests/servers.py index 5777ddd17..d28fd4bb3 100644 --- a/snf-cyclades-app/synnefo/logic/tests/servers.py +++ b/snf-cyclades-app/synnefo/logic/tests/servers.py @@ -16,7 +16,7 @@ # Provides automated tests for logic module from django.test import TransactionTestCase -#from snf_django.utils.testing import mocked_quotaholder +# from snf_django.utils.testing import mocked_quotaholder from synnefo.logic import servers from synnefo import quotas from synnefo.db import models_factory as mfactory, models @@ -28,8 +28,8 @@ from copy import deepcopy fixed_image = Mock() -fixed_image.return_value = {'location': 'pithos://foo', - 'mapfile': 'test_mapfile', +fixed_image.return_value = {"location": "pithos://foo", + "mapfile": "test_mapfile", "id": 1, "name": "test_image", "version": 42, @@ -38,7 +38,7 @@ "status": "AVAILABLE", "size": 1000, "is_snapshot": False, - 'disk_format': 'diskdump'} + "disk_format": "diskdump"} @patch('synnefo.api.util.get_image', fixed_image) @@ -190,7 +190,7 @@ def test_invalid_operstate_for_action(self, mrapi): self.assertRaises(faults.BadRequest, servers.connect, vm, network) self.assertRaises(faults.BadRequest, servers.disconnect, vm, network) - #test valid + # test valid vm = mfactory.VirtualMachineFactory(operstate="STOPPED") mrapi().StartupInstance.return_value = 1 with mocked_quotaholder(): From 7acaf0f2112a83649ba200a087e07ac7436c3b1d Mon Sep 17 00:00:00 2001 From: indorilftw Date: Wed, 12 Nov 2014 11:56:17 +0200 Subject: [PATCH 22/43] PEP8 fixes on snf-cyclades-app/synnefo/quotas directory --- snf-cyclades-app/synnefo/quotas/tests.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/snf-cyclades-app/synnefo/quotas/tests.py b/snf-cyclades-app/synnefo/quotas/tests.py index 332c00a3e..606fa348f 100644 --- a/snf-cyclades-app/synnefo/quotas/tests.py +++ b/snf-cyclades-app/synnefo/quotas/tests.py @@ -126,8 +126,8 @@ def test_commissions(self): status="IN_USE", delete_on_termination=True) vm.volumes.update(project=vm.project) - #commission = quotas.get_commission_info(vm, "BUILD") - #self.assertEqual({"cyclades.vm": 1, + # commission = quotas.get_commission_info(vm, "BUILD") + # self.assertEqual({"cyclades.vm": 1, # "cyclades.cpu": 2, # "cyclades.cpu": 2, # "cyclades.ram": 1048576 * 1024, From b4f3a45143181d26b024866ff8c053db121e39b1 Mon Sep 17 00:00:00 2001 From: indorilftw Date: Wed, 12 Nov 2014 11:56:45 +0200 Subject: [PATCH 23/43] PEP8 fixes on snf-cyclades-app/synnefo/ui directory --- snf-cyclades-app/synnefo/ui/__init__.py | 2 +- snf-cyclades-app/synnefo/ui/models.py | 2 +- snf-cyclades-app/synnefo/ui/tests.py | 11 ++++++----- snf-cyclades-app/synnefo/ui/views.py | 1 + 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/snf-cyclades-app/synnefo/ui/__init__.py b/snf-cyclades-app/synnefo/ui/__init__.py index 908dd6f9a..d71bef327 100644 --- a/snf-cyclades-app/synnefo/ui/__init__.py +++ b/snf-cyclades-app/synnefo/ui/__init__.py @@ -12,4 +12,4 @@ # # You should have received a copy of the GNU General Public License # along with this program. If not, see . -# +# diff --git a/snf-cyclades-app/synnefo/ui/models.py b/snf-cyclades-app/synnefo/ui/models.py index 62911f2d9..5dce4f6fa 100644 --- a/snf-cyclades-app/synnefo/ui/models.py +++ b/snf-cyclades-app/synnefo/ui/models.py @@ -12,7 +12,7 @@ # # You should have received a copy of the GNU General Public License # along with this program. If not, see . -# +# from django.db import models # Create your models here. diff --git a/snf-cyclades-app/synnefo/ui/tests.py b/snf-cyclades-app/synnefo/ui/tests.py index 2e5d8ba30..3ca3c88bc 100644 --- a/snf-cyclades-app/synnefo/ui/tests.py +++ b/snf-cyclades-app/synnefo/ui/tests.py @@ -12,12 +12,13 @@ # # You should have received a copy of the GNU General Public License # along with this program. If not, see . -# +# from django.test import TestCase from selenium import selenium from multiprocessing import Process from time import sleep + class FunctionalCase(TestCase): """ Functional tests for synnefo.ui using Selenium @@ -74,8 +75,8 @@ def test_wizard(self): except AssertionError, e: self.verificationErrors.append(str(e)) - #self.assertEqual("Success!", + # self.assertEqual("Success!", # sel.get_text("//div[@id='error-success']/h3")) - #sel.click("//div[@id='error-success']/a") - #try: self.failUnless(sel.is_text_present("My Debian Unstable server")) - #except AssertionError, e: self.verificationErrors.append(str(e)) + # sel.click("//div[@id='error-success']/a") + # try: self.failUnless(sel.is_text_present("My Debian Unstable server")) + # except AssertionError, e: self.verificationErrors.append(str(e)) diff --git a/snf-cyclades-app/synnefo/ui/views.py b/snf-cyclades-app/synnefo/ui/views.py index e24d86449..08197d1e3 100644 --- a/snf-cyclades-app/synnefo/ui/views.py +++ b/snf-cyclades-app/synnefo/ui/views.py @@ -151,6 +151,7 @@ VOLUME_MAX_SIZE = getattr(settings, "CYCLADES_VOLUME_MAX_SIZE", 200) SNAPSHOTS_ENABLED = getattr(settings, "CYCLADES_SNAPSHOTS_ENABLED", True) + def template(name, request, context): template_path = os.path.join(os.path.dirname(__file__), "templates/") current_template = template_path + name + '.html' From 05078ef83b2594a7eed118da2b929dc6eb07117f Mon Sep 17 00:00:00 2001 From: indorilftw Date: Wed, 12 Nov 2014 11:57:01 +0200 Subject: [PATCH 24/43] PEP8 fixes on snf-cyclades-app/synnefo/userdata directory --- .../synnefo/userdata/migrations/0001_initial.py | 3 +-- .../userdata/migrations/0002_fingerprint_field.py | 7 +++---- ...ir_fingerprint__chg_field_publickeypair_use.py | 3 +-- snf-cyclades-app/synnefo/userdata/rest.py | 2 +- snf-cyclades-app/synnefo/userdata/util.py | 15 ++++++++------- 5 files changed, 14 insertions(+), 16 deletions(-) diff --git a/snf-cyclades-app/synnefo/userdata/migrations/0001_initial.py b/snf-cyclades-app/synnefo/userdata/migrations/0001_initial.py index 4b0905960..b4381dcd1 100644 --- a/snf-cyclades-app/synnefo/userdata/migrations/0001_initial.py +++ b/snf-cyclades-app/synnefo/userdata/migrations/0001_initial.py @@ -4,6 +4,7 @@ from south.v2 import SchemaMigration from django.db import models + class Migration(SchemaMigration): depends_on = ( @@ -21,13 +22,11 @@ def forwards(self, orm): )) db.send_create_signal('userdata', ['PublicKeyPair']) - def backwards(self, orm): # Deleting model 'PublicKeyPair' db.delete_table('userdata_publickeypair') - models = { 'db.synnefouser': { 'Meta': {'object_name': 'SynnefoUser'}, diff --git a/snf-cyclades-app/synnefo/userdata/migrations/0002_fingerprint_field.py b/snf-cyclades-app/synnefo/userdata/migrations/0002_fingerprint_field.py index 4e7acbcb6..08f10f888 100644 --- a/snf-cyclades-app/synnefo/userdata/migrations/0002_fingerprint_field.py +++ b/snf-cyclades-app/synnefo/userdata/migrations/0002_fingerprint_field.py @@ -4,20 +4,19 @@ from south.v2 import SchemaMigration from django.db import models + class Migration(SchemaMigration): def forwards(self, orm): - + # Adding field 'PublicKeyPair.fingerprint' db.add_column('userdata_publickeypair', 'fingerprint', self.gf('django.db.models.fields.CharField')(default='', max_length=100), keep_default=False) - def backwards(self, orm): - + # Deleting field 'PublicKeyPair.fingerprint' db.delete_column('userdata_publickeypair', 'fingerprint') - models = { 'db.synnefouser': { 'Meta': {'object_name': 'SynnefoUser'}, diff --git a/snf-cyclades-app/synnefo/userdata/migrations/0003_auto__chg_field_publickeypair_fingerprint__chg_field_publickeypair_use.py b/snf-cyclades-app/synnefo/userdata/migrations/0003_auto__chg_field_publickeypair_fingerprint__chg_field_publickeypair_use.py index 90bd2ebed..95565df3a 100644 --- a/snf-cyclades-app/synnefo/userdata/migrations/0003_auto__chg_field_publickeypair_fingerprint__chg_field_publickeypair_use.py +++ b/snf-cyclades-app/synnefo/userdata/migrations/0003_auto__chg_field_publickeypair_fingerprint__chg_field_publickeypair_use.py @@ -4,6 +4,7 @@ from south.v2 import SchemaMigration from django.db import models + class Migration(SchemaMigration): needed_by = ( @@ -30,7 +31,6 @@ def forwards(self, orm): except: pass - def backwards(self, orm): # Changing field 'PublicKeyPair.fingerprint' @@ -44,7 +44,6 @@ def backwards(self, orm): # Adding index on 'PublicKeyPair', fields ['user'] db.create_index('userdata_publickeypair', ['user_id']) - models = { 'userdata.publickeypair': { 'Meta': {'object_name': 'PublicKeyPair'}, diff --git a/snf-cyclades-app/synnefo/userdata/rest.py b/snf-cyclades-app/synnefo/userdata/rest.py index f8c28fc71..c79929098 100644 --- a/snf-cyclades-app/synnefo/userdata/rest.py +++ b/snf-cyclades-app/synnefo/userdata/rest.py @@ -98,7 +98,7 @@ def dispatch(self, request, *args, **kwargs): return http.HttpResponse( json.dumps({'errors': e.message_dict, 'non_field_key': NON_FIELD_ERRORS}), - status=422, content_type="application/json") + status=422, content_type="application/json") else: allowed_methods = \ diff --git a/snf-cyclades-app/synnefo/userdata/util.py b/snf-cyclades-app/synnefo/userdata/util.py index 0e0982a55..b6b5f66e3 100644 --- a/snf-cyclades-app/synnefo/userdata/util.py +++ b/snf-cyclades-app/synnefo/userdata/util.py @@ -17,6 +17,7 @@ from synnefo.userdata.asn1 import DerObject, DerSequence + def exportKey(keyobj, format='PEM'): """Export the RSA key. A string is returned with the encoded public or the private half @@ -27,24 +28,24 @@ def exportKey(keyobj, format='PEM'): der = DerSequence() if keyobj.has_private(): keyType = "RSA PRIVATE" - der[:] = [ 0, keyobj.n, keyobj.e, keyobj.d, keyobj.p, keyobj.q, - keyobj.d % (keyobj.p-1), keyobj.d % (keyobj.q-1), - keyobj.u ] + der[:] = [0, keyobj.n, keyobj.e, keyobj.d, keyobj.p, keyobj.q, + keyobj.d % (keyobj.p - 1), keyobj.d % (keyobj.q - 1), + keyobj.u] else: keyType = "PUBLIC" der.append('\x30\x0D\x06\x09\x2A\x86\x48\x86\xF7\x0D\x01\x01\x01\x05\x00') bitmap = DerObject('BIT STRING') derPK = DerSequence() - derPK[:] = [ keyobj.n, keyobj.e ] + derPK[:] = [keyobj.n, keyobj.e] bitmap.payload = '\x00' + derPK.encode() der.append(bitmap.encode()) - if format=='DER': + if format == 'DER': return der.encode() - if format=='PEM': + if format == 'PEM': pem = "-----BEGIN %s KEY-----\n" % keyType binaryKey = der.encode() # Each BASE64 line can take up to 64 characters (=48 bytes of data) - chunks = [ binascii.b2a_base64(binaryKey[i:i+48]) for i in range(0, len(binaryKey), 48) ] + chunks = [binascii.b2a_base64(binaryKey[i:i + 48]) for i in range(0, len(binaryKey), 48)] pem += ''.join(chunks) pem += "-----END %s KEY-----" % keyType return pem From 5e8f67b49ea9d644374c5fd3ae1618747edd1112 Mon Sep 17 00:00:00 2001 From: indorilftw Date: Wed, 12 Nov 2014 11:57:12 +0200 Subject: [PATCH 25/43] PEP8 fixes on snf-cyclades-app/synnefo/vmapi directory --- snf-cyclades-app/synnefo/vmapi/tests.py | 1 + 1 file changed, 1 insertion(+) diff --git a/snf-cyclades-app/synnefo/vmapi/tests.py b/snf-cyclades-app/synnefo/vmapi/tests.py index a14742dd6..8ef16d810 100644 --- a/snf-cyclades-app/synnefo/vmapi/tests.py +++ b/snf-cyclades-app/synnefo/vmapi/tests.py @@ -30,6 +30,7 @@ def setUp(self, *args, **kwargs): super(VMAPITest, self).setUp(*args, **kwargs) self.api_path = get_service_path(cyclades_services, 'vmapi', version='v1.0') + def myget(self, path, *args, **kwargs): path = join_urls(self.api_path, path) return self.client.get(path, *args, **kwargs) From 161fd86e32be03ce14ad40935e0f4e522a31873f Mon Sep 17 00:00:00 2001 From: indorilftw Date: Wed, 12 Nov 2014 11:57:47 +0200 Subject: [PATCH 26/43] PEP8 fixes on snf-cyclades-app/synnefo/volume directory --- .../synnefo/volume/management/commands/snapshot-create.py | 2 +- .../synnefo/volume/management/commands/volume-list.py | 2 +- .../synnefo/volume/management/commands/volume-type-list.py | 2 +- snf-cyclades-app/synnefo/volume/tests/__init__.py | 2 +- snf-cyclades-app/synnefo/volume/tests/volumes.py | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/snf-cyclades-app/synnefo/volume/management/commands/snapshot-create.py b/snf-cyclades-app/synnefo/volume/management/commands/snapshot-create.py index caba1eddc..c2a9e3556 100644 --- a/snf-cyclades-app/synnefo/volume/management/commands/snapshot-create.py +++ b/snf-cyclades-app/synnefo/volume/management/commands/snapshot-create.py @@ -17,7 +17,7 @@ from snf_django.management.commands import SynnefoCommand, CommandError from synnefo.management import common -#from snf_django.management.utils import parse_bool +# from snf_django.management.utils import parse_bool from synnefo.volume import snapshots diff --git a/snf-cyclades-app/synnefo/volume/management/commands/volume-list.py b/snf-cyclades-app/synnefo/volume/management/commands/volume-list.py index 9024369c9..0d81d6af3 100644 --- a/snf-cyclades-app/synnefo/volume/management/commands/volume-list.py +++ b/snf-cyclades-app/synnefo/volume/management/commands/volume-list.py @@ -13,7 +13,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -#from optparse import make_option +# from optparse import make_option from snf_django.management.commands import ListCommand from synnefo.db.models import Volume diff --git a/snf-cyclades-app/synnefo/volume/management/commands/volume-type-list.py b/snf-cyclades-app/synnefo/volume/management/commands/volume-type-list.py index 9d58fb251..1380063ba 100644 --- a/snf-cyclades-app/synnefo/volume/management/commands/volume-type-list.py +++ b/snf-cyclades-app/synnefo/volume/management/commands/volume-type-list.py @@ -13,7 +13,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -#from optparse import make_option +# from optparse import make_option from snf_django.management.commands import ListCommand from synnefo.db.models import VolumeType diff --git a/snf-cyclades-app/synnefo/volume/tests/__init__.py b/snf-cyclades-app/synnefo/volume/tests/__init__.py index c4ddcf442..fabdbaccb 100644 --- a/snf-cyclades-app/synnefo/volume/tests/__init__.py +++ b/snf-cyclades-app/synnefo/volume/tests/__init__.py @@ -1,3 +1,3 @@ -#from .api_tests import * +# from .api_tests import * from .api import * from .volumes import * diff --git a/snf-cyclades-app/synnefo/volume/tests/volumes.py b/snf-cyclades-app/synnefo/volume/tests/volumes.py index c070cb2de..d7db79bfc 100644 --- a/snf-cyclades-app/synnefo/volume/tests/volumes.py +++ b/snf-cyclades-app/synnefo/volume/tests/volumes.py @@ -14,7 +14,7 @@ # along with this program. If not, see . from snf_django.utils.testing import BaseAPITest, mocked_quotaholder -#from synnefo.db.models import Volume +# from synnefo.db.models import Volume from synnefo.db import models_factory as mf from synnefo.volume import volumes from snf_django.lib.api import faults From d0c62a440b552dadb4dc0157a21a269438e9a52b Mon Sep 17 00:00:00 2001 From: indorilftw Date: Wed, 12 Nov 2014 11:58:05 +0200 Subject: [PATCH 27/43] PEP8 fixes on snf-cyclades-app directory --- snf-cyclades-app/distribute_setup.py | 35 ++++++----- snf-cyclades-app/docs/conf.py | 53 ++++++++-------- snf-cyclades-app/setup.py | 94 ++++++++++++++-------------- 3 files changed, 94 insertions(+), 88 deletions(-) diff --git a/snf-cyclades-app/distribute_setup.py b/snf-cyclades-app/distribute_setup.py index 10d66840a..34bd39c27 100644 --- a/snf-cyclades-app/distribute_setup.py +++ b/snf-cyclades-app/distribute_setup.py @@ -144,17 +144,17 @@ def use_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL, except ImportError: return _do_download(version, download_base, to_dir, download_delay) try: - pkg_resources.require("distribute>="+version) + pkg_resources.require("distribute>=" + version) return except pkg_resources.VersionConflict: e = sys.exc_info()[1] if was_imported: sys.stderr.write( - "The required version of distribute (>=%s) is not available,\n" - "and can't be installed while this script is running. Please\n" - "install a more recent version first, using\n" - "'easy_install -U distribute'." - "\n\n(Currently using %r)\n" % (version, e.args[0])) + "The required version of distribute (>=%s) is not available,\n" + "and can't be installed while this script is running. Please\n" + "install a more recent version first, using\n" + "'easy_install -U distribute'." + "\n\n(Currently using %r)\n" % (version, e.args[0])) sys.exit(2) else: del pkg_resources, sys.modules['pkg_resources'] # reload ok @@ -167,10 +167,10 @@ def use_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL, if not no_fake: _create_fake_setuptools_pkg_info(to_dir) + def download_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL, to_dir=os.curdir, delay=15): """Download distribute from a specified location and return its filename - `version` should be a valid distribute version number that is available as an egg for download under the `download_base` URL (which should end with a '/'). `to_dir` is the directory where the egg will be downloaded. @@ -203,6 +203,7 @@ def download_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL, dst.close() return os.path.realpath(saveto) + def _no_sandbox(function): def __no_sandbox(*args, **kw): try: @@ -227,6 +228,7 @@ def violation(*args): return __no_sandbox + def _patch_file(path, content): """Will backup the file then patch it""" existing_content = open(path).read() @@ -245,15 +247,18 @@ def _patch_file(path, content): _patch_file = _no_sandbox(_patch_file) + def _same_content(path, content): return open(path).read() == content + def _rename_path(path): new_name = path + '.OLD.%s' % time.time() log.warn('Renaming %s into %s', path, new_name) os.rename(path, new_name) return new_name + def _remove_flat_installation(placeholder): if not os.path.isdir(placeholder): log.warn('Unkown installation at %s', placeholder) @@ -289,18 +294,19 @@ def _remove_flat_installation(placeholder): _remove_flat_installation = _no_sandbox(_remove_flat_installation) + def _after_install(dist): log.warn('After install bootstrap.') placeholder = dist.get_command_obj('install').install_purelib _create_fake_setuptools_pkg_info(placeholder) + def _create_fake_setuptools_pkg_info(placeholder): if not placeholder or not os.path.exists(placeholder): log.warn('Could not find the install location') return pyver = '%s.%s' % (sys.version_info[0], sys.version_info[1]) - setuptools_file = 'setuptools-%s-py%s.egg-info' % \ - (SETUPTOOLS_FAKED_VERSION, pyver) + setuptools_file = 'setuptools-%s-py%s.egg-info' % (SETUPTOOLS_FAKED_VERSION, pyver) pkg_info = os.path.join(placeholder, setuptools_file) if os.path.exists(pkg_info): log.warn('%s already exists', pkg_info) @@ -323,6 +329,7 @@ def _create_fake_setuptools_pkg_info(placeholder): _create_fake_setuptools_pkg_info = _no_sandbox(_create_fake_setuptools_pkg_info) + def _patch_egg_dir(path): # let's check if it's already patched pkg_info = os.path.join(path, 'EGG-INFO', 'PKG-INFO') @@ -343,6 +350,7 @@ def _patch_egg_dir(path): _patch_egg_dir = _no_sandbox(_patch_egg_dir) + def _before_install(): log.warn('Before install bootstrap.') _fake_setuptools() @@ -351,7 +359,7 @@ def _before_install(): def _under_prefix(location): if 'install' not in sys.argv: return True - args = sys.argv[sys.argv.index('install')+1:] + args = sys.argv[sys.argv.index('install') + 1:] for index, arg in enumerate(args): for option in ('--root', '--prefix'): if arg.startswith('%s=' % option): @@ -359,7 +367,7 @@ def _under_prefix(location): return location.startswith(top_dir) elif arg == option: if len(args) > index: - top_dir = args[index+1] + top_dir = args[index + 1] return location.startswith(top_dir) if arg == '--user' and USER_SITE is not None: return location.startswith(USER_SITE) @@ -405,8 +413,7 @@ def _fake_setuptools(): else: log.warn('Egg installation') pkg_info = os.path.join(setuptools_location, 'EGG-INFO', 'PKG-INFO') - if (os.path.exists(pkg_info) and - _same_content(pkg_info, SETUPTOOLS_PKG_INFO)): + if (os.path.exists(pkg_info) and _same_content(pkg_info, SETUPTOOLS_PKG_INFO)): log.warn('Already patched.') return log.warn('Patching...') @@ -448,7 +455,7 @@ def _extractall(self, path=".", members=None): # Extract directories with a safe mode. directories.append(tarinfo) tarinfo = copy.copy(tarinfo) - tarinfo.mode = 448 # decimal for oct 0700 + tarinfo.mode = 448 # decimal for oct 0700 self.extract(tarinfo, path) # Reverse sort directories. diff --git a/snf-cyclades-app/docs/conf.py b/snf-cyclades-app/docs/conf.py index bf173dc88..678fe5c8a 100644 --- a/snf-cyclades-app/docs/conf.py +++ b/snf-cyclades-app/docs/conf.py @@ -1,4 +1,5 @@ -import sys, os +import sys +import os sys.path.insert(0, os.path.abspath('../')) from synnefo.versions.apps import __version__ @@ -16,34 +17,34 @@ pygments_style = 'sphinx' html_theme = 'default' html_theme_options = { - 'collapsiblesidebar': 'true', - 'footerbgcolor': '#55b577', - 'footertextcolor': '#000000', - 'sidebarbgcolor': '#ffffff', - 'sidebarbtncolor': '#f2f2f2', - 'sidebartextcolor': '#000000', - 'sidebarlinkcolor': '#328e4a', - 'relbarbgcolor': '#55b577', - 'relbartextcolor': '#ffffff', - 'relbarlinkcolor': '#ffffff', - 'bgcolor': '#ffffff', - 'textcolor': '#000000', - 'headbgcolor': '#ffffff', - 'headtextcolor': '#000000', - 'headlinkcolor': '#c60f0f', - 'linkcolor': '#328e4a', - 'visitedlinkcolor': '#63409b', - 'codebgcolor': '#eeffcc', - 'codetextcolor': '#333333' + 'collapsiblesidebar': 'true', + 'footerbgcolor': '#55b577', + 'footertextcolor': '#000000', + 'sidebarbgcolor': '#ffffff', + 'sidebarbtncolor': '#f2f2f2', + 'sidebartextcolor': '#000000', + 'sidebarlinkcolor': '#328e4a', + 'relbarbgcolor': '#55b577', + 'relbartextcolor': '#ffffff', + 'relbarlinkcolor': '#ffffff', + 'bgcolor': '#ffffff', + 'textcolor': '#000000', + 'headbgcolor': '#ffffff', + 'headtextcolor': '#000000', + 'headlinkcolor': '#c60f0f', + 'linkcolor': '#328e4a', + 'visitedlinkcolor': '#63409b', + 'codebgcolor': '#eeffcc', + 'codetextcolor': '#333333' } html_static_path = ['_static'] htmlhelp_basename = 'synnefodoc' intersphinx_mapping = { - 'pithon': ('http://docs.python.org/', None), - 'django': ('https://docs.djangoproject.com/en/dev/', - 'https://docs.djangoproject.com/en/dev/_objects/') + 'pithon': ('http://docs.python.org/', None), + 'django': ('https://docs.djangoproject.com/en/dev/', + 'https://docs.djangoproject.com/en/dev/_objects/') } SYNNEFO_DOCS_BASE_URL = 'http://www.synnefo.org/docs' @@ -57,9 +58,9 @@ } for name, ver in SYNNEFO_PROJECTS.iteritems(): - intersphinx_mapping[name.replace("-","")] = (SYNNEFO_DOCS_BASE_URL + - '%s/%s/' % (name, ver), - None) + intersphinx_mapping[name.replace("-", "")] = (SYNNEFO_DOCS_BASE_URL + + '%s/%s/' % (name, ver), + None) extensions = ['sphinx.ext.intersphinx', 'sphinx.ext.todo', diff --git a/snf-cyclades-app/setup.py b/snf-cyclades-app/setup.py index c0abff28c..e7658335e 100644 --- a/snf-cyclades-app/setup.py +++ b/snf-cyclades-app/setup.py @@ -65,9 +65,9 @@ ] EXTRAS_REQUIRES = { - 'DISPATCHER': ['puka', 'python-daemon==1.5.5', 'lockfile==0.8', - 'setproctitle>=1.0.1'], - 'SSH_KEYS': ['pycrypto==2.1.0'], + 'DISPATCHER': ['puka', 'python-daemon==1.5.5', 'lockfile==0.8', + 'setproctitle>=1.0.1'], + 'SSH_KEYS': ['pycrypto==2.1.0'], } TESTS_REQUIRES = [ @@ -82,18 +82,19 @@ ".*", "CVS", "_darcs", "./build", "./dist", "EGG-INFO", "*.egg-info", "snf-0.7" ] + # (c) 2005 Ian Bicking and contributors; written for Paste (http://pythonpaste.org) # Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php # Note: you may want to copy this into your setup.py file verbatim, as # you can't import this from another package, when you don't know if # that package is installed yet. def find_package_data( - where=".", - package="", - exclude=standard_exclude, - exclude_directories=standard_exclude_directories, - only_in_packages=True, - show_ignored=False): + where=".", + package="", + exclude=standard_exclude, + exclude_directories=standard_exclude_directories, + only_in_packages=True, + show_ignored=False): """ Return a dictionary suitable for use in ``package_data`` in a distutils ``setup.py`` file. @@ -129,8 +130,7 @@ def find_package_data( if os.path.isdir(fn): bad_name = False for pattern in exclude_directories: - if (fnmatchcase(name, pattern) - or fn.lower() == pattern.lower()): + if (fnmatchcase(name, pattern) or fn.lower() == pattern.lower()): bad_name = True if show_ignored: print >> sys.stderr, ( @@ -139,8 +139,7 @@ def find_package_data( break if bad_name: continue - if (os.path.isfile(os.path.join(fn, "__init__.py")) - and not prefix): + if (os.path.isfile(os.path.join(fn, "__init__.py")) and not prefix): if not package: new_package = name else: @@ -152,8 +151,7 @@ def find_package_data( # is a file bad_name = False for pattern in exclude: - if (fnmatchcase(name, pattern) - or fn.lower() == pattern.lower()): + if (fnmatchcase(name, pattern) or fn.lower() == pattern.lower()): bad_name = True if show_ignored: print >> sys.stderr, ( @@ -162,46 +160,46 @@ def find_package_data( break if bad_name: continue - out.setdefault(package, []).append(prefix+name) + out.setdefault(package, []).append(prefix + name) return out setup( - name = 'snf-cyclades-app', - version = VERSION, - license = 'GNU GPLv3', - url = 'http://www.synnefo.org/', - description = SHORT_DESCRIPTION, - classifiers = CLASSIFIERS, + name='snf-cyclades-app', + version=VERSION, + license='GNU GPLv3', + url='http://www.synnefo.org/', + description=SHORT_DESCRIPTION, + classifiers=CLASSIFIERS, author='Synnefo development team', author_email='synnefo-devel@googlegroups.com', maintainer='Synnefo development team', maintainer_email='synnefo-devel@googlegroups.com', - namespace_packages = ['synnefo', 'synnefo.versions'], - packages = PACKAGES, - package_dir= {'': PACKAGES_ROOT}, - include_package_data = True, - package_data = find_package_data('.'), - zip_safe = False, - - install_requires = INSTALL_REQUIRES, - extras_require = EXTRAS_REQUIRES, - tests_require = TESTS_REQUIRES, - - dependency_links = ['http://www.synnefo.org/packages/pypi'], - - entry_points = { - 'console_scripts': [ - 'snf-dispatcher = synnefo.logic.dispatcher:main', - ], - 'synnefo': [ - 'default_settings = synnefo.app_settings.default', - 'web_apps = synnefo.app_settings:synnefo_web_apps', - 'web_middleware = synnefo.app_settings:synnefo_web_middleware', - 'web_context_processors = synnefo.app_settings:synnefo_web_context_processors', - 'urls = synnefo.app_settings.urls:urlpatterns', - 'web_static = synnefo.app_settings:synnefo_static_files', - ] - }, + namespace_packages=['synnefo', 'synnefo.versions'], + packages=PACKAGES, + package_dir={'': PACKAGES_ROOT}, + include_package_data=True, + package_data=find_package_data('.'), + zip_safe=False, + + install_requires=INSTALL_REQUIRES, + extras_require=EXTRAS_REQUIRES, + tests_require=TESTS_REQUIRES, + + dependency_links=['http://www.synnefo.org/packages/pypi'], + + entry_points={ + 'console_scripts': [ + 'snf-dispatcher = synnefo.logic.dispatcher:main', + ], + 'synnefo': [ + 'default_settings = synnefo.app_settings.default', + 'web_apps = synnefo.app_settings:synnefo_web_apps', + 'web_middleware = synnefo.app_settings:synnefo_web_middleware', + 'web_context_processors = synnefo.app_settings:synnefo_web_context_processors', + 'urls = synnefo.app_settings.urls:urlpatterns', + 'web_static = synnefo.app_settings:synnefo_static_files', + ] + }, ) From 5d4362fab05b485cf39f68daa16bfe8d8913d85b Mon Sep 17 00:00:00 2001 From: indorilftw Date: Wed, 12 Nov 2014 11:58:27 +0200 Subject: [PATCH 28/43] PEP8 fixes on snf-cyclades-gtools directory --- snf-cyclades-gtools/docs/conf.py | 53 ++++++++++--------- snf-cyclades-gtools/synnefo/ganeti/config.py | 7 +-- snf-cyclades-gtools/synnefo/ganeti/eventd.py | 12 ++--- .../synnefo/versions/__init__.py | 1 - .../test/synnefo.ganeti_unittest.py | 12 ++--- 5 files changed, 43 insertions(+), 42 deletions(-) diff --git a/snf-cyclades-gtools/docs/conf.py b/snf-cyclades-gtools/docs/conf.py index dd48d644b..e5db0816f 100644 --- a/snf-cyclades-gtools/docs/conf.py +++ b/snf-cyclades-gtools/docs/conf.py @@ -1,4 +1,5 @@ -import sys, os +import sys +import os sys.path.insert(0, os.path.abspath('../')) from synnefo.versions.ganeti import __version__ @@ -16,34 +17,34 @@ pygments_style = 'sphinx' html_theme = 'default' html_theme_options = { - 'collapsiblesidebar': 'true', - 'footerbgcolor': '#55b577', - 'footertextcolor': '#000000', - 'sidebarbgcolor': '#ffffff', - 'sidebarbtncolor': '#f2f2f2', - 'sidebartextcolor': '#000000', - 'sidebarlinkcolor': '#328e4a', - 'relbarbgcolor': '#55b577', - 'relbartextcolor': '#ffffff', - 'relbarlinkcolor': '#ffffff', - 'bgcolor': '#ffffff', - 'textcolor': '#000000', - 'headbgcolor': '#ffffff', - 'headtextcolor': '#000000', - 'headlinkcolor': '#c60f0f', - 'linkcolor': '#328e4a', - 'visitedlinkcolor': '#63409b', - 'codebgcolor': '#eeffcc', - 'codetextcolor': '#333333' + 'collapsiblesidebar': 'true', + 'footerbgcolor': '#55b577', + 'footertextcolor': '#000000', + 'sidebarbgcolor': '#ffffff', + 'sidebarbtncolor': '#f2f2f2', + 'sidebartextcolor': '#000000', + 'sidebarlinkcolor': '#328e4a', + 'relbarbgcolor': '#55b577', + 'relbartextcolor': '#ffffff', + 'relbarlinkcolor': '#ffffff', + 'bgcolor': '#ffffff', + 'textcolor': '#000000', + 'headbgcolor': '#ffffff', + 'headtextcolor': '#000000', + 'headlinkcolor': '#c60f0f', + 'linkcolor': '#328e4a', + 'visitedlinkcolor': '#63409b', + 'codebgcolor': '#eeffcc', + 'codetextcolor': '#333333' } html_static_path = ['_static'] htmlhelp_basename = 'synnefodoc' intersphinx_mapping = { - 'pithon': ('http://docs.python.org/', None), - 'django': ('https://docs.djangoproject.com/en/dev/', - 'https://docs.djangoproject.com/en/dev/_objects/') + 'pithon': ('http://docs.python.org/', None), + 'django': ('https://docs.djangoproject.com/en/dev/', + 'https://docs.djangoproject.com/en/dev/_objects/') } SYNNEFO_DOCS_BASE_URL = 'http://www.synnefo.org/docs' @@ -57,9 +58,9 @@ } for name, ver in SYNNEFO_PROJECTS.iteritems(): - intersphinx_mapping[name.replace("-","")] = (SYNNEFO_DOCS_BASE_URL + - '%s/%s/' % (name, ver), - None) + intersphinx_mapping[name.replace("-", "")] = (SYNNEFO_DOCS_BASE_URL + + '%s/%s/' % (name, ver), + None) extensions = ['sphinx.ext.intersphinx', 'sphinx.ext.todo', diff --git a/snf-cyclades-gtools/synnefo/ganeti/config.py b/snf-cyclades-gtools/synnefo/ganeti/config.py index e3294d2bf..c53b17434 100644 --- a/snf-cyclades-gtools/synnefo/ganeti/config.py +++ b/snf-cyclades-gtools/synnefo/ganeti/config.py @@ -3,7 +3,8 @@ import sys import glob -def load(conf_dir): + +def load(conf_dir): """Takes a configuration file directory and interprets all *.conf files""" files = glob.glob(os.path.join(conf_dir, '*.conf')) @@ -13,10 +14,10 @@ def load(conf_dir): # We are using a version that understands PYTHONDONTWRITEBYTECODE # so it is safe to use imp.load_source here module = imp.load_source(filename, filename) - #CONFIG = getattr(module, 'CONFIG', None) + # CONFIG = getattr(module, 'CONFIG', None) else: module = {} execfile(filename, module) - #CONFIG = module.get('CONFIG') + # CONFIG = module.get('CONFIG') return module diff --git a/snf-cyclades-gtools/synnefo/ganeti/eventd.py b/snf-cyclades-gtools/synnefo/ganeti/eventd.py index 972d37071..5d7629238 100644 --- a/snf-cyclades-gtools/synnefo/ganeti/eventd.py +++ b/snf-cyclades-gtools/synnefo/ganeti/eventd.py @@ -368,10 +368,10 @@ def process_network_op(self, op, job_id): # 'network_link': get_field(input, 'network_link'), 'group_name': get_field(input, 'group_name')} - msg = {'operation': op_id, - 'type': "ganeti-network-status", - 'network': network_name, - 'job_fields': job_fields} + msg = {'operation': op_id, + 'type': "ganeti-network-status", + 'network': network_name, + 'job_fields': job_fields} routekey = "ganeti.%s.event.network" % prefix_from_name(network_name) @@ -391,8 +391,8 @@ def process_cluster_op(self, op, job_id): # Send only modifications of cluster return None, None - msg = {'operation': op_id, - 'type': "ganeti-cluster-status"} + msg = {'operation': op_id, + 'type': "ganeti-cluster-status"} routekey = "ganeti.event.cluster" diff --git a/snf-cyclades-gtools/synnefo/versions/__init__.py b/snf-cyclades-gtools/synnefo/versions/__init__.py index 4ee938c01..5cda84290 100644 --- a/snf-cyclades-gtools/synnefo/versions/__init__.py +++ b/snf-cyclades-gtools/synnefo/versions/__init__.py @@ -20,4 +20,3 @@ except ImportError: import pkgutil __path__ = pkgutil.extend_path(__path__, __name__) - diff --git a/snf-cyclades-gtools/test/synnefo.ganeti_unittest.py b/snf-cyclades-gtools/test/synnefo.ganeti_unittest.py index b47bd7e0b..af3570717 100755 --- a/snf-cyclades-gtools/test/synnefo.ganeti_unittest.py +++ b/snf-cyclades-gtools/test/synnefo.ganeti_unittest.py @@ -62,16 +62,16 @@ def test_two_nics(self, client): "mac": "mac1", "mode": "mode1", "link": "link1"}, - {"network": "network2", - "ip": "ip2", - "mac": "mac2", - "mode": "mode2", - "link": "link2"}] + {"network": "network2", + "ip": "ip2", + "mac": "mac2", + "mode": "mode2", + "link": "link2"}] self.assertEqual(nics0, nics1) def test_firewall(self, client): ret = [[["network"], ["ip"], ["mac"], ["mode"], ["link"], - ["tag1", "synnefo:network:0:protected"]]] + ["tag1", "synnefo:network:0:protected"]]] client.return_value.QueryInstances.return_value = ret nics0 = get_instance_nics("test", log) nics1 = [{"network": "network", From b3ae78b0af3455ff1b04515398006d7f1870c69c Mon Sep 17 00:00:00 2001 From: indorilftw Date: Wed, 12 Nov 2014 11:59:01 +0200 Subject: [PATCH 29/43] PEP8 fixes on snf-deploy directory --- snf-deploy/distribute_setup.py | 34 ++++++++++++------- .../gunicorn-hooks/gunicorn-archipelago.py | 3 +- .../files/root/firefox_cert_override.py | 5 ++- snf-deploy/snfdeploy/components.py | 11 +++--- 4 files changed, 31 insertions(+), 22 deletions(-) diff --git a/snf-deploy/distribute_setup.py b/snf-deploy/distribute_setup.py index 10d66840a..c933b1d0b 100644 --- a/snf-deploy/distribute_setup.py +++ b/snf-deploy/distribute_setup.py @@ -144,17 +144,17 @@ def use_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL, except ImportError: return _do_download(version, download_base, to_dir, download_delay) try: - pkg_resources.require("distribute>="+version) + pkg_resources.require("distribute>=" + version) return except pkg_resources.VersionConflict: e = sys.exc_info()[1] if was_imported: sys.stderr.write( - "The required version of distribute (>=%s) is not available,\n" - "and can't be installed while this script is running. Please\n" - "install a more recent version first, using\n" - "'easy_install -U distribute'." - "\n\n(Currently using %r)\n" % (version, e.args[0])) + "The required version of distribute (>=%s) is not available,\n" + "and can't be installed while this script is running. Please\n" + "install a more recent version first, using\n" + "'easy_install -U distribute'." + "\n\n(Currently using %r)\n" % (version, e.args[0])) sys.exit(2) else: del pkg_resources, sys.modules['pkg_resources'] # reload ok @@ -167,6 +167,7 @@ def use_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL, if not no_fake: _create_fake_setuptools_pkg_info(to_dir) + def download_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL, to_dir=os.curdir, delay=15): """Download distribute from a specified location and return its filename @@ -203,6 +204,7 @@ def download_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL, dst.close() return os.path.realpath(saveto) + def _no_sandbox(function): def __no_sandbox(*args, **kw): try: @@ -227,6 +229,7 @@ def violation(*args): return __no_sandbox + def _patch_file(path, content): """Will backup the file then patch it""" existing_content = open(path).read() @@ -245,15 +248,18 @@ def _patch_file(path, content): _patch_file = _no_sandbox(_patch_file) + def _same_content(path, content): return open(path).read() == content + def _rename_path(path): new_name = path + '.OLD.%s' % time.time() log.warn('Renaming %s into %s', path, new_name) os.rename(path, new_name) return new_name + def _remove_flat_installation(placeholder): if not os.path.isdir(placeholder): log.warn('Unkown installation at %s', placeholder) @@ -289,18 +295,19 @@ def _remove_flat_installation(placeholder): _remove_flat_installation = _no_sandbox(_remove_flat_installation) + def _after_install(dist): log.warn('After install bootstrap.') placeholder = dist.get_command_obj('install').install_purelib _create_fake_setuptools_pkg_info(placeholder) + def _create_fake_setuptools_pkg_info(placeholder): if not placeholder or not os.path.exists(placeholder): log.warn('Could not find the install location') return pyver = '%s.%s' % (sys.version_info[0], sys.version_info[1]) - setuptools_file = 'setuptools-%s-py%s.egg-info' % \ - (SETUPTOOLS_FAKED_VERSION, pyver) + setuptools_file = 'setuptools-%s-py%s.egg-info' % (SETUPTOOLS_FAKED_VERSION, pyver) pkg_info = os.path.join(placeholder, setuptools_file) if os.path.exists(pkg_info): log.warn('%s already exists', pkg_info) @@ -323,6 +330,7 @@ def _create_fake_setuptools_pkg_info(placeholder): _create_fake_setuptools_pkg_info = _no_sandbox(_create_fake_setuptools_pkg_info) + def _patch_egg_dir(path): # let's check if it's already patched pkg_info = os.path.join(path, 'EGG-INFO', 'PKG-INFO') @@ -343,6 +351,7 @@ def _patch_egg_dir(path): _patch_egg_dir = _no_sandbox(_patch_egg_dir) + def _before_install(): log.warn('Before install bootstrap.') _fake_setuptools() @@ -351,7 +360,7 @@ def _before_install(): def _under_prefix(location): if 'install' not in sys.argv: return True - args = sys.argv[sys.argv.index('install')+1:] + args = sys.argv[sys.argv.index('install') + 1:] for index, arg in enumerate(args): for option in ('--root', '--prefix'): if arg.startswith('%s=' % option): @@ -359,7 +368,7 @@ def _under_prefix(location): return location.startswith(top_dir) elif arg == option: if len(args) > index: - top_dir = args[index+1] + top_dir = args[index + 1] return location.startswith(top_dir) if arg == '--user' and USER_SITE is not None: return location.startswith(USER_SITE) @@ -405,8 +414,7 @@ def _fake_setuptools(): else: log.warn('Egg installation') pkg_info = os.path.join(setuptools_location, 'EGG-INFO', 'PKG-INFO') - if (os.path.exists(pkg_info) and - _same_content(pkg_info, SETUPTOOLS_PKG_INFO)): + if (os.path.exists(pkg_info) and _same_content(pkg_info, SETUPTOOLS_PKG_INFO)): log.warn('Already patched.') return log.warn('Patching...') @@ -448,7 +456,7 @@ def _extractall(self, path=".", members=None): # Extract directories with a safe mode. directories.append(tarinfo) tarinfo = copy.copy(tarinfo) - tarinfo.mode = 448 # decimal for oct 0700 + tarinfo.mode = 448 # decimal for oct 0700 self.extract(tarinfo, path) # Reverse sort directories. diff --git a/snf-deploy/files/etc/synnefo/gunicorn-hooks/gunicorn-archipelago.py b/snf-deploy/files/etc/synnefo/gunicorn-hooks/gunicorn-archipelago.py index 15cf37466..990f67b21 100644 --- a/snf-deploy/files/etc/synnefo/gunicorn-hooks/gunicorn-archipelago.py +++ b/snf-deploy/files/etc/synnefo/gunicorn-hooks/gunicorn-archipelago.py @@ -20,7 +20,8 @@ import pickle import os -SYNNEFO_UMASK=0o007 +SYNNEFO_UMASK = 0o007 + def find_hole(workers, fworkers): old_key = [] diff --git a/snf-deploy/files/root/firefox_cert_override.py b/snf-deploy/files/root/firefox_cert_override.py index 246a822cb..c2ed3e45e 100755 --- a/snf-deploy/files/root/firefox_cert_override.py +++ b/snf-deploy/files/root/firefox_cert_override.py @@ -40,13 +40,12 @@ def cert_override(cert_contents, domain): issuer_name = "".join(issuer_parts[:-2]) issuer_domain = ".".join(issuer_parts[-2:]) - serial_prefix = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\t" + \ - "\x00\x00\x00$\x00" + serial_prefix = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\t" + \ + "\x00\x00\x00$\x00" serial_content = serial_prefix + serial + issuer_name serial_hash = base64.b64encode(serial_content) issuer_hash = base64.b64encode(issuer_domain) - return tpl % { 'domain': domain, 'oid': oid, diff --git a/snf-deploy/snfdeploy/components.py b/snf-deploy/snfdeploy/components.py index 119b891f9..f9e4b9779 100644 --- a/snf-deploy/snfdeploy/components.py +++ b/snf-deploy/snfdeploy/components.py @@ -1275,8 +1275,8 @@ def prepare(self): "mkdir -p %s" % config.ganeti_dir, "mkdir -p %s" % config.archip_dir, "cd %s && mkdir {maps,blocks,locks}" % config.archip_dir, - "cd %s && chown archipelago:synnefo {maps,blocks,locks}" % \ - config.archip_dir, + "cd %s && chown archipelago:synnefo {maps,blocks,locks}" % + config.archip_dir, "cd %s && chmod 770 {maps,blocks,locks}" % config.archip_dir, "cd %s && chmod g+s {maps,blocks,locks}" % config.archip_dir, ] @@ -1334,7 +1334,7 @@ def export_service(self): @base.run_cmds def prepare(self): return [ - #FIXME: Workaround until snf-pithos-webclient creates conf + # FIXME: Workaround until snf-pithos-webclient creates conf # files properly with root:synnefo "chown root:synnefo /etc/synnefo/*snf-pithos-webclient*conf", ] @@ -1668,6 +1668,7 @@ def make_user_admin_user(self): "snf-manage user-modify %s --add-group=admin" % user_id ] + class Kamaki(base.Component): REQUIRED_PACKAGES = [ "python-progress", @@ -1682,7 +1683,7 @@ def admin_pre(self): self.ADMIN.make_user_admin_user() self.CA.get("/root/ca/cacert.pem", "/tmp/cacert.pem") self.put("/tmp/cacert.pem", - "/usr/local/share/ca-certificates/Synnefo_Root_CA.crt") + "/usr/local/share/ca-certificates/Synnefo_Root_CA.crt") @base.run_cmds def prepare(self): @@ -1848,7 +1849,7 @@ def _configure(self): @base.run_cmds def restart(self): return [ - #FIXME: See https://github.com/grnet/archipelago/pull/44 + # FIXME: See https://github.com/grnet/archipelago/pull/44 "mkdir -p /dev/shm/posixfd", "chown -R synnefo:synnefo /dev/shm/posixfd", "archipelago restart", From 1ffbe14fb3c82d895970470521d7dd18c80a80d8 Mon Sep 17 00:00:00 2001 From: indorilftw Date: Wed, 12 Nov 2014 11:59:28 +0200 Subject: [PATCH 30/43] PEP8 fixes on snf-django-lib directory --- snf-django-lib/distribute_setup.py | 34 ++++++++++++++--------- snf-django-lib/setup.py | 24 ++++++++-------- snf-django-lib/snf_django/lib/api/urls.py | 2 +- 3 files changed, 33 insertions(+), 27 deletions(-) diff --git a/snf-django-lib/distribute_setup.py b/snf-django-lib/distribute_setup.py index 10d66840a..c933b1d0b 100644 --- a/snf-django-lib/distribute_setup.py +++ b/snf-django-lib/distribute_setup.py @@ -144,17 +144,17 @@ def use_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL, except ImportError: return _do_download(version, download_base, to_dir, download_delay) try: - pkg_resources.require("distribute>="+version) + pkg_resources.require("distribute>=" + version) return except pkg_resources.VersionConflict: e = sys.exc_info()[1] if was_imported: sys.stderr.write( - "The required version of distribute (>=%s) is not available,\n" - "and can't be installed while this script is running. Please\n" - "install a more recent version first, using\n" - "'easy_install -U distribute'." - "\n\n(Currently using %r)\n" % (version, e.args[0])) + "The required version of distribute (>=%s) is not available,\n" + "and can't be installed while this script is running. Please\n" + "install a more recent version first, using\n" + "'easy_install -U distribute'." + "\n\n(Currently using %r)\n" % (version, e.args[0])) sys.exit(2) else: del pkg_resources, sys.modules['pkg_resources'] # reload ok @@ -167,6 +167,7 @@ def use_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL, if not no_fake: _create_fake_setuptools_pkg_info(to_dir) + def download_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL, to_dir=os.curdir, delay=15): """Download distribute from a specified location and return its filename @@ -203,6 +204,7 @@ def download_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL, dst.close() return os.path.realpath(saveto) + def _no_sandbox(function): def __no_sandbox(*args, **kw): try: @@ -227,6 +229,7 @@ def violation(*args): return __no_sandbox + def _patch_file(path, content): """Will backup the file then patch it""" existing_content = open(path).read() @@ -245,15 +248,18 @@ def _patch_file(path, content): _patch_file = _no_sandbox(_patch_file) + def _same_content(path, content): return open(path).read() == content + def _rename_path(path): new_name = path + '.OLD.%s' % time.time() log.warn('Renaming %s into %s', path, new_name) os.rename(path, new_name) return new_name + def _remove_flat_installation(placeholder): if not os.path.isdir(placeholder): log.warn('Unkown installation at %s', placeholder) @@ -289,18 +295,19 @@ def _remove_flat_installation(placeholder): _remove_flat_installation = _no_sandbox(_remove_flat_installation) + def _after_install(dist): log.warn('After install bootstrap.') placeholder = dist.get_command_obj('install').install_purelib _create_fake_setuptools_pkg_info(placeholder) + def _create_fake_setuptools_pkg_info(placeholder): if not placeholder or not os.path.exists(placeholder): log.warn('Could not find the install location') return pyver = '%s.%s' % (sys.version_info[0], sys.version_info[1]) - setuptools_file = 'setuptools-%s-py%s.egg-info' % \ - (SETUPTOOLS_FAKED_VERSION, pyver) + setuptools_file = 'setuptools-%s-py%s.egg-info' % (SETUPTOOLS_FAKED_VERSION, pyver) pkg_info = os.path.join(placeholder, setuptools_file) if os.path.exists(pkg_info): log.warn('%s already exists', pkg_info) @@ -323,6 +330,7 @@ def _create_fake_setuptools_pkg_info(placeholder): _create_fake_setuptools_pkg_info = _no_sandbox(_create_fake_setuptools_pkg_info) + def _patch_egg_dir(path): # let's check if it's already patched pkg_info = os.path.join(path, 'EGG-INFO', 'PKG-INFO') @@ -343,6 +351,7 @@ def _patch_egg_dir(path): _patch_egg_dir = _no_sandbox(_patch_egg_dir) + def _before_install(): log.warn('Before install bootstrap.') _fake_setuptools() @@ -351,7 +360,7 @@ def _before_install(): def _under_prefix(location): if 'install' not in sys.argv: return True - args = sys.argv[sys.argv.index('install')+1:] + args = sys.argv[sys.argv.index('install') + 1:] for index, arg in enumerate(args): for option in ('--root', '--prefix'): if arg.startswith('%s=' % option): @@ -359,7 +368,7 @@ def _under_prefix(location): return location.startswith(top_dir) elif arg == option: if len(args) > index: - top_dir = args[index+1] + top_dir = args[index + 1] return location.startswith(top_dir) if arg == '--user' and USER_SITE is not None: return location.startswith(USER_SITE) @@ -405,8 +414,7 @@ def _fake_setuptools(): else: log.warn('Egg installation') pkg_info = os.path.join(setuptools_location, 'EGG-INFO', 'PKG-INFO') - if (os.path.exists(pkg_info) and - _same_content(pkg_info, SETUPTOOLS_PKG_INFO)): + if (os.path.exists(pkg_info) and _same_content(pkg_info, SETUPTOOLS_PKG_INFO)): log.warn('Already patched.') return log.warn('Patching...') @@ -448,7 +456,7 @@ def _extractall(self, path=".", members=None): # Extract directories with a safe mode. directories.append(tarinfo) tarinfo = copy.copy(tarinfo) - tarinfo.mode = 448 # decimal for oct 0700 + tarinfo.mode = 448 # decimal for oct 0700 self.extract(tarinfo, path) # Reverse sort directories. diff --git a/snf-django-lib/setup.py b/snf-django-lib/setup.py index 7adee7e65..b6de3312e 100644 --- a/snf-django-lib/setup.py +++ b/snf-django-lib/setup.py @@ -56,18 +56,19 @@ ".*", "CVS", "_darcs", "./build", "./dist", "EGG-INFO", "*.egg-info", "snf-0.7" ] + # (c) 2005 Ian Bicking and contributors; written for Paste (http://pythonpaste.org) # Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php # Note: you may want to copy this into your setup.py file verbatim, as # you can't import this from another package, when you don't know if # that package is installed yet. def find_package_data( - where=".", - package="", - exclude=standard_exclude, - exclude_directories=standard_exclude_directories, - only_in_packages=True, - show_ignored=False): + where=".", + package="", + exclude=standard_exclude, + exclude_directories=standard_exclude_directories, + only_in_packages=True, + show_ignored=False): """ Return a dictionary suitable for use in ``package_data`` in a distutils ``setup.py`` file. @@ -103,8 +104,7 @@ def find_package_data( if os.path.isdir(fn): bad_name = False for pattern in exclude_directories: - if (fnmatchcase(name, pattern) - or fn.lower() == pattern.lower()): + if (fnmatchcase(name, pattern) or fn.lower() == pattern.lower()): bad_name = True if show_ignored: print >> sys.stderr, ( @@ -113,8 +113,7 @@ def find_package_data( break if bad_name: continue - if (os.path.isfile(os.path.join(fn, "__init__.py")) - and not prefix): + if (os.path.isfile(os.path.join(fn, "__init__.py")) and not prefix): if not package: new_package = name else: @@ -126,8 +125,7 @@ def find_package_data( # is a file bad_name = False for pattern in exclude: - if (fnmatchcase(name, pattern) - or fn.lower() == pattern.lower()): + if (fnmatchcase(name, pattern) or fn.lower() == pattern.lower()): bad_name = True if show_ignored: print >> sys.stderr, ( @@ -136,7 +134,7 @@ def find_package_data( break if bad_name: continue - out.setdefault(package, []).append(prefix+name) + out.setdefault(package, []).append(prefix + name) return out setup( diff --git a/snf-django-lib/snf_django/lib/api/urls.py b/snf-django-lib/snf_django/lib/api/urls.py index 0505d0e7c..d0e1cf602 100644 --- a/snf-django-lib/snf_django/lib/api/urls.py +++ b/snf-django-lib/snf_django/lib/api/urls.py @@ -41,7 +41,7 @@ def _patch_resolver(r): for entry in entries: if isinstance(entry, urlresolvers.RegexURLResolver): _patch_resolver(entry) - #if isinstance(entry, urlresolvers.RegexURLPattern): + # if isinstance(entry, urlresolvers.RegexURLPattern): # let it break... else: _patch_pattern(entry) From 59e75f8ae968fec12e996b4682248836d77564cf Mon Sep 17 00:00:00 2001 From: indorilftw Date: Wed, 12 Nov 2014 12:00:06 +0200 Subject: [PATCH 31/43] PEP8 fixes on snf-pithos-app directory --- snf-pithos-app/pithos/api/settings.py | 2 +- snf-pithos-app/pithos/api/test/__init__.py | 6 +++--- snf-pithos-app/pithos/api/test/accounts.py | 4 ++-- snf-pithos-app/pithos/api/test/containers.py | 2 +- snf-pithos-app/pithos/api/test/objects.py | 2 +- snf-pithos-app/pithos/api/test/permissions.py | 2 +- snf-pithos-app/pithos/api/test/public.py | 16 ++++++++-------- snf-pithos-app/pithos/api/test/top_level.py | 4 ++-- snf-pithos-app/pithos/api/test/unicode.py | 6 +++--- .../pithos/api/test/util/__init__.py | 14 +++++++------- snf-pithos-app/pithos/api/test/views.py | 18 +++++++++--------- 11 files changed, 38 insertions(+), 38 deletions(-) diff --git a/snf-pithos-app/pithos/api/settings.py b/snf-pithos-app/pithos/api/settings.py index e8b8efea4..c3257fd91 100644 --- a/snf-pithos-app/pithos/api/settings.py +++ b/snf-pithos-app/pithos/api/settings.py @@ -13,7 +13,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -#coding=utf8 +# coding=utf8 import logging from django.conf import settings diff --git a/snf-pithos-app/pithos/api/test/__init__.py b/snf-pithos-app/pithos/api/test/__init__.py index 87e29dddf..a8266595b 100644 --- a/snf-pithos-app/pithos/api/test/__init__.py +++ b/snf-pithos-app/pithos/api/test/__init__.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -#coding=utf8 +# coding=utf8 # Copyright (C) 2010-2014 GRNET S.A. # # This program is free software: you can redistribute it and/or modify @@ -242,11 +242,11 @@ def setUp(self): "pending": 0}}}} def tearDown(self): - #delete additionally created metadata + # delete additionally created metadata meta = self.get_account_meta() self.delete_account_meta(meta) - #delete additionally created groups + # delete additionally created groups groups = self.get_account_groups() self.delete_account_groups(groups) diff --git a/snf-pithos-app/pithos/api/test/accounts.py b/snf-pithos-app/pithos/api/test/accounts.py index d02139ddc..4272e7c9c 100644 --- a/snf-pithos-app/pithos/api/test/accounts.py +++ b/snf-pithos-app/pithos/api/test/accounts.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -#coding=utf8 +# coding=utf8 # Copyright (C) 2010-2014 GRNET S.A. # @@ -139,7 +139,7 @@ def setUp(self): uploaded_bytes += len(data) def test_list(self): - #list containers: row format + # list containers: row format containers = self.list_containers(format=None) self.assertEquals(containers, ['apples', 'bananas', 'kiwis', 'oranges', 'pears']) diff --git a/snf-pithos-app/pithos/api/test/containers.py b/snf-pithos-app/pithos/api/test/containers.py index a352dc614..9d2828527 100644 --- a/snf-pithos-app/pithos/api/test/containers.py +++ b/snf-pithos-app/pithos/api/test/containers.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -#coding=utf8 +# coding=utf8 # Copyright (C) 2010-2014 GRNET S.A. # diff --git a/snf-pithos-app/pithos/api/test/objects.py b/snf-pithos-app/pithos/api/test/objects.py index 5061155b7..310025f49 100644 --- a/snf-pithos-app/pithos/api/test/objects.py +++ b/snf-pithos-app/pithos/api/test/objects.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -#coding=utf8 +# coding=utf8 # Copyright (C) 2010-2014 GRNET S.A. # diff --git a/snf-pithos-app/pithos/api/test/permissions.py b/snf-pithos-app/pithos/api/test/permissions.py index bfe017728..9e3dca797 100644 --- a/snf-pithos-app/pithos/api/test/permissions.py +++ b/snf-pithos-app/pithos/api/test/permissions.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -#coding=utf8 +# coding=utf8 # Copyright (C) 2010-2014 GRNET S.A. # diff --git a/snf-pithos-app/pithos/api/test/public.py b/snf-pithos-app/pithos/api/test/public.py index 8c377e835..a3ffbe094 100644 --- a/snf-pithos-app/pithos/api/test/public.py +++ b/snf-pithos-app/pithos/api/test/public.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -#coding=utf8 +# coding=utf8 # Copyright (C) 2010-2014 GRNET S.A. # # This program is free software: you can redistribute it and/or modify @@ -57,23 +57,23 @@ def _assert_public_object(self, cname, oname, odata): r = self.delete(public) self.assertEqual(r.status_code, 405) - self.assertEqual(sorted(r['Allow'].split(',')), ['GET', 'HEAD']) + self.assertEqual(sorted(r['Allow'].split(',')), ['GET', 'HEAD']) r = self.post(public) self.assertEqual(r.status_code, 405) - self.assertEqual(sorted(r['Allow'].split(',')), ['GET', 'HEAD']) + self.assertEqual(sorted(r['Allow'].split(',')), ['GET', 'HEAD']) r = self.put(public) self.assertEqual(r.status_code, 405) - self.assertEqual(sorted(r['Allow'].split(',')), ['GET', 'HEAD']) + self.assertEqual(sorted(r['Allow'].split(',')), ['GET', 'HEAD']) r = self.copy(public) self.assertEqual(r.status_code, 405) - self.assertEqual(sorted(r['Allow'].split(',')), ['GET', 'HEAD']) + self.assertEqual(sorted(r['Allow'].split(',')), ['GET', 'HEAD']) r = self.move(public) self.assertEqual(r.status_code, 405) - self.assertEqual(sorted(r['Allow'].split(',')), ['GET', 'HEAD']) + self.assertEqual(sorted(r['Allow'].split(',')), ['GET', 'HEAD']) r = self.get(public, user='user2', token=None) self.assertEqual(r.status_code, 200) @@ -351,8 +351,8 @@ def test_public_manifest(self): r = self.get(public) self.assertTrue(r.content, data) - #self.assertTrue('X-Object-Manifest' in r) - #self.assertEqual(r['X-Object-Manifest'], manifest) + # self.assertTrue('X-Object-Manifest' in r) + # self.assertEqual(r['X-Object-Manifest'], manifest) def test_public_get_partial(self): cname = self.create_container()[0] diff --git a/snf-pithos-app/pithos/api/test/top_level.py b/snf-pithos-app/pithos/api/test/top_level.py index 6f8075266..d091b92d4 100644 --- a/snf-pithos-app/pithos/api/test/top_level.py +++ b/snf-pithos-app/pithos/api/test/top_level.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -#coding=utf8 +# coding=utf8 # Copyright (C) 2010-2014 GRNET S.A. # @@ -20,6 +20,7 @@ from synnefo.lib import join_urls + class TopLevel(PithosAPITest): def test_not_allowed_method(self): url = join_urls(self.pithos_path, '/') @@ -40,7 +41,6 @@ def test_not_allowed_method(self): self.assertTrue('Allow' in r) self.assertEqual(r['Allow'], 'GET') - def test_authenticate(self): url = join_urls(self.pithos_path, '/') r = self.get(url, token=None) diff --git a/snf-pithos-app/pithos/api/test/unicode.py b/snf-pithos-app/pithos/api/test/unicode.py index 57bab39b9..442683e18 100644 --- a/snf-pithos-app/pithos/api/test/unicode.py +++ b/snf-pithos-app/pithos/api/test/unicode.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -#coding=utf8 +# coding=utf8 # Copyright (C) 2010-2014 GRNET S.A. # @@ -27,7 +27,7 @@ class TestUnicode(PithosAPITest): - #def setUp(self): + # def setUp(self): # super(TestUnicode, self).setUp() # self.user = 'χρήστης' @@ -376,7 +376,7 @@ def test_groups(self): # check write access appended_data = get_random_data() - r = self.post(url, user='διογένης', data=appended_data, + r = self.post(url, user='διογένης', data=appended_data, content_type='application/octet-stream', HTTP_CONTENT_LENGTH=str(len(appended_data)), HTTP_CONTENT_RANGE='bytes */*') diff --git a/snf-pithos-app/pithos/api/test/util/__init__.py b/snf-pithos-app/pithos/api/test/util/__init__.py index 6bd8c8714..05ab32bb6 100644 --- a/snf-pithos-app/pithos/api/test/util/__init__.py +++ b/snf-pithos-app/pithos/api/test/util/__init__.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -#coding=utf8 +# coding=utf8 # Copyright (C) 2010-2014 GRNET S.A. # @@ -53,12 +53,12 @@ def strnextling(prefix): strnextling('hello') -> 'hellp' """ if not prefix: - ## all strings start with the null string, - ## therefore we have to approximate strnextling('') - ## with the last unicode character supported by python - ## 0x10ffff for wide (32-bit unicode) python builds - ## 0x00ffff for narrow (16-bit unicode) python builds - ## We will not autodetect. 0xffff is safe enough. + # all strings start with the null string, + # therefore we have to approximate strnextling('') + # with the last unicode character supported by python + # 0x10ffff for wide (32-bit unicode) python builds + # 0x00ffff for narrow (16-bit unicode) python builds + # We will not autodetect. 0xffff is safe enough. return unichr(0xffff) s = prefix[:-1] c = ord(prefix[-1]) diff --git a/snf-pithos-app/pithos/api/test/views.py b/snf-pithos-app/pithos/api/test/views.py index 0a60ea6c2..ef476d401 100644 --- a/snf-pithos-app/pithos/api/test/views.py +++ b/snf-pithos-app/pithos/api/test/views.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -#coding=utf8 +# coding=utf8 # Copyright (C) 2010-2014 GRNET S.A. # @@ -24,7 +24,7 @@ from synnefo.lib.services import get_service_path from synnefo.lib import join_urls -#from mock import patch +# from mock import patch from urllib import quote, unquote import django.utils.simplejson as json @@ -57,27 +57,27 @@ def test_not_allowed(self): r = self.delete(self.view_url) self.assertEqual(r.status_code, 405) self.assertTrue('Allow' in r) - self.assertEqual(sorted(r['Allow'].split(', ')), ['GET', 'HEAD']) + self.assertEqual(sorted(r['Allow'].split(', ')), ['GET', 'HEAD']) r = self.post(self.view_url) self.assertEqual(r.status_code, 405) self.assertTrue('Allow' in r) - self.assertEqual(sorted(r['Allow'].split(', ')), ['GET', 'HEAD']) + self.assertEqual(sorted(r['Allow'].split(', ')), ['GET', 'HEAD']) r = self.put(self.view_url) self.assertEqual(r.status_code, 405) self.assertTrue('Allow' in r) - self.assertEqual(sorted(r['Allow'].split(', ')), ['GET', 'HEAD']) + self.assertEqual(sorted(r['Allow'].split(', ')), ['GET', 'HEAD']) r = self.copy(self.view_url) self.assertEqual(r.status_code, 405) self.assertTrue('Allow' in r) - self.assertEqual(sorted(r['Allow'].split(', ')), ['GET', 'HEAD']) + self.assertEqual(sorted(r['Allow'].split(', ')), ['GET', 'HEAD']) r = self.move(self.view_url) self.assertEqual(r.status_code, 405) self.assertTrue('Allow' in r) - self.assertEqual(sorted(r['Allow'].split(', ')), ['GET', 'HEAD']) + self.assertEqual(sorted(r['Allow'].split(', ')), ['GET', 'HEAD']) class ObjectGetView(PithosAPITest): @@ -325,8 +325,8 @@ def test_get_partial(self): def test_get_range_not_satisfiable(self): # TODO - #r = self.view(self.view_url, HTTP_RANGE='bytes=50-10') - #self.assertEqual(r.status_code, 416) + # r = self.view(self.view_url, HTTP_RANGE='bytes=50-10') + # self.assertEqual(r.status_code, 416) offset = len(self.odata) + 1 r = self.view(self.view_url, HTTP_RANGE='bytes=0-%s' % offset) From 6f0858567a3f5172911a58323f3ef1d05989d401 Mon Sep 17 00:00:00 2001 From: indorilftw Date: Wed, 12 Nov 2014 12:00:38 +0200 Subject: [PATCH 32/43] PEP8 fixes on snf-pithos-backend directory --- .../backends/lib/sqlalchemy/dbwrapper.py | 4 +- .../pithos/backends/lib/sqlalchemy/node.py | 42 +++++++++---------- .../backends/lib/sqlalchemy/xfeatures.py | 2 +- .../pithos/backends/lib/sqlite/node.py | 14 +++---- 4 files changed, 31 insertions(+), 31 deletions(-) diff --git a/snf-pithos-backend/pithos/backends/lib/sqlalchemy/dbwrapper.py b/snf-pithos-backend/pithos/backends/lib/sqlalchemy/dbwrapper.py index 1cd0e3b0d..c1856ed15 100644 --- a/snf-pithos-backend/pithos/backends/lib/sqlalchemy/dbwrapper.py +++ b/snf-pithos-backend/pithos/backends/lib/sqlalchemy/dbwrapper.py @@ -31,11 +31,11 @@ def connect(self, dbapi_con, con_record): db, connect_args={'check_same_thread': False}, poolclass=NullPool, listeners=[ForeignKeysListener()], isolation_level='SERIALIZABLE') - #elif db.startswith('mysql://'): + # elif db.startswith('mysql://'): # db = '%s?charset=utf8&use_unicode=0' %db # self.engine = create_engine(db, convert_unicode=True) else: - #self.engine = create_engine(db, pool_size=0, max_overflow=-1) + # self.engine = create_engine(db, pool_size=0, max_overflow=-1) self.engine = create_engine( db, poolclass=NullPool, isolation_level='READ COMMITTED') self.engine.echo = False diff --git a/snf-pithos-backend/pithos/backends/lib/sqlalchemy/node.py b/snf-pithos-backend/pithos/backends/lib/sqlalchemy/node.py index 95b38189b..9b8dd2f56 100644 --- a/snf-pithos-backend/pithos/backends/lib/sqlalchemy/node.py +++ b/snf-pithos-backend/pithos/backends/lib/sqlalchemy/node.py @@ -45,12 +45,12 @@ def strnextling(prefix): strnextling('hello') -> 'hellp' """ if not prefix: - ## all strings start with the null string, - ## therefore we have to approximate strnextling('') - ## with the last unicode character supported by python - ## 0x10ffff for wide (32-bit unicode) python builds - ## 0x00ffff for narrow (16-bit unicode) python builds - ## We will not autodetect. 0xffff is safe enough. + # all strings start with the null string, + # therefore we have to approximate strnextling('') + # with the last unicode character supported by python + # 0x10ffff for wide (32-bit unicode) python builds + # 0x00ffff for narrow (16-bit unicode) python builds + # We will not autodetect. 0xffff is safe enough. return unichr(0xffff) s = prefix[:-1] c = ord(prefix[-1]) @@ -66,7 +66,7 @@ def strprevling(prefix): strprevling(u'hello') -> u'helln\\xffff' """ if not prefix: - ## There is no prevling for the null string + # There is no prevling for the null string return prefix s = prefix[:-1] c = ord(prefix[-1]) @@ -78,7 +78,7 @@ def strprevling(prefix): def create_tables(engine): metadata = MetaData() - #create nodes table + # create nodes table columns = [] columns.append(Column('node', Integer, primary_key=True)) columns.append(Column('parent', Integer, @@ -97,7 +97,7 @@ def create_tables(engine): Index('idx_nodes_parent0_path', nodes.c.parent, nodes.c.path, postgresql_where=nodes.c.parent == 0) - #create policy table + # create policy table columns = [] columns.append(Column('node', Integer, ForeignKey('nodes.node', @@ -108,7 +108,7 @@ def create_tables(engine): columns.append(Column('value', String(256))) Table('policy', metadata, *columns, mysql_engine='InnoDB') - #create statistics table + # create statistics table columns = [] columns.append(Column('node', Integer, ForeignKey('nodes.node', @@ -122,7 +122,7 @@ def create_tables(engine): primary_key=True, autoincrement=False)) Table('statistics', metadata, *columns, mysql_engine='InnoDB') - #create versions table + # create versions table columns = [] columns.append(Column('serial', Integer, primary_key=True)) columns.append(Column('node', Integer, @@ -164,7 +164,7 @@ def create_tables(engine): Index('idx_versions_serial_cluster2', versions.c.serial, versions.c.cluster, postgresql_where=versions.c.cluster == 2) - #create attributes table + # create attributes table columns = [] columns.append(Column('serial', Integer, ForeignKey('versions.serial', @@ -374,7 +374,7 @@ def node_purge_children(self, parent, before=inf, cluster=0, the hashes, the total size and the serials of versions deleted. Clears out nodes with no remaining versions. """ - #update statistics + # update statistics c1 = select([self.nodes.c.node], self.nodes.c.parent == parent) where_clause = and_(self.versions.c.node.in_(c1), @@ -406,12 +406,12 @@ def node_purge_children(self, parent, before=inf, cluster=0, serials += [row[1]] r.close() - #delete versions + # delete versions s = self.versions.delete().where(where_clause) r = self.conn.execute(s) r.close() - #delete nodes + # delete nodes s = select([self.nodes.c.node], and_(self.nodes.c.parent == parent, select([func.count(self.versions.c.serial)], @@ -434,7 +434,7 @@ def node_purge(self, node, before=inf, cluster=0, Clears out the node if it has no remaining versions. """ - #update statistics + # update statistics s = select([func.count(self.versions.c.serial), func.sum(self.versions.c.size)]) where_clause = and_(self.versions.c.node == node, @@ -463,12 +463,12 @@ def node_purge(self, node, before=inf, cluster=0, serials += [row[1]] r.close() - #delete versions + # delete versions s = self.versions.delete().where(where_clause) r = self.conn.execute(s) r.close() - #delete nodes + # delete nodes s = select([self.nodes.c.node], and_(self.nodes.c.node == node, select([func.count(self.versions.c.serial)], @@ -608,7 +608,7 @@ def policy_get(self, node): return d def policy_set(self, node, policy): - #insert or replace + # insert or replace for k, v in policy.iteritems(): s = self.policy.update().where(and_(self.policy.c.node == node, self.policy.c.key == k)) @@ -656,8 +656,8 @@ def statistics_update(self, node, population, size, mtime, cluster=0): population = max(population, 0) size += presize - #insert or replace - #TODO better upsert + # insert or replace + # TODO better upsert u = self.statistics.update().where(and_( self.statistics.c.node == node, self.statistics.c.cluster == cluster)) diff --git a/snf-pithos-backend/pithos/backends/lib/sqlalchemy/xfeatures.py b/snf-pithos-backend/pithos/backends/lib/sqlalchemy/xfeatures.py index 2f1b80435..bcb166221 100644 --- a/snf-pithos-backend/pithos/backends/lib/sqlalchemy/xfeatures.py +++ b/snf-pithos-backend/pithos/backends/lib/sqlalchemy/xfeatures.py @@ -159,7 +159,7 @@ def feature_set(self, feature, key, value): def feature_setmany(self, feature, key, values): """Associate the given key, and values with a feature.""" - #TODO: more efficient way to do it + # TODO: more efficient way to do it for v in values: self.feature_set(feature, key, v) diff --git a/snf-pithos-backend/pithos/backends/lib/sqlite/node.py b/snf-pithos-backend/pithos/backends/lib/sqlite/node.py index a66a076ca..c98f10051 100644 --- a/snf-pithos-backend/pithos/backends/lib/sqlite/node.py +++ b/snf-pithos-backend/pithos/backends/lib/sqlite/node.py @@ -36,12 +36,12 @@ def strnextling(prefix): strnextling('hello') -> 'hellp' """ if not prefix: - ## all strings start with the null string, - ## therefore we have to approximate strnextling('') - ## with the last unicode character supported by python - ## 0x10ffff for wide (32-bit unicode) python builds - ## 0x00ffff for narrow (16-bit unicode) python builds - ## We will not autodetect. 0xffff is safe enough. + # all strings start with the null string, + # therefore we have to approximate strnextling('') + # with the last unicode character supported by python + # 0x10ffff for wide (32-bit unicode) python builds + # 0x00ffff for narrow (16-bit unicode) python builds + # We will not autodetect. 0xffff is safe enough. return unichr(0xffff) s = prefix[:-1] c = ord(prefix[-1]) @@ -57,7 +57,7 @@ def strprevling(prefix): strprevling(u'hello') -> u'helln\\xffff' """ if not prefix: - ## There is no prevling for the null string + # There is no prevling for the null string return prefix s = prefix[:-1] c = ord(prefix[-1]) From f67b510d4097e894d27ed40d9416ba8cdc24cab0 Mon Sep 17 00:00:00 2001 From: indorilftw Date: Wed, 12 Nov 2014 12:00:59 +0200 Subject: [PATCH 33/43] PEP8 fixes on snf-stats-app directory --- snf-stats-app/distribute_setup.py | 34 +++++++++++++++---------- snf-stats-app/setup.py | 6 ++--- snf-stats-app/synnefo_stats/settings.py | 2 +- 3 files changed, 25 insertions(+), 17 deletions(-) diff --git a/snf-stats-app/distribute_setup.py b/snf-stats-app/distribute_setup.py index 10d66840a..c933b1d0b 100644 --- a/snf-stats-app/distribute_setup.py +++ b/snf-stats-app/distribute_setup.py @@ -144,17 +144,17 @@ def use_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL, except ImportError: return _do_download(version, download_base, to_dir, download_delay) try: - pkg_resources.require("distribute>="+version) + pkg_resources.require("distribute>=" + version) return except pkg_resources.VersionConflict: e = sys.exc_info()[1] if was_imported: sys.stderr.write( - "The required version of distribute (>=%s) is not available,\n" - "and can't be installed while this script is running. Please\n" - "install a more recent version first, using\n" - "'easy_install -U distribute'." - "\n\n(Currently using %r)\n" % (version, e.args[0])) + "The required version of distribute (>=%s) is not available,\n" + "and can't be installed while this script is running. Please\n" + "install a more recent version first, using\n" + "'easy_install -U distribute'." + "\n\n(Currently using %r)\n" % (version, e.args[0])) sys.exit(2) else: del pkg_resources, sys.modules['pkg_resources'] # reload ok @@ -167,6 +167,7 @@ def use_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL, if not no_fake: _create_fake_setuptools_pkg_info(to_dir) + def download_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL, to_dir=os.curdir, delay=15): """Download distribute from a specified location and return its filename @@ -203,6 +204,7 @@ def download_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL, dst.close() return os.path.realpath(saveto) + def _no_sandbox(function): def __no_sandbox(*args, **kw): try: @@ -227,6 +229,7 @@ def violation(*args): return __no_sandbox + def _patch_file(path, content): """Will backup the file then patch it""" existing_content = open(path).read() @@ -245,15 +248,18 @@ def _patch_file(path, content): _patch_file = _no_sandbox(_patch_file) + def _same_content(path, content): return open(path).read() == content + def _rename_path(path): new_name = path + '.OLD.%s' % time.time() log.warn('Renaming %s into %s', path, new_name) os.rename(path, new_name) return new_name + def _remove_flat_installation(placeholder): if not os.path.isdir(placeholder): log.warn('Unkown installation at %s', placeholder) @@ -289,18 +295,19 @@ def _remove_flat_installation(placeholder): _remove_flat_installation = _no_sandbox(_remove_flat_installation) + def _after_install(dist): log.warn('After install bootstrap.') placeholder = dist.get_command_obj('install').install_purelib _create_fake_setuptools_pkg_info(placeholder) + def _create_fake_setuptools_pkg_info(placeholder): if not placeholder or not os.path.exists(placeholder): log.warn('Could not find the install location') return pyver = '%s.%s' % (sys.version_info[0], sys.version_info[1]) - setuptools_file = 'setuptools-%s-py%s.egg-info' % \ - (SETUPTOOLS_FAKED_VERSION, pyver) + setuptools_file = 'setuptools-%s-py%s.egg-info' % (SETUPTOOLS_FAKED_VERSION, pyver) pkg_info = os.path.join(placeholder, setuptools_file) if os.path.exists(pkg_info): log.warn('%s already exists', pkg_info) @@ -323,6 +330,7 @@ def _create_fake_setuptools_pkg_info(placeholder): _create_fake_setuptools_pkg_info = _no_sandbox(_create_fake_setuptools_pkg_info) + def _patch_egg_dir(path): # let's check if it's already patched pkg_info = os.path.join(path, 'EGG-INFO', 'PKG-INFO') @@ -343,6 +351,7 @@ def _patch_egg_dir(path): _patch_egg_dir = _no_sandbox(_patch_egg_dir) + def _before_install(): log.warn('Before install bootstrap.') _fake_setuptools() @@ -351,7 +360,7 @@ def _before_install(): def _under_prefix(location): if 'install' not in sys.argv: return True - args = sys.argv[sys.argv.index('install')+1:] + args = sys.argv[sys.argv.index('install') + 1:] for index, arg in enumerate(args): for option in ('--root', '--prefix'): if arg.startswith('%s=' % option): @@ -359,7 +368,7 @@ def _under_prefix(location): return location.startswith(top_dir) elif arg == option: if len(args) > index: - top_dir = args[index+1] + top_dir = args[index + 1] return location.startswith(top_dir) if arg == '--user' and USER_SITE is not None: return location.startswith(USER_SITE) @@ -405,8 +414,7 @@ def _fake_setuptools(): else: log.warn('Egg installation') pkg_info = os.path.join(setuptools_location, 'EGG-INFO', 'PKG-INFO') - if (os.path.exists(pkg_info) and - _same_content(pkg_info, SETUPTOOLS_PKG_INFO)): + if (os.path.exists(pkg_info) and _same_content(pkg_info, SETUPTOOLS_PKG_INFO)): log.warn('Already patched.') return log.warn('Patching...') @@ -448,7 +456,7 @@ def _extractall(self, path=".", members=None): # Extract directories with a safe mode. directories.append(tarinfo) tarinfo = copy.copy(tarinfo) - tarinfo.mode = 448 # decimal for oct 0700 + tarinfo.mode = 448 # decimal for oct 0700 self.extract(tarinfo, path) # Reverse sort directories. diff --git a/snf-stats-app/setup.py b/snf-stats-app/setup.py index 62b227633..5dc450dc5 100644 --- a/snf-stats-app/setup.py +++ b/snf-stats-app/setup.py @@ -67,9 +67,9 @@ dependency_links=['http://www.synnefo.org/packages/pypi'], entry_points={ 'synnefo': [ - 'default_settings = synnefo_stats.synnefo_settings', - 'web_apps = synnefo_stats.synnefo_settings:installed_apps', - 'urls = synnefo_stats.urls:urlpatterns', + 'default_settings = synnefo_stats.synnefo_settings', + 'web_apps = synnefo_stats.synnefo_settings:installed_apps', + 'urls = synnefo_stats.urls:urlpatterns', ] } ) diff --git a/snf-stats-app/synnefo_stats/settings.py b/snf-stats-app/synnefo_stats/settings.py index adabe7cdf..550e15ecb 100644 --- a/snf-stats-app/synnefo_stats/settings.py +++ b/snf-stats-app/synnefo_stats/settings.py @@ -1,4 +1,4 @@ -## -*- coding: utf-8 -*- +# -*- coding: utf-8 -*- from django.conf import settings STATS_SECRET_KEY = getattr(settings, 'STATS_SECRET_KEY', "secret key") From 1416a6175762595f9a690f13bd7c6f1166ce3300 Mon Sep 17 00:00:00 2001 From: indorilftw Date: Wed, 12 Nov 2014 12:01:24 +0200 Subject: [PATCH 34/43] PEP8 fixes on snf-tools directory --- snf-tools/distribute_setup.py | 34 ++++++++++++------- .../synnefo_tools/burnin/images_tests.py | 2 +- 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/snf-tools/distribute_setup.py b/snf-tools/distribute_setup.py index 10d66840a..c933b1d0b 100644 --- a/snf-tools/distribute_setup.py +++ b/snf-tools/distribute_setup.py @@ -144,17 +144,17 @@ def use_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL, except ImportError: return _do_download(version, download_base, to_dir, download_delay) try: - pkg_resources.require("distribute>="+version) + pkg_resources.require("distribute>=" + version) return except pkg_resources.VersionConflict: e = sys.exc_info()[1] if was_imported: sys.stderr.write( - "The required version of distribute (>=%s) is not available,\n" - "and can't be installed while this script is running. Please\n" - "install a more recent version first, using\n" - "'easy_install -U distribute'." - "\n\n(Currently using %r)\n" % (version, e.args[0])) + "The required version of distribute (>=%s) is not available,\n" + "and can't be installed while this script is running. Please\n" + "install a more recent version first, using\n" + "'easy_install -U distribute'." + "\n\n(Currently using %r)\n" % (version, e.args[0])) sys.exit(2) else: del pkg_resources, sys.modules['pkg_resources'] # reload ok @@ -167,6 +167,7 @@ def use_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL, if not no_fake: _create_fake_setuptools_pkg_info(to_dir) + def download_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL, to_dir=os.curdir, delay=15): """Download distribute from a specified location and return its filename @@ -203,6 +204,7 @@ def download_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL, dst.close() return os.path.realpath(saveto) + def _no_sandbox(function): def __no_sandbox(*args, **kw): try: @@ -227,6 +229,7 @@ def violation(*args): return __no_sandbox + def _patch_file(path, content): """Will backup the file then patch it""" existing_content = open(path).read() @@ -245,15 +248,18 @@ def _patch_file(path, content): _patch_file = _no_sandbox(_patch_file) + def _same_content(path, content): return open(path).read() == content + def _rename_path(path): new_name = path + '.OLD.%s' % time.time() log.warn('Renaming %s into %s', path, new_name) os.rename(path, new_name) return new_name + def _remove_flat_installation(placeholder): if not os.path.isdir(placeholder): log.warn('Unkown installation at %s', placeholder) @@ -289,18 +295,19 @@ def _remove_flat_installation(placeholder): _remove_flat_installation = _no_sandbox(_remove_flat_installation) + def _after_install(dist): log.warn('After install bootstrap.') placeholder = dist.get_command_obj('install').install_purelib _create_fake_setuptools_pkg_info(placeholder) + def _create_fake_setuptools_pkg_info(placeholder): if not placeholder or not os.path.exists(placeholder): log.warn('Could not find the install location') return pyver = '%s.%s' % (sys.version_info[0], sys.version_info[1]) - setuptools_file = 'setuptools-%s-py%s.egg-info' % \ - (SETUPTOOLS_FAKED_VERSION, pyver) + setuptools_file = 'setuptools-%s-py%s.egg-info' % (SETUPTOOLS_FAKED_VERSION, pyver) pkg_info = os.path.join(placeholder, setuptools_file) if os.path.exists(pkg_info): log.warn('%s already exists', pkg_info) @@ -323,6 +330,7 @@ def _create_fake_setuptools_pkg_info(placeholder): _create_fake_setuptools_pkg_info = _no_sandbox(_create_fake_setuptools_pkg_info) + def _patch_egg_dir(path): # let's check if it's already patched pkg_info = os.path.join(path, 'EGG-INFO', 'PKG-INFO') @@ -343,6 +351,7 @@ def _patch_egg_dir(path): _patch_egg_dir = _no_sandbox(_patch_egg_dir) + def _before_install(): log.warn('Before install bootstrap.') _fake_setuptools() @@ -351,7 +360,7 @@ def _before_install(): def _under_prefix(location): if 'install' not in sys.argv: return True - args = sys.argv[sys.argv.index('install')+1:] + args = sys.argv[sys.argv.index('install') + 1:] for index, arg in enumerate(args): for option in ('--root', '--prefix'): if arg.startswith('%s=' % option): @@ -359,7 +368,7 @@ def _under_prefix(location): return location.startswith(top_dir) elif arg == option: if len(args) > index: - top_dir = args[index+1] + top_dir = args[index + 1] return location.startswith(top_dir) if arg == '--user' and USER_SITE is not None: return location.startswith(USER_SITE) @@ -405,8 +414,7 @@ def _fake_setuptools(): else: log.warn('Egg installation') pkg_info = os.path.join(setuptools_location, 'EGG-INFO', 'PKG-INFO') - if (os.path.exists(pkg_info) and - _same_content(pkg_info, SETUPTOOLS_PKG_INFO)): + if (os.path.exists(pkg_info) and _same_content(pkg_info, SETUPTOOLS_PKG_INFO)): log.warn('Already patched.') return log.warn('Patching...') @@ -448,7 +456,7 @@ def _extractall(self, path=".", members=None): # Extract directories with a safe mode. directories.append(tarinfo) tarinfo = copy.copy(tarinfo) - tarinfo.mode = 448 # decimal for oct 0700 + tarinfo.mode = 448 # decimal for oct 0700 self.extract(tarinfo, path) # Reverse sort directories. diff --git a/snf-tools/synnefo_tools/burnin/images_tests.py b/snf-tools/synnefo_tools/burnin/images_tests.py index 1eb7b24cc..d4800a48e 100644 --- a/snf-tools/synnefo_tools/burnin/images_tests.py +++ b/snf-tools/synnefo_tools/burnin/images_tests.py @@ -223,7 +223,7 @@ def test_009_register_image(self): self.info("Set image metadata in the pithos domain") pithos.set_object_meta('%s_copy' % self.temp_image_name, - {'foo': 'bar'}) + {'foo': 'bar'}) self.info("Checking copied image " "is still listed among the images.") From 94441f8a80874786caf01105cb0149e367e4f05b Mon Sep 17 00:00:00 2001 From: indorilftw Date: Wed, 12 Nov 2014 12:02:07 +0200 Subject: [PATCH 35/43] PEP8 fixes on snf-webproject directory --- .../gunicorn-hooks/gunicorn-archipelago.py | 3 +- snf-webproject/distribute_setup.py | 34 +++++++----- snf-webproject/docs/conf.py | 53 ++++++++++--------- snf-webproject/setup.py | 42 +++++++-------- snf-webproject/synnefo/__init__.py | 1 - snf-webproject/synnefo/versions/__init__.py | 1 - .../synnefo/webproject/context_processors.py | 6 +-- snf-webproject/synnefo/webproject/i18n.py | 3 +- .../synnefo/webproject/settings/__init__.py | 28 +++++----- .../webproject/settings/default/__init__.py | 1 - .../webproject/settings/default/apps.py | 3 +- .../webproject/settings/default/database.py | 4 +- .../webproject/settings/default/deploy.py | 10 ++-- .../webproject/settings/default/logging.py | 10 ++-- 14 files changed, 102 insertions(+), 97 deletions(-) diff --git a/snf-webproject/conf/gunicorn-hooks/gunicorn-archipelago.py b/snf-webproject/conf/gunicorn-hooks/gunicorn-archipelago.py index 15cf37466..990f67b21 100644 --- a/snf-webproject/conf/gunicorn-hooks/gunicorn-archipelago.py +++ b/snf-webproject/conf/gunicorn-hooks/gunicorn-archipelago.py @@ -20,7 +20,8 @@ import pickle import os -SYNNEFO_UMASK=0o007 +SYNNEFO_UMASK = 0o007 + def find_hole(workers, fworkers): old_key = [] diff --git a/snf-webproject/distribute_setup.py b/snf-webproject/distribute_setup.py index 10d66840a..c933b1d0b 100644 --- a/snf-webproject/distribute_setup.py +++ b/snf-webproject/distribute_setup.py @@ -144,17 +144,17 @@ def use_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL, except ImportError: return _do_download(version, download_base, to_dir, download_delay) try: - pkg_resources.require("distribute>="+version) + pkg_resources.require("distribute>=" + version) return except pkg_resources.VersionConflict: e = sys.exc_info()[1] if was_imported: sys.stderr.write( - "The required version of distribute (>=%s) is not available,\n" - "and can't be installed while this script is running. Please\n" - "install a more recent version first, using\n" - "'easy_install -U distribute'." - "\n\n(Currently using %r)\n" % (version, e.args[0])) + "The required version of distribute (>=%s) is not available,\n" + "and can't be installed while this script is running. Please\n" + "install a more recent version first, using\n" + "'easy_install -U distribute'." + "\n\n(Currently using %r)\n" % (version, e.args[0])) sys.exit(2) else: del pkg_resources, sys.modules['pkg_resources'] # reload ok @@ -167,6 +167,7 @@ def use_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL, if not no_fake: _create_fake_setuptools_pkg_info(to_dir) + def download_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL, to_dir=os.curdir, delay=15): """Download distribute from a specified location and return its filename @@ -203,6 +204,7 @@ def download_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL, dst.close() return os.path.realpath(saveto) + def _no_sandbox(function): def __no_sandbox(*args, **kw): try: @@ -227,6 +229,7 @@ def violation(*args): return __no_sandbox + def _patch_file(path, content): """Will backup the file then patch it""" existing_content = open(path).read() @@ -245,15 +248,18 @@ def _patch_file(path, content): _patch_file = _no_sandbox(_patch_file) + def _same_content(path, content): return open(path).read() == content + def _rename_path(path): new_name = path + '.OLD.%s' % time.time() log.warn('Renaming %s into %s', path, new_name) os.rename(path, new_name) return new_name + def _remove_flat_installation(placeholder): if not os.path.isdir(placeholder): log.warn('Unkown installation at %s', placeholder) @@ -289,18 +295,19 @@ def _remove_flat_installation(placeholder): _remove_flat_installation = _no_sandbox(_remove_flat_installation) + def _after_install(dist): log.warn('After install bootstrap.') placeholder = dist.get_command_obj('install').install_purelib _create_fake_setuptools_pkg_info(placeholder) + def _create_fake_setuptools_pkg_info(placeholder): if not placeholder or not os.path.exists(placeholder): log.warn('Could not find the install location') return pyver = '%s.%s' % (sys.version_info[0], sys.version_info[1]) - setuptools_file = 'setuptools-%s-py%s.egg-info' % \ - (SETUPTOOLS_FAKED_VERSION, pyver) + setuptools_file = 'setuptools-%s-py%s.egg-info' % (SETUPTOOLS_FAKED_VERSION, pyver) pkg_info = os.path.join(placeholder, setuptools_file) if os.path.exists(pkg_info): log.warn('%s already exists', pkg_info) @@ -323,6 +330,7 @@ def _create_fake_setuptools_pkg_info(placeholder): _create_fake_setuptools_pkg_info = _no_sandbox(_create_fake_setuptools_pkg_info) + def _patch_egg_dir(path): # let's check if it's already patched pkg_info = os.path.join(path, 'EGG-INFO', 'PKG-INFO') @@ -343,6 +351,7 @@ def _patch_egg_dir(path): _patch_egg_dir = _no_sandbox(_patch_egg_dir) + def _before_install(): log.warn('Before install bootstrap.') _fake_setuptools() @@ -351,7 +360,7 @@ def _before_install(): def _under_prefix(location): if 'install' not in sys.argv: return True - args = sys.argv[sys.argv.index('install')+1:] + args = sys.argv[sys.argv.index('install') + 1:] for index, arg in enumerate(args): for option in ('--root', '--prefix'): if arg.startswith('%s=' % option): @@ -359,7 +368,7 @@ def _under_prefix(location): return location.startswith(top_dir) elif arg == option: if len(args) > index: - top_dir = args[index+1] + top_dir = args[index + 1] return location.startswith(top_dir) if arg == '--user' and USER_SITE is not None: return location.startswith(USER_SITE) @@ -405,8 +414,7 @@ def _fake_setuptools(): else: log.warn('Egg installation') pkg_info = os.path.join(setuptools_location, 'EGG-INFO', 'PKG-INFO') - if (os.path.exists(pkg_info) and - _same_content(pkg_info, SETUPTOOLS_PKG_INFO)): + if (os.path.exists(pkg_info) and _same_content(pkg_info, SETUPTOOLS_PKG_INFO)): log.warn('Already patched.') return log.warn('Patching...') @@ -448,7 +456,7 @@ def _extractall(self, path=".", members=None): # Extract directories with a safe mode. directories.append(tarinfo) tarinfo = copy.copy(tarinfo) - tarinfo.mode = 448 # decimal for oct 0700 + tarinfo.mode = 448 # decimal for oct 0700 self.extract(tarinfo, path) # Reverse sort directories. diff --git a/snf-webproject/docs/conf.py b/snf-webproject/docs/conf.py index 770db4116..e8a3ee6a3 100644 --- a/snf-webproject/docs/conf.py +++ b/snf-webproject/docs/conf.py @@ -1,4 +1,5 @@ -import sys, os +import sys +import os sys.path.insert(0, os.path.abspath('../')) from synnefo.versions.webproject import __version__ @@ -16,34 +17,34 @@ pygments_style = 'sphinx' html_theme = 'default' html_theme_options = { - 'collapsiblesidebar': 'true', - 'footerbgcolor': '#55b577', - 'footertextcolor': '#000000', - 'sidebarbgcolor': '#ffffff', - 'sidebarbtncolor': '#f2f2f2', - 'sidebartextcolor': '#000000', - 'sidebarlinkcolor': '#328e4a', - 'relbarbgcolor': '#55b577', - 'relbartextcolor': '#ffffff', - 'relbarlinkcolor': '#ffffff', - 'bgcolor': '#ffffff', - 'textcolor': '#000000', - 'headbgcolor': '#ffffff', - 'headtextcolor': '#000000', - 'headlinkcolor': '#c60f0f', - 'linkcolor': '#328e4a', - 'visitedlinkcolor': '#63409b', - 'codebgcolor': '#eeffcc', - 'codetextcolor': '#333333' + 'collapsiblesidebar': 'true', + 'footerbgcolor': '#55b577', + 'footertextcolor': '#000000', + 'sidebarbgcolor': '#ffffff', + 'sidebarbtncolor': '#f2f2f2', + 'sidebartextcolor': '#000000', + 'sidebarlinkcolor': '#328e4a', + 'relbarbgcolor': '#55b577', + 'relbartextcolor': '#ffffff', + 'relbarlinkcolor': '#ffffff', + 'bgcolor': '#ffffff', + 'textcolor': '#000000', + 'headbgcolor': '#ffffff', + 'headtextcolor': '#000000', + 'headlinkcolor': '#c60f0f', + 'linkcolor': '#328e4a', + 'visitedlinkcolor': '#63409b', + 'codebgcolor': '#eeffcc', + 'codetextcolor': '#333333' } html_static_path = ['_static'] htmlhelp_basename = 'synnefodoc' intersphinx_mapping = { - 'pithon': ('http://docs.python.org/', None), - 'django': ('https://docs.djangoproject.com/en/dev/', - 'https://docs.djangoproject.com/en/dev/_objects/') + 'pithon': ('http://docs.python.org/', None), + 'django': ('https://docs.djangoproject.com/en/dev/', + 'https://docs.djangoproject.com/en/dev/_objects/') } SYNNEFO_DOCS_BASE_URL = 'http://www.synnefo.org/docs' @@ -57,9 +58,9 @@ } for name, ver in SYNNEFO_PROJECTS.iteritems(): - intersphinx_mapping[name.replace("-","")] = (SYNNEFO_DOCS_BASE_URL + - '%s/%s/' % (name, ver), - None) + intersphinx_mapping[name.replace("-", "")] = (SYNNEFO_DOCS_BASE_URL + + '%s/%s/' % (name, ver), + None) extensions = ['sphinx.ext.intersphinx', 'sphinx.ext.todo', diff --git a/snf-webproject/setup.py b/snf-webproject/setup.py index 0b8ac6697..64f6d212d 100644 --- a/snf-webproject/setup.py +++ b/snf-webproject/setup.py @@ -40,8 +40,8 @@ # Package requirements INSTALL_REQUIRES = [ - 'Django>=1.4, <1.5', - 'snf-common', + 'Django>=1.4, <1.5', + 'snf-common', ] EXTRAS_REQUIRES = { @@ -58,18 +58,19 @@ "snf-0.7" ] + # (c) 2005 Ian Bicking and contributors; written for Paste (http://pythonpaste.org) # Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php # Note: you may want to copy this into your setup.py file verbatim, as # you can't import this from another package, when you don't know if # that package is installed yet. def find_package_data( - where=".", - package="", - exclude=standard_exclude, - exclude_directories=standard_exclude_directories, - only_in_packages=True, - show_ignored=False): + where=".", + package="", + exclude=standard_exclude, + exclude_directories=standard_exclude_directories, + only_in_packages=True, + show_ignored=False): """ Return a dictionary suitable for use in ``package_data`` in a distutils ``setup.py`` file. @@ -105,8 +106,7 @@ def find_package_data( if os.path.isdir(fn): bad_name = False for pattern in exclude_directories: - if (fnmatchcase(name, pattern) - or fn.lower() == pattern.lower()): + if (fnmatchcase(name, pattern) or fn.lower() == pattern.lower()): bad_name = True if show_ignored: print >> sys.stderr, ( @@ -115,8 +115,7 @@ def find_package_data( break if bad_name: continue - if (os.path.isfile(os.path.join(fn, "__init__.py")) - and not prefix): + if (os.path.isfile(os.path.join(fn, "__init__.py")) and not prefix): if not package: new_package = name else: @@ -128,8 +127,7 @@ def find_package_data( # is a file bad_name = False for pattern in exclude: - if (fnmatchcase(name, pattern) - or fn.lower() == pattern.lower()): + if (fnmatchcase(name, pattern) or fn.lower() == pattern.lower()): bad_name = True if show_ignored: print >> sys.stderr, ( @@ -138,7 +136,7 @@ def find_package_data( break if bad_name: continue - out.setdefault(package, []).append(prefix+name) + out.setdefault(package, []).append(prefix + name) return out setup( @@ -168,11 +166,11 @@ def find_package_data( dependency_links=['http://www.synnefo.org/packages/pypi'], entry_points={ - 'console_scripts': [ - 'snf-manage = synnefo.webproject.manage:main', - ], - 'synnefo': [ - 'default_settings = synnefo.webproject.settings' - ] - }, + 'console_scripts': [ + 'snf-manage = synnefo.webproject.manage:main', + ], + 'synnefo': [ + 'default_settings = synnefo.webproject.settings' + ] + }, ) diff --git a/snf-webproject/synnefo/__init__.py b/snf-webproject/synnefo/__init__.py index 4ee938c01..5cda84290 100644 --- a/snf-webproject/synnefo/__init__.py +++ b/snf-webproject/synnefo/__init__.py @@ -20,4 +20,3 @@ except ImportError: import pkgutil __path__ = pkgutil.extend_path(__path__, __name__) - diff --git a/snf-webproject/synnefo/versions/__init__.py b/snf-webproject/synnefo/versions/__init__.py index 4ee938c01..5cda84290 100644 --- a/snf-webproject/synnefo/versions/__init__.py +++ b/snf-webproject/synnefo/versions/__init__.py @@ -20,4 +20,3 @@ except ImportError: import pkgutil __path__ = pkgutil.extend_path(__path__, __name__) - diff --git a/snf-webproject/synnefo/webproject/context_processors.py b/snf-webproject/synnefo/webproject/context_processors.py index 1c8a75e20..2bd1ef167 100644 --- a/snf-webproject/synnefo/webproject/context_processors.py +++ b/snf-webproject/synnefo/webproject/context_processors.py @@ -42,13 +42,13 @@ def cloudbar(request): CB_VERSION = version.get_component_version("webproject") CB_COOKIE_NAME = getattr(settings, 'CLOUDBAR_COOKIE_NAME', - 'okeanos_account') + 'okeanos_account') CB_SERVICES_URL = getattr(settings, 'CLOUDBAR_SERVICES_URL') CB_MENU_URL = getattr(settings, 'CLOUDBAR_MENU_URL') CB_HEIGHT = getattr(settings, 'CLOUDBAR_HEIGHT', - '35') + '35') CB_BGCOLOR = getattr(settings, 'CLOUDBAR_BACKGROUND_COLOR', - '#000000') + '#000000') CB_CODE = """