CloudyScripts 1.8.30 → 1.8.31

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -12,7 +12,7 @@ require 'rake/testtask'
12
12
 
13
13
  spec = Gem::Specification.new do |s|
14
14
  s.name = 'CloudyScripts'
15
- s.version = '1.8.30'
15
+ s.version = '1.8.31'
16
16
  s.has_rdoc = true
17
17
  s.extra_rdoc_files = ['README.rdoc', 'LICENSE']
18
18
  s.summary = 'Scripts to facilitate programming for infrastructure clouds.'
@@ -69,14 +69,19 @@ class RemoteCommandHandler
69
69
  get_output("cat /etc/mtab | grep -E '[[:blank:]]+\/[[:blank:]]+' | cut -d ' ' -f 1").strip
70
70
  end
71
71
 
72
- # Get root partition label
73
- def get_root_label(root_device)
74
- get_output("e2label #{root_device}").strip
72
+ # Get partition label
73
+ def get_partition_device(part)
74
+ get_output("cat /etc/mtab | grep -E '[[:blank:]]+" + "#{part}" + "[[:blank:]]+' | cut -d ' ' -f 1").strip
75
+ end
76
+
77
+ # Get device label
78
+ def get_device_label(device)
79
+ get_output("e2label #{device}").strip
75
80
  end
76
81
 
77
- # Set root partition label
78
- def set_root_label(root_device, label)
79
- remote_execute("e2label #{root_device} #{label}", nil, false)
82
+ # Set device label
83
+ def set_device_label(device, label)
84
+ remote_execute("e2label #{device} #{label}", nil, false)
80
85
  end
81
86
 
82
87
  # Get filesystem type
@@ -84,6 +89,11 @@ class RemoteCommandHandler
84
89
  get_output("cat /etc/mtab | grep -E '[[:blank:]]+\/[[:blank:]]+' | cut -d ' ' -f 3").strip
85
90
  end
86
91
 
92
+ # Get filesystem type
93
+ def get_partition_fs_type(part)
94
+ get_output("cat /etc/mtab | grep -E '[[:blank:]]+" + "#{part}" + "[[:blank:]]+' | cut -d ' ' -f 3").strip
95
+ end
96
+
87
97
  # Installs the software package specified.
88
98
  def install(software_package)
89
99
  e = "yum -yq install #{software_package}"
@@ -280,7 +290,7 @@ class RemoteCommandHandler
280
290
  exec_string = "echo #{push_data} >tmp.txt; #{exec_string} <tmp.txt; rm -f tmp.txt" unless push_data == nil
281
291
  stdout = []
282
292
  stderr = []
283
- remote_exec_helper(exec_string, stdout, stderr)
293
+ remote_exec_helper(exec_string, stdout, stderr, true)
284
294
  stdout.join()
285
295
  end
286
296
 
@@ -478,7 +478,7 @@ module StateTransitionHelper
478
478
  if !label.nil? && !label.empty?
479
479
  post_message("going to add label #{label} for device #{device}...")
480
480
  @logger.debug "add label '#{label}' to device '#{device}'"
481
- if remote_handler().set_root_label(device, label)
481
+ if remote_handler().set_device_label(device, label)
482
482
  post_message("label #{label} added to device #{device}")
483
483
  else
484
484
  raise Exception.new("failed to add label #{label} to device #{device}")
@@ -580,7 +580,7 @@ module StateTransitionHelper
580
580
  # get root device and then its label
581
581
  root_device = remote_handler().get_root_device()
582
582
  @logger.debug "Found '#{root_device}' as root device"
583
- label = remote_handler().get_root_label(root_device)
583
+ label = remote_handler().get_device_label(root_device)
584
584
  @logger.debug "Found label '#{label}'"
585
585
  if label.nil? || label.empty?
586
586
  post_message("'/' root partition has no label specified")
@@ -590,7 +590,24 @@ module StateTransitionHelper
590
590
  return label
591
591
  end
592
592
 
593
- # get root filesytem type
593
+ # Get partition label
594
+ def get_partition_label(part)
595
+ post_message("Retrieving '#{part}' partition label if any...")
596
+ @logger.debug "get #{part} partition label"
597
+ # get part device and then its label
598
+ part_device = remote_handler().get_partition_device(part)
599
+ @logger.debug "Found '#{part_device}' as partition device"
600
+ label = remote_handler().get_device_label(part_device)
601
+ @logger.debug "Found label '#{label}'"
602
+ if label.nil? || label.empty?
603
+ post_message("'#{part}' partition has no label specified")
604
+ else
605
+ post_message("'#{part}' partition label '#{label}' for device node '#{part_device}'")
606
+ end
607
+ return label
608
+ end
609
+
610
+ # Get root filesytem type
594
611
  def get_root_partition_fs_type()
595
612
  post_message("Retrieving '/' root partition filesystem type...")
596
613
  @logger.debug "get root partition filesystel type"
@@ -603,7 +620,21 @@ module StateTransitionHelper
603
620
  post_message("'/' root partition contains an #{root_fs_type} filesystem")
604
621
  end
605
622
  return root_fs_type
606
-
623
+ end
624
+
625
+ # Get partition filesytem type
626
+ def get_partition_fs_type(part)
627
+ post_message("Retrieving '#{part}' partition filesystem type...")
628
+ @logger.debug "get #{part} partition filesystel type"
629
+ # get partition device and then its fs type
630
+ part_fs_type = remote_handler().get_partition_fs_type(part)
631
+ @logger.debug "Found '#{part_fs_type}' as filesystem type"
632
+ if part_fs_type.nil? || part_fs_type.empty?
633
+ raise Exception.new("Failed to retrieve filesystem type for '#{part}' partition")
634
+ else
635
+ post_message("'#{part}' partition contains an #{part_fs_type} filesystem")
636
+ end
637
+ return part_fs_type
607
638
  end
608
639
 
609
640
  # Copy all files of a running linux distribution via rsync to a mounted directory
@@ -96,9 +96,9 @@ class CopySnapshot< Ec2Script
96
96
  attach_volume(@context[:source_volume_id], @context[:source_instance_id], device)
97
97
  connect(@context[:source_dns_name], @context[:source_ssh_username], nil, @context[:source_ssh_keydata])
98
98
  mount_fs(mount_point, device)
99
- # get root partition label and filesystem type
100
- @context[:label] = get_root_partition_label()
101
- @context[:fs_type] = get_root_partition_fs_type()
99
+ # get partition label and filesystem type
100
+ @context[:label] = get_partition_label(mount_point)
101
+ @context[:fs_type] = get_partition_fs_type(mount_point)
102
102
  disconnect()
103
103
  SourceVolumeReadyState.new(@context)
104
104
  end
@@ -146,7 +146,9 @@ class CopySnapshot< Ec2Script
146
146
  path_candidates = ["/#{@context[:source_ssh_username]}/.ssh/",
147
147
  "/home/#{@context[:source_ssh_username]}/.ssh/"]
148
148
  key_path = determine_file(@context[:source_dns_name], @context[:source_ssh_username], @context[:source_ssh_keydata], path_candidates)
149
- upload_file(@context[:source_dns_name], "root", @context[:source_ssh_keydata],
149
+ #upload_file(@context[:source_dns_name], "root", @context[:source_ssh_keydata],
150
+ # @context[:target_ssh_keyfile], "#{key_path}#{@context[:target_key_name]}.pem")
151
+ upload_file(@context[:source_dns_name], @context[:source_ssh_username], @context[:source_ssh_keydata],
150
152
  @context[:target_ssh_keyfile], "#{key_path}#{@context[:target_key_name]}.pem")
151
153
  post_message("credentials are in place to connect source and target.")
152
154
  KeyInPlaceState.new(@context)
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: CloudyScripts
3
3
  version: !ruby/object:Gem::Version
4
- hash: 11
4
+ hash: 9
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 8
9
- - 30
10
- version: 1.8.30
9
+ - 31
10
+ version: 1.8.31
11
11
  platform: ruby
12
12
  authors:
13
13
  - Matthias Jung
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-07-19 00:00:00 +00:00
18
+ date: 2011-07-28 00:00:00 +00:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency