fog-google 1.8.2 → 1.12.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (297) hide show
  1. checksums.yaml +5 -5
  2. data/.fog.example +1 -3
  3. data/.rubocop.yml +3 -3
  4. data/.travis.yml +5 -3
  5. data/CHANGELOG.md +126 -2
  6. data/CONTRIBUTING.md +0 -1
  7. data/README.md +59 -8
  8. data/SECURITY.md +16 -0
  9. data/ci/README.md +8 -8
  10. data/ci/build-head-pipeline.yml +173 -0
  11. data/ci/credentials.yml.template +0 -2
  12. data/ci/docker-image/Dockerfile +3 -3
  13. data/ci/{pipeline.yml → integration-pipeline.yml} +0 -33
  14. data/ci/pipeline-dev.yml +58 -0
  15. data/ci/tasks/run-int.sh +20 -3
  16. data/ci/tasks/run-int.yml +3 -1
  17. data/examples/sql/flags.rb +10 -6
  18. data/examples/sql/instances.rb +38 -34
  19. data/examples/sql/operations.rb +20 -16
  20. data/examples/sql/ssl_certs.rb +32 -28
  21. data/examples/sql/tiers.rb +10 -6
  22. data/fog-google.gemspec +3 -3
  23. data/lib/fog/compute/google.rb +5 -5
  24. data/lib/fog/compute/google/mock.rb +2 -1
  25. data/lib/fog/compute/google/models/address.rb +15 -2
  26. data/lib/fog/compute/google/models/disk.rb +6 -2
  27. data/lib/fog/compute/google/models/images.rb +6 -1
  28. data/lib/fog/compute/google/models/instance_groups.rb +2 -2
  29. data/lib/fog/compute/google/models/server.rb +33 -9
  30. data/lib/fog/compute/google/real.rb +2 -1
  31. data/lib/fog/compute/google/requests/abandon_instances.rb +2 -0
  32. data/lib/fog/compute/google/requests/add_backend_service_backends.rb +2 -0
  33. data/lib/fog/compute/google/requests/add_instance_group_instances.rb +2 -0
  34. data/lib/fog/compute/google/requests/add_server_access_config.rb +2 -0
  35. data/lib/fog/compute/google/requests/add_target_pool_health_checks.rb +2 -0
  36. data/lib/fog/compute/google/requests/add_target_pool_instances.rb +2 -0
  37. data/lib/fog/compute/google/requests/attach_disk.rb +2 -0
  38. data/lib/fog/compute/google/requests/create_disk_snapshot.rb +2 -0
  39. data/lib/fog/compute/google/requests/delete_address.rb +2 -0
  40. data/lib/fog/compute/google/requests/delete_backend_service.rb +2 -0
  41. data/lib/fog/compute/google/requests/delete_disk.rb +2 -0
  42. data/lib/fog/compute/google/requests/delete_firewall.rb +2 -0
  43. data/lib/fog/compute/google/requests/delete_forwarding_rule.rb +2 -0
  44. data/lib/fog/compute/google/requests/delete_global_address.rb +2 -0
  45. data/lib/fog/compute/google/requests/delete_global_forwarding_rule.rb +2 -0
  46. data/lib/fog/compute/google/requests/delete_global_operation.rb +2 -0
  47. data/lib/fog/compute/google/requests/delete_http_health_check.rb +2 -0
  48. data/lib/fog/compute/google/requests/delete_image.rb +2 -0
  49. data/lib/fog/compute/google/requests/delete_instance_group.rb +2 -0
  50. data/lib/fog/compute/google/requests/delete_instance_group_manager.rb +2 -0
  51. data/lib/fog/compute/google/requests/delete_instance_template.rb +2 -0
  52. data/lib/fog/compute/google/requests/delete_network.rb +2 -0
  53. data/lib/fog/compute/google/requests/delete_region_operation.rb +2 -0
  54. data/lib/fog/compute/google/requests/delete_route.rb +2 -0
  55. data/lib/fog/compute/google/requests/delete_server.rb +2 -0
  56. data/lib/fog/compute/google/requests/delete_server_access_config.rb +2 -0
  57. data/lib/fog/compute/google/requests/delete_snapshot.rb +2 -0
  58. data/lib/fog/compute/google/requests/delete_ssl_certificate.rb +2 -0
  59. data/lib/fog/compute/google/requests/delete_subnetwork.rb +2 -0
  60. data/lib/fog/compute/google/requests/delete_target_http_proxy.rb +2 -0
  61. data/lib/fog/compute/google/requests/delete_target_https_proxy.rb +2 -0
  62. data/lib/fog/compute/google/requests/delete_target_instance.rb +2 -0
  63. data/lib/fog/compute/google/requests/delete_target_pool.rb +2 -0
  64. data/lib/fog/compute/google/requests/delete_url_map.rb +2 -0
  65. data/lib/fog/compute/google/requests/delete_zone_operation.rb +2 -0
  66. data/lib/fog/compute/google/requests/deprecate_image.rb +2 -0
  67. data/lib/fog/compute/google/requests/detach_disk.rb +2 -0
  68. data/lib/fog/compute/google/requests/expand_subnetwork_ip_cidr_range.rb +2 -0
  69. data/lib/fog/compute/google/requests/get_address.rb +2 -0
  70. data/lib/fog/compute/google/requests/get_backend_service_health.rb +2 -0
  71. data/lib/fog/compute/google/requests/get_disk.rb +2 -0
  72. data/lib/fog/compute/google/requests/get_disk_type.rb +2 -0
  73. data/lib/fog/compute/google/requests/get_firewall.rb +2 -0
  74. data/lib/fog/compute/google/requests/get_forwarding_rule.rb +2 -0
  75. data/lib/fog/compute/google/requests/get_global_address.rb +2 -0
  76. data/lib/fog/compute/google/requests/get_global_forwarding_rule.rb +2 -0
  77. data/lib/fog/compute/google/requests/get_global_operation.rb +2 -0
  78. data/lib/fog/compute/google/requests/get_http_health_check.rb +2 -0
  79. data/lib/fog/compute/google/requests/get_image.rb +2 -0
  80. data/lib/fog/compute/google/requests/get_image_from_family.rb +2 -0
  81. data/lib/fog/compute/google/requests/get_instance_group.rb +2 -0
  82. data/lib/fog/compute/google/requests/get_instance_group_manager.rb +2 -0
  83. data/lib/fog/compute/google/requests/get_instance_template.rb +2 -0
  84. data/lib/fog/compute/google/requests/get_machine_type.rb +2 -0
  85. data/lib/fog/compute/google/requests/get_network.rb +2 -0
  86. data/lib/fog/compute/google/requests/get_project.rb +2 -0
  87. data/lib/fog/compute/google/requests/get_region.rb +2 -0
  88. data/lib/fog/compute/google/requests/get_route.rb +2 -0
  89. data/lib/fog/compute/google/requests/get_server.rb +2 -0
  90. data/lib/fog/compute/google/requests/get_server_serial_port_output.rb +2 -0
  91. data/lib/fog/compute/google/requests/get_snapshot.rb +2 -0
  92. data/lib/fog/compute/google/requests/get_ssl_certificate.rb +2 -0
  93. data/lib/fog/compute/google/requests/get_subnetwork.rb +2 -0
  94. data/lib/fog/compute/google/requests/get_target_http_proxy.rb +2 -0
  95. data/lib/fog/compute/google/requests/get_target_https_proxy.rb +2 -0
  96. data/lib/fog/compute/google/requests/get_target_instance.rb +2 -0
  97. data/lib/fog/compute/google/requests/get_target_pool.rb +2 -0
  98. data/lib/fog/compute/google/requests/get_target_pool_health.rb +2 -0
  99. data/lib/fog/compute/google/requests/get_url_map.rb +2 -0
  100. data/lib/fog/compute/google/requests/get_zone.rb +2 -0
  101. data/lib/fog/compute/google/requests/get_zone_operation.rb +2 -0
  102. data/lib/fog/compute/google/requests/insert_address.rb +2 -0
  103. data/lib/fog/compute/google/requests/insert_backend_service.rb +2 -0
  104. data/lib/fog/compute/google/requests/insert_disk.rb +8 -5
  105. data/lib/fog/compute/google/requests/insert_firewall.rb +2 -0
  106. data/lib/fog/compute/google/requests/insert_forwarding_rule.rb +2 -0
  107. data/lib/fog/compute/google/requests/insert_global_address.rb +2 -0
  108. data/lib/fog/compute/google/requests/insert_global_forwarding_rule.rb +2 -0
  109. data/lib/fog/compute/google/requests/insert_http_health_check.rb +2 -0
  110. data/lib/fog/compute/google/requests/insert_image.rb +2 -0
  111. data/lib/fog/compute/google/requests/insert_instance_group.rb +2 -0
  112. data/lib/fog/compute/google/requests/insert_instance_group_manager.rb +2 -0
  113. data/lib/fog/compute/google/requests/insert_instance_template.rb +2 -0
  114. data/lib/fog/compute/google/requests/insert_network.rb +2 -0
  115. data/lib/fog/compute/google/requests/insert_route.rb +2 -0
  116. data/lib/fog/compute/google/requests/insert_server.rb +6 -0
  117. data/lib/fog/compute/google/requests/insert_ssl_certificate.rb +2 -0
  118. data/lib/fog/compute/google/requests/insert_subnetwork.rb +2 -0
  119. data/lib/fog/compute/google/requests/insert_target_http_proxy.rb +2 -0
  120. data/lib/fog/compute/google/requests/insert_target_https_proxy.rb +2 -0
  121. data/lib/fog/compute/google/requests/insert_target_instance.rb +2 -0
  122. data/lib/fog/compute/google/requests/insert_target_pool.rb +2 -0
  123. data/lib/fog/compute/google/requests/insert_url_map.rb +2 -0
  124. data/lib/fog/compute/google/requests/invalidate_url_map_cache.rb +2 -0
  125. data/lib/fog/compute/google/requests/list_addresses.rb +2 -0
  126. data/lib/fog/compute/google/requests/list_aggregated_addresses.rb +2 -0
  127. data/lib/fog/compute/google/requests/list_aggregated_disk_types.rb +2 -0
  128. data/lib/fog/compute/google/requests/list_aggregated_disks.rb +2 -0
  129. data/lib/fog/compute/google/requests/list_aggregated_forwarding_rules.rb +2 -0
  130. data/lib/fog/compute/google/requests/list_aggregated_instance_group_managers.rb +2 -0
  131. data/lib/fog/compute/google/requests/list_aggregated_instance_groups.rb +2 -0
  132. data/lib/fog/compute/google/requests/list_aggregated_machine_types.rb +2 -0
  133. data/lib/fog/compute/google/requests/list_aggregated_servers.rb +2 -0
  134. data/lib/fog/compute/google/requests/list_aggregated_subnetworks.rb +2 -0
  135. data/lib/fog/compute/google/requests/list_aggregated_target_instances.rb +2 -0
  136. data/lib/fog/compute/google/requests/list_aggregated_target_pools.rb +2 -0
  137. data/lib/fog/compute/google/requests/list_disk_types.rb +2 -0
  138. data/lib/fog/compute/google/requests/list_disks.rb +2 -0
  139. data/lib/fog/compute/google/requests/list_firewalls.rb +2 -0
  140. data/lib/fog/compute/google/requests/list_forwarding_rules.rb +2 -0
  141. data/lib/fog/compute/google/requests/list_global_addresses.rb +2 -0
  142. data/lib/fog/compute/google/requests/list_global_forwarding_rules.rb +2 -0
  143. data/lib/fog/compute/google/requests/list_global_operations.rb +2 -0
  144. data/lib/fog/compute/google/requests/list_http_health_checks.rb +2 -0
  145. data/lib/fog/compute/google/requests/list_images.rb +2 -0
  146. data/lib/fog/compute/google/requests/list_instance_group_instances.rb +2 -0
  147. data/lib/fog/compute/google/requests/list_instance_group_managers.rb +2 -0
  148. data/lib/fog/compute/google/requests/list_instance_groups.rb +2 -0
  149. data/lib/fog/compute/google/requests/list_instance_templates.rb +2 -0
  150. data/lib/fog/compute/google/requests/list_machine_types.rb +2 -0
  151. data/lib/fog/compute/google/requests/list_networks.rb +2 -0
  152. data/lib/fog/compute/google/requests/list_region_operations.rb +2 -0
  153. data/lib/fog/compute/google/requests/list_regions.rb +2 -0
  154. data/lib/fog/compute/google/requests/list_routes.rb +2 -0
  155. data/lib/fog/compute/google/requests/list_servers.rb +2 -0
  156. data/lib/fog/compute/google/requests/list_snapshots.rb +2 -0
  157. data/lib/fog/compute/google/requests/list_ssl_certificates.rb +2 -0
  158. data/lib/fog/compute/google/requests/list_subnetworks.rb +2 -0
  159. data/lib/fog/compute/google/requests/list_target_http_proxies.rb +2 -0
  160. data/lib/fog/compute/google/requests/list_target_https_proxies.rb +2 -0
  161. data/lib/fog/compute/google/requests/list_target_instances.rb +2 -0
  162. data/lib/fog/compute/google/requests/list_target_pools.rb +2 -0
  163. data/lib/fog/compute/google/requests/list_url_maps.rb +2 -0
  164. data/lib/fog/compute/google/requests/list_zone_operations.rb +2 -0
  165. data/lib/fog/compute/google/requests/list_zones.rb +2 -0
  166. data/lib/fog/compute/google/requests/patch_firewall.rb +2 -0
  167. data/lib/fog/compute/google/requests/patch_url_map.rb +2 -0
  168. data/lib/fog/compute/google/requests/recreate_instances.rb +2 -0
  169. data/lib/fog/compute/google/requests/remove_instance_group_instances.rb +2 -0
  170. data/lib/fog/compute/google/requests/remove_target_pool_health_checks.rb +2 -0
  171. data/lib/fog/compute/google/requests/remove_target_pool_instance.rb +2 -0
  172. data/lib/fog/compute/google/requests/remove_target_pool_instances.rb +2 -0
  173. data/lib/fog/compute/google/requests/reset_server.rb +2 -0
  174. data/lib/fog/compute/google/requests/reset_windows_password.rb +154 -0
  175. data/lib/fog/compute/google/requests/set_common_instance_metadata.rb +2 -0
  176. data/lib/fog/compute/google/requests/set_forwarding_rule_target.rb +2 -0
  177. data/lib/fog/compute/google/requests/set_global_forwarding_rule_target.rb +2 -0
  178. data/lib/fog/compute/google/requests/set_instance_template.rb +2 -0
  179. data/lib/fog/compute/google/requests/set_server_disk_auto_delete.rb +2 -0
  180. data/lib/fog/compute/google/requests/set_server_machine_type.rb +23 -0
  181. data/lib/fog/compute/google/requests/set_server_metadata.rb +3 -1
  182. data/lib/fog/compute/google/requests/set_server_scheduling.rb +2 -0
  183. data/lib/fog/compute/google/requests/set_server_tags.rb +2 -0
  184. data/lib/fog/compute/google/requests/set_snapshot_labels.rb +2 -0
  185. data/lib/fog/compute/google/requests/set_subnetwork_private_ip_google_access.rb +2 -0
  186. data/lib/fog/compute/google/requests/set_target_http_proxy_url_map.rb +2 -0
  187. data/lib/fog/compute/google/requests/set_target_https_proxy_ssl_certificates.rb +2 -0
  188. data/lib/fog/compute/google/requests/set_target_https_proxy_url_map.rb +2 -0
  189. data/lib/fog/compute/google/requests/set_target_pool_backup.rb +2 -0
  190. data/lib/fog/compute/google/requests/start_server.rb +2 -0
  191. data/lib/fog/compute/google/requests/stop_server.rb +2 -0
  192. data/lib/fog/compute/google/requests/update_firewall.rb +2 -0
  193. data/lib/fog/compute/google/requests/update_http_health_check.rb +2 -0
  194. data/lib/fog/compute/google/requests/update_url_map.rb +2 -0
  195. data/lib/fog/compute/google/requests/validate_url_map.rb +2 -0
  196. data/lib/fog/dns/google.rb +1 -1
  197. data/lib/fog/dns/google/requests/create_change.rb +2 -0
  198. data/lib/fog/dns/google/requests/create_managed_zone.rb +2 -0
  199. data/lib/fog/dns/google/requests/delete_managed_zone.rb +2 -0
  200. data/lib/fog/dns/google/requests/get_change.rb +2 -0
  201. data/lib/fog/dns/google/requests/get_managed_zone.rb +2 -0
  202. data/lib/fog/dns/google/requests/get_project.rb +2 -0
  203. data/lib/fog/dns/google/requests/list_changes.rb +2 -0
  204. data/lib/fog/dns/google/requests/list_managed_zones.rb +2 -0
  205. data/lib/fog/dns/google/requests/list_resource_record_sets.rb +2 -0
  206. data/lib/fog/google/models/sql/ssl_cert.rb +7 -1
  207. data/lib/fog/google/models/sql/user.rb +2 -0
  208. data/lib/fog/google/monitoring.rb +2 -1
  209. data/lib/fog/google/pubsub.rb +1 -1
  210. data/lib/fog/google/requests/monitoring/create_metric_descriptor.rb +2 -0
  211. data/lib/fog/google/requests/monitoring/create_timeseries.rb +3 -1
  212. data/lib/fog/google/requests/monitoring/delete_metric_descriptor.rb +2 -0
  213. data/lib/fog/google/requests/monitoring/get_metric_descriptor.rb +2 -0
  214. data/lib/fog/google/requests/monitoring/list_monitored_resource_descriptors.rb +2 -0
  215. data/lib/fog/google/requests/monitoring/list_timeseries.rb +2 -0
  216. data/lib/fog/google/requests/pubsub/pull_subscription.rb +5 -1
  217. data/lib/fog/google/requests/sql/clone_instance.rb +2 -0
  218. data/lib/fog/google/requests/sql/delete_backup_run.rb +2 -0
  219. data/lib/fog/google/requests/sql/delete_instance.rb +2 -0
  220. data/lib/fog/google/requests/sql/delete_ssl_cert.rb +2 -0
  221. data/lib/fog/google/requests/sql/delete_user.rb +3 -1
  222. data/lib/fog/google/requests/sql/export_instance.rb +2 -0
  223. data/lib/fog/google/requests/sql/get_backup_run.rb +2 -0
  224. data/lib/fog/google/requests/sql/get_instance.rb +2 -0
  225. data/lib/fog/google/requests/sql/get_operation.rb +2 -0
  226. data/lib/fog/google/requests/sql/get_ssl_cert.rb +2 -0
  227. data/lib/fog/google/requests/sql/import_instance.rb +2 -0
  228. data/lib/fog/google/requests/sql/insert_backup_run.rb +2 -0
  229. data/lib/fog/google/requests/sql/insert_instance.rb +2 -0
  230. data/lib/fog/google/requests/sql/insert_ssl_cert.rb +2 -0
  231. data/lib/fog/google/requests/sql/insert_user.rb +2 -0
  232. data/lib/fog/google/requests/sql/list_backup_runs.rb +2 -0
  233. data/lib/fog/google/requests/sql/list_flags.rb +2 -0
  234. data/lib/fog/google/requests/sql/list_instances.rb +2 -0
  235. data/lib/fog/google/requests/sql/list_operations.rb +2 -0
  236. data/lib/fog/google/requests/sql/list_ssl_certs.rb +2 -0
  237. data/lib/fog/google/requests/sql/list_tiers.rb +2 -0
  238. data/lib/fog/google/requests/sql/list_users.rb +2 -0
  239. data/lib/fog/google/requests/sql/reset_instance_ssl_config.rb +2 -0
  240. data/lib/fog/google/requests/sql/restart_instance.rb +2 -0
  241. data/lib/fog/google/requests/sql/restore_instance_backup.rb +2 -0
  242. data/lib/fog/google/requests/sql/update_instance.rb +2 -0
  243. data/lib/fog/google/requests/sql/update_user.rb +2 -0
  244. data/lib/fog/google/shared.rb +115 -55
  245. data/lib/fog/google/sql.rb +1 -1
  246. data/lib/fog/google/version.rb +1 -1
  247. data/lib/fog/storage/google_json.rb +5 -1
  248. data/lib/fog/storage/google_json/mock.rb +6 -0
  249. data/lib/fog/storage/google_json/real.rb +106 -3
  250. data/lib/fog/storage/google_json/requests/copy_object.rb +2 -0
  251. data/lib/fog/storage/google_json/requests/delete_bucket.rb +2 -0
  252. data/lib/fog/storage/google_json/requests/delete_object.rb +2 -0
  253. data/lib/fog/storage/google_json/requests/get_bucket.rb +2 -0
  254. data/lib/fog/storage/google_json/requests/get_bucket_acl.rb +2 -0
  255. data/lib/fog/storage/google_json/requests/get_object.rb +2 -0
  256. data/lib/fog/storage/google_json/requests/get_object_acl.rb +2 -0
  257. data/lib/fog/storage/google_json/requests/get_object_metadata.rb +2 -0
  258. data/lib/fog/storage/google_json/requests/list_bucket_acl.rb +2 -0
  259. data/lib/fog/storage/google_json/requests/list_buckets.rb +2 -0
  260. data/lib/fog/storage/google_json/requests/list_object_acl.rb +2 -0
  261. data/lib/fog/storage/google_json/requests/list_objects.rb +2 -0
  262. data/lib/fog/storage/google_json/requests/put_bucket.rb +2 -0
  263. data/lib/fog/storage/google_json/requests/put_bucket_acl.rb +2 -0
  264. data/lib/fog/storage/google_json/requests/put_object.rb +2 -0
  265. data/lib/fog/storage/google_json/requests/put_object_acl.rb +2 -0
  266. data/lib/fog/storage/google_json/utils.rb +1 -1
  267. data/lib/fog/storage/google_xml/models/file.rb +1 -1
  268. data/lib/fog/storage/google_xml/requests/get_bucket.rb +0 -1
  269. data/lib/fog/storage/google_xml/requests/head_object.rb +7 -6
  270. data/lib/fog/storage/google_xml/requests/put_bucket_acl.rb +2 -0
  271. data/tasks/changelog.rake +37 -0
  272. data/tasks/test.rake +6 -2
  273. data/test/helpers/integration_test_helper.rb +17 -6
  274. data/test/helpers/test_helper.rb +1 -0
  275. data/test/integration/compute/core_compute/test_servers.rb +40 -0
  276. data/test/integration/compute/core_compute/test_zones.rb +1 -1
  277. data/test/integration/compute/core_networking/test_addresses.rb +23 -0
  278. data/test/integration/factories/{sql_v1_certs_factory.rb → sql_certs_factory.rb} +3 -3
  279. data/test/integration/factories/{sql_v1_instances_factory.rb → sql_instances_factory.rb} +3 -3
  280. data/test/integration/factories/{sql_v1_users_factory.rb → sql_users_factory.rb} +6 -3
  281. data/test/integration/monitoring/test_metric_descriptors.rb +2 -0
  282. data/test/integration/monitoring/test_timeseries.rb +14 -26
  283. data/test/integration/pubsub/test_pubsub_models.rb +3 -3
  284. data/test/integration/pubsub/test_pubsub_requests.rb +2 -2
  285. data/test/integration/sql/{sqlv1/test_v1_certs.rb → test_certs.rb} +3 -3
  286. data/test/integration/sql/{sqlv1/test_common_flags.rb → test_common_flags.rb} +0 -0
  287. data/test/integration/sql/{sqlv1/test_common_tiers.rb → test_common_tiers.rb} +0 -0
  288. data/test/integration/sql/{sqlv1/test_coverage.rb → test_coverage.rb} +1 -1
  289. data/test/integration/sql/{sqlv2/test_v2_instances.rb → test_instances.rb} +22 -2
  290. data/test/integration/sql/{sqlv1/test_v1_users.rb → test_users.rb} +4 -4
  291. data/test/integration/test_authentication.rb +0 -7
  292. data/test/unit/storage/test_common_xml_collections.rb +11 -0
  293. data/test/unit/storage/test_json_requests.rb +0 -1
  294. metadata +50 -31
  295. data/test/integration/factories/sql_v2_instances_factory.rb +0 -19
  296. data/test/integration/sql/sqlv1/test_v1_instances.rb +0 -31
  297. data/test/integration/sql/sqlv2/test_coverage.rb +0 -6
@@ -3,7 +3,9 @@ module Fog
3
3
  class Google
4
4
  class Mock
5
5
  def patch_url_map(_url_map_name, _options = {})
6
+ # :no-coverage:
6
7
  Fog::Mock.not_implemented
8
+ # :no-coverage:
7
9
  end
8
10
  end
9
11
 
@@ -3,7 +3,9 @@ module Fog
3
3
  class Google
4
4
  class Mock
5
5
  def recreate_instances(_instance_group_manager, _instances)
6
+ # :no-coverage:
6
7
  Fog::Mock.not_implemented
8
+ # :no-coverage:
7
9
  end
8
10
  end
9
11
 
@@ -3,7 +3,9 @@ module Fog
3
3
  class Google
4
4
  class Mock
5
5
  def add_instance_group_instances(_group, _zone, _instances)
6
+ # :no-coverage:
6
7
  Fog::Mock.not_implemented
8
+ # :no-coverage:
7
9
  end
8
10
  end
9
11
 
@@ -3,7 +3,9 @@ module Fog
3
3
  class Google
4
4
  class Mock
5
5
  def remove_target_pool_health_checks(_target_pool, _region, _health_checks)
6
+ # :no-coverage:
6
7
  Fog::Mock.not_implemented
8
+ # :no-coverage:
7
9
  end
8
10
  end
9
11
 
@@ -3,7 +3,9 @@ module Fog
3
3
  class Google
4
4
  class Mock
5
5
  def remove_target_pool_instances(_target_pool, _region, _instances)
6
+ # :no-coverage:
6
7
  Fog::Mock.not_implemented
8
+ # :no-coverage:
7
9
  end
8
10
  end
9
11
 
@@ -3,7 +3,9 @@ module Fog
3
3
  class Google
4
4
  class Mock
5
5
  def remove_target_pool_instances(_target_pool, _region, _instances)
6
+ # :no-coverage:
6
7
  Fog::Mock.not_implemented
8
+ # :no-coverage:
7
9
  end
8
10
  end
9
11
 
@@ -3,7 +3,9 @@ module Fog
3
3
  class Google
4
4
  class Mock
5
5
  def reset_server(_identity, _zone)
6
+ # :no-coverage:
6
7
  Fog::Mock.not_implemented
8
+ # :no-coverage:
7
9
  end
8
10
  end
9
11
 
@@ -0,0 +1,154 @@
1
+ # Copyright 2015 Google Inc. All Rights Reserved.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+ #
15
+ # Changes:
16
+ # March 2020: Modified example found here:
17
+ # https://github.com/GoogleCloudPlatform/compute-image-windows/blob/master/examples/windows_auth_python_sample.py
18
+ # to enable fog-google to change windows passwords.
19
+
20
+ require "openssl"
21
+ require "base64"
22
+ require "json"
23
+
24
+ module Fog
25
+ module Compute
26
+ class Google
27
+ class Mock
28
+ def reset_windows_password(_server:, _user:)
29
+ Fog::Mock.not_implemented
30
+ end
31
+ end
32
+
33
+ class Real
34
+ ##
35
+ # Resets Windows passwords for users on Google's Windows based images. Code based on Google provided example.
36
+ #
37
+ # @param instance [String] the name of the instance
38
+ # @param zone [String] the name of the zone of the instance
39
+ # @param user [String] the user whose password should be reset
40
+ #
41
+ # @return [String] new password
42
+ #
43
+ # @see https://cloud.google.com/compute/docs/instances/windows/automate-pw-generation
44
+ def reset_windows_password(server:, user:)
45
+ # Pull the e-mail address of user authenticated to API
46
+ email = @compute.request_options.authorization.issuer
47
+
48
+ # Create a new key
49
+ key = OpenSSL::PKey::RSA.new(2048)
50
+ modulus, exponent = get_modulus_exponent_in_base64(key)
51
+
52
+ # Get Old Metadata
53
+ old_metadata = server.metadata
54
+
55
+ # Create JSON Object with needed information
56
+ metadata_entry = get_json_string(user, modulus, exponent, email)
57
+
58
+ # Create new metadata object
59
+ new_metadata = update_windows_keys(old_metadata, metadata_entry)
60
+
61
+ # Set metadata on instance
62
+ server.set_metadata(new_metadata, false)
63
+
64
+ # Get encrypted password from Serial Port 4 Output
65
+
66
+ # If machine is booting for the first time, there appears to be a
67
+ # delay before the password appears on the serial port.
68
+ sleep(1) until server.ready?
69
+ serial_port_output = server.serial_port_output(:port => 4)
70
+ loop_cnt = 0
71
+ while serial_port_output.empty?
72
+ if loop_cnt > 12
73
+ Fog::Logger.warning("Encrypted password never found on Serial Output Port 4")
74
+ raise "Could not reset password."
75
+ end
76
+ sleep(5)
77
+ serial_port_output = server.serial_port_output(:port => 4)
78
+ loop_cnt += 1
79
+ end
80
+
81
+ # Parse and decrypt password
82
+ enc_password = get_encrypted_password_from_serial_port(serial_port_output, modulus)
83
+ password = decrypt_password(enc_password, key)
84
+
85
+ return password
86
+ end
87
+
88
+ def get_modulus_exponent_in_base64(key)
89
+ mod = [key.n.to_s(16)].pack("H*").strip
90
+ exp = [key.e.to_s(16)].pack("H*").strip
91
+ modulus = Base64.strict_encode64(mod).strip
92
+ exponent = Base64.strict_encode64(exp).strip
93
+ return modulus, exponent
94
+ end
95
+
96
+ def get_expiration_time_string
97
+ utc_now = Time.now.utc
98
+ expire_time = utc_now + 5 * 60
99
+ return expire_time.strftime("%Y-%m-%dT%H:%M:%SZ")
100
+ end
101
+
102
+ def get_json_string(user, modulus, exponent, email)
103
+ expire = get_expiration_time_string
104
+ data = { 'userName': user,
105
+ 'modulus': modulus,
106
+ 'exponent': exponent,
107
+ 'email': email,
108
+ 'expireOn': expire }
109
+ return ::JSON.dump(data)
110
+ end
111
+
112
+ def update_windows_keys(old_metadata, metadata_entry)
113
+ if old_metadata[:items]
114
+ new_metadata = Hash[old_metadata[:items].map { |item| [item[:key], item[:value]] }]
115
+ else
116
+ new_metadata = {}
117
+ end
118
+ new_metadata["windows-keys"] = metadata_entry
119
+ return new_metadata
120
+ end
121
+
122
+ def get_encrypted_password_from_serial_port(serial_port_output, modulus)
123
+ output = serial_port_output.split("\n")
124
+ output.reverse_each do |line|
125
+ begin
126
+ if line.include?("modulus") && line.include?("encryptedPassword")
127
+ entry = ::JSON.parse(line)
128
+ if modulus == entry["modulus"]
129
+ return entry["encryptedPassword"]
130
+ end
131
+ else
132
+ next
133
+ end
134
+ rescue ::JSON::ParserError
135
+ Fog::Logger.warning("Parsing encrypted password from serial output
136
+ failed. Trying to parse next matching line.")
137
+ next
138
+ end
139
+ end
140
+ end
141
+
142
+ def decrypt_password(enc_password, key)
143
+ decoded_password = Base64.strict_decode64(enc_password)
144
+ begin
145
+ return key.private_decrypt(decoded_password, OpenSSL::PKey::RSA::PKCS1_OAEP_PADDING)
146
+ rescue OpenSSL::PKey::RSAError
147
+ Fog::Logger.warning("Error decrypting password received from Google.
148
+ Maybe check output on Serial Port 4 and Metadata key: windows-keys?")
149
+ end
150
+ end
151
+ end
152
+ end
153
+ end
154
+ end
@@ -3,7 +3,9 @@ module Fog
3
3
  class Google
4
4
  class Mock
5
5
  def set_common_instance_metadata(_project, _current_fingerprint, _metadata = {})
6
+ # :no-coverage:
6
7
  Fog::Mock.not_implemented
8
+ # :no-coverage:
7
9
  end
8
10
  end
9
11
 
@@ -3,7 +3,9 @@ module Fog
3
3
  class Google
4
4
  class Mock
5
5
  def set_forwarding_rule_target(_rule_name, _region, _target_opts)
6
+ # :no-coverage:
6
7
  Fog::Mock.not_implemented
8
+ # :no-coverage:
7
9
  end
8
10
  end
9
11
 
@@ -3,7 +3,9 @@ module Fog
3
3
  class Google
4
4
  class Mock
5
5
  def set_global_forwarding_rule_target(_rule_name, _target)
6
+ # :no-coverage:
6
7
  Fog::Mock.not_implemented
8
+ # :no-coverage:
7
9
  end
8
10
  end
9
11
 
@@ -3,7 +3,9 @@ module Fog
3
3
  class Google
4
4
  class Mock
5
5
  def set_instance_template(_instance_group_manager, _instance_template)
6
+ # :no-coverage:
6
7
  Fog::Mock.not_implemented
8
+ # :no-coverage:
7
9
  end
8
10
  end
9
11
 
@@ -3,7 +3,9 @@ module Fog
3
3
  class Google
4
4
  class Mock
5
5
  def set_server_disk_auto_delete(_identity, _zone, _auto_delete, _device_name)
6
+ # :no-coverage:
6
7
  Fog::Mock.not_implemented
8
+ # :no-coverage:
7
9
  end
8
10
  end
9
11
 
@@ -0,0 +1,23 @@
1
+ module Fog
2
+ module Compute
3
+ class Google
4
+ class Mock
5
+ def set_server_machine_type(_instance, _zone, _machine_type)
6
+ # :no-coverage:
7
+ Fog::Mock.not_implemented
8
+ # :no-coverage:
9
+ end
10
+ end
11
+
12
+ class Real
13
+ def set_server_machine_type(instance, zone, machine_type)
14
+ request = ::Google::Apis::ComputeV1::InstancesSetMachineTypeRequest.new
15
+ zone = zone.split("/")[-1]
16
+ machine_type = machine_type.split("/")[-1]
17
+ request.machine_type = "zones/#{zone}/machineTypes/#{machine_type}"
18
+ @compute.set_instance_machine_type(@project, zone, instance, request)
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -3,7 +3,9 @@ module Fog
3
3
  class Google
4
4
  class Mock
5
5
  def set_server_metadata(_instance, _zone, _fingerprint, _metadata_items = {})
6
+ # :no-coverage:
6
7
  Fog::Mock.not_implemented
8
+ # :no-coverage:
7
9
  end
8
10
  end
9
11
 
@@ -19,7 +21,7 @@ module Fog
19
21
  # fingerprint = instance.metadata['fingerprint']
20
22
  # @param [Hash] metadata A new metadata object
21
23
  # Should have the following structure:
22
- # {:items=>[{:key=>"foo", :value=>"bar"}, {:key=>"baz", :value=>"foo"}]}
24
+ # {'foo' => 'bar', 'baz'=>'foo'}
23
25
  #
24
26
  # @returns [::Google::Apis::ComputeV1::Operation] set operation
25
27
  def set_server_metadata(instance, zone, fingerprint, metadata_items = [])
@@ -3,7 +3,9 @@ module Fog
3
3
  class Google
4
4
  class Mock
5
5
  def set_server_scheduling(_identity, _zone, _on_host_maintenance, _automatic_restart, _preemptible)
6
+ # :no-coverage:
6
7
  Fog::Mock.not_implemented
8
+ # :no-coverage:
7
9
  end
8
10
  end
9
11
 
@@ -3,7 +3,9 @@ module Fog
3
3
  class Google
4
4
  class Mock
5
5
  def set_server_tags(_instance, _zone, _tags = [])
6
+ # :no-coverage:
6
7
  Fog::Mock.not_implemented
8
+ # :no-coverage:
7
9
  end
8
10
  end
9
11
 
@@ -3,7 +3,9 @@ module Fog
3
3
  class Google
4
4
  class Mock
5
5
  def set_snapshot_labels(_snap_name)
6
+ # :no-coverage:
6
7
  Fog::Mock.not_implemented
8
+ # :no-coverage:
7
9
  end
8
10
  end
9
11
 
@@ -5,7 +5,9 @@ module Fog
5
5
  def set_subnetwork_private_ip_google_access(_subnetwork_name,
6
6
  _region_name,
7
7
  _private_ip_google_access)
8
+ # :no-coverage:
8
9
  Fog::Mock.not_implemented
10
+ # :no-coverage:
9
11
  end
10
12
  end
11
13
 
@@ -3,7 +3,9 @@ module Fog
3
3
  class Google
4
4
  class Mock
5
5
  def set_target_http_proxy_url_map(_proxy_name, _url_map)
6
+ # :no-coverage:
6
7
  Fog::Mock.not_implemented
8
+ # :no-coverage:
7
9
  end
8
10
  end
9
11
 
@@ -3,7 +3,9 @@ module Fog
3
3
  class Google
4
4
  class Mock
5
5
  def set_target_https_proxy_ssl_certificates(_proxy_name, _certs)
6
+ # :no-coverage:
6
7
  Fog::Mock.not_implemented
8
+ # :no-coverage:
7
9
  end
8
10
  end
9
11
 
@@ -3,7 +3,9 @@ module Fog
3
3
  class Google
4
4
  class Mock
5
5
  def set_target_https_proxy_url_map(_proxy_name, _url_map)
6
+ # :no-coverage:
6
7
  Fog::Mock.not_implemented
8
+ # :no-coverage:
7
9
  end
8
10
  end
9
11
 
@@ -4,7 +4,9 @@ module Fog
4
4
  class Mock
5
5
  def set_target_pool_backup(_target_pool, _region, _backup_target,
6
6
  _failover_ratio: nil)
7
+ # :no-coverage:
7
8
  Fog::Mock.not_implemented
9
+ # :no-coverage:
8
10
  end
9
11
  end
10
12
 
@@ -3,7 +3,9 @@ module Fog
3
3
  class Google
4
4
  class Mock
5
5
  def start_server(_identity, _zone)
6
+ # :no-coverage:
6
7
  Fog::Mock.not_implemented
8
+ # :no-coverage:
7
9
  end
8
10
  end
9
11
 
@@ -3,7 +3,9 @@ module Fog
3
3
  class Google
4
4
  class Mock
5
5
  def stop_server(_identity, _zone)
6
+ # :no-coverage:
6
7
  Fog::Mock.not_implemented
8
+ # :no-coverage:
7
9
  end
8
10
  end
9
11
 
@@ -3,7 +3,9 @@ module Fog
3
3
  class Google
4
4
  class Mock
5
5
  def update_firewall(_firewall_name, _firewall_opts = {})
6
+ # :no-coverage:
6
7
  Fog::Mock.not_implemented
8
+ # :no-coverage:
7
9
  end
8
10
  end
9
11