diff --git a/README.MD b/README.MD index 4098a10..bab557c 100644 --- a/README.MD +++ b/README.MD @@ -213,3 +213,71 @@ bin/rails g scaffold Script name:string stage:string lang:string content:text lo bin/rails g scaffold Site name:string domain:string gateway:string nameserver:string network:string netmask:string bin/rails s -b 0.0.0.0 + +# Add devise +``` +root@autogen:/usr/src/autogen# bundle add devise +``` + +``` +Fetching gem metadata from https://rubygems.org/......... +Resolving dependencies... +Fetching gem metadata from https://rubygems.org/......... +Resolving dependencies... +``` +``` +root@autogen:/usr/src/autogen# rails generate devise:install +``` +``` + create config/initializers/devise.rb + create config/locales/devise.en.yml +=============================================================================== + +Depending on your application's configuration some manual setup may be required: + + 1. Ensure you have defined default url options in your environments files. Here + is an example of default_url_options appropriate for a development environment + in config/environments/development.rb: + + config.action_mailer.default_url_options = { host: 'localhost', port: 3000 } + + In production, :host should be set to the actual host of your application. + + * Required for all applications. * + + 2. Ensure you have defined root_url to *something* in your config/routes.rb. + For example: + + root to: "home#index" + + * Not required for API-only Applications * + + 3. Ensure you have flash messages in app/views/layouts/application.html.erb. + For example: + +

<%= notice %>

+

<%= alert %>

+ + * Not required for API-only Applications * + + 4. You can copy Devise views (for customization) to your app by running: + + rails g devise:views + + * Not required * + +=============================================================================== +``` +``` +root@autogen:/usr/src/autogen# rails generate devise User +``` +``` + invoke mongoid + create app/models/user.rb + invoke test_unit + create test/models/user_test.rb + create test/fixtures/users.yml + insert app/models/user.rb + insert app/models/user.rb + route devise_for :users +``` \ No newline at end of file diff --git a/src/autogen/Gemfile b/src/autogen/Gemfile index c7ad3d1..3f5a875 100644 --- a/src/autogen/Gemfile +++ b/src/autogen/Gemfile @@ -68,3 +68,5 @@ gem "mongoid", "~> 8.1" gem "bulma-rails", "~> 0.9.4" gem "jquery-rails", "~> 4.6" + +gem "devise", "~> 4.9" diff --git a/src/autogen/Gemfile.lock b/src/autogen/Gemfile.lock index 2472ecf..aefe4ff 100644 --- a/src/autogen/Gemfile.lock +++ b/src/autogen/Gemfile.lock @@ -78,6 +78,7 @@ GEM addressable (2.8.6) public_suffix (>= 2.0.2, < 6.0) base64 (0.2.0) + bcrypt (3.1.20) bigdecimal (3.1.6) bindex (0.8.1) bootsnap (1.18.3) @@ -104,6 +105,12 @@ GEM debug (1.9.1) irb (~> 1.10) reline (>= 0.3.8) + devise (4.9.3) + bcrypt (~> 3.0) + orm_adapter (~> 0.1) + railties (>= 4.1.0) + responders + warden (~> 1.2.3) drb (2.2.0) ruby2_keywords erubi (1.12.0) @@ -170,6 +177,7 @@ GEM racc (~> 1.4) nokogiri (1.16.2-x86_64-linux) racc (~> 1.4) + orm_adapter (0.5.0) psych (5.1.2) stringio public_suffix (5.0.4) @@ -219,6 +227,9 @@ GEM regexp_parser (2.9.0) reline (0.4.2) io-console (~> 0.5) + responders (3.1.1) + actionpack (>= 5.2) + railties (>= 5.2) rexml (3.2.6) ruby2_keywords (0.0.5) rubyzip (2.3.2) @@ -247,6 +258,8 @@ GEM railties (>= 6.0.0) tzinfo (2.0.6) concurrent-ruby (~> 1.0) + warden (1.2.9) + rack (>= 2.0.9) web-console (4.2.1) actionview (>= 6.0.0) activemodel (>= 6.0.0) @@ -275,6 +288,7 @@ DEPENDENCIES capybara cssbundling-rails debug + devise (~> 4.9) importmap-rails jbuilder jquery-rails (~> 4.6) diff --git a/src/autogen/app/assets/javascript/apicall.js b/src/autogen/app/assets/javascript/apicall.js new file mode 100644 index 0000000..90bc813 --- /dev/null +++ b/src/autogen/app/assets/javascript/apicall.js @@ -0,0 +1,50 @@ +function get_ipxe(id){ + $.ajax({ + method: "GET", + url: "/host/ipxe", + data: { uuid:id} + }).done(function(result) { + + $("#script_result").empty().append(result) + }); +} + +function get_install(id){ + $.ajax({ + method: "GET", + url: "/host/install", + data: { uuid:id} + }).done(function(result) { + + $("#script_result").empty().append(result) + }); +} + +function get_postinstall(id){ + $.ajax({ + method: "GET", + url: "/host/postinstall", + data: { uuid:id} + }).done(function(result) { + + $("#script_result").empty().append(result) + }); +} + + + +$( document ).ready(function() { + $(document).on("click",".getIpxeScript", function(){ + var id=$(this).attr('id') + get_ipxe(id) + }); + $(document).on("click",".getInstallScript", function(){ + var id=$(this).attr('id') + get_install(id) + }); + + $(document).on("click",".getPostinstallScript", function(){ + var id=$(this).attr('id') + get_postinstall(id) + }); +}); \ No newline at end of file diff --git a/src/autogen/app/assets/javascript/init.js b/src/autogen/app/assets/javascript/init.js index 283de1b..c0121cb 100644 --- a/src/autogen/app/assets/javascript/init.js +++ b/src/autogen/app/assets/javascript/init.js @@ -1,7 +1,53 @@ +function get_ipxe(id){ + $.ajax({ + method: "GET", + url: "/host/ipxe", + data: { uuid:id} + }).done(function(result) { + + $("#script_result").empty().append(result) + }); +} + +function get_install(id){ + $.ajax({ + method: "GET", + url: "/host/install", + data: { uuid:id} + }).done(function(result) { + + $("#script_result").empty().append(result) + }); +} + +function get_postinstall(id){ + $.ajax({ + method: "GET", + url: "/host/postinstall", + data: { uuid:id} + }).done(function(result) { + + $("#script_result").empty().append(result) + }); +} + $( document ).ready(function() { $('.toggleable').next().hide(); $(document).on("click",".toggleable", function(){ $(this).toggleClass("is-active"); $(this).next().toggle(); }); + $(document).on("click",".getIpxeScript", function(){ + var id=$(this).attr('id') + get_ipxe(id) + }); + $(document).on("click",".getInstallScript", function(){ + var id=$(this).attr('id') + get_install(id) + }); + + $(document).on("click",".getPostinstallScript", function(){ + var id=$(this).attr('id') + get_postinstall(id) + }); }) \ No newline at end of file diff --git a/src/autogen/app/assets/stylesheets/style.css b/src/autogen/app/assets/stylesheets/style.css new file mode 100644 index 0000000..8dc0758 --- /dev/null +++ b/src/autogen/app/assets/stylesheets/style.css @@ -0,0 +1,23 @@ +.scrollDiv { + max-height: 80vh; + overflow:auto; +} + +table { + /* Not required only for visualizing */ + border-collapse: collapse; + width: 100%; + } + +table thead tr th { + /* Important */ + background-color: white; + position: sticky; + z-index: 100; + top: 0; +} + +td { + /* Not required only for visualizing */ + padding: 1em; +} \ No newline at end of file diff --git a/src/autogen/app/controllers/accounts_controller.rb b/src/autogen/app/controllers/accounts_controller.rb new file mode 100644 index 0000000..e58bbfc --- /dev/null +++ b/src/autogen/app/controllers/accounts_controller.rb @@ -0,0 +1,80 @@ +class AccountsController < ApplicationController + before_action :set_account, only: %i[ show edit update destroy ] + before_action :set_pass, only: %i[ update ] + # GET /accounts or /accounts.json + def index + @accounts = Account.all + end + + # GET /accounts/1 or /accounts/1.json + def show + end + + # GET /accounts/new + def new + @account = Account.new + end + + # GET /accounts/1/edit + def edit + end + + # POST /accounts or /accounts.json + def create + @account = Account.new(account_params.except(:password)) + + respond_to do |format| + if @account.save + format.html { redirect_to account_url(@account), notice: "Account was successfully created." } + format.json { render :show, status: :created, location: @account } + else + format.html { render :new, status: :unprocessable_entity } + format.json { render json: @account.errors, status: :unprocessable_entity } + end + end + end + + # PATCH/PUT /accounts/1 or /accounts/1.json + def update + respond_to do |format| + logger.debug(account_params) + if @account.update(account_params.except(:password)) + format.html { redirect_to account_url(@account), notice: "Account was successfully updated." } + format.json { render :show, status: :ok, location: @account } + else + format.html { render :edit, status: :unprocessable_entity } + format.json { render json: @account.errors, status: :unprocessable_entity } + end + end + end + + # DELETE /accounts/1 or /accounts/1.json + def destroy + @account.destroy! + + respond_to do |format| + format.html { redirect_to accounts_url, notice: "Account was successfully destroyed." } + format.json { head :no_content } + end + end + + private + # Use callbacks to share common setup or constraints between actions. + def set_account + @account = Account.find(params[:id]) + end + + def set_pass + # [IMPORTANT] Salt must be generated for prodution ! + + cmdline = "mkpasswd -m sha-512 -S 012345678 #{account_params[:password]}" + @account.encpassword = `#{cmdline}`.strip + account_params.delete(:password) + + end + + # Only allow a list of trusted parameters through. + def account_params + params.require(:account).permit(:name, :login, :password, :sshpubkey,:encpassword) + end +end diff --git a/src/autogen/app/controllers/application_controller.rb b/src/autogen/app/controllers/application_controller.rb index 09705d1..7ba5279 100644 --- a/src/autogen/app/controllers/application_controller.rb +++ b/src/autogen/app/controllers/application_controller.rb @@ -1,2 +1,10 @@ class ApplicationController < ActionController::Base + protect_from_forgery with: :exception + before_action :configure_permitted_parameters, if: :devise_controller? + protected + + def configure_permitted_parameters + devise_parameter_sanitizer.permit(:sign_up, keys: %i[first_name last_name address phone date_of_birth gender]) + devise_parameter_sanitizer.permit(:account_update, keys: %i[first_name last_name address phone date_of_birth gender]) + end end diff --git a/src/autogen/app/controllers/engine_controller.rb b/src/autogen/app/controllers/engine_controller.rb new file mode 100644 index 0000000..061741a --- /dev/null +++ b/src/autogen/app/controllers/engine_controller.rb @@ -0,0 +1,100 @@ +class EngineController < ApplicationController + before_action :set_host_by_uuid, only: %i[ generate_boot generate_install generate_postinstall generate_installed generate_metadata ] + def generateglobal + gv=Utils::Globalvar.new + + puts gv.Get + end + + def generate_boot + if @host + sourceip=request.headers['REMOTE_ADDR'] + log=Log.new({source: "#{sourceip}", crit: "info",message: "#{@host.uuid} Request boot script"}) + log.save() + @host.mac = params[:mac] + @host.installip = params[:installip] + boot_script = @host.installtemplate.boot.content + template = @host.installtemplate + @site = @host.site + host = @host + @template = @host.installtemplate + if @host.toinstall + @host.update({status: "Computer Booting"}) + end + result = render inline: boot_script, layout: false, content_type: 'text/plain' + @host.update({lastbootgenerated: result}) + end + end + + def generate_install + if @host + sourceip=request.headers['REMOTE_ADDR'] + log=Log.new({source: "#{sourceip}", crit: "info",message: "#{@host.uuid} Request Install script"}) + log.save() + script = @host.installtemplate.install.content + template = @host.installtemplate + @site = @host.site + host = @host + @template = @host.installtemplate + @host.update({status: "System Install"}) + result = render inline: script, layout: false, content_type: 'text/plain' + @host.update({lastinstallgenerated: result}) + end + end + + def generate_postinstall + if @host + sourceip=request.headers['REMOTE_ADDR'] + log=Log.new({source: "#{sourceip}", crit: "info",message: "#{@host.uuid} Request Postinstall script"}) + log.save() + @host.update({status: "System Post Install"}) + script = @host.installtemplate.postinstall.content + template = @host.installtemplate + @ansible = Account.find_by(name: "ansible") + @site = @host.site + host = @host + @template = @host.installtemplate + result = render inline: script, layout: false, content_type: 'text/plain' + @host.update({lastpostinstallgenerated: result}) + end + end + + def generate_installed + sourceip=request.headers['REMOTE_ADDR'] + log=Log.new({source: "#{sourceip}", crit: "info",message: "#{@host.uuid} Install Finished."}) + log.save() + if @host.update({status: "Installation Finish", installed: true, toinstall: false, interface: params[:interface],ip: params[:installip]}) + render plain: "ok" + else + render json: @host.errors + end + end + + def generate_metadata + @host = Host.find_by(uuid: params[:uuid]) + script = Script.find_by({name: "metadata",stage: "config"}) + result = render inline: script.content, layout: false, content_type: 'text/plain' + end + + private + # Use callbacks to share common setup or constraints between actions. + def set_host_by_uuid + @host = Host.find_by(uuid: params[:uuid]) + if ! @host + logger.debug "> NEW HOST DETECTED !!!" + sourceip=request.headers['REMOTE_ADDR'] + log=Log.new({source: "#{sourceip}", crit: "warning",message: "New host with uuid #{params[:uuid]} Detected."}) + log.save() + @template = Installtemplate.find_by(name:"default") + @site = Site.find_by(name:"default") + @account = Account.find_by(name:"default") + @host = Host.new(hostname: "New host detected",uuid: params["uuid"], installip: params["installip"], installtemplate: @template,site: @site, mac: params["mac"], status: "discover", discover: true,installed: false, toinstall: false,rootaccount: @account, mainaccount: @account) + @host.save! + end + end + # Only allow a list of trusted parameters through. + def host_params + params.require(:host).permit(:uuid, :hostname, :ip, :status, :mac, :discover, :installed, :interface , :installtemplate, :site , :installtemplate_id, :site_id, :rootaccount_id, :mainaccount_id,:toinstall, :installip) + end + +end diff --git a/src/autogen/app/controllers/home_controller.rb b/src/autogen/app/controllers/home_controller.rb deleted file mode 100644 index 95f2992..0000000 --- a/src/autogen/app/controllers/home_controller.rb +++ /dev/null @@ -1,4 +0,0 @@ -class HomeController < ApplicationController - def index - end -end diff --git a/src/autogen/app/controllers/hosts_controller.rb b/src/autogen/app/controllers/hosts_controller.rb new file mode 100644 index 0000000..11f13f1 --- /dev/null +++ b/src/autogen/app/controllers/hosts_controller.rb @@ -0,0 +1,139 @@ +class HostsController < ApplicationController + before_action :authenticate_user! + + 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 ] + + # GET /hosts or /hosts.json + def index + @hosts = Host.asc(:hostname) + end + + # GET /hosts/1 or /hosts/1.json + def show + end + + # GET /hosts/new + def new + @host = Host.new + end + + # GET /hosts/1/edit + def edit + end + + # POST /hosts or /hosts.json + def create + @host = Host.new(host_params) + respond_to do |format| + if @host.save + format.html { redirect_to host_url(@host), notice: "Host was successfully created." } + format.json { render :show, status: :created, location: @host } + else + format.html { render :new, status: :unprocessable_entity } + format.json { render json: @host.errors, status: :unprocessable_entity } + end + end + end + + # PATCH/PUT /hosts/1 or /hosts/1.json + def update + puts host_params + respond_to do |format| + log=Log.new({source: "admin", crit: "info",message: "User xxx update #{host_params[:hostname]}"}) + log.save() + if @host.update(host_params) + format.html { redirect_to host_url(@host), notice: "Host was successfully updated." } + format.json { render :show, status: :ok, location: @host } + else + format.html { render :edit, status: :unprocessable_entity } + format.json { render json: @host.errors, status: :unprocessable_entity } + end + end + end + + # DELETE /hosts/1 or /hosts/1.json + def destroy + @host.destroy! + + respond_to do |format| + format.html { redirect_to hosts_url, notice: "Host was successfully destroyed." } + format.json { head :no_content } + end + end + + def generate_boot + if @host + + @host.mac = params[:mac] + @host.installip = params[:installip] + boot_script = @host.installtemplate.boot.content + template = @host.installtemplate + @site = @host.site + host = @host + @template = @host.installtemplate + result = render inline: boot_script, layout: false, content_type: 'text/plain' + @host.update({lastbootgenerated: result}) + + end + end + + def generate_install + if @host + script = @host.installtemplate.install.content + template = @host.installtemplate + @site = @host.site + host = @host + @template = @host.installtemplate + result = render inline: script, layout: false, content_type: 'text/plain' + @host.update({lastinstallgenerated: result}) + end + end + + def generate_postinstall + if @host + script = @host.installtemplate.postinstall.content + template = @host.installtemplate + @ansible = Account.find_by(name: "ansible") + @site = @host.site + host = @host + @template = @host.installtemplate + result = render inline: script, layout: false, content_type: 'text/plain' + end + end + + + def generate_metadata + @host = Host.find_by(uuid: params[:uuid]) + script = Script.find_by({name: "metadata",stage: "config"}) + result = render inline: script.content, layout: false, content_type: 'text/plain' + end + + private + # Use callbacks to share common setup or constraints between actions. + + def set_host + logger.debug "#{params}" + @host = Host.find(params[:id]) + end + + def set_host_by_uuid + @host = Host.find_by(uuid: params[:uuid]) + if ! @host + logger.debug "> NEW HOST DETECTED !!!" + sourceip=request.headers['REMOTE_ADDR'] + log=Log.new({source: "#{sourceip}", crit: "warning",message: "New host with uuid #{params[:uuid]} Detected."}) + log.save() + @template = Installtemplate.find_by(name:"default") + @site = Site.find_by(name:"default") + @account = Account.find_by(name:"default") + @host = Host.new(hostname: "New host detected",uuid: params["uuid"], installip: params["installip"], installtemplate: @template,site: @site, mac: params["mac"], status: "discover", discover: true,installed: false, toinstall: false,rootuser: @account, mainuser: @account) + @host.save! + end + end + + # Only allow a list of trusted parameters through. + def host_params + params.require(:host).permit(:uuid, :hostname, :ip, :status, :mac, :discover, :installed, :interface , :installtemplate, :site , :installtemplate_id, :site_id, :rootaccount_id, :mainaccount_id,:toinstall, :installip) + end +end diff --git a/src/autogen/app/controllers/installtemplates_controller.rb b/src/autogen/app/controllers/installtemplates_controller.rb new file mode 100644 index 0000000..3bc3bf1 --- /dev/null +++ b/src/autogen/app/controllers/installtemplates_controller.rb @@ -0,0 +1,71 @@ +class InstalltemplatesController < ApplicationController + before_action :authenticate_user! + before_action :set_installtemplate, only: %i[ show edit update destroy ] + + # GET /installtemplates or /installtemplates.json + def index + @installtemplates = Installtemplate.asc(:name) + end + + # GET /installtemplates/1 or /installtemplates/1.json + def show + end + + # GET /installtemplates/new + def new + @installtemplate = Installtemplate.new + end + + # GET /installtemplates/1/edit + def edit + end + + # POST /installtemplates or /installtemplates.json + def create + @installtemplate = Installtemplate.new(installtemplate_params) + + respond_to do |format| + if @installtemplate.save + format.html { redirect_to installtemplate_url(@installtemplate), notice: "Installtemplate was successfully created." } + format.json { render :show, status: :created, location: @installtemplate } + else + format.html { render :new, status: :unprocessable_entity } + format.json { render json: @installtemplate.errors, status: :unprocessable_entity } + end + end + end + + # PATCH/PUT /installtemplates/1 or /installtemplates/1.json + def update + respond_to do |format| + if @installtemplate.update(installtemplate_params) + format.html { redirect_to installtemplate_url(@installtemplate), notice: "Installtemplate was successfully updated." } + format.json { render :show, status: :ok, location: @installtemplate } + else + format.html { render :edit, status: :unprocessable_entity } + format.json { render json: @installtemplate.errors, status: :unprocessable_entity } + end + end + end + + # DELETE /installtemplates/1 or /installtemplates/1.json + def destroy + @installtemplate.destroy! + + respond_to do |format| + format.html { redirect_to installtemplates_url, notice: "Installtemplate was successfully destroyed." } + format.json { head :no_content } + end + end + + private + # Use callbacks to share common setup or constraints between actions. + def set_installtemplate + @installtemplate = Installtemplate.find(params[:id]) + end + + # Only allow a list of trusted parameters through. + def installtemplate_params + params.require(:installtemplate).permit(:name, :ostype, :osversion, :repository, :nfsroot, :kernel, :initrd, :rootfile, :boot_id, :install_id, :postinstall_id, :lang) + end +end diff --git a/src/autogen/app/controllers/logs_controller.rb b/src/autogen/app/controllers/logs_controller.rb new file mode 100644 index 0000000..31fdeb7 --- /dev/null +++ b/src/autogen/app/controllers/logs_controller.rb @@ -0,0 +1,75 @@ +class LogsController < ApplicationController + before_action :authenticate_user! + before_action :set_log, only: %i[ show edit update destroy ] + + # GET /logs or /logs.json + def index + @logs = Log.desc(:created_at) + end + + # GET /logs/1 or /logs/1.json + def show + end + + # GET /logs/new + def new + @log = Log.new + end + + # GET /logs/1/edit + def edit + end + + # POST /logs or /logs.json + def create + @log = Log.new(log_params) + respond_to do |format| + if @log.save + format.html { redirect_to log_url(@log), notice: "Log was successfully created." } + format.json { render :show, status: :created, location: @log } + else + format.html { render :new, status: :unprocessable_entity } + format.json { render json: @log.errors, status: :unprocessable_entity } + end + end + end + + # PATCH/PUT /logs/1 or /logs/1.json + def update + puts log_params + respond_to do |format| + if @log.update(log_params) + format.html { redirect_to log_url(@log), notice: "Log was successfully updated." } + format.json { render :show, status: :ok, location: @log } + else + format.html { render :edit, status: :unprocessable_entity } + format.json { render json: @log.errors, status: :unprocessable_entity } + end + end + end + + # DELETE /logs/1 or /logs/1.json + def destroy + @log.destroy! + + respond_to do |format| + format.html { redirect_to logs_url, notice: "Log was successfully destroyed." } + format.json { head :no_content } + end + end + + + private + # Use callbacks to share common setup or constraints between actions. + + def set_log + logger.debug "#{params}" + @log = Log.find(params[:id]) + end + + + # Only allow a list of trusted parameters through. + def log_params + params.require(:log).permit(:source, :crit, :message) + end + end diff --git a/src/autogen/app/controllers/pages_controller.rb b/src/autogen/app/controllers/pages_controller.rb new file mode 100644 index 0000000..2daa56d --- /dev/null +++ b/src/autogen/app/controllers/pages_controller.rb @@ -0,0 +1,5 @@ +class PagesController < ApplicationController + def index + @hostslist = Host.all + end +end diff --git a/src/autogen/app/controllers/scripts_controller.rb b/src/autogen/app/controllers/scripts_controller.rb index 7798f31..66de860 100644 --- a/src/autogen/app/controllers/scripts_controller.rb +++ b/src/autogen/app/controllers/scripts_controller.rb @@ -1,4 +1,6 @@ class ScriptsController < ApplicationController + before_action :authenticate_user! + before_action :set_script, only: %i[ show edit update destroy ] # GET /scripts or /scripts.json diff --git a/src/autogen/app/controllers/sites_controller.rb b/src/autogen/app/controllers/sites_controller.rb new file mode 100644 index 0000000..edfafb8 --- /dev/null +++ b/src/autogen/app/controllers/sites_controller.rb @@ -0,0 +1,73 @@ +class SitesController < ApplicationController + before_action :authenticate_user! + before_action :set_site, only: %i[ show edit update destroy ] + + # GET /sites or /sites.json + def index + @sites = Site.all + end + + # GET /sites/1 or /sites/1.json + def show + end + + # GET /sites/new + def new + @site = Site.new + end + + # GET /sites/1/edit + def edit + end + + # POST /sites or /sites.json + def create + @site = Site.new(site_params) + + respond_to do |format| + if @site.save + format.html { redirect_to site_url(@site), notice: "Site was successfully created." } + format.json { render :show, status: :created, location: @site } + else + format.html { render :new, status: :unprocessable_entity } + format.json { render json: @site.errors, status: :unprocessable_entity } + end + end + end + + # PATCH/PUT /sites/1 or /sites/1.json + def update + respond_to do |format| + if @site.update(site_params) + format.html { redirect_to site_url(@site), notice: "Site was successfully updated." } + format.json { render :show, status: :ok, location: @site } + else + format.html { render :edit, status: :unprocessable_entity } + format.json { render json: @site.errors, status: :unprocessable_entity } + end + end + end + + # DELETE /sites/1 or /sites/1.json + def destroy + @site.destroy! + + respond_to do |format| + format.html { redirect_to sites_url, notice: "Site was successfully destroyed." } + format.json { head :no_content } + end + end + + private + # Use callbacks to share common setup or constraints between actions. + def set_site + @site = Site.find(params[:id]) + end + + # Only allow a list of trusted parameters through. + def site_params + params.require(:site).permit(:name, :domain, :gateway, :nameserver, :network, :netmask, :server_ip, :server_port, :fileserver_ip, :fileserver_port,:fileserver_basepath, :timezone, :apiurl, :cfenginehub) + end + + +end diff --git a/src/autogen/app/models/account.rb b/src/autogen/app/models/account.rb new file mode 100644 index 0000000..5670dcc --- /dev/null +++ b/src/autogen/app/models/account.rb @@ -0,0 +1,10 @@ +class Account + include Mongoid::Document + include Mongoid::Timestamps + field :name, type: String + field :login, type: String + field :encpassword, type: String + field :sshpubkey, type: String + has_many :rootref, class_name: "Host", inverse_of: :rootuser + has_many :userref, class_name: "Host", inverse_of: :mainuser +end diff --git a/src/autogen/app/models/host.rb b/src/autogen/app/models/host.rb new file mode 100644 index 0000000..d0b460d --- /dev/null +++ b/src/autogen/app/models/host.rb @@ -0,0 +1,21 @@ +class Host + include Mongoid::Document + include Mongoid::Timestamps + field :uuid, type: String + field :hostname, type: String + field :ip, type: String + field :installip, type: String + field :status, type: String + field :mac, type: String + field :discover, type: Mongoid::Boolean + field :installed, type: Mongoid::Boolean + field :toinstall, type: Mongoid::Boolean + field :interface, type: String + field :lastbootgenerated, type: String , default: '' + field :lastinstallgenerated, type: String , default: '' + field :lastpostinstallgenerated, type: String, default: '' + belongs_to :installtemplate , class_name: "Installtemplate", inverse_of: :hostreferences + belongs_to :site , class_name: "Site", inverse_of: :sitereferences + belongs_to :rootaccount , class_name: "Account", inverse_of: :rootref + belongs_to :mainaccount , class_name: "Account", inverse_of: :accountref +end diff --git a/src/autogen/app/models/installtemplate.rb b/src/autogen/app/models/installtemplate.rb new file mode 100644 index 0000000..4da642b --- /dev/null +++ b/src/autogen/app/models/installtemplate.rb @@ -0,0 +1,18 @@ +class Installtemplate + include Mongoid::Document + include Mongoid::Timestamps + field :name, type: String + field :ostype, type: String + field :osversion, type: String + field :repository, type: String + field :nfsroot, type: String + field :kernel, type: String + field :initrd, type: String + field :rootfile, type: String + field :lang, type: String + has_many :hostreferences, class_name: "Host", inverse_of: :installtemplate + belongs_to :boot , class_name: "Script", inverse_of: :bootref + belongs_to :install , class_name: "Script", inverse_of: :installref + belongs_to :postinstall , class_name: "Script", inverse_of: :postsinstallref + +end diff --git a/src/autogen/app/models/log.rb b/src/autogen/app/models/log.rb new file mode 100644 index 0000000..c9226de --- /dev/null +++ b/src/autogen/app/models/log.rb @@ -0,0 +1,8 @@ +class Log + include Mongoid::Document + include Mongoid::Timestamps + field :source, type: String + field :crit, type: String + field :message, type: String +end + \ No newline at end of file diff --git a/src/autogen/app/models/site.rb b/src/autogen/app/models/site.rb new file mode 100644 index 0000000..ad0bc48 --- /dev/null +++ b/src/autogen/app/models/site.rb @@ -0,0 +1,21 @@ +class Site + include Mongoid::Document + include Mongoid::Timestamps + field :name, type: String + field :domain, type: String + field :gateway, type: String + field :nameserver, type: String + field :network, type: String + field :netmask, type: String + field :server_ip, type: String + field :server_port, type: String + field :fileserver_ip, type: String + field :fileserver_port, type: String + field :fileserver_basepath, type: String + field :timezone, type: String + field :apiurl, type: String + field :description, type: String + field :cfenginehub, type: String + has_many :sitereferences, class_name: "Host", inverse_of: :site + +end diff --git a/src/autogen/app/models/user.rb b/src/autogen/app/models/user.rb new file mode 100644 index 0000000..f3c127f --- /dev/null +++ b/src/autogen/app/models/user.rb @@ -0,0 +1,37 @@ +class User + include Mongoid::Document + # Include default devise modules. Others available are: + # :confirmable, :lockable, :timeoutable, :trackable and :omniauthable + devise :database_authenticatable, :registerable, + :recoverable, :rememberable, :validatable + + ## Database authenticatable + field :email, type: String, default: "" + field :encrypted_password, type: String, default: "" + + ## Recoverable + field :reset_password_token, type: String + field :reset_password_sent_at, type: Time + + ## Rememberable + field :remember_created_at, type: Time + + ## Trackable + # field :sign_in_count, type: Integer, default: 0 + # field :current_sign_in_at, type: Time + # field :last_sign_in_at, type: Time + # field :current_sign_in_ip, type: String + # field :last_sign_in_ip, type: String + + ## Confirmable + # field :confirmation_token, type: String + # field :confirmed_at, type: Time + # field :confirmation_sent_at, type: Time + # field :unconfirmed_email, type: String # Only if using reconfirmable + + ## Lockable + # 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 :locked_at, type: Time + include Mongoid::Timestamps +end diff --git a/src/autogen/app/views/accounts/_account.html.erb b/src/autogen/app/views/accounts/_account.html.erb new file mode 100644 index 0000000..a6009e0 --- /dev/null +++ b/src/autogen/app/views/accounts/_account.html.erb @@ -0,0 +1,20 @@ + +
+

