Skip to content

Commit

Permalink
Making attach volume detach action work again.
Browse files Browse the repository at this point in the history
Fixes syntax error and uses get_object() consistently. Also removes
extraneous print statement.

  * Fixes bug 929224

Change-Id: I34c2574b53241890a142471d4c47689348730646
  • Loading branch information
jakedahn authored and Paul McMillan committed Feb 9, 2012
1 parent 84954e5 commit c106616
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
Expand Up @@ -134,7 +134,6 @@ def get_object_display(self, obj):

def get_object_by_id(self, obj_id):
for obj in self.data:
print self.get_object_id(obj)
if self.get_object_id(obj) == obj_id:
return obj
raise ValueError('No match found for the id "%s".' % obj_id)
Expand Down
Expand Up @@ -68,19 +68,20 @@ class EditAttachmentsView(tables.DataTableView):
template_name = 'nova/instances_and_volumes/volumes/attach.html'

def get_object(self):
if not hasattr(self, "object"):
if not hasattr(self, "_object"):
volume_id = self.kwargs['volume_id']
try:
self.object = api.volume_get(self.request, volume_id)
self._object = api.volume_get(self.request, volume_id)
except:
self.object = None
self._object = None
exceptions.handle(self.request,
_('Unable to retrieve volume information.'))
return self.object
return self._object

def get_data(self):
try:
attachments = [att for att in self.object.attachments if att]
volumes = self.get_object()
attachments = [att for att in volumes.attachments if att]
except:
attachments = []
exceptions.handle(self.request,
Expand All @@ -102,7 +103,7 @@ def get(self, request, *args, **kwargs):
"index")
context = self.get_context_data(**kwargs)
context['form'] = form
context['volume'] = self.object
context['volume'] = self.get_object()
return self.render_to_response(context)

def post(self, request, *args, **kwargs):
Expand Down

0 comments on commit c106616

Please sign in to comment.