From 4edcb8e52277e9c8aca5a6f925174fda73f708cf Mon Sep 17 00:00:00 2001 From: Christoph Matthies Date: Tue, 26 Mar 2019 22:47:45 +0100 Subject: [PATCH 01/13] Fix(VMs show): First try to show puppet scripts --- app/controllers/vms_controller.rb | 4 +++- app/views/requests/index.html.erb | 6 ------ app/views/vms/show.html.erb | 27 +++++++++++++++++++++++++++ 3 files changed, 30 insertions(+), 7 deletions(-) diff --git a/app/controllers/vms_controller.rb b/app/controllers/vms_controller.rb index f1bd2365..71cc51b5 100644 --- a/app/controllers/vms_controller.rb +++ b/app/controllers/vms_controller.rb @@ -19,7 +19,9 @@ def index filter_vm_categories current_user unless current_user.admin? end - def show; end + def show + @vm_config = VirtualMachineConfig.find_by_name params[:id] + end def edit_config @vm.ensure_config diff --git a/app/views/requests/index.html.erb b/app/views/requests/index.html.erb index 5282a29b..330a492a 100644 --- a/app/views/requests/index.html.erb +++ b/app/views/requests/index.html.erb @@ -5,12 +5,6 @@ title: 'New VM request', :data => { toggle: 'tooltip', placement: 'bottom' }, class: "btn btn-primary float-right mt-3" %> - <% if current_user.admin? %> - <%= link_to "Templates", request_templates_path, - class: "btn btn-primary float-right mt-3 mr-3" %> - <%= link_to 'Operating Systems', operating_systems_path, - class: 'btn btn-primary float-right mt-3 mr-3' %> - <% end %>

Pending requests

diff --git a/app/views/vms/show.html.erb b/app/views/vms/show.html.erb index efc2b3c4..0d6aff59 100644 --- a/app/views/vms/show.html.erb +++ b/app/views/vms/show.html.erb @@ -135,3 +135,30 @@ end %> + +<% if @vm_config.present? %> + + + +<% end %> From cf20deb48605a642fb337036b60ae73e8c7d1aff Mon Sep 17 00:00:00 2001 From: Christoph Matthies Date: Tue, 26 Mar 2019 22:54:59 +0100 Subject: [PATCH 02/13] Fix(Requests index): Remove puppetscript button --- app/views/requests/index.html.erb | 29 ----------------------------- 1 file changed, 29 deletions(-) diff --git a/app/views/requests/index.html.erb b/app/views/requests/index.html.erb index 330a492a..d8adf97b 100644 --- a/app/views/requests/index.html.erb +++ b/app/views/requests/index.html.erb @@ -52,7 +52,6 @@ Application Name Comment Status - Actions @@ -73,34 +72,6 @@ :data => { toggle: 'tooltip', placement: 'right' }, class: "round #{request.accepted? ? 'bg-success' : 'bg-warning'}" %> - - <% if request.accepted? %> - > - - - <% end %> - <% end %> <%# @resolved_requests&.each %> From ac2406fb365cfb8d2552af5ae8cde1a3f00f9158 Mon Sep 17 00:00:00 2001 From: Christoph Matthies Date: Thu, 4 Apr 2019 11:14:35 +0200 Subject: [PATCH 03/13] Fix(VM Config): Make 'node_script' method public --- app/models/virtual_machine_config.rb | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/app/models/virtual_machine_config.rb b/app/models/virtual_machine_config.rb index 524a3a30..4802ec04 100644 --- a/app/models/virtual_machine_config.rb +++ b/app/models/virtual_machine_config.rb @@ -28,16 +28,20 @@ def sudo_users @sudo_users end - + def users read_users if @users.nil? - + @users end - + def all_users (users + sudo_users + responsible_users).uniq end + + def node_script + Puppetscript.node_script(name, (sudo_users + responsible_users).uniq, all_users) + end private @@ -72,10 +76,6 @@ def commit_message(git_writer) end end - def node_script - Puppetscript.node_script(name, (sudo_users + responsible_users).uniq, all_users) - end - def write_puppetscripts(git_writer, name_script, node_script) git_writer.write_file(Puppetscript.class_file_name(name), name_script) git_writer.write_file(Puppetscript.node_file_name(name), node_script) From 71bbe1ab69d4b542fad85d9f499dcb6997946288 Mon Sep 17 00:00:00 2001 From: Christoph Matthies Date: Thu, 4 Apr 2019 11:15:47 +0200 Subject: [PATCH 04/13] Fix(VMs Show): Puppet Script Modal --- app/views/vms/show.html.erb | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/app/views/vms/show.html.erb b/app/views/vms/show.html.erb index 0d6aff59..e4f5aab5 100644 --- a/app/views/vms/show.html.erb +++ b/app/views/vms/show.html.erb @@ -137,28 +137,38 @@ end %> <% if @vm_config.present? %> - - + -<% if @vm_config.present? %> +<% if @vm.config.present? && current_user.admin? %> @@ -151,17 +151,29 @@ end %> <%# card %>
-
Name Script
+
+ Generated Name Script + + <%= link_to "File in '#{AppSetting.instance.git_repository_name}' repository", + AppSetting.instance.github_base_file_url + Puppetscript.class_file_name(@vm.name) %> + +
<%# card-header %>
<%= Puppetscript.name_script @vm.name %>
-
+ <%# card %>