correction multiple

main
zen 2024-05-01 21:58:14 +02:00
parent 7d6b4393c3
commit dd079ec88f
19 changed files with 308 additions and 163 deletions

View File

@ -1,4 +1,6 @@
class AccountsController < ApplicationController class AccountsController < ApplicationController
before_action :authenticate_user!
before_action :check_group
before_action :set_account, only: %i[ show edit update destroy ] before_action :set_account, only: %i[ show edit update destroy ]
before_action :set_pass, only: %i[ update ] before_action :set_pass, only: %i[ update ]
# GET /accounts or /accounts.json # GET /accounts or /accounts.json
@ -79,4 +81,12 @@ class AccountsController < ApplicationController
def account_params def account_params
params.require(:account).permit(:name, :login, :password, :sshpubkey,:encpassword) params.require(:account).permit(:name, :login, :password, :sshpubkey,:encpassword)
end end
def account_params
params.require(:account).permit(:name, :login, :password, :sshpubkey,:encpassword)
end
def check_group
if current_user.group != "admin"
redirect_back_or_to("/")
end
end
end end

View File

@ -7,51 +7,56 @@ class EngineController < ApplicationController
end end
def generate_boot def generate_boot
if @host if @host
sourceip=request.headers['REMOTE_ADDR'] sourceip=request.headers['X-Forwarded-for']
log=Log.new({source: "#{sourceip}", crit: "info",message: "#{@host.uuid} Request boot script"}) log=Log.new({source: "#{sourceip}", crit: "info",message: "#{@host.uuid}: Request boot script"})
log.save() log.save()
@host.mac = params[:mac] @host.mac = params[:mac]
@host.install_ip = params[:install_ip] @host.install_ip = params[:ip]
boot_script = @host.installtemplate.boot.content @host.access_ip = sourceip
template = @host.installtemplate boot_script = @host.installtemplate.boot.content
@site = @host.site template = @host.installtemplate
host = @host @site = @host.site
@template = @host.installtemplate host = @host
if @host.toinstall @template = @host.installtemplate
@host.update({status: "Computer Booting"}) if @host.toinstall
end @host.update({status: "Computer Booting"})
@api_uri = get_uri(@site)
result = render inline: boot_script, layout: false, content_type: 'text/plain'
@host.update({lastbootgenerated: result})
end end
@script_name = @host.installtemplate.boot.name
@api_uri = get_uri(@site)
result = render inline: boot_script, layout: false, content_type: 'text/plain'
@host.update({lastbootgenerated: result})
end end
end
def generate_install def generate_install
if @host if @host
sourceip=request.headers['REMOTE_ADDR'] sourceip=request.headers['X-Forwarded-for']
log=Log.new({source: "#{sourceip}", crit: "info",message: "#{@host.uuid} Request Install script"}) log=Log.new({source: "#{sourceip}", crit: "info",message: "#{@host.hostname},UUDI:#{@host.uuid}: Request Install script"})
log.save() log.save()
script = @host.installtemplate.install.content script = @host.installtemplate.install.content
template = @host.installtemplate template = @host.installtemplate
@site = @host.site @site = @host.site
@template = @host.installtemplate @template = @host.installtemplate
host = @host host = @host
@host.access_ip = "#{sourceip}"
@host.update({status: "System Install"}) @host.update({status: "System Install"})
@script_name = @host.installtemplate.boot.name
@api_uri = get_uri(@site) @api_uri = get_uri(@site)
result = render inline: script, layout: false, content_type: 'text/plain' result = render inline: script, layout: false, content_type: 'text/plain'
@host.update({lastinstallgenerated: result}) @host.update({lastinstallgenerated: result})
else else
log=Log.new({source: "#{sourceip}", crit: "info",message: "Request Install script"}) log=Log.new({source: sourceip, crit: "info",message: "#{@host.hostname},UUDI:#{@host.uuid}: Error on Request Install script"})
log.save() log.save()
end end
end end
def generate_postinstall def generate_postinstall
if @host if @host
sourceip=request.headers['REMOTE_ADDR'] sourceip=request.headers['X-Forwarded-for']
log=Log.new({source: "#{sourceip}", crit: "info",message: "#{@host.uuid} Request Postinstall script"}) log=Log.new({source: sourceip, crit: "info",message: "#{@host.hostname},UUDI:#{@host.uuid}: Request Postinstall script"})
log.save() log.save()
@host.access_ip = "#{sourceip}"
@host.update({status: "System Post Install"}) @host.update({status: "System Post Install"})
script = @host.installtemplate.postinstall.content script = @host.installtemplate.postinstall.content
template = @host.installtemplate template = @host.installtemplate
@ -59,6 +64,7 @@ class EngineController < ApplicationController
@site = @host.site @site = @host.site
host = @host host = @host
@template = @host.installtemplate @template = @host.installtemplate
@script_name = @host.installtemplate.boot.name
@api_uri = get_uri(@site) @api_uri = get_uri(@site)
result = render inline: script, layout: false, content_type: 'text/plain' result = render inline: script, layout: false, content_type: 'text/plain'
@host.update({lastpostinstallgenerated: result}) @host.update({lastpostinstallgenerated: result})
@ -66,10 +72,10 @@ class EngineController < ApplicationController
end end
def generate_installed def generate_installed
sourceip=request.headers['REMOTE_ADDR'] sourceip=request.headers['X-Forwarded-for']
log=Log.new({source: "#{sourceip}", crit: "info",message: "#{@host.uuid} Install Finished."}) log=Log.new({source: sourceip, crit: "info",message: "#{@host.hostname},UUDI:#{@host.uuid}: Send install Finished."})
log.save() log.save()
if @host.update({status: "Installation Finish", installed: true, toinstall: false, interface: params[:interface],ip: params[:install_ip]}) if @host.update({status: "Installation Finish", installed: true, toinstall: false, interface: params[:interface],ip: params[:ip],access_ip: sourceip})
render plain: "ok" render plain: "ok"
else else
render json: @host.errors render json: @host.errors
@ -78,10 +84,10 @@ class EngineController < ApplicationController
def update_info def update_info
@host = Host.find_by(uuid: params[:uuid]) @host = Host.find_by(uuid: params[:uuid])
sourceip=request.headers['REMOTE_ADDR'] sourceip=request.headers['X-Forwarded-for']
log=Log.new({source: "#{sourceip}", crit: "info",message: "#{@host.uuid} update info."}) log=Log.new({source: sourceip, crit: "info",message: "#{@host.hostname},UUDI:#{@host.uuid}: Send refresh informations."})
log.save() log.save()
if @host.update({interface: params[:interface],ip: params[:ip], hostname: params[:hostname], access_ip: "#{sourceip}"}) if @host.update({interface: params[:interface],ip: params[:ip], hostname: params[:hostname], access_ip: sourceip})
render plain: "ok" render plain: "ok"
else else
render json: @host.errors render json: @host.errors
@ -95,14 +101,13 @@ class EngineController < ApplicationController
end end
def generate_file def generate_file
sourceip=request.headers['REMOTE_ADDR'] sourceip=request.headers['X-Forwarded-for']
log=Log.new({source: "#{sourceip}", crit: "info",message: "Request #{params[:filename]}"}) log=Log.new({source: sourceip, crit: "info",message: "#{@host.hostname},UUDI:#{@host.uuid}: Request ressource #{params[:filename]}"})
log.save() log.save()
if @host if @host
script = Script.find_by({name: params[:filename], stage: "ressource"}) script = Script.find_by({name: params[:filename], stage: "ressource"})
@site = @host.site @site = @host.site
@template = @host.installtemplate @template = @host.installtemplate
host = @host
@api_uri = get_uri(@site) @api_uri = get_uri(@site)
result = render inline: script.content, layout: false, content_type: 'text/plain' result = render inline: script.content, layout: false, content_type: 'text/plain'
end end
@ -112,18 +117,19 @@ class EngineController < ApplicationController
def set_host_by_uuid def set_host_by_uuid
@host = Host.find_by(uuid: params[:uuid]) @host = Host.find_by(uuid: params[:uuid])
if ! @host if ! @host
logger.debug "> NEW HOST DETECTED !!!" sourceip=request.headers['X-Forwarded-for']
sourceip=request.headers['REMOTE_ADDR'] log=Log.new({source: sourceip, crit: "warning",message: "New host with uuid #{params[:uuid]} Detected."})
log=Log.new({source: "#{sourceip}", crit: "warning",message: "New host with uuid #{params[:uuid]} Detected."}) log.save()
log.save() log=Log.new({source: "Engine", crit: "info",message: "Generate default configuration for #{params[:uuid]} requested from #{sourceip}."})
@template = Installtemplate.find_by(name:"default") log.save()
@site = Site.find_by(name:"default") @template = Installtemplate.find_by(name:"default")
@account = Account.find_by(name:"default") @site = Site.find_by(name:"default")
# Generate random lusk key @account = Account.find_by(name:"default")
random_string=SecureRandom.urlsafe_base64(24) # Generate random lusk key
# Create new host random_string=SecureRandom.urlsafe_base64(24)
@host = Host.new(hostname: "New host detected",uuid: params["uuid"], install_ip: params["ip"], installtemplate: @template,site: @site, mac: params["mac"], status: "discover", discover: true,installed: false, toinstall: false,rootaccount: @account, mainaccount: @account, product: params["p"], serial: params["s"], lusk_key: random_string) # Create new host
@host.save! @host = Host.new(hostname: "New host detected",uuid: params["uuid"], install_ip: params["ip"], access_ip: sourceip,installtemplate: @template,site: @site, mac: params["mac"], status: "discover", discover: true,installed: false, toinstall: false,rootaccount: @account, mainaccount: @account, product: params["p"], serial: params["s"], lusk_key: random_string)
@host.save!
end end
end end
# Only allow a list of trusted parameters through. # Only allow a list of trusted parameters through.

