Skip to content

Commit

Permalink
Merge branch 'bz1278036' into '5.5.z'
Browse files Browse the repository at this point in the history
Bz1278036

Missing API version select box in cloud provider

Clean cherry pick of:
ManageIQ#5277
ManageIQ#5297

Fixed BZ:
https://bugzilla.redhat.com/show_bug.cgi?id=1278036

See merge request !428
  • Loading branch information
Dan Clarizio committed Nov 12, 2015
2 parents 0a84fbd + e3c0c47 commit eb9f35b
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ ManageIQ.angularApplication.controller('emsCommonFormController', ['$http', '$sc
zone: '',
hostname: '',
api_port: '',
api_version: '',
provider_region: '',
default_userid: '',
default_password: '',
Expand Down Expand Up @@ -45,6 +46,7 @@ ManageIQ.angularApplication.controller('emsCommonFormController', ['$http', '$sc
$scope.emsCommonModel.emstype_vm = data.emstype_vm;
$scope.emsCommonModel.openstack_infra_providers_exist = data.openstack_infra_providers_exist;
$scope.emsCommonModel.api_port = 5000;
$scope.emsCommonModel.api_version = 'v2';
miqService.sparkleOff();
});
$scope.afterGet = true;
Expand All @@ -64,6 +66,7 @@ ManageIQ.angularApplication.controller('emsCommonFormController', ['$http', '$sc
$scope.emsCommonModel.provider_id = data.provider_id.toString();

$scope.emsCommonModel.api_port = data.api_port;
$scope.emsCommonModel.api_version = data.api_version;
$scope.emsCommonModel.provider_region = data.provider_region;

$scope.emsCommonModel.default_userid = data.default_userid;
Expand Down
4 changes: 4 additions & 0 deletions app/controllers/ems_cloud_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ def ems_cloud_form_fields
:provider_id => @ems.provider_id ? @ems.provider_id : "",
:hostname => @ems.hostname,
:api_port => @ems.port,
:api_version => @ems.api_version ? @ems.api_version : "v2",
:provider_region => @ems.provider_region,
:openstack_infra_providers_exist => retrieve_openstack_infra_providers.length > 0 ? true : false,
:default_userid => @ems.authentication_userid ? @ems.authentication_userid : "",
Expand Down Expand Up @@ -209,6 +210,7 @@ def set_ems_record_vars(ems, mode = nil)
ems.provider_region = params[:provider_region]
ems.hostname = params[:hostname].strip if params[:hostname]
ems.port = params[:api_port].strip if params[:api_port]
ems.api_version = params[:api_version].strip if params[:api_version]
ems.provider_id = params[:provider_id]
ems.zone = Zone.find_by_name(params[:zone])

Expand Down Expand Up @@ -248,6 +250,7 @@ def construct_edit_for_audit(ems)
:hostname => ems.hostname,
:azure_tenant_id => azure_tenant_id,
:port => ems.port,
:api_version => ems.api_version,
:provider_id => ems.provider_id,
:zone => ems.zone
}
Expand All @@ -256,6 +259,7 @@ def construct_edit_for_audit(ems)
:hostname => params[:hostname],
:azure_tenant_id => params[:azure_tenant_id],
:port => params[:port],
:api_version => params[:api_version],
:provider_id => params[:provider_id],
:zone => params[:zone]
}
Expand Down
7 changes: 6 additions & 1 deletion app/controllers/ems_common.rb
Original file line number Diff line number Diff line change
Expand Up @@ -712,7 +712,7 @@ def set_form_vars
x.push([openstack_infra_provider.name, openstack_infra_provider.id])
end

@edit[:openstack_api_versions] = [['Keystone v2', 'v2'], ['Keystone v3', 'v3']]
@edit[:openstack_api_versions] = retrieve_openstack_api_versions

@edit[:new][:default_userid] = @ems.authentication_userid
@edit[:new][:default_password] = @ems.authentication_password
Expand Down Expand Up @@ -756,6 +756,7 @@ def form_instance_vars
@ems_types = Array(model.supported_types_and_descriptions_hash.invert).sort_by(&:first)
@amazon_regions = get_amazon_regions
@openstack_infra_providers = retrieve_openstack_infra_providers
@openstack_api_versions = retrieve_openstack_api_versions
@emstype_display = model.supported_types_and_descriptions_hash[@ems.emstype]
end

Expand All @@ -777,6 +778,10 @@ def retrieve_openstack_infra_providers
openstack_infra_providers
end

def retrieve_openstack_api_versions
[['Keystone v2', 'v2'], ['Keystone v3', 'v3']]
end

# Get variables from edit form
def get_form_vars
@ems = @edit[:ems_id] ? model.find_by_id(@edit[:ems_id]) : model.new
Expand Down
12 changes: 11 additions & 1 deletion app/views/shared/views/ems_common/angular/_form.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,16 @@
%span.help-block{"ng-show" => "angularForm.api_port.$error.required"}
= _("Required")
.form-group{"ng-class" => "{'has-error': angularForm.api_version.$invalid}", "ng-if" => "emsCommonModel.emstype == 'openstack' || emsCommonModel.emstype == 'openstack_infra'"}
%label.col-md-2.control-label{"for" => "textInput-markup"}
= _("API Version")
.col-md-8
= select_tag('api_version',
options_for_select(@openstack_api_versions),
"ng-model" => "emsCommonModel.api_version",
"checkchange" => "",
"selectpicker-for-select-tag" => "")
.form-group{"ng-class" => "{'has-error': angularForm.provider_id.$invalid}", "ng-if" => "emsCommonModel.emstype == 'openstack' && emsCommonModel.openstack_infra_providers_exist"}
%label.col-md-2.control-label{"for" => "textInput-markup"}
= _("Openstack Infra Provider")
Expand Down Expand Up @@ -175,4 +185,4 @@
%div{"ng-show" => "emsCommonModel.emstype != 'azure'"}
= render :partial => "/layouts/angular/multi_auth_credentials", :locals => {:record => @ems, :ng_model => "emsCommonModel"}
= render :partial => "layouts/angular/x_edit_buttons_angular", :locals => {:record => @ems, :restful => true}
= render :partial => "layouts/angular/x_edit_buttons_angular", :locals => {:record => @ems, :restful => true}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ describe('emsCommonFormController', function() {
zone: 'default',
emstype_vm: false,
openstack_infra_providers_exist: false,
api_port: '5000'
api_port: '5000',
api_version: 'v2'
};
$httpBackend = _$httpBackend_;
$httpBackend.whenGET('/ems_cloud/ems_cloud_form_fields/new').respond(emsCommonFormResponse);
Expand Down Expand Up @@ -65,6 +66,10 @@ describe('emsCommonFormController', function() {
it('sets the api_port to 5000', function() {
expect($scope.emsCommonModel.api_port).toEqual(5000);
});

it('sets the api_version to v2', function() {
expect($scope.emsCommonModel.api_version).toEqual('v2');
});
});

describe('when the emsCommonFormId is an Amazon Id', function() {
Expand Down

0 comments on commit eb9f35b

Please sign in to comment.