Added various capacity properties for flavors,

and added display to index page (along with sample data).

Adding/editing capacities for flavors is forthcoming.

Change-Id: I80261745b32092e0eec6a13a42b3c09818c1beb0
This commit is contained in:
Tzu-Mainn Chen
2013-06-18 12:20:34 -04:00
committed by Tomas Sedovic
parent 1d1f77b5d6
commit 871d579190
4 changed files with 94 additions and 4 deletions

View File

@@ -34,5 +34,35 @@
{"pk": 9, "model": "infrastructure.capacity", "fields": {"value": 12, "unit": "TB", "object_id": 1, "content_type": ["infrastructure", "host"], "name": "storage"}},
{"pk": 10, "model": "infrastructure.capacity", "fields": {"value": 12, "unit": "TB", "object_id": 2, "content_type": ["infrastructure", "host"], "name": "storage"}},
{"pk": 11, "model": "infrastructure.capacity", "fields": {"value": 12, "unit": "TB", "object_id": 3, "content_type": ["infrastructure", "host"], "name": "storage"}},
{"pk": 12, "model": "infrastructure.capacity", "fields": {"value": 12, "unit": "TB", "object_id": 4, "content_type": ["infrastructure", "host"], "name": "storage"}}
{"pk": 12, "model": "infrastructure.capacity", "fields": {"value": 12, "unit": "TB", "object_id": 4, "content_type": ["infrastructure", "host"], "name": "storage"}},
{"pk": 13, "model": "infrastructure.capacity", "fields": {"value": 1, "unit": "", "object_id": 1, "content_type": ["infrastructure", "flavor"], "name": "vcpu"}},
{"pk": 14, "model": "infrastructure.capacity", "fields": {"value": 2, "unit": "", "object_id": 2, "content_type": ["infrastructure", "flavor"], "name": "vcpu"}},
{"pk": 15, "model": "infrastructure.capacity", "fields": {"value": 4, "unit": "", "object_id": 3, "content_type": ["infrastructure", "flavor"], "name": "vcpu"}},
{"pk": 16, "model": "infrastructure.capacity", "fields": {"value": 8, "unit": "", "object_id": 4, "content_type": ["infrastructure", "flavor"], "name": "vcpu"}},
{"pk": 17, "model": "infrastructure.capacity", "fields": {"value": 16, "unit": "", "object_id": 5, "content_type": ["infrastructure", "flavor"], "name": "vcpu"}},
{"pk": 18, "model": "infrastructure.capacity", "fields": {"value": 32, "unit": "", "object_id": 6, "content_type": ["infrastructure", "flavor"], "name": "vcpu"}},
{"pk": 19, "model": "infrastructure.capacity", "fields": {"value": 64, "unit": "MB", "object_id": 1, "content_type": ["infrastructure", "flavor"], "name": "ram"}},
{"pk": 20, "model": "infrastructure.capacity", "fields": {"value": 128, "unit": "MB", "object_id": 2, "content_type": ["infrastructure", "flavor"], "name": "ram"}},
{"pk": 21, "model": "infrastructure.capacity", "fields": {"value": 256, "unit": "MB", "object_id": 3, "content_type": ["infrastructure", "flavor"], "name": "ram"}},
{"pk": 22, "model": "infrastructure.capacity", "fields": {"value": 512, "unit": "MB", "object_id": 4, "content_type": ["infrastructure", "flavor"], "name": "ram"}},
{"pk": 23, "model": "infrastructure.capacity", "fields": {"value": 1024, "unit": "MB", "object_id": 5, "content_type": ["infrastructure", "flavor"], "name": "ram"}},
{"pk": 24, "model": "infrastructure.capacity", "fields": {"value": 2048, "unit": "MB", "object_id": 6, "content_type": ["infrastructure", "flavor"], "name": "ram"}},
{"pk": 25, "model": "infrastructure.capacity", "fields": {"value": 0, "unit": "GB", "object_id": 1, "content_type": ["infrastructure", "flavor"], "name": "root_disk"}},
{"pk": 26, "model": "infrastructure.capacity", "fields": {"value": 0, "unit": "GB", "object_id": 2, "content_type": ["infrastructure", "flavor"], "name": "root_disk"}},
{"pk": 27, "model": "infrastructure.capacity", "fields": {"value": 1, "unit": "GB", "object_id": 3, "content_type": ["infrastructure", "flavor"], "name": "root_disk"}},
{"pk": 28, "model": "infrastructure.capacity", "fields": {"value": 20, "unit": "GB", "object_id": 4, "content_type": ["infrastructure", "flavor"], "name": "root_disk"}},
{"pk": 29, "model": "infrastructure.capacity", "fields": {"value": 40, "unit": "GB", "object_id": 5, "content_type": ["infrastructure", "flavor"], "name": "root_disk"}},
{"pk": 30, "model": "infrastructure.capacity", "fields": {"value": 80, "unit": "GB", "object_id": 6, "content_type": ["infrastructure", "flavor"], "name": "root_disk"}},
{"pk": 31, "model": "infrastructure.capacity", "fields": {"value": 0, "unit": "GB", "object_id": 1, "content_type": ["infrastructure", "flavor"], "name": "ephemeral_disk"}},
{"pk": 32, "model": "infrastructure.capacity", "fields": {"value": 0, "unit": "GB", "object_id": 2, "content_type": ["infrastructure", "flavor"], "name": "ephemeral_disk"}},
{"pk": 33, "model": "infrastructure.capacity", "fields": {"value": 1, "unit": "GB", "object_id": 3, "content_type": ["infrastructure", "flavor"], "name": "ephemeral_disk"}},
{"pk": 34, "model": "infrastructure.capacity", "fields": {"value": 1, "unit": "GB", "object_id": 4, "content_type": ["infrastructure", "flavor"], "name": "ephemeral_disk"}},
{"pk": 35, "model": "infrastructure.capacity", "fields": {"value": 2, "unit": "GB", "object_id": 5, "content_type": ["infrastructure", "flavor"], "name": "ephemeral_disk"}},
{"pk": 36, "model": "infrastructure.capacity", "fields": {"value": 2, "unit": "GB", "object_id": 6, "content_type": ["infrastructure", "flavor"], "name": "ephemeral_disk"}},
{"pk": 37, "model": "infrastructure.capacity", "fields": {"value": 0, "unit": "MB", "object_id": 1, "content_type": ["infrastructure", "flavor"], "name": "swap_disk"}},
{"pk": 38, "model": "infrastructure.capacity", "fields": {"value": 1, "unit": "MB", "object_id": 2, "content_type": ["infrastructure", "flavor"], "name": "swap_disk"}},
{"pk": 39, "model": "infrastructure.capacity", "fields": {"value": 2, "unit": "MB", "object_id": 3, "content_type": ["infrastructure", "flavor"], "name": "swap_disk"}},
{"pk": 40, "model": "infrastructure.capacity", "fields": {"value": 3, "unit": "MB", "object_id": 4, "content_type": ["infrastructure", "flavor"], "name": "swap_disk"}},
{"pk": 41, "model": "infrastructure.capacity", "fields": {"value": 4, "unit": "MB", "object_id": 5, "content_type": ["infrastructure", "flavor"], "name": "swap_disk"}},
{"pk": 42, "model": "infrastructure.capacity", "fields": {"value": 5, "unit": "MB", "object_id": 6, "content_type": ["infrastructure", "flavor"], "name": "swap_disk"}}
]

