Support Affinity Rule column in the Virtual Instance Resource Type

Blazar supports True and None for the affinity key in the instance
reservation from Stein release. This patch follows the change in
the blazar dashboard.

Closes-Bug: #1821168
Change-Id: Ibceef87ee717cd978e38765bde80e8294a69833d
This commit is contained in:
Masahito Muroi 2019-03-27 14:17:52 +09:00
parent 05c577af0a
commit 4064094918
2 changed files with 17 additions and 2 deletions

View File

@ -143,6 +143,20 @@ class CreateForm(forms.SelfHandlingForm):
'data-switch-on': 'source',
'data-source-instance': _('Root Disk (GB)')})
)
affinity = forms.ChoiceField(
label=_("Affinity Rule"),
required=False,
choices=(
(None, _('None')),
(True, _('Affinity')),
(False, _('Anti-Affinity')),
),
initial=None,
widget=forms.ThemableSelectWidget(attrs={
'class': 'switched',
'data-switch-on': 'source',
'data-source-instance': _('Affinity Rule')})
)
# Fields for both of host and instance reservations
resource_properties = forms.CharField(
@ -174,7 +188,7 @@ class CreateForm(forms.SelfHandlingForm):
'vcpus': data['vcpus'],
'memory_mb': data['memory_mb'],
'disk_gb': data['disk_gb'],
'affinity': False,
'affinity': data['affinity'],
'resource_properties': data['resource_properties'] or ''
}
]

View File

@ -141,6 +141,7 @@ class LeasesTests(test.TestCase):
'vcpus': 2,
'memory_mb': 4096,
'disk_gb': 128,
'affinity': False,
'resource_properties': '["==", "$energy", "clean"]'
}
lease_create.return_value = dummy_lease
@ -159,7 +160,7 @@ class LeasesTests(test.TestCase):
'vcpus': 2,
'memory_mb': 4096,
'disk_gb': 128,
'affinity': False,
'affinity': 'False',
'resource_properties': '["==", "$energy", "clean"]'
}
],