Skip to content

Commit

Permalink
Adds ID to flavors list.
Browse files Browse the repository at this point in the history
Adds new flavor ID by adding one to the max flavor ID.

Related to bug 915785

Change-Id: I25d5c231e8228d3348e04ba3254a72b1a79ff354
  • Loading branch information
treshenry committed Jan 20, 2012
1 parent da92e69 commit 26878f6
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
4 changes: 2 additions & 2 deletions horizon/horizon/dashboards/syspanel/flavors/forms.py
Expand Up @@ -33,7 +33,7 @@

class CreateFlavor(forms.SelfHandlingForm):
#flavorid is required because of openstackx
flavorid = forms.IntegerField(label=_("Flavor ID"))
flavor_id = forms.IntegerField(label=_("Flavor ID"))
name = forms.CharField(max_length="25", label=_("Name"))
vcpus = forms.CharField(max_length="5", label=_("VCPUs"))
memory_mb = forms.CharField(max_length="5", label=_("Memory MB"))
Expand All @@ -45,7 +45,7 @@ def handle(self, request, data):
int(data['memory_mb']),
int(data['vcpus']),
int(data['disk_gb']),
int(data['flavorid']))
int(data['flavor_id']))
msg = _('%s was successfully added to flavors.') % data['name']
LOG.info(msg)
messages.success(request, msg)
Expand Down
3 changes: 1 addition & 2 deletions horizon/horizon/dashboards/syspanel/flavors/tables.py
@@ -1,7 +1,5 @@
import logging

from django import shortcuts
from django.contrib import messages
from django.utils.translation import ugettext_lazy as _

from horizon import api
Expand All @@ -27,6 +25,7 @@ class CreateFlavor(tables.LinkAction):


class FlavorsTable(tables.DataTable):
flavor_id = tables.Column('id', verbose_name=('ID'))
name = tables.Column('name', verbose_name=_('Flavor Name'))
vcpus = tables.Column('vcpus', verbose_name=_('VCPUs'))
ram = tables.Column('ram', verbose_name=_('Memory'))
Expand Down
10 changes: 8 additions & 2 deletions horizon/horizon/dashboards/syspanel/flavors/views.py
Expand Up @@ -20,7 +20,6 @@

import logging

from django import shortcuts
from django.contrib import messages
from django.utils.translation import ugettext as _
from novaclient import exceptions as api_exceptions
Expand All @@ -30,7 +29,7 @@
from horizon import tables
from .forms import CreateFlavor
from .tables import FlavorsTable
from horizon.dashboards.syspanel.instances import views as instance_views


LOG = logging.getLogger(__name__)

Expand Down Expand Up @@ -60,3 +59,10 @@ def get_data(self):
class CreateView(forms.ModalFormView):
form_class = CreateFlavor
template_name = 'syspanel/flavors/create.html'

def get_initial(self):
# TODO(tres): Get rid of this hacky bit of nonsense after flavors get
# converted to nova client.
flavors = api.flavor_list(self.request)
flavors.sort(key=lambda f: f.id, reverse=True)
return {'flavor_id': int(flavors[0].id) + 1}

0 comments on commit 26878f6

Please sign in to comment.