Skip to content

Commit

Permalink
Render ems_physical_infra json using it's own controller
Browse files Browse the repository at this point in the history
  • Loading branch information
AparnaKarve committed Feb 21, 2017
1 parent e4496fa commit 1dd3e43
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 22 deletions.
18 changes: 17 additions & 1 deletion app/controllers/ems_physical_infra_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,23 @@ def new_ems_path
end

def ems_physical_infra_form_fields
ems_form_fields
assert_privileges("#{permission_prefix}_edit")
@ems = model.new if params[:id] == 'new'
@ems = find_by_id_filtered(model, params[:id]) if params[:id] != 'new'

render :json => {
:name => @ems.name,
:emstype => @ems.emstype,
:zone => zone,
:provider_id => @ems.provider_id ? @ems.provider_id : "",
:hostname => @ems.hostname,
:default_hostname => @ems.connection_configurations.default.endpoint.hostname,
:default_api_port => @ems.connection_configurations.default.endpoint.port,
:provider_region => @ems.provider_region,
:default_userid => @ems.authentication_userid ? @ems.authentication_userid : "",
:ems_controller => controller_name,
:default_auth_status => default_auth_status,
}
end

private
Expand Down
33 changes: 12 additions & 21 deletions app/controllers/mixins/ems_common_angular.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,6 @@ def ems_form_fields
@ems = find_by_id_filtered(model, params[:id]) if params[:id] != 'new'
default_security_protocol = @ems.default_endpoint.security_protocol ? @ems.default_endpoint.security_protocol : 'ssl'

if @ems.zone.nil? || @ems.my_zone == ""
zone = "default"
else
zone = @ems.my_zone
end
amqp_userid = ""
amqp_hostname = ""
amqp_port = ""
Expand Down Expand Up @@ -201,8 +196,6 @@ def ems_form_fields
service_account_auth_status = @ems.authentication_status_ok?
end

default_auth_status = @ems.authentication_status_ok? unless @ems.kind_of?(ManageIQ::Providers::Google::CloudManager)

render :json => {:name => @ems.name,
:emstype => @ems.emstype,
:zone => zone,
Expand Down Expand Up @@ -266,20 +259,6 @@ def ems_form_fields
:ssh_keypair_auth_status => ssh_keypair_auth_status.nil? ? true : ssh_keypair_auth_status
} if controller_name == "ems_infra"

render :json => {
:name => @ems.name,
:emstype => @ems.emstype,
:zone => zone,
:provider_id => @ems.provider_id ? @ems.provider_id : "",
:hostname => @ems.hostname,
:default_hostname => @ems.connection_configurations.default.endpoint.hostname,
:default_api_port => @ems.connection_configurations.default.endpoint.port,
:provider_region => @ems.provider_region,
:default_userid => @ems.authentication_userid ? @ems.authentication_userid : "",
:ems_controller => controller_name,
:default_auth_status => default_auth_status,
} if controller_name == "ems_physical_infra"

render :json => {:name => @ems.name,
:emstype => @ems.emstype,
:zone => zone,
Expand Down Expand Up @@ -564,5 +543,17 @@ def construct_edit_for_audit(ems)

@edit[:new][:tenant_mapping_enabled] = params[:tenant_mapping_enabled] if ems.class.supports_cloud_tenant_mapping?
end

def zone
if @ems.zone.nil? || @ems.my_zone == ""
"default"
else
@ems.my_zone
end
end

def default_auth_status
@ems.authentication_status_ok? unless @ems.kind_of?(ManageIQ::Providers::Google::CloudManager)
end
end
end

0 comments on commit 1dd3e43

Please sign in to comment.