zaws 0.0.5 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (282) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +2 -0
  3. data/.travis.yml +9 -18
  4. data/Gemfile +0 -0
  5. data/Gemfile.lock +26 -35
  6. data/Gemfile.lock.linux +69 -0
  7. data/Gemfile.lock.mac +81 -0
  8. data/Gemfile.lock.windows +77 -0
  9. data/LICENSE +0 -0
  10. data/README.md +11 -0
  11. data/Rakefile +1 -7
  12. data/archive/cloud_trail/cloud_trail.feature +124 -0
  13. data/bin/win_zaws.bat +2 -0
  14. data/lib/zaws.rb +54 -41
  15. data/lib/zaws/command/ai.rb +34 -0
  16. data/lib/zaws/command/bucket.rb +35 -0
  17. data/lib/zaws/command/cloud_trail.rb +43 -0
  18. data/lib/zaws/command/compute.rb +152 -87
  19. data/lib/zaws/command/config.rb +42 -0
  20. data/lib/zaws/command/elasticip.rb +19 -9
  21. data/lib/zaws/command/hosted_zone.rb +31 -18
  22. data/lib/zaws/command/iam.rb +37 -0
  23. data/lib/zaws/command/load_balancer.rb +54 -51
  24. data/lib/zaws/command/nessus.rb +41 -0
  25. data/lib/zaws/command/newrelic.rb +30 -0
  26. data/lib/zaws/command/route_table.rb +135 -122
  27. data/lib/zaws/command/security_group.rb +95 -82
  28. data/lib/zaws/command/subnet.rb +58 -46
  29. data/lib/zaws/command/sumo.rb +34 -0
  30. data/lib/zaws/command/vpc.rb +53 -0
  31. data/lib/zaws/external/awscli/awscli.rb +65 -0
  32. data/lib/zaws/external/awscli/commands.rb +10 -0
  33. data/lib/zaws/external/awscli/commands/aws.rb +40 -0
  34. data/lib/zaws/external/awscli/commands/ec2.rb +74 -0
  35. data/lib/zaws/external/awscli/commands/ec2/allocate_address.rb +42 -0
  36. data/lib/zaws/external/awscli/commands/ec2/assign_private_ip_addresses.rb +49 -0
  37. data/lib/zaws/external/awscli/commands/ec2/associate_address.rb +48 -0
  38. data/lib/zaws/external/awscli/commands/ec2/associate_route_table.rb +48 -0
  39. data/lib/zaws/external/awscli/commands/ec2/authorize_security_group_ingress.rb +70 -0
  40. data/lib/zaws/external/awscli/commands/ec2/create_route.rb +60 -0
  41. data/lib/zaws/external/awscli/commands/ec2/create_route_table.rb +40 -0
  42. data/lib/zaws/external/awscli/commands/ec2/create_security_group.rb +58 -0
  43. data/lib/zaws/external/awscli/commands/ec2/create_subnet.rb +62 -0
  44. data/lib/zaws/external/awscli/commands/ec2/create_tags.rb +53 -0
  45. data/lib/zaws/external/awscli/commands/ec2/create_vpc.rb +21 -0
  46. data/lib/zaws/external/awscli/commands/ec2/delete_route.rb +54 -0
  47. data/lib/zaws/external/awscli/commands/ec2/delete_route_table.rb +46 -0
  48. data/lib/zaws/external/awscli/commands/ec2/delete_security_group.rb +46 -0
  49. data/lib/zaws/external/awscli/commands/ec2/delete_subnet.rb +46 -0
  50. data/lib/zaws/external/awscli/commands/ec2/describe_addresses.rb +41 -0
  51. data/lib/zaws/external/awscli/commands/ec2/describe_images.rb +58 -0
  52. data/lib/zaws/external/awscli/commands/ec2/describe_instances.rb +56 -0
  53. data/lib/zaws/external/awscli/commands/ec2/describe_route_tables.rb +44 -0
  54. data/lib/zaws/external/awscli/commands/ec2/describe_security_groups.rb +50 -0
  55. data/lib/zaws/external/awscli/commands/ec2/describe_subnets.rb +48 -0
  56. data/lib/zaws/external/awscli/commands/ec2/describe_vpc_peering_connections.rb +23 -0
  57. data/lib/zaws/external/awscli/commands/ec2/describe_vpcs.rb +26 -0
  58. data/lib/zaws/external/awscli/commands/ec2/disable_vgw_route_propagation.rb +48 -0
  59. data/lib/zaws/external/awscli/commands/ec2/disassociate-address.rb +42 -0
  60. data/lib/zaws/external/awscli/commands/ec2/disassociate_route_table.rb +41 -0
  61. data/lib/zaws/external/awscli/commands/ec2/enable_vgw_route_propagation.rb +48 -0
  62. data/lib/zaws/external/awscli/commands/ec2/filter.rb +115 -0
  63. data/lib/zaws/external/awscli/commands/ec2/modify_instance_attribute.rb +62 -0
  64. data/lib/zaws/external/awscli/commands/ec2/network_interfaces.rb +63 -0
  65. data/lib/zaws/external/awscli/commands/ec2/release_address.rb +42 -0
  66. data/lib/zaws/external/awscli/commands/ec2/revoke_security_group_ingress.rb +70 -0
  67. data/lib/zaws/external/awscli/commands/ec2/run_instances.rb +21 -0
  68. data/lib/zaws/external/awscli/commands/ec2/stop_instances.rb +21 -0
  69. data/lib/zaws/external/awscli/commands/ec2/terminate_instances.rb +40 -0
  70. data/lib/zaws/external/awscli/commands/ec2/unassign_private_ip_addresses.rb +49 -0
  71. data/lib/zaws/external/awscli/commands/elb.rb +19 -0
  72. data/lib/zaws/external/awscli/commands/elb/create_load_balancer.rb +64 -0
  73. data/lib/zaws/external/awscli/commands/elb/create_load_balancer_listeners.rb +47 -0
  74. data/lib/zaws/external/awscli/commands/elb/delete_load_balancer.rb +40 -0
  75. data/lib/zaws/external/awscli/commands/elb/delete_load_balancer_listeners.rb +49 -0
  76. data/lib/zaws/external/awscli/commands/elb/deregister_instances_with_load_balancer.rb +49 -0
  77. data/lib/zaws/external/awscli/commands/elb/describe_load_balancers.rb +30 -0
  78. data/lib/zaws/external/awscli/commands/elb/register_instances_with_load_balancer.rb +49 -0
  79. data/lib/zaws/external/awscli/commands/iam.rb +31 -0
  80. data/lib/zaws/external/awscli/commands/iam/GetPolicy.rb +21 -0
  81. data/lib/zaws/external/awscli/commands/iam/GetPolicyVersion.rb +21 -0
  82. data/lib/zaws/external/awscli/commands/iam/GetRolePolicy.rb +21 -0
  83. data/lib/zaws/external/awscli/commands/route53.rb +19 -0
  84. data/lib/zaws/external/awscli/commands/route53/list_hosted_zones.rb +30 -0
  85. data/lib/zaws/external/awscli/commands/route53/list_resource_record_sets.rb +41 -0
  86. data/lib/zaws/external/awscli/commands/s3/ls.rb +34 -0
  87. data/lib/zaws/external/awscli/commands/s3/mb.rb +41 -0
  88. data/lib/zaws/external/awscli/commands/s3/sync.rb +48 -0
  89. data/lib/zaws/external/awscli/credentials.rb +22 -0
  90. data/lib/zaws/external/awscli/data.rb +10 -0
  91. data/lib/zaws/external/awscli/data/ec2.rb +33 -0
  92. data/lib/zaws/external/awscli/data/ec2/instance.rb +162 -0
  93. data/lib/zaws/external/awscli/data/ec2/security_group.rb +51 -0
  94. data/lib/zaws/external/awscli/data/ec2/subnet.rb +59 -0
  95. data/lib/zaws/external/awscli/data/ec2/vpc.rb +85 -0
  96. data/lib/zaws/external/awscli/data/iam.rb +34 -0
  97. data/lib/zaws/external/awscli/data/iam/policy.rb +42 -0
  98. data/lib/zaws/external/awscli/data/iam/policy_document.rb +52 -0
  99. data/lib/zaws/external/awscli/data/iam/policy_version.rb +42 -0
  100. data/lib/zaws/external/awscli/data/iam/role_policy.rb +52 -0
  101. data/lib/zaws/external/awscli/generators/result/ec2/addresses.rb +70 -0
  102. data/lib/zaws/external/awscli/generators/result/ec2/allocation_id.rb +39 -0
  103. data/lib/zaws/external/awscli/generators/result/ec2/association_id.rb +29 -0
  104. data/lib/zaws/external/awscli/generators/result/ec2/images.rb +46 -0
  105. data/lib/zaws/external/awscli/generators/result/ec2/instances.rb +57 -0
  106. data/lib/zaws/external/awscli/generators/result/ec2/ip_permissions.rb +70 -0
  107. data/lib/zaws/external/awscli/generators/result/ec2/network_interfaces.rb +53 -0
  108. data/lib/zaws/external/awscli/generators/result/ec2/private_ip_addresses.rb +41 -0
  109. data/lib/zaws/external/awscli/generators/result/ec2/route_tables.rb +80 -0
  110. data/lib/zaws/external/awscli/generators/result/ec2/routes.rb +58 -0
  111. data/lib/zaws/external/awscli/generators/result/ec2/security_groups.rb +73 -0
  112. data/lib/zaws/external/awscli/generators/result/ec2/subnets.rb +88 -0
  113. data/lib/zaws/external/awscli/generators/result/ec2/tags.rb +34 -0
  114. data/lib/zaws/external/awscli/generators/result/ec2/virtual_gateway.rb +32 -0
  115. data/lib/zaws/external/awscli/generators/result/elb/listeners.rb +65 -0
  116. data/lib/zaws/external/awscli/generators/result/elb/load_balancers.rb +61 -0
  117. data/lib/zaws/external/awscli/generators/result/route53/hosted_zones.rb +52 -0
  118. data/lib/zaws/external/awscli/regions.rb +13 -0
  119. data/lib/zaws/external/nessusapi/data/agents.rb +36 -0
  120. data/lib/zaws/external/nessusapi/data/scanners.rb +35 -0
  121. data/lib/zaws/external/nessusapi/nessusapi.rb +57 -0
  122. data/lib/zaws/external/nessusapi/reources.rb +10 -0
  123. data/lib/zaws/external/nessusapi/resources/agents.rb +18 -0
  124. data/lib/zaws/external/nessusapi/resources/agents/list.rb +20 -0
  125. data/lib/zaws/external/nessusapi/resources/scanners.rb +18 -0
  126. data/lib/zaws/external/nessusapi/resources/scanners/list.rb +20 -0
  127. data/lib/zaws/external/newrelicapi/data/servers.rb +36 -0
  128. data/lib/zaws/external/newrelicapi/newrelic_client.rb +64 -0
  129. data/lib/zaws/external/newrelicapi/newrelic_creds.rb +60 -0
  130. data/lib/zaws/external/newrelicapi/newrelicapi.rb +46 -0
  131. data/lib/zaws/external/newrelicapi/resources/servers.rb +18 -0
  132. data/lib/zaws/external/newrelicapi/resources/servers/list.rb +20 -0
  133. data/lib/zaws/external/sumoapi/data/collectors.rb +35 -0
  134. data/lib/zaws/external/sumoapi/data/sources.rb +35 -0
  135. data/lib/zaws/external/sumoapi/resources/collectors.rb +18 -0
  136. data/lib/zaws/external/sumoapi/resources/collectors/list.rb +20 -0
  137. data/lib/zaws/external/sumoapi/resources/sources.rb +18 -0
  138. data/lib/zaws/external/sumoapi/resources/sources/list.rb +20 -0
  139. data/lib/zaws/external/sumoapi/sumo_client.rb +63 -0
  140. data/lib/zaws/external/sumoapi/sumo_creds.rb +67 -0
  141. data/lib/zaws/external/sumoapi/sumoapi.rb +56 -0
  142. data/lib/zaws/helper/data_lattice.rb +22 -0
  143. data/lib/zaws/helper/filestore.rb +48 -0
  144. data/lib/zaws/helper/filter.rb +15 -0
  145. data/lib/zaws/helper/inifile.rb +632 -0
  146. data/lib/zaws/helper/nessus_client.rb +143 -0
  147. data/lib/zaws/helper/nessus_creds.rb +67 -0
  148. data/lib/zaws/helper/option.rb +14 -15
  149. data/lib/zaws/helper/output.rb +81 -29
  150. data/lib/zaws/helper/process_hash.rb +47 -0
  151. data/lib/zaws/helper/shell.rb +0 -0
  152. data/lib/zaws/helper/verbose.rb +15 -0
  153. data/lib/zaws/helper/zfile.rb +8 -8
  154. data/lib/zaws/services/ai.rb +35 -0
  155. data/lib/zaws/services/ai/query.rb +135 -0
  156. data/lib/zaws/services/aws.rb +41 -0
  157. data/lib/zaws/services/chef.rb +0 -0
  158. data/lib/zaws/services/cloud_trail.rb +76 -0
  159. data/lib/zaws/services/config.rb +31 -0
  160. data/lib/zaws/services/ec2.rb +47 -0
  161. data/lib/zaws/services/ec2/compute.rb +352 -0
  162. data/lib/zaws/services/ec2/elasticip.rb +82 -0
  163. data/lib/zaws/services/ec2/route_table.rb +210 -0
  164. data/lib/zaws/services/ec2/security_group.rb +186 -0
  165. data/lib/zaws/services/ec2/subnet.rb +111 -0
  166. data/lib/zaws/services/ec2/vpc.rb +69 -0
  167. data/lib/zaws/{elb.rb → services/elb.rb} +3 -2
  168. data/lib/zaws/services/elb/load_balancer.rb +160 -0
  169. data/lib/zaws/services/iam.rb +25 -0
  170. data/lib/zaws/services/iam/policy.rb +25 -0
  171. data/lib/zaws/services/iam/role.rb +23 -0
  172. data/lib/zaws/services/nessus.rb +24 -0
  173. data/lib/zaws/services/nessus/agents.rb +19 -0
  174. data/lib/zaws/services/nessus/scanners.rb +19 -0
  175. data/lib/zaws/services/newrelic.rb +21 -0
  176. data/lib/zaws/services/newrelic/servers.rb +19 -0
  177. data/lib/zaws/{route53.rb → services/route53.rb} +1 -1
  178. data/lib/zaws/services/route53/hosted_zone.rb +36 -0
  179. data/lib/zaws/services/s3.rb +15 -0
  180. data/lib/zaws/services/s3/bucket.rb +42 -0
  181. data/lib/zaws/services/sumo.rb +21 -0
  182. data/lib/zaws/services/sumo/collectors.rb +19 -0
  183. data/lib/zaws/services/vmware.rb +0 -0
  184. data/lib/zaws/version.rb +1 -1
  185. data/shove_all.sh +6 -0
  186. data/shove_all_mac.sh +6 -0
  187. data/shove_all_windows.sh +6 -0
  188. data/spec/spec_helper.rb +0 -0
  189. data/spec/zaws/command/ec2/compute/assoc_security_group_spec.rb +135 -0
  190. data/spec/zaws/command/ec2/compute/compute_spec.rb +321 -0
  191. data/spec/zaws/command/ec2/compute/images_spec.rb +69 -0
  192. data/spec/zaws/command/ec2/compute/management_spec.rb +364 -0
  193. data/spec/zaws/command/ec2/compute/network_spec.rb +93 -0
  194. data/spec/zaws/command/ec2/compute/node_spec.rb +70 -0
  195. data/spec/zaws/command/ec2/compute/secondary_ip_spec.rb +212 -0
  196. data/spec/zaws/command/ec2/compute/storage_spec.rb +63 -0
  197. data/spec/zaws/command/ec2/elasticip_spec.rb +271 -0
  198. data/spec/zaws/command/ec2/route_table_spec.rb +844 -0
  199. data/spec/zaws/command/ec2/security_group_spec.rb +710 -0
  200. data/spec/zaws/command/ec2/subnet_spec.rb +273 -0
  201. data/spec/zaws/command/ec2/vpc_spec.rb +180 -0
  202. data/spec/zaws/command/elb/load_balancer_spec.rb +633 -0
  203. data/spec/zaws/command/iam/policy_spec.rb +101 -0
  204. data/spec/zaws/command/iam/role_policy_spec.rb +35 -0
  205. data/spec/zaws/command/route53/hosted_zone_spec.rb +100 -0
  206. data/spec/zaws/command/s3/bucket_spec.rb +70 -0
  207. data/spec/zaws/external/awscli/data/ec2/instance_spec.rb +90 -0
  208. data/spec/zaws/external/awscli/data/iam/policy_document_spec.rb +56 -0
  209. data/spec/zaws/external/awscli/data/iam/role_policy_spec.rb +54 -0
  210. data/spec/zaws/external/awscli/get_aws_version_spec.rb +18 -0
  211. data/spec/zaws/helper/option_spec.rb +54 -0
  212. data/spec/zaws/helper/output_spec.rb +144 -0
  213. data/spec/zaws/helper/process_hash_spec.rb +48 -0
  214. data/spec/zaws/helper/shell_spec.rb +56 -0
  215. data/spec/zaws/nessus/scanners.json +0 -0
  216. data/spec/zaws/version_spec.rb +18 -0
  217. data/zaws.gemspec +1 -3
  218. metadata +260 -189
  219. data/feature/compute/assoc_security_group.feature +0 -55
  220. data/feature/compute/compute.feature +0 -138
  221. data/feature/compute/secondary_ip.feature +0 -107
  222. data/feature/compute/view.feature +0 -23
  223. data/feature/compute/view_images.feature +0 -24
  224. data/feature/elasticip/elasticip.feature +0 -138
  225. data/feature/elasticip/view.feature +0 -18
  226. data/feature/hosted_zone/view.feature +0 -17
  227. data/feature/hosted_zone/view_record.feature +0 -29
  228. data/feature/load_balancer/instance_registration.feature +0 -120
  229. data/feature/load_balancer/listener.feature +0 -86
  230. data/feature/load_balancer/load_balancer.feature +0 -101
  231. data/feature/load_balancer/view.feature +0 -18
  232. data/feature/route_table/assoc_subnet.feature +0 -128
  233. data/feature/route_table/route_propagation.feature +0 -93
  234. data/feature/route_table/route_table.feature +0 -91
  235. data/feature/route_table/route_to_gateway.feature +0 -69
  236. data/feature/route_table/route_to_instance.feature +0 -115
  237. data/feature/route_table/view.feature +0 -25
  238. data/feature/security_group/ingress_cidr.feature +0 -144
  239. data/feature/security_group/ingress_group.feature +0 -184
  240. data/feature/security_group/security_group.feature +0 -107
  241. data/feature/security_group/view.feature +0 -23
  242. data/feature/subnet/subnet.feature +0 -94
  243. data/feature/subnet/view.feature +0 -24
  244. data/feature/support/env.rb +0 -14
  245. data/feature/version.feature +0 -6
  246. data/lib/zaws/aws.rb +0 -26
  247. data/lib/zaws/ec2.rb +0 -40
  248. data/lib/zaws/ec2/compute.rb +0 -247
  249. data/lib/zaws/ec2/elasticip.rb +0 -79
  250. data/lib/zaws/ec2/route_table.rb +0 -207
  251. data/lib/zaws/ec2/security_group.rb +0 -154
  252. data/lib/zaws/ec2/subnet.rb +0 -109
  253. data/lib/zaws/elb/load_balancer.rb +0 -157
  254. data/lib/zaws/route53/hosted_zone.rb +0 -36
  255. data/spec/zaws/ec2/compute/add_volume_spec.rb +0 -39
  256. data/spec/zaws/ec2/compute/block_device_mapping_spec.rb +0 -31
  257. data/spec/zaws/ec2/compute/instance_id_by_external_id_spec.rb +0 -23
  258. data/spec/zaws/ec2/compute/instance_ping_spec.rb +0 -34
  259. data/spec/zaws/ec2/compute/instance_running_spec.rb +0 -47
  260. data/spec/zaws/ec2/compute/network_interface_json_spec.rb +0 -57
  261. data/spec/zaws/ec2/compute/nosdcheck_spec.rb +0 -17
  262. data/spec/zaws/ec2/compute/tag_instance_spec.rb +0 -21
  263. data/spec/zaws/ec2/security_group/id_by_name_spec.rb +0 -32
  264. data/spec/zaws/ec2/subnet/available_spec.rb +0 -22
  265. data/spec/zaws/ec2/subnet/declare_spec.rb +0 -31
  266. data/spec/zaws/ec2/subnet/exists_spec.rb +0 -33
  267. data/spec/zaws/ec2/subnet/id_array_by_cidrblock_array_spec.rb +0 -48
  268. data/spec/zaws/ec2/subnet/id_by_cidrblock_spec.rb +0 -35
  269. data/spec/zaws/ec2/subnet/id_by_ip_spec.rb +0 -42
  270. data/spec/zaws/ec2/subnet/view_spec.rb +0 -34
  271. data/spec/zaws/elb/load_balancer/calculated_listener_spec.rb +0 -18
  272. data/spec/zaws/helper/option/absent_spec.rb +0 -14
  273. data/spec/zaws/helper/option/exclusive_spec.rb +0 -14
  274. data/spec/zaws/helper/option/exists_spec.rb +0 -18
  275. data/spec/zaws/helper/option/minimum_spec.rb +0 -14
  276. data/spec/zaws/helper/output/binary_nagios_check_spec.rb +0 -19
  277. data/spec/zaws/helper/output/colorize_spec.rb +0 -30
  278. data/spec/zaws/helper/output/opt_exclusive_spec.rb +0 -14
  279. data/spec/zaws/helper/output/opt_minimum_spec.rb +0 -15
  280. data/spec/zaws/helper/output/opt_required_spec.rb +0 -12
  281. data/spec/zaws/helper/shell/cli_spec.rb +0 -33
  282. data/spec/zaws/helper/shell/if_then_spec.rb +0 -24