+ Name: + <%= account.name %> +

+ +

+ Login: + <%= account.login %> +

+ +

+ SSH Key: + <%= account.sshpubkey %> +

+ + +
+ diff --git a/src/autogen/app/views/accounts/_account.json.jbuilder b/src/autogen/app/views/accounts/_account.json.jbuilder new file mode 100644 index 0000000..c414bf3 --- /dev/null +++ b/src/autogen/app/views/accounts/_account.json.jbuilder @@ -0,0 +1,2 @@ +json.extract! account, :id, :name, :login, :sshpubkey, :password, :created_at, :updated_at +json.url account_url(account, format: :json) diff --git a/src/autogen/app/views/accounts/_account_raw.html.erb b/src/autogen/app/views/accounts/_account_raw.html.erb new file mode 100644 index 0000000..6abd520 --- /dev/null +++ b/src/autogen/app/views/accounts/_account_raw.html.erb @@ -0,0 +1,5 @@ + +<%= account.name %> +<%= account.login %> + <%= button_to "Edit", edit_account_path(account), method: :get, class: "button is-small is-primary" %> + diff --git a/src/autogen/app/views/accounts/_form.html.erb b/src/autogen/app/views/accounts/_form.html.erb new file mode 100644 index 0000000..fab8de3 --- /dev/null +++ b/src/autogen/app/views/accounts/_form.html.erb @@ -0,0 +1,51 @@ +
+<%= form_with(model: account) do |form| %> + <% if account.errors.any? %> +
+

