Class: Elasticsnap::Snapshot

Inherits:
Object
  • Object
show all
Defined in:
lib/elasticsnap/snapshot.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(security_group: nil, url: nil, mount: nil, quorum_nodes: nil, wait_timeout: 30, cluster_name: nil, ssh_user: nil) ⇒ Snapshot

Returns a new instance of Snapshot.

Raises:

  • (ArgumentError)


16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/elasticsnap/snapshot.rb', line 16

def initialize(security_group: nil, url: nil, mount: nil, quorum_nodes: nil, wait_timeout: 30, cluster_name: nil, ssh_user: nil)
  raise ArgumentError, "security_group required" if security_group.nil?
  raise ArgumentError, "url required" if url.nil?
  raise ArgumentError, "mount required" if mount.nil?
  raise ArgumentError, "quorum_nodes required" if quorum_nodes.nil?

  @security_group = security_group
  @url = url
  @mount = mount
  @quorum_nodes = quorum_nodes
  @wait_timeout = wait_timeout
  @cluster_name = cluster_name
  @ssh_user = ssh_user
end

Instance Attribute Details

#cluster_nameObject

Returns the value of attribute cluster_name.



13
14
15
# File 'lib/elasticsnap/snapshot.rb', line 13

def cluster_name
  @cluster_name
end

#mountObject

Returns the value of attribute mount.



10
11
12
# File 'lib/elasticsnap/snapshot.rb', line 10

def mount
  @mount
end

#quorum_nodesObject

Returns the value of attribute quorum_nodes.



11
12
13
# File 'lib/elasticsnap/snapshot.rb', line 11

def quorum_nodes
  @quorum_nodes
end

#security_groupObject

Returns the value of attribute security_group.



8
9
10
# File 'lib/elasticsnap/snapshot.rb', line 8

def security_group
  @security_group
end

#ssh_userObject

Returns the value of attribute ssh_user.



14
15
16
# File 'lib/elasticsnap/snapshot.rb', line 14

def ssh_user
  @ssh_user
end

#urlObject

Returns the value of attribute url.



9
10
11
# File 'lib/elasticsnap/snapshot.rb', line 9

def url
  @url
end

#wait_timeoutObject

Returns the value of attribute wait_timeout.



12
13
14
# File 'lib/elasticsnap/snapshot.rb', line 12

def wait_timeout
  @wait_timeout
end

Instance Method Details

#callObject



31
32
33
34
35
36
37
38
# File 'lib/elasticsnap/snapshot.rb', line 31

def call
  verify_es_cluster_status!
  freeze_es do
    freeze_fs do
      ebs_snapshot!
    end
  end
end

#ebs_snapshot!Object



52
53
54
# File 'lib/elasticsnap/snapshot.rb', line 52

def ebs_snapshot!
  EbsSnapshot.new(security_group: security_group, cluster_name: cluster_name).snapshot
end

#freeze_es(&block) ⇒ Object



44
45
46
# File 'lib/elasticsnap/snapshot.rb', line 44

def freeze_es(&block)
  FreezeElasticsearch.new(url: url).freeze(&block)
end

#freeze_fs(&block) ⇒ Object



48
49
50
# File 'lib/elasticsnap/snapshot.rb', line 48

def freeze_fs(&block)
  FreezeFs.new(mount: mount, security_group: security_group, ssh_user: ssh_user).freeze(&block)
end

#verify_es_cluster_status!Object



40
41
42
# File 'lib/elasticsnap/snapshot.rb', line 40

def verify_es_cluster_status!
  VerifyEsClusterStatus.new(url: url, quorum_nodes: quorum_nodes, wait_timeout: wait_timeout).verify!
end