Class: TrueNAS
- Inherits:
-
Oxidized::Model
- Object
- Oxidized::Model
- TrueNAS
- Defined in:
- lib/oxidized/model/truenas.rb
Constant Summary
Constants inherited from Oxidized::Model
Oxidized::Model::METADATA_DEFAULT
Constants included from Oxidized::Model::Macros
Oxidized::Model::Macros::VERBS
Instance Attribute Summary
Attributes inherited from Oxidized::Model
Attributes included from Oxidized::Model::DSLCommands
Instance Method Summary collapse
Methods inherited from Oxidized::Model
#cfg, #cmd, #comment, #expect, #expects, #get, inherited, #interpolate_string, #metadata, #output, #prompt, #screenscrape, #send, #significant_changes, #xmlcomment
Methods included from Oxidized::Model::DSLSetup
#cfg, #cfgs, #comment, #expect, #expects, #input_sequence, #inputs, #metadata, #prompt
Methods included from Oxidized::Model::DSLCommands
Methods included from Oxidized::Config::Vars
Instance Method Details
#collect_ixapps_configurations ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/oxidized/model/truenas.rb', line 61 def collect_ixapps_configurations config_command = <<~'CMDEND' if [ -d /mnt/.ix-apps ]; then sudo find /mnt/.ix-apps/app_configs \( -name "app.yaml" -or -name "user_config.yaml" -or -name "metadata.yaml" \) -printf "\n\n#######################\n# %p\n#######################\n" -exec cat {} \; ; else echo "# No Apps configuration found in /mnt/.ix-apps"; fi CMDEND cmd(config_command.gsub("\n", "")) end |
#filter_column(table_name, column_name) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/oxidized/model/truenas.rb', line 39 def filter_column(table_name, column_name) sqlite_cmd = "sqlite3 -readonly 'file:/data/freenas-v1.db'" # This SQL command will create a SELECT query with all columns except the one we want to skip. generate_select_cmd = "select 'select ' || group_concat(name,', ') || ' FROM #{table_name};' FROM pragma_table_info('#{table_name}') WHERE name != '#{column_name}';" select_stmt = cmd("#{sqlite_cmd} \"#{generate_select_cmd}\"") if select_stmt.include? "Error: unable to open database" # retry with sudo sqlite_cmd = "sudo #{sqlite_cmd}" select_stmt = cmd("#{sqlite_cmd} \"#{generate_select_cmd}\"") end insert_cmds = "-header '.mode insert #{table_name}' '#{select_stmt}'" cmd("#{sqlite_cmd} #{insert_cmds}") do |cfg| if cfg.include? "INSERT" # Don't add a COMMIT; if the query came up with no rows cfg + "COMMIT;\n" end end end |