<%= pluralize(account.errors.count, "error") %> prohibited this account from being saved:

+ + +
+ <% end %> + +
+ +
+ <%= form.text_field :name , { class: "input"} %> +
+
+ +
+
+ +
+ <%= form.text_field :login , { class: "input"} %> +
+
+ +
+ +
+ <%= form.text_field :password , { class: "input"} %> +
+
+
+ +
+
+ + +
+
+ +
+ + <%= link_to "Return", "/accounts", class: "button is-success" %> +
+<% end %> +
+<%= button_to "Destroy", @account, method: :delete, class: "button is-danger" %> \ No newline at end of file diff --git a/src/autogen/app/views/accounts/edit.html.erb b/src/autogen/app/views/accounts/edit.html.erb new file mode 100644 index 0000000..a672ba7 --- /dev/null +++ b/src/autogen/app/views/accounts/edit.html.erb @@ -0,0 +1,3 @@ +

Editing Account: <%= @account.name %>

+ +<%= render "form", account: @account %> diff --git a/src/autogen/app/views/accounts/index.html.erb b/src/autogen/app/views/accounts/index.html.erb new file mode 100644 index 0000000..3946770 --- /dev/null +++ b/src/autogen/app/views/accounts/index.html.erb @@ -0,0 +1,23 @@ +

