hpcloud 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (238) hide show
  1. data/CHANGELOG +127 -0
  2. data/LICENSE +1 -0
  3. data/README.rdoc +59 -0
  4. data/bin/hpcloud +11 -0
  5. data/completion/hpcloud +372 -0
  6. data/lib/hpcloud/accounts.rb +288 -0
  7. data/lib/hpcloud/acl.rb +112 -0
  8. data/lib/hpcloud/acl_cmd.rb +81 -0
  9. data/lib/hpcloud/address_helper.rb +63 -0
  10. data/lib/hpcloud/addresses.rb +42 -0
  11. data/lib/hpcloud/auth_cache.rb +128 -0
  12. data/lib/hpcloud/base_helper.rb +56 -0
  13. data/lib/hpcloud/checker.rb +104 -0
  14. data/lib/hpcloud/cli.rb +170 -0
  15. data/lib/hpcloud/cli_status.rb +80 -0
  16. data/lib/hpcloud/columns.rb +46 -0
  17. data/lib/hpcloud/commands/account/catalog.rb +57 -0
  18. data/lib/hpcloud/commands/account/copy.rb +44 -0
  19. data/lib/hpcloud/commands/account/edit.rb +204 -0
  20. data/lib/hpcloud/commands/account/remove.rb +53 -0
  21. data/lib/hpcloud/commands/account/setup.rb +40 -0
  22. data/lib/hpcloud/commands/account/tenants.rb +43 -0
  23. data/lib/hpcloud/commands/account/use.rb +46 -0
  24. data/lib/hpcloud/commands/account/verify.rb +55 -0
  25. data/lib/hpcloud/commands/account.rb +67 -0
  26. data/lib/hpcloud/commands/acl/grant.rb +59 -0
  27. data/lib/hpcloud/commands/acl/revoke.rb +52 -0
  28. data/lib/hpcloud/commands/acl.rb +63 -0
  29. data/lib/hpcloud/commands/addresses/add.rb +67 -0
  30. data/lib/hpcloud/commands/addresses/associate.rb +63 -0
  31. data/lib/hpcloud/commands/addresses/disassociate.rb +58 -0
  32. data/lib/hpcloud/commands/addresses/remove.rb +57 -0
  33. data/lib/hpcloud/commands/addresses.rb +63 -0
  34. data/lib/hpcloud/commands/cdn_containers/add.rb +56 -0
  35. data/lib/hpcloud/commands/cdn_containers/get.rb +70 -0
  36. data/lib/hpcloud/commands/cdn_containers/location.rb +61 -0
  37. data/lib/hpcloud/commands/cdn_containers/remove.rb +55 -0
  38. data/lib/hpcloud/commands/cdn_containers/set.rb +63 -0
  39. data/lib/hpcloud/commands/cdn_containers.rb +72 -0
  40. data/lib/hpcloud/commands/complete.rb +60 -0
  41. data/lib/hpcloud/commands/config/set.rb +63 -0
  42. data/lib/hpcloud/commands/config.rb +46 -0
  43. data/lib/hpcloud/commands/containers/add.rb +67 -0
  44. data/lib/hpcloud/commands/containers/remove.rb +63 -0
  45. data/lib/hpcloud/commands/containers/sync.rb +59 -0
  46. data/lib/hpcloud/commands/containers.rb +24 -0
  47. data/lib/hpcloud/commands/copy.rb +78 -0
  48. data/lib/hpcloud/commands/dns/add.rb +56 -0
  49. data/lib/hpcloud/commands/dns/records/add.rb +50 -0
  50. data/lib/hpcloud/commands/dns/records/remove.rb +53 -0
  51. data/lib/hpcloud/commands/dns/records/update.rb +50 -0
  52. data/lib/hpcloud/commands/dns/records.rb +57 -0
  53. data/lib/hpcloud/commands/dns/remove.rb +57 -0
  54. data/lib/hpcloud/commands/dns/servers.rb +57 -0
  55. data/lib/hpcloud/commands/dns/update.rb +58 -0
  56. data/lib/hpcloud/commands/dns.rb +65 -0
  57. data/lib/hpcloud/commands/flavors.rb +59 -0
  58. data/lib/hpcloud/commands/get.rb +58 -0
  59. data/lib/hpcloud/commands/images/add.rb +54 -0
  60. data/lib/hpcloud/commands/images/metadata/add.rb +54 -0
  61. data/lib/hpcloud/commands/images/metadata/remove.rb +56 -0
  62. data/lib/hpcloud/commands/images/metadata.rb +54 -0
  63. data/lib/hpcloud/commands/images/remove.rb +58 -0
  64. data/lib/hpcloud/commands/images.rb +67 -0
  65. data/lib/hpcloud/commands/info.rb +41 -0
  66. data/lib/hpcloud/commands/keypairs/add.rb +73 -0
  67. data/lib/hpcloud/commands/keypairs/import.rb +62 -0
  68. data/lib/hpcloud/commands/keypairs/private/add.rb +44 -0
  69. data/lib/hpcloud/commands/keypairs/private/location.rb +50 -0
  70. data/lib/hpcloud/commands/keypairs/private/remove.rb +52 -0
  71. data/lib/hpcloud/commands/keypairs/private.rb +47 -0
  72. data/lib/hpcloud/commands/keypairs/public_key.rb +51 -0
  73. data/lib/hpcloud/commands/keypairs/remove.rb +58 -0
  74. data/lib/hpcloud/commands/keypairs.rb +64 -0
  75. data/lib/hpcloud/commands/lb/add.rb +92 -0
  76. data/lib/hpcloud/commands/lb/algorithms.rb +55 -0
  77. data/lib/hpcloud/commands/lb/limits.rb +55 -0
  78. data/lib/hpcloud/commands/lb/nodes/add.rb +47 -0
  79. data/lib/hpcloud/commands/lb/nodes/remove.rb +54 -0
  80. data/lib/hpcloud/commands/lb/nodes/update.rb +47 -0
  81. data/lib/hpcloud/commands/lb/nodes.rb +55 -0
  82. data/lib/hpcloud/commands/lb/protocols.rb +55 -0
  83. data/lib/hpcloud/commands/lb/remove.rb +54 -0
  84. data/lib/hpcloud/commands/lb/update.rb +46 -0
  85. data/lib/hpcloud/commands/lb/versions.rb +55 -0
  86. data/lib/hpcloud/commands/lb/virtualips.rb +51 -0
  87. data/lib/hpcloud/commands/lb.rb +73 -0
  88. data/lib/hpcloud/commands/list.rb +114 -0
  89. data/lib/hpcloud/commands/location.rb +56 -0
  90. data/lib/hpcloud/commands/metadata/set.rb +61 -0
  91. data/lib/hpcloud/commands/metadata.rb +60 -0
  92. data/lib/hpcloud/commands/migrate.rb +61 -0
  93. data/lib/hpcloud/commands/move.rb +73 -0
  94. data/lib/hpcloud/commands/networks/add.rb +55 -0
  95. data/lib/hpcloud/commands/networks/remove.rb +57 -0
  96. data/lib/hpcloud/commands/networks/update.rb +54 -0
  97. data/lib/hpcloud/commands/networks.rb +63 -0
  98. data/lib/hpcloud/commands/ports/add.rb +81 -0
  99. data/lib/hpcloud/commands/ports/remove.rb +57 -0
  100. data/lib/hpcloud/commands/ports/update.rb +67 -0
  101. data/lib/hpcloud/commands/ports.rb +63 -0
  102. data/lib/hpcloud/commands/remove.rb +75 -0
  103. data/lib/hpcloud/commands/routers/add.rb +67 -0
  104. data/lib/hpcloud/commands/routers/interface/add.rb +59 -0
  105. data/lib/hpcloud/commands/routers/interface/remove.rb +66 -0
  106. data/lib/hpcloud/commands/routers/remove.rb +54 -0
  107. data/lib/hpcloud/commands/routers/update.rb +66 -0
  108. data/lib/hpcloud/commands/routers.rb +66 -0
  109. data/lib/hpcloud/commands/securitygroups/add.rb +52 -0
  110. data/lib/hpcloud/commands/securitygroups/remove.rb +57 -0
  111. data/lib/hpcloud/commands/securitygroups/rules/add.rb +126 -0
  112. data/lib/hpcloud/commands/securitygroups/rules/remove.rb +51 -0
  113. data/lib/hpcloud/commands/securitygroups/rules.rb +56 -0
  114. data/lib/hpcloud/commands/securitygroups.rb +62 -0
  115. data/lib/hpcloud/commands/servers/add.rb +100 -0
  116. data/lib/hpcloud/commands/servers/console.rb +81 -0
  117. data/lib/hpcloud/commands/servers/limits.rb +46 -0
  118. data/lib/hpcloud/commands/servers/metadata/add.rb +56 -0
  119. data/lib/hpcloud/commands/servers/metadata/remove.rb +57 -0
  120. data/lib/hpcloud/commands/servers/metadata.rb +56 -0
  121. data/lib/hpcloud/commands/servers/password.rb +47 -0
  122. data/lib/hpcloud/commands/servers/ratelimits.rb +46 -0
  123. data/lib/hpcloud/commands/servers/reboot.rb +61 -0
  124. data/lib/hpcloud/commands/servers/rebuild.rb +59 -0
  125. data/lib/hpcloud/commands/servers/remove.rb +58 -0
  126. data/lib/hpcloud/commands/servers/securitygroups/add.rb +47 -0
  127. data/lib/hpcloud/commands/servers/securitygroups/remove.rb +47 -0
  128. data/lib/hpcloud/commands/servers/ssh.rb +92 -0
  129. data/lib/hpcloud/commands/servers.rb +92 -0
  130. data/lib/hpcloud/commands/snapshots/add.rb +62 -0
  131. data/lib/hpcloud/commands/snapshots/remove.rb +58 -0
  132. data/lib/hpcloud/commands/snapshots.rb +62 -0
  133. data/lib/hpcloud/commands/subnets/add.rb +78 -0
  134. data/lib/hpcloud/commands/subnets/remove.rb +57 -0
  135. data/lib/hpcloud/commands/subnets/update.rb +70 -0
  136. data/lib/hpcloud/commands/subnets.rb +63 -0
  137. data/lib/hpcloud/commands/tempurl.rb +62 -0
  138. data/lib/hpcloud/commands/volumes/add.rb +88 -0
  139. data/lib/hpcloud/commands/volumes/attach.rb +59 -0
  140. data/lib/hpcloud/commands/volumes/detach.rb +57 -0
  141. data/lib/hpcloud/commands/volumes/metadata/add.rb +54 -0
  142. data/lib/hpcloud/commands/volumes/metadata.rb +55 -0
  143. data/lib/hpcloud/commands/volumes/remove.rb +57 -0
  144. data/lib/hpcloud/commands/volumes/server.rb +64 -0
  145. data/lib/hpcloud/commands/volumes.rb +65 -0
  146. data/lib/hpcloud/config.rb +205 -0
  147. data/lib/hpcloud/connection.rb +290 -0
  148. data/lib/hpcloud/container_resource.rb +175 -0
  149. data/lib/hpcloud/database_helper.rb +70 -0
  150. data/lib/hpcloud/databases.rb +38 -0
  151. data/lib/hpcloud/dns_helper.rb +125 -0
  152. data/lib/hpcloud/dnss.rb +38 -0
  153. data/lib/hpcloud/error_response.rb +89 -0
  154. data/lib/hpcloud/exceptions/base.rb +35 -0
  155. data/lib/hpcloud/exceptions/general.rb +34 -0
  156. data/lib/hpcloud/exceptions/not_found.rb +34 -0
  157. data/lib/hpcloud/flavors.rb +40 -0
  158. data/lib/hpcloud/floating_ip_helper.rb +114 -0
  159. data/lib/hpcloud/floating_ips.rb +42 -0
  160. data/lib/hpcloud/fog_collection.rb +124 -0
  161. data/lib/hpcloud/image_helper.rb +111 -0
  162. data/lib/hpcloud/images.rb +43 -0
  163. data/lib/hpcloud/keypair_helper.rb +109 -0
  164. data/lib/hpcloud/keypairs.rb +41 -0
  165. data/lib/hpcloud/lb_algorithms.rb +37 -0
  166. data/lib/hpcloud/lb_limits.rb +37 -0
  167. data/lib/hpcloud/lb_nodes.rb +42 -0
  168. data/lib/hpcloud/lb_protocols.rb +37 -0
  169. data/lib/hpcloud/lb_versions.rb +37 -0
  170. data/lib/hpcloud/lb_virtualips.rb +42 -0
  171. data/lib/hpcloud/lbs.rb +38 -0
  172. data/lib/hpcloud/local_resource.rb +183 -0
  173. data/lib/hpcloud/log.rb +55 -0
  174. data/lib/hpcloud/metadata.rb +118 -0
  175. data/lib/hpcloud/monkey.rb +22 -0
  176. data/lib/hpcloud/network_helper.rb +88 -0
  177. data/lib/hpcloud/networks.rb +47 -0
  178. data/lib/hpcloud/object_store.rb +66 -0
  179. data/lib/hpcloud/port_helper.rb +150 -0
  180. data/lib/hpcloud/ports.rb +38 -0
  181. data/lib/hpcloud/progress.rb +53 -0
  182. data/lib/hpcloud/remote_resource.rb +512 -0
  183. data/lib/hpcloud/resource.rb +264 -0
  184. data/lib/hpcloud/resource_factory.rb +110 -0
  185. data/lib/hpcloud/routers.rb +56 -0
  186. data/lib/hpcloud/rule_helper.rb +70 -0
  187. data/lib/hpcloud/rules.rb +41 -0
  188. data/lib/hpcloud/security_group_helper.rb +59 -0
  189. data/lib/hpcloud/security_groups.rb +37 -0
  190. data/lib/hpcloud/server_helper.rb +318 -0
  191. data/lib/hpcloud/servers.rb +47 -0
  192. data/lib/hpcloud/shared_resource.rb +172 -0
  193. data/lib/hpcloud/snapshot_helper.rb +78 -0
  194. data/lib/hpcloud/snapshots.rb +38 -0
  195. data/lib/hpcloud/subnet_helper.rb +170 -0
  196. data/lib/hpcloud/subnets.rb +38 -0
  197. data/lib/hpcloud/tableizer.rb +77 -0
  198. data/lib/hpcloud/thor_ext/thor.rb +54 -0
  199. data/lib/hpcloud/time_parser.rb +47 -0
  200. data/lib/hpcloud/version.rb +27 -0
  201. data/lib/hpcloud/volume_attachment.rb +58 -0
  202. data/lib/hpcloud/volume_attachments.rb +58 -0
  203. data/lib/hpcloud/volume_helper.rb +119 -0
  204. data/lib/hpcloud/volumes.rb +38 -0
  205. data/lib/hpcloud.rb +112 -0
  206. data/lib/monkey/hp/lb.rb +188 -0
  207. data/lib/monkey/hp/models/lb/algorithm.rb +32 -0
  208. data/lib/monkey/hp/models/lb/algorithms.rb +46 -0
  209. data/lib/monkey/hp/models/lb/limit.rb +38 -0
  210. data/lib/monkey/hp/models/lb/limits.rb +50 -0
  211. data/lib/monkey/hp/models/lb/load_balancer.rb +70 -0
  212. data/lib/monkey/hp/models/lb/load_balancers.rb +46 -0
  213. data/lib/monkey/hp/models/lb/node.rb +69 -0
  214. data/lib/monkey/hp/models/lb/nodes.rb +47 -0
  215. data/lib/monkey/hp/models/lb/protocol.rb +33 -0
  216. data/lib/monkey/hp/models/lb/protocols.rb +46 -0
  217. data/lib/monkey/hp/models/lb/version.rb +34 -0
  218. data/lib/monkey/hp/models/lb/versions.rb +47 -0
  219. data/lib/monkey/hp/models/lb/virtual_ip.rb +37 -0
  220. data/lib/monkey/hp/models/lb/virtual_ips.rb +47 -0
  221. data/lib/monkey/hp/requests/lb/create_load_balancer.rb +64 -0
  222. data/lib/monkey/hp/requests/lb/create_load_balancer_node.rb +58 -0
  223. data/lib/monkey/hp/requests/lb/delete_load_balancer.rb +54 -0
  224. data/lib/monkey/hp/requests/lb/delete_load_balancer_node.rb +60 -0
  225. data/lib/monkey/hp/requests/lb/get_load_balancer.rb +88 -0
  226. data/lib/monkey/hp/requests/lb/get_load_balancer_node.rb +60 -0
  227. data/lib/monkey/hp/requests/lb/get_version.rb +68 -0
  228. data/lib/monkey/hp/requests/lb/get_virtual_ips.rb +48 -0
  229. data/lib/monkey/hp/requests/lb/list_algorithms.rb +51 -0
  230. data/lib/monkey/hp/requests/lb/list_limits.rb +60 -0
  231. data/lib/monkey/hp/requests/lb/list_load_balancer_nodes.rb +79 -0
  232. data/lib/monkey/hp/requests/lb/list_load_balancer_virtual_ips.rb +76 -0
  233. data/lib/monkey/hp/requests/lb/list_load_balancers.rb +69 -0
  234. data/lib/monkey/hp/requests/lb/list_protocols.rb +51 -0
  235. data/lib/monkey/hp/requests/lb/list_versions.rb +51 -0
  236. data/lib/monkey/hp/requests/lb/update_load_balancer.rb +46 -0
  237. data/lib/monkey/hp/requests/lb/update_load_balancer_node.rb +50 -0
  238. metadata +368 -0