@@ -0,0 +1,42 @@
1
+ require 'thor'
2
+
3
+ module ZAWS
4
+ module Command
5
+ class Config < Thor
6
+ class_option :verbose, :type => :boolean, :desc => "Verbose outout", :aliases => :d, :default => false
7
+
8
+ attr_accessor :config
9
+ attr_accessor :out
10
+ attr_accessor :print_exit_code
11
+
12
+ def initialize(*args)
13
+ super
14
+ shellout=ZAWS::Helper::Shell.new
15
+ nessusapi = ZAWS::Nessusapi.new(shellout)
16
+ sumoapi = ZAWS::Sumoapi.new(shellout)
17
+ newrelicapi = ZAWS::Newrelicapi.new(shellout)
18
+ awscli = ZAWS::AWSCLI.new(shellout)
19
+ @config = ZAWS::Controllers::Config.new(shellout, nessusapi,sumoapi,newrelicapi,awscli)
20
+ @out = $stdout
21
+ @print_exit_code = false
22
+ end
23
+
24
+ desc "remove_creds", "remove_creds"
25
+ option :home, :type => :string, :default => ENV['HOME'], :desc => 'Home directory location for credentials file'
26
+ def remove_creds
27
+ @config.awscli.home=options[:home]
28
+ @config.awscli.remove_creds()
29
+
30
+ @config.nessusapi.home=options[:home]
31
+ @config.nessusapi.remove_creds()
32
+
33
+ @config.sumoapi.home=options[:home]
34
+ @config.sumoapi.remove_creds()
35
+
36
+ @config.newrelicapi.home=options[:home]
37
+ @config.newrelicapi.remove_creds()
38
+ end
39
+
40
+ end
41
+ end
42
+ end
@@ -6,37 +6,47 @@ module ZAWS
6
6
  class_option :region, :type => :string, :desc => "AWS Region", :banner => "<region>", :aliases => :r, :required => true