View File

@ -1,5 +1,6 @@
class HostsController < ApplicationController class HostsController < ApplicationController
before_action :authenticate_user! before_action :authenticate_user!
before_action :check_group
before_action :set_host, only: %i[ show edit update destroy ] before_action :set_host, only: %i[ show edit update destroy ]
before_action :set_host_by_uuid, only: %i[ generate_boot generate_install generate_postinstall generate_metadata ] before_action :set_host_by_uuid, only: %i[ generate_boot generate_install generate_postinstall generate_metadata ]
@ -40,7 +41,7 @@ class HostsController < ApplicationController
def update def update
puts host_params puts host_params
respond_to do |format| respond_to do |format|
log=Log.new({source: "admin", crit: "info",message: "User xxx update #{host_params[:hostname]}"}) log=Log.new({source: "host", crit: "info",message: "User #{current_user.name}, Update #{host_params[:hostname]}"})
log.save() log.save()
if @host.update(host_params) if @host.update(host_params)
format.html { redirect_to host_url(@host), notice: "Host was successfully updated." } format.html { redirect_to host_url(@host), notice: "Host was successfully updated." }
@ -148,4 +149,9 @@ class HostsController < ApplicationController
def host_params def host_params
params.require(:host).permit(:uuid, :hostname, :ip, :install_ip,:access_ip,:status, :mac, :discover, :installed, :interface , :installtemplate, :site , :installtemplate_id, :site_id, :rootaccount_id, :mainaccount_id,:toinstall, :lusk_key,:lusk_device, :lusk_encrypt, :host_device,:lang) params.require(:host).permit(:uuid, :hostname, :ip, :install_ip,:access_ip,:status, :mac, :discover, :installed, :interface , :installtemplate, :site , :installtemplate_id, :site_id, :rootaccount_id, :mainaccount_id,:toinstall, :lusk_key,:lusk_device, :lusk_encrypt, :host_device,:lang)
end end
def check_group
if current_user.group != "admin"
redirect_back_or_to("/")
end
end
end end

