CloudyScripts 1.8.31 → 1.8.32
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -1
- data/lib/help/remote_command_handler.rb +20 -0
- data/lib/help/state_transition_helper.rb +65 -3
- data/lib/scripts/ec2/copy_ami.rb +3 -2
- data/lib/scripts/ec2/copy_snapshot.rb +3 -2
- metadata +4 -4
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.
|
15
|
+
s.version = '1.8.32'
|
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.'
|
@@ -79,11 +79,31 @@ class RemoteCommandHandler
|
|
79
79
|
get_output("e2label #{device}").strip
|
80
80
|
end
|
81
81
|
|
82
|
+
# Get device label
|
83
|
+
def get_device_label_ext(device, fs_type)
|
84
|
+
if fs_type.eql?("xfs")
|
85
|
+
cmd = "xfs_admin -l #{device} | sed -r -e 's/^label[[:blank:]]*=[[:blank:]]*\"(.*)\"$/\\1/'"
|
86
|
+
else
|
87
|
+
cmd = "e2label #{device}"
|
88
|
+
end
|
89
|
+
get_output(cmd).strip
|
90
|
+
end
|
91
|
+
|
82
92
|
# Set device label
|
83
93
|
def set_device_label(device, label)
|
84
94
|
remote_execute("e2label #{device} #{label}", nil, false)
|
85
95
|
end
|
86
96
|
|
97
|
+
# Set device label
|
98
|
+
def set_device_label_ext(device, label, fs_type)
|
99
|
+
if fs_type.eql?("xfs")
|
100
|
+
cmd = "xfs_admin -L #{label} #{device}"
|
101
|
+
else
|
102
|
+
cmd = "e2label #{device} #{label}"
|
103
|
+
end
|
104
|
+
remote_execute("e2label #{device} #{label}", nil, false)
|
105
|
+
end
|
106
|
+
|
87
107
|
# Get filesystem type
|
88
108
|
def get_root_fs_type()
|
89
109
|
get_output("cat /etc/mtab | grep -E '[[:blank:]]+\/[[:blank:]]+' | cut -d ' ' -f 3").strip
|
@@ -428,7 +428,7 @@ module StateTransitionHelper
|
|
428
428
|
# * image_id => ID of the AMI created and registered
|
429
429
|
def register_snapshot(snapshot_id, name, root_device_name, description, kernel_id, ramdisk_id, architecture)
|
430
430
|
post_message("going to register snapshot #{snapshot_id}...")
|
431
|
-
@logger.debug "register snapshot #{snapshot_id} as #{name}"
|
431
|
+
@logger.debug "register snapshot #{snapshot_id} as #{name} using AKI '#{kernel_id}' ARI '#{ramdisk_id}' and arch '#{architecture}'"
|
432
432
|
res = ec2_handler().register_image_updated(:snapshot_id => snapshot_id,
|
433
433
|
:kernel_id => kernel_id, :architecture => architecture,
|
434
434
|
:root_device_name => root_device_name,
|
@@ -474,11 +474,11 @@ module StateTransitionHelper
|
|
474
474
|
if status == false
|
475
475
|
raise Exception.new("failed to create #{type} filesystem on #{device} device on #{dns_name}")
|
476
476
|
end
|
477
|
-
post_message("filesystem system successfully created")
|
477
|
+
post_message("#{fs_type} filesystem system successfully created on device #{device}")
|
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().
|
481
|
+
if remote_handler().set_device_label_ext(device, label, fs_type)
|
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}")
|
@@ -622,6 +622,35 @@ module StateTransitionHelper
|
|
622
622
|
return root_fs_type
|
623
623
|
end
|
624
624
|
|
625
|
+
# Get root filesytem type and label
|
626
|
+
def get_root_partition_fs_type_and_label()
|
627
|
+
post_message("Retrieving '/' root partition filesystem type and label...")
|
628
|
+
@logger.debug "get root partition filesystel type"
|
629
|
+
# get root device and then its fs type
|
630
|
+
root_fs_type = remote_handler().get_root_fs_type()
|
631
|
+
@logger.debug "Found '#{root_fs_type}' as root filesystem type"
|
632
|
+
if root_fs_type.nil? || root_fs_type.empty?
|
633
|
+
raise Exception.new("Failed to retrieve filesystem type for '/' root partition")
|
634
|
+
else
|
635
|
+
post_message("'/' root partition contains an #{root_fs_type} filesystem")
|
636
|
+
end
|
637
|
+
root_device = remote_handler().get_root_device()
|
638
|
+
@logger.debug "Found '#{root_device}' as root device"
|
639
|
+
if root_device.nil? || root_device.empty?
|
640
|
+
raise Exception.new("Failed to retrieve root device for '/' root partition")
|
641
|
+
else
|
642
|
+
post_message("'/' root partitition on root device '#{root_device}'")
|
643
|
+
end
|
644
|
+
root_label = remote_handler().get_device_label_ext(root_device, root_fs_type)
|
645
|
+
@logger.debug "Found label '#{root_label}'"
|
646
|
+
if root_label.nil? || root_label.empty?
|
647
|
+
post_message("'/' root partition has no label specified")
|
648
|
+
else
|
649
|
+
post_message("'/' root partition label '#{root_label}' for root device node '#{root_device}'")
|
650
|
+
end
|
651
|
+
return root_fs_type, root_label
|
652
|
+
end
|
653
|
+
|
625
654
|
# Get partition filesytem type
|
626
655
|
def get_partition_fs_type(part)
|
627
656
|
post_message("Retrieving '#{part}' partition filesystem type...")
|
@@ -637,6 +666,35 @@ module StateTransitionHelper
|
|
637
666
|
return part_fs_type
|
638
667
|
end
|
639
668
|
|
669
|
+
# Get partition filesytem type and label
|
670
|
+
def get_partition_fs_type_and_label(part)
|
671
|
+
post_message("Retrieving '#{part}' partition filesystem type...")
|
672
|
+
@logger.debug "get #{part} partition filesystel type"
|
673
|
+
# get partition device and then its fs type
|
674
|
+
part_fs_type = remote_handler().get_partition_fs_type(part)
|
675
|
+
@logger.debug "Found '#{part_fs_type}' as filesystem type"
|
676
|
+
if part_fs_type.nil? || part_fs_type.empty?
|
677
|
+
raise Exception.new("Failed to retrieve filesystem type for '#{part}' partition")
|
678
|
+
else
|
679
|
+
post_message("'#{part}' partition contains an #{part_fs_type} filesystem")
|
680
|
+
end
|
681
|
+
part_device = remote_handler().get_partition_device(part)
|
682
|
+
@logger.debug "Found '#{part_device}' as partition device"
|
683
|
+
if part_device.nil? || part_device.empty?
|
684
|
+
raise Exception.new("Failed to retrieve device for '#{part}' partition")
|
685
|
+
else
|
686
|
+
post_message("'#{part}' partitition on device '#{part_device}'")
|
687
|
+
end
|
688
|
+
part_label = remote_handler().get_device_label_ext(part_device, part_fs_type)
|
689
|
+
@logger.debug "Found label '#{part_label}'"
|
690
|
+
if part_label.nil? || part_label.empty?
|
691
|
+
post_message("'#{part}' partition has no label specified")
|
692
|
+
else
|
693
|
+
post_message("'#{part}' partition label '#{part_label}' for device node '#{part_device}'")
|
694
|
+
end
|
695
|
+
return part_fs_type, part_label
|
696
|
+
end
|
697
|
+
|
640
698
|
# Copy all files of a running linux distribution via rsync to a mounted directory
|
641
699
|
# Input Parameters:
|
642
700
|
# * destination_path => where to copy to
|
@@ -851,6 +909,8 @@ module StateTransitionHelper
|
|
851
909
|
}
|
852
910
|
}
|
853
911
|
target_aki = ''
|
912
|
+
post_message("mapping AKI '#{source_aki}' from #{source_region} region to #{target_region} region...")
|
913
|
+
|
854
914
|
if map[source_region] == nil
|
855
915
|
Exception.new("source region not supported")
|
856
916
|
elsif map[target_region] == nil
|
@@ -862,12 +922,14 @@ module StateTransitionHelper
|
|
862
922
|
pv_grub_info = map[source_region][source_aki]
|
863
923
|
map[target_region].each() {|key, value|
|
864
924
|
if pv_grub_info.eql?(value)
|
925
|
+
@logger.debug "found AKI: #{key} for #{value}"
|
865
926
|
target_aki = key
|
866
927
|
break
|
867
928
|
end
|
868
929
|
}
|
869
930
|
end
|
870
931
|
end
|
932
|
+
post_message("AKI mapped to #{target_aki}")
|
871
933
|
return target_aki
|
872
934
|
end
|
873
935
|
|
data/lib/scripts/ec2/copy_ami.rb
CHANGED
@@ -121,8 +121,9 @@ class CopyAmi < Ec2Script
|
|
121
121
|
connect(@context[:source_dns_name], @context[:source_ssh_username], nil, @context[:source_ssh_keydata])
|
122
122
|
mount_fs(mount_point, device)
|
123
123
|
# get root partition label and filesystem type
|
124
|
-
|
125
|
-
|
124
|
+
#@context[:label] = get_root_partition_label()
|
125
|
+
#@context[:fs_type] = get_root_partition_fs_type()
|
126
|
+
@context[:fs_type], @context[:label] = get_root_partition_fs_type_and_label()
|
126
127
|
disconnect()
|
127
128
|
SourceVolumeReadyState.new(@context)
|
128
129
|
end
|
@@ -97,8 +97,9 @@ class CopySnapshot< Ec2Script
|
|
97
97
|
connect(@context[:source_dns_name], @context[:source_ssh_username], nil, @context[:source_ssh_keydata])
|
98
98
|
mount_fs(mount_point, device)
|
99
99
|
# get partition label and filesystem type
|
100
|
-
|
101
|
-
|
100
|
+
#@context[:label] = get_partition_label(mount_point)
|
101
|
+
#@context[:fs_type] = get_partition_fs_type(mount_point)
|
102
|
+
@context[:fs_type], @context[:label] = get_partition_fs_type_and_label(mount_point)
|
102
103
|
disconnect()
|
103
104
|
SourceVolumeReadyState.new(@context)
|
104
105
|
end
|
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:
|
4
|
+
hash: 119
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 8
|
9
|
-
-
|
10
|
-
version: 1.8.
|
9
|
+
- 32
|
10
|
+
version: 1.8.32
|
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-
|
18
|
+
date: 2011-07-29 00:00:00 +00:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|