Class: Comet::SourceConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/comet/models/source_config.rb

Overview

SourceConfig is a typed class wrapper around the underlying Comet Server API data structure.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeSourceConfig

Returns a new instance of SourceConfig.



115
116
117
# File 'lib/comet/models/source_config.rb', line 115

def initialize
  clear
end

Instance Attribute Details

#create_timeObject

Unix timestamp in seconds



27
28
29
# File 'lib/comet/models/source_config.rb', line 27

def create_time
  @create_time
end

#descriptionObject

Returns the value of attribute description.



20
21
22
# File 'lib/comet/models/source_config.rb', line 20

def description
  @description
end

#engineObject

One of the ENGINE_BUILTIN_ constants



17
18
19
# File 'lib/comet/models/source_config.rb', line 17

def engine
  @engine
end

#engine_propsObject

Configuration for the selected Protected Item type. Each “Engine” supports different configuration options for the EngineProps values.

For engine1/file, Comet understands the following EngineProp keys:

  • Any key starting with INCLUDE: A path that is included

  • Any key starting with EXCLUDE: An exclusion (glob format)

  • Any key starting with REXCLUDE: An exclusion (regular expression format)

  • Any key starting with PINCLUDE: A SourceIncludePattern type encoded in JSON format, describing

an advanced inclusion in glob format

  • Any key starting with RINCLUDE: A SourceIncludePattern type encoded in JSON format, describing

an advanced inclusion in regular expression format

  • Any key starting with SMBAUTH: A set of Windows network share credentials in WinSMBAuth JSON

format

  • USE_WIN_VSS: If present, the ‘Take filesystem snapshot’ checkbox is checked

  • CONFIRM_EFS: If present, the ‘Dismiss EFS warning’ checkbox is checked

  • RESCAN_UNCHANGED: If present, the ‘Rescan unchanged files’ checkbox is checked

For engine1/mssql, Comet understands the following EngineProp keys:

  • ALL_DATABASES: If present, include all databases with specified exclusions. If not present, only

back up the specified inclusions

  • Any key starting with DATABASE- : A database that is included. Only valid if ALL_DATABASES is

not present.

  • Any key starting with EXCEPT-DATABASE- : A database that is excluded. Only valid if

ALL_DATABASES is present.

  • INSTANCE: The Microsoft SQL Server instance name

  • USERNAME: The username to connect to Microsoft SQL Server

  • PASSWORD: The password to connect to Microsoft SQL Server

  • AUTHMODE: Either “windows” or “native” (corresponding to the declared MSSQL_AUTH_WINDOWS and

MSSQL_AUTH_NATIVE constant values). If not present, use native authentication if the USERNAME and/or PASSWORD fields are filled in, use windows authentication if they are blank

  • METHOD: Either “OLEDB_NATIVE” or “OLEDB_32” (corresponding to the declared

MSSQL_METHOD_OLEDB_NATIVE and MSSQL_METHOD_OLEDB_32 constant values). If not present, defaults to Native

  • DIFFBASE: If present, take a “Full (base image)” backup job. Otherwise, take a “Full (copy

only)“ backup job.

  • DIFFERENTIAL: If present, take a “Differential increment” backup job. Otherwise, take a “Full

(copy only)“ backup job.

  • LOGTRUNC: If present, take a “Log (truncating)” backup job. Otherwise, take a “Full (copy only)”

backup job.

  • LOGNOTRUNC: If present, take a “Log (no truncation)” backup job. Otherwise, take a “Full (copy

only)“ backup job.



90
91
92
# File 'lib/comet/models/source_config.rb', line 90

def engine_props
  @engine_props
end

#existing_user_updateObject

For a Policy-defined SourceConfig, this field controls whether the Protected Item will stay linked with the policy. This field is available in Comet 23.6.0 and later.



101
102
103
# File 'lib/comet/models/source_config.rb', line 101

def existing_user_update
  @existing_user_update
end

#modify_timeObject

Unix timestamp in seconds



31
32
33
# File 'lib/comet/models/source_config.rb', line 31

def modify_time
  @modify_time
end

#override_destination_retentionObject

By default, backup jobs from this Protected Item will be subject to the overall retention policy for the Storage Vault. You can override the policy for specific Storage Vaults by putting their destination ID as a key here.



107
108
109
# File 'lib/comet/models/source_config.rb', line 107

def override_destination_retention
  @override_destination_retention
end

#owner_deviceObject

Returns the value of attribute owner_device.



23
24
25
# File 'lib/comet/models/source_config.rb', line 23

def owner_device
  @owner_device
end

#policy_source_idObject

If set, this SourceConfig was added from a Policy with the specified ID. This field is available in Comet 23.6.0 and later.



95
96
97
# File 'lib/comet/models/source_config.rb', line 95

def policy_source_id
  @policy_source_id
end

#post_execObject

Custom commands to run after the job



43
44
45
# File 'lib/comet/models/source_config.rb', line 43

def post_exec
  @post_exec
end

#pre_execObject

Custom commands to run before the job



35
36
37
# File 'lib/comet/models/source_config.rb', line 35

def pre_exec
  @pre_exec
end

#statisticsObject

Returns the value of attribute statistics.



110
111
112
# File 'lib/comet/models/source_config.rb', line 110

def statistics
  @statistics
end

#thaw_execObject

Custom commands to run after taking a disk snapshot



39
40
41
# File 'lib/comet/models/source_config.rb', line 39

def thaw_exec
  @thaw_exec
end

#unknown_json_fieldsObject

Returns the value of attribute unknown_json_fields.



113
114
115
# File 'lib/comet/models/source_config.rb', line 113

def unknown_json_fields
  @unknown_json_fields
end

Instance Method Details

#clearObject



119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# File 'lib/comet/models/source_config.rb', line 119

def clear
  @engine = ''
  @description = ''
  @owner_device = ''
  @create_time = 0
  @modify_time = 0
  @pre_exec = []
  @thaw_exec = []
  @post_exec = []
  @engine_props = {}
  @policy_source_id = ''
  @override_destination_retention = {}
  @statistics = Comet::SourceStatistics.new
  @unknown_json_fields = {}
end

#from_hash(obj) ⇒ Object

Parameters:

  • obj (Hash)

    The complete object as a Ruby hash

Raises:

  • (TypeError)


143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
# File 'lib/comet/models/source_config.rb', line 143

def from_hash(obj)
  raise TypeError, "'obj' expected Hash, got #{obj.class}" unless obj.is_a? Hash

  obj.each do |k, v|
    case k
    when 'Engine'
      raise TypeError, "'v' expected String, got #{v.class}" unless v.is_a? String

      @engine = v
    when 'Description'
      raise TypeError, "'v' expected String, got #{v.class}" unless v.is_a? String

      @description = v
    when 'OwnerDevice'
      raise TypeError, "'v' expected String, got #{v.class}" unless v.is_a? String

      @owner_device = v
    when 'CreateTime'
      raise TypeError, "'v' expected Numeric, got #{v.class}" unless v.is_a? Numeric

      @create_time = v
    when 'ModifyTime'
      raise TypeError, "'v' expected Numeric, got #{v.class}" unless v.is_a? Numeric

      @modify_time = v
    when 'PreExec'
      if v.nil?
        @pre_exec = []
      else
        @pre_exec = Array.new(v.length)
        v.each_with_index do |v1, i1|
          raise TypeError, "'v1' expected String, got #{v1.class}" unless v1.is_a? String

          @pre_exec[i1] = v1
        end
      end
    when 'ThawExec'
      if v.nil?
        @thaw_exec = []
      else
        @thaw_exec = Array.new(v.length)
        v.each_with_index do |v1, i1|
          raise TypeError, "'v1' expected String, got #{v1.class}" unless v1.is_a? String

          @thaw_exec[i1] = v1
        end
      end
    when 'PostExec'
      if v.nil?
        @post_exec = []
      else
        @post_exec = Array.new(v.length)
        v.each_with_index do |v1, i1|
          raise TypeError, "'v1' expected String, got #{v1.class}" unless v1.is_a? String

          @post_exec[i1] = v1
        end
      end
    when 'EngineProps'
      @engine_props = {}
      if v.nil?
        @engine_props = {}
      else
        v.each do |k1, v1|
          raise TypeError, "'v1' expected String, got #{v1.class}" unless v1.is_a? String

          @engine_props[k1] = v1
        end
      end
    when 'PolicySourceID'
      raise TypeError, "'v' expected String, got #{v.class}" unless v.is_a? String

      @policy_source_id = v
    when 'ExistingUserUpdate'
      @existing_user_update = v
    when 'OverrideDestinationRetention'
      @override_destination_retention = {}
      if v.nil?
        @override_destination_retention = {}
      else
        v.each do |k1, v1|
          @override_destination_retention[k1] = Comet::RetentionPolicy.new
          @override_destination_retention[k1].from_hash(v1)
        end
      end
    when 'Statistics'
      @statistics = Comet::SourceStatistics.new
      @statistics.from_hash(v)
    else
      @unknown_json_fields[k] = v
    end
  end
end

#from_json(json_string) ⇒ Object

Parameters:

  • json_string (String)

    The complete object in JSON format

Raises:

  • (TypeError)


136
137
138
139
140
# File 'lib/comet/models/source_config.rb', line 136

def from_json(json_string)
  raise TypeError, "'json_string' expected String, got #{json_string.class}" unless json_string.is_a? String

  from_hash(JSON.parse(json_string))
end

#to_hHash

Returns The complete object as a Ruby hash.

Returns:

  • (Hash)

    The complete object as a Ruby hash



264
265
266
# File 'lib/comet/models/source_config.rb', line 264

def to_h
  to_hash
end

#to_hashHash

Returns The complete object as a Ruby hash.

Returns:

  • (Hash)

    The complete object as a Ruby hash



238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
# File 'lib/comet/models/source_config.rb', line 238

def to_hash
  ret = {}
  ret['Engine'] = @engine
  ret['Description'] = @description
  ret['OwnerDevice'] = @owner_device
  ret['CreateTime'] = @create_time
  ret['ModifyTime'] = @modify_time
  ret['PreExec'] = @pre_exec
  ret['ThawExec'] = @thaw_exec
  ret['PostExec'] = @post_exec
  ret['EngineProps'] = @engine_props
  ret['PolicySourceID'] = @policy_source_id
  ret['ExistingUserUpdate'] = @existing_user_update
  unless @override_destination_retention.nil?
    ret['OverrideDestinationRetention'] = @override_destination_retention
  end
  unless @statistics.nil?
    ret['Statistics'] = @statistics
  end
  @unknown_json_fields.each do |k, v|
    ret[k] = v
  end
  ret
end

#to_json(options = {}) ⇒ String

Returns The complete object as a JSON string.

Returns:

  • (String)

    The complete object as a JSON string



269
270
271
# File 'lib/comet/models/source_config.rb', line 269

def to_json(options = {})
  to_hash.to_json(options)
end