Skip to content

Commit

Permalink
Added missing features from NG to feature/deployment (#2467)
Browse files Browse the repository at this point in the history
* Filtering by service uid in API
* Networking info for cloud host in inline
  • Loading branch information
mkurek committed Jun 9, 2016
1 parent 5329134 commit 7c50103
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/ralph/assets/api/views.py
Expand Up @@ -79,7 +79,8 @@ class BaseObjectViewSet(PolymorphicViewSetMixin, RalphAPIViewSet):
)),
]
filter_fields = [
'id', 'service_env', 'service_env', 'content_type'
'id', 'service_env', 'service_env', 'service_env__service__uid',
'content_type'
]
extended_filter_fields = {
'name': ['asset__hostname'],
Expand Down
20 changes: 15 additions & 5 deletions src/ralph/virtual/admin.py
Expand Up @@ -5,8 +5,9 @@

from ralph.admin import RalphAdmin, RalphAdminForm, RalphTabularInline, register
from ralph.admin.filters import IPFilter, TagsListFilter
from ralph.assets.models.components import Ethernet
from ralph.data_center.models.virtual import BaseObjectCluster
from ralph.networks.models.networks import IPAddress
from ralph.networks.forms import SimpleNetworkForm
from ralph.virtual.models import (
CloudFlavor,
CloudHost,
Expand Down Expand Up @@ -109,10 +110,20 @@ def get_queryset(self, *args, **kwargs):
).prefetch_related('tags')


class CloudHostNetworkForm(SimpleNetworkForm):
class Meta(SimpleNetworkForm.Meta):
fields = ['address', 'hostname']

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
for field in ['address', 'hostname']:
self.fields[field].widget.attrs['readonly'] = True


class CloudNetworkInline(RalphTabularInline):
can_delete = False
readonly_fields = fields = ['address', 'hostname']
model = IPAddress
form = CloudHostNetworkForm
model = Ethernet

def has_add_permission(self, request, obj=None):
return False
Expand All @@ -134,8 +145,7 @@ class CloudHostAdmin(RalphAdmin):
'modified', 'parent', 'service_env', 'image_name']
search_fields = ['cloudflavor__name', 'hostname', 'host_id']
raw_id_override_parent = {'parent': CloudProject}
# TODO
# inlines = [CloudNetworkInline]
inlines = [CloudNetworkInline]
fieldsets = (
(None, {
'fields': ['hostname', 'get_hypervisor', 'host_id', 'created',
Expand Down

0 comments on commit 7c50103

Please sign in to comment.