<%= notice %>

+ + + +

Accounts

+<%= button_to "New Account", new_account_path, method: :get, class: "button is-small is-primary" %> +
+ + + + + + + + + <% @accounts.each do |account| %> + <%= render :partial => 'account_raw', :locals => { :account => account} %> + <% end %> + +
Login
+
+ + diff --git a/src/autogen/app/views/accounts/index.json.jbuilder b/src/autogen/app/views/accounts/index.json.jbuilder new file mode 100644 index 0000000..e41369e --- /dev/null +++ b/src/autogen/app/views/accounts/index.json.jbuilder @@ -0,0 +1 @@ +json.array! @accounts, partial: "accounts/account", as: :account diff --git a/src/autogen/app/views/accounts/new.html.erb b/src/autogen/app/views/accounts/new.html.erb new file mode 100644 index 0000000..62e862a --- /dev/null +++ b/src/autogen/app/views/accounts/new.html.erb @@ -0,0 +1,9 @@ +

New account

+ +<%= render "form", account: @account %> + +
+ +
+ <%= link_to "Back to accounts", accounts_path %> +
diff --git a/src/autogen/app/views/accounts/show.html.erb b/src/autogen/app/views/accounts/show.html.erb new file mode 100644 index 0000000..a1051f5 --- /dev/null +++ b/src/autogen/app/views/accounts/show.html.erb @@ -0,0 +1,10 @@ +

<%= notice %>

+ +<%= render @account %> + +
+ <%= link_to "Edit this account", edit_account_path(@account) %> | + <%= link_to "Back to accounts", accounts_path %> + + <%= button_to "Destroy", @account, method: :delete %> +
diff --git a/src/autogen/app/views/accounts/show.json.jbuilder b/src/autogen/app/views/accounts/show.json.jbuilder new file mode 100644 index 0000000..89a793f --- /dev/null +++ b/src/autogen/app/views/accounts/show.json.jbuilder @@ -0,0 +1 @@ +json.partial! "accounts/account", account: @account diff --git a/src/autogen/app/views/devise/confirmations/new.html.erb b/src/autogen/app/views/devise/confirmations/new.html.erb new file mode 100644 index 0000000..b12dd0c --- /dev/null +++ b/src/autogen/app/views/devise/confirmations/new.html.erb @@ -0,0 +1,16 @@ +

Resend confirmation instructions

+ +<%= form_for(resource, as: resource_name, url: confirmation_path(resource_name), html: { method: :post }) do |f| %> + <%= render "devise/shared/error_messages", resource: resource %> + +
+ <%= f.label :email %>
+ <%= f.email_field :email, autofocus: true, autocomplete: "email", value: (resource.pending_reconfirmation? ? resource.unconfirmed_email : resource.email) %> +
+ +
+ <%= f.submit "Resend confirmation instructions" %> +
+<% end %> + +<%= render "devise/shared/links" %> diff --git a/src/autogen/app/views/devise/mailer/confirmation_instructions.html.erb b/src/autogen/app/views/devise/mailer/confirmation_instructions.html.erb new file mode 100644 index 0000000..dc55f64 --- /dev/null +++ b/src/autogen/app/views/devise/mailer/confirmation_instructions.html.erb @@ -0,0 +1,5 @@ +

Welcome <%= @email %>!

+ +

You can confirm your account email through the link below:

+ +

<%= link_to 'Confirm my account', confirmation_url(@resource, confirmation_token: @token) %>

diff --git a/src/autogen/app/views/devise/mailer/email_changed.html.erb b/src/autogen/app/views/devise/mailer/email_changed.html.erb new file mode 100644 index 0000000..32f4ba8 --- /dev/null +++ b/src/autogen/app/views/devise/mailer/email_changed.html.erb @@ -0,0 +1,7 @@ +

Hello <%= @email %>!

+ +<% if @resource.try(:unconfirmed_email?) %> +

We're contacting you to notify you that your email is being changed to <%= @resource.unconfirmed_email %>.

+<% else %> +

We're contacting you to notify you that your email has been changed to <%= @resource.email %>.

+<% end %> diff --git a/src/autogen/app/views/devise/mailer/password_change.html.erb b/src/autogen/app/views/devise/mailer/password_change.html.erb new file mode 100644 index 0000000..b41daf4 --- /dev/null +++ b/src/autogen/app/views/devise/mailer/password_change.html.erb @@ -0,0 +1,3 @@ +

Hello <%= @resource.email %>!

+ +

We're contacting you to notify you that your password has been changed.

diff --git a/src/autogen/app/views/devise/mailer/reset_password_instructions.html.erb b/src/autogen/app/views/devise/mailer/reset_password_instructions.html.erb new file mode 100644 index 0000000..f667dc1 --- /dev/null +++ b/src/autogen/app/views/devise/mailer/reset_password_instructions.html.erb @@ -0,0 +1,8 @@ +

Hello <%= @resource.email %>!

+ +

Someone has requested a link to change your password. You can do this through the link below.

+ +

<%= link_to 'Change my password', edit_password_url(@resource, reset_password_token: @token) %>

+ +

If you didn't request this, please ignore this email.

+

Your password won't change until you access the link above and create a new one.

diff --git a/src/autogen/app/views/devise/mailer/unlock_instructions.html.erb b/src/autogen/app/views/devise/mailer/unlock_instructions.html.erb new file mode 100644 index 0000000..41e148b --- /dev/null +++ b/src/autogen/app/views/devise/mailer/unlock_instructions.html.erb @@ -0,0 +1,7 @@ +

Hello <%= @resource.email %>!

+ +

Your account has been locked due to an excessive number of unsuccessful sign in attempts.

+ +

Click the link below to unlock your account:

+ +

<%= link_to 'Unlock my account', unlock_url(@resource, unlock_token: @token) %>

diff --git a/src/autogen/app/views/devise/passwords/edit.html.erb b/src/autogen/app/views/devise/passwords/edit.html.erb new file mode 100644 index 0000000..5fbb9ff --- /dev/null +++ b/src/autogen/app/views/devise/passwords/edit.html.erb @@ -0,0 +1,25 @@ +

Change your password

+ +<%= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :put }) do |f| %> + <%= render "devise/shared/error_messages", resource: resource %> + <%= f.hidden_field :reset_password_token %> + +
+ <%= f.label :password, "New password" %>
+ <% if @minimum_password_length %> + (<%= @minimum_password_length %> characters minimum)
+ <% end %> + <%= f.password_field :password, autofocus: true, autocomplete: "new-password" %> +
+ +
+ <%= f.label :password_confirmation, "Confirm new password" %>
+ <%= f.password_field :password_confirmation, autocomplete: "new-password" %> +
+ +
+ <%= f.submit "Change my password" %> +
+<% end %> + +<%= render "devise/shared/links" %> diff --git a/src/autogen/app/views/devise/passwords/new.html.erb b/src/autogen/app/views/devise/passwords/new.html.erb new file mode 100644 index 0000000..9b486b8 --- /dev/null +++ b/src/autogen/app/views/devise/passwords/new.html.erb @@ -0,0 +1,16 @@ +

Forgot your password?

+ +<%= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :post }) do |f| %> + <%= render "devise/shared/error_messages", resource: resource %> + +
+ <%= f.label :email %>
+ <%= f.email_field :email, autofocus: true, autocomplete: "email" %> +
+ +
+ <%= f.submit "Send me reset password instructions" %> +
+<% end %> + +<%= render "devise/shared/links" %> diff --git a/src/autogen/app/views/devise/registrations/edit.html.erb b/src/autogen/app/views/devise/registrations/edit.html.erb new file mode 100644 index 0000000..669204f --- /dev/null +++ b/src/autogen/app/views/devise/registrations/edit.html.erb @@ -0,0 +1,48 @@ +
+
+
+