7
7
  class_option :verbose, :type => :boolean, :desc => "Verbose outout", :aliases => :d, :default => false
8
8
 
9
+ attr_accessor :aws
10
+ attr_accessor :out
11
+ attr_accessor :print_exit_code
12
+
13
+ def initialize(*args)
14
+ super
15
+ shellout=ZAWS::Helper::Shell.new
16
+ awscli = ZAWS::AWSCLI.new(shellout)
17
+ @aws = ZAWS::AWS.new(shellout,awscli)
18
+ @out = $stdout
19
+ @print_exit_code = false
20
+ end
21
+
22
+
9
23
  desc "view","View elastic ips."
10
24
  option :viewtype, :type => :string, :desc => "View type, json or table", :banner => "<viewtype>", :aliases => :w, :default => "table"
11
25
  option :vpcid, :type => :string, :desc => "AWS VPC id", :banner => "<vpcid>", :aliases => :v, :default => nil
12
26
  def view
13
- aws=(ZAWS::AWS.new(ZAWS::Helper::Shell.new))
14
- aws.ec2.elasticip.view(options[:region],options[:viewtype],$stdout,(options[:verbose]?$stdout:nil),options[:vpcid])
27
+ @aws.ec2.elasticip.view(options[:region],options[:viewtype],@out,(options[:verbose]?@out:nil),options[:vpcid])
15
28
  end
16
29
 
17
30
  desc "assoc_exists EXTERNAL_ID","Determine by an instance's EXTERNAL_ID if it has an elastic."
18
31
  option :vpcid, :type => :string, :desc => "AWS VPC id", :banner => "<vpcid>", :aliases => :v, :default => nil
19
32
  def assoc_exists(externalid)
20
- aws=(ZAWS::AWS.new(ZAWS::Helper::Shell.new))
21
- val,instanceid,assoc,alloc,ip=aws.ec2.elasticip.assoc_exists(options[:region],externalid,$stdout,(options[:verbose]?$stdout:nil),options[:vpcid])
33
+ val,instanceid,assoc,alloc,ip=@aws.ec2.elasticip.assoc_exists(options[:region],externalid,@out,(options[:verbose]?@out:nil),options[:vpcid])
22
34
  return val
23
35
  end
24
36
 
25
37
  desc "declare EXTERNAL_ID","Declare an instance by its instance's EXTERNAL_ID should have an elastic ip."
26
38
  option :vpcid, :type => :string, :desc => "AWS VPC id", :banner => "<vpcid>", :aliases => :v, :default => nil
27
- option :nagios, :type => :boolean, :desc => "Returns a nagios check result", :aliases => :n, :default => false
39
+ option :check, :type => :boolean, :desc => "Returns a nagios check result", :aliases => :n, :default => false
28
40
  option :undofile, :type => :string, :desc => "File for undo commands", :banner => "<undofile>", :aliases => :f, :default => nil
29
41
  def declare(externalid)
30
- aws=(ZAWS::AWS.new(ZAWS::Helper::Shell.new))
31
- val=aws.ec2.elasticip.declare(options[:region],externalid,$stdout,(options[:verbose]?$stdout:nil),options[:vpcid],options[:nagios],options[:undofile])
42
+ val=@aws.ec2.elasticip.declare(options[:region],externalid,@out,(options[:verbose]?@out:nil),options[:vpcid],options[:check],options[:undofile])
32
43
  return val
