- Removed duplicate stacktach/config.py
- Image usages are now created from image.activate instead of image.update - Removed unneccessary fields from image_deletes - Made image_usage.last_raw and image_deletes.raw nullable because the seed script will not populate these fields
This commit is contained in:
		 Anuj Mathur
					Anuj Mathur
				
			
				
					committed by
					
						 Manali Latkar
						Manali Latkar
					
				
			
			
				
	
			
			
			 Manali Latkar
						Manali Latkar
					
				
			
						parent
						
							f227803dd5
						
					
				
				
					commit
					7e44644790
				
			| @@ -1,43 +0,0 @@ | ||||
| # Copyright (c) 2013 - Rackspace Inc. | ||||
| # | ||||
| # Permission is hereby granted, free of charge, to any person obtaining a copy | ||||
| # of this software and associated documentation files (the "Software"), to | ||||
| # deal in the Software without restriction, including without limitation the | ||||
| # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or | ||||
| # sell copies of the Software, and to permit persons to whom the Software is | ||||
| # furnished to do so, subject to the following conditions: | ||||
| # | ||||
| # The above copyright notice and this permission notice shall be included in | ||||
| # all copies or substantial portions of the Software. | ||||
| # | ||||
| # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||||
| # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||||
| # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||||
| # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||||
| # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||||
| # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS | ||||
| # IN THE SOFTWARE. | ||||
| import json | ||||
| import os | ||||
|  | ||||
| config_filename = os.environ.get('STACKTACH_DEPLOYMENTS_FILE', | ||||
|                                  'stacktach_worker_config.json') | ||||
| try: | ||||
|     from local_settings import * | ||||
|     config_filename = STACKTACH_DEPLOYMENTS_FILE | ||||
| except ImportError: | ||||
|     pass | ||||
|  | ||||
| config = None | ||||
| with open(config_filename, "r") as f: | ||||
|     config = json.load(f) | ||||
|  | ||||
|  | ||||
| def deployments(): | ||||
|     return config['deployments'] | ||||
|  | ||||
|  | ||||
| def topics(): | ||||
|     return config['topics'] | ||||
|  | ||||
|  | ||||
| @@ -12,11 +12,8 @@ class Migration(SchemaMigration): | ||||
|         db.create_table(u'stacktach_imagedeletes', ( | ||||
|             (u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), | ||||
|             ('uuid', self.gf('django.db.models.fields.CharField')(max_length=50, db_index=True)), | ||||
|             ('created_at', self.gf('django.db.models.fields.DecimalField')(max_digits=20, decimal_places=6, db_index=True)), | ||||
|             ('deleted_at', self.gf('django.db.models.fields.DecimalField')(null=True, max_digits=20, decimal_places=6, db_index=True)), | ||||
|             ('owner', self.gf('django.db.models.fields.CharField')(max_length=50, db_index=True)), | ||||
|             ('size', self.gf('django.db.models.fields.BigIntegerField')(max_length=20)), | ||||
|             ('raw', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['stacktach.GlanceRawData'])), | ||||
|             ('raw', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['stacktach.GlanceRawData'], null=True)), | ||||
|         )) | ||||
|         db.send_create_signal(u'stacktach', ['ImageDeletes']) | ||||
|  | ||||
| @@ -47,28 +44,10 @@ class Migration(SchemaMigration): | ||||
|             ('created_at', self.gf('django.db.models.fields.DecimalField')(max_digits=20, decimal_places=6, db_index=True)), | ||||
|             ('owner', self.gf('django.db.models.fields.CharField')(max_length=50, db_index=True)), | ||||
|             ('size', self.gf('django.db.models.fields.BigIntegerField')(max_length=20)), | ||||
|             ('last_raw', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['stacktach.GlanceRawData'])), | ||||
|             ('last_raw', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['stacktach.GlanceRawData'], null=True)), | ||||
|         )) | ||||
|         db.send_create_signal(u'stacktach', ['ImageUsage']) | ||||
|  | ||||
|         # Adding model 'GenericRawData' | ||||
|         db.create_table(u'stacktach_genericrawdata', ( | ||||
|             (u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), | ||||
|             ('deployment', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['stacktach.Deployment'])), | ||||
|             ('tenant', self.gf('django.db.models.fields.CharField')(db_index=True, max_length=50, null=True, blank=True)), | ||||
|             ('json', self.gf('django.db.models.fields.TextField')()), | ||||
|             ('routing_key', self.gf('django.db.models.fields.CharField')(db_index=True, max_length=50, null=True, blank=True)), | ||||
|             ('image_type', self.gf('django.db.models.fields.IntegerField')(default=0, null=True, db_index=True)), | ||||
|             ('when', self.gf('django.db.models.fields.DecimalField')(max_digits=20, decimal_places=6, db_index=True)), | ||||
|             ('publisher', self.gf('django.db.models.fields.CharField')(db_index=True, max_length=100, null=True, blank=True)), | ||||
|             ('event', self.gf('django.db.models.fields.CharField')(db_index=True, max_length=50, null=True, blank=True)), | ||||
|             ('service', self.gf('django.db.models.fields.CharField')(db_index=True, max_length=50, null=True, blank=True)), | ||||
|             ('host', self.gf('django.db.models.fields.CharField')(db_index=True, max_length=100, null=True, blank=True)), | ||||
|             ('instance', self.gf('django.db.models.fields.CharField')(db_index=True, max_length=50, null=True, blank=True)), | ||||
|             ('request_id', self.gf('django.db.models.fields.CharField')(db_index=True, max_length=50, null=True, blank=True)), | ||||
|         )) | ||||
|         db.send_create_signal(u'stacktach', ['GenericRawData']) | ||||
|  | ||||
|         # Adding model 'ImageExists' | ||||
|         db.create_table(u'stacktach_imageexists', ( | ||||
|             (u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), | ||||
| @@ -88,6 +67,24 @@ class Migration(SchemaMigration): | ||||
|         )) | ||||
|         db.send_create_signal(u'stacktach', ['ImageExists']) | ||||
|  | ||||
|         # Adding model 'GenericRawData' | ||||
|         db.create_table(u'stacktach_genericrawdata', ( | ||||
|             (u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), | ||||
|             ('deployment', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['stacktach.Deployment'])), | ||||
|             ('tenant', self.gf('django.db.models.fields.CharField')(db_index=True, max_length=50, null=True, blank=True)), | ||||
|             ('json', self.gf('django.db.models.fields.TextField')()), | ||||
|             ('routing_key', self.gf('django.db.models.fields.CharField')(db_index=True, max_length=50, null=True, blank=True)), | ||||
|             ('image_type', self.gf('django.db.models.fields.IntegerField')(default=0, null=True, db_index=True)), | ||||
|             ('when', self.gf('django.db.models.fields.DecimalField')(max_digits=20, decimal_places=6, db_index=True)), | ||||
|             ('publisher', self.gf('django.db.models.fields.CharField')(db_index=True, max_length=100, null=True, blank=True)), | ||||
|             ('event', self.gf('django.db.models.fields.CharField')(db_index=True, max_length=50, null=True, blank=True)), | ||||
|             ('service', self.gf('django.db.models.fields.CharField')(db_index=True, max_length=50, null=True, blank=True)), | ||||
|             ('host', self.gf('django.db.models.fields.CharField')(db_index=True, max_length=100, null=True, blank=True)), | ||||
|             ('instance', self.gf('django.db.models.fields.CharField')(db_index=True, max_length=50, null=True, blank=True)), | ||||
|             ('request_id', self.gf('django.db.models.fields.CharField')(db_index=True, max_length=50, null=True, blank=True)), | ||||
|         )) | ||||
|         db.send_create_signal(u'stacktach', ['GenericRawData']) | ||||
|  | ||||
|  | ||||
|     def backwards(self, orm): | ||||
|         # Deleting model 'ImageDeletes' | ||||
| @@ -99,12 +96,12 @@ class Migration(SchemaMigration): | ||||
|         # Deleting model 'ImageUsage' | ||||
|         db.delete_table(u'stacktach_imageusage') | ||||
|  | ||||
|         # Deleting model 'GenericRawData' | ||||
|         db.delete_table(u'stacktach_genericrawdata') | ||||
|  | ||||
|         # Deleting model 'ImageExists' | ||||
|         db.delete_table(u'stacktach_imageexists') | ||||
|  | ||||
|         # Deleting model 'GenericRawData' | ||||
|         db.delete_table(u'stacktach_genericrawdata') | ||||
|  | ||||
|  | ||||
|     models = { | ||||
|         u'stacktach.deployment': { | ||||
| @@ -148,12 +145,9 @@ class Migration(SchemaMigration): | ||||
|         }, | ||||
|         u'stacktach.imagedeletes': { | ||||
|             'Meta': {'object_name': 'ImageDeletes'}, | ||||
|             'created_at': ('django.db.models.fields.DecimalField', [], {'max_digits': '20', 'decimal_places': '6', 'db_index': 'True'}), | ||||
|             'deleted_at': ('django.db.models.fields.DecimalField', [], {'null': 'True', 'max_digits': '20', 'decimal_places': '6', 'db_index': 'True'}), | ||||
|             u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), | ||||
|             'owner': ('django.db.models.fields.CharField', [], {'max_length': '50', 'db_index': 'True'}), | ||||
|             'raw': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['stacktach.GlanceRawData']"}), | ||||
|             'size': ('django.db.models.fields.BigIntegerField', [], {'max_length': '20'}), | ||||
|             'raw': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['stacktach.GlanceRawData']", 'null': 'True'}), | ||||
|             'uuid': ('django.db.models.fields.CharField', [], {'max_length': '50', 'db_index': 'True'}) | ||||
|         }, | ||||
|         u'stacktach.imageexists': { | ||||
| @@ -177,7 +171,7 @@ class Migration(SchemaMigration): | ||||
|             'Meta': {'object_name': 'ImageUsage'}, | ||||
|             'created_at': ('django.db.models.fields.DecimalField', [], {'max_digits': '20', 'decimal_places': '6', 'db_index': 'True'}), | ||||
|             u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), | ||||
|             'last_raw': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['stacktach.GlanceRawData']"}), | ||||
|             'last_raw': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['stacktach.GlanceRawData']", 'null': 'True'}), | ||||
|             'owner': ('django.db.models.fields.CharField', [], {'max_length': '50', 'db_index': 'True'}), | ||||
|             'size': ('django.db.models.fields.BigIntegerField', [], {'max_length': '20'}), | ||||
|             'uuid': ('django.db.models.fields.CharField', [], {'max_length': '50', 'db_index': 'True'}) | ||||
|   | ||||
| @@ -308,19 +308,15 @@ class ImageUsage(models.Model): | ||||
|                                      decimal_places=6, db_index=True) | ||||
|     owner = models.CharField(max_length=50, db_index=True) | ||||
|     size = models.BigIntegerField(max_length=20) | ||||
|     last_raw = models.ForeignKey(GlanceRawData) | ||||
|     last_raw = models.ForeignKey(GlanceRawData, null=True) | ||||
|  | ||||
|  | ||||
| class ImageDeletes(models.Model): | ||||
|     uuid = models.CharField(max_length=50, db_index=True) | ||||
|     created_at = models.DecimalField(max_digits=20, | ||||
|                                      decimal_places=6, db_index=True) | ||||
|     deleted_at = models.DecimalField(max_digits=20, | ||||
|                                      decimal_places=6, db_index=True, | ||||
|                                      null=True) | ||||
|     owner = models.CharField(max_length=50, db_index=True) | ||||
|     size = models.BigIntegerField(max_length=20) | ||||
|     raw = models.ForeignKey(GlanceRawData) | ||||
|     raw = models.ForeignKey(GlanceRawData, null=True) | ||||
|  | ||||
|  | ||||
| class ImageExists(models.Model): | ||||
|   | ||||
| @@ -174,9 +174,6 @@ class GlanceNotification(Notification): | ||||
|     def save_delete(self, raw): | ||||
|         values = { | ||||
|             'uuid': self.uuid, | ||||
|             'created_at': self.created_at, | ||||
|             'owner': self.owner, | ||||
|             'size': self.size, | ||||
|             'raw': raw, | ||||
|             'deleted_at': self.deleted_at | ||||
|         } | ||||
|   | ||||
| @@ -121,9 +121,6 @@ class GlanceTestCase(TransactionTestCase): | ||||
|         _, rawdata = self._create_glance_rawdata() | ||||
|         kwargs = { | ||||
|             'uuid': '1', | ||||
|             'created_at': dt_to_decimal(datetime.utcnow()), | ||||
|             'owner': 'owner', | ||||
|             'size': 12345, | ||||
|             'raw': rawdata, | ||||
|             'deleted_at': dt_to_decimal(datetime.utcnow()) | ||||
|         } | ||||
|   | ||||
| @@ -310,7 +310,7 @@ USAGE_PROCESS_MAPPING = { | ||||
| } | ||||
|  | ||||
| GLANCE_USAGE_PROCESS_MAPPING = { | ||||
|     'image.upload': _process_glance_usage, | ||||
|     'image.activate': _process_glance_usage, | ||||
|     'image.delete': _process_glance_delete, | ||||
|     'image.exists': _process_glance_exists | ||||
| } | ||||
|   | ||||
| @@ -396,17 +396,12 @@ class GlanceNotificationTestCase(unittest.TestCase): | ||||
|  | ||||
|     def test_save_delete_should_persist_image_delete(self): | ||||
|         raw = self.mox.CreateMockAnything() | ||||
|         size = 123 | ||||
|         uuid = "2df2ccf6-bc1b-4853-aab0-25fda346b3bb" | ||||
|         deleted_at = "2013-06-20 14:31:57.939614" | ||||
|         body = { | ||||
|             "event_type": "image.delete", | ||||
|             "timestamp": "2013-06-20 18:31:57.939614", | ||||
|             "publisher_id": "glance-api01-r2961.global.preprod-ord.ohthree.com", | ||||
|             "payload": { | ||||
|                 "created_at": str(DUMMY_TIME), | ||||
|                 "size": size, | ||||
|                 "owner": TENANT_ID_1, | ||||
|                 "id": "2df2ccf6-bc1b-4853-aab0-25fda346b3bb", | ||||
|                 "deleted_at": deleted_at | ||||
|             } | ||||
| @@ -417,10 +412,7 @@ class GlanceNotificationTestCase(unittest.TestCase): | ||||
|  | ||||
|         self.mox.StubOutWithMock(db, 'create_image_delete') | ||||
|         db.create_image_delete( | ||||
|             created_at=utils.str_time_to_unix(str(DUMMY_TIME)), | ||||
|             owner=TENANT_ID_1, | ||||
|             raw=raw, | ||||
|             size=size, | ||||
|             uuid=uuid, | ||||
|             deleted_at=utils.str_time_to_unix(deleted_at)).AndReturn(raw) | ||||
|         self.mox.ReplayAll() | ||||
|   | ||||
		Reference in New Issue
	
	Block a user