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,73 @@
|
|
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 'mv' => 'move'
|
27
|
+
|
28
|
+
desc 'move <source ...> <destination>', 'Move objects inside or between containers.'
|
29
|
+
long_desc <<-DESC
|
30
|
+
Move objects to a new location inside a container or between containers. The source file is removed after a successful transfer. If you specify more than one source, the destination must be a container, or a directory ending in `/`. Optionally, you can specify an availability zone. For copying files to and from your local filesystem see `copy`.
|
31
|
+
|
32
|
+
Examples:
|
33
|
+
hpcloud move :my_container/file.txt :my_container/old/backup.txt # Move file `file.txt` to new name and location `old/backup.txt` in container `my_container`
|
34
|
+
hpcloud move :my_container/file.txt :other_container/file.txt # Move file `file.txt` from container `my_container` to container `other_container`
|
35
|
+
hpcloud move :tain/f1.txt :tain/f2.txt :othertain/directory/ # Move files `f1.txt` and f2.txt` from container `tain` to directory `/directory` in container `othertain`
|
36
|
+
hpcloud move :my_container/file.txt :my_container/old/backup.txt -z region-a.geo-1 # Move file `file.txt` to new name and location `old/backup.txt` in container `my_container` for availability zone `region-a.geo-1`
|
37
|
+
|
38
|
+
Aliases: mv
|
39
|
+
DESC
|
40
|
+
CLI.add_common_options
|
41
|
+
def move(source, *destination)
|
42
|
+
cli_command(options) {
|
43
|
+
last = destination.pop
|
44
|
+
if last.nil?
|
45
|
+
@log.fatal "To move you must specify a source and a destination", :incorrect_usage
|
46
|
+
end
|
47
|
+
source = [source] + destination
|
48
|
+
destination = last
|
49
|
+
to = ResourceFactory.create_any(Connection.instance.storage, destination)
|
50
|
+
if source.length > 1 && to.isDirectory() == false
|
51
|
+
@log.fatal("The destination '#{destination}' for multiple files must be a directory or container")
|
52
|
+
end
|
53
|
+
source.each { |name|
|
54
|
+
from = ResourceFactory.create_any(Connection.instance.storage, name)
|
55
|
+
if from.isLocal()
|
56
|
+
@log.error "Move is limited to remote objects. Please use '#{selfname} copy' instead.", :incorrect_usage
|
57
|
+
next
|
58
|
+
end
|
59
|
+
if to.copy(from)
|
60
|
+
if from.remove(false)
|
61
|
+
@log.display "Moved #{from.fname} => #{to.fname}"
|
62
|
+
else
|
63
|
+
@log.error from.cstatus
|
64
|
+
end
|
65
|
+
else
|
66
|
+
@log.error to.cstatus
|
67
|
+
end
|
68
|
+
}
|
69
|
+
}
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
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
|
+
desc "networks:add <name>", "Add a network."
|
27
|
+
long_desc <<-DESC
|
28
|
+
Add a new network in your account with the specified name. Optionally, you can specify administrative state.
|
29
|
+
|
30
|
+
Examples:
|
31
|
+
hpcloud networks:add netty # Create a new network named 'netty'
|
32
|
+
hpcloud networks:add netty --no-adminstateup # Create a new network named 'netty' admin state down
|
33
|
+
DESC
|
34
|
+
method_option :adminstateup, :default => true,
|
35
|
+
:type => :boolean, :aliases => '-u',
|
36
|
+
:desc => 'Administrative state up.'
|
37
|
+
CLI.add_common_options
|
38
|
+
define_method "networks:add" do |name|
|
39
|
+
cli_command(options) {
|
40
|
+
if Networks.new.get(name).is_valid? == true
|
41
|
+
@log.fatal "Network with the name '#{name}' already exists"
|
42
|
+
end
|
43
|
+
network = HP::Cloud::NetworkHelper.new(Connection.instance)
|
44
|
+
network.name = name
|
45
|
+
network.admin_state_up = options[:adminstateup]
|
46
|
+
if network.save == true
|
47
|
+
@log.display "Created network '#{name}' with id '#{network.id}'."
|
48
|
+
else
|
49
|
+
@log.fatal network.cstatus
|
50
|
+
end
|
51
|
+
}
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
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(networks:rm networks:delete networks:del) => 'networks:remove'
|
27
|
+
|
28
|
+
desc "networks:remove name_or_id [name_or_id ...]", "Remove a network (specified by name or ID)."
|
29
|
+
long_desc <<-DESC
|
30
|
+
Remove network by specifying their names or ID. You may specify more than one network name or ID on a command line.
|
31
|
+
|
32
|
+
Examples:
|
33
|
+
hpcloud networks:remove arpa darpa # Delete the network 'arpa' and 'darpa'
|
34
|
+
hpcloud networks:remove 0b78d0cd # Delete the network with ID 998
|
35
|
+
|
36
|
+
Aliases: networks:rm, networks:delete, networks:del
|
37
|
+
DESC
|
38
|
+
CLI.add_common_options
|
39
|
+
define_method "networks:remove" do |name_or_id, *name_or_ids|
|
40
|
+
cli_command(options) {
|
41
|
+
name_or_ids = [name_or_id] + name_or_ids
|
42
|
+
networks = Networks.new.get(name_or_ids, false)
|
43
|
+
networks.each { |network|
|
44
|
+
sub_command("removing network") {
|
45
|
+
if network.is_valid?
|
46
|
+
network.destroy
|
47
|
+
@log.display "Removed network '#{network.name}'."
|
48
|
+
else
|
49
|
+
@log.error network.cstatus
|
50
|
+
end
|
51
|
+
}
|
52
|
+
}
|
53
|
+
}
|
54
|
+
end
|
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
|
+
desc "networks:update <name>", "Update a network."
|
27
|
+
long_desc <<-DESC
|
28
|
+
Update network in your account with the specified name. The administrative state may be updated.
|
29
|
+
|
30
|
+
Examples:
|
31
|
+
hpcloud networks:update netty -u # Updated 'netty' to up
|
32
|
+
hpcloud networks:update 701be39b --no-adminstateup # Update network '701be39b' admin state down
|
33
|
+
DESC
|
34
|
+
method_option :adminstateup, :default => true,
|
35
|
+
:type => :boolean, :aliases => '-u',
|
36
|
+
:desc => 'Administrative state up.'
|
37
|
+
CLI.add_common_options
|
38
|
+
define_method "networks:update" do |name|
|
39
|
+
cli_command(options) {
|
40
|
+
network = Networks.new.get(name)
|
41
|
+
if network.is_valid? == false
|
42
|
+
@log.fatal "Network with the name '#{name}' does not exist"
|
43
|
+
end
|
44
|
+
network.admin_state_up = options[:adminstateup]
|
45
|
+
if network.save == true
|
46
|
+
@log.display "Updated network '#{name}'"
|
47
|
+
else
|
48
|
+
@log.fatal network.cstatus
|
49
|
+
end
|
50
|
+
}
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
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/networks/add.rb'
|
23
|
+
require 'hpcloud/commands/networks/remove.rb'
|
24
|
+
require 'hpcloud/commands/networks/update.rb'
|
25
|
+
require 'hpcloud/networks'
|
26
|
+
|
27
|
+
module HP
|
28
|
+
module Cloud
|
29
|
+
class CLI < Thor
|
30
|
+
|
31
|
+
map 'networks:list' => 'networks'
|
32
|
+
|
33
|
+
desc 'networks [name_or_id ...]', "List the available networks."
|
34
|
+
long_desc <<-DESC
|
35
|
+
Lists all the networks 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 networks # List all networks
|
39
|
+
hpcloud networks 12857174 # List the details for networks with id `12857174`
|
40
|
+
hpcloud networks testo # List the details for networks named `testo`
|
41
|
+
|
42
|
+
Aliases: networks:list
|
43
|
+
DESC
|
44
|
+
CLI.add_report_options
|
45
|
+
CLI.add_common_options
|
46
|
+
def networks(*arguments)
|
47
|
+
cli_command(options) {
|
48
|
+
networks = Networks.new
|
49
|
+
if networks.empty?
|
50
|
+
@log.display "You currently have no networks, use `#{selfname} networks:add <name>` to create one."
|
51
|
+
else
|
52
|
+
ray = networks.get_array(arguments)
|
53
|
+
if ray.empty?
|
54
|
+
@log.display "There are no networks that match the provided arguments"
|
55
|
+
else
|
56
|
+
Tableizer.new(options, NetworkHelper.get_keys(), ray).print
|
57
|
+
end
|
58
|
+
end
|
59
|
+
}
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,81 @@
|
|
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 "ports:add <name> <network_id_or_name>", "Add a port."
|
27
|
+
long_desc <<-DESC
|
28
|
+
Add a new port to your network with the specified name. Optionally, you can specify fixed IPs, MAC address, administrative state, device identifier, device owner, and security groups.
|
29
|
+
|
30
|
+
Examples:
|
31
|
+
hpcloud ports:add porto netty # Create a new port named 'porto'
|
32
|
+
hpcloud ports:add porto 701be39b -d devvy -o ohnur -u # Create a new port named 'porto' associated with 'devvy' and 'ohnur' administratively up
|
33
|
+
DESC
|
34
|
+
method_option :fixedips,
|
35
|
+
:type => :string, :aliases => '-f',
|
36
|
+
:desc => 'Fixed IPs.'
|
37
|
+
method_option :macaddress,
|
38
|
+
:type => :string, :aliases => '-m',
|
39
|
+
:desc => 'MAC address.'
|
40
|
+
method_option :adminstate, :default => true,
|
41
|
+
:type => :boolean, :aliases => '-u',
|
42
|
+
:desc => 'Administrative state.'
|
43
|
+
method_option :deviceid,
|
44
|
+
:type => :string, :aliases => '-d',
|
45
|
+
:desc => 'Device ID.'
|
46
|
+
method_option :deviceowner,
|
47
|
+
:type => :string, :aliases => '-o',
|
48
|
+
:desc => 'Device owner.'
|
49
|
+
method_option :securitygroups,
|
50
|
+
:type => :string, :aliases => '-g',
|
51
|
+
:desc => 'Security groups.'
|
52
|
+
CLI.add_common_options
|
53
|
+
define_method "ports:add" do |name, network|
|
54
|
+
cli_command(options) {
|
55
|
+
if Ports.new.get(name).is_valid? == true
|
56
|
+
@log.fatal "Port with the name '#{name}' already exists"
|
57
|
+
end
|
58
|
+
network = HP::Cloud::Networks.new.get(network)
|
59
|
+
if network.is_valid? == false
|
60
|
+
@log.fatal network.cstatus
|
61
|
+
end
|
62
|
+
|
63
|
+
port = HP::Cloud::PortHelper.new(Connection.instance)
|
64
|
+
port.name = name
|
65
|
+
port.network_id = network.id
|
66
|
+
port.set_fixed_ips(options[:fixedips])
|
67
|
+
port.set_mac_address(options[:macaddress])
|
68
|
+
port.set_admin_state(options[:adminstate])
|
69
|
+
port.set_device_id(options[:deviceid])
|
70
|
+
port.set_device_owner(options[:deviceowner])
|
71
|
+
port.set_security_groups(options[:security_groups])
|
72
|
+
if port.save == true
|
73
|
+
@log.display "Created port '#{name}' with id '#{port.id}'."
|
74
|
+
else
|
75
|
+
@log.fatal port.cstatus
|
76
|
+
end
|
77
|
+
}
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
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(ports:rm ports:delete ports:del) => 'ports:remove'
|
27
|
+
|
28
|
+
desc "ports:remove name_or_id [name_or_id ...]", "Remove a port (specified by name or ID)."
|
29
|
+
long_desc <<-DESC
|
30
|
+
Remove port by specifying their names or ID. You may specify more than one port name or ID on a command line.
|
31
|
+
|
32
|
+
Examples:
|
33
|
+
hpcloud ports:remove blue red # Delete the port 'blue' and 'red'
|
34
|
+
hpcloud ports:remove 6d45794b # Delete the port with ID 6d45794b
|
35
|
+
|
36
|
+
Aliases: ports:rm, ports:delete, ports:del
|
37
|
+
DESC
|
38
|
+
CLI.add_common_options
|
39
|
+
define_method "ports:remove" do |name_or_id, *name_or_ids|
|
40
|
+
cli_command(options) {
|
41
|
+
name_or_ids = [name_or_id] + name_or_ids
|
42
|
+
ports = Ports.new.get(name_or_ids, false)
|
43
|
+
ports.each { |port|
|
44
|
+
sub_command("removing port") {
|
45
|
+
if port.is_valid?
|
46
|
+
port.destroy
|
47
|
+
@log.display "Removed port '#{port.id}'."
|
48
|
+
else
|
49
|
+
@log.error port.cstatus
|
50
|
+
end
|
51
|
+
}
|
52
|
+
}
|
53
|
+
}
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
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 "ports:update <name>", "Update a port."
|
27
|
+
long_desc <<-DESC
|
28
|
+
Update fixed IPs, administrative state, device identifier, or device owner on a port in your network.
|
29
|
+
|
30
|
+
Examples:
|
31
|
+
hpcloud ports:update porto -u -d trump # Update 'porto' administrative status and device owner
|
32
|
+
hpcloud ports:update c14411d7 -u -d trump # Update 'c14411d7' administrative status and device owner
|
33
|
+
DESC
|
34
|
+
method_option :fixedips,
|
35
|
+
:type => :string, :aliases => '-f',
|
36
|
+
:desc => 'Fixed IPs.'
|
37
|
+
method_option :adminstate, :default => true,
|
38
|
+
:type => :boolean, :aliases => '-u',
|
39
|
+
:desc => 'Administrative state.'
|
40
|
+
method_option :deviceid,
|
41
|
+
:type => :string, :aliases => '-d',
|
42
|
+
:desc => 'Device ID.'
|
43
|
+
method_option :deviceowner,
|
44
|
+
:type => :string, :aliases => '-o',
|
45
|
+
:desc => 'Device owner.'
|
46
|
+
CLI.add_common_options
|
47
|
+
define_method "ports:update" do |name|
|
48
|
+
cli_command(options) {
|
49
|
+
port = Ports.new.get(name)
|
50
|
+
if port.is_valid? == false
|
51
|
+
@log.fatal port.cstatus
|
52
|
+
end
|
53
|
+
|
54
|
+
port.set_fixed_ips(options[:fixedips])
|
55
|
+
port.set_admin_state(options[:adminstate])
|
56
|
+
port.set_device_id(options[:deviceid])
|
57
|
+
port.set_device_owner(options[:deviceowner])
|
58
|
+
if port.save == true
|
59
|
+
@log.display "Updated port '#{name}' with id '#{port.id}'."
|
60
|
+
else
|
61
|
+
@log.fatal port.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
|
+
require 'hpcloud/commands/ports/add.rb'
|
23
|
+
require 'hpcloud/commands/ports/remove.rb'
|
24
|
+
require 'hpcloud/commands/ports/update.rb'
|
25
|
+
require 'hpcloud/ports'
|
26
|
+
|
27
|
+
module HP
|
28
|
+
module Cloud
|
29
|
+
class CLI < Thor
|
30
|
+
|
31
|
+
map 'ports:list' => 'ports'
|
32
|
+
|
33
|
+
desc 'ports [name_or_id ...]', "List the available ports."
|
34
|
+
long_desc <<-DESC
|
35
|
+
Lists all the ports that are associated with the account. The list begins with identifier and contains name, network identifier, fixed IPs, MAC address, status, admin state, device identifier, and device owner. Optionally, you can filter the list by specifying name or ID.
|
36
|
+
|
37
|
+
Examples:
|
38
|
+
hpcloud ports # List all ports
|
39
|
+
hpcloud ports 701be39b # List the details for ports with id `701be39b`
|
40
|
+
hpcloud ports testo # List the details for ports named `testo`
|
41
|
+
|
42
|
+
Aliases: ports:list
|
43
|
+
DESC
|
44
|
+
CLI.add_report_options
|
45
|
+
CLI.add_common_options
|
46
|
+
def ports(*arguments)
|
47
|
+
cli_command(options) {
|
48
|
+
ports = Ports.new
|
49
|
+
if ports.empty?
|
50
|
+
@log.display "You currently have no ports, use `#{selfname} ports:add <name>` to create one."
|
51
|
+
else
|
52
|
+
ray = ports.get_array(arguments)
|
53
|
+
if ray.empty?
|
54
|
+
@log.display "There are no ports that match the provided arguments"
|
55
|
+
else
|
56
|
+
Tableizer.new(options, PortHelper.get_keys(), ray).print
|
57
|
+
end
|
58
|
+
end
|
59
|
+
}
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,75 @@
|
|
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(rm delete destroy del) => 'remove'
|
27
|
+
|
28
|
+
desc 'remove object_or_container [object_or_container ...]', 'Remove objects or containers.'
|
29
|
+
long_desc <<-DESC
|
30
|
+
Remove objects or containers. Optionally, you can specify an availability zone.
|
31
|
+
|
32
|
+
Examples:
|
33
|
+
hpcloud remove :tainer/my.txt :tainer/other.txt # Delete objects 'my.txt' and 'other.txt' from container `tainer`
|
34
|
+
hpcloud remove :my_container # Delete container 'my_container'
|
35
|
+
hpcloud remove --after 7200 :my_container/current.log # Delete object 'my_container/current.log' after 2 hours
|
36
|
+
hpcloud remove --at 1366119838 :my_container/current.log # Delete object 'my_container/current.log' in the morning of 4/16/2013
|
37
|
+
hpcloud remove :my_container -z region-a.geo-1 # Delete container 'my_container' in availability zone `region-a.geo-1`
|
38
|
+
|
39
|
+
Aliases: rm, delete, destroy, del
|
40
|
+
DESC
|
41
|
+
method_option :force, :default => false,
|
42
|
+
:type => :boolean, :aliases => '-f',
|
43
|
+
:desc => 'Do not confirm removal; remove non-empty containers.'
|
44
|
+
method_option :at,
|
45
|
+
:type => :string,
|
46
|
+
:desc => 'Delete the object at the specified UNIX epoch time.'
|
47
|
+
method_option :after,
|
48
|
+
:type => :string,
|
49
|
+
:desc => 'Delete the object after the specified number of seconds.'
|
50
|
+
CLI.add_common_options
|
51
|
+
def remove(name, *names)
|
52
|
+
cli_command(options) {
|
53
|
+
names = [name] + names
|
54
|
+
names.each { |name|
|
55
|
+
resource = ResourceFactory.create(Connection.instance.storage, name)
|
56
|
+
if resource.remove(options.force, options[:at], options[:after])
|
57
|
+
if options[:at].nil?
|
58
|
+
if options[:after].nil?
|
59
|
+
@log.display "Removed '#{name}'."
|
60
|
+
else
|
61
|
+
@log.display "Removing '#{name}' after #{options[:after]} seconds."
|
62
|
+
end
|
63
|
+
else
|
64
|
+
@log.display "Removing '#{name}' at #{options[:at]} seconds of the epoch."
|
65
|
+
end
|
66
|
+
else
|
67
|
+
@log.error resource.cstatus
|
68
|
+
end
|
69
|
+
}
|
70
|
+
}
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|