33
44
  end
34
45
 
35
46
  desc "release EXTERNAL_ID","Release an elastic ip address a specific instance. The instance's EXTERNAL_ID is required."
36
47
  option :vpcid, :type => :string, :desc => "AWS VPC id", :banner => "<vpcid>", :aliases => :v, :default => nil
37
48
  def release(externalid)
38
- aws=(ZAWS::AWS.new(ZAWS::Helper::Shell.new))
39
- val=aws.ec2.elasticip.release(options[:region],externalid,$stdout,(options[:verbose]?$stdout:nil),options[:vpcid])
49
+ val=@aws.ec2.elasticip.release(options[:region],externalid,@out,(options[:verbose]?@out:nil),options[:vpcid])
40
50
  return val
41
51
  end
42
52
 
@@ -2,24 +2,37 @@ require 'thor'
2
2
 
3
3
  module ZAWS
4
4
  module Command
5
- class Hosted_Zone < Thor
6
- class_option :verbose, :type => :boolean, :desc => "Verbose outout", :aliases => :d, :default => false
7
-
8
- desc "view","View hosted zones."
9
- option :viewtype, :type => :string, :desc => "View type, json or table", :banner => "<viewtype>", :aliases => :w, :default => "table"
10
- def view
11
- aws=(ZAWS::AWS.new(ZAWS::Helper::Shell.new))
12
- aws.route53.hosted_zone.view(options[:viewtype],$stdout,(options[:verbose]?$stdout:nil))
13
- end
14
-
15
- desc "view_records ZONE_NAME","View record sets for hosted ZONE_NAME."
16
- option :viewtype, :type => :string, :desc => "View type, json or table", :banner => "<viewtype>", :aliases => :w, :default => "table"
17
- def view_records(zonename)
18
- aws=(ZAWS::AWS.new(ZAWS::Helper::Shell.new))
19
- aws.route53.hosted_zone.view_records(options[:viewtype],$stdout,(options[:verbose]?$stdout:nil),zonename)
20
- end
21
-
22
- end
5
+ class Hosted_Zone < Thor
6
+ class_option :verbose, :type => :boolean, :desc => "Verbose outout", :aliases => :d, :default => false
7
+
8
+ attr_accessor :aws
9
+ attr_accessor :out
10
+ attr_accessor :print_exit_code
11
+
12
+ def initialize(*args)
13
+ super
14
+ shellout=ZAWS::Helper::Shell.new
15
+ awscli = ZAWS::AWSCLI.new(shellout)
16
+ @aws = ZAWS::AWS.new(shellout, awscli)
17
+ @out = $stdout
18
+ @print_exit_code = false
19
+ end
20
+
21
+ desc "view", "View hosted zones."
22
+ option :viewtype, :type => :string, :desc => "View type, json or table", :banner => "<viewtype>", :aliases => :w, :default => "table"
23
+
24
+ def view
25
+ @aws.route53.hosted_zone.view(options[:viewtype], @out, (options[:verbose] ? @out : nil))
26
+ end
27
+
28
+ desc "view_records ZONE_NAME", "View record sets for hosted ZONE_NAME."
29
+ option :viewtype, :type => :string, :desc => "View type, json or table", :banner => "<viewtype>", :aliases => :w, :default => "table"
30
+
31
+ def view_records(zonename)
32
+ @aws.route53.hosted_zone.view_records(options[:viewtype], @out, (options[:verbose] ? @out : nil), zonename)
33
+ end
34
+
35
+ end
23
36
  end
24
37
  end
25
38
 
@@ -0,0 +1,37 @@
1
+ require 'thor'
2
+
3
+ module ZAWS
4
+ module Command
5
+ class IAM < Thor
6
+ class_option :verbose, :type => :boolean, :desc => "Verbose outout", :aliases => :d, :default => false
7
+
8
+ attr_accessor :aws
9
+ attr_accessor :out
10
+ attr_accessor :print_exit_code
11
+
12
+ def initialize(*args)
13
+ super
14
+ shellout=ZAWS::Helper::Shell.new
15
+ awscli = ZAWS::AWSCLI.new(shellout,false)
16
+ @aws = ZAWS::AWS.new(shellout,awscli)
17
+ @out = $stdout
18
+ @print_exit_code = false
19
+ end
20
+
21
+ desc "view_role_policy ROLE POLICY","View inline role policy."
22
+ option :viewtype, :type => :string, :desc => "View type, json or table", :banner => "<viewtype>", :aliases => :w, :default => "table"
23
+ def view_role_policy(role,policy)
24
+ @aws.iam.role.view_policy(role,policy,options[:viewtype],@out,options[:verbose]?@out:nil)
25
+ end
26
+
27
+ desc "view_default_policy_version POLICY_ARN","View default policy."
28
+ option :viewtype, :type => :string, :desc => "View type, json or table", :banner => "<viewtype>", :aliases => :w, :default => "table"
29
+ def view_default_policy_version(policy_arn)
30
+ @aws.iam.policy.view_default_policy_version(policy_arn,options[:viewtype],@out,options[:verbose]?@out:nil)
31
+ end
32
+
33
+ end
34
+ end
35
+ end
36
+
37
+
@@ -6,105 +6,108 @@ module ZAWS
6
6
  class_option :region, :type => :string, :desc => "AWS Region", :banner => "<region>", :aliases => :r, :required => true
7
7
  class_option :verbose, :type => :boolean, :desc => "Verbose outout", :aliases => :d, :default => false
8
8
 
9
+ attr_accessor :aws
10
+ attr_accessor :out
11
+ attr_accessor :print_exit_code
12
+
13
+ def initialize(*args)
14
+ super
15
+ shellout=ZAWS::Helper::Shell.new
16
+ awscli = ZAWS::AWSCLI.new(shellout)
17
+ @aws = ZAWS::AWS.new(shellout,awscli)
18
+ @out = $stdout
19
+ @print_exit_code = false
20
+ end
21
+
9
22
  desc "view","View load balancers."
10
23
  option :viewtype, :type => :string, :desc => "View type, json or table", :banner => "<viewtype>", :aliases => :w, :default => "table"
11
24
  def view
12
- aws=(ZAWS::AWS.new(ZAWS::Helper::Shell.new))
13
- aws.elb.load_balancer.view(options[:region],options[:viewtype],$stdout,(options[:verbose]?$stdout:nil))
25
+ @aws.elb.load_balancer.view(options[:region],options[:viewtype],@out,(options[:verbose]?@out:nil))
14
26
  end
15
27
 
16
28
  desc "exists LOAD_BALANCER_NAME","Determine if a load balancer exists by its LOAD_BALANCER_NAME"
17
29
  def exists(lbname)
18
- aws=(ZAWS::AWS.new(ZAWS::Helper::Shell.new))
19
- val,instances=aws.elb.load_balancer.exists(options[:region],lbname,$stdout,(options[:verbose]?$stdout:nil))
30
+ val,instances=@aws.elb.load_balancer.exists(options[:region],lbname,@out,(options[:verbose]?@out:nil))
20
31
  return val
21
32
  end
22
33
 
23
- desc "create_in_subnets","Create a new load balancer in the subnets specified by the option --cidrblocks."
34
+ desc "create_in_subnet LOAD_BALANCER_NAME LB_PROTOCOL LB_PORT IN_PROTOCOL IN_PORT SECURITY_GROUP","Create a new load balancer in the subnets specified by the option --cidrblocks."
24
35
  option :vpcid, :type => :string, :desc => "AWS VPC id", :banner => "<vpcid>", :aliases => :v, :default => nil
25
36
  option :cidrblocks,:type => :array, :desc => "subnet cidr blocks to attach to load balancer, one per avaialability zone.", :banner => "<cidrblocks>", :aliases => :u
26
- option :nagios, :type => :boolean, :desc => "Returns a nagios check result", :aliases => :n, :default => false
37
+ option :check, :type => :boolean, :desc => "Returns a check result", :aliases => :n, :default => false
27
38
  option :undofile, :type => :string, :desc => "File for undo commands", :banner => "<undofile>", :aliases => :f, :default => nil
28
39
  def create_in_subnet(lbname,lbprotocol,lbport,inprotocol,inport,securitygroup)
29
- aws=(ZAWS::AWS.new(ZAWS::Helper::Shell.new))
30
- exitcode = aws.elb.load_balancer.create_in_subnet(options[:region],lbname,lbprotocol,lbport,inprotocol,inport,securitygroup,options[:cidrblocks],options[:vpcid],options[:nagios],$stdout,(options[:verbose]?$stdout:nil),options[:undofile])
40
+ exitcode = @aws.elb.load_balancer.create_in_subnet(options[:region],lbname,lbprotocol,lbport,inprotocol,inport,securitygroup,options[:cidrblocks],options[:vpcid],options[:check],@out,(options[:verbose]?@out:nil),options[:undofile])
31
41
  exit exitcode
32
42
  end
33
43
 
34
44
  desc "delete LOAD_BALANCER_NAME","Delete load balancer identified by LOAD_BALANCER_NAME if it exists."
35
45
  def delete(lbname)
36
- aws=(ZAWS::AWS.new(ZAWS::Helper::Shell.new))
37
- aws.elb.load_balancer.delete(options[:region],lbname,$stdout,(options[:verbose]?$stdout:nil))
46
+ @aws.elb.load_balancer.delete(options[:region],lbname,@out,(options[:verbose]?@out:nil))
38
47
  end
39
48
 
40
49
  desc "exists_instance LOAD_BALANCER_NAME INSTANCE_EXTERNAL_ID","Determine if an instance identified by the INSTANCE_EXTERNAL_ID is registered with load balancer identified by LOAD_BALANCER_NAME."
41
50
  option :vpcid, :type => :string, :desc => "AWS VPC id", :banner => "<vpcid>", :aliases => :v, :default => nil
42
51
  def exists_instance(lbname,instance_external_id)
43
- $stdout.puts "DEBUG: options[:region]=#{options[:region]}" if options[:verbose]
44
- $stdout.puts "DEBUG: lbname=#{lbname}" if options[:verbose]
45
- $stdout.puts "DEBUG: instance_external_id=#{instance_external_id}" if options[:verbose]
46
- $stdout.puts "DEBUG: options[:vpcid]=#{options[:vpcid]}" if options[:verbose]
47
- aws=(ZAWS::AWS.new(ZAWS::Helper::Shell.new))
48
- aws.elb.load_balancer.exists_instance(options[:region],lbname,instance_external_id,options[:vpcid],$stdout,(options[:verbose]?$stdout:nil))
52
+ @out.puts "DEBUG: options[:region]=#{options[:region]}" if options[:verbose]
53
+ @out.puts "DEBUG: lbname=#{lbname}" if options[:verbose]
54
+ @out.puts "DEBUG: instance_external_id=#{instance_external_id}" if options[:verbose]
55
+ @out.puts "DEBUG: options[:vpcid]=#{options[:vpcid]}" if options[:verbose]
56
+ @aws.elb.load_balancer.exists_instance(options[:region],lbname,instance_external_id,options[:vpcid],@out,(options[:verbose]?@out:nil))
49
57
  end
50
58
 
51
59
  desc "register_instance LOAD_BALANCER_NAME INSTANCE_EXTERNAL_ID","Register an instance identified by the INSTANCE_EXTERNAL_ID is registered with load balancer identified by LOAD_BALANCER_NAME."
52
60
  option :vpcid, :type => :string, :desc => "AWS VPC id", :banner => "<vpcid>", :aliases => :v, :default => nil
53
- option :nagios, :type => :boolean, :desc => "Returns a nagios check result", :aliases => :n, :default => false
61
+ option :check, :type => :boolean, :desc => "Returns a check result", :aliases => :n, :default => false
54
62
  option :undofile, :type => :string, :desc => "File for undo commands", :banner => "<undofile>", :aliases => :f, :default => nil
55
63
  def register_instance(lbname,instance_external_id)
56
- $stdout.puts "DEBUG: options[:region]=#{options[:region]}" if options[:verbose]
57
- $stdout.puts "DEBUG: lbname=#{lbname}" if options[:verbose]
58
- $stdout.puts "DEBUG: instance_external_id=#{instance_external_id}" if options[:verbose]
59
- $stdout.puts "DEBUG: options[:vpcid]=#{options[:vpcid]}" if options[:verbose]
60
- aws=(ZAWS::AWS.new(ZAWS::Helper::Shell.new))
61
- aws.elb.load_balancer.register_instance(options[:region],lbname,instance_external_id,options[:vpcid],options[:nagios],$stdout,(options[:verbose]?$stdout:nil),options[:undofile])
64
+ @out.puts "DEBUG: options[:region]=#{options[:region]}" if options[:verbose]
65
+ @out.puts "DEBUG: lbname=#{lbname}" if options[:verbose]
66
+ @out.puts "DEBUG: instance_external_id=#{instance_external_id}" if options[:verbose]
67
+ @out.puts "DEBUG: options[:vpcid]=#{options[:vpcid]}" if options[:verbose]
68
+ @aws.elb.load_balancer.register_instance(options[:region],lbname,instance_external_id,options[:vpcid],options[:check],@out,(options[:verbose]?@out:nil),options[:undofile])
62
69
  end
63
70
 
64
71
  desc "deregister_instance LOAD_BALANCER_NAME INSTANCE_EXTERNAL_ID","Deregister an instance identified by the INSTANCE_EXTERNAL_ID is registered with load balancer identified by LOAD_BALANCER_NAME."
65
72
  option :vpcid, :type => :string, :desc => "AWS VPC id", :banner => "<vpcid>", :aliases => :v, :default => nil
66
73
  def deregister_instance(lbname,instance_external_id)
67
- $stdout.puts "DEBUG: options[:region]=#{options[:region]}" if options[:verbose]
68
- $stdout.puts "DEBUG: lbname=#{lbname}" if options[:verbose]
69
- $stdout.puts "DEBUG: instance_external_id=#{instance_external_id}" if options[:verbose]
70
- $stdout.puts "DEBUG: options[:vpcid]=#{options[:vpcid]}" if options[:verbose]
71
- aws=(ZAWS::AWS.new(ZAWS::Helper::Shell.new))
72
- aws.elb.load_balancer.deregister_instance(options[:region],lbname,instance_external_id,options[:vpcid],$stdout,(options[:verbose]?$stdout:nil))
74
+ @out.puts "DEBUG: options[:region]=#{options[:region]}" if options[:verbose]
75
+ @out.puts "DEBUG: lbname=#{lbname}" if options[:verbose]
76
+ @out.puts "DEBUG: instance_external_id=#{instance_external_id}" if options[:verbose]
77
+ @out.puts "DEBUG: options[:vpcid]=#{options[:vpcid]}" if options[:verbose]
78
+ @aws.elb.load_balancer.deregister_instance(options[:region],lbname,instance_external_id,options[:vpcid],@out,(options[:verbose]?@out:nil))
73
79
  end
74
80
 
75
81
  desc "exists_listener LOAD_BALANCER_NAME LBPROTOCOL LBPORT INPROTOCOL INPORT","Determine if a listener is registered with load balancer."
76
82
  def exists_listener(lbname,lbprotocol,lbport,inprotocol,inport)
77
- $stdout.puts "DEBUG: lbname=#{lbname}" if options[:verbose]
78
- $stdout.puts "DEBUG: lbprotocol=#{lbprotocol}" if options[:verbose]
79
- $stdout.puts "DEBUG: lbport=#{lbport}" if options[:verbose]
80
- $stdout.puts "DEBUG: inprotocol=#{inprotocol}" if options[:verbose]
81
- $stdout.puts "DEBUG: inport=#{inport}" if options[:verbose]
82
- aws=(ZAWS::AWS.new(ZAWS::Helper::Shell.new))
83
- aws.elb.load_balancer.exists_listener(options[:region],lbname,lbprotocol,lbport,inprotocol,inport,$stdout,(options[:verbose]?$stdout:nil))
83
+ @out.puts "DEBUG: lbname=#{lbname}" if options[:verbose]
84
+ @out.puts "DEBUG: lbprotocol=#{lbprotocol}" if options[:verbose]
85
+ @out.puts "DEBUG: lbport=#{lbport}" if options[:verbose]
86
+ @out.puts "DEBUG: inprotocol=#{inprotocol}" if options[:verbose]
87
+ @out.puts "DEBUG: inport=#{inport}" if options[:verbose]
88
+ @aws.elb.load_balancer.exists_listener(options[:region],lbname,lbprotocol,lbport,inprotocol,inport,@out,(options[:verbose]?@out:nil))
84
89
  end
85
90
 
86
91
  desc "declare_listener LOAD_BALANCER_NAME LBPROTOCOL LBPORT INPROTOCOL INPORT","Create a new listener."
87
- option :nagios, :type => :boolean, :desc => "Returns a nagios check result", :aliases => :n, :default => false
92
+ option :check, :type => :boolean, :desc => "Returns a check result", :aliases => :n, :default => false
88
93
  option :undofile, :type => :string, :desc => "File for undo commands", :banner => "<undofile>", :aliases => :f, :default => nil
89
94
  def declare_listener(lbname,lbprotocol,lbport,inprotocol,inport)
90
- $stdout.puts "DEBUG: lbname=#{lbname}" if options[:verbose]
91
- $stdout.puts "DEBUG: lbprotocol=#{lbprotocol}" if options[:verbose]
92
- $stdout.puts "DEBUG: lbport=#{lbport}" if options[:verbose]
93
- $stdout.puts "DEBUG: inprotocol=#{inprotocol}" if options[:verbose]
94
- $stdout.puts "DEBUG: inport=#{inport}" if options[:verbose]
95
- aws=(ZAWS::AWS.new(ZAWS::Helper::Shell.new))
96
- aws.elb.load_balancer.declare_listener(options[:region],lbname,lbprotocol,lbport,inprotocol,inport,options[:nagios],$stdout,(options[:verbose]?$stdout:nil),options[:undofile])
95
+ @out.puts "DEBUG: lbname=#{lbname}" if options[:verbose]
96
+ @out.puts "DEBUG: lbprotocol=#{lbprotocol}" if options[:verbose]
97
+ @out.puts "DEBUG: lbport=#{lbport}" if options[:verbose]
98
+ @out.puts "DEBUG: inprotocol=#{inprotocol}" if options[:verbose]
99
+ @out.puts "DEBUG: inport=#{inport}" if options[:verbose]
100
+ @aws.elb.load_balancer.declare_listener(options[:region],lbname,lbprotocol,lbport,inprotocol,inport,options[:check],@out,(options[:verbose]?@out:nil),options[:undofile])
97
101
  end
98
102
 
99
103
  desc "delete_listener LOAD_BALANCER_NAME LBPROTOCOL LBPORT INPROTOCOL INPORT","Delete listener."
100
104
  def delete_listener(lbname,lbprotocol,lbport,inprotocol,inport)
101
- $stdout.puts "DEBUG: lbname=#{lbname}" if options[:verbose]
102
- $stdout.puts "DEBUG: lbprotocol=#{lbprotocol}" if options[:verbose]
103
- $stdout.puts "DEBUG: lbport=#{lbport}" if options[:verbose]
104
- $stdout.puts "DEBUG: inprotocol=#{inprotocol}" if options[:verbose]
105
- $stdout.puts "DEBUG: inport=#{inport}" if options[:verbose]
106
- aws=(ZAWS::AWS.new(ZAWS::Helper::Shell.new))
107
- aws.elb.load_balancer.delete_listener(options[:region],lbname,lbprotocol,lbport,inprotocol,inport,$stdout,(options[:verbose]?$stdout:nil))
105
+ @out.puts "DEBUG: lbname=#{lbname}" if options[:verbose]
106
+ @out.puts "DEBUG: lbprotocol=#{lbprotocol}" if options[:verbose]
107
+ @out.puts "DEBUG: lbport=#{lbport}" if options[:verbose]
108
+ @out.puts "DEBUG: inprotocol=#{inprotocol}" if options[:verbose]
109
+ @out.puts "DEBUG: inport=#{inport}" if options[:verbose]
110
+ @aws.elb.load_balancer.delete_listener(options[:region],lbname,lbprotocol,lbport,inprotocol,inport,@out,(options[:verbose]?@out:nil))
108
111
  end
109
112
 
110
113
  end
@@ -0,0 +1,41 @@
1
+ require 'thor'
2
+
3
+ module ZAWS
4
+ module Command
5
+ class Nessus < Thor
6
+ class_option :verbose, :type => :boolean, :desc => "Verbose outout", :aliases => :d, :default => false
7
+ class_option :home, :type => :string, :default => ENV['HOME'], :desc => 'Home directory location for credentials file'
8
+ class_option :viewtype, :type => :string, :desc => "View type, json or table", :banner => "<viewtype>", :aliases => :w, :default => "table"
9
+
10
+ attr_accessor :nessus
11
+ attr_accessor :out
12
+ attr_accessor :print_exit_code
13
+
14
+ def initialize(*args)
15
+ super
16
+ shellout=ZAWS::Helper::Shell.new
17
+ nessusapi = ZAWS::Nessusapi.new(shellout)
18
+ @nessus = ZAWS::Controllers::Nessus.new(shellout, nessusapi)
19
+ @out = $stdout
20
+ @print_exit_code = false
21
+ @params= {
22
+ 'home' => options[:home]
23
+ }
24
+ end
25
+
26
+ desc "view_scanners", "View scanners."
27
+ def view_scanners
28
+ @out.puts(@nessus.scanners.view(@params));
29
+ end
30
+
31
+ desc "view_agents", "View agents."
32
+ option :scanner, :type => :string, :default => '1', :desc => 'scanner id'
33
+ def view_agents
34
+ @params['scanner']=options[:scanner]
35
+ @out.puts(@nessus.agents.view(params));
36
+ end
37
+ end
38
+ end
39
+ end
40
+
41
+
@@ -0,0 +1,30 @@
1
+ require 'thor'
2
+
3
+ module ZAWS
4
+ module Command
5
+ class Newrelic < Thor
6
+ class_option :verbose, :type => :boolean, :desc => "Verbose outout", :aliases => :d, :default => false
7
+
8
+ attr_accessor :newrelic
9
+ attr_accessor :out
10
+ attr_accessor :print_exit_code
11
+
12
+ def initialize(*args)
13
+ super
14
+ shellout=ZAWS::Helper::Shell.new
15
+ newrelicapi = ZAWS::Newrelicapi.new(shellout)
16
+ @newrelic = ZAWS::Controllers::Newrelic.new(shellout, newrelicapi)
17
+ @out = $stdout
18
+ @print_exit_code = false
19
+ end
20
+
21
+ desc "view_servers", "View Servers."
22
+ option :home, :type => :string, :default => ENV['HOME'], :desc => 'Home directory location for credentials file'
23
+ def view_servers
24
+ @newrelic.servers.view(options[:home], @out, (options[:verbose] ? @out : nil))
25
+ end
26
+
27
+ end
28
+ end
29
+ end
30
+
@@ -2,131 +2,144 @@ require 'thor'
2
2
 
3
3
  module ZAWS
4
4
  module Command
5
- class Route_Table < Thor
6
- class_option :region, :type => :string, :desc => "AWS Region", :banner => "<region>", :aliases => :r, :required => true
7
- class_option :verbose, :type => :boolean, :desc => "Verbose outout", :aliases => :d, :default => false
8
-
9
- desc "view","View route tables."
10
- option :viewtype, :type => :string, :desc => "View type, json or table", :banner => "<viewtype>", :aliases => :w, :default => "table"
11
- option :vpcid, :type => :string, :desc => "AWS VPC id", :banner => "<vpcid>", :aliases => :v, :default => nil
12
- def view
13
- aws=(ZAWS::AWS.new(ZAWS::Helper::Shell.new))
14
- aws.ec2.route_table.view(options[:region],options[:viewtype],$stdout,(options[:verbose]?$stdout:nil),options[:vpcid])
15
- end
16
-
17
- desc "exists_by_external_id EXTERNAL_ID","Determine if a route table exists by EXTERNAL_ID."
18
- option :vpcid, :type => :string, :desc => "AWS VPC id", :banner => "<vpcid>", :aliases => :v, :default => nil
19
- def exists_by_external_id(externalid)
20
- aws=(ZAWS::AWS.new(ZAWS::Helper::Shell.new))
21
- aws.ec2.route_table.exists(options[:region],$stdout,(options[:verbose]?$stdout:nil),options[:vpcid],externalid)
22
- end
23
-
24
- desc "declare EXTERNAL_ID VPCID","Declare a new route table by EXTERNAL_ID in VPCID, but skip creating it if it exists."
25
- option :nagios, :type => :boolean, :desc => "Returns a nagios check result", :aliases => :n, :default => false
26
- option :undofile, :type => :string, :desc => "File for undo commands", :banner => "<undofile>", :aliases => :f, :default => nil
27
- def declare(externalid,vpcid)
28
- aws=(ZAWS::AWS.new(ZAWS::Helper::Shell.new))
29
- exitcode = aws.ec2.route_table.declare(options[:region],vpcid,externalid,options[:nagios],$stdout,(options[:verbose]?$stdout:nil),options[:undofile])
5
+ class Route_Table < Thor
6
+ class_option :region, :type => :string, :desc => "AWS Region", :banner => "<region>", :aliases => :r, :required => true
7
+ class_option :verbose, :type => :boolean, :desc => "Verbose outout", :aliases => :d, :default => false
8
+
9
+ attr_accessor :aws
10
+ attr_accessor :out
11
+ attr_accessor :print_exit_code
12
+
13
+ def initialize(*args)
14
+ super
15
+ shellout=ZAWS::Helper::Shell.new
16
+ awscli = ZAWS::AWSCLI.new(shellout)
17
+ @aws = ZAWS::AWS.new(shellout, awscli)
18
+ @out = $stdout
19
+ @print_exit_code = false
20
+ end
21
+
22
+ desc "view", "View route tables."
23
+ option :viewtype, :type => :string, :desc => "View type, json or table", :banner => "<viewtype>", :aliases => :w, :default => "table"
24
+ option :vpcid, :type => :string, :desc => "AWS VPC id", :banner => "<vpcid>", :aliases => :v, :default => nil
25
+
26
+ def view
27
+ @out.puts(@aws.ec2.route_table.view(options[:region], options[:viewtype], @out, (options[:verbose] ? @out : nil), options[:vpcid]))
28
+ end
29
+
30
+ desc "exists_by_external_id EXTERNAL_ID", "Determine if a route table exists by EXTERNAL_ID."
31
+ option :vpcid, :type => :string, :desc => "AWS VPC id", :banner => "<vpcid>", :aliases => :v, :default => nil
32
+
33
+ def exists_by_external_id(externalid)
34
+ @aws.ec2.route_table.exists(options[:region], @out, (options[:verbose] ? @out : nil), options[:vpcid], externalid)
35
+ end
36
+
37
+ desc "declare EXTERNAL_ID VPCID", "Declare a new route table by EXTERNAL_ID in VPCID, but skip creating it if it exists."
38
+ option :check, :type => :boolean, :desc => "Returns a check result", :aliases => :n, :default => false
39
+ option :undofile, :type => :string, :desc => "File for undo commands", :banner => "<undofile>", :aliases => :f, :default => nil
40
+
41
+ def declare(externalid, vpcid)
42
+ exitcode = @aws.ec2.route_table.declare(options[:region], vpcid, externalid, options[:check], @out, (options[:verbose] ? @out : nil), options[:undofile])
30
43
  exit exitcode
31
- end
32
-
33
- desc "delete EXTERNAL_ID","Delete route table by its EXTERNAL_ID."
34
- option :vpcid, :type => :string, :desc => "AWS VPC id", :banner => "<vpcid>", :aliases => :v, :default => nil
35
- def delete(externalid)
36
- aws=(ZAWS::AWS.new(ZAWS::Helper::Shell.new))
37
- aws.ec2.route_table.delete(options[:region],$stdout,(options[:verbose]?$stdout:nil),options[:vpcid],externalid)
38
- end
39
-
40
- desc "route_exists_by_instance ROUTE_TABLE CIDR_BLOCK INSTANCE_EXTERNAL_ID","Determine if a route exists for CIDR_BLOCK in ROUTE_TABLE to an instance INSTANCE_EXTERNAL_ID."
41
- option :vpcid, :type => :string, :desc => "AWS VPC id", :banner => "<vpcid>", :aliases => :v, :default => nil
42
- def route_exists_by_instance(routetable,cidrblock,externalid)
43
- aws=(ZAWS::AWS.new(ZAWS::Helper::Shell.new))
44
- aws.ec2.route_table.route_exists_by_instance(options[:region],$stdout,(options[:verbose]?$stdout:nil),options[:vpcid],routetable,cidrblock,externalid)
45
- end
46
-
47
- desc "declare_route ROUTE_TABLE CIDR_BLOCK INSTANCE_EXTERNAL_ID","Declare a new route to instance INSTANCE_EXTERNAL_ID for CIDR_BLOCK in ROUTE_TABLE, but skip creating it if it exists."
48
- option :vpcid, :type => :string, :desc => "AWS VPC id", :banner => "<vpcid>", :aliases => :v, :default => nil
49
- option :nagios, :type => :boolean, :desc => "Returns a nagios check result", :aliases => :n, :default => false
50
- option :undofile, :type => :string, :desc => "File for undo commands", :banner => "<undofile>", :aliases => :f, :default => nil
51
- def declare_route(routetable,cidrblock,externalid)
52
- aws=(ZAWS::AWS.new(ZAWS::Helper::Shell.new))
53
- exitcode = aws.ec2.route_table.declare_route(options[:region],$stdout,(options[:verbose]?$stdout:nil),options[:vpcid],routetable,cidrblock,externalid,options[:nagios],options[:undofile])
44
+ end
45
+
46
+ desc "delete EXTERNAL_ID", "Delete route table by its EXTERNAL_ID."
47
+ option :vpcid, :type => :string, :desc => "AWS VPC id", :banner => "<vpcid>", :aliases => :v, :default => nil
48
+
49
+ def delete(externalid)
50
+ @aws.ec2.route_table.delete(options[:region], @out, (options[:verbose] ? @out : nil), options[:vpcid], externalid)
51
+ end
52
+
53
+ desc "route_exists_by_instance ROUTE_TABLE CIDR_BLOCK INSTANCE_EXTERNAL_ID", "Determine if a route exists for CIDR_BLOCK in ROUTE_TABLE to an instance INSTANCE_EXTERNAL_ID."
54
+ option :vpcid, :type => :string, :desc => "AWS VPC id", :banner => "<vpcid>", :aliases => :v, :default => nil
55
+
56
+ def route_exists_by_instance(routetable, cidrblock, externalid)
57
+ @aws.ec2.route_table.route_exists_by_instance(options[:region], @out, (options[:verbose] ? @out : nil), options[:vpcid], routetable, cidrblock, externalid)
58
+ end
59
+
60
+ desc "declare_route ROUTE_TABLE CIDR_BLOCK INSTANCE_EXTERNAL_ID", "Declare a new route to instance INSTANCE_EXTERNAL_ID for CIDR_BLOCK in ROUTE_TABLE, but skip creating it if it exists."
61
+ option :vpcid, :type => :string, :desc => "AWS VPC id", :banner => "<vpcid>", :aliases => :v, :default => nil
62
+ option :check, :type => :boolean, :desc => "Returns a check result", :aliases => :n, :default => false
63
+ option :undofile, :type => :string, :desc => "File for undo commands", :banner => "<undofile>", :aliases => :f, :default => nil
64
+
65
+ def declare_route(routetable, cidrblock, externalid)
66
+ exitcode = @aws.ec2.route_table.declare_route(options[:region], @out, (options[:verbose] ? @out : nil), options[:vpcid], routetable, cidrblock, externalid, options[:check], options[:undofile])
54
67
  exit exitcode
55
- end
56
-
57
- desc "delete_route ROUTE_TABLE CIDR_BLOCK","Delete a route to CIDR_BLOCK in ROUTE_TABLE, but skip deletion if it doesn't exist."
58
- option :vpcid, :type => :string, :desc => "AWS VPC id", :banner => "<vpcid>", :aliases => :v, :default => nil
59
- def delete_route(routetable,cidrblock)
60
- aws=(ZAWS::AWS.new(ZAWS::Helper::Shell.new))
61
- aws.ec2.route_table.delete_route(options[:region],$stdout,(options[:verbose]?$stdout:nil),options[:vpcid],routetable,cidrblock)
62
- end
63
-
64
- desc "route_exists_by_gatewayid ROUTE_TABLE CIDR_BLOCK GATEWAY_ID","Determine if a route exists for CIDR_BLOCK in ROUTE_TABLE to GATEWAY_ID."
65
- option :vpcid, :type => :string, :desc => "AWS VPC id", :banner => "<vpcid>", :aliases => :v, :default => nil
66
- def route_exists_by_gatewayid(routetable,cidrblock,gatewayid)
67
- aws=(ZAWS::AWS.new(ZAWS::Helper::Shell.new))
68
- aws.ec2.route_table.route_exists_by_gatewayid(options[:region],$stdout,(options[:verbose]?$stdout:nil),options[:vpcid],routetable,cidrblock,gatewayid)
69
- end
70
-
71
- desc "declare_route_to_gateway ROUTE_TABLE CIDR_BLOCK GATEWAY_ID","Declare a new route to GATEWAY_ID, but skip creating it if it exists."
72
- option :vpcid, :type => :string, :desc => "AWS VPC id", :banner => "<vpcid>", :aliases => :v, :default => nil
73
- option :nagios, :type => :boolean, :desc => "Returns a nagios check result", :aliases => :n, :default => false
74
- option :undofile, :type => :string, :desc => "File for undo commands", :banner => "<undofile>", :aliases => :f, :default => nil
75
- def declare_route_to_gateway(routetable,cidrblock,gatewayid)
76
- aws=(ZAWS::AWS.new(ZAWS::Helper::Shell.new))
77
- exitcode = aws.ec2.route_table.declare_route_to_gateway(options[:region],$stdout,(options[:verbose]?$stdout:nil),options[:vpcid],routetable,cidrblock,gatewayid,options[:nagios],options[:undofile])
68
+ end
69
+
70
+ desc "delete_route ROUTE_TABLE CIDR_BLOCK", "Delete a route to CIDR_BLOCK in ROUTE_TABLE, but skip deletion if it doesn't exist."
71
+ option :vpcid, :type => :string, :desc => "AWS VPC id", :banner => "<vpcid>", :aliases => :v, :default => nil
72
+
73
+ def delete_route(routetable, cidrblock)
74
+ @aws.ec2.route_table.delete_route(options[:region], @out, (options[:verbose] ? @out : nil), options[:vpcid], routetable, cidrblock)
75
+ end
76
+
77
+ desc "route_exists_by_gatewayid ROUTE_TABLE CIDR_BLOCK GATEWAY_ID", "Determine if a route exists for CIDR_BLOCK in ROUTE_TABLE to GATEWAY_ID."
78
+ option :vpcid, :type => :string, :desc => "AWS VPC id", :banner => "<vpcid>", :aliases => :v, :default => nil
79
+
80
+ def route_exists_by_gatewayid(routetable, cidrblock, gatewayid)
81
+ @aws.ec2.route_table.route_exists_by_gatewayid(options[:region], @out, (options[:verbose] ? @out : nil), options[:vpcid], routetable, cidrblock, gatewayid)
82
+ end
83
+
84
+ desc "declare_route_to_gateway ROUTE_TABLE CIDR_BLOCK GATEWAY_ID", "Declare a new route to GATEWAY_ID, but skip creating it if it exists."
85
+ option :vpcid, :type => :string, :desc => "AWS VPC id", :banner => "<vpcid>", :aliases => :v, :default => nil
86
+ option :check, :type => :boolean, :desc => "Returns a check result", :aliases => :n, :default => false
87
+ option :undofile, :type => :string, :desc => "File for undo commands", :banner => "<undofile>", :aliases => :f, :default => nil
88
+
89
+ def declare_route_to_gateway(routetable, cidrblock, gatewayid)
90
+ exitcode = @aws.ec2.route_table.declare_route_to_gateway(options[:region], @out, (options[:verbose] ? @out : nil), options[:vpcid], routetable, cidrblock, gatewayid, options[:check], options[:undofile])
78
91
  exit exitcode
79
- end
80
-
81
- desc "subnet_assoc_exists ROUTE_TABLE_EXTERNAL_ID CIDRBLOCK","Determine if a route table is associated to a subnet."
82
- option :vpcid, :type => :string, :desc => "AWS VPC id", :banner => "<vpcid>", :aliases => :v, :default => nil
83
- def subnet_assoc_exists(rtable_externalid,cidrblock)
84
- aws=(ZAWS::AWS.new(ZAWS::Helper::Shell.new))
85
- aws.ec2.route_table.subnet_assoc_exists(options[:region],$stdout,(options[:verbose]?$stdout:nil),options[:vpcid],rtable_externalid,cidrblock)
86
- end
87
-
88
- desc "assoc_subnet ROUTE_TABLE_EXTERNAL_ID CIDRBLOCK","Associate a route table to a subnet."
89
- option :vpcid, :type => :string, :desc => "AWS VPC id", :banner => "<vpcid>", :aliases => :v, :default => nil
90
- option :nagios, :type => :boolean, :desc => "Returns a nagios check result", :aliases => :n, :default => false
91
- option :undofile, :type => :string, :desc => "File for undo commands", :banner => "<undofile>", :aliases => :f, :default => nil
92
- def assoc_subnet(rtable_externalid,cidrblock)
93
- aws=(ZAWS::AWS.new(ZAWS::Helper::Shell.new))
94
- exitcode = aws.ec2.route_table.assoc_subnet(options[:region],$stdout,(options[:verbose]?$stdout:nil),options[:vpcid],rtable_externalid,cidrblock,options[:nagios],options[:undofile])
95
- exit exitcode
96
- end
97
-
98
- desc "delete_assoc_subnet ROUTE_TABLE_EXTERNAL_ID CIDRBLOCK","Delete association of route table to subnet."
99
- option :vpcid, :type => :string, :desc => "AWS VPC id", :banner => "<vpcid>", :aliases => :v, :default => nil
100
- def delete_assoc_subnet(rtable_externalid,cidrblock)
101
- aws=(ZAWS::AWS.new(ZAWS::Helper::Shell.new))
102
- aws.ec2.route_table.delete_assoc_subnet(options[:region],$stdout,(options[:verbose]?$stdout:nil),options[:vpcid],rtable_externalid,cidrblock)
103
- end
104
-
105
- desc "propagation_exists_from_gateway ROUTE_TABLE_EXTERNAL_ID VIRTUAL_GATEWAY_ID","Determine if route propagation from a gateway exists."
106
- option :vpcid, :type => :string, :desc => "AWS VPC id", :banner => "<vpcid>", :aliases => :v, :default => nil
107
- def propagation_exists_from_gateway(rtable_externalid,vgatewayid)
108
- aws=(ZAWS::AWS.new(ZAWS::Helper::Shell.new))
109
- aws.ec2.route_table.propagation_exists_from_gateway(options[:region],$stdout,(options[:verbose]?$stdout:nil),options[:vpcid],rtable_externalid,vgatewayid)
110
- end
111
-
112
- desc "declare_propagation_from_gateway ROUTE_TABLE_EXTERNAL_ID VIRTUAL_GATEWAY_ID","Propagate routes to the routing tables from a virtual gateway."
113
- option :vpcid, :type => :string, :desc => "AWS VPC id", :banner => "<vpcid>", :aliases => :v, :default => nil
114
- option :nagios, :type => :boolean, :desc => "Returns a nagios check result", :aliases => :n, :default => false
115
- option :undofile, :type => :string, :desc => "File for undo commands", :banner => "<undofile>", :aliases => :f, :default => nil
116
- def declare_propagation_from_gateway(rtable_externalid,vgatewayid)
117
- aws=(ZAWS::AWS.new(ZAWS::Helper::Shell.new))
118
- exitcode = aws.ec2.route_table.declare_propagation_from_gateway(options[:region],$stdout,(options[:verbose]?$stdout:nil),options[:vpcid],rtable_externalid,vgatewayid,options[:nagios],options[:undofile])
119
- exit exitcode
120
- end
121
-
122
- desc "delete_propagation_from_gateway ROUTE_TABLE_EXTERNAL_ID GATEWAY_ID","Delete route propagation from virtual gateway."
123
- option :vpcid, :type => :string, :desc => "AWS VPC id", :banner => "<vpcid>", :aliases => :v, :default => nil
124
- def delete_propagation_from_gateway(rtable_externalid,vgatewayid)
125
- aws=(ZAWS::AWS.new(ZAWS::Helper::Shell.new))
126
- aws.ec2.route_table.delete_propagation_from_gateway(options[:region],$stdout,(options[:verbose]?$stdout:nil),options[:vpcid],rtable_externalid,vgatewayid)
127
- end
128
-
129
- end
92
+ end
93
+
94
+ desc "subnet_assoc_exists ROUTE_TABLE_EXTERNAL_ID CIDRBLOCK", "Determine if a route table is associated to a subnet."
95
+ option :vpcid, :type => :string, :desc => "AWS VPC id", :banner => "<vpcid>", :aliases => :v, :default => nil
96
+
97
+ def subnet_assoc_exists(rtable_externalid, cidrblock)
98
+ @aws.ec2.route_table.subnet_assoc_exists(options[:region], @out, (options[:verbose] ? @out : nil), options[:vpcid], rtable_externalid, cidrblock)
99
+ end
100
+
101
+ desc "assoc_subnet ROUTE_TABLE_EXTERNAL_ID CIDRBLOCK", "Associate a route table to a subnet."
102
+ option :vpcid, :type => :string, :desc => "AWS VPC id", :banner => "<vpcid>", :aliases => :v, :default => nil
103
+ option :check, :type => :boolean, :desc => "Returns a check result", :aliases => :n, :default => false
104
+ option :undofile, :type => :string, :desc => "File for undo commands", :banner => "<undofile>", :aliases => :f, :default => nil
105
+
106
+ def assoc_subnet(rtable_externalid, cidrblock)
107
+ exitcode = @aws.ec2.route_table.assoc_subnet(options[:region], @out, (options[:verbose] ? @out : nil), options[:vpcid], rtable_externalid, cidrblock, options[:check], options[:undofile])
108
+ exit exitcode
109
+ end
110
+
111
+ desc "delete_assoc_subnet ROUTE_TABLE_EXTERNAL_ID CIDRBLOCK", "Delete association of route table to subnet."
112
+ option :vpcid, :type => :string, :desc => "AWS VPC id", :banner => "<vpcid>", :aliases => :v, :default => nil
113
+
114
+ def delete_assoc_subnet(rtable_externalid, cidrblock)
115
+ @aws.ec2.route_table.delete_assoc_subnet(options[:region], @out, (options[:verbose] ? @out : nil), options[:vpcid], rtable_externalid, cidrblock)
116
+ end
117
+
118
+ desc "propagation_exists_from_gateway ROUTE_TABLE_EXTERNAL_ID VIRTUAL_GATEWAY_ID", "Determine if route propagation from a gateway exists."
119
+ option :vpcid, :type => :string, :desc => "AWS VPC id", :banner => "<vpcid>", :aliases => :v, :default => nil
120
+
121
+ def propagation_exists_from_gateway(rtable_externalid, vgatewayid)
122
+ @aws.ec2.route_table.propagation_exists_from_gateway(options[:region], @out, (options[:verbose] ? @out : nil), options[:vpcid], rtable_externalid, vgatewayid)
123
+ end
124
+
125
+ desc "declare_propagation_from_gateway ROUTE_TABLE_EXTERNAL_ID VIRTUAL_GATEWAY_ID", "Propagate routes to the routing tables from a virtual gateway."
126
+ option :vpcid, :type => :string, :desc => "AWS VPC id", :banner => "<vpcid>", :aliases => :v, :default => nil
127
+ option :check, :type => :boolean, :desc => "Returns a check result", :aliases => :n, :default => false
128
+ option :undofile, :type => :string, :desc => "File for undo commands", :banner => "<undofile>", :aliases => :f, :default => nil
129
+
130
+ def declare_propagation_from_gateway(rtable_externalid, vgatewayid)
131
+ exitcode = @aws.ec2.route_table.declare_propagation_from_gateway(options[:region], @out, (options[:verbose] ? @out : nil), options[:vpcid], rtable_externalid, vgatewayid, options[:check], options[:undofile])
132
+ exit exitcode
133
+ end
134
+
135
+ desc "delete_propagation_from_gateway ROUTE_TABLE_EXTERNAL_ID GATEWAY_ID", "Delete route propagation from virtual gateway."
136
+ option :vpcid, :type => :string, :desc => "AWS VPC id", :banner => "<vpcid>", :aliases => :v, :default => nil
137
+
138
+ def delete_propagation_from_gateway(rtable_externalid, vgatewayid)
139
+ @aws.ec2.route_table.delete_propagation_from_gateway(options[:region], @out, (options[:verbose] ? @out : nil), options[:vpcid], rtable_externalid, vgatewayid)
140
+ end
141
+
142
+ end
130
143
  end
131
144
  end
132
145