View File

@ -1,6 +1,7 @@
class InstalltemplatesController < ApplicationController class InstalltemplatesController < ApplicationController
before_action :authenticate_user! before_action :authenticate_user!
before_action :set_installtemplate, only: %i[ show edit update destroy ] before_action :set_installtemplate, only: %i[ show edit update destroy ]
before_action :check_group
# GET /installtemplates or /installtemplates.json # GET /installtemplates or /installtemplates.json
def index def index
@ -68,4 +69,9 @@ class InstalltemplatesController < ApplicationController
def installtemplate_params def installtemplate_params
params.require(:installtemplate).permit(:name, :ostype, :osversion, :repository, :nfsroot, :kernel, :initrd, :rootfile, :boot_id, :install_id, :postinstall_id, :lang) params.require(:installtemplate).permit(:name, :ostype, :osversion, :repository, :nfsroot, :kernel, :initrd, :rootfile, :boot_id, :install_id, :postinstall_id, :lang)
end end
def check_group
if current_user.group != "admin"
redirect_back_or_to("/")
end
end
end end

View File

@ -1,5 +1,7 @@
class LogsController < ApplicationController class LogsController < ApplicationController
before_action :authenticate_user! before_action :authenticate_user!
before_action :check_group
before_action :set_log, only: %i[ show edit update destroy ] before_action :set_log, only: %i[ show edit update destroy ]
# GET /logs or /logs.json # GET /logs or /logs.json
@ -72,4 +74,9 @@ class LogsController < ApplicationController
def log_params def log_params
params.require(:log).permit(:source, :crit, :message) params.require(:log).permit(:source, :crit, :message)
end end
def check_group
if current_user.group != "admin"
redirect_back_or_to("/")
end
end
end end

View File

@ -1,5 +1,11 @@
class PagesController < ApplicationController class PagesController < ApplicationController
before_action :authenticate_user!
def index def index
@hostslist = Host.all @hostslist = Host.all
end end
def check_group
if current_user.group != "admin"
redirect_back_or_to("/")
end
end
end end

View File

