hpcloud 2.0.0
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 +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,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/acl/grant'
|
|
23
|
+
require 'hpcloud/commands/acl/revoke'
|
|
24
|
+
|
|
25
|
+
module HP
|
|
26
|
+
module Cloud
|
|
27
|
+
class CLI < Thor
|
|
28
|
+
|
|
29
|
+
desc 'acl <object/container>', "View the ACL for an object or container."
|
|
30
|
+
long_desc <<-DESC
|
|
31
|
+
View the access control list (ACL) for a container or object. Optionally, you can specify an availability zone.
|
|
32
|
+
|
|
33
|
+
Examples:
|
|
34
|
+
hpcloud acl :my_container/my_file.txt # Display the ACL for the object 'my_file.txt'
|
|
35
|
+
hpcloud acl :my_container # Display the ACL for the container 'my_container'
|
|
36
|
+
hpcloud acl :my_container -z region-a.geo-1 # Display the ACL for the container 'my_container' for availability zone `region-a.geo-1`
|
|
37
|
+
DESC
|
|
38
|
+
CLI.add_report_options
|
|
39
|
+
CLI.add_common_options
|
|
40
|
+
def acl(name, *names)
|
|
41
|
+
cli_command(options) {
|
|
42
|
+
names = [name] + names
|
|
43
|
+
|
|
44
|
+
ray = []
|
|
45
|
+
names.each { |name|
|
|
46
|
+
resource = ResourceFactory.create(Connection.instance.storage, name)
|
|
47
|
+
if resource.container_head
|
|
48
|
+
ray << resource.to_hash()
|
|
49
|
+
else
|
|
50
|
+
@log.error resource.cstatus
|
|
51
|
+
end
|
|
52
|
+
}
|
|
53
|
+
keys = [ "public", "readers", "writers", "public_url"]
|
|
54
|
+
if ray.empty?
|
|
55
|
+
@log.display "There are no resources that match the provided arguments"
|
|
56
|
+
else
|
|
57
|
+
Tableizer.new(options, keys, ray).print
|
|
58
|
+
end
|
|
59
|
+
}
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
|
@@ -0,0 +1,67 @@
|
|
|
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(addresses:allocate) => 'addresses:add'
|
|
27
|
+
|
|
28
|
+
desc "addresses:add", "Allocate a new public IP address."
|
|
29
|
+
long_desc <<-DESC
|
|
30
|
+
Add or allocate a new public IP address from the pool of available IP addresses. If a network is not specified, the first external network found will be used.
|
|
31
|
+
|
|
32
|
+
Examples:
|
|
33
|
+
hpcloud addresses:add # Add a new public IP address to external network
|
|
34
|
+
hpcloud addresses:add -n netty # Add a new IP address to `netty`
|
|
35
|
+
|
|
36
|
+
Aliases: addresses:allocate
|
|
37
|
+
DESC
|
|
38
|
+
method_option :network,
|
|
39
|
+
:type => :string, :aliases => '-n',
|
|
40
|
+
:desc => 'Name or id of the network associated with this IP.'
|
|
41
|
+
method_option :port,
|
|
42
|
+
:type => :string, :aliases => '-p',
|
|
43
|
+
:desc => 'Name or id of the port associated with this IP.'
|
|
44
|
+
method_option :fixed_ip,
|
|
45
|
+
:type => :string,
|
|
46
|
+
:desc => 'Fixed IP address to associate with this IP.'
|
|
47
|
+
method_option :floating_ip,
|
|
48
|
+
:type => :string,
|
|
49
|
+
:desc => 'Floating IP to assign.'
|
|
50
|
+
CLI.add_common_options
|
|
51
|
+
define_method "addresses:add" do
|
|
52
|
+
cli_command(options) {
|
|
53
|
+
address = FloatingIpHelper.new(Connection.instance)
|
|
54
|
+
address.set_network(options[:network])
|
|
55
|
+
address.port = options[:port]
|
|
56
|
+
address.fixed_ip = options[:fixed_ip]
|
|
57
|
+
address.floating_ip = options[:floating_ip]
|
|
58
|
+
if address.save
|
|
59
|
+
@log.display "Created a public IP address '#{address.ip}'."
|
|
60
|
+
else
|
|
61
|
+
@log.fatal address.cstatus
|
|
62
|
+
end
|
|
63
|
+
}
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
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
|
+
module HP
|
|
23
|
+
module Cloud
|
|
24
|
+
class CLI < Thor
|
|
25
|
+
|
|
26
|
+
map 'addresses:attach' => 'addresses:associate'
|
|
27
|
+
|
|
28
|
+
desc "addresses:associate <ip_or_id> <port_name_or_id>", "Associate a public IP address to a port."
|
|
29
|
+
long_desc <<-DESC
|
|
30
|
+
Associate an existing and unassigned public IP address, to the specified port. Optionally, you can specify an availability.
|
|
31
|
+
|
|
32
|
+
Examples:
|
|
33
|
+
hpcloud addresses:associate 111.111.111.111 myport # Associate the address `111.111.111.111` to port `myport`
|
|
34
|
+
DESC
|
|
35
|
+
CLI.add_common_options
|
|
36
|
+
define_method "addresses:associate" do |ip_or_id, port_name_or_id|
|
|
37
|
+
cli_command(options) {
|
|
38
|
+
port = Ports.new.get(port_name_or_id)
|
|
39
|
+
if port.is_valid? == false
|
|
40
|
+
@log.fatal port.cstatus
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
address = FloatingIps.new.get(ip_or_id)
|
|
44
|
+
if address.is_valid? == false
|
|
45
|
+
@log.fatal address.cstatus
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
if address.port.nil? == false
|
|
49
|
+
if address.port == port.id
|
|
50
|
+
@log.display "The IP address '#{ip_or_id}' is already associated with '#{port_name_or_id}'."
|
|
51
|
+
else
|
|
52
|
+
@log.fatal "The IP address '#{ip_or_id}' is in use by another port '#{address.port}'.", :conflicted
|
|
53
|
+
end
|
|
54
|
+
else
|
|
55
|
+
address.port = port.id
|
|
56
|
+
address.associate
|
|
57
|
+
@log.display "Associated address '#{ip_or_id}' to port '#{port_name_or_id}'."
|
|
58
|
+
end
|
|
59
|
+
}
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
|
@@ -0,0 +1,58 @@
|
|
|
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 'addresses:detach' => 'addresses:disassociate'
|
|
27
|
+
|
|
28
|
+
desc "addresses:disassociate ip_or_id [ip_or_id ...]", "Disassociate any port associated to the public IP address."
|
|
29
|
+
long_desc <<-DESC
|
|
30
|
+
Disassociate any port associated to the public IP address. The public IP address is not removed or released to the pool. Optionally, you can specify an availability zone.
|
|
31
|
+
|
|
32
|
+
Examples:
|
|
33
|
+
hpcloud addresses:disassociate 111.111.111.111 127.0.0.1 # Disassociate IP addresses `111.111.111.111` and `127.0.0.1` from their ports
|
|
34
|
+
hpcloud addresses:disassociate f01b27f3 # Disassociate the address with the ID '9709'
|
|
35
|
+
DESC
|
|
36
|
+
CLI.add_common_options
|
|
37
|
+
define_method "addresses:disassociate" do |ip_or_id, *ip_or_ids|
|
|
38
|
+
cli_command(options) {
|
|
39
|
+
addresses = FloatingIps.new
|
|
40
|
+
ip_or_ids = [ip_or_id] + ip_or_ids
|
|
41
|
+
ip_or_ids.each { |ip_or_id|
|
|
42
|
+
address = addresses.get(ip_or_id)
|
|
43
|
+
if address.is_valid? == false
|
|
44
|
+
@log.error address.cstatus
|
|
45
|
+
else
|
|
46
|
+
if address.port.nil?
|
|
47
|
+
@log.display "You don't have any port associated with address '#{ip_or_id}'."
|
|
48
|
+
else
|
|
49
|
+
address.port = nil
|
|
50
|
+
@log.display "Disassociated address '#{ip_or_id}' from any port."
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
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(addresses:rm addresses:delete addresses:release addresses:del) => 'addresses:remove'
|
|
27
|
+
|
|
28
|
+
desc "addresses:remove ip_or_id [ip_or_id ...]", "Remove or release a public IP address."
|
|
29
|
+
long_desc <<-DESC
|
|
30
|
+
Remove or release a previously allocated public IP address. Any server instances that were associated to this address are disassociated. You may specify one ore more address IPs or IDs on the command line. Optionally, you can specify an availability zone.
|
|
31
|
+
|
|
32
|
+
Examples:
|
|
33
|
+
hpcloud addresses:remove 111.111.111.111 # Remove IP address '111.111.111.111'
|
|
34
|
+
hpcloud addresses:remove a5bd6680 c80dfe05 # Remove addresses with the IDs 'a5bd6680' and 'c80dfe05'
|
|
35
|
+
|
|
36
|
+
Aliases: addresses:rm, addresses:delete, addresses:release, addresses:del
|
|
37
|
+
DESC
|
|
38
|
+
CLI.add_common_options
|
|
39
|
+
define_method "addresses:remove" do |ip, *ips|
|
|
40
|
+
cli_command(options) {
|
|
41
|
+
addresses = FloatingIps.new
|
|
42
|
+
ips = [ip] + ips
|
|
43
|
+
ips.each { |ip_or_id|
|
|
44
|
+
address = addresses.get(ip_or_id)
|
|
45
|
+
if address.is_valid? == false
|
|
46
|
+
@log.error address.cstatus
|
|
47
|
+
else
|
|
48
|
+
address.disassociate
|
|
49
|
+
address.destroy
|
|
50
|
+
@log.display "Removed address '#{ip_or_id}'."
|
|
51
|
+
end
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
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/addresses/add'
|
|
23
|
+
require 'hpcloud/commands/addresses/remove'
|
|
24
|
+
require 'hpcloud/commands/addresses/associate'
|
|
25
|
+
require 'hpcloud/commands/addresses/disassociate'
|
|
26
|
+
|
|
27
|
+
module HP
|
|
28
|
+
module Cloud
|
|
29
|
+
class CLI < Thor
|
|
30
|
+
|
|
31
|
+
map 'addresses:list' => 'addresses'
|
|
32
|
+
|
|
33
|
+
desc "addresses [ip_or_id ...]", "Display list of available addresses."
|
|
34
|
+
long_desc <<-DESC
|
|
35
|
+
List the available addresses for your account. You may filter the addresses listed by specifying one or more IPs or IDs on the command line. Optionally, you can specify an availability zone.
|
|
36
|
+
|
|
37
|
+
Examples:
|
|
38
|
+
hpcloud addresses # List addresses
|
|
39
|
+
hpcloud addresses 127.0.0.2 # List address information for IP address 127.0.0.2
|
|
40
|
+
hpcloud addresses -z az-2.region-a.geo-1 # List addresses for availability zone `az-2.region-a.geo-1`
|
|
41
|
+
|
|
42
|
+
Aliases: addresses:list
|
|
43
|
+
DESC
|
|
44
|
+
CLI.add_report_options
|
|
45
|
+
CLI.add_common_options
|
|
46
|
+
def addresses(*arguments)
|
|
47
|
+
cli_command(options) {
|
|
48
|
+
addresses = FloatingIps.new
|
|
49
|
+
if addresses.empty?
|
|
50
|
+
@log.display "You currently have no public IP addresses, use `#{selfname} addresses:add` to create one."
|
|
51
|
+
else
|
|
52
|
+
ray = addresses.get_array(arguments)
|
|
53
|
+
if ray.empty?
|
|
54
|
+
@log.display "There are no IP addresses that match the provided arguments"
|
|
55
|
+
else
|
|
56
|
+
Tableizer.new(options, FloatingIpHelper.get_keys(), ray).print
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
}
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
|
@@ -0,0 +1,56 @@
|
|
|
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 "cdn:containers:add name [name ...]", "Add containers to the CDN."
|
|
27
|
+
long_desc <<-DESC
|
|
28
|
+
Add existing containers from your storage account to the CDN. Container names can be specified with or without the preceding colon: 'my_container' or ':my_container'. Optionally, you can specify an availability zone.
|
|
29
|
+
|
|
30
|
+
Examples:
|
|
31
|
+
hpcloud cdn:containers:add :tainer1 :tainer2 # Add the containers`tainer1` and `tainer2` to the CDN
|
|
32
|
+
hpcloud cdn:containers:add :my_cdn_container -z region-a.geo-1 # Add the container `my_cdn_container` to the CDN in the availability zone `region-a.geo`
|
|
33
|
+
DESC
|
|
34
|
+
CLI.add_common_options
|
|
35
|
+
define_method "cdn:containers:add" do |name, *names|
|
|
36
|
+
cli_command(options) {
|
|
37
|
+
names = [name] + names
|
|
38
|
+
names.each { |name|
|
|
39
|
+
res = ContainerResource.new(Connection.instance.storage, name)
|
|
40
|
+
name = res.container
|
|
41
|
+
begin
|
|
42
|
+
if res.container_head()
|
|
43
|
+
response = Connection.instance.cdn.put_container(name)
|
|
44
|
+
@log.display "Added container '#{name}' to the CDN."
|
|
45
|
+
else
|
|
46
|
+
@log.error "The container '#{name}' does not exist in your storage account. Please create the storage container first and then add it to the CDN.", :incorrect_usage
|
|
47
|
+
end
|
|
48
|
+
rescue Fog::Storage::HP::NotFound
|
|
49
|
+
@log.error "The container '#{name}' does not exist in your storage account. Please create the storage container first and then add it to the CDN.", :incorrect_usage
|
|
50
|
+
end
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
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 "cdn:containers:get <name> [attribute..]", "Get the value of an attribute of a CDN container."
|
|
27
|
+
long_desc <<-DESC
|
|
28
|
+
Get the value of an attribute for an existing CDN container. The allowed attributes whose value can be retrieved are:
|
|
29
|
+
* 'X-Ttl'
|
|
30
|
+
* 'X-Cdn-Uri'
|
|
31
|
+
* 'X-Cdn-Enabled'
|
|
32
|
+
* 'X-Log-Retention'.
|
|
33
|
+
|
|
34
|
+
Optionally, you can specify an availability zone.
|
|
35
|
+
|
|
36
|
+
Examples:
|
|
37
|
+
hpcloud cdn:containers:get :my_cdn_container # List all the values
|
|
38
|
+
hpcloud cdn:containers:get :my_cdn_container "X-Ttl" # Get the value of the attribute 'X-Ttl'
|
|
39
|
+
hpcloud cdn:containers:get :my_cdn_container "X-Cdn-Uri" # Get the value of the attribute 'X-Cdn-Uri'
|
|
40
|
+
hpcloud cdn:containers:get :my_cdn_container "X-Ttl" -z region-a.geo-1 # Get the value of the attribute `X-Ttl` for availability zone `regioni-a.geo`
|
|
41
|
+
DESC
|
|
42
|
+
CLI.add_common_options
|
|
43
|
+
define_method "cdn:containers:get" do |name, *attributes|
|
|
44
|
+
cli_command(options) {
|
|
45
|
+
res = ContainerResource.new(Connection.instance.cdn, name)
|
|
46
|
+
name = res.container
|
|
47
|
+
# check to see cdn container exists
|
|
48
|
+
begin
|
|
49
|
+
response = Connection.instance.cdn.head_container(name)
|
|
50
|
+
allowed_attributes = ['X-Ttl', 'X-Cdn-Uri', 'X-Cdn-Enabled', 'X-Log-Retention']
|
|
51
|
+
if attributes.empty?
|
|
52
|
+
attributes = allowed_attributes
|
|
53
|
+
end
|
|
54
|
+
attributes.each{ |attribute|
|
|
55
|
+
if allowed_attributes.include?(attribute) == false && response.headers["#{attribute}"].nil?
|
|
56
|
+
@log.error "The value of the attribute '#{attribute}' cannot be retrieved. The allowed attributes are '#{allowed_attributes.join(', ')}'.", :incorrect_usage
|
|
57
|
+
else
|
|
58
|
+
value = response.headers["#{attribute}"]
|
|
59
|
+
value = "\n" if value.nil?
|
|
60
|
+
@log.display "#{attribute} #{value}"
|
|
61
|
+
end
|
|
62
|
+
}
|
|
63
|
+
rescue Fog::CDN::HP::NotFound => error
|
|
64
|
+
@log.fatal "You don't have a container named '#{name}' on the CDN.", :not_found
|
|
65
|
+
end
|
|
66
|
+
}
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
end
|
|
@@ -0,0 +1,61 @@
|
|
|
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 'cdn:containers:loc' => 'cdn:containers:location'
|
|
27
|
+
|
|
28
|
+
desc "cdn:containers:location <name>", "Get the location of a container on the CDN."
|
|
29
|
+
long_desc <<-DESC
|
|
30
|
+
Get the location of an existing container on the CDN. Optionally, you can specify an availability zone.
|
|
31
|
+
|
|
32
|
+
Examples:
|
|
33
|
+
hpcloud cdn:containers:location :my_cdn_container # Get the location of the container 'my_cdn_container'
|
|
34
|
+
hpcloud cdn:containers:location :my_cdn_container -z region-a.geo-1 # Get the location of the container `my_cdn_container` for availability zone `region-a.geo-1`
|
|
35
|
+
|
|
36
|
+
Aliases: cdn:containers:loc
|
|
37
|
+
DESC
|
|
38
|
+
method_option :ssl, :default => false,
|
|
39
|
+
:type => :boolean, :aliases => '-s',
|
|
40
|
+
:desc => 'Print the SSL version of the URL.'
|
|
41
|
+
CLI.add_common_options
|
|
42
|
+
define_method "cdn:containers:location" do |name, *names|
|
|
43
|
+
cli_command(options) {
|
|
44
|
+
names = [name] + names
|
|
45
|
+
names.each { |name|
|
|
46
|
+
resource = ResourceFactory.create(Connection.instance.storage, name)
|
|
47
|
+
if resource.container_head
|
|
48
|
+
if options.ssl
|
|
49
|
+
@log.display resource.cdn_public_ssl_url
|
|
50
|
+
else
|
|
51
|
+
@log.display resource.cdn_public_url
|
|
52
|
+
end
|
|
53
|
+
else
|
|
54
|
+
@log.error resource.cstatus
|
|
55
|
+
end
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
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
|
+
module HP
|
|
23
|
+
module Cloud
|
|
24
|
+
class CLI < Thor
|
|
25
|
+
|
|
26
|
+
map %w(cdn:containers:rm cdn:containers:delete cdn:containers:del) => 'cdn:containers:remove'
|
|
27
|
+
|
|
28
|
+
desc "cdn:containers:remove name [name ...]", "Remove containers from the CDN."
|
|
29
|
+
long_desc <<-DESC
|
|
30
|
+
Remove containers from the CDN. Optionally, you can specify an availability zone.
|
|
31
|
+
|
|
32
|
+
Examples:
|
|
33
|
+
hpcloud cdn:containers:remove :tainer1 :tainer2 # Delete the containers `:tainer1` and `:tainer2` from the CDN
|
|
34
|
+
hpcloud cdn:containers:remove :my_cdn_container -z region-a.geo-1 # Delete the container `my_cdn_container for the availability zone `region-a.geo-1` from the CDN
|
|
35
|
+
|
|
36
|
+
Aliases: cdn:containers:rm, cdn:containers:delete, cdn:containers:del
|
|
37
|
+
DESC
|
|
38
|
+
CLI.add_common_options
|
|
39
|
+
define_method "cdn:containers:remove" do |name, *names|
|
|
40
|
+
cli_command(options) {
|
|
41
|
+
names = [name] + names
|
|
42
|
+
names.each { |name|
|
|
43
|
+
begin
|
|
44
|
+
name = name[1..-1] if name.start_with?(":")
|
|
45
|
+
Connection.instance.cdn.delete_container(name)
|
|
46
|
+
@log.display "Removed container '#{name}' from the CDN."
|
|
47
|
+
rescue Excon::Errors::NotFound, Fog::CDN::HP::NotFound
|
|
48
|
+
@log.error "You don't have a container named '#{name}' on the CDN.", :not_found
|
|
49
|
+
end
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|