View File

@@ -58,6 +58,31 @@ class FlavorsFilterAction(tables.FilterAction):
class FlavorsTable(tables.DataTable):
name = tables.Column('name', verbose_name=_('Flavor Name'))
vcpu = tables.Column(
"vcpu",
verbose_name=_('VCPU'),
filters=(lambda x: getattr(x, 'value', ''),)
)
ram = tables.Column(
"ram",
verbose_name=_('RAM (MB)'),
filters=(lambda x: getattr(x, 'value', ''),)
)
root_disk = tables.Column(
"root_disk",
verbose_name=_('Root Disk (GB)'),
filters=(lambda x: getattr(x, 'value', ''),)
)
ephemeral_disk = tables.Column(
"ephemeral_disk",
verbose_name=_('Ephemeral Disk (GB)'),
filters=(lambda x: getattr(x, 'value', ''),)
)
swap_disk = tables.Column(
"swap_disk",
verbose_name=_('Swap Disk (MB)'),
filters=(lambda x: getattr(x, 'value', ''),)
)
class Meta:
name = "flavors"

View File

@@ -28,7 +28,7 @@ class ResourceManagementTests(test.BaseAdminViewTests):
super(ResourceManagementTests, self).setUp()
def test_index(self):
flavors = self.flavors.list()
flavors = self.management_flavors.list()
self.mox.StubOutWithMock(api.management.Flavor, 'list')
api.management.Flavor.list(IsA(http.HttpRequest)).AndReturn(flavors)