@ -1,5 +1,6 @@
class ScriptsController < ApplicationController class ScriptsController < ApplicationController
before_action :authenticate_user! before_action :authenticate_user!
before_action :check_group
before_action :set_script, only: %i[ show edit update destroy ] before_action :set_script, only: %i[ show edit update destroy ]
@ -24,7 +25,8 @@ class ScriptsController < ApplicationController
# POST /scripts or /scripts.json # POST /scripts or /scripts.json
def create def create
@script = Script.new(script_params) @script = Script.new(script_params)
log=Log.new({source: "Script", crit: "info",message: "User #{current_user.name}, Create #{script_params[:stage]} Script #{script_params[:name]}"})
log.save()
respond_to do |format| respond_to do |format|
if @script.save if @script.save
format.html { redirect_to script_url(@script), notice: "Script was successfully created." } format.html { redirect_to script_url(@script), notice: "Script was successfully created." }
@ -39,6 +41,8 @@ class ScriptsController < ApplicationController
# PATCH/PUT /scripts/1 or /scripts/1.json # PATCH/PUT /scripts/1 or /scripts/1.json
def update def update
respond_to do |format| respond_to do |format|
log=Log.new({source: "Script", crit: "info",message: "User #{current_user.name}, Update #{script_params[:stage]} Script #{script_params[:name]}"})
log.save()
if @script.update(script_params) if @script.update(script_params)
format.html { redirect_to script_url(@script), notice: "Script was successfully updated." } format.html { redirect_to script_url(@script), notice: "Script was successfully updated." }
format.json { render :show, status: :ok, location: @script } format.json { render :show, status: :ok, location: @script }
@ -52,7 +56,8 @@ class ScriptsController < ApplicationController
# DELETE /scripts/1 or /scripts/1.json # DELETE /scripts/1 or /scripts/1.json
def destroy def destroy
@script.destroy! @script.destroy!
log=Log.new({source: "Script", crit: "warning",message: "User #{current_user.name}, Delete #{script_params[:stage]} Script #{script_params[:name]}"})
log.save()
respond_to do |format| respond_to do |format|
format.html { redirect_to scripts_url, notice: "Script was successfully destroyed." } format.html { redirect_to scripts_url, notice: "Script was successfully destroyed." }
format.json { head :no_content } format.json { head :no_content }
@ -69,4 +74,9 @@ class ScriptsController < ApplicationController
def script_params def script_params
params.require(:script).permit(:name, :stage, :lang, :content, :lock, :description) params.require(:script).permit(:name, :stage, :lang, :content, :lock, :description)
end end
def check_group
if current_user.group != "admin"
redirect_back_or_to("/")
end
end
end end

View File

@ -1,5 +1,7 @@
class SitesController < ApplicationController class SitesController < ApplicationController
before_action :authenticate_user! before_action :authenticate_user!
before_action :check_group
before_action :set_site, only: %i[ show edit update destroy ] before_action :set_site, only: %i[ show edit update destroy ]
# GET /sites or /sites.json # GET /sites or /sites.json
@ -69,5 +71,11 @@ class SitesController < ApplicationController
params.require(:site).permit(:name, :domain, :gateway, :nameserver, :network, :netmask, :api_ip, :api_port, :api_url, :fileserver_uri, :fileserver_basepath, :timezone, :apiurl, :cfenginehub, :nfsserver_path, :country) params.require(:site).permit(:name, :domain, :gateway, :nameserver, :network, :netmask, :api_ip, :api_port, :api_url, :fileserver_uri, :fileserver_basepath, :timezone, :apiurl, :cfenginehub, :nfsserver_path, :country)
end end
def check_group
if current_user.group != "admin"
redirect_back_or_to("/")
end
end
end end

View File

@ -8,6 +8,7 @@ class User
## Database authenticatable ## Database authenticatable
field :email, type: String, default: "" field :email, type: String, default: ""
field :encrypted_password, type: String, default: "" field :encrypted_password, type: String, default: ""
field :name, type: String, default: ""
## Recoverable ## Recoverable
field :reset_password_token, type: String field :reset_password_token, type: String
@ -33,5 +34,6 @@ class User
# field :failed_attempts, type: Integer, default: 0 # Only if lock strategy is :failed_attempts # field :failed_attempts, type: Integer, default: 0 # Only if lock strategy is :failed_attempts
# field :unlock_token, type: String # Only if unlock strategy is :email or :both # field :unlock_token, type: String # Only if unlock strategy is :email or :both
# field :locked_at, type: Time # field :locked_at, type: Time
field :group, type: String, default: ""
include Mongoid::Timestamps include Mongoid::Timestamps
end end

View File

