Skip to content

Commit

Permalink
Cloud images - support duplicated names
Browse files Browse the repository at this point in the history
  • Loading branch information
tomez committed Jun 25, 2019
1 parent bd2d884 commit 1c0a169
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/ralph/virtual/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ class CloudProviderAdmin(RalphAdmin):
@register(CloudImage)
class CloudImageAdmin(RalphAdmin):
list_display = ['name', 'image_id']
list_filter = ['name', 'image_id']
list_filter = ['name']

fieldsets = (
('Cloud Image', {
Expand Down
5 changes: 3 additions & 2 deletions src/ralph/virtual/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from ralph.data_center.models import DCHost
from ralph.security.api import SecurityScanSerializer
from ralph.security.models import SecurityScan
from ralph.virtual.admin import CloudFlavorAdmin, VirtualServerAdmin
from ralph.virtual.admin import VirtualServerAdmin
from ralph.virtual.models import (
CloudFlavor,
CloudHost,
Expand Down Expand Up @@ -178,7 +178,7 @@ class CloudFlavorViewSet(RalphAPIViewSet):
serializer_class = CloudFlavorSerializer
save_serializer_class = SaveCloudFlavorSerializer
prefetch_related = ['tags', 'virtualcomponent_set__model']
list_filter = CloudFlavorAdmin.list_filter + ['flavor_id']
filter_fields = ['flavor_id']


class CloudProviderViewSet(RalphAPIViewSet):
Expand All @@ -189,6 +189,7 @@ class CloudProviderViewSet(RalphAPIViewSet):
class CloudImageViewSet(RalphAPIViewSet):
queryset = CloudImage.objects.all()
serializer_class = CloudImageSerializer
filter_fields = ['image_id']


class CloudHostViewSet(BaseObjectViewSetMixin, RalphAPIViewSet):
Expand Down
6 changes: 1 addition & 5 deletions src/ralph/virtual/migrations/0012_cloudimage.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,9 @@ class Migration(migrations.Migration):
name='CloudImage',
fields=[
('id', models.AutoField(verbose_name='ID', primary_key=True, serialize=False, auto_created=True)),
('name', models.CharField(verbose_name='name', max_length=255, unique=True)),
('image_id', models.CharField(verbose_name='image ID', max_length=100, unique=True)),
('name', models.CharField(max_length=200)),
],
options={
'verbose_name': 'Cloud image',
'verbose_name_plural': 'Cloud images',
},
bases=(ralph.lib.mixins.models.AdminAbsoluteUrlMixin, models.Model),
),
]
7 changes: 2 additions & 5 deletions src/ralph/virtual/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,16 +164,13 @@ def __str__(self):
return 'Cloud Project: {}'.format(self.name)


class CloudImage(AdminAbsoluteUrlMixin, NamedMixin):
class Meta:
verbose_name = _('Cloud image')
verbose_name_plural = _('Cloud images')

class CloudImage(AdminAbsoluteUrlMixin, models.Model):
image_id = models.CharField(
verbose_name=_('image ID'),
unique=True,
max_length=100
)
name = models.CharField(max_length=200, unique=False)

def __str__(self):
return 'Cloud Image: {}'.format(self.name)
Expand Down

0 comments on commit 1c0a169

Please sign in to comment.