[openstack-dev] horizon - extra-specs questionS

Bhandaru, Malini K malini.k.bhandaru at intel.com
Tue Sep 4 22:48:20 UTC 2012

Greetings All!

Would like to via the flavor-edit menu make extra specs view-able and editable.

Is it possible in a view to support rendering a table in addition to ordinary fields?
The ordinary fields being VCPUs, RAM etc and the table being extra_specs?
I also need the create_extra_specs and edit_extra_specs to carry over the flavor_id in their url
Alternately if there is a similar example you could point me too...

And before I can debug the above I run in a javascrip error on clicking my edit-flavor button.

Any and all help appreciated!

In views.py

from .extra_specs.tables import ExtraSpecsTable



def get_extra_spec_data(request, flavor_id):

        extra_spec_list = []


            extra_spec_dict = api.extra_spec_list(request, flavor_id)

            for k in extra_spec_dict.keys():

                extra_spec_list.append(ExtraSpecAux(flavor_id, k, extra_spec_dict[k]))



                              _('Unable to retrieve extra spec list.'))

        return extra_spec_list

class EditView(forms.ModalFormView):

    form_class = EditFlavor

    table_class = ExtraSpecsTable

    template_name = 'syspanel/flavors/edit.html'

    success_url = reverse_lazy('horizon:syspanel:flavors:index')

    def get_context_data(self, **kwargs):

        context = super(EditView, self).get_context_data(**kwargs)

        context['flavor_id'] = self.kwargs['id']

        return context

    def get_initial(self):


            flavor = api.nova.flavor_get(self.request, self.kwargs['id'])

            extra_spec_list = get_extra_spec_data(self.request, self.kwargs['id'])



                              _("Unable to retrieve flavor data."))

        return {'flavor_id': flavor.id,

                'name': flavor.name,

                'vcpus': flavor.vcpus,

                'memory_mb': flavor.ram,

                'disk_gb': flavor.disk,

                'eph_gb': getattr(flavor, 'OS-FLV-EXT-DATA:ephemeral', None),

                'extra_specs': extra_spec_list}



<div id="extra_specs">

      {{ extra_specs_table.render }}


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstack.org/pipermail/openstack-dev/attachments/20120904/23b58199/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: flavor_edit_full.png
Type: image/png
Size: 55915 bytes
Desc: flavor_edit_full.png
URL: <http://lists.openstack.org/pipermail/openstack-dev/attachments/20120904/23b58199/attachment-0001.png>

More information about the OpenStack-dev mailing list