@ -6,7 +6,6 @@
<div class="field"> <div class="field">
<%= f.email_field :email, autofocus: true, autocomplete: "email" , class: "input is-small" , placeholder: :email %> <%= f.email_field :email, autofocus: true, autocomplete: "email" , class: "input is-small" , placeholder: :email %>
</div> </div>
<div class="field"> <div class="field">
<%= f.password_field :password, autocomplete: "current-password" ,class: "input is-small" , placeholder: :password%> <%= f.password_field :password, autocomplete: "current-password" ,class: "input is-small" , placeholder: :password%>
</div> </div>

View File

@ -1,4 +1,3 @@
<%# _form.html.erb %>
<div class="columns"> <div class="columns">
<div class="column"> <div class="column">
<div class="box"> <div class="box">
@ -109,7 +108,7 @@
<div class="field-body"> <div class="field-body">
<div class="field"> <div class="field">
<div class="control"> <div class="control">
<%= form.text_field :install_ip , { class: "input"} %> <%= form.text_field :install_ip , { class: "input", disabled: true } %>
</div> </div>
<p class="help">Ip during install of host, Refered by @host.install_ip in script</p> <p class="help">Ip during install of host, Refered by @host.install_ip in script</p>
</div> </div>
@ -123,7 +122,7 @@
<div class="field-body"> <div class="field-body">
<div class="field"> <div class="field">
<div class="control"> <div class="control">
<%= form.text_field :status , { class: "input"} %> <%= form.text_field :status , { class: "input" , disabled: true } %>
</div> </div>
<p class="help">Host status, Refered by @host.status in script</p> <p class="help">Host status, Refered by @host.status in script</p>
</div> </div>
@ -137,7 +136,7 @@
<div class="field-body"> <div class="field-body">
<div class="field"> <div class="field">
<div class="control"> <div class="control">
<%= form.text_field :mac , { class: "input"} %> <%= form.text_field :mac , { class: "input", disabled: true } %>
</div> </div>
<p class="help">MAc Adress, Refered by @host.mac in script</p> <p class="help">MAc Adress, Refered by @host.mac in script</p>
</div> </div>
@ -171,7 +170,7 @@
</div> </div>
<div class="control"> <div class="control">
<%= form.label :lusk_key, class: "label is-small" %> <%= form.label :lusk_key, class: "label is-small" %>
<%= form.text_field :lusk_key , { class: "input"} %> <%= form.text_field :lusk_key , { class: "input", disabled: true } %>
<p class="help">Lusk encrypt key, Refered by @host.lusk_key in script</p> <p class="help">Lusk encrypt key, Refered by @host.lusk_key in script</p>
</div> </div>

View File

@ -1,69 +1,120 @@
<div class="card" id="<%= dom_id host %>"> <p style="color: green"><%= notice %></p>
<header class="card-header"> <div class="columns">
<p class="card-header-title"> <div class="column">
<%= host.hostname %>
</p>
<button class="card-header-icon" aria-label="more options">
<span class="icon">
<i class="fas fa-angle-down" aria-hidden="true"></i>
</span>
</button>
</header>
<div class="card-content">
<div class="content">
<p>
<strong>Ip:</strong>
<%= host.ip %>
</p>
<p> <div class="box">
<strong>Status:</strong> <% if @host.errors.any? %>
<%= host.status %> <div style="color: red">
</p> <h2><%= pluralize(@host.errors.count, "error") %> prohibited this host from being saved:</h2>
<ul>
<% @host.errors.each do |error| %>
<li><%= error.full_message %></li>
<% end %>
</ul>
</div>
<% end %>
<p>
<strong>Mac:</strong>
<%= host.mac %>
</p>
<p> <div id="<%= dom_id @host %>">
<strong>Discover:</strong> <p>
<%= host.discover %> <strong>Hostname:</strong>
</p> <%= @host.hostname %>
</p>
<p> <p>
<strong>Installed:</strong> <strong>UUID:</strong>
<%= host.installed %> <%= @host.uuid %>
</p> </p>
<p>
<strong>Serial:</strong>
<%= @host.product %>
</p>
<p>
<strong>Serial:</strong>
<%= @host.serial %>
</p>
<p>
<strong>MAC:</strong>
<%= @host.mac %>
</p>
<p>
<strong>Interface:</strong>
<%= @host.interface %>
</p>
<p>
<strong>IP:</strong>
<%= @host.ip %>
</p>
<p>
<strong>IP Access:</strong>
<%= @host.access_ip %>
</p>
<p>
<strong>Install IP:</strong>
<%= @host.install_ip %>
</p>
<p>
<strong>Status:</strong>
<%= @host.status %>
</p>
<p>
<strong>Device:</strong>
<%= @host.host_device %>
</p>
<p>
<strong>Lusk Encryption:</strong>
<%= @host.lusk_encrypt %>
</p>
<p>
<strong>Lusk Device to Encrypt:</strong>
<%= @host.lusk_device %>
</p>
<p>
<strong>Lusk Key:</strong>
<%= @host.lusk_key %>
</p>
<p> <p>
<strong>Interface:</strong> <strong>Site</strong>
<%= host.interface %> <%= @host.site.name %>
</p> </p>
<p> <p>
<strong>Install Template:</strong> <strong>Lang</strong>
<% if defined?host.installtemplate.name %> <%= @host.lang %>
<%= host.installtemplate.name %> </p>
<% else %>
not set
<% end %>
</p>
<p> <p>
<strong>Site:</strong> <strong>Root Account</strong>
<% if defined?host.site.name %> <%= @host.rootaccount.name %>
<%= host.site.name %> </p>
<% else %>
not set <p>
<% end %> <strong>Main Account</strong>
</p> <%= @host.mainaccount.name %>
</p>
<p>
<strong>Discover</strong>
<%= @host.discover %>
</p>
<p>
<strong>Installed</strong>
<%= @host.installed %>
</p>
<p>
<strong>Toinstall</strong>
<%= @host.toinstall %>
</p>
</div>
<div class="buttons has-addons">
<%= button_to "Edit Host", edit_host_path(@host), method: :get, class: "button is-small is-primary" %>
<%= button_to "Edit Template",edit_installtemplate_path(@host.installtemplate_id), method: :get, class: "button is-small is-primary", form: {target: '_blank'}%></tr>
<%= button_to "Edit Boot", edit_script_path(@host.installtemplate.boot), method: :get, class: "button is-small is-primary" %>
<%= button_to "Edit Install", edit_script_path(@host.installtemplate.install), method: :get, class: "button is-small is-primary" %>
<%= button_to "Edit Post Install", edit_script_path(@host.installtemplate.postinstall), method: :get, class: "button is-small is-primary" %>
</div>
</div> </div>
</div> </div>
<button class="button">
<%= link_to "Edit this host", edit_host_path(host) %>
</button>
</div> </div>

