cft_smartcloud 0.1.8 → 0.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +0 -1
- data/VERSION +1 -1
- data/bin/cft_smartcloud +11 -1
- data/bin/smartcloud +11 -1
- data/cft_smartcloud.gemspec +91 -2
- data/lib/cli_tools/README.txt +50 -0
- data/lib/cli_tools/ic-add-keypair.cmd +29 -0
- data/lib/cli_tools/ic-add-keypair.sh +15 -0
- data/lib/cli_tools/ic-allocate-address.cmd +29 -0
- data/lib/cli_tools/ic-allocate-address.sh +14 -0
- data/lib/cli_tools/ic-attach-volume.cmd +27 -0
- data/lib/cli_tools/ic-attach-volume.sh +27 -0
- data/lib/cli_tools/ic-clone-image.cmd +27 -0
- data/lib/cli_tools/ic-clone-image.sh +14 -0
- data/lib/cli_tools/ic-clone-volume.cmd +27 -0
- data/lib/cli_tools/ic-clone-volume.sh +60 -0
- data/lib/cli_tools/ic-cmd.cmd +41 -0
- data/lib/cli_tools/ic-cmd.sh +38 -0
- data/lib/cli_tools/ic-create-instance.cmd +27 -0
- data/lib/cli_tools/ic-create-instance.sh +14 -0
- data/lib/cli_tools/ic-create-password.cmd +27 -0
- data/lib/cli_tools/ic-create-password.sh +14 -0
- data/lib/cli_tools/ic-create-volume.cmd +27 -0
- data/lib/cli_tools/ic-create-volume.sh +14 -0
- data/lib/cli_tools/ic-delete-image.cmd +27 -0
- data/lib/cli_tools/ic-delete-image.sh +14 -0
- data/lib/cli_tools/ic-delete-instance.cmd +27 -0
- data/lib/cli_tools/ic-delete-instance.sh +14 -0
- data/lib/cli_tools/ic-delete-volume.cmd +27 -0
- data/lib/cli_tools/ic-delete-volume.sh +14 -0
- data/lib/cli_tools/ic-describe-address-offerings.cmd +27 -0
- data/lib/cli_tools/ic-describe-address-offerings.sh +14 -0
- data/lib/cli_tools/ic-describe-addresses.cmd +27 -0
- data/lib/cli_tools/ic-describe-addresses.sh +14 -0
- data/lib/cli_tools/ic-describe-image-agreement.cmd +27 -0
- data/lib/cli_tools/ic-describe-image-agreement.sh +14 -0
- data/lib/cli_tools/ic-describe-image.cmd +27 -0
- data/lib/cli_tools/ic-describe-image.sh +14 -0
- data/lib/cli_tools/ic-describe-images.cmd +27 -0
- data/lib/cli_tools/ic-describe-images.sh +14 -0
- data/lib/cli_tools/ic-describe-instance.cmd +27 -0
- data/lib/cli_tools/ic-describe-instance.sh +14 -0
- data/lib/cli_tools/ic-describe-instances.cmd +27 -0
- data/lib/cli_tools/ic-describe-instances.sh +14 -0
- data/lib/cli_tools/ic-describe-keypair.cmd +27 -0
- data/lib/cli_tools/ic-describe-keypair.sh +14 -0
- data/lib/cli_tools/ic-describe-keypairs.cmd +27 -0
- data/lib/cli_tools/ic-describe-keypairs.sh +14 -0
- data/lib/cli_tools/ic-describe-location.cmd +14 -0
- data/lib/cli_tools/ic-describe-location.sh +14 -0
- data/lib/cli_tools/ic-describe-locations.cmd +14 -0
- data/lib/cli_tools/ic-describe-locations.sh +14 -0
- data/lib/cli_tools/ic-describe-request.cmd +27 -0
- data/lib/cli_tools/ic-describe-request.sh +14 -0
- data/lib/cli_tools/ic-describe-vlans.cmd +27 -0
- data/lib/cli_tools/ic-describe-vlans.sh +14 -0
- data/lib/cli_tools/ic-describe-volume-offerings.cmd +27 -0
- data/lib/cli_tools/ic-describe-volume-offerings.sh +14 -0
- data/lib/cli_tools/ic-describe-volume.cmd +27 -0
- data/lib/cli_tools/ic-describe-volume.sh +14 -0
- data/lib/cli_tools/ic-describe-volumes.cmd +27 -0
- data/lib/cli_tools/ic-describe-volumes.sh +14 -0
- data/lib/cli_tools/ic-detach-volume.cmd +27 -0
- data/lib/cli_tools/ic-detach-volume.sh +27 -0
- data/lib/cli_tools/ic-extend-reservation.cmd +27 -0
- data/lib/cli_tools/ic-extend-reservation.sh +14 -0
- data/lib/cli_tools/ic-generate-keypair.cmd +27 -0
- data/lib/cli_tools/ic-generate-keypair.sh +14 -0
- data/lib/cli_tools/ic-release-address.cmd +27 -0
- data/lib/cli_tools/ic-release-address.sh +14 -0
- data/lib/cli_tools/ic-remove-keypair.cmd +27 -0
- data/lib/cli_tools/ic-remove-keypair.sh +14 -0
- data/lib/cli_tools/ic-restart-instance.cmd +27 -0
- data/lib/cli_tools/ic-restart-instance.sh +14 -0
- data/lib/cli_tools/ic-save-instance.cmd +27 -0
- data/lib/cli_tools/ic-save-instance.sh +14 -0
- data/lib/cli_tools/ic-set-default-key.cmd +27 -0
- data/lib/cli_tools/ic-set-default-key.sh +14 -0
- data/lib/cli_tools/ic-update-instance.cmd +27 -0
- data/lib/cli_tools/ic-update-instance.sh +14 -0
- data/lib/cli_tools/ic-update-keypair.cmd +27 -0
- data/lib/cli_tools/ic-update-keypair.sh +14 -0
- data/lib/cli_tools/lib/DeveloperCloud_API_Client_JAR.jar +0 -0
- data/lib/cli_tools/lib/DeveloperCloud_CMD_Tool.jar +0 -0
- data/lib/cli_tools/lib/commons-beanutils-1.6.1.jar +0 -0
- data/lib/cli_tools/lib/commons-cli-1.2.jar +0 -0
- data/lib/cli_tools/lib/commons-codec-1.3.jar +0 -0
- data/lib/cli_tools/lib/commons-collections-3.2.1.jar +0 -0
- data/lib/cli_tools/lib/commons-digester-1.8.jar +0 -0
- data/lib/cli_tools/lib/commons-httpclient-3.1.jar +0 -0
- data/lib/cli_tools/lib/commons-lang-2.3.jar +0 -0
- data/lib/cli_tools/lib/commons-logging-1.1.1.jar +0 -0
- data/lib/cli_tools/logging.properties +7 -0
- data/lib/cli_tools/manifest.rmd +26 -0
- data/lib/mock_smartcloud.rb +12 -4
- data/lib/smartcloud.rb +101 -15
- metadata +92 -3
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
############################################################################
|
|
3
|
+
#
|
|
4
|
+
# Licensed Materials - Property of IBM
|
|
5
|
+
#
|
|
6
|
+
# (C) COPYRIGHT International Business Machines Corp. 2009
|
|
7
|
+
#
|
|
8
|
+
# All Rights Reserved.
|
|
9
|
+
#
|
|
10
|
+
# US Government Users Restricted Rights - Use, duplication or
|
|
11
|
+
# disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
|
|
12
|
+
#
|
|
13
|
+
#############################################################################
|
|
14
|
+
./ic-cmd.sh -action RestartInstance $*
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
@echo off
|
|
2
|
+
|
|
3
|
+
REM ###########################################################################
|
|
4
|
+
|
|
5
|
+
REM #
|
|
6
|
+
|
|
7
|
+
REM # Licensed Materials - Property of IBM
|
|
8
|
+
|
|
9
|
+
REM #
|
|
10
|
+
|
|
11
|
+
REM # (C) COPYRIGHT International Business Machines Corp. 2009
|
|
12
|
+
|
|
13
|
+
REM #
|
|
14
|
+
|
|
15
|
+
REM # All Rights Reserved.
|
|
16
|
+
|
|
17
|
+
REM #
|
|
18
|
+
|
|
19
|
+
REM # US Government Users Restricted Rights - Use, duplication or
|
|
20
|
+
|
|
21
|
+
REM # disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
|
|
22
|
+
|
|
23
|
+
REM #
|
|
24
|
+
|
|
25
|
+
REM #############################################################################
|
|
26
|
+
|
|
27
|
+
ic-cmd.cmd -action SaveInstance %*
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
############################################################################
|
|
3
|
+
#
|
|
4
|
+
# Licensed Materials - Property of IBM
|
|
5
|
+
#
|
|
6
|
+
# (C) COPYRIGHT International Business Machines Corp. 2009
|
|
7
|
+
#
|
|
8
|
+
# All Rights Reserved.
|
|
9
|
+
#
|
|
10
|
+
# US Government Users Restricted Rights - Use, duplication or
|
|
11
|
+
# disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
|
|
12
|
+
#
|
|
13
|
+
#############################################################################
|
|
14
|
+
./ic-cmd.sh -action SaveInstance $*
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
@echo off
|
|
2
|
+
|
|
3
|
+
REM ###########################################################################
|
|
4
|
+
|
|
5
|
+
REM #
|
|
6
|
+
|
|
7
|
+
REM # Licensed Materials - Property of IBM
|
|
8
|
+
|
|
9
|
+
REM #
|
|
10
|
+
|
|
11
|
+
REM # (C) COPYRIGHT International Business Machines Corp. 2009
|
|
12
|
+
|
|
13
|
+
REM #
|
|
14
|
+
|
|
15
|
+
REM # All Rights Reserved.
|
|
16
|
+
|
|
17
|
+
REM #
|
|
18
|
+
|
|
19
|
+
REM # US Government Users Restricted Rights - Use, duplication or
|
|
20
|
+
|
|
21
|
+
REM # disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
|
|
22
|
+
|
|
23
|
+
REM #
|
|
24
|
+
|
|
25
|
+
REM #############################################################################
|
|
26
|
+
|
|
27
|
+
ic-cmd.cmd -action SetDefaultKey %*
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
############################################################################
|
|
3
|
+
#
|
|
4
|
+
# Licensed Materials - Property of IBM
|
|
5
|
+
#
|
|
6
|
+
# (C) COPYRIGHT International Business Machines Corp. 2009
|
|
7
|
+
#
|
|
8
|
+
# All Rights Reserved.
|
|
9
|
+
#
|
|
10
|
+
# US Government Users Restricted Rights - Use, duplication or
|
|
11
|
+
# disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
|
|
12
|
+
#
|
|
13
|
+
#############################################################################
|
|
14
|
+
./ic-cmd.sh -action SetDefaultKey $*
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
@echo off
|
|
2
|
+
|
|
3
|
+
REM ###########################################################################
|
|
4
|
+
|
|
5
|
+
REM #
|
|
6
|
+
|
|
7
|
+
REM # Licensed Materials - Property of IBM
|
|
8
|
+
|
|
9
|
+
REM #
|
|
10
|
+
|
|
11
|
+
REM # (C) COPYRIGHT International Business Machines Corp. 2009
|
|
12
|
+
|
|
13
|
+
REM #
|
|
14
|
+
|
|
15
|
+
REM # All Rights Reserved.
|
|
16
|
+
|
|
17
|
+
REM #
|
|
18
|
+
|
|
19
|
+
REM # US Government Users Restricted Rights - Use, duplication or
|
|
20
|
+
|
|
21
|
+
REM # disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
|
|
22
|
+
|
|
23
|
+
REM #
|
|
24
|
+
|
|
25
|
+
REM #############################################################################
|
|
26
|
+
|
|
27
|
+
ic-cmd.cmd -action UpdateInstance %*
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
############################################################################
|
|
3
|
+
#
|
|
4
|
+
# Licensed Materials - Property of IBM
|
|
5
|
+
#
|
|
6
|
+
# (C) COPYRIGHT International Business Machines Corp. 2009
|
|
7
|
+
#
|
|
8
|
+
# All Rights Reserved.
|
|
9
|
+
#
|
|
10
|
+
# US Government Users Restricted Rights - Use, duplication or
|
|
11
|
+
# disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
|
|
12
|
+
#
|
|
13
|
+
#############################################################################
|
|
14
|
+
./ic-cmd.sh -action UpdateInstance $*
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
@echo off
|
|
2
|
+
|
|
3
|
+
REM ###########################################################################
|
|
4
|
+
|
|
5
|
+
REM #
|
|
6
|
+
|
|
7
|
+
REM # Licensed Materials - Property of IBM
|
|
8
|
+
|
|
9
|
+
REM #
|
|
10
|
+
|
|
11
|
+
REM # (C) COPYRIGHT International Business Machines Corp. 2009
|
|
12
|
+
|
|
13
|
+
REM #
|
|
14
|
+
|
|
15
|
+
REM # All Rights Reserved.
|
|
16
|
+
|
|
17
|
+
REM #
|
|
18
|
+
|
|
19
|
+
REM # US Government Users Restricted Rights - Use, duplication or
|
|
20
|
+
|
|
21
|
+
REM # disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
|
|
22
|
+
|
|
23
|
+
REM #
|
|
24
|
+
|
|
25
|
+
REM #############################################################################
|
|
26
|
+
|
|
27
|
+
ic-cmd.cmd -action UpdateKeyPair %*
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
############################################################################
|
|
3
|
+
#
|
|
4
|
+
# Licensed Materials - Property of IBM
|
|
5
|
+
#
|
|
6
|
+
# (C) COPYRIGHT International Business Machines Corp. 2009
|
|
7
|
+
#
|
|
8
|
+
# All Rights Reserved.
|
|
9
|
+
#
|
|
10
|
+
# US Government Users Restricted Rights - Use, duplication or
|
|
11
|
+
# disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
|
|
12
|
+
#
|
|
13
|
+
#############################################################################
|
|
14
|
+
./ic-cmd.sh -action UpdateKeyPair $*
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
handlers = java.util.logging.FileHandler
|
|
2
|
+
java.util.logging.FileHandler.level = INFO
|
|
3
|
+
java.util.logging.FileHandler.pattern = ./logs/log%u.log
|
|
4
|
+
java.util.logging.FileHandler.limit = 50000
|
|
5
|
+
java.util.logging.FileHandler.count = 1
|
|
6
|
+
java.util.logging.FileHandler.formatter = java.util.logging.SimpleFormatter
|
|
7
|
+
java.util.logging.FileHandler.append = true
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<defaultprofile:Asset xmi:version="2.0"
|
|
3
|
+
xmlns:xmi="http://www.omg.org/XMI" xmlns:defaultprofile="http:///defaultprofile22.ecore" name="Command Line Tool Reference and Binaries"
|
|
4
|
+
id="{F1466F46-A4AB-3879-D883-1A26A43BF046}" date="2011-05-13" state="Approved" version="1.4" shortDescription="Cloud API Reference of Command Line Tool">
|
|
5
|
+
<classification>
|
|
6
|
+
<descriptorGroup name="AssetType">
|
|
7
|
+
<nodeDescriptor href="https://www-147.ibm.com/cloud/enterprise/ram/classif/assetTypesSchema.xmi#documentation"/>
|
|
8
|
+
</descriptorGroup>
|
|
9
|
+
<descriptorGroup name="StandardInfo">
|
|
10
|
+
<freeFormValue value="31" freeFormDescriptor="//@classification/@descriptorGroup.1/@freeFormDescriptor.0"/>
|
|
11
|
+
<freeFormDescriptor name="revisionCount"/>
|
|
12
|
+
</descriptorGroup>
|
|
13
|
+
</classification>
|
|
14
|
+
<solution>
|
|
15
|
+
<artifact name="GA_CommandLine.pdf" type="application/pdf">
|
|
16
|
+
<reference value="GA_CommandLine.pdf"/>
|
|
17
|
+
</artifact>
|
|
18
|
+
<artifact name="README.txt" type="text/plain">
|
|
19
|
+
<reference value="README.txt"/>
|
|
20
|
+
</artifact>
|
|
21
|
+
<artifact name="DeveloperCloud_CMD_Tool.zip" type="multipart/x-zip">
|
|
22
|
+
<reference value="DeveloperCloud_CMD_Tool.zip"/>
|
|
23
|
+
</artifact>
|
|
24
|
+
</solution>
|
|
25
|
+
<description value="<p style="margin: 0px;">You can retrieve the command line tool and its documentation by clicking the "Content" tab above. </p>"/>
|
|
26
|
+
</defaultprofile:Asset>
|
data/lib/mock_smartcloud.rb
CHANGED
|
@@ -16,11 +16,19 @@ class MockSmartCloud
|
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
def describe_image(*args)
|
|
19
|
-
{"CreatedTime"=>"2011-02-25T01:22:57.000Z", "Owner"=>"SYSTEM",
|
|
19
|
+
{"CreatedTime"=>"2011-02-25T01:22:57.000Z", "Owner"=>"SYSTEM",
|
|
20
|
+
"SupportedInstanceTypes"=>{"InstanceType"=>[
|
|
21
|
+
{"Label"=>"Bronze 32 bit", "ID"=>"BRZ32.1/2048/60*175",
|
|
22
|
+
"Price"=>{"Rate"=>"0.21", "PricePerQuantity"=>"1", "UnitOfMeasure"=>"UHR ", "CountryCode"=>"897", "CurrencyCode"=>"USD"}},
|
|
23
|
+
{"Label"=>"Copper 32 bit", "ID"=>"COP32.1/2048/60",
|
|
24
|
+
"Price"=>{"Rate"=>"0.21", "PricePerQuantity"=>"1", "UnitOfMeasure"=>"UHR ", "CountryCode"=>"897", "CurrencyCode"=>"USD"}},
|
|
25
|
+
]
|
|
26
|
+
},
|
|
27
|
+
"Name"=>"CohesiveFT VPN-Cubed Datacenter Connect V2.0.0 - BYOL (TOR)", "Location"=>"101", "ProductCodes"=>{"ProductCode"=>"caondc13bV97Kg5TLyGNodD9or7gA"}, "Documentation"=>"https://www-147.ibm.com/cloud/enterprise/ram.ws/RAMSecure/artifact/{974E595E-566E-87E3-A483-AC0FC468C4D9}/1.0/GettingStarted.html", "ID"=>"20016530", "Manifest"=>"https://www-147.ibm.com/cloud/enterprise/ram.ws/RAMSecure/artifact/{974E595E-566E-87E3-A483-AC0FC468C4D9}/1.0/parameters.xml", "Description"=>"CohesiveFT VPN-Cubed 2.0.0 UL - for TOR datacenter", "State"=>"AVAILABLE", "Visibility"=>"PUBLIC", "Platform"=>"Red Hat Enterprise Linux/5.4"}
|
|
20
28
|
end
|
|
21
29
|
|
|
22
30
|
def describe_instance(*args)
|
|
23
|
-
{"
|
|
31
|
+
{"Status"=>"NEW", "PrimaryIP"=>{"IP"=>{}, "Hostname"=>{}, "Type"=>"DYNAMIC"}, "ImageID"=>"20015391", "DiskSize"=>"60", "Owner"=>"smartes@cohesiveft.com", "RequestID"=>{"name"=>"sir_19_rhel5532-bit-1zGS", "content"=>"102271"}, "Name"=>"MockInstance", "ProductCodes"=>{}, "KeyName"=>"si-tempkey-rhel5532-bit-1zGS-eDY4T", "Location"=>"101", "LaunchTime"=>"2011-07-07T22:13:49.891Z", "Volumes"=>{}, "ID"=>"101971", "MiniEphemeral"=>"false", "Software"=>{"Application"=>{"Version"=>"5.5", "Name"=>"Red Hat Enterprise Linux", "Type"=>"OS"}}, "IP"=>{}, "InstanceType"=>"COP32.1/2048/60", "Hostname"=>{}}
|
|
24
32
|
end
|
|
25
33
|
|
|
26
34
|
def create_volume(*args)
|
|
@@ -44,10 +52,10 @@ class MockSmartCloud
|
|
|
44
52
|
end
|
|
45
53
|
|
|
46
54
|
def poll_for_volume_state(*args)
|
|
47
|
-
|
|
55
|
+
describe_volume(*args)
|
|
48
56
|
end
|
|
49
57
|
|
|
50
58
|
def poll_for_instance_state(*args)
|
|
51
|
-
|
|
59
|
+
describe_instance(*args)
|
|
52
60
|
end
|
|
53
61
|
end
|
data/lib/smartcloud.rb
CHANGED
|
@@ -23,6 +23,8 @@ require 'hash_fix'
|
|
|
23
23
|
require 'xmlsimple'
|
|
24
24
|
require 'smartcloud_logger'
|
|
25
25
|
|
|
26
|
+
IBM_TOOLS_HOME=File.join(File.dirname(__FILE__), "cli_tools") unless defined?(IBM_TOOLS_HOME)
|
|
27
|
+
|
|
26
28
|
# Encapsulates communications with IBM SmartCloud via REST
|
|
27
29
|
class IBMSmartCloud
|
|
28
30
|
|
|
@@ -100,6 +102,10 @@ class IBMSmartCloud
|
|
|
100
102
|
get("/locations").Location
|
|
101
103
|
end
|
|
102
104
|
|
|
105
|
+
def describe_location(location_id)
|
|
106
|
+
get("/locations/#{location_id}").Location
|
|
107
|
+
end
|
|
108
|
+
|
|
103
109
|
def display_locations
|
|
104
110
|
log = describe_locations.map {|loc| "#{loc.ID.ljust(4)} | #{loc.Location.ljust(15)} | #{loc.Name}"}.join("\n")
|
|
105
111
|
logger.info "\n#{log}"
|
|
@@ -197,12 +203,27 @@ class IBMSmartCloud
|
|
|
197
203
|
# TODO: the API call does not work, we have to use the cli for now
|
|
198
204
|
args :clone_volume, [:name, :source_disk_id]
|
|
199
205
|
def clone_volume(name, source_disk_id)
|
|
200
|
-
original_disk = describe_volume(source_disk_id)
|
|
201
|
-
logger.info "Looking up volume #{source_disk_id} to prepare for cloning..."
|
|
202
|
-
offering = describe_volume_offerings(original_disk.Location).detect {|offer| offer.ID == original_disk.OfferingID}
|
|
203
|
-
logger.info "Original volume size: #{offering.Name}"
|
|
204
|
-
result = post("/storage", :name => name, :SourceDiskID => source_disk_id, :format => original_disk.Format.upcase, :location => original_disk.Location, :size => offering.Name, :offeringID => original_disk.OfferingID )
|
|
205
|
-
result.Volume.ID
|
|
206
|
+
# original_disk = describe_volume(source_disk_id)
|
|
207
|
+
# logger.info "Looking up volume #{source_disk_id} to prepare for cloning..."
|
|
208
|
+
# offering = describe_volume_offerings(original_disk.Location).detect {|offer| offer.ID == original_disk.OfferingID}
|
|
209
|
+
# logger.info "Original volume size: #{offering.Name}"
|
|
210
|
+
# result = post("/storage", :name => name, :SourceDiskID => source_disk_id, :format => original_disk.Format.upcase, :location => original_disk.Location, :size => offering.Name, :offeringID => original_disk.OfferingID )
|
|
211
|
+
# result.Volume.ID
|
|
212
|
+
|
|
213
|
+
create_password_file
|
|
214
|
+
result = run_ibm_tool("ic-clone-volume.sh -n #{name} -S #{source_disk_id}")
|
|
215
|
+
result =~ /ID : (.*)/
|
|
216
|
+
return $1 # grab the id of the created volume
|
|
217
|
+
end
|
|
218
|
+
|
|
219
|
+
args :attach_volume, [:instance_id, :volume_id]
|
|
220
|
+
def attach_volume(instance_id, volume_id)
|
|
221
|
+
put("/instances/#{instance_id}", :volumeID => volume_id, :attach => true)
|
|
222
|
+
end
|
|
223
|
+
|
|
224
|
+
args :detach_volume, [:instance_id, :volume_id]
|
|
225
|
+
def detach_volume(instance_id, volume_id)
|
|
226
|
+
put("/instances/#{instance_id}", :volumeID => volume_id, :detach => true)
|
|
206
227
|
end
|
|
207
228
|
|
|
208
229
|
# Delete the volume
|
|
@@ -212,9 +233,14 @@ class IBMSmartCloud
|
|
|
212
233
|
true
|
|
213
234
|
end
|
|
214
235
|
|
|
215
|
-
args :delete_volumes, [:
|
|
216
|
-
def delete_volumes(vol_id_list)
|
|
217
|
-
|
|
236
|
+
args :delete_volumes, [:volume_ids], %{Example: smartcloud "delete_volumes(12345,12346,12347)"}
|
|
237
|
+
def delete_volumes(*vol_id_list)
|
|
238
|
+
threads=[]
|
|
239
|
+
vol_id_list.each {|vol|
|
|
240
|
+
threads << Thread.new { logger.info "Sending delete request for: #{vol}..."; delete_volume(vol); logger.info "Finished delete request for #{vol}" }
|
|
241
|
+
}
|
|
242
|
+
threads.each(&:join)
|
|
243
|
+
true
|
|
218
244
|
end
|
|
219
245
|
|
|
220
246
|
# generates a keypair and returns the private key
|
|
@@ -248,6 +274,14 @@ class IBMSmartCloud
|
|
|
248
274
|
response
|
|
249
275
|
end
|
|
250
276
|
|
|
277
|
+
def display_addresses
|
|
278
|
+
addresses = describe_addresses
|
|
279
|
+
|
|
280
|
+
logger.info "\nID | Loc | State | IP \n" + addresses.map {|a|
|
|
281
|
+
a.ID.ljust(6) + " | " + a.Location.ljust(4) + " | " + (a.State[0..9].ljust(10) rescue '?'.ljust(10)) + " | " + (a.IP.to_s || "")
|
|
282
|
+
}.join("\n")
|
|
283
|
+
end
|
|
284
|
+
|
|
251
285
|
# Allows you to poll for a specific storage state
|
|
252
286
|
# ex: storage_state_is?("123456", "UNMOUNTED")
|
|
253
287
|
# storage state string can be given as a string or symbol
|
|
@@ -298,7 +332,8 @@ class IBMSmartCloud
|
|
|
298
332
|
# Optionally supply a location to get offerings filtered to a particular location
|
|
299
333
|
# Optionally supply a name (Small, Medium, Large) to get the specific offering
|
|
300
334
|
args :describe_volume_offerings, [{:location => :opt}, {:name => :opt}]
|
|
301
|
-
|
|
335
|
+
args :describe_storage_offerings, [{:location => :opt}, {:name => :opt}]
|
|
336
|
+
def describe_storage_offerings(location=nil, name=nil)
|
|
302
337
|
response = get("/offerings/storage")
|
|
303
338
|
if location
|
|
304
339
|
filtered_by_location = response.Offerings.select {|o| o.Location.to_s == location.to_s}
|
|
@@ -312,6 +347,8 @@ class IBMSmartCloud
|
|
|
312
347
|
end
|
|
313
348
|
end
|
|
314
349
|
|
|
350
|
+
alias describe_volume_offerings describe_storage_offerings
|
|
351
|
+
|
|
315
352
|
# Create a volume. offering_id is optional and will be determined automatically
|
|
316
353
|
# for you based on the location and volume size.
|
|
317
354
|
#
|
|
@@ -430,11 +467,18 @@ class IBMSmartCloud
|
|
|
430
467
|
end
|
|
431
468
|
|
|
432
469
|
# Deletes many instances in a thread
|
|
433
|
-
args :delete_instances, [:instance_ids
|
|
434
|
-
def delete_instances(instance_ids)
|
|
435
|
-
|
|
470
|
+
args :delete_instances, [:instance_ids], %{Example: smartcloud "delete_instances(12345,12346,12347)"}
|
|
471
|
+
def delete_instances(*instance_ids)
|
|
472
|
+
threads=[]
|
|
473
|
+
instance_ids.each {|id| logger.info "Sending delete request for: #{id}..."; threads << Thread.new { delete_instance(id) }; logger.info "Finished delete request for #{id}" }
|
|
474
|
+
threads.each(&:join)
|
|
475
|
+
true
|
|
436
476
|
end
|
|
437
477
|
|
|
478
|
+
args :rename_instance, [:instance_id, :new_name]
|
|
479
|
+
def rename_instance(instance_id, new_name)
|
|
480
|
+
put("/instances/#{instance_id}", :name => new_name)
|
|
481
|
+
end
|
|
438
482
|
|
|
439
483
|
args :delete_instance, [:instance_id]
|
|
440
484
|
def delete_instance(instance_id)
|
|
@@ -478,9 +522,11 @@ class IBMSmartCloud
|
|
|
478
522
|
def display_instances(filters={})
|
|
479
523
|
instances = describe_instances(filters)
|
|
480
524
|
|
|
481
|
-
log = %{#{"Started".ljust(18)} | #{"Instance".ljust(8)} | #{"Image".ljust(9)} | #{"Loc".ljust(3)} | #{"Status".ljust(10)} | #{"KeyName".ljust(15)} | #{"IP".ljust(15)} | Name\n}
|
|
525
|
+
log = %{#{"Started".ljust(18)} | #{"Instance".ljust(8)} | #{"Image".ljust(9)} | #{"Loc".ljust(3)} | #{"Status".ljust(10)} | #{"KeyName".ljust(15)} | #{"IP".ljust(15)} | #{"Volume".ljust(6)} | Name\n}
|
|
482
526
|
log << instances.map do |ins|
|
|
483
|
-
|
|
527
|
+
ip = (ins.IP && ins.IP.to_s) || ""
|
|
528
|
+
ip = (ip.strip == "") ? "[NONE]" : ip.strip
|
|
529
|
+
"#{DateTime.parse(ins.LaunchTime).strftime("%Y-%m-%d %I:%M%p")} | #{ins.ID.ljust(8)} | #{ins.ImageID.ljust(9)} | #{ins.Location.ljust(3)} | #{ins.Status[0..9].ljust(10)} | #{(ins.KeyName || "").strip[0..14].ljust(15)} | #{ip.ljust(15)} | #{(ins.Volume && ins.Volume || "").ljust(6)} | #{ins.Name}"
|
|
484
530
|
end.join("\n")
|
|
485
531
|
logger.info "\n#{log}"
|
|
486
532
|
end
|
|
@@ -501,6 +547,10 @@ class IBMSmartCloud
|
|
|
501
547
|
images = filter_and_sort(images, filters)
|
|
502
548
|
end
|
|
503
549
|
|
|
550
|
+
def describe_manifest(image_id)
|
|
551
|
+
get("offerings/image/#{image_id}/manifest").Manifest
|
|
552
|
+
end
|
|
553
|
+
|
|
504
554
|
args :display_images, [:filters => :opt]
|
|
505
555
|
def display_images(filters={})
|
|
506
556
|
images = describe_images(filters)
|
|
@@ -603,6 +653,42 @@ class IBMSmartCloud
|
|
|
603
653
|
array_or_object.is_a?(Array) ? array_or_object : [array_or_object]
|
|
604
654
|
end
|
|
605
655
|
|
|
656
|
+
# TODO: all methods below here can be nuked once CLI tools are removed
|
|
657
|
+
def run_ibm_tool(command)
|
|
658
|
+
FileUtils.mkdir_p(File.join(IBM_TOOLS_HOME, 'logs'))
|
|
659
|
+
cmd = "cd #{IBM_TOOLS_HOME} && ./#{command} -u #{@username} -w #{passphrase} -g #{password_file}"
|
|
660
|
+
logger.debug cmd
|
|
661
|
+
output = if @debug
|
|
662
|
+
IBMMockResponseGenerator.respond(command)
|
|
663
|
+
else
|
|
664
|
+
`#{cmd}`
|
|
665
|
+
end
|
|
666
|
+
|
|
667
|
+
logger.debug output
|
|
668
|
+
|
|
669
|
+
if output =~ /ErrorMessage : (.*)/
|
|
670
|
+
raise $1 # raise the error message matched above
|
|
671
|
+
else
|
|
672
|
+
return output
|
|
673
|
+
end
|
|
674
|
+
end
|
|
675
|
+
|
|
676
|
+
def create_password_file
|
|
677
|
+
# if no passphrase or password file is supplied, we'll generate it
|
|
678
|
+
run_ibm_tool("ic-create-password.sh -u #{@username} -p #{@password}")
|
|
679
|
+
end
|
|
680
|
+
|
|
681
|
+
def password_file
|
|
682
|
+
@password_file ||= "/tmp/smrtcloud-pwfile-#{Time.now.to_i.to_s}"
|
|
683
|
+
end
|
|
684
|
+
|
|
685
|
+
def passphrase
|
|
686
|
+
@passphrase ||= Time.now.to_i.to_s
|
|
687
|
+
end
|
|
688
|
+
# End CLI tool helpers
|
|
689
|
+
|
|
690
|
+
|
|
691
|
+
|
|
606
692
|
end
|
|
607
693
|
|
|
608
694
|
# predefine an instance for convenience
|