diff --git a/blazar_dashboard/content/leases/forms.py b/blazar_dashboard/content/leases/forms.py index f57c7da..c2b0d2f 100644 --- a/blazar_dashboard/content/leases/forms.py +++ b/blazar_dashboard/content/leases/forms.py @@ -97,17 +97,6 @@ class CreateForm(forms.SelfHandlingForm): 'data-source-host': _('Hypervisor Properties'), 'placeholder': 'e.g. [">=", "$vcpus", "2"]'}) ) - resource_properties = forms.CharField( - label=_("Resource Properties"), - required=False, - help_text=_('Enter properties of a resource to reserve.'), - max_length=255, - widget=forms.TextInput(attrs={ - 'class': 'switched', - 'data-switch-on': 'source', - 'data-source-host': _('Resource Properties'), - 'placeholder': 'e.g. ["==", "$extra_key", "extra_value"]'}) - ) # Fields for instance reservation amount = forms.IntegerField( @@ -155,6 +144,16 @@ class CreateForm(forms.SelfHandlingForm): 'data-source-instance': _('Root Disk (GB)')}) ) + # Fields for both of host and instance reservations + resource_properties = forms.CharField( + label=_("Resource Properties"), + required=False, + help_text=_('Enter properties of a resource to reserve.'), + max_length=255, + widget=forms.TextInput(attrs={ + 'placeholder': 'e.g. ["==", "$extra_key", "extra_value"]'}) + ) + def handle(self, request, data): if data['resource_type'] == 'host': reservations = [ @@ -175,7 +174,8 @@ class CreateForm(forms.SelfHandlingForm): 'vcpus': data['vcpus'], 'memory_mb': data['memory_mb'], 'disk_gb': data['disk_gb'], - 'affinity': False + 'affinity': False, + 'resource_properties': data['resource_properties'] or '' } ] diff --git a/blazar_dashboard/content/leases/tests.py b/blazar_dashboard/content/leases/tests.py index 7fd459c..7b3aa91 100644 --- a/blazar_dashboard/content/leases/tests.py +++ b/blazar_dashboard/content/leases/tests.py @@ -140,7 +140,8 @@ class LeasesTests(test.TestCase): 'amount': 3, 'vcpus': 2, 'memory_mb': 4096, - 'disk_gb': 128 + 'disk_gb': 128, + 'resource_properties': '["==", "$energy", "clean"]' } lease_create.return_value = dummy_lease @@ -158,7 +159,8 @@ class LeasesTests(test.TestCase): 'vcpus': 2, 'memory_mb': 4096, 'disk_gb': 128, - 'affinity': False + 'affinity': False, + 'resource_properties': '["==", "$energy", "clean"]' } ], [])