Class: Nexpose::Backup

Inherits:
Object
  • Object
show all
Defined in:
lib/nexpose/maint.rb

Overview

Details about an existing backup on the security console.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, date, description, version, independent, size) ⇒ Backup

Returns a new instance of Backup.



87
88
89
90
91
92
93
94
# File 'lib/nexpose/maint.rb', line 87

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

#dateObject (readonly)

Date the backup was made.



76
77
78
# File 'lib/nexpose/maint.rb', line 76

def date
  @date
end

#descriptionObject (readonly)

Description of the backup.



78
79
80
# File 'lib/nexpose/maint.rb', line 78

def description
  @description
end

#nameObject (readonly)

Filename



74
75
76
# File 'lib/nexpose/maint.rb', line 74

def name
  @name
end

#platform_independentObject (readonly)

Whether the backup is platform-idependent or not.



82
83
84
# File 'lib/nexpose/maint.rb', line 82

def platform_independent
  @platform_independent
end

#sizeObject (readonly)

Size of backup file on disk, in Bytes. Can be used to estimate the amount of time the backup may take to load.



85
86
87
# File 'lib/nexpose/maint.rb', line 85

def size
  @size
end

#versionObject (readonly)

Nexpose version the console was on when the backup was made.



80
81
82
# File 'lib/nexpose/maint.rb', line 80

def version
  @version
end

Class Method Details

.parse(hash) ⇒ Object



125
126
127
128
129
130
131
132
# File 'lib/nexpose/maint.rb', line 125

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.

Parameters:

  • nsc (Connection)

    An active connection to a Nexpose console.

Returns:

  • (Boolean)

    If the backup was removed.



117
118
119
120
121
122
123
# File 'lib/nexpose/maint.rb', line 117

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) ⇒ Boolean

Restore this backup to the Nexpose console. It will restart the console after acknowledging receiving the request.

Parameters:

  • nsc (Connection)

    An active connection to a Nexpose console.

Returns:

  • (Boolean)

    Whether the request was received.



102
103
104
105
106
107
108
109
110
# File 'lib/nexpose/maint.rb', line 102

def restore(nsc)
  parameters = { 'backupid' => @name,
                 'cmd' => 'restore',
                 'targetTask' => 'backupRestore' }
  xml = AJAX.form_post(nsc, '/admin/global/maintenance/maintCmd.txml', parameters)
  if !!(xml =~ /succeded="true"/)
    nsc._maintenance_restart
  end
end