View File

@ -1,9 +1,20 @@
<tr> <tr>
<td><%= host.hostname %></td> <td><%= host.hostname %></td>
<td><%= host.status %></td> <td><span class="tag is-info"><%= host.status %></span></td>
<td><%= host.installtemplate.name %></td> <td><%= host.installtemplate.name %></td>
<td><%= button_to "Edit", edit_host_path(host), method: :get, class: "button is-small is-primary" %></td> <td>
<td><button id=<%= host.uuid %> class="getIpxeScript button is-small is-primary">IPXE</button></td> <div class="buttons has-addons">
<td><button id=<%= host.uuid %> class="getInstallScript button is-small is-primary">Install</button></td> <%= button_to "View", host_path(host), method: :get, class: "button is-small is-success"%>
<td><button id=<%= host.uuid %> class="getPostinstallScript button is-small is-primary">Postinstall</button></td> <%= button_to "Edit", edit_host_path(host), method: :get, class: "button is-small is-primary" %>
<%= button_to "Delete", host_path(host), method: :delete, class: "button is-small is-danger" %>
</div>
</td>
<td>
<div class="buttons has-addons">
<button id=<%= host.uuid %> class="getIpxeScript button is-small is-primary">IPXE</button>
<button id=<%= host.uuid %> class="getInstallScript button is-small is-primary">Install</button>
<button id=<%= host.uuid %> class="getPostinstallScript button is-small is-primary">Postinstall</button>
</div>
</td>
</tr> </tr>

View File

@ -8,20 +8,22 @@
<th colspan="1">Hostname</th> <th colspan="1">Hostname</th>
<th colspan="1">Status</th> <th colspan="1">Status</th>
<th colspan="1">Template</th> <th colspan="1">Template</th>
<th colspan="1"></th> <th colspan="1">Action</th>
<th colspan="1">View Generated Script</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<% @hosts.each do |host| %> <% @hosts.each do |host| %>
<%= render :partial => 'hostraw', :locals => { :host => host} %> <%= render :partial => 'hostraw', :locals => { :host => host} %>
<% end %> <% end %>
</tbody> </tbody>
</table> </table>
<div id="script_div">
<h2>Render</h2>
<pre style="overflow:scroll; max-height:500px" id="script_result">
</pre>
</div>
</div> </div>
<div id="script_div">
<h2>Render</h2>
<pre style="overflow:scroll; max-height:500px" id="script_result">
</pre>
</div>

View File

@ -1,12 +1,9 @@
<section> <section>
<p style="color: green"><%= notice %></p> <p style="color: green"><%= notice %></p>
</section> </section>
<section>
<%= render @host %> <%= render @host %>
</section>
<div> <section>
<button class="button"> <%= link_to "Back to hosts", "/hosts", class: "button is-success is-small is-pulled-left" %>
<%= link_to "Back to hosts", hosts_path %> </section>
</button>
</div>