Your profil

+ <%= form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put }) do |f| %> + <%= render "devise/shared/error_messages", resource: resource %> + +
+ <%= f.label :email %>
+ <%= f.email_field :email, autofocus: true, autocomplete: "email", class: "input is-small" , placeholder: :email %> +
+ + <% if devise_mapping.confirmable? && resource.pending_reconfirmation? %> +
Currently waiting confirmation for: <%= resource.unconfirmed_email %>
+ <% end %> + +
+ <%= f.label :password %> (leave blank if you don't want to change it)
+ <%= f.password_field :password, autocomplete: "new-password",class: "input is-small" , placeholder: "New password" %> + <% if @minimum_password_length %> +
+ <%= @minimum_password_length %> characters minimum + <% end %> +
+ +
+ <%= f.label :password_confirmation %>
+ <%= f.password_field :password_confirmation, autocomplete: "new-password", class: "input is-small" , placeholder: "New password confirmation" %> +
+ +
+ <%= f.label :current_password %> (we need your current password to confirm your changes)
+ <%= f.password_field :current_password, autocomplete: "current-password", class: "input is-small" , placeholder: "Current password" %> +
+ +
+ <%= f.submit "Update",class:"button is-success" %> +
+ <% end %> + +

Cancel my account

+ +
Unhappy? <%= button_to "Cancel my account", registration_path(resource_name), data: { confirm: "Are you sure?", turbo_confirm: "Are you sure?" }, method: :delete , class:"button is-danger"%>
+ + <%= link_to "Back", :back %> +
+
+
\ No newline at end of file diff --git a/src/autogen/app/views/devise/registrations/new.html.erb b/src/autogen/app/views/devise/registrations/new.html.erb new file mode 100644 index 0000000..90a9ccc --- /dev/null +++ b/src/autogen/app/views/devise/registrations/new.html.erb @@ -0,0 +1,32 @@ +
+
+
+

Sign up

+ <%= form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %> + <%= render "devise/shared/error_messages", resource: resource %> + +
+ <%= f.label :email %>
+ <%= f.email_field :email, autofocus: true, autocomplete: "email", class: "input is-small" , placeholder: :email %> +
+ +
+ <%= f.label :password %> + <% if @minimum_password_length %> + (<%= @minimum_password_length %> characters minimum) + <% end %>
+ <%= f.password_field :password, autocomplete: "new-password", class: "input is-small" , placeholder: "password" %> +
+ +
+ <%= f.label :password_confirmation %>
+ <%= f.password_field :password_confirmation, autocomplete: "new-password", class: "input is-small" , placeholder: "password confirmation" %> +
+ +
+ <%= f.submit "Sign up" , class:"button is-success" %> +
+ <% end %> +
+
+
diff --git a/src/autogen/app/views/devise/sessions/new.html.erb b/src/autogen/app/views/devise/sessions/new.html.erb new file mode 100644 index 0000000..f1148fc --- /dev/null +++ b/src/autogen/app/views/devise/sessions/new.html.erb @@ -0,0 +1,29 @@ +
+
+
+

Login

+ <%= form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| %> +
+ <%= f.email_field :email, autofocus: true, autocomplete: "email" , class: "input is-small" , placeholder: :email %> +
+ +
+ <%= f.password_field :password, autocomplete: "current-password" ,class: "input is-small" , placeholder: :password%> +
+ + <% if devise_mapping.rememberable? %> +
+ <%= f.check_box :remember_me %> + <%= f.label :remember_me %> +
+ <% end %> + +
+ <%= f.submit "Log in" , class:"button is-success" %> +
+ <% end %> + + <%= render "devise/shared/links" %> +
+
+
\ No newline at end of file diff --git a/src/autogen/app/views/devise/shared/_error_messages.html.erb b/src/autogen/app/views/devise/shared/_error_messages.html.erb new file mode 100644 index 0000000..cabfe30 --- /dev/null +++ b/src/autogen/app/views/devise/shared/_error_messages.html.erb @@ -0,0 +1,15 @@ +<% if resource.errors.any? %> +
+

+ <%= I18n.t("errors.messages.not_saved", + count: resource.errors.count, + resource: resource.class.model_name.human.downcase) + %> +

+ +
+<% end %> diff --git a/src/autogen/app/views/devise/shared/_links.html.erb b/src/autogen/app/views/devise/shared/_links.html.erb new file mode 100644 index 0000000..7a75304 --- /dev/null +++ b/src/autogen/app/views/devise/shared/_links.html.erb @@ -0,0 +1,25 @@ +<%- if controller_name != 'sessions' %> + <%= link_to "Log in", new_session_path(resource_name) %>
+<% end %> + +<%- if devise_mapping.registerable? && controller_name != 'registrations' %> + <%= link_to "Sign up", new_registration_path(resource_name) %>
+<% end %> + +<%- if devise_mapping.recoverable? && controller_name != 'passwords' && controller_name != 'registrations' %> + <%= link_to "Forgot your password?", new_password_path(resource_name) %>
+<% end %> + +<%- if devise_mapping.confirmable? && controller_name != 'confirmations' %> + <%= link_to "Didn't receive confirmation instructions?", new_confirmation_path(resource_name) %>
+<% end %> + +<%- if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks' %> + <%= link_to "Didn't receive unlock instructions?", new_unlock_path(resource_name) %>
+<% end %> + +<%- if devise_mapping.omniauthable? %> + <%- resource_class.omniauth_providers.each do |provider| %> + <%= button_to "Sign in with #{OmniAuth::Utils.camelize(provider)}", omniauth_authorize_path(resource_name, provider), data: { turbo: false } %>
+ <% end %> +<% end %> diff --git a/src/autogen/app/views/devise/unlocks/new.html.erb b/src/autogen/app/views/devise/unlocks/new.html.erb new file mode 100644 index 0000000..ffc34de --- /dev/null +++ b/src/autogen/app/views/devise/unlocks/new.html.erb @@ -0,0 +1,16 @@ +

Resend unlock instructions

+ +<%= form_for(resource, as: resource_name, url: unlock_path(resource_name), html: { method: :post }) do |f| %> + <%= render "devise/shared/error_messages", resource: resource %> + +
+ <%= f.label :email %>
+ <%= f.email_field :email, autofocus: true, autocomplete: "email" %> +
+ +
+ <%= f.submit "Resend unlock instructions" %> +
+<% end %> + +<%= render "devise/shared/links" %> diff --git a/src/autogen/app/views/hosts/_form.html.erb b/src/autogen/app/views/hosts/_form.html.erb new file mode 100644 index 0000000..67aca7b --- /dev/null +++ b/src/autogen/app/views/hosts/_form.html.erb @@ -0,0 +1,170 @@ +<%# _form.html.erb %> +
+
+
+ <%= form_with(model: host) do |form| %> + <% if host.errors.any? %> +
+

<%= pluralize(host.errors.count, "error") %> prohibited this host from being saved:

+ +
    + <% host.errors.each do |error| %> +
  • <%= error.full_message %>
  • + <% end %> +
+
+ <% end %> +
+
+ +
+
+
+
+ <%= form.text_field :uuid , { class: "input"} %> +
+
+
+
+ +
+
+ +
+
+
+
+ <%= form.text_field :hostname , { class: "input"} %> +
+
+
+
+ +
+
+ +
+
+
+
+ <%= form.text_field :ip , { class: "input"} %> +
+
+
+
+ +
+
+ +
+
+
+
+ <%= form.text_field :installip , { class: "input"} %> +
+
+
+
+ +
+
+ +
+
+
+
+ <%= form.text_field :status , { class: "input"} %> +
+
+
+
+ +
+
+ +
+
+
+
+ <%= form.text_field :mac , { class: "input"} %> +
+
+
+
+ +
+
+ +
+
+
+
+ <%= form.text_field :interface , { class: "input"} %> +
+
+
+
+ +
+
+ +
+
+
+
+ <%= collection_select(:host, :installtemplate_id, Installtemplate.all, :_id, :name) %> +
+
+
+
+ +
+
+ +
+
+
+
+ <%= collection_select(:host, :site_id, Site.all, :_id, :name) %> +
+
+
+
+ +
+
+ <%= form.label :rootaccount, class: "label is-small" %> +
+ <%= form.collection_select :rootaccount_id, Account.all, :id, :name %> +
+
+ +
+ <%= form.label :mainaccount, class: "label is-small" %> +
+ <%= form.collection_select :mainaccount_id, Account.all, :id, :name %> +
+
+ +
+ <%= form.label :discover, class: "checkbox" %> + <%= form.check_box :discover %> +
+
+ <%= form.label :installed, class: "checkbox" %> + <%= form.check_box :installed %> +
+
+ <%= form.label :toinstall, class: "checkbox" %> + <%= form.check_box :toinstall %> +
+
+
+ + <%= link_to "Return", "/hosts", class: "button is-success" %> + <%= button_to "Destroy", @host, method: :delete, class: "button is-danger is-pulled-right" %> +
+ <% end %> +
+
+
diff --git a/src/autogen/app/views/hosts/_host.html.erb b/src/autogen/app/views/hosts/_host.html.erb new file mode 100644 index 0000000..2d9b52d --- /dev/null +++ b/src/autogen/app/views/hosts/_host.html.erb @@ -0,0 +1,69 @@ +
+
+

+ <%= host.hostname %> +

+ +
+
+
+

+ Ip: + <%= host.ip %> +

+ +

+ Status: + <%= host.status %> +

+ +

+ Mac: + <%= host.mac %> +

+ +

+ Discover: + <%= host.discover %> +

+ +

+ Installed: + <%= host.installed %> +

+ +

+ Interface: + <%= host.interface %> +

+

+ Install Template: + <% if defined?host.installtemplate.name %> + <%= host.installtemplate.name %> + <% else %> + not set + <% end %> +

+ +

+ Site: + <% if defined?host.site.name %> + <%= host.site.name %> + <% else %> + not set + <% end %> +

+
+
+ +
+ + + + diff --git a/src/autogen/app/views/hosts/_host.json.jbuilder b/src/autogen/app/views/hosts/_host.json.jbuilder new file mode 100644 index 0000000..ac01c97 --- /dev/null +++ b/src/autogen/app/views/hosts/_host.json.jbuilder @@ -0,0 +1,2 @@ +json.extract! host, :id, :uuid, :hostname, :ip, :status, :mac, :discover, :installed, :interface, :installtemplate, :site, :created_at, :updated_at +json.url host_url(host, format: :json) diff --git a/src/autogen/app/views/hosts/_hostraw.html.erb b/src/autogen/app/views/hosts/_hostraw.html.erb new file mode 100644 index 0000000..68166f9 --- /dev/null +++ b/src/autogen/app/views/hosts/_hostraw.html.erb @@ -0,0 +1,9 @@ + + <%= host.hostname %> + <%= host.status %> + <%= host.installtemplate.name %> + <%= button_to "Edit", edit_host_path(host), method: :get, class: "button is-small is-primary" %> + + + + diff --git a/src/autogen/app/views/hosts/edit.html.erb b/src/autogen/app/views/hosts/edit.html.erb new file mode 100644 index 0000000..9ed65cb --- /dev/null +++ b/src/autogen/app/views/hosts/edit.html.erb @@ -0,0 +1,6 @@ +

Editing Host: <%= @host.hostname %>

+ +<%= render "form", host: @host %> + + + diff --git a/src/autogen/app/views/hosts/index.html.erb b/src/autogen/app/views/hosts/index.html.erb new file mode 100644 index 0000000..c0d044f --- /dev/null +++ b/src/autogen/app/views/hosts/index.html.erb @@ -0,0 +1,27 @@ + +

Hosts

+<%= button_to "New Host", new_host_path, method: :get, class: "button is-small is-primary" %> +
+ + + + + + + + + + + <% @hosts.each do |host| %> + <%= render :partial => 'hostraw', :locals => { :host => host} %> + <% end %> + +
HostnameStatusTemplate
+
+

Render

+
+        
+
+
+ + diff --git a/src/autogen/app/views/hosts/index.json.jbuilder b/src/autogen/app/views/hosts/index.json.jbuilder new file mode 100644 index 0000000..1f8c29a --- /dev/null +++ b/src/autogen/app/views/hosts/index.json.jbuilder @@ -0,0 +1 @@ +json.array! @hosts, partial: "hosts/host", as: :host diff --git a/src/autogen/app/views/hosts/new.html.erb b/src/autogen/app/views/hosts/new.html.erb new file mode 100644 index 0000000..96784bc --- /dev/null +++ b/src/autogen/app/views/hosts/new.html.erb @@ -0,0 +1,9 @@ +

New host

+ +<%= render "form", host: @host %> + +
+ +
+ <%= link_to "Back to hosts", hosts_path %> +
diff --git a/src/autogen/app/views/hosts/show.html.erb b/src/autogen/app/views/hosts/show.html.erb new file mode 100644 index 0000000..0cb1e3f --- /dev/null +++ b/src/autogen/app/views/hosts/show.html.erb @@ -0,0 +1,12 @@ +
+

<%= notice %>

+
+ +<%= render @host %> + +
+ + +
diff --git a/src/autogen/app/views/hosts/show.json.jbuilder b/src/autogen/app/views/hosts/show.json.jbuilder new file mode 100644 index 0000000..ce1aca0 --- /dev/null +++ b/src/autogen/app/views/hosts/show.json.jbuilder @@ -0,0 +1 @@ +json.partial! "hosts/host", host: @host diff --git a/src/autogen/app/views/installtemplates/_form.html.erb b/src/autogen/app/views/installtemplates/_form.html.erb new file mode 100644 index 0000000..fd5d876 --- /dev/null +++ b/src/autogen/app/views/installtemplates/_form.html.erb @@ -0,0 +1,112 @@ +
+<%= form_with(model: installtemplate) do |form| %> + <% if installtemplate.errors.any? %> +
+

<%= pluralize(installtemplate.errors.count, "error") %> prohibited this installtemplate from being saved:

+ + +
+ <% end %> + + +
+ <%= form.label :name, class: "label" %> +
+ <%= form.text_field :name , { class: "input"} %> +
+
+ +
+
+ <%= form.label :ostype, class: "label" %> +
+ <%= form.text_field :ostype , { class: "input"} %> +
+
+ +
+ <%= form.label :osversion, class: "label" %> +
+ <%= form.text_field :osversion , { class: "input"} %> +
+
+
+ +
+ <%= form.label :repository, class: "label" %> +
+ <%= form.text_field :repository , { class: "input"} %> +
+
+ +
+ <%= form.label :nfsroot, class: "label" %> +
+ <%= form.text_field :nfsroot , { class: "input"} %> +
+
+
+
+ <%= form.label :kernel, class: "label" %> +
+ <%= form.text_field :kernel , { class: "input"} %> +
+
+ +
+ <%= form.label :initrd, class: "label" %> +
+ <%= form.text_field :initrd , { class: "input"} %> +
+
+
+ +
+ <%= form.label :rootfile, class: "label" %> +
+ <%= form.text_field :rootfile , { class: "input"} %> +
+
+ +
+
+ <%= form.label :boot, class: "label" %> +
+ <%= form.collection_select :boot_id, Script.where(stage:"boot"), :id, :name %> +
+
+ +
+ <%= form.label :install, class: "label" %> +
+ <%= form.collection_select :install_id, Script.where(stage:"install"), :id, :name %> +
+
+ +
+ <%= form.label :postinstall, class: "label" %> +
+ <%= form.collection_select :postinstall_id, Script.where(stage:"postinstall"), :id, :name %> +
+
+
+ +
+ <%= form.label :lang, class: "label" %> +
+ <%= form.text_field :lang , { class: "input"} %> +
+
+ +
+ + <%= link_to "Return", "/installtemplates", class: "button is-success" %> +
+ +<% end %> +<%= button_to " Destroy ", @installtemplate, method: :delete, class: "button is-danger" %> + diff --git a/src/autogen/app/views/installtemplates/_installtemplate.html.erb b/src/autogen/app/views/installtemplates/_installtemplate.html.erb new file mode 100644 index 0000000..ba1917f --- /dev/null +++ b/src/autogen/app/views/installtemplates/_installtemplate.html.erb @@ -0,0 +1,69 @@ +
+

+ Name: + <%= installtemplate.name %> +

+ +

+ Ostype: + <%= installtemplate.ostype %> +

+ +

+ Osversion: + <%= installtemplate.osversion %> +

+ +

+ Repository: + <%= installtemplate.repository %> +

+ +

+ Nfsroot: + <%= installtemplate.nfsroot %> +

+ +

+ Kernel: + <%= installtemplate.kernel %> +

+ +

+ Initrd: + <%= installtemplate.initrd %> +

+ +

+ Rootfile: + <%= installtemplate.rootfile %> +

+ +

+ Boot Script + <% if defined?installtemplate.boot.name %> + <%= installtemplate.boot.name %> + <% else %> + not set + <% end %> +

+ + +

+ Install + <% if defined?installtemplate.install.name %> + <%= installtemplate.install.name %> + <% else %> + not set + <% end %> +

+ +

+ PostInstall + <% if defined?installtemplate.boot.name %> + <%= installtemplate.boot.name %> + <% else %> + not set + <% end %> +

+
diff --git a/src/autogen/app/views/installtemplates/_installtemplate.json.jbuilder b/src/autogen/app/views/installtemplates/_installtemplate.json.jbuilder new file mode 100644 index 0000000..74f0386 --- /dev/null +++ b/src/autogen/app/views/installtemplates/_installtemplate.json.jbuilder @@ -0,0 +1,2 @@ +json.extract! installtemplate, :id, :name, :ostype, :osversion, :repository, :nfsroot, :kernel, :initrd, :rootfile, :boot, :install, :postinstall :created_at, :updated_at +json.url installtemplate_url(installtemplate, format: :json) diff --git a/src/autogen/app/views/installtemplates/_templateraw.html.erb b/src/autogen/app/views/installtemplates/_templateraw.html.erb new file mode 100644 index 0000000..266810f --- /dev/null +++ b/src/autogen/app/views/installtemplates/_templateraw.html.erb @@ -0,0 +1,4 @@ + +<%= installtemplate.name %> + <%= button_to "Edit", edit_installtemplate_path(installtemplate), method: :get, class: "button is-small is-primary" %> + diff --git a/src/autogen/app/views/installtemplates/edit.html.erb b/src/autogen/app/views/installtemplates/edit.html.erb new file mode 100644 index 0000000..fe10a34 --- /dev/null +++ b/src/autogen/app/views/installtemplates/edit.html.erb @@ -0,0 +1,10 @@ +

Editing <%= @installtemplate.name %>

+ +<%= render "form", installtemplate: @installtemplate %> + +
+ +
+ <%= link_to "Show", @installtemplate %> | + <%= link_to "Back", installtemplates_path %> +
diff --git a/src/autogen/app/views/installtemplates/index.html.erb b/src/autogen/app/views/installtemplates/index.html.erb new file mode 100644 index 0000000..fe952c4 --- /dev/null +++ b/src/autogen/app/views/installtemplates/index.html.erb @@ -0,0 +1,21 @@ +

<%= notice %>

+ +

Templates

+<%= button_to "New Template", new_installtemplate_path, method: :get, class: "button is-small is-primary" %> +
+ + + + + + + + + <% @installtemplates.each do |installtemplate| %> + <%= render :partial => 'templateraw', :locals => { :installtemplate => installtemplate} %> + <% end %> + +
Name
+
+ + diff --git a/src/autogen/app/views/installtemplates/index.json.jbuilder b/src/autogen/app/views/installtemplates/index.json.jbuilder new file mode 100644 index 0000000..c4034c9 --- /dev/null +++ b/src/autogen/app/views/installtemplates/index.json.jbuilder @@ -0,0 +1 @@ +json.array! @installtemplates, partial: "installtemplates/installtemplate", as: :installtemplate diff --git a/src/autogen/app/views/installtemplates/new.html.erb b/src/autogen/app/views/installtemplates/new.html.erb new file mode 100644 index 0000000..b38542a --- /dev/null +++ b/src/autogen/app/views/installtemplates/new.html.erb @@ -0,0 +1,9 @@ +

New installtemplate

+ +<%= render "form", installtemplate: @installtemplate %> + +
+ +
+ <%= link_to "Back to installtemplates", installtemplates_path %> +
diff --git a/src/autogen/app/views/installtemplates/show.html.erb b/src/autogen/app/views/installtemplates/show.html.erb new file mode 100644 index 0000000..ae9e8a9 --- /dev/null +++ b/src/autogen/app/views/installtemplates/show.html.erb @@ -0,0 +1,10 @@ +

<%= notice %>

+ +<%= render @installtemplate %> + +
+ <%= link_to "Edit this installtemplate", edit_installtemplate_path(@installtemplate) %> | + <%= link_to "Back to installtemplates", installtemplates_path %> + + <%= button_to "Destroy this installtemplate", @installtemplate, method: :delete %> +
diff --git a/src/autogen/app/views/installtemplates/show.json.jbuilder b/src/autogen/app/views/installtemplates/show.json.jbuilder new file mode 100644 index 0000000..c0e6fba --- /dev/null +++ b/src/autogen/app/views/installtemplates/show.json.jbuilder @@ -0,0 +1 @@ +json.partial! "installtemplates/installtemplate", installtemplate: @installtemplate diff --git a/src/autogen/app/views/layouts/application.html.erb b/src/autogen/app/views/layouts/application.html.erb index 124e8e9..0f37fd1 100644 --- a/src/autogen/app/views/layouts/application.html.erb +++ b/src/autogen/app/views/layouts/application.html.erb @@ -1,3 +1,4 @@ + @@ -14,13 +15,14 @@
<%= render "partials/top-menu" %> -
-
+
+
<%= render "partials/left-menu" %> -
-
- -
+
+
+

<%= notice %>

+

<%= alert %>

+
<%= yield %>
@@ -29,3 +31,5 @@ <%= javascript_include_tag "init" %> + + diff --git a/src/autogen/app/views/logs/_log_raw.html.erb b/src/autogen/app/views/logs/_log_raw.html.erb new file mode 100644 index 0000000..044a827 --- /dev/null +++ b/src/autogen/app/views/logs/_log_raw.html.erb @@ -0,0 +1,6 @@ + +<%= log.created_at %> +<%= log.source %> +<%= log.crit %> +<%= log.message %> + diff --git a/src/autogen/app/views/logs/index.html.erb b/src/autogen/app/views/logs/index.html.erb new file mode 100644 index 0000000..67cf982 --- /dev/null +++ b/src/autogen/app/views/logs/index.html.erb @@ -0,0 +1,22 @@ +

<%= notice %>

+ +
+ + + + + + + + + + + + <% @logs.each do |log| %> + <%= render :partial => 'log_raw', :locals => { :log => log} %> + <% end %> + +
DateSourceCritMessage
+
+ + diff --git a/src/autogen/app/views/logs/index.json.jbuilder b/src/autogen/app/views/logs/index.json.jbuilder new file mode 100644 index 0000000..9254038 --- /dev/null +++ b/src/autogen/app/views/logs/index.json.jbuilder @@ -0,0 +1 @@ +json.array! @logs, partial: "logs/log", as: :log diff --git a/src/autogen/app/views/home/index.html.erb b/src/autogen/app/views/pages/index.html.erb similarity index 65% rename from src/autogen/app/views/home/index.html.erb rename to src/autogen/app/views/pages/index.html.erb index 3998b38..88279b0 100644 --- a/src/autogen/app/views/home/index.html.erb +++ b/src/autogen/app/views/pages/index.html.erb @@ -3,5 +3,5 @@

Home#index

-

Find me in app/views/home/index.html.erb

+

Find me in app/views/pages/index.html.erb

\ No newline at end of file diff --git a/src/autogen/app/views/partials/_left-menu.html.erb b/src/autogen/app/views/partials/_left-menu.html.erb index 53c7b54..9e5c887 100644 --- a/src/autogen/app/views/partials/_left-menu.html.erb +++ b/src/autogen/app/views/partials/_left-menu.html.erb @@ -1,40 +1,32 @@ - \ No newline at end of file diff --git a/src/autogen/app/views/partials/_top-menu.html.erb b/src/autogen/app/views/partials/_top-menu.html.erb index eab3aef..c7e877a 100644 --- a/src/autogen/app/views/partials/_top-menu.html.erb +++ b/src/autogen/app/views/partials/_top-menu.html.erb @@ -13,7 +13,7 @@