[openstack-dev] horizon - extra-specs questionS

Bhandaru, Malini K malini.k.bhandaru at intel.com
Tue Sep 4 23:38:27 UTC 2012


Update

1)      Javascript error eliminated -- happy

2)      I can just as easily code up buttons and tables with the for-loop tag from Django.

Just wondering if I can use the Horizon table support ala in access-and-security

3)      Get_link_url  -- on a table action is it possible to define this method? My attempts to do so resulted in empty url, this is useful for hierarchical objects.

For instance create_action on the extra_specs table should basically pop up a form to allow one to specify an key and a value for the flavor-id that one is editing.

Regards
Malini
From: Bhandaru, Malini K [mailto:malini.k.bhandaru at intel.com]
Sent: Tuesday, September 04, 2012 4:17 PM
To: OpenStack Development Mailing List
Subject: Re: [openstack-dev] horizon - extra-specs questionS

Matt, new to all things Open Stack. I thought blueprints were to define a feature and get approval.
Extra specs for flavors is all approved.  Yours truly just struggling to build in the UI support!

Extra specs is associated with a flavor is we have a hierarchy.


From: Matt Joyce [mailto:matt.joyce at cloudscaling.com]<mailto:[mailto:matt.joyce at cloudscaling.com]>
Sent: Tuesday, September 04, 2012 4:04 PM
To: OpenStack Development Mailing List
Subject: Re: [openstack-dev] horizon - extra-specs questionS

Maybe this is better done as a blueprint in launchpad?
On Tue, Sep 4, 2012 at 3:48 PM, Bhandaru, Malini K <malini.k.bhandaru at intel.com<mailto:malini.k.bhandaru at intel.com>> wrote:
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!
Regards
Malini





In views.py



from .extra_specs.tables import ExtraSpecsTable

..

..



def get_extra_spec_data(request, flavor_id):

        extra_spec_list = []

        try:

            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]))

        except:

            exceptions.handle(request,

                              _('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):

        try:

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

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

        except:

            exceptions.handle(self.request,

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

        return {'flavor_id': flavor.id<http://flavor.id>,

                'name': flavor.name<http://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}





_edit.html



Adding

<div id="extra_specs">

      {{ extra_specs_table.render }}

</div>



_______________________________________________
OpenStack-dev mailing list
OpenStack-dev at lists.openstack.org<mailto:OpenStack-dev at lists.openstack.org>
http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstack.org/pipermail/openstack-dev/attachments/20120904/d7219f0c/attachment-0001.html>


More information about the OpenStack-dev mailing list