View File

@ -48,8 +48,10 @@
<div class="navbar-item"> <div class="navbar-item">
<div class="buttons"> <div class="buttons">
<% if !user_signed_in? %> <% if !user_signed_in? %>
>
<%= link_to "Login", new_user_session_path, class: "button is-light" %> <%= link_to "Login", new_user_session_path, class: "button is-light" %>
<% else %> <% else %>
<h1>Bonjour <%= current_user.name %></h2>
<%= link_to "Profil", edit_user_registration_path, class: "button is-light" %> <%= link_to "Profil", edit_user_registration_path, class: "button is-light" %>
<%= button_to "Logout", destroy_user_session_path, method: :delete, class: "button is-light" %> <%= button_to "Logout", destroy_user_session_path, method: :delete, class: "button is-light" %>
<% end %> <% end %>
@ -58,6 +60,3 @@
</div> </div>
</div> </div>
</nav> </nav>

View File

@ -17,6 +17,8 @@
<div class="control"> <div class="control">
<%= form.text_field :name , { class: "input"} %> <%= form.text_field :name , { class: "input"} %>
</div> </div>
<p class="help">Name of script (@script.name )</p>
</div> </div>
<div class="field is-grouped"> <div class="field is-grouped">
@ -25,38 +27,44 @@
<div class="control"> <div class="control">
<%= form.text_field :stage , { class: "input"} %> <%= form.text_field :stage , { class: "input"} %>
</div> </div>
</div> <p class="help">Stage of script [boot,install,postinstall, ressources](@script.stage )</p>
</div>ma
<div class="field"> <div class="field">
<label class="label">Lang</label> <label class="label">Lang</label>
<div class="control"> <div class="control">
<%= form.text_field :lang , { class: "input"} %> <%= form.text_field :lang , { class: "input"} %>
</div> </div>
<p class="help">Langage of script (ipxe,preseed, yaml,bash ...)(@script.lang )</p>
</div> </div>
</div> </div>
<div class="field"> <div class="field">
<div> <div>
<label class="label">Content</label> <label class="label">Content</label>
<textarea class="textarea" name="script[content]" id="script_content" rows="15"><%= script.content %></textarea> <% if script.lock == true %>
<textarea disabled class="textarea" name="script[content]" id="script_content" rows="15"><%= script.content %></textarea>
<% else %>
<textarea class="textarea" name="script[content]" id="script_content" rows="15"><%= script.content %></textarea>
<% end %>
</div> </div>
<p class="help">Script himself (@script.content )</p>
</div> </div>
<div class="control"> <div class="control">
<label class="checkbox"> <%= form.label :lock, class: "checkbox" %>
<% if script.lock %> <%= form.check_box :lock %>
<input type="checkbox" name="script[lock]", id="script_lock", checked> </div>
<% else %>
<input type="checkbox" name="script[lock]", id="script_lock">
<% end %>
Lock
</label>
</div>
<div class="control">
<div class="field"> <div class="field">
<div> <div>
<label class="label">Description</label> <label class="label">Description</label>
<textarea class="textarea" name="script[description]" id="script_description" rows="2"><%= script.description %></textarea> <textarea class="textarea readonly" name="script[description]" id="script_description" rows="2"><%= script.description %></textarea>
</div> </div>
</div> </div>
@ -66,4 +74,4 @@
</div> </div>
<% end %> <% end %>
</div> </div>
<%= button_to "Destroy", @script, method: :delete, class: "button is-danger" %> <%= button_to "Delete", script_path( @script), method: :delete, class: "button is-small is-danger" %>

View File

