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,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
|
+
desc "cdn:containers:set <name> <attribute> <value>", "Set attributes on a CDN container."
|
27
|
+
long_desc <<-DESC
|
28
|
+
Set attributes for an existing CDN container by specifying their values. The allowed attributes that can be set are:
|
29
|
+
|
30
|
+
* 'X-Ttl'
|
31
|
+
* 'X-Cdn-Uri'
|
32
|
+
* 'X-Cdn-Enabled'
|
33
|
+
* 'X-Log-Retention'.
|
34
|
+
|
35
|
+
Optionally, you can specify an availability zone.
|
36
|
+
|
37
|
+
Examples:
|
38
|
+
hpcloud cdn:containers:set :my_cdn_container "X-Ttl" 900 # Set the attribute 'X-Ttl' to 900
|
39
|
+
hpcloud cdn:containers:set :my_cdn_container "X-Cdn-Uri" "http://my.home.com/cdn" # Set the attribute 'X-Cdn-Uri' to http://my.home.com/cdn
|
40
|
+
hpcloud cdn:containers:set :my_cdn_container "X-Ttl" 900 -z region-a.geo-1 # Set the attribute `X-Ttl` to 900 for availability zoneregion-a.geo-1`
|
41
|
+
DESC
|
42
|
+
CLI.add_common_options
|
43
|
+
define_method "cdn:containers:set" do |name, attribute, value|
|
44
|
+
cli_command(options) {
|
45
|
+
begin
|
46
|
+
name = name[1..-1] if name.start_with?(":")
|
47
|
+
Connection.instance.cdn.head_container(name)
|
48
|
+
allowed_attributes = ['X-Ttl', 'X-Cdn-Uri', 'X-Cdn-Enabled', 'X-Log-Retention']
|
49
|
+
if attribute && value && allowed_attributes.include?(attribute)
|
50
|
+
options = {"#{attribute}" => "#{value}"}
|
51
|
+
Connection.instance.cdn.post_container(name, options)
|
52
|
+
@log.display "The attribute '#{attribute}' with value '#{value}' was set on CDN container '#{name}'."
|
53
|
+
else
|
54
|
+
@log.fatal "The attribute '#{attribute}' cannot be set. The allowed attributes are '#{allowed_attributes.join(', ')}'.", :incorrect_usage
|
55
|
+
end
|
56
|
+
rescue Fog::CDN::HP::NotFound => err
|
57
|
+
@log.fatal "You don't have a container named '#{name}' on the CDN.", :not_found
|
58
|
+
end
|
59
|
+
}
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,72 @@
|
|
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/cdn_containers/add'
|
23
|
+
require 'hpcloud/commands/cdn_containers/remove'
|
24
|
+
require 'hpcloud/commands/cdn_containers/set'
|
25
|
+
require 'hpcloud/commands/cdn_containers/get'
|
26
|
+
require 'hpcloud/commands/cdn_containers/location'
|
27
|
+
|
28
|
+
module HP
|
29
|
+
module Cloud
|
30
|
+
class CLI < Thor
|
31
|
+
|
32
|
+
map 'cdn:containers:list' => 'cdn:containers'
|
33
|
+
|
34
|
+
desc "cdn:containers", "List available containers on the CDN."
|
35
|
+
long_desc <<-DESC
|
36
|
+
List the available containers on the content delivery network (CDN). Optionally, you can specify an availability zone.
|
37
|
+
|
38
|
+
Examples:
|
39
|
+
hpcloud cdn:containers # List only the CDN-enabled containers
|
40
|
+
hpcloud cdn:containers -l # List all the container on the CDN
|
41
|
+
hpcloud cdn:containers -z region-a.geo-1 # List only the CDN-enabled containers for availability zone `region-a.geo-1`
|
42
|
+
|
43
|
+
Aliases: cdn:containers:list
|
44
|
+
DESC
|
45
|
+
method_option :all, :default => false,
|
46
|
+
:type => :boolean, :aliases => '-l',
|
47
|
+
:desc => 'List all the CDN containers, either enabled or disabled.'
|
48
|
+
CLI.add_common_options
|
49
|
+
define_method "cdn:containers" do
|
50
|
+
cli_command(options) {
|
51
|
+
begin
|
52
|
+
response = if options[:all]
|
53
|
+
Connection.instance.cdn.get_containers()
|
54
|
+
else
|
55
|
+
Connection.instance.cdn.get_containers({'enabled_only' => true})
|
56
|
+
end
|
57
|
+
cdn_containers = response.body
|
58
|
+
if cdn_containers.nil? or cdn_containers.empty?
|
59
|
+
@log.display "You currently have no containers on the CDN."
|
60
|
+
else
|
61
|
+
cdn_containers.each { |cdn_container|
|
62
|
+
@log.display cdn_container['name']
|
63
|
+
}
|
64
|
+
end
|
65
|
+
rescue Fog::CDN::HP::NotFound => e
|
66
|
+
@log.display "You currently have no containers on the CDN."
|
67
|
+
end
|
68
|
+
}
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,60 @@
|
|
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 'fileutils'
|
23
|
+
|
24
|
+
module HP
|
25
|
+
module Cloud
|
26
|
+
class CLI < Thor
|
27
|
+
|
28
|
+
desc 'complete', "Installs the bash completion file."
|
29
|
+
long_desc <<-DESC
|
30
|
+
Installs the HP Cloud bash completion file. If you run this command as the root user, the file is installed in a system-wide directory (if one is available). Otherwise, the file is installed in the `~/.bash_completion.d/` directory. The `~/.bash_completion.d/` directory is not run by default; you must run the completion script explicitly.
|
31
|
+
|
32
|
+
Examples:
|
33
|
+
hpcloud complete # Installs the HP Cloud bash completion file.
|
34
|
+
DESC
|
35
|
+
def complete
|
36
|
+
begin
|
37
|
+
completion_dir = File.expand_path(File.join(File.dirname(__FILE__), '../../..', 'completion'))
|
38
|
+
destination = '/etc/bash_completion.d/'
|
39
|
+
unless File.writable?(destination)
|
40
|
+
@log.display "The system wide #{destination} directory exists, but is not writable." if File.exists?(destination)
|
41
|
+
destination = "/opt/local/etc/bash_completion.d"
|
42
|
+
unless File.writable?(destination)
|
43
|
+
@log.display "The system wide #{destination} directory exists, but is not writable." if File.exists?(destination)
|
44
|
+
destination = "#{ENV['HOME']}/.bash_completion.d"
|
45
|
+
FileUtils.mkdir(destination) unless File.exists?(destination)
|
46
|
+
@log.display "You may need to manually execute the bash completion script in your .bashrc"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
completion_file = "#{completion_dir}/hpcloud"
|
50
|
+
destination = "#{destination}/hpcloud"
|
51
|
+
@log.display "Attempting to copy #{completion_file} file to #{destination}"
|
52
|
+
FileUtils.copy(completion_file, destination)
|
53
|
+
@log.display "Success"
|
54
|
+
rescue Exception => e
|
55
|
+
@log.error "Error configuring bash completion: #{e}"
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
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 %w(config:add config:update) => 'config:set'
|
27
|
+
|
28
|
+
desc 'config:set key=value [key=value ...]', "Set values in the configuration file."
|
29
|
+
long_desc <<-DESC
|
30
|
+
Set values in the configuration file. You may specify multiple name value pairs separated by spaces on a single command line. Valid settings include:
|
31
|
+
|
32
|
+
* connect_timeout (in seconds)
|
33
|
+
* read_timeout (in seconds)
|
34
|
+
* write_timeout (in seconds)
|
35
|
+
|
36
|
+
Examples:
|
37
|
+
hpcloud config:set read_timeout=120 # Set the read timeout to 120 seconds
|
38
|
+
hpcloud config:set write_timeout=60 read_time=60 # Set the write timeout to 60 seconds and the read timeout to 60 seconds
|
39
|
+
|
40
|
+
Aliases: config:add, config:update
|
41
|
+
DESC
|
42
|
+
define_method "config:set" do |pair, *pairs|
|
43
|
+
cli_command(options) {
|
44
|
+
config = Config.new(true)
|
45
|
+
updated = ""
|
46
|
+
pairs = [pair] + pairs
|
47
|
+
pairs.each { |nvp|
|
48
|
+
sub_command {
|
49
|
+
k, v = Config.split(nvp)
|
50
|
+
config.set(k, v)
|
51
|
+
updated += " " if updated.empty? == false
|
52
|
+
updated += nvp
|
53
|
+
}
|
54
|
+
}
|
55
|
+
if updated.empty? == false
|
56
|
+
config.write()
|
57
|
+
@log.display "Configuration set " + updated
|
58
|
+
end
|
59
|
+
}
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,46 @@
|
|
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/config/set'
|
23
|
+
|
24
|
+
module HP
|
25
|
+
module Cloud
|
26
|
+
class CLI < Thor
|
27
|
+
|
28
|
+
map 'config:list' => 'config'
|
29
|
+
|
30
|
+
desc 'config', "List the current configuration settings."
|
31
|
+
long_desc <<-DESC
|
32
|
+
List the current configuration settings.
|
33
|
+
|
34
|
+
Examples:
|
35
|
+
hpcloud config # List the current configuration settings
|
36
|
+
|
37
|
+
Aliases: config:list
|
38
|
+
DESC
|
39
|
+
def config
|
40
|
+
cli_command(options) {
|
41
|
+
@log.display Config.new.list
|
42
|
+
}
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
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
|
+
desc "containers:add name [name ...]", "Add a container."
|
27
|
+
long_desc <<-DESC
|
28
|
+
Add a new container to your storage account. You may creeate multiple containers by specifying more than one container name on the command line. You can specify the ontainer name with or without the preceding colon: 'my_container' or ':my_container'. Optionally, you can specify an availability zone.
|
29
|
+
|
30
|
+
Examples:
|
31
|
+
hpcloud containers:add :my_container # Create a new container called 'my_container'
|
32
|
+
hpcloud containers:add :con :tainer # Create two new containers called 'con' and 'tainer'
|
33
|
+
hpcloud containers:add :my_container -z region-a.geo-1 # Create the container `my_container` for the availability zone `region-a.geo-1`
|
34
|
+
DESC
|
35
|
+
method_option :force, :default => false,
|
36
|
+
:type => :boolean, :aliases => '-f',
|
37
|
+
:desc => "Don't prompt if container name is not a valid virtual host."
|
38
|
+
CLI.add_common_options
|
39
|
+
define_method "containers:add" do |name, *names|
|
40
|
+
cli_command(options) {
|
41
|
+
names = [name] + names
|
42
|
+
names.each { |name|
|
43
|
+
sub_command("adding container") {
|
44
|
+
res = ContainerResource.new(Connection.instance.storage, name)
|
45
|
+
name = res.container
|
46
|
+
if res.container_head()
|
47
|
+
@log.fatal "Container '#{name}' already exists.", :conflicted
|
48
|
+
else
|
49
|
+
if acceptable_name?(res, options)
|
50
|
+
Connection.instance.storage.directories.create(:key => name)
|
51
|
+
@log.display "Created container '#{name}'."
|
52
|
+
end
|
53
|
+
end
|
54
|
+
}
|
55
|
+
}
|
56
|
+
}
|
57
|
+
end
|
58
|
+
|
59
|
+
private
|
60
|
+
|
61
|
+
def acceptable_name?(res, options)
|
62
|
+
res.valid_virtualhost? or options[:force] or yes?('Specified container name is not a valid virtualhost, continue anyway? [y/n]')
|
63
|
+
end
|
64
|
+
|
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 %w(containers:rm containers:delete containers:del) => 'containers:remove'
|
27
|
+
|
28
|
+
desc "containers:remove name [name ...]", "Remove a containers."
|
29
|
+
long_desc <<-DESC
|
30
|
+
Remove one or more containers. By default this command removes a container if it is empty, but you may use the `--force` flag to delete non-empty containers. Be careful with this flag or you could have a really bad day.
|
31
|
+
|
32
|
+
Examples:
|
33
|
+
hpcloud containers:remove :my_container # Delete 'my_container' (if empty)
|
34
|
+
hpcloud containers:remove :tainer1 :tainer2 # Delete 'tainer1' and 'tainer2' (if empty)
|
35
|
+
hpcloud containers:remove :my_container --force # Delete `my container` (regardless of contents)
|
36
|
+
hpcloud containers:remove :my_container -z region-a.geo-1 # Delete the container `my_container` for availability zone 'region-a.geo-1`
|
37
|
+
|
38
|
+
Aliases: containers:rm, containers:delete, containers:del
|
39
|
+
DESC
|
40
|
+
method_option :force, :default => false,
|
41
|
+
:type => :boolean, :aliases => '-f',
|
42
|
+
:desc => 'Force removal of non-empty containers.'
|
43
|
+
CLI.add_common_options
|
44
|
+
define_method "containers:remove" do |name, *names|
|
45
|
+
cli_command(options) {
|
46
|
+
names = [name] + names
|
47
|
+
names.each { |name|
|
48
|
+
resource = ResourceFactory.create(Connection.instance.storage, name)
|
49
|
+
if resource.is_container?
|
50
|
+
if resource.remove(options.force)
|
51
|
+
@log.display "Removed container '#{name}'."
|
52
|
+
else
|
53
|
+
@log.error resource.cstatus
|
54
|
+
end
|
55
|
+
else
|
56
|
+
@log.error "The specified object is not a container: #{name}", :incorrect_usage
|
57
|
+
end
|
58
|
+
}
|
59
|
+
}
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
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 "containers:sync name key [location]", "Allow container synchronization."
|
27
|
+
long_desc <<-DESC
|
28
|
+
Allow container synchronization using the specified key. If you are creating a destination for synchronization, only the key should be specified. If you are creating a source for synchronization, specify a key and location. The same key must be used in the source and destination. It is possible to have containers as both a source and destination. List your synchronization information with the "hpcloud list --sync" command.
|
29
|
+
|
30
|
+
Examples:
|
31
|
+
hpcloud containers:sync :atainer keyo # Set up the container :atainer to be a destination for synchronization
|
32
|
+
hpcloud containers:sync :btainer keyo atainer # Synchronize :btainer to remote container :atainer
|
33
|
+
hpcloud containers:sync :atainer keyo https://region-b.geo-1.objects.hpcloudsvc.com:443/v1/96XXXXXX/btainer # Create a two way synchronization between :atainer and :btainer
|
34
|
+
DESC
|
35
|
+
CLI.add_common_options
|
36
|
+
define_method "containers:sync" do |name, key, *location|
|
37
|
+
cli_command(options) {
|
38
|
+
if location.empty?
|
39
|
+
location = nil
|
40
|
+
else
|
41
|
+
location = location[0]
|
42
|
+
end
|
43
|
+
sub_command("syncing container") {
|
44
|
+
res = ContainerResource.new(Connection.instance.storage, name)
|
45
|
+
if res.sync(key, location)
|
46
|
+
if location.nil?
|
47
|
+
@log.display "Container #{name} using key '#{key}'"
|
48
|
+
else
|
49
|
+
@log.display "Container #{name} using key '#{key}' to #{location}"
|
50
|
+
end
|
51
|
+
else
|
52
|
+
@log.error res.cstatus
|
53
|
+
end
|
54
|
+
}
|
55
|
+
}
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,24 @@
|
|
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/containers/add'
|
23
|
+
require 'hpcloud/commands/containers/remove'
|
24
|
+
require 'hpcloud/commands/containers/sync'
|
@@ -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
|
+
map 'cp' => 'copy'
|
27
|
+
|
28
|
+
desc 'copy <source> [source ...] <destination>', "Copy files from one resource to another."
|
29
|
+
long_desc <<-DESC
|
30
|
+
Copy a file between your file system and a container, inside a container, or between containers. You may copy multiple files to a directory or container on one command line. Optionally, you can specify an availability zone. Note that a leading colon `:` is required when you specify a container; for example `:my_container`.
|
31
|
+
|
32
|
+
Examples:
|
33
|
+
hpcloud copy my_file.txt :my_container # Copy the file `my_file.txt` to container 'my_container'
|
34
|
+
hpcloud copy :my_container/file.txt file.txt # Copy the file `file.txt` from container `my_container` to your local system
|
35
|
+
hpcloud copy :logs/today :logs/old/weds # Copy the file `today` to new location `old/weds` inside container `logs`
|
36
|
+
hpcloud copy :one/file.txt :two/file.txt # Copy file.txt from container `one` to container `two`
|
37
|
+
hpcloud copy :one /usr/local # Copy container `one` to the `/usr/local` directory on your local system
|
38
|
+
hpcloud copy /usr/local :two # Copy directory `/usr/local` to container `two`
|
39
|
+
hpcloud copy one.txt two.txt :numbers # Copy text files `one.txt` and `two.txt` to container `numbers`
|
40
|
+
hpcloud copy my_file.txt :my_container -z region-a.geo-1 # Copy the file `my_file.txt` to container 'my_container' for availability zone `region-a.geo-1`
|
41
|
+
|
42
|
+
Aliases: cp
|
43
|
+
|
44
|
+
DESC
|
45
|
+
method_option :mime,
|
46
|
+
:type => :string, :aliases => '-m',
|
47
|
+
:desc => 'Set the MIME type of the remote object.'
|
48
|
+
method_option :source_account,
|
49
|
+
:type => :string, :aliases => '-s',
|
50
|
+
:desc => 'Source account name.'
|
51
|
+
method_option :restart, :default => false,
|
52
|
+
:type => :boolean, :aliases => '-r',
|
53
|
+
:desc => 'Restart a previous large file upload.'
|
54
|
+
CLI.add_common_options
|
55
|
+
def copy(source, *destination)
|
56
|
+
cli_command(options) {
|
57
|
+
last = destination.pop
|
58
|
+
source = [source] + destination
|
59
|
+
destination = last
|
60
|
+
to = ResourceFactory.create_any(Connection.instance.storage, destination)
|
61
|
+
if source.length > 1 && to.isDirectory() == false
|
62
|
+
@log.fatal("The destination '#{destination}' for multiple files must be a directory or container")
|
63
|
+
end
|
64
|
+
source.each { |name|
|
65
|
+
from = ResourceFactory.create_any(Connection.instance.storage(options[:source_account]), name)
|
66
|
+
from.set_mime_type(options[:mime])
|
67
|
+
to.set_restart(options[:restart])
|
68
|
+
if to.copy(from)
|
69
|
+
@log.display "Copied #{from.fname} => #{to.fname}"
|
70
|
+
else
|
71
|
+
@log.fatal to.cstatus
|
72
|
+
end
|
73
|
+
}
|
74
|
+
}
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
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 "dns:add <name> <email>", "Add a DNS domain."
|
27
|
+
long_desc <<-DESC
|
28
|
+
Add a DNS domain with the specified name and email address. Optionally, you can specify a TTL (time to live) to adjust DNS caching of your entry. The default time to live (TTL) is 3600 (one hour).
|
29
|
+
|
30
|
+
Examples:
|
31
|
+
hpcloud dns:add mydomain.com. email@example.com # Create a new DNS domain `mydomain.com` with email address `email@example.com`
|
32
|
+
hpcloud dns:add mydomain.com. email@xample.com -t 7200 # Create a new DNS domain `mydomain.com` with email address `email@example.com` and time to live 7200
|
33
|
+
DESC
|
34
|
+
method_option :ttl, :default => 3600,
|
35
|
+
:type => :string, :aliases => '-t',
|
36
|
+
:desc => 'Time to live.'
|
37
|
+
CLI.add_common_options
|
38
|
+
define_method "dns:add" do |name, email|
|
39
|
+
cli_command(options) {
|
40
|
+
if Dnss.new.get(name).is_valid? == true
|
41
|
+
@log.fatal "Dns with the name '#{name}' already exists"
|
42
|
+
end
|
43
|
+
dns = HP::Cloud::DnsHelper.new(Connection.instance)
|
44
|
+
dns.name = name
|
45
|
+
dns.ttl = options[:ttl]
|
46
|
+
dns.email = email
|
47
|
+
if dns.save == true
|
48
|
+
@log.display "Created dns '#{name}' with id '#{dns.id}'."
|
49
|
+
else
|
50
|
+
@log.fatal dns.cstatus
|
51
|
+
end
|
52
|
+
}
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|