New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Validate either a host or cluster is selected when provisioning on VMware #11665
Validate either a host or cluster is selected when provisioning on VMware #11665
Conversation
ae4509b
to
cfa67a9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall, this looks like it's on the right track. Thanks @agrare
|
||
ems_cluster = EmsCluster.find_by(:id => get_value(values[:placement_cluster_name])) | ||
|
||
if get_value(values[:placement_cluster_name]).blank? || ems_cluster.nil? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't it be enough to say if ems_cluster.nil?
rather than calling get_value
a second time?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes it would, done
if get_value(values[:placement_cluster_name]).blank? || ems_cluster.nil? | ||
_("Either Host Name or Cluster Name is required") | ||
elsif !ems_cluster.drs_enabled | ||
_("Host Name required for Non-DRS enabled cluster") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like this message should be:
_("%{field_required} for Non-DRS enabled cluster") % {:field_required => result}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, is there something similar I can do for "Either Host Name or Cluster Name is required"
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current validation goes field by field and runs each validation method or required method for required fields. Getting the messaging right would be tough.
cfa67a9
to
84c8bb2
Compare
if ems_cluster.nil? | ||
_("Either Host Name or Cluster Name is required") | ||
elsif !ems_cluster.drs_enabled | ||
_("%{field_required} required for Non-DRS enabled cluster") % {:field_required => result} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
field_required
should render out to something like Environment/Host is required
, so you should also drop the "required" in your string otherwise you'll get Environment/Host is required required for Non-DRS enabled cluster
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
84c8bb2
to
449deb8
Compare
Checked commit agrare@449deb8 with ruby 2.2.5, rubocop 0.37.2, and haml-lint 0.16.1 |
@agrare Please apply the appropriate euwe label |
…er_validation Validate either a host or cluster is selected when provisioning on VMware (cherry picked from commit 5ef33b1)
Euwe Backport details: $ git log
commit ac19cd3bc3a59bc314854cb28b6125f814aed434
Author: Brandon Dunne <brandondunne@hotmail.com>
Date: Wed Oct 5 09:54:44 2016 -0400
Merge pull request #11665 from agrare/vmware_infra_provisioning_cluster_validation
Validate either a host or cluster is selected when provisioning on VMware
(cherry picked from commit 5ef33b185bfc6f961089595ef5ab4b142efcc45c) |
Darga BZ https://bugzilla.redhat.com/show_bug.cgi?id=1378116 Backport after #11437 |
…er_validation Validate either a host or cluster is selected when provisioning on VMware (cherry picked from commit 5ef33b1) https://bugzilla.redhat.com/show_bug.cgi?id=1378116
Darga Backport details: $ git log
commit 8263d1b798be931ce5bc53ee6015dd2b26538a05
Author: Brandon Dunne <brandondunne@hotmail.com>
Date: Wed Oct 5 09:54:44 2016 -0400
Merge pull request #11665 from agrare/vmware_infra_provisioning_cluster_validation
Validate either a host or cluster is selected when provisioning on VMware
(cherry picked from commit 5ef33b185bfc6f961089595ef5ab4b142efcc45c)
https://bugzilla.redhat.com/show_bug.cgi?id=1378116 |
VMware allows you to select just a cluster (and not a host) if that cluster supports DRS, this updates the validation method to check that:
https://bugzilla.redhat.com/show_bug.cgi?id=1377975