oraclebmc 1.2.4 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/{README.md → README_BMCS.md} +21 -26
- data/lib/oraclebmc.rb +1 -19
- metadata +16 -259
- data/lib/oraclebmc/api_client.rb +0 -306
- data/lib/oraclebmc/config.rb +0 -80
- data/lib/oraclebmc/config_file_loader.rb +0 -85
- data/lib/oraclebmc/core/blockstorage_client.rb +0 -460
- data/lib/oraclebmc/core/compute_client.rb +0 -1267
- data/lib/oraclebmc/core/core.rb +0 -112
- data/lib/oraclebmc/core/models/attach_i_scsi_volume_details.rb +0 -137
- data/lib/oraclebmc/core/models/attach_vnic_details.rb +0 -144
- data/lib/oraclebmc/core/models/attach_volume_details.rb +0 -165
- data/lib/oraclebmc/core/models/capture_console_history_details.rb +0 -120
- data/lib/oraclebmc/core/models/console_history.rb +0 -213
- data/lib/oraclebmc/core/models/cpe.rb +0 -169
- data/lib/oraclebmc/core/models/create_cpe_details.rb +0 -145
- data/lib/oraclebmc/core/models/create_cross_connect_details.rb +0 -204
- data/lib/oraclebmc/core/models/create_cross_connect_group_details.rb +0 -133
- data/lib/oraclebmc/core/models/create_dhcp_details.rb +0 -153
- data/lib/oraclebmc/core/models/create_drg_attachment_details.rb +0 -142
- data/lib/oraclebmc/core/models/create_drg_details.rb +0 -131
- data/lib/oraclebmc/core/models/create_image_details.rb +0 -159
- data/lib/oraclebmc/core/models/create_internet_gateway_details.rb +0 -153
- data/lib/oraclebmc/core/models/create_ip_sec_connection_details.rb +0 -168
- data/lib/oraclebmc/core/models/create_private_ip_details.rb +0 -173
- data/lib/oraclebmc/core/models/create_route_table_details.rb +0 -153
- data/lib/oraclebmc/core/models/create_security_list_details.rb +0 -164
- data/lib/oraclebmc/core/models/create_subnet_details.rb +0 -257
- data/lib/oraclebmc/core/models/create_vcn_details.rb +0 -171
- data/lib/oraclebmc/core/models/create_virtual_circuit_details.rb +0 -260
- data/lib/oraclebmc/core/models/create_vnic_details.rb +0 -214
- data/lib/oraclebmc/core/models/create_volume_backup_details.rb +0 -133
- data/lib/oraclebmc/core/models/create_volume_details.rb +0 -170
- data/lib/oraclebmc/core/models/cross_connect.rb +0 -235
- data/lib/oraclebmc/core/models/cross_connect_group.rb +0 -187
- data/lib/oraclebmc/core/models/cross_connect_location.rb +0 -134
- data/lib/oraclebmc/core/models/cross_connect_mapping.rb +0 -190
- data/lib/oraclebmc/core/models/cross_connect_port_speed_shape.rb +0 -137
- data/lib/oraclebmc/core/models/cross_connect_status.rb +0 -200
- data/lib/oraclebmc/core/models/dhcp_dns_option.rb +0 -171
- data/lib/oraclebmc/core/models/dhcp_option.rb +0 -135
- data/lib/oraclebmc/core/models/dhcp_options.rb +0 -208
- data/lib/oraclebmc/core/models/dhcp_search_domain_option.rb +0 -141
- data/lib/oraclebmc/core/models/drg.rb +0 -186
- data/lib/oraclebmc/core/models/drg_attachment.rb +0 -208
- data/lib/oraclebmc/core/models/egress_security_rule.rb +0 -198
- data/lib/oraclebmc/core/models/export_image_details.rb +0 -134
- data/lib/oraclebmc/core/models/export_image_via_object_storage_tuple_details.rb +0 -150
- data/lib/oraclebmc/core/models/export_image_via_object_storage_uri_details.rb +0 -130
- data/lib/oraclebmc/core/models/fast_connect_provider_service.rb +0 -145
- data/lib/oraclebmc/core/models/i_scsi_volume_attachment.rb +0 -212
- data/lib/oraclebmc/core/models/icmp_options.rb +0 -131
- data/lib/oraclebmc/core/models/image.rb +0 -245
- data/lib/oraclebmc/core/models/image_source_details.rb +0 -134
- data/lib/oraclebmc/core/models/image_source_via_object_storage_tuple_details.rb +0 -150
- data/lib/oraclebmc/core/models/image_source_via_object_storage_uri_details.rb +0 -128
- data/lib/oraclebmc/core/models/ingress_security_rule.rb +0 -198
- data/lib/oraclebmc/core/models/instance.rb +0 -307
- data/lib/oraclebmc/core/models/instance_credentials.rb +0 -131
- data/lib/oraclebmc/core/models/internet_gateway.rb +0 -210
- data/lib/oraclebmc/core/models/ip_sec_connection.rb +0 -223
- data/lib/oraclebmc/core/models/ip_sec_connection_device_config.rb +0 -153
- data/lib/oraclebmc/core/models/ip_sec_connection_device_status.rb +0 -156
- data/lib/oraclebmc/core/models/launch_instance_details.rb +0 -336
- data/lib/oraclebmc/core/models/letter_of_authority.rb +0 -194
- data/lib/oraclebmc/core/models/port_range.rb +0 -133
- data/lib/oraclebmc/core/models/private_ip.rb +0 -248
- data/lib/oraclebmc/core/models/route_rule.rb +0 -135
- data/lib/oraclebmc/core/models/route_table.rb +0 -208
- data/lib/oraclebmc/core/models/security_list.rb +0 -219
- data/lib/oraclebmc/core/models/shape.rb +0 -122
- data/lib/oraclebmc/core/models/subnet.rb +0 -351
- data/lib/oraclebmc/core/models/tcp_options.rb +0 -135
- data/lib/oraclebmc/core/models/tunnel_config.rb +0 -151
- data/lib/oraclebmc/core/models/tunnel_status.rb +0 -178
- data/lib/oraclebmc/core/models/udp_options.rb +0 -135
- data/lib/oraclebmc/core/models/update_cpe_details.rb +0 -122
- data/lib/oraclebmc/core/models/update_cross_connect_details.rb +0 -138
- data/lib/oraclebmc/core/models/update_cross_connect_group_details.rb +0 -122
- data/lib/oraclebmc/core/models/update_dhcp_details.rb +0 -132
- data/lib/oraclebmc/core/models/update_drg_attachment_details.rb +0 -122
- data/lib/oraclebmc/core/models/update_drg_details.rb +0 -122
- data/lib/oraclebmc/core/models/update_image_details.rb +0 -124
- data/lib/oraclebmc/core/models/update_instance_details.rb +0 -124
- data/lib/oraclebmc/core/models/update_internet_gateway_details.rb +0 -133
- data/lib/oraclebmc/core/models/update_ip_sec_connection_details.rb +0 -122
- data/lib/oraclebmc/core/models/update_private_ip_details.rb +0 -157
- data/lib/oraclebmc/core/models/update_route_table_details.rb +0 -133
- data/lib/oraclebmc/core/models/update_security_list_details.rb +0 -144
- data/lib/oraclebmc/core/models/update_subnet_details.rb +0 -122
- data/lib/oraclebmc/core/models/update_vcn_details.rb +0 -122
- data/lib/oraclebmc/core/models/update_virtual_circuit_details.rb +0 -240
- data/lib/oraclebmc/core/models/update_vnic_details.rb +0 -144
- data/lib/oraclebmc/core/models/update_volume_backup_details.rb +0 -122
- data/lib/oraclebmc/core/models/update_volume_details.rb +0 -122
- data/lib/oraclebmc/core/models/vcn.rb +0 -276
- data/lib/oraclebmc/core/models/virtual_circuit.rb +0 -395
- data/lib/oraclebmc/core/models/virtual_circuit_bandwidth_shape.rb +0 -137
- data/lib/oraclebmc/core/models/vnic.rb +0 -287
- data/lib/oraclebmc/core/models/vnic_attachment.rb +0 -250
- data/lib/oraclebmc/core/models/volume.rb +0 -210
- data/lib/oraclebmc/core/models/volume_attachment.rb +0 -246
- data/lib/oraclebmc/core/models/volume_backup.rb +0 -235
- data/lib/oraclebmc/core/util.rb +0 -1
- data/lib/oraclebmc/core/virtual_network_client.rb +0 -3419
- data/lib/oraclebmc/errors.rb +0 -80
- data/lib/oraclebmc/global_context.rb +0 -21
- data/lib/oraclebmc/identity/identity.rb +0 -51
- data/lib/oraclebmc/identity/identity_client.rb +0 -1983
- data/lib/oraclebmc/identity/models/add_user_to_group_details.rb +0 -131
- data/lib/oraclebmc/identity/models/api_key.rb +0 -211
- data/lib/oraclebmc/identity/models/availability_domain.rb +0 -131
- data/lib/oraclebmc/identity/models/compartment.rb +0 -211
- data/lib/oraclebmc/identity/models/create_api_key_details.rb +0 -120
- data/lib/oraclebmc/identity/models/create_compartment_details.rb +0 -145
- data/lib/oraclebmc/identity/models/create_group_details.rb +0 -144
- data/lib/oraclebmc/identity/models/create_identity_provider_details.rb +0 -212
- data/lib/oraclebmc/identity/models/create_idp_group_mapping_details.rb +0 -133
- data/lib/oraclebmc/identity/models/create_policy_details.rb +0 -173
- data/lib/oraclebmc/identity/models/create_region_subscription_details.rb +0 -127
- data/lib/oraclebmc/identity/models/create_saml2_identity_provider_details.rb +0 -154
- data/lib/oraclebmc/identity/models/create_swift_password_details.rb +0 -121
- data/lib/oraclebmc/identity/models/create_user_details.rb +0 -144
- data/lib/oraclebmc/identity/models/group.rb +0 -211
- data/lib/oraclebmc/identity/models/identity_provider.rb +0 -256
- data/lib/oraclebmc/identity/models/idp_group_mapping.rb +0 -220
- data/lib/oraclebmc/identity/models/policy.rb +0 -237
- data/lib/oraclebmc/identity/models/region.rb +0 -141
- data/lib/oraclebmc/identity/models/region_subscription.rb +0 -178
- data/lib/oraclebmc/identity/models/saml2_identity_provider.rb +0 -180
- data/lib/oraclebmc/identity/models/swift_password.rb +0 -226
- data/lib/oraclebmc/identity/models/tenancy.rb +0 -158
- data/lib/oraclebmc/identity/models/ui_password.rb +0 -187
- data/lib/oraclebmc/identity/models/update_compartment_details.rb +0 -120
- data/lib/oraclebmc/identity/models/update_group_details.rb +0 -120
- data/lib/oraclebmc/identity/models/update_identity_provider_details.rb +0 -160
- data/lib/oraclebmc/identity/models/update_idp_group_mapping_details.rb +0 -131
- data/lib/oraclebmc/identity/models/update_policy_details.rb +0 -148
- data/lib/oraclebmc/identity/models/update_saml2_identity_provider_details.rb +0 -145
- data/lib/oraclebmc/identity/models/update_state_details.rb +0 -121
- data/lib/oraclebmc/identity/models/update_swift_password_details.rb +0 -120
- data/lib/oraclebmc/identity/models/update_user_details.rb +0 -120
- data/lib/oraclebmc/identity/models/user.rb +0 -217
- data/lib/oraclebmc/identity/models/user_group_membership.rb +0 -209
- data/lib/oraclebmc/identity/util.rb +0 -1
- data/lib/oraclebmc/internal/internal.rb +0 -11
- data/lib/oraclebmc/internal/util.rb +0 -69
- data/lib/oraclebmc/load_balancer/load_balancer.rb +0 -46
- data/lib/oraclebmc/load_balancer/load_balancer_client.rb +0 -1281
- data/lib/oraclebmc/load_balancer/models/backend.rb +0 -220
- data/lib/oraclebmc/load_balancer/models/backend_details.rb +0 -206
- data/lib/oraclebmc/load_balancer/models/backend_set.rb +0 -179
- data/lib/oraclebmc/load_balancer/models/backend_set_details.rb +0 -165
- data/lib/oraclebmc/load_balancer/models/certificate.rb +0 -167
- data/lib/oraclebmc/load_balancer/models/certificate_details.rb +0 -203
- data/lib/oraclebmc/load_balancer/models/create_backend_details.rb +0 -206
- data/lib/oraclebmc/load_balancer/models/create_backend_set_details.rb +0 -178
- data/lib/oraclebmc/load_balancer/models/create_certificate_details.rb +0 -203
- data/lib/oraclebmc/load_balancer/models/create_listener_details.rb +0 -174
- data/lib/oraclebmc/load_balancer/models/create_load_balancer_details.rb +0 -219
- data/lib/oraclebmc/load_balancer/models/health_checker.rb +0 -223
- data/lib/oraclebmc/load_balancer/models/health_checker_details.rb +0 -222
- data/lib/oraclebmc/load_balancer/models/ip_address.rb +0 -139
- data/lib/oraclebmc/load_balancer/models/listener.rb +0 -174
- data/lib/oraclebmc/load_balancer/models/listener_details.rb +0 -160
- data/lib/oraclebmc/load_balancer/models/load_balancer.rb +0 -280
- data/lib/oraclebmc/load_balancer/models/load_balancer_policy.rb +0 -120
- data/lib/oraclebmc/load_balancer/models/load_balancer_protocol.rb +0 -120
- data/lib/oraclebmc/load_balancer/models/load_balancer_shape.rb +0 -120
- data/lib/oraclebmc/load_balancer/models/session_persistence_configuration_details.rb +0 -141
- data/lib/oraclebmc/load_balancer/models/ssl_configuration.rb +0 -153
- data/lib/oraclebmc/load_balancer/models/ssl_configuration_details.rb +0 -153
- data/lib/oraclebmc/load_balancer/models/update_backend_details.rb +0 -178
- data/lib/oraclebmc/load_balancer/models/update_backend_set_details.rb +0 -165
- data/lib/oraclebmc/load_balancer/models/update_health_checker_details.rb +0 -221
- data/lib/oraclebmc/load_balancer/models/update_listener_details.rb +0 -160
- data/lib/oraclebmc/load_balancer/models/update_load_balancer_details.rb +0 -123
- data/lib/oraclebmc/load_balancer/models/work_request.rb +0 -229
- data/lib/oraclebmc/load_balancer/models/work_request_error.rb +0 -145
- data/lib/oraclebmc/load_balancer/util.rb +0 -55
- data/lib/oraclebmc/regions.rb +0 -41
- data/lib/oraclebmc/response.rb +0 -86
- data/lib/oraclebmc/signer.rb +0 -119
- data/lib/oraclebmc/version.rb +0 -5
- data/lib/oraclebmc/waiter.rb +0 -111
data/lib/oraclebmc/response.rb
DELETED
@@ -1,86 +0,0 @@
|
|
1
|
-
# Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
|
2
|
-
|
3
|
-
module OracleBMC
|
4
|
-
|
5
|
-
# A response, which represents all successful API calls.
|
6
|
-
class Response
|
7
|
-
# The HTTP status, such as 200, 401, etc
|
8
|
-
#
|
9
|
-
# @return [Integer]
|
10
|
-
attr_reader :status
|
11
|
-
|
12
|
-
# A hash containing all response headers
|
13
|
-
#
|
14
|
-
# @return [Hash]
|
15
|
-
attr_reader :headers
|
16
|
-
|
17
|
-
# The body of the response. For example, this
|
18
|
-
# may contain a User object, or a list of Users.
|
19
|
-
attr_reader :data
|
20
|
-
|
21
|
-
# The value of the next page token, if available,
|
22
|
-
# taken from the opc-next-page header.
|
23
|
-
#
|
24
|
-
# @return [String]
|
25
|
-
attr_reader :next_page
|
26
|
-
|
27
|
-
# The request ID, taken from the opc-request-id header.
|
28
|
-
#
|
29
|
-
# @return [String]
|
30
|
-
attr_reader :request_id
|
31
|
-
|
32
|
-
def initialize(status, headers, data)
|
33
|
-
@status = status
|
34
|
-
@headers = headers
|
35
|
-
@data = data
|
36
|
-
|
37
|
-
if headers
|
38
|
-
@next_page = headers["opc-next-page"]
|
39
|
-
@request_id = headers["opc-request-id"]
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
# Returns true if there is another page available.
|
44
|
-
def has_next_page?
|
45
|
-
return !next_page.nil?
|
46
|
-
end
|
47
|
-
|
48
|
-
include Enumerable
|
49
|
-
|
50
|
-
# For paged responses, yields each page until the last page is reached.
|
51
|
-
# For example:
|
52
|
-
#
|
53
|
-
# OracleBMC::Identity::IdentityClient.new.list_users(compartment, limit:'3').each { |r| r.data.each { |user| puts user.name }}
|
54
|
-
#
|
55
|
-
# The first response yielded is always the response that 'each' is being
|
56
|
-
# called on.
|
57
|
-
#
|
58
|
-
# If any of the requests result in an error, that error will be thrown
|
59
|
-
# as normal, which will abort the enumeration.
|
60
|
-
#
|
61
|
-
# While this can be called on non-paged responses, it will simply result
|
62
|
-
# in the response itself being yielded.
|
63
|
-
#
|
64
|
-
# @yieldparam [Response] response A response object for each page, starting with the response used to call 'each'.
|
65
|
-
def each
|
66
|
-
yield self
|
67
|
-
page = @next_page
|
68
|
-
|
69
|
-
while @api_call && page
|
70
|
-
next_response = @api_call.call(page)
|
71
|
-
|
72
|
-
if page == next_response.next_page
|
73
|
-
fail "Paging failure: Two consecutive responses had the same next page token."
|
74
|
-
end
|
75
|
-
|
76
|
-
page = next_response.next_page
|
77
|
-
yield next_response
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
def api_call=(c)
|
82
|
-
@api_call = c
|
83
|
-
end
|
84
|
-
|
85
|
-
end
|
86
|
-
end
|
data/lib/oraclebmc/signer.rb
DELETED
@@ -1,119 +0,0 @@
|
|
1
|
-
# Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
|
2
|
-
|
3
|
-
require 'base64'
|
4
|
-
require 'digest'
|
5
|
-
require 'openssl'
|
6
|
-
require 'securerandom'
|
7
|
-
require 'time'
|
8
|
-
require 'uri'
|
9
|
-
require 'cgi'
|
10
|
-
|
11
|
-
module OracleBMC
|
12
|
-
|
13
|
-
# Used to sign HTTP requests as required by Oracle Bare Metal Cloud services.
|
14
|
-
class Signer
|
15
|
-
|
16
|
-
# The Oracle Bare Metal Cloud Services API signature version
|
17
|
-
SIGNATURE_VERSION = "1"
|
18
|
-
|
19
|
-
# Creates a Signer
|
20
|
-
#
|
21
|
-
# @param [String] user OCID of the user to be used for authentication, for example "ocidv1:user:oc1:phx:1460406592659:aaaaaaaawcbqrkycbolrirg2n3xjl5fyxe".
|
22
|
-
# @param [String] fingerprint Fingerprint of the key used for authentication, for example "20:3b:97:13:55:1c:5b:0d:d3:37:d8:50:4e:c5:3a:34"
|
23
|
-
# @param [String] tenancy OCID of the tenancy
|
24
|
-
# @param [String] private_key_file Full path and filename of the unencrypted PEM file, for example "/Users/bgustafs/.ssh/id_rsa.pem"
|
25
|
-
# @param [String] pass_phrase Optional pass phrase used to encrypt the private key
|
26
|
-
def initialize(user, fingerprint, tenancy, private_key_file, pass_phrase:nil)
|
27
|
-
fail 'Missing required parameter user.' unless user
|
28
|
-
fail 'Missing required parameter fingerprint.' unless fingerprint
|
29
|
-
fail 'Missing required parameter tenancy.' unless tenancy
|
30
|
-
fail 'Missing required parameter private_key_file.' unless private_key_file
|
31
|
-
|
32
|
-
@key_id = tenancy + "/" + user + "/" + fingerprint
|
33
|
-
@private_key_file = private_key_file
|
34
|
-
@pass_phrase = pass_phrase
|
35
|
-
end
|
36
|
-
|
37
|
-
# Generates the correct signature and adds it to the
|
38
|
-
# headers that are passed in. Also injects any required
|
39
|
-
# headers that might be missing.
|
40
|
-
#
|
41
|
-
# @param [Symbol] method The HTTP method, such as :get or :post.
|
42
|
-
# @param [String] uri The URI, such as 'https://iaas.us-phoenix-1.oraclecloud.com/20160918/volumeAttachments/'
|
43
|
-
# @param [Hash] headers A hash of headers
|
44
|
-
# @param [String] body The request body
|
45
|
-
def sign(method, uri, headers, body)
|
46
|
-
method = method.to_sym.downcase
|
47
|
-
uri = URI(uri)
|
48
|
-
path = uri.query.nil? ? uri.path : "#{uri.path}?#{uri.query}"
|
49
|
-
inject_missing_headers(method, headers, body, uri)
|
50
|
-
signature = compute_signature(headers, method, path)
|
51
|
-
unless signature.nil?
|
52
|
-
inject_authorization_header(headers, method, signature)
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
private
|
57
|
-
|
58
|
-
GENERIC_HEADERS = [:"date", :"(request-target)", :"host"]
|
59
|
-
BODY_HEADERS = [:"content-length", :"content-type", :"x-content-sha256"]
|
60
|
-
|
61
|
-
OPERATION_HEADER_MAPPING = {
|
62
|
-
options: [],
|
63
|
-
get: GENERIC_HEADERS,
|
64
|
-
head: GENERIC_HEADERS,
|
65
|
-
delete: GENERIC_HEADERS,
|
66
|
-
put: GENERIC_HEADERS + BODY_HEADERS,
|
67
|
-
post: GENERIC_HEADERS + BODY_HEADERS
|
68
|
-
}
|
69
|
-
|
70
|
-
def inject_missing_headers(method, headers, body, uri)
|
71
|
-
headers["date"] ||= Time.now.utc.httpdate
|
72
|
-
headers["content-type"] ||= "application/json"
|
73
|
-
headers["accept"] ||= "*/*"
|
74
|
-
headers["host"] ||= uri.host
|
75
|
-
|
76
|
-
if method == :put || method == :post
|
77
|
-
body ||= ''
|
78
|
-
headers["content-length"] ||= body.length.to_s
|
79
|
-
headers["x-content-sha256"] ||= Digest::SHA256.base64digest(body)
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
def inject_authorization_header(headers, method, signature)
|
84
|
-
signed_headers = OPERATION_HEADER_MAPPING[method].map(&:to_s).join(" ")
|
85
|
-
headers["authorization"] = [
|
86
|
-
%(Signature headers="#{signed_headers}"),
|
87
|
-
%(keyId="#{@key_id}"),
|
88
|
-
%(algorithm="rsa-sha256"),
|
89
|
-
%(signature="#{signature}"),
|
90
|
-
%(version="#{SIGNATURE_VERSION}")
|
91
|
-
].join(",")
|
92
|
-
end
|
93
|
-
|
94
|
-
def compute_signature(headers, method, path)
|
95
|
-
return if OPERATION_HEADER_MAPPING[method].empty?
|
96
|
-
signing_string = OPERATION_HEADER_MAPPING[method].map do |header|
|
97
|
-
if header == :"(request-target)"
|
98
|
-
"#{header}: #{method.downcase} #{path}"
|
99
|
-
else
|
100
|
-
"#{header}: #{headers[header.to_s]}"
|
101
|
-
end
|
102
|
-
end.join("\n")
|
103
|
-
|
104
|
-
signature = private_key.sign(OpenSSL::Digest::SHA256.new, signing_string.encode("ascii"))
|
105
|
-
Base64.strict_encode64(signature)
|
106
|
-
end
|
107
|
-
|
108
|
-
def private_key
|
109
|
-
# If a pass_phase was not provided and the key is in fact encrypted, then passing in
|
110
|
-
# nil for the passphrase here will show a user prompt and block until there is a response.
|
111
|
-
# Passing in an empty string will work for some versions of Ruby's openssl wrapper, but
|
112
|
-
# other versions will enforce the 4 character password minimum at this point. Passing in
|
113
|
-
# a dummy password that's greater than 4 characters avoids both problems, and will
|
114
|
-
# always succeed if the file is not encrypted.
|
115
|
-
@private_key ||= OpenSSL::PKey::RSA.new(File.read(@private_key_file), @pass_phrase || SecureRandom.uuid)
|
116
|
-
end
|
117
|
-
end
|
118
|
-
|
119
|
-
end
|
data/lib/oraclebmc/version.rb
DELETED
data/lib/oraclebmc/waiter.rb
DELETED
@@ -1,111 +0,0 @@
|
|
1
|
-
# Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
|
2
|
-
|
3
|
-
module OracleBMC
|
4
|
-
module Waiter
|
5
|
-
module Errors
|
6
|
-
# Raised when a call to wait_until reaches the maximum wait time.
|
7
|
-
class MaximumWaitTimeExceededError < RuntimeError; end
|
8
|
-
|
9
|
-
# Raised when wait_until is called on a response that does not
|
10
|
-
# support waiters. Typically, waiters are only supported for
|
11
|
-
# get operations.
|
12
|
-
class WaitUntilNotSupportedError < RuntimeError; end
|
13
|
-
|
14
|
-
# If thrown from the yield statement of a waiter, it will cause the
|
15
|
-
# waiter to fail with this exception.
|
16
|
-
class WaiterFailedError < RuntimeError; end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
class Response
|
21
|
-
|
22
|
-
# Wait until the value of the given property in the response data has
|
23
|
-
# the given value. This will block the current thread until the
|
24
|
-
# the desired state is reached, the maximum wait time is reached, or the
|
25
|
-
# optional yield block throws :stop_succeed or :stop_fail. This is only
|
26
|
-
# supported for responses resulting from GET operations. A typical use
|
27
|
-
# case is to wait on an instance until it is in a running state:
|
28
|
-
#
|
29
|
-
# compute_client.get_instance(@instance_id).wait_until(:lifecycle_state, OracleBMC::Core::Models::Instance::LIFECYCLE_STATE_RUNNING)
|
30
|
-
#
|
31
|
-
# Although this can be run on any property of the data resulting from any
|
32
|
-
# GET operation, the most common use case is to check state properties on
|
33
|
-
# operations that GET a single object.
|
34
|
-
#
|
35
|
-
# The wait will poll at an increasing interval up to 'max_interval_seconds'
|
36
|
-
# for a maximum total time of 'max_wait_seconds'. If the maximum time
|
37
|
-
# is exceeded, then it will raise a {OracleBMC::Waiter::Errors::MaximumWaitTimeExceededError}.
|
38
|
-
#
|
39
|
-
# On successful completion the final Response object will be returned. The
|
40
|
-
# original Response object will not be altered.
|
41
|
-
#
|
42
|
-
# If any responses result in an error, then the error will be thrown as normal
|
43
|
-
# resulting in the wait being aborted.
|
44
|
-
#
|
45
|
-
# @param [Symbol] property The property of the response data to evaluate. For example, :lifecycle_state.
|
46
|
-
# @param state The value of the property that will indicate successful completion of the wait.
|
47
|
-
# @param [Integer] max_interval_seconds The maximum interval between queries, in seconds.
|
48
|
-
# @param [Integer] max_wait_seconds The maximum time to wait, in seconds.
|
49
|
-
# @yieldparam [Response] response A response object for every additional successful call to the get request.
|
50
|
-
# Throw :stop_succeed from the yield to stop the waiter and return the current response.
|
51
|
-
# Throw :stop_fail from the yield to stop the waiter and throw a WaiterFailedError.
|
52
|
-
# @return [Response] The final response, which will contain the property in the specified state.
|
53
|
-
def wait_until(property, state, max_interval_seconds: 30, max_wait_seconds: 1200)
|
54
|
-
fail 'Cannot wait on a response without data.' unless self.data
|
55
|
-
fail 'Response data does not contain the given property.' unless self.data.methods.include? property
|
56
|
-
|
57
|
-
raise Waiter::Errors::WaitUntilNotSupportedError.new('wait_until is not supported by this response.') unless @api_call
|
58
|
-
|
59
|
-
response = self
|
60
|
-
count = 0
|
61
|
-
interval_seconds = 1
|
62
|
-
start_time = Time.now
|
63
|
-
|
64
|
-
while true
|
65
|
-
if response.data.send(property) == state
|
66
|
-
return response
|
67
|
-
end
|
68
|
-
|
69
|
-
elapsed_seconds = (Time.now - start_time).to_i
|
70
|
-
|
71
|
-
if elapsed_seconds + interval_seconds > max_wait_seconds
|
72
|
-
if max_wait_seconds > elapsed_seconds
|
73
|
-
# Make one last request right at the maximum wait time.
|
74
|
-
interval_seconds = max_wait_seconds - elapsed_seconds
|
75
|
-
else
|
76
|
-
raise Waiter::Errors::MaximumWaitTimeExceededError.new('Maximum wait time has been exceeded.')
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
sleep(interval_seconds)
|
81
|
-
|
82
|
-
interval_seconds *= 2
|
83
|
-
if interval_seconds > max_interval_seconds
|
84
|
-
interval_seconds = max_interval_seconds
|
85
|
-
end
|
86
|
-
|
87
|
-
response = @api_call.call(nil)
|
88
|
-
|
89
|
-
if block_given?
|
90
|
-
continue = false
|
91
|
-
catch(:stop_fail) {
|
92
|
-
catch(:stop_succeed) {
|
93
|
-
yield response
|
94
|
-
continue = true
|
95
|
-
}
|
96
|
-
|
97
|
-
if not continue
|
98
|
-
return response
|
99
|
-
end
|
100
|
-
}
|
101
|
-
|
102
|
-
if not continue
|
103
|
-
raise Waiter::Errors::WaiterFailedError
|
104
|
-
end
|
105
|
-
end
|
106
|
-
end
|
107
|
-
|
108
|
-
end
|
109
|
-
|
110
|
-
end
|
111
|
-
end
|