@ -5,12 +5,16 @@
<%= form.text_field :name , { class: "input"} %> <%= form.text_field :name , { class: "input"} %>
</div> </div>
</div> </div>
<p class="help">Site name, Refered by @site.name in script</p>
<div class="field is-grouped"> <div class="field is-grouped">
<div class="field"> <div class="field">
<label class="label">Domain</label> <label class="label">Domain</label>
<div class="control"> <div class="control">
<%= form.text_field :domain , { class: "input"} %> <%= form.text_field :domain , { class: "input"} %>
</div> </div>
<p class="help">Site dns domain (@site.domain)</p>
</div> </div>
<div class="field"> <div class="field">
@ -18,6 +22,7 @@
<div class="control"> <div class="control">
<%= form.text_field :gateway , { class: "input"} %> <%= form.text_field :gateway , { class: "input"} %>
</div> </div>
<p class="help">Site Gateway (@site.gateway)</p>
</div> </div>
<div class="field"> <div class="field">
@ -25,6 +30,8 @@
<div class="control"> <div class="control">
<%= form.text_field :nameserver , { class: "input"} %> <%= form.text_field :nameserver , { class: "input"} %>
</div> </div>
<p class="help">Site Nameserver (@site.nameserver)</p>
</div> </div>
</div> </div>
<div class="field is-grouped"> <div class="field is-grouped">
@ -33,27 +40,24 @@
<div class="control"> <div class="control">
<%= form.text_field :network , { class: "input"} %> <%= form.text_field :network , { class: "input"} %>
</div> </div>
<p class="help">Site Network (@site.network)</p>
</div> </div>
<div class="field"> <div class="field">
<label class="label">Netmask</label> <label class="label">Netmask</label>
<div class="control"> <div class="control">
<%= form.text_field :netmask , { class: "input"} %> <%= form.text_field :netmask , { class: "input"} %>
</div> </div>
<p class="help">Site Netmask (@site.netmask)</p>
</div> </div>
</div> </div>
<div class="field">
<%= form.label :api_url, class: "label" %>
<div class="control">
<%= form.text_field :api_url , { class: "input"} %>
</div>
</div>
<div class="field"> <div class="field">
<%= form.label :nfsserver_path, class: "label" %> <%= form.label :nfsserver_path, class: "label" %>
<div class="control"> <div class="control">
<%= form.text_field :nfsserver_path , { class: "input"} %> <%= form.text_field :nfsserver_path , { class: "input"} %>
</div> </div>
<p class="help">Site nfs server path (@site.nfsserver_path)</p>
</div> </div>
@ -63,6 +67,7 @@
<div class="control"> <div class="control">
<%= form.text_field :api_ip , { class: "input"} %> <%= form.text_field :api_ip , { class: "input"} %>
</div> </div>
<p class="help">Api ip (@site.api_ip)</p>
</div> </div>
<div class="field"> <div class="field">
@ -70,14 +75,18 @@
<div class="control"> <div class="control">
<%= form.text_field :api_port , { class: "input"} %> <%= form.text_field :api_port , { class: "input"} %>
</div> </div>
<p class="help">Api port (@site.api_ip)</p>
</div> </div>
<div class="field"> <div class="field">
<label class="label">api_url</label> <label class="label">api_url</label>
<div class="control"> <div class="control">
<%= form.text_field :api_url , { class: "input"} %> <%= form.text_field :api_url , { class: "input"} %>
</div>
<p class="help">Api url (@site.api_url) ( if defined, replace acces by ip:port )</p>
<p class="help">Generique Api access is @site.api_uri ( if api_url is defined = @site.api_url else = http://site.api_ip:site.api.port )</p>
</div> </div>
</div> </div>
</div>
<div class="field is-grouped"> <div class="field is-grouped">
<div class="field"> <div class="field">
@ -85,14 +94,17 @@
<div class="control"> <div class="control">
<%= form.text_field :fileserver_uri , { class: "input"} %> <%= form.text_field :fileserver_uri , { class: "input"} %>
</div> </div>
</div> <p class="help">Web server with local content to download ( kernel, isos ..) (@site.fileserver_uri )</p>
</div>
<div class="field"> <div class="field">
<label class="label">fileserver_basepath</label> <label class="label">fileserver_basepath</label>
<div class="control"> <div class="control">
<%= form.text_field :fileserver_basepath , { class: "input"} %> <%= form.text_field :fileserver_basepath , { class: "input"} %>
</div> </div>
<p class="help">Content directory on local webserver (@site.fileserver_basepath )</p>
</div> </div>
</div> </div>
@ -101,6 +113,8 @@
<div class="control"> <div class="control">
<%= form.text_field :cfenginehub , { class: "input"} %> <%= form.text_field :cfenginehub , { class: "input"} %>
</div> </div>
<p class="help">cfengine url (@site.cfenginehub )</p>
</div> </div>
<%= link_to "Goto cfengine hub", "http://#{@site.cfenginehub}", class: "button is-info", :target => "_blank" %> <%= link_to "Goto cfengine hub", "http://#{@site.cfenginehub}", class: "button is-info", :target => "_blank" %>
@ -110,6 +124,8 @@
<div class="control"> <div class="control">
<%= form.text_field :country , { class: "input"} %> <%= form.text_field :country , { class: "input"} %>
</div> </div>
<p class="help">Country of site (@site.country )</p>
</div> </div>
<div class="field"> <div class="field">
@ -117,6 +133,8 @@
<div class="control"> <div class="control">
<%= form.text_field :timezone , { class: "input"} %> <%= form.text_field :timezone , { class: "input"} %>
</div> </div>
<p class="help">Timezone of site (@site.timezone )</p>
</div> </div>
<div class="control"> <div class="control">