hpcloud 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +127 -0
- data/LICENSE +1 -0
- data/README.rdoc +59 -0
- data/bin/hpcloud +11 -0
- data/completion/hpcloud +372 -0
- data/lib/hpcloud/accounts.rb +288 -0
- data/lib/hpcloud/acl.rb +112 -0
- data/lib/hpcloud/acl_cmd.rb +81 -0
- data/lib/hpcloud/address_helper.rb +63 -0
- data/lib/hpcloud/addresses.rb +42 -0
- data/lib/hpcloud/auth_cache.rb +128 -0
- data/lib/hpcloud/base_helper.rb +56 -0
- data/lib/hpcloud/checker.rb +104 -0
- data/lib/hpcloud/cli.rb +170 -0
- data/lib/hpcloud/cli_status.rb +80 -0
- data/lib/hpcloud/columns.rb +46 -0
- data/lib/hpcloud/commands/account/catalog.rb +57 -0
- data/lib/hpcloud/commands/account/copy.rb +44 -0
- data/lib/hpcloud/commands/account/edit.rb +204 -0
- data/lib/hpcloud/commands/account/remove.rb +53 -0
- data/lib/hpcloud/commands/account/setup.rb +40 -0
- data/lib/hpcloud/commands/account/tenants.rb +43 -0
- data/lib/hpcloud/commands/account/use.rb +46 -0
- data/lib/hpcloud/commands/account/verify.rb +55 -0
- data/lib/hpcloud/commands/account.rb +67 -0
- data/lib/hpcloud/commands/acl/grant.rb +59 -0
- data/lib/hpcloud/commands/acl/revoke.rb +52 -0
- data/lib/hpcloud/commands/acl.rb +63 -0
- data/lib/hpcloud/commands/addresses/add.rb +67 -0
- data/lib/hpcloud/commands/addresses/associate.rb +63 -0
- data/lib/hpcloud/commands/addresses/disassociate.rb +58 -0
- data/lib/hpcloud/commands/addresses/remove.rb +57 -0
- data/lib/hpcloud/commands/addresses.rb +63 -0
- data/lib/hpcloud/commands/cdn_containers/add.rb +56 -0
- data/lib/hpcloud/commands/cdn_containers/get.rb +70 -0
- data/lib/hpcloud/commands/cdn_containers/location.rb +61 -0
- data/lib/hpcloud/commands/cdn_containers/remove.rb +55 -0
- data/lib/hpcloud/commands/cdn_containers/set.rb +63 -0
- data/lib/hpcloud/commands/cdn_containers.rb +72 -0
- data/lib/hpcloud/commands/complete.rb +60 -0
- data/lib/hpcloud/commands/config/set.rb +63 -0
- data/lib/hpcloud/commands/config.rb +46 -0
- data/lib/hpcloud/commands/containers/add.rb +67 -0
- data/lib/hpcloud/commands/containers/remove.rb +63 -0
- data/lib/hpcloud/commands/containers/sync.rb +59 -0
- data/lib/hpcloud/commands/containers.rb +24 -0
- data/lib/hpcloud/commands/copy.rb +78 -0
- data/lib/hpcloud/commands/dns/add.rb +56 -0
- data/lib/hpcloud/commands/dns/records/add.rb +50 -0
- data/lib/hpcloud/commands/dns/records/remove.rb +53 -0
- data/lib/hpcloud/commands/dns/records/update.rb +50 -0
- data/lib/hpcloud/commands/dns/records.rb +57 -0
- data/lib/hpcloud/commands/dns/remove.rb +57 -0
- data/lib/hpcloud/commands/dns/servers.rb +57 -0
- data/lib/hpcloud/commands/dns/update.rb +58 -0
- data/lib/hpcloud/commands/dns.rb +65 -0
- data/lib/hpcloud/commands/flavors.rb +59 -0
- data/lib/hpcloud/commands/get.rb +58 -0
- data/lib/hpcloud/commands/images/add.rb +54 -0
- data/lib/hpcloud/commands/images/metadata/add.rb +54 -0
- data/lib/hpcloud/commands/images/metadata/remove.rb +56 -0
- data/lib/hpcloud/commands/images/metadata.rb +54 -0
- data/lib/hpcloud/commands/images/remove.rb +58 -0
- data/lib/hpcloud/commands/images.rb +67 -0
- data/lib/hpcloud/commands/info.rb +41 -0
- data/lib/hpcloud/commands/keypairs/add.rb +73 -0
- data/lib/hpcloud/commands/keypairs/import.rb +62 -0
- data/lib/hpcloud/commands/keypairs/private/add.rb +44 -0
- data/lib/hpcloud/commands/keypairs/private/location.rb +50 -0
- data/lib/hpcloud/commands/keypairs/private/remove.rb +52 -0
- data/lib/hpcloud/commands/keypairs/private.rb +47 -0
- data/lib/hpcloud/commands/keypairs/public_key.rb +51 -0
- data/lib/hpcloud/commands/keypairs/remove.rb +58 -0
- data/lib/hpcloud/commands/keypairs.rb +64 -0
- data/lib/hpcloud/commands/lb/add.rb +92 -0
- data/lib/hpcloud/commands/lb/algorithms.rb +55 -0
- data/lib/hpcloud/commands/lb/limits.rb +55 -0
- data/lib/hpcloud/commands/lb/nodes/add.rb +47 -0
- data/lib/hpcloud/commands/lb/nodes/remove.rb +54 -0
- data/lib/hpcloud/commands/lb/nodes/update.rb +47 -0
- data/lib/hpcloud/commands/lb/nodes.rb +55 -0
- data/lib/hpcloud/commands/lb/protocols.rb +55 -0
- data/lib/hpcloud/commands/lb/remove.rb +54 -0
- data/lib/hpcloud/commands/lb/update.rb +46 -0
- data/lib/hpcloud/commands/lb/versions.rb +55 -0
- data/lib/hpcloud/commands/lb/virtualips.rb +51 -0
- data/lib/hpcloud/commands/lb.rb +73 -0
- data/lib/hpcloud/commands/list.rb +114 -0
- data/lib/hpcloud/commands/location.rb +56 -0
- data/lib/hpcloud/commands/metadata/set.rb +61 -0
- data/lib/hpcloud/commands/metadata.rb +60 -0
- data/lib/hpcloud/commands/migrate.rb +61 -0
- data/lib/hpcloud/commands/move.rb +73 -0
- data/lib/hpcloud/commands/networks/add.rb +55 -0
- data/lib/hpcloud/commands/networks/remove.rb +57 -0
- data/lib/hpcloud/commands/networks/update.rb +54 -0
- data/lib/hpcloud/commands/networks.rb +63 -0
- data/lib/hpcloud/commands/ports/add.rb +81 -0
- data/lib/hpcloud/commands/ports/remove.rb +57 -0
- data/lib/hpcloud/commands/ports/update.rb +67 -0
- data/lib/hpcloud/commands/ports.rb +63 -0
- data/lib/hpcloud/commands/remove.rb +75 -0
- data/lib/hpcloud/commands/routers/add.rb +67 -0
- data/lib/hpcloud/commands/routers/interface/add.rb +59 -0
- data/lib/hpcloud/commands/routers/interface/remove.rb +66 -0
- data/lib/hpcloud/commands/routers/remove.rb +54 -0
- data/lib/hpcloud/commands/routers/update.rb +66 -0
- data/lib/hpcloud/commands/routers.rb +66 -0
- data/lib/hpcloud/commands/securitygroups/add.rb +52 -0
- data/lib/hpcloud/commands/securitygroups/remove.rb +57 -0
- data/lib/hpcloud/commands/securitygroups/rules/add.rb +126 -0
- data/lib/hpcloud/commands/securitygroups/rules/remove.rb +51 -0
- data/lib/hpcloud/commands/securitygroups/rules.rb +56 -0
- data/lib/hpcloud/commands/securitygroups.rb +62 -0
- data/lib/hpcloud/commands/servers/add.rb +100 -0
- data/lib/hpcloud/commands/servers/console.rb +81 -0
- data/lib/hpcloud/commands/servers/limits.rb +46 -0
- data/lib/hpcloud/commands/servers/metadata/add.rb +56 -0
- data/lib/hpcloud/commands/servers/metadata/remove.rb +57 -0
- data/lib/hpcloud/commands/servers/metadata.rb +56 -0
- data/lib/hpcloud/commands/servers/password.rb +47 -0
- data/lib/hpcloud/commands/servers/ratelimits.rb +46 -0
- data/lib/hpcloud/commands/servers/reboot.rb +61 -0
- data/lib/hpcloud/commands/servers/rebuild.rb +59 -0
- data/lib/hpcloud/commands/servers/remove.rb +58 -0
- data/lib/hpcloud/commands/servers/securitygroups/add.rb +47 -0
- data/lib/hpcloud/commands/servers/securitygroups/remove.rb +47 -0
- data/lib/hpcloud/commands/servers/ssh.rb +92 -0
- data/lib/hpcloud/commands/servers.rb +92 -0
- data/lib/hpcloud/commands/snapshots/add.rb +62 -0
- data/lib/hpcloud/commands/snapshots/remove.rb +58 -0
- data/lib/hpcloud/commands/snapshots.rb +62 -0
- data/lib/hpcloud/commands/subnets/add.rb +78 -0
- data/lib/hpcloud/commands/subnets/remove.rb +57 -0
- data/lib/hpcloud/commands/subnets/update.rb +70 -0
- data/lib/hpcloud/commands/subnets.rb +63 -0
- data/lib/hpcloud/commands/tempurl.rb +62 -0
- data/lib/hpcloud/commands/volumes/add.rb +88 -0
- data/lib/hpcloud/commands/volumes/attach.rb +59 -0
- data/lib/hpcloud/commands/volumes/detach.rb +57 -0
- data/lib/hpcloud/commands/volumes/metadata/add.rb +54 -0
- data/lib/hpcloud/commands/volumes/metadata.rb +55 -0
- data/lib/hpcloud/commands/volumes/remove.rb +57 -0
- data/lib/hpcloud/commands/volumes/server.rb +64 -0
- data/lib/hpcloud/commands/volumes.rb +65 -0
- data/lib/hpcloud/config.rb +205 -0
- data/lib/hpcloud/connection.rb +290 -0
- data/lib/hpcloud/container_resource.rb +175 -0
- data/lib/hpcloud/database_helper.rb +70 -0
- data/lib/hpcloud/databases.rb +38 -0
- data/lib/hpcloud/dns_helper.rb +125 -0
- data/lib/hpcloud/dnss.rb +38 -0
- data/lib/hpcloud/error_response.rb +89 -0
- data/lib/hpcloud/exceptions/base.rb +35 -0
- data/lib/hpcloud/exceptions/general.rb +34 -0
- data/lib/hpcloud/exceptions/not_found.rb +34 -0
- data/lib/hpcloud/flavors.rb +40 -0
- data/lib/hpcloud/floating_ip_helper.rb +114 -0
- data/lib/hpcloud/floating_ips.rb +42 -0
- data/lib/hpcloud/fog_collection.rb +124 -0
- data/lib/hpcloud/image_helper.rb +111 -0
- data/lib/hpcloud/images.rb +43 -0
- data/lib/hpcloud/keypair_helper.rb +109 -0
- data/lib/hpcloud/keypairs.rb +41 -0
- data/lib/hpcloud/lb_algorithms.rb +37 -0
- data/lib/hpcloud/lb_limits.rb +37 -0
- data/lib/hpcloud/lb_nodes.rb +42 -0
- data/lib/hpcloud/lb_protocols.rb +37 -0
- data/lib/hpcloud/lb_versions.rb +37 -0
- data/lib/hpcloud/lb_virtualips.rb +42 -0
- data/lib/hpcloud/lbs.rb +38 -0
- data/lib/hpcloud/local_resource.rb +183 -0
- data/lib/hpcloud/log.rb +55 -0
- data/lib/hpcloud/metadata.rb +118 -0
- data/lib/hpcloud/monkey.rb +22 -0
- data/lib/hpcloud/network_helper.rb +88 -0
- data/lib/hpcloud/networks.rb +47 -0
- data/lib/hpcloud/object_store.rb +66 -0
- data/lib/hpcloud/port_helper.rb +150 -0
- data/lib/hpcloud/ports.rb +38 -0
- data/lib/hpcloud/progress.rb +53 -0
- data/lib/hpcloud/remote_resource.rb +512 -0
- data/lib/hpcloud/resource.rb +264 -0
- data/lib/hpcloud/resource_factory.rb +110 -0
- data/lib/hpcloud/routers.rb +56 -0
- data/lib/hpcloud/rule_helper.rb +70 -0
- data/lib/hpcloud/rules.rb +41 -0
- data/lib/hpcloud/security_group_helper.rb +59 -0
- data/lib/hpcloud/security_groups.rb +37 -0
- data/lib/hpcloud/server_helper.rb +318 -0
- data/lib/hpcloud/servers.rb +47 -0
- data/lib/hpcloud/shared_resource.rb +172 -0
- data/lib/hpcloud/snapshot_helper.rb +78 -0
- data/lib/hpcloud/snapshots.rb +38 -0
- data/lib/hpcloud/subnet_helper.rb +170 -0
- data/lib/hpcloud/subnets.rb +38 -0
- data/lib/hpcloud/tableizer.rb +77 -0
- data/lib/hpcloud/thor_ext/thor.rb +54 -0
- data/lib/hpcloud/time_parser.rb +47 -0
- data/lib/hpcloud/version.rb +27 -0
- data/lib/hpcloud/volume_attachment.rb +58 -0
- data/lib/hpcloud/volume_attachments.rb +58 -0
- data/lib/hpcloud/volume_helper.rb +119 -0
- data/lib/hpcloud/volumes.rb +38 -0
- data/lib/hpcloud.rb +112 -0
- data/lib/monkey/hp/lb.rb +188 -0
- data/lib/monkey/hp/models/lb/algorithm.rb +32 -0
- data/lib/monkey/hp/models/lb/algorithms.rb +46 -0
- data/lib/monkey/hp/models/lb/limit.rb +38 -0
- data/lib/monkey/hp/models/lb/limits.rb +50 -0
- data/lib/monkey/hp/models/lb/load_balancer.rb +70 -0
- data/lib/monkey/hp/models/lb/load_balancers.rb +46 -0
- data/lib/monkey/hp/models/lb/node.rb +69 -0
- data/lib/monkey/hp/models/lb/nodes.rb +47 -0
- data/lib/monkey/hp/models/lb/protocol.rb +33 -0
- data/lib/monkey/hp/models/lb/protocols.rb +46 -0
- data/lib/monkey/hp/models/lb/version.rb +34 -0
- data/lib/monkey/hp/models/lb/versions.rb +47 -0
- data/lib/monkey/hp/models/lb/virtual_ip.rb +37 -0
- data/lib/monkey/hp/models/lb/virtual_ips.rb +47 -0
- data/lib/monkey/hp/requests/lb/create_load_balancer.rb +64 -0
- data/lib/monkey/hp/requests/lb/create_load_balancer_node.rb +58 -0
- data/lib/monkey/hp/requests/lb/delete_load_balancer.rb +54 -0
- data/lib/monkey/hp/requests/lb/delete_load_balancer_node.rb +60 -0
- data/lib/monkey/hp/requests/lb/get_load_balancer.rb +88 -0
- data/lib/monkey/hp/requests/lb/get_load_balancer_node.rb +60 -0
- data/lib/monkey/hp/requests/lb/get_version.rb +68 -0
- data/lib/monkey/hp/requests/lb/get_virtual_ips.rb +48 -0
- data/lib/monkey/hp/requests/lb/list_algorithms.rb +51 -0
- data/lib/monkey/hp/requests/lb/list_limits.rb +60 -0
- data/lib/monkey/hp/requests/lb/list_load_balancer_nodes.rb +79 -0
- data/lib/monkey/hp/requests/lb/list_load_balancer_virtual_ips.rb +76 -0
- data/lib/monkey/hp/requests/lb/list_load_balancers.rb +69 -0
- data/lib/monkey/hp/requests/lb/list_protocols.rb +51 -0
- data/lib/monkey/hp/requests/lb/list_versions.rb +51 -0
- data/lib/monkey/hp/requests/lb/update_load_balancer.rb +46 -0
- data/lib/monkey/hp/requests/lb/update_load_balancer_node.rb +50 -0
- metadata +368 -0
@@ -0,0 +1,78 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
#
|
3
|
+
# © Copyright 2013 Hewlett-Packard Development Company, L.P.
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
+
# of this software and associated documentation files (the "Software"), to deal
|
6
|
+
# in the Software without restriction, including without limitation the rights
|
7
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
# copies of the Software, and to permit persons to whom the Software is
|
9
|
+
# furnished to do so, subject to the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be included in all
|
12
|
+
# copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
20
|
+
# SOFTWARE.
|
21
|
+
|
22
|
+
module HP
|
23
|
+
module Cloud
|
24
|
+
class CLI < Thor
|
25
|
+
|
26
|
+
desc "subnets:add <name> <network_id_or_name> <cidr>", "Add a subnet."
|
27
|
+
long_desc <<-DESC
|
28
|
+
Add a new subnet to your network with the specified name and CIDR. Optionally, you can specify IP version, gateway, DHCP, DNS name servers, or host routes. The add command will do its best to guess the IP version from the CIDR, but you may override it. The DNS name servers should be a command seperated list e.g.: 10.1.1.1,10.2.2.2. The host routes should be a semicolon separated list of destination and nexthop pairs e.g.: 127.0.0.1/32,10.1.1.1;100.1.1.1/32,10.2.2.2
|
29
|
+
|
30
|
+
Examples:
|
31
|
+
hpcloud subnets:add subwoofer netty 127.0.0.0/24 # Create a new subnet named 'subwoofer'
|
32
|
+
hpcloud subnets:add subwoofer netty 127.0.0.0/24 -g 127.0.0.1 -d # Create a new subnet named 'subwoofer' with gateway and DHCP
|
33
|
+
DESC
|
34
|
+
method_option :ipversion,
|
35
|
+
:type => :string, :aliases => '-i',
|
36
|
+
:desc => 'IP version.'
|
37
|
+
method_option :gateway,
|
38
|
+
:type => :string, :aliases => '-g',
|
39
|
+
:desc => 'Gateway IP address.'
|
40
|
+
method_option :dhcp, :default => true,
|
41
|
+
:type => :boolean, :aliases => '-d',
|
42
|
+
:desc => 'Enable DHCP.'
|
43
|
+
method_option :dnsnameservers,
|
44
|
+
:type => :string, :aliases => '-n',
|
45
|
+
:desc => 'Comma separated list of DNS name servers.'
|
46
|
+
method_option :hostroutes,
|
47
|
+
:type => :string, :aliases => '-h',
|
48
|
+
:desc => 'Semicolon separated list of host routes pairs.'
|
49
|
+
CLI.add_common_options
|
50
|
+
define_method "subnets:add" do |name, network, cidr|
|
51
|
+
cli_command(options) {
|
52
|
+
if Subnets.new.get(name).is_valid? == true
|
53
|
+
@log.fatal "Subnet with the name '#{name}' already exists"
|
54
|
+
end
|
55
|
+
network = HP::Cloud::Networks.new.get(network)
|
56
|
+
if network.is_valid? == false
|
57
|
+
@log.fatal network.cstatus
|
58
|
+
end
|
59
|
+
|
60
|
+
subnet = HP::Cloud::SubnetHelper.new(Connection.instance)
|
61
|
+
subnet.name = name
|
62
|
+
subnet.network_id = network.id
|
63
|
+
subnet.set_cidr(cidr)
|
64
|
+
subnet.set_ip_version(options[:ipversion])
|
65
|
+
subnet.set_gateway(options[:gateway])
|
66
|
+
subnet.dhcp = options[:dhcp]
|
67
|
+
subnet.set_dns_nameservers(options[:dnsnameservers])
|
68
|
+
subnet.set_host_routes(options[:hostroutes])
|
69
|
+
if subnet.save == true
|
70
|
+
@log.display "Created subnet '#{name}' with id '#{subnet.id}'."
|
71
|
+
else
|
72
|
+
@log.fatal subnet.cstatus
|
73
|
+
end
|
74
|
+
}
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
#
|
3
|
+
# © Copyright 2013 Hewlett-Packard Development Company, L.P.
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
+
# of this software and associated documentation files (the "Software"), to deal
|
6
|
+
# in the Software without restriction, including without limitation the rights
|
7
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
# copies of the Software, and to permit persons to whom the Software is
|
9
|
+
# furnished to do so, subject to the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be included in all
|
12
|
+
# copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
20
|
+
# SOFTWARE.
|
21
|
+
|
22
|
+
module HP
|
23
|
+
module Cloud
|
24
|
+
class CLI < Thor
|
25
|
+
|
26
|
+
map %w(subnets:rm subnets:delete subnets:del) => 'subnets:remove'
|
27
|
+
|
28
|
+
desc "subnets:remove name_or_id [name_or_id ...]", "Remove a subnet (specified by name or ID)."
|
29
|
+
long_desc <<-DESC
|
30
|
+
Remove subnet by specifying their names or ID. You may specify more than one subnet name or ID on a command line.
|
31
|
+
|
32
|
+
Examples:
|
33
|
+
hpcloud subnets:remove blue red # Delete the subnet 'blue' and 'red'
|
34
|
+
hpcloud subnets:remove ffc0edba # Delete the subnet with ID ffc0edba
|
35
|
+
|
36
|
+
Aliases: subnets:rm, subnets:delete, subnets:del
|
37
|
+
DESC
|
38
|
+
CLI.add_common_options
|
39
|
+
define_method "subnets:remove" do |name_or_id, *name_or_ids|
|
40
|
+
cli_command(options) {
|
41
|
+
name_or_ids = [name_or_id] + name_or_ids
|
42
|
+
subnets = Subnets.new.get(name_or_ids, false)
|
43
|
+
subnets.each { |subnet|
|
44
|
+
sub_command("removing subnet") {
|
45
|
+
if subnet.is_valid?
|
46
|
+
subnet.destroy
|
47
|
+
@log.display "Removed subnet '#{subnet.name}'."
|
48
|
+
else
|
49
|
+
@log.error subnet.cstatus
|
50
|
+
end
|
51
|
+
}
|
52
|
+
}
|
53
|
+
}
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
#
|
3
|
+
# © Copyright 2013 Hewlett-Packard Development Company, L.P.
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
+
# of this software and associated documentation files (the "Software"), to deal
|
6
|
+
# in the Software without restriction, including without limitation the rights
|
7
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
# copies of the Software, and to permit persons to whom the Software is
|
9
|
+
# furnished to do so, subject to the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be included in all
|
12
|
+
# copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
20
|
+
# SOFTWARE.
|
21
|
+
|
22
|
+
module HP
|
23
|
+
module Cloud
|
24
|
+
class CLI < Thor
|
25
|
+
|
26
|
+
desc "subnets:update <name>", "Update a subnet."
|
27
|
+
long_desc <<-DESC
|
28
|
+
Update a subnet IP version, gateway, DHCP, DNS name servers, or host routes. The update command will do its best to guess the IP version from the CIDR, but you may override it. The DNS name servers should be a command seperated list e.g.: 10.1.1.1,10.2.2.2. The host routes should be a semicolon separated list of destination and nexthop pairs e.g.: 127.0.0.1/32,10.1.1.1;100.1.1.1/32,10.2.2.2
|
29
|
+
|
30
|
+
Examples:
|
31
|
+
hpcloud subnets:update subwoofer -g 10.0.0.1 # Update 'subwoofer' gateway
|
32
|
+
hpcloud subnets:update subwoofer -n 100.1.1.1 -d # Update 'subwoofer' with new DNS and DHCP
|
33
|
+
DESC
|
34
|
+
method_option :ipversion,
|
35
|
+
:type => :string, :aliases => '-i',
|
36
|
+
:desc => 'IP version.'
|
37
|
+
method_option :gateway,
|
38
|
+
:type => :string, :aliases => '-g',
|
39
|
+
:desc => 'Gateway IP address.'
|
40
|
+
method_option :dhcp,
|
41
|
+
:type => :boolean, :aliases => '-d',
|
42
|
+
:desc => 'Enable DHCP.'
|
43
|
+
method_option :dnsnameservers,
|
44
|
+
:type => :string, :aliases => '-n',
|
45
|
+
:desc => 'Comma separated list of DNS name servers.'
|
46
|
+
method_option :hostroutes,
|
47
|
+
:type => :string, :aliases => '-h',
|
48
|
+
:desc => 'Semicolon separated list of host routes pairs.'
|
49
|
+
CLI.add_common_options
|
50
|
+
define_method "subnets:update" do |name|
|
51
|
+
cli_command(options) {
|
52
|
+
subnet = Subnets.new.get(name)
|
53
|
+
if subnet.is_valid? == false
|
54
|
+
@log.fatal subnet.cstatus
|
55
|
+
end
|
56
|
+
subnet.set_ip_version(options[:ipversion]) unless options[:ipversion].nil?
|
57
|
+
subnet.set_gateway(options[:gateway]) unless options[:gateway].nil?
|
58
|
+
subnet.dhcp = options[:dhcp] unless options[:dhcp].nil?
|
59
|
+
subnet.set_dns_nameservers(options[:dnsnameservers]) unless options[:dnsnameservers].nil?
|
60
|
+
subnet.set_host_routes(options[:hostroutes]) unless options[:hostroutes].nil?
|
61
|
+
if subnet.save == true
|
62
|
+
@log.display "Updated subnet '#{name}'."
|
63
|
+
else
|
64
|
+
@log.fatal subnet.cstatus
|
65
|
+
end
|
66
|
+
}
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
#
|
3
|
+
# © Copyright 2013 Hewlett-Packard Development Company, L.P.
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
+
# of this software and associated documentation files (the "Software"), to deal
|
6
|
+
# in the Software without restriction, including without limitation the rights
|
7
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
# copies of the Software, and to permit persons to whom the Software is
|
9
|
+
# furnished to do so, subject to the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be included in all
|
12
|
+
# copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
20
|
+
# SOFTWARE.
|
21
|
+
|
22
|
+
require 'hpcloud/commands/subnets/add.rb'
|
23
|
+
require 'hpcloud/commands/subnets/remove.rb'
|
24
|
+
require 'hpcloud/commands/subnets/update.rb'
|
25
|
+
require 'hpcloud/subnets'
|
26
|
+
|
27
|
+
module HP
|
28
|
+
module Cloud
|
29
|
+
class CLI < Thor
|
30
|
+
|
31
|
+
map 'subnets:list' => 'subnets'
|
32
|
+
|
33
|
+
desc 'subnets [name_or_id ...]', "List the available subnets."
|
34
|
+
long_desc <<-DESC
|
35
|
+
Lists all the subnets that are associated with the account. The list begins with identifier and contains name, status, shared, admin state, and subnets. Optionally, you can filter the list by specifying name or ID.
|
36
|
+
|
37
|
+
Examples:
|
38
|
+
hpcloud subnets # List all subnets
|
39
|
+
hpcloud subnets b8e90a48 # List the details for subnets with id `b8e90a48`
|
40
|
+
hpcloud subnets testo # List the details for subnets named `testo`
|
41
|
+
|
42
|
+
Aliases: subnets:list
|
43
|
+
DESC
|
44
|
+
CLI.add_report_options
|
45
|
+
CLI.add_common_options
|
46
|
+
def subnets(*arguments)
|
47
|
+
cli_command(options) {
|
48
|
+
subnets = Subnets.new
|
49
|
+
if subnets.empty?
|
50
|
+
@log.display "You currently have no subnets, use `#{selfname} subnets:add <name>` to create one."
|
51
|
+
else
|
52
|
+
ray = subnets.get_array(arguments)
|
53
|
+
if ray.empty?
|
54
|
+
@log.display "There are no subnets that match the provided arguments"
|
55
|
+
else
|
56
|
+
Tableizer.new(options, SubnetHelper.get_keys(), ray).print
|
57
|
+
end
|
58
|
+
end
|
59
|
+
}
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
#
|
3
|
+
# © Copyright 2013 Hewlett-Packard Development Company, L.P.
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
+
# of this software and associated documentation files (the "Software"), to deal
|
6
|
+
# in the Software without restriction, including without limitation the rights
|
7
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
# copies of the Software, and to permit persons to whom the Software is
|
9
|
+
# furnished to do so, subject to the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be included in all
|
12
|
+
# copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
20
|
+
# SOFTWARE.
|
21
|
+
|
22
|
+
module HP
|
23
|
+
module Cloud
|
24
|
+
class CLI < Thor
|
25
|
+
|
26
|
+
map 'tmpurl' => 'tempurl'
|
27
|
+
|
28
|
+
desc 'tempurl <object> ...', 'Create temporary URLs for the given objects.'
|
29
|
+
long_desc <<-DESC
|
30
|
+
Create temporary URLS for the given objects. Creating a temporary URL allows you to share an object for a specified period of time making it available to everyone. Only users with access to the URL can access the file. You can specify the time period in seconds (s), hours (h), or days (d). If you do not specify a time period, the default is two days. Optionally, you can specify an availability zone.
|
31
|
+
|
32
|
+
Examples:
|
33
|
+
hpcloud tempurl -p7d :my_container/file.txt # Create a temporary URL for the file `file.txt` with a period of 7 days
|
34
|
+
hpcloud tempurl -p24h :my_container/file.txt :my_container/other.txt # Create temporary URLs for the files `file.txt` and `other.txt` in container `my_container` with a period of 24 hours
|
35
|
+
hpcloud tempurl :my_container/file.txt -z region-a.geo-1 # Create a temporary URL for the file `file.txt` with a period of 7 days for availability zone `region-a.geo-1`
|
36
|
+
|
37
|
+
Aliases: tmpurl
|
38
|
+
DESC
|
39
|
+
method_option :time_period,
|
40
|
+
:type => :string, :aliases => '-p',
|
41
|
+
:desc => 'time period to keep the url alive'
|
42
|
+
method_option :update,
|
43
|
+
:type => :boolean, :aliases => '-u',
|
44
|
+
:desc => 'Update an existing tempurl'
|
45
|
+
CLI.add_common_options
|
46
|
+
def tempurl(name, *names)
|
47
|
+
cli_command(options) {
|
48
|
+
names = [name] + names
|
49
|
+
names.each { |name|
|
50
|
+
resource = ResourceFactory.create(Connection.instance.storage, name)
|
51
|
+
url = resource.tempurl(TimeParser.parse(options[:time_period]))
|
52
|
+
unless url.nil?
|
53
|
+
@log.display url
|
54
|
+
else
|
55
|
+
@log.error resource.cstatus
|
56
|
+
end
|
57
|
+
}
|
58
|
+
}
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
#
|
3
|
+
# © Copyright 2013 Hewlett-Packard Development Company, L.P.
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
+
# of this software and associated documentation files (the "Software"), to deal
|
6
|
+
# in the Software without restriction, including without limitation the rights
|
7
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
# copies of the Software, and to permit persons to whom the Software is
|
9
|
+
# furnished to do so, subject to the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be included in all
|
12
|
+
# copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
20
|
+
# SOFTWARE.
|
21
|
+
|
22
|
+
module HP
|
23
|
+
module Cloud
|
24
|
+
class CLI < Thor
|
25
|
+
|
26
|
+
desc "volumes:add <name> [size]", "Add a volume."
|
27
|
+
long_desc <<-DESC
|
28
|
+
Add a new volume to your compute account with the specified name and size. Optionally, you can specify a description, metadata or availability zone. If you do not specify a size, it is taken from the specified snapshot or image. If no image or snapshot is specified, the size defaults to 1 gigabyte.
|
29
|
+
|
30
|
+
Examples:
|
31
|
+
hpcloud volumes:add my_volume 10 --zone az3 # Create a new volume named 'my_volume' of size 10 in zone az3
|
32
|
+
hpcloud volumes:add my_volume -s 'snappy' # Create a new volume named 'my_volume' based on the snapshot 'snappy'
|
33
|
+
hpcloud volumes:add my_volume -i 53e78869 # Create a new bootable volume named 'my_volume' based on the image '53e78869'
|
34
|
+
DESC
|
35
|
+
method_option :description,
|
36
|
+
:type => :string, :aliases => '-d',
|
37
|
+
:desc => 'Description of the volume.'
|
38
|
+
method_option :metadata,
|
39
|
+
:type => :string, :aliases => '-m',
|
40
|
+
:desc => 'Set the metadata.'
|
41
|
+
method_option :snapshot,
|
42
|
+
:type => :string, :aliases => '-s',
|
43
|
+
:desc => 'Create a volume from the specified snapshot.'
|
44
|
+
method_option :image,
|
45
|
+
:type => :string, :aliases => '-i',
|
46
|
+
:desc => 'Create a volume from the specified image.'
|
47
|
+
method_option :zone,
|
48
|
+
:type => :string,
|
49
|
+
:desc => 'Create a volume in the specified zone.'
|
50
|
+
CLI.add_common_options
|
51
|
+
define_method "volumes:add" do |name, *volume_size|
|
52
|
+
cli_command(options) {
|
53
|
+
if Volumes.new.get(name).is_valid? == true
|
54
|
+
@log.fatal "Volume with the name '#{name}' already exists"
|
55
|
+
end
|
56
|
+
vol = HP::Cloud::VolumeHelper.new(Connection.instance)
|
57
|
+
vol.name = name
|
58
|
+
vol.size = volume_size.first
|
59
|
+
unless options[:snapshot].nil?
|
60
|
+
snapshot = HP::Cloud::Snapshots.new.get(options[:snapshot])
|
61
|
+
if snapshot.is_valid?
|
62
|
+
vol.snapshot_id = snapshot.id.to_s
|
63
|
+
vol.size = snapshot.size.to_s if vol.size.nil?
|
64
|
+
else
|
65
|
+
@log.fatal snapshot.cstatus
|
66
|
+
end
|
67
|
+
end
|
68
|
+
unless options[:image].nil?
|
69
|
+
image = HP::Cloud::Images.new.get(options[:image])
|
70
|
+
if image.is_valid?
|
71
|
+
vol.imageref = image.id.to_s
|
72
|
+
else
|
73
|
+
@log.fatal image.cstatus
|
74
|
+
end
|
75
|
+
end
|
76
|
+
vol.size = 1 if vol.size.nil?
|
77
|
+
vol.description = options[:description]
|
78
|
+
vol.availability_zone = options[:zone]
|
79
|
+
if vol.save == true
|
80
|
+
@log.display "Created volume '#{name}' with id '#{vol.id}'."
|
81
|
+
else
|
82
|
+
@log.fatal vol.cstatus
|
83
|
+
end
|
84
|
+
}
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
#
|
3
|
+
# © Copyright 2013 Hewlett-Packard Development Company, L.P.
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
+
# of this software and associated documentation files (the "Software"), to deal
|
6
|
+
# in the Software without restriction, including without limitation the rights
|
7
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
# copies of the Software, and to permit persons to whom the Software is
|
9
|
+
# furnished to do so, subject to the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be included in all
|
12
|
+
# copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
20
|
+
# SOFTWARE.
|
21
|
+
|
22
|
+
module HP
|
23
|
+
module Cloud
|
24
|
+
class CLI < Thor
|
25
|
+
|
26
|
+
desc "volumes:attach <volume> <server> <device_or_number>", "Attach a volume to a server specified by device name or number."
|
27
|
+
long_desc <<-DESC
|
28
|
+
Attach a volume to a server on the specified device name. You may specify a device name in the format /dev/vdX where X is c, d, e, ... or a attacment point 3, 4, 5,... The attacment point 1 would map to /dev/vda on a Linux platform, but /dev/vda and /dev/vdb are already in use by the server, so you need to start with 3 or /dev/vdc. If you attempt to attach a volume to an attachment point that is in use, it will fail silently. The call is asynchronous and the failure cannot be detected by the CLI. If you attempt to mount to attachment point 4 and attachment point 3 is not in use, your volume will be attached to attachment point 3 or /dev/vdc on Linux. This cannot be detected by the CLI.
|
29
|
+
|
30
|
+
Examples:
|
31
|
+
hpcloud volumes:attach myVolume myServer /dev/vdc # Attach volume `myVolume` to server `myServer` on device `/dev/vdc`
|
32
|
+
hpcloud volumes:attach f9520651 b8e90a48 4 # Attach volume `f9520651` to server `b8e90a48` on device `/dev/vdb`
|
33
|
+
|
34
|
+
DESC
|
35
|
+
CLI.add_common_options
|
36
|
+
define_method "volumes:attach" do |vol_name, server_name, device|
|
37
|
+
cli_command(options) {
|
38
|
+
server = Servers.new.get(server_name)
|
39
|
+
if server.is_valid?
|
40
|
+
volume = Volumes.new.get(vol_name)
|
41
|
+
if volume.is_valid?
|
42
|
+
if volume.fog.ready?
|
43
|
+
device = volume.map_device(device)
|
44
|
+
volume.attach(server, device)
|
45
|
+
@log.display "Attached volume '#{volume.name}' to '#{server.name}' on '#{device}'."
|
46
|
+
else
|
47
|
+
@log.fatal "Error attaching volume already in use '#{volume.name}'", :conflicted
|
48
|
+
end
|
49
|
+
else
|
50
|
+
@log.fatal volume.cstatus
|
51
|
+
end
|
52
|
+
else
|
53
|
+
@log.fatal server.cstatus
|
54
|
+
end
|
55
|
+
}
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
#
|
3
|
+
# © Copyright 2013 Hewlett-Packard Development Company, L.P.
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
+
# of this software and associated documentation files (the "Software"), to deal
|
6
|
+
# in the Software without restriction, including without limitation the rights
|
7
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
# copies of the Software, and to permit persons to whom the Software is
|
9
|
+
# furnished to do so, subject to the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be included in all
|
12
|
+
# copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
20
|
+
# SOFTWARE.
|
21
|
+
|
22
|
+
require 'csv'
|
23
|
+
|
24
|
+
module HP
|
25
|
+
module Cloud
|
26
|
+
class CLI < Thor
|
27
|
+
|
28
|
+
desc "volumes:detach name_or_id [name_or_id ...]", "Detach a volume or volumes."
|
29
|
+
long_desc <<-DESC
|
30
|
+
Detach volumes from all servers. You may specify the volume by name or ID. You can detach one more more volumes in a command line.
|
31
|
+
|
32
|
+
Examples:
|
33
|
+
hpcloud volumes:detach myVolume # Detach the volume 'myVolume'
|
34
|
+
hpcloud volumes:detach 3407653b # Detach the volume with ID 1159
|
35
|
+
|
36
|
+
DESC
|
37
|
+
CLI.add_common_options
|
38
|
+
define_method "volumes:detach" do |name_or_id, *name_or_ids|
|
39
|
+
cli_command(options) {
|
40
|
+
name_or_ids = [name_or_id] + name_or_ids
|
41
|
+
Volumes.new.get(name_or_ids).each { |volume|
|
42
|
+
if volume.is_valid?
|
43
|
+
if (volume.detach() == true)
|
44
|
+
@log.display "Detached volume '#{volume.name}' from '#{volume.servers}'."
|
45
|
+
else
|
46
|
+
@log.fatal volume.cstatus
|
47
|
+
end
|
48
|
+
else
|
49
|
+
@log.fatal volume.cstatus
|
50
|
+
end
|
51
|
+
}
|
52
|
+
}
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
#
|
3
|
+
# © Copyright 2013 Hewlett-Packard Development Company, L.P.
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
+
# of this software and associated documentation files (the "Software"), to deal
|
6
|
+
# in the Software without restriction, including without limitation the rights
|
7
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
# copies of the Software, and to permit persons to whom the Software is
|
9
|
+
# furnished to do so, subject to the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be included in all
|
12
|
+
# copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
20
|
+
# SOFTWARE.
|
21
|
+
|
22
|
+
module HP
|
23
|
+
module Cloud
|
24
|
+
class CLI < Thor
|
25
|
+
|
26
|
+
map 'volumes:metadata:update' => 'volumes:metadata:add'
|
27
|
+
|
28
|
+
desc "volumes:metadata:add <name_or_id> <metadata>", "Add metadata to a volume."
|
29
|
+
long_desc <<-DESC
|
30
|
+
Add metadata to a volume in your compute account. You can specify the volume name or ID. Optionally, you can specify an availability zone. The metadata must be a comma separated list of name value pairs.
|
31
|
+
|
32
|
+
Examples:
|
33
|
+
hpcloud volumes:metadata:add my_volume 'r2=d2,c3=po' # Add the specified metadata to the volume (f the metadata exists, it is updated)
|
34
|
+
|
35
|
+
Aliases: volumes:metadata:update
|
36
|
+
DESC
|
37
|
+
CLI.add_common_options
|
38
|
+
define_method "volumes:metadata:add" do |name_or_id, metadata|
|
39
|
+
cli_command(options) {
|
40
|
+
volume = Volumes.new.get(name_or_id.to_s)
|
41
|
+
if volume.is_valid? == false
|
42
|
+
@log.fatal volume.cstatus
|
43
|
+
else
|
44
|
+
if volume.meta.set_metadata(metadata)
|
45
|
+
@log.display "Volume '#{name_or_id}' set metadata '#{metadata}'."
|
46
|
+
else
|
47
|
+
@log.fatal volume.meta.cstatus
|
48
|
+
end
|
49
|
+
end
|
50
|
+
}
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
#
|
3
|
+
# © Copyright 2013 Hewlett-Packard Development Company, L.P.
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
+
# of this software and associated documentation files (the "Software"), to deal
|
6
|
+
# in the Software without restriction, including without limitation the rights
|
7
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
# copies of the Software, and to permit persons to whom the Software is
|
9
|
+
# furnished to do so, subject to the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be included in all
|
12
|
+
# copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
20
|
+
# SOFTWARE.
|
21
|
+
|
22
|
+
require 'hpcloud/metadata'
|
23
|
+
|
24
|
+
module HP
|
25
|
+
module Cloud
|
26
|
+
class CLI < Thor
|
27
|
+
|
28
|
+
map 'volumes:metadata:list' => 'volumes:metadata'
|
29
|
+
|
30
|
+
desc "volumes:metadata <volume_name_or_id>", "List the metadata for a volume."
|
31
|
+
long_desc <<-DESC
|
32
|
+
List the metadata for a volume in your compute account. You may specify the volume by either the name or the ID. Optionally, you can specify an availability zone.
|
33
|
+
|
34
|
+
Examples:
|
35
|
+
hpcloud volumes:metadata Skynet # List the metadata for volume 'Skynet'
|
36
|
+
hpcloud volumes:metadata d6a89a5d # List metadata for the volume with the ID d6a89a5d
|
37
|
+
|
38
|
+
Aliases: volumes:metadata:list
|
39
|
+
DESC
|
40
|
+
CLI.add_report_options
|
41
|
+
CLI.add_common_options
|
42
|
+
define_method "volumes:metadata" do |name_or_id|
|
43
|
+
cli_command(options) {
|
44
|
+
volume = Volumes.new.get(name_or_id)
|
45
|
+
if volume.is_valid?
|
46
|
+
hsh = volume.meta.to_array()
|
47
|
+
Tableizer.new(options, Metadata.get_keys(), hsh).print
|
48
|
+
else
|
49
|
+
@log.fatal volume.cstatus
|
50
|
+
end
|
51
|
+
}
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|