@@ -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 "routers:add <name>", "Add a router."
27
+ long_desc <<-DESC
28
+ Add a new router to your network with the specified name. If a gateway is not specified, the first network that has router_external set to true is used (typically 'Ext-Net'.
29
+
30
+ Examples:
31
+ hpcloud routers:add routerone # Create a new router named 'routerone'
32
+ hpcloud routers:add routertwo -g Ext-Net # Create a new router named 'routertwo' with the specified network as a gateway
33
+ DESC
34
+ method_option :gateway,
35
+ :type => :string, :aliases => '-g',
36
+ :desc => 'Network to use as external router.'
37
+ method_option :adminstateup, :default => true,
38
+ :type => :boolean, :aliases => '-u',
39
+ :desc => 'Administrative state.'
40
+ CLI.add_common_options
41
+ define_method "routers:add" do |name|
42
+ cli_command(options) {
43
+ router = Routers.new.unique(name)
44
+ router.name = name
45
+ netty = Routers.parse_gateway(options[:gateway])
46
+ if netty.nil?
47
+ router.external_gateway_info = {}
48
+ else
49
+ router.external_gateway_info = { 'network_id' => netty.id }
50
+ end
51
+ router.admin_state_up = options[:adminstateup]
52
+ router.save
53
+ unless netty.nil?
54
+ unless netty.subnets.nil?
55
+ unless netty.subnets.empty?
56
+ sub_command("add router interface for subnet") {
57
+ Connection.instance.network.add_router_interface(router.id, netty.subnets, nil)
58
+ }
59
+ end
60
+ end
61
+ end
62
+ @log.display "Created router '#{name}' with id '#{router.id}'."
63
+ }
64
+ end
65
+ end
66
+ end
67
+ 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 "routers:interface:add <router> <subnet_or_port>", "Add an interface to a router."
27
+ long_desc <<-DESC
28
+ Add an interface to your router with the specified subnet or port.
29
+
30
+ Examples:
31
+ hpcloud routers:interface:add trout subnetty # Add an interface to the subnet 'subnetty'
32
+ hpcloud routers:interface:add trout proto # Add an interface to the port 'porto'
33
+ DESC
34
+ CLI.add_common_options
35
+ define_method "routers:interface:add" do |name, subnet_or_port|
36
+ cli_command(options) {
37
+ router = Routers.new.get(name)
38
+ subnet_id = nil
39
+ port_id = nil
40
+ subby = Subnets.new.get(subnet_or_port)
41
+ if subby.is_valid?
42
+ subnet_id = subby.id
43
+ newinterface = subnet_id
44
+ else
45
+ porty = Ports.new.get(subnet_or_port)
46
+ unless porty.is_valid?
47
+ @log.fatal "Cannot find a subnet or port matching '#{subnet_or_port}'."
48
+ end
49
+ port_id = porty.id
50
+ newinterface = port_id
51
+ end
52
+
53
+ Connection.instance.network.add_router_interface(router.id, subnet_id, port_id)
54
+ @log.display "Created router interface '#{name}' to '#{subnet_or_port}'."
55
+ }
56
+ end
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,66 @@
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(routers:interface:rm routers:interface:delete routers:interface:del) => 'routers:interface:remove'
27
+
28
+ desc "routers:interface:remove <router_name_or_id> <subnet_or_port>", "Remove router interface."
29
+ long_desc <<-DESC
30
+ Remove router port or subnet router interface from router.
31
+
32
+ Examples:
33
+ hpcloud routers:interface:remove trout puerto # Delete port 'puerto' from 'trout'
34
+ hpcloud routers:interface:remove trout netty # Delete subnet 'netty' from 'trout'
35
+
36
+ Aliases: routers:interface:rm, routers:interface:delete, routers:interface:del
37
+ DESC
38
+ CLI.add_common_options
39
+ define_method "routers:interface:remove" do |name, subnet_or_port|
40
+ cli_command(options) {
41
+ router = Routers.new.get(name)
42
+ subnet_id = nil
43
+ port_id = nil
44
+ word = ""
45
+ subby = Subnets.new.get(subnet_or_port)
46
+ if subby.is_valid?
47
+ subnet_id = subby.id
48
+ oldinterface = subnet_id
49
+ word = "subnet"
50
+ else
51
+ porty = Ports.new.get(subnet_or_port)
52
+ unless porty.is_valid?
53
+ @log.fatal "Cannot find a subnet or port matching '#{subnet_or_port}'."
54
+ end
55
+ port_id = porty.id
56
+ oldinterface = port_id
57
+ word = "port"
58
+ end
59
+
60
+ Connection.instance.network.remove_router_interface(router.id, subnet_id, port_id)
61
+ @log.display "Removed #{word} interface '#{subnet_or_port}' from '#{name}'."
62
+ }
63
+ end
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,54 @@
1
+ # encoding: utf-8
2
+ #
3
+ # © Copyright 2013 Hewlett-Packard Development Company, L.P.
4
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ # of this software and associated documentation files (the "Software"), to deal
6
+ # in the Software without restriction, including without limitation the rights
7
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ # copies of the Software, and to permit persons to whom the Software is
9
+ # furnished to do so, subject to the following conditions:
10
+ #
11
+ # The above copyright notice and this permission notice shall be included in all
12
+ # copies or substantial portions of the Software.
13
+ #
14
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ # SOFTWARE.
21
+
22
+ module HP
23
+ module Cloud
24
+ class CLI < Thor
25
+
26
+ map %w(routers:rm routers:delete routers:del) => 'routers:remove'
27
+
28
+ desc "routers:remove name_or_id [name_or_id ...]", "Remove a router (specified by name or ID)."
29
+ long_desc <<-DESC
30
+ Remove router by specifying their names or ID. You may specify more than one router name or ID on a command line.
31
+
32
+ Examples:
33
+ hpcloud routers:remove blue red # Delete the router 'blue' and 'red'
34
+ hpcloud routers:remove 39e36520 # Delete the router with ID 39e36520
35
+
36
+ Aliases: routers:rm, routers:delete, routers:del
37
+ DESC
38
+ CLI.add_common_options
39
+ define_method "routers:remove" do |name_or_id, *name_or_ids|
40
+ cli_command(options) {
41
+ name_or_ids = [name_or_id] + name_or_ids
42
+ routers = Routers.new
43
+ name_or_ids.each{ |name|
44
+ sub_command("removing router") {
45
+ router = routers.get(name, false)
46
+ router.destroy
47
+ @log.display "Removed router '#{router.name}'."
48
+ }
49
+ }
50
+ }
51
+ end
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,66 @@
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 "routers:update <name>", "Update the specified router."
27
+ long_desc <<-DESC
28
+ Update an existing router with new administrative state or gateway infomration. If you do not want an external network, use the gateway option with an empty string.
29
+
30
+ Examples:
31
+ hpcloud routers:update trout -u # Update router 'trout' administrative state
32
+ hpcloud routers:update c14411d7 -u # Update router 'c14411d7' administrative state
33
+ DESC
34
+ method_option :gateway,
35
+ :type => :string, :aliases => '-g',
36
+ :desc => 'Network to use as external router.'
37
+ method_option :adminstateup,
38
+ :type => :boolean, :aliases => '-u',
39
+ :desc => 'Administrative state.'
40
+ CLI.add_common_options
41
+ define_method "routers:update" do |name|
42
+ cli_command(options) {
43
+ router = Routers.new.get(name)
44
+ unless options[:adminstateup].nil?
45
+ if options[:adminstateup] == true
46
+ router.admin_state_up = true
47
+ else
48
+ router.admin_state_up = "false"
49
+ end
50
+ end
51
+ router.external_gateway_info = nil
52
+ unless options[:gateway].nil?
53
+ netty = Routers.parse_gateway(options[:gateway])
54
+ if netty.nil?
55
+ router.external_gateway_info = {}
56
+ else
57
+ router.external_gateway_info = { 'network_id' => netty.id }
58
+ end
59
+ end
60
+ router.save
61
+ @log.display "Updated router '#{name}'."
62
+ }
63
+ end
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,66 @@
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/routers/add.rb'
23
+ require 'hpcloud/commands/routers/remove.rb'
24
+ require 'hpcloud/commands/routers/update.rb'
25
+ require 'hpcloud/commands/routers/interface/add.rb'
26
+ require 'hpcloud/commands/routers/interface/remove.rb'
27
+ require 'hpcloud/routers'
28
+
29
+ module HP
30
+ module Cloud
31
+ class CLI < Thor
32
+
33
+ map 'routers:list' => 'routers'
34
+
35
+ desc 'routers [name_or_id ...]', "List the available routers."
36
+ long_desc <<-DESC
37
+ Lists all the routers that are associated with the account. The list begins with identifier and contains name, status, administrative state, and gateways. Optionally, you can filter the list by specifying name or ID.
38
+
39
+ Examples:
40
+ hpcloud routers # List all routers
41
+ hpcloud routers c14411d7 # List the details for routers with id `c14411d7`
42
+ hpcloud routers testo # List the details for routers named `testo`
43
+
44
+ Aliases: routers:list
45
+ DESC
46
+ CLI.add_report_options
47
+ CLI.add_common_options
48
+ def routers(*arguments)
49
+ columns = [ "id", "name", "admin_state_up", "status", "external_gateway_info" ]
50
+ cli_command(options) {
51
+ routers = Routers.new
52
+ if routers.empty?
53
+ @log.display "You currently have no routers, use `#{selfname} routers:add <name>` to create one."
54
+ else
55
+ ray = routers.get_array(arguments)
56
+ if ray.empty?
57
+ @log.display "There are no routers that match the provided arguments"
58
+ else
59
+ Tableizer.new(options, columns, ray).print
60
+ end
61
+ end
62
+ }
63
+ end
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,52 @@
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 "securitygroups:add <name> <description>", "Add a security group."
27
+ long_desc <<-DESC
28
+ Add a new security group by specifying a name and a description. Optionally, you can specify an availability zone.
29
+
30
+ Examples:
31
+ hpcloud securitygroups:add mysecgroup "seg group desc" # Add new security group `mysecgroup` with description `seg group desc`
32
+ DESC
33
+ CLI.add_common_options
34
+ define_method "securitygroups:add" do |sec_group_name, sg_desc|
35
+ cli_command(options) {
36
+ if SecurityGroups.new.get(sec_group_name).is_valid? == true
37
+ @log.fatal "Security group '#{sec_group_name}' already exists."
38
+ end
39
+
40
+ security_group = SecurityGroupHelper.new(Connection.instance)
41
+ security_group.name = sec_group_name
42
+ security_group.description = sg_desc
43
+ if security_group.save == true
44
+ @log.display "Created security group '#{sec_group_name}' with id '#{security_group.id}'."
45
+ else
46
+ @log.fatal security_group.cstatus
47
+ end
48
+ }
49
+ end
50
+ end
51
+ end
52
+ 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(securitygroups:rm securitygroups:delete securitygroups:del) => 'securitygroups:remove'
27
+
28
+ desc "securitygroups:remove name_or_id [name_or_id ...]", "Remove a security group or groups."
29
+ long_desc <<-DESC
30
+ Remove existing security groups by name or ID. Optionally, you can specify an availability zone.
31
+
32
+ Examples:
33
+ hpcloud securitygroups:remove group1 group2 # Remove the security groups `group1` and `group2`
34
+ hpcloud securitygroups:remove 41fb5504 # Remove the security group with the ID `41fb5504`
35
+
36
+ Aliases: securitygroups:rm, securitygroups:delete, securitygroups:del
37
+ DESC
38
+ CLI.add_common_options
39
+ define_method "securitygroups:remove" do |name_or_id, *name_or_ids|
40
+ cli_command(options) {
41
+ name_or_ids = [name_or_id] + name_or_ids
42
+ securitygroups = SecurityGroups.new.get(name_or_ids, false)
43
+ securitygroups.each { |securitygroup|
44
+ sub_command("removing security group") {
45
+ if securitygroup.is_valid?
46
+ securitygroup.destroy
47
+ @log.display "Removed security group '#{securitygroup.name}'."
48
+ else
49
+ @log.error securitygroup.cstatus
50
+ end
51
+ }
52
+ }
53
+ }
54
+ end
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,126 @@
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(securitygroups:rules:authorize) => 'securitygroups:rules:add'
27
+
28
+ desc "securitygroups:rules:add <sec_group_name> <ip_protocol>", "Add a rule to the security group."
29
+ long_desc <<-DESC
30
+ Add a rule to the security group. If <ip_protocol> is specified as 'icmp', then port range may be omitted. If <cidr> is not specified, then the address defaults to '0.0.0.0/0'. To allow communications within a given security group, you must specify a source group while creating a rule. Optionally, you can specify an availability zone.
31
+
32
+ Examples:
33
+ hpcloud securitygroups:rules:add mysggroup icmp # Set the default port range to -1..-1
34
+ hpcloud securitygroups:rules:add mysggroup tcp -p 22..22 # Set the default cidr to `0.0.0.0/0`
35
+ hpcloud securitygroups:rules:add mysggroup tcp -p 80..80 -c "111.111.111.111/1" # Set the cidr to `111.111.111.111/1`
36
+ hpcloud securitygroups:rules:add mysggroup tcp -p 80..80 -g "mysourcegroup" # Set the source group to `mysourcegroup`
37
+
38
+ Aliases: securitygroups:rules:authorize
39
+ DESC
40
+ method_option :port_range,
41
+ :type => :string, :aliases => '-p',
42
+ :desc => 'Specify a port range like 22..22'
43
+ method_option :cidr,
44
+ :type => :string, :aliases => '-c',
45
+ :desc => 'Specify a cidr ip range like 0.0.0.0/0'
46
+ method_option :source_group,
47
+ :type => :string, :aliases => '-g',
48
+ :desc => 'Specify a source group.'
49
+ method_option :direction,
50
+ :type => :string, :default => 'egress',
51
+ :desc => 'Direction egress or ingress.'
52
+ method_option :ethertype,
53
+ :type => :string, :default => 'IPv4',
54
+ :desc => 'Ether type must be IPv6 or IPv4.'
55
+ CLI.add_common_options
56
+ define_method "securitygroups:rules:add" do |sec_group_name, ip_protocol|
57
+ cli_command(options) {
58
+ src_group_id = nil
59
+ port_range = Range.new(-1, -1)
60
+ port_range_str = options[:port_range]
61
+ cidr = options[:cidr]
62
+ src_group = options[:source_group]
63
+ direction = options[:direction]
64
+ ethertype = options[:ethertype]
65
+
66
+ # either a source group or a cidr value can be specified
67
+ if (src_group && cidr)
68
+ @log.fatal "You can either specify a source group or an ip address, not both.", :incorrect_usage
69
+ end
70
+
71
+ unless (direction == 'egress' || direction == 'ingress')
72
+ @log.fatal "Direction must be egress or ingress.", :incorrect_usage
73
+ end
74
+ unless (ethertype == 'IPv6' || ethertype == 'IPv4')
75
+ @log.fatal "Ethertype must be IPv6 or IPv4.", :incorrect_usage
76
+ end
77
+ unless (ip_protocol == 'tcp' || ip_protocol == 'udp' || ip_protocol == 'icmp')
78
+ @log.fatal "Protocol must be tcp, udp or icmp.", :incorrect_usage
79
+ end
80
+ # incase of icmp it defaults to -1..-1 and 0.0.0.0/0
81
+ unless ip_protocol == 'icmp'
82
+ if port_range_str.nil?
83
+ @log.fatal "You have to specify a port range for any ip protocol other than 'icmp'.", :incorrect_usage
84
+ end
85
+ end
86
+
87
+ # resolve port range
88
+ unless port_range_str.nil?
89
+ port_range = port_range_str.split('..').inject { |s,e| s.to_i..e.to_i }
90
+ end
91
+
92
+ security_group = SecurityGroups.new.get(sec_group_name)
93
+ if security_group.is_valid? == false
94
+ @log.fatal "You don't have a security group '#{sec_group_name}'.", :not_found
95
+ end
96
+
97
+ # if a source group is specified, get its id
98
+ if src_group
99
+ source_group = Connection.instance.network.security_groups.select {|srg| srg.name == src_group}.first
100
+ if (source_group && source_group.name == src_group)
101
+ src_group_id = source_group.id
102
+ else
103
+ @log.fatal "You don't have a source security group '#{src_group}'.", :not_found
104
+ end
105
+ end
106
+
107
+ options = {
108
+ :protocol => ip_protocol,
109
+ :ethertype => ethertype
110
+ }
111
+ unless ip_protocol == 'icmp'
112
+ options[:port_range_min] = port_range.begin
113
+ options[:port_range_max] = port_range.end
114
+ end
115
+ options[:remote_ip_prefix] = cidr unless cidr.nil?
116
+ options[:remote_group_id] = src_group_id unless src_group_id.nil?
117
+
118
+ # create the security group rule
119
+ response = Connection.instance.network.create_security_group_rule(security_group.id, direction, options)
120
+ rule_id = response.body["security_group_rule"]["id"]
121
+ @log.display "Created rule '#{rule_id}' for security group '#{sec_group_name}'."
122
+ }
123
+ end
124
+ end
125
+ end
126
+ end
@@ -0,0 +1,51 @@
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(securitygroups:rules:rm securitygroups:rules:revoke securitygroups:rules:delete securitygroups:rules:del) => 'securitygroups:rules:remove'
27
+
28
+ desc "securitygroups:rules:remove rule_id [rule_id...]", "Remove security group rules."
29
+ long_desc <<-DESC
30
+ Remove the specified security group rules. More than one rule may be specified on the command line.
31
+
32
+ Examples:
33
+ hpcloud securitygroups:rules:remove 6686fc56 # Remove the rule `6686fc56`
34
+ hpcloud securitygroups:rules:remove 6686fc56 2ffc3a4c # Remove the rule `6686fc56` and `2ffc3a4c`
35
+
36
+ Aliases: securitygroups:rules:rm, securitygroups:rules:revoke, securitygroups:rules:delete, securitygroups:rules:del
37
+ DESC
38
+ CLI.add_common_options
39
+ define_method "securitygroups:rules:remove" do |*rule_ids|
40
+ cli_command(options) {
41
+ rule_ids.each { |rule_id|
42
+ sub_command("removing security group rule") {
43
+ Connection.instance.network.delete_security_group_rule(rule_id)
44
+ @log.display "Removed rule '#{rule_id}'."
45
+ }
46
+ }
47
+ }
48
+ end
49
+ end
50
+ end
51
+ end