Class: Nexpose::Backup
- Inherits:
-
Object
- Object
- Nexpose::Backup
- Defined in:
- lib/nexpose/maint.rb
Overview
Details about an existing backup on the security console.
Instance Attribute Summary collapse
-
#date ⇒ Object
readonly
Date the backup was made.
-
#description ⇒ Object
readonly
Description of the backup.
-
#name ⇒ Object
readonly
Filename.
-
#platform_independent ⇒ Object
readonly
Whether the backup is platform-idependent or not.
-
#size ⇒ Object
readonly
Size of backup file on disk, in Bytes.
-
#version ⇒ Object
readonly
Nexpose version the console was on when the backup was made.
Class Method Summary collapse
Instance Method Summary collapse
-
#delete(nsc) ⇒ Boolean
Remove this backup file from the security console.
-
#initialize(name, date, description, version, independent, size) ⇒ Backup
constructor
A new instance of Backup.
-
#restore(nsc, password = nil) ⇒ Boolean
Restore this backup to the Nexpose console.
Constructor Details
#initialize(name, date, description, version, independent, size) ⇒ Backup
Returns a new instance of Backup.
86 87 88 89 90 91 92 93 |
# File 'lib/nexpose/maint.rb', line 86 def initialize(name, date, description, version, independent, size) @name = name @date = date @description = description @version = version @platform_independent = independent @size = size end |
Instance Attribute Details
#date ⇒ Object (readonly)
Date the backup was made.
75 76 77 |
# File 'lib/nexpose/maint.rb', line 75 def date @date end |
#description ⇒ Object (readonly)
Description of the backup.
77 78 79 |
# File 'lib/nexpose/maint.rb', line 77 def description @description end |
#name ⇒ Object (readonly)
Filename
73 74 75 |
# File 'lib/nexpose/maint.rb', line 73 def name @name end |
#platform_independent ⇒ Object (readonly)
Whether the backup is platform-idependent or not.
81 82 83 |
# File 'lib/nexpose/maint.rb', line 81 def platform_independent @platform_independent end |
#size ⇒ Object (readonly)
Size of backup file on disk, in Bytes. Can be used to estimate the amount of time the backup may take to load.
84 85 86 |
# File 'lib/nexpose/maint.rb', line 84 def size @size end |
#version ⇒ Object (readonly)
Nexpose version the console was on when the backup was made.
79 80 81 |
# File 'lib/nexpose/maint.rb', line 79 def version @version end |
Class Method Details
.parse(hash) ⇒ Object
127 128 129 130 131 132 133 134 |
# File 'lib/nexpose/maint.rb', line 127 def self.parse(hash) new(hash['Download'], Time.at(hash['Date'].to_i / 1000), hash['Description'], hash['Version'], hash['Platform-Independent'], hash['Size']) end |
Instance Method Details
#delete(nsc) ⇒ Boolean
Remove this backup file from the security console.
119 120 121 122 123 124 125 |
# File 'lib/nexpose/maint.rb', line 119 def delete(nsc) parameters = { 'backupid' => @name, 'cmd' => 'deleteBackup', 'targetTask' => 'backupRestore' } xml = AJAX.form_post(nsc, '/admin/global/maintenance/maintCmd.txml', parameters) !!(xml =~ /succeded="true"/) end |
#restore(nsc, password = nil) ⇒ Boolean
Restore this backup to the Nexpose console. It will restart the console after acknowledging receiving the request.
102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/nexpose/maint.rb', line 102 def restore(nsc, password = nil) raise 'Supplied Password is incorrect for restoring this Backup.' if invalid_backup_password?(nsc, password) parameters = { 'backupid' => @name, 'cmd' => 'restore', 'targetTask' => 'backupRestore', 'password' => password } xml = AJAX.form_post(nsc, '/admin/global/maintenance/maintCmd.txml', parameters) if !!(xml =~ /succeded="true"/) nsc._maintenance_restart end end |