-
Notifications
You must be signed in to change notification settings - Fork 356
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
add sshkey support to OpenStack Cloud #4388
Conversation
@@ -261,7 +261,7 @@ | |||
:change_stored_password => _("Change stored client key"), | |||
:cancel_password_change => _("Cancel client key change"), | |||
:verify_title_off => _("Tenant ID, Client ID and matching Client Key fields are needed to perform verification of credentials")} | |||
%div{"ng-if" => "emsCommonModel.emstype != '' && emsCommonModel.emstype != 'azure'"} | |||
%div{"ng-show" => "emsCommonModel.emstype != '' && emsCommonModel.emstype != 'azure'"} |
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.
This may be the wrong solution here, but "ng-show" is what is used for the ems_infra version of this form. Before I changed from ng-if, I was getting a javascript error. It looks like what was happening was that with the partial not rendering at all with ng-if (vs. rendering and being hidden with ng-show), default_userid is left undefined when $scope.canValidateBasicInfo is called. As a result of this, the javascript on the SSH Keypair endpoint tab does not run. I don't know if there are any downsides to using ng-show here, but this partially reverses an earlier change to the validation (I'll link to the commit in another comment).
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 downside to ng-show
is that all the fields are there, always.
You can't have multiple ng-show statemens with different conditions including the same partial because then, the partial will always exist multiple times.
(Unless that partial supports some kind of prefix to regulate this.)
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.
((If you really need the partial to exist and not be visible, use ng-if
with a .hidden class, but ... better fix the underlying problem really.))
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.
In this specific case... this looks like isBasicInfoValid
is already doing logic to determine which fields should be there.
So I'm almost sure any fix for your issue should be to isBasicInfoValid
itself, not the partial.
The javascript error referenced in my comment on the commit above when I don't change the directive to "ng-show": |
This is the commit that is partially undone by the ng-show change above: |
@sseago OpenStack part was merged, can the WIP be removed? |
@aufi I can remove WIP now. I kept it around in case further work was needed around the potential issue I commented on above, but it's not really "in progress" anymore. It's done unless a better suggestion comes down as to how to handle the prior javascript error. |
This pull request is not mergeable. Please rebase and repush. |
@blomquisg The merge issue has already been resolved -- miq-bot removed the unmergeable label. Looking at the codeclimate and scrutinizer errors, those don't seem particularly relevant to my PR. For scrutinizer, it hit an npm version error, and for codeclimate, it's mostly flagging "complexity" issues that reflect the existing design of the code I'm making minor tweaks to rather than the design of the changes. |
@@ -759,6 +761,11 @@ def build_credentials(ems, mode) | |||
ssh_keypair_password = params[:ssh_keypair_password] ? params[:ssh_keypair_password].gsub(/\r\n/, "\n") : ems.authentication_key(:ssh_keypair) | |||
creds[:ssh_keypair] = {:userid => params[:ssh_keypair_userid], :auth_key => ssh_keypair_password, :save => (mode != :validate)} | |||
end | |||
if ems.kind_of?(ManageIQ::Providers::Openstack::CloudManager) && | |||
ems.supports_authentication?(:ssh_keypair) && params[:ssh_keypair_userid] | |||
ssh_keypair_password = params[:ssh_keypair_password] ? params[:ssh_keypair_password].gsub(/\r\n/, "\n") : ems.authentication_key(:ssh_keypair) |
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.
why do we need a third copy of this code?
Especially since all the other places use a openstack or openstack_infra or rhevm condition instead of 3 different ones.
Please unify the three.
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.
Updated version of the PR combines the three.
@@ -309,8 +309,8 @@ ManageIQ.angular.app.controller('emsCommonFormController', ['$http', '$scope', ' | |||
($scope.emsCommonModel.emstype == "ec2" || | |||
['kubevirt', 'nuage_network', 'openstack', 'openstack_infra', 'rhevm', 'scvmm', 'vmwarews', 'vmware_cloud'].includes($scope.emsCommonModel.emstype) && | |||
$scope.emsCommonModel.default_hostname) && | |||
($scope.emsCommonModel.default_userid != '' && $scope.angularForm.default_userid.$valid && | |||
$scope.emsCommonModel.default_password != '' && $scope.angularForm.default_password.$valid)) { | |||
($scope.emsCommonModel.default_userid != '' && $scope.angularForm.default_userid !== undefined && $scope.angularForm.default_userid.$valid && |
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.
why do we need to check for ssh_keypair_userid === undefined
for if the tab is correctly displayed?
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.
(Either looks like a bug that needs to be fixed in the other places as well, or a random change that could potentially break other places, unless there is something special about this particular pair of fields that's not happening elsewhere..)
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.
This was the fix that allowed me to remove the earlier change of "ng-if" to "ng-show". Without the 'undefined' check, this code fails with a javascript error. We didn't see the error appear until adding the sshkey tab, since the other case where the sshkey tab is used (ems_infra) uses 'ng-show' instead of 'ng-if' to display the tab. I followed the example of the existing code (see below in this same method) for handling fields which may be undefined. If the prior change using 'ng-show' instead of 'ng-if' is better, I could revert back to the prior version, but I was following your suggestion here to fix this method rather than using ng-show in the view. I think this version is probably a cleaner solution than what was done before. I suspect getting rid of the problem without checking for undefined would be a much larger change to this code which would be tricky to make sure it didn't break other things (across providers, etc.). This is a pretty safe change, since it basically can't break anything -- for any case where these are undefined, the code is broken without this change already, and when these are defined, checking for undefined is safe.
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.
OK, makes sense, thanks :) I was just trying to make sure this is still intended :)
@@ -63,9 +63,10 @@ | |||
}; | |||
|
|||
EmsKeypairController.prototype.showValidate = function(tab) { | |||
var openstackAndNew = (this.model.emstype === 'openstack_infra') && this.newRecord; | |||
var openstackInfraAndNew = (this.model.emstype === 'openstack_infra') && this.newRecord; | |||
var openstackCloud = this.model.emstype === 'openstack'; |
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.
Is cloud supposed to be different from openstack infra and rhevm here?
Why is validation different for non-new openstack records than for non-new openstack infra? (Any chance that's a bug?)
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.
Cloud is just like rhevm here -- no validation for either 'new' or 'update' forms. Cloud is not like openstack infra because for OpenStack infra, we only validate for 'update', not for 'new'. If you look at the conditional before, we treat rhevm and cloud the same. The distinction is made for OpenStack Infra -- where we validate for update form but not new form. It's not a bug -- it's the way it's supposed to work, since we don't necessarily have an instance running at this point in which we can validate the keypair credentials -- this is the case for both rhevm and openstack cloud.
Add sshkey support to OpenStack Cloud needed for v2v.
Checked commit sseago@cdc619f with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0 **
|
OK, LGTM , thanks for the details! :) (ignoring hakiri - fixed by #4563, and cc because ems_common) |
Add sshkey support to OpenStack Cloud needed for v2v.