fog-oraclecloud 0.1.12 → 0.1.13

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 (142) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +12 -10
  3. data/Gemfile +4 -4
  4. data/LICENSE +20 -20
  5. data/README.md +153 -153
  6. data/Rakefile +2 -2
  7. data/bin/console +14 -14
  8. data/bin/setup +8 -8
  9. data/fog-oracle.gemspec +32 -31
  10. data/lib/fog/oraclecloud.rb +29 -29
  11. data/lib/fog/oraclecloud/compute.rb +184 -184
  12. data/lib/fog/oraclecloud/database.rb +129 -129
  13. data/lib/fog/oraclecloud/java.rb +123 -115
  14. data/lib/fog/oraclecloud/models/compute/image.rb +43 -43
  15. data/lib/fog/oraclecloud/models/compute/image_list.rb +39 -39
  16. data/lib/fog/oraclecloud/models/compute/image_lists.rb +22 -22
  17. data/lib/fog/oraclecloud/models/compute/images.rb +22 -22
  18. data/lib/fog/oraclecloud/models/compute/instance.rb +74 -69
  19. data/lib/fog/oraclecloud/models/compute/instances.rb +22 -22
  20. data/lib/fog/oraclecloud/models/compute/object_plan.rb +16 -16
  21. data/lib/fog/oraclecloud/models/compute/object_plans.rb +12 -12
  22. data/lib/fog/oraclecloud/models/compute/orchestration.rb +89 -89
  23. data/lib/fog/oraclecloud/models/compute/orchestrations.rb +20 -20
  24. data/lib/fog/oraclecloud/models/compute/security_application.rb +42 -42
  25. data/lib/fog/oraclecloud/models/compute/security_applications.rb +22 -22
  26. data/lib/fog/oraclecloud/models/compute/security_list.rb +26 -26
  27. data/lib/fog/oraclecloud/models/compute/security_lists.rb +22 -22
  28. data/lib/fog/oraclecloud/models/compute/security_rule.rb +41 -41
  29. data/lib/fog/oraclecloud/models/compute/security_rules.rb +22 -22
  30. data/lib/fog/oraclecloud/models/compute/ssh_key.rb +37 -37
  31. data/lib/fog/oraclecloud/models/compute/ssh_keys.rb +22 -22
  32. data/lib/fog/oraclecloud/models/compute/volume.rb +47 -47
  33. data/lib/fog/oraclecloud/models/compute/volumes.rb +20 -20
  34. data/lib/fog/oraclecloud/models/database/backup.rb +37 -37
  35. data/lib/fog/oraclecloud/models/database/backups.rb +30 -30
  36. data/lib/fog/oraclecloud/models/database/instance.rb +331 -331
  37. data/lib/fog/oraclecloud/models/database/instances.rb +25 -25
  38. data/lib/fog/oraclecloud/models/database/patch.rb +34 -34
  39. data/lib/fog/oraclecloud/models/database/patches.rb +18 -18
  40. data/lib/fog/oraclecloud/models/database/recoveries.rb +26 -26
  41. data/lib/fog/oraclecloud/models/database/recovery.rb +43 -43
  42. data/lib/fog/oraclecloud/models/database/server.rb +28 -28
  43. data/lib/fog/oraclecloud/models/database/servers.rb +18 -18
  44. data/lib/fog/oraclecloud/models/database/snapshot.rb +60 -60
  45. data/lib/fog/oraclecloud/models/database/snapshots.rb +22 -22
  46. data/lib/fog/oraclecloud/models/java/database.rb +17 -17
  47. data/lib/fog/oraclecloud/models/java/databases.rb +17 -17
  48. data/lib/fog/oraclecloud/models/java/instance.rb +269 -265
  49. data/lib/fog/oraclecloud/models/java/instances.rb +23 -23
  50. data/lib/fog/oraclecloud/models/java/server.rb +62 -62
  51. data/lib/fog/oraclecloud/models/java/servers.rb +25 -25
  52. data/lib/fog/oraclecloud/models/soa/instance.rb +163 -163
  53. data/lib/fog/oraclecloud/models/soa/instances.rb +54 -54
  54. data/lib/fog/oraclecloud/models/storage/container.rb +33 -33
  55. data/lib/fog/oraclecloud/models/storage/containers.rb +24 -24
  56. data/lib/fog/oraclecloud/models/storage/object.rb +27 -27
  57. data/lib/fog/oraclecloud/models/storage/objects.rb +27 -27
  58. data/lib/fog/oraclecloud/requests/compute/create_image.rb +30 -30
  59. data/lib/fog/oraclecloud/requests/compute/create_image_list.rb +27 -27
  60. data/lib/fog/oraclecloud/requests/compute/create_instance.rb +53 -53
  61. data/lib/fog/oraclecloud/requests/compute/create_orchestration.rb +82 -82
  62. data/lib/fog/oraclecloud/requests/compute/create_security_application.rb +28 -28
  63. data/lib/fog/oraclecloud/requests/compute/create_security_rule.rb +29 -29
  64. data/lib/fog/oraclecloud/requests/compute/create_ssh_key.rb +46 -46
  65. data/lib/fog/oraclecloud/requests/compute/create_volume.rb +28 -28
  66. data/lib/fog/oraclecloud/requests/compute/delete_image.rb +19 -19
  67. data/lib/fog/oraclecloud/requests/compute/delete_image_list.rb +19 -19
  68. data/lib/fog/oraclecloud/requests/compute/delete_instance.rb +33 -33
  69. data/lib/fog/oraclecloud/requests/compute/delete_orchestration.rb +36 -36
  70. data/lib/fog/oraclecloud/requests/compute/delete_security_application.rb +20 -20
  71. data/lib/fog/oraclecloud/requests/compute/delete_security_rule.rb +20 -20
  72. data/lib/fog/oraclecloud/requests/compute/delete_ssh_key.rb +32 -32
  73. data/lib/fog/oraclecloud/requests/compute/get_image.rb +21 -21
  74. data/lib/fog/oraclecloud/requests/compute/get_image_list.rb +21 -21
  75. data/lib/fog/oraclecloud/requests/compute/get_instance.rb +45 -45
  76. data/lib/fog/oraclecloud/requests/compute/get_orchestration.rb +39 -39
  77. data/lib/fog/oraclecloud/requests/compute/get_security_application.rb +20 -20
  78. data/lib/fog/oraclecloud/requests/compute/get_security_rule.rb +20 -20
  79. data/lib/fog/oraclecloud/requests/compute/get_ssh_key.rb +39 -39
  80. data/lib/fog/oraclecloud/requests/compute/list_image_lists.rb +29 -29
  81. data/lib/fog/oraclecloud/requests/compute/list_images.rb +16 -16
  82. data/lib/fog/oraclecloud/requests/compute/list_instances.rb +28 -28
  83. data/lib/fog/oraclecloud/requests/compute/list_orchestrations.rb +28 -28
  84. data/lib/fog/oraclecloud/requests/compute/list_security_applications.rb +21 -21
  85. data/lib/fog/oraclecloud/requests/compute/list_security_lists.rb +16 -16
  86. data/lib/fog/oraclecloud/requests/compute/list_security_rules.rb +21 -21
  87. data/lib/fog/oraclecloud/requests/compute/list_ssh_keys.rb +29 -29
  88. data/lib/fog/oraclecloud/requests/compute/list_volumes.rb +16 -16
  89. data/lib/fog/oraclecloud/requests/compute/start_orchestration.rb +39 -39
  90. data/lib/fog/oraclecloud/requests/compute/stop_orchestration.rb +39 -39
  91. data/lib/fog/oraclecloud/requests/compute/update_image.rb +27 -27
  92. data/lib/fog/oraclecloud/requests/compute/update_image_list.rb +27 -27
  93. data/lib/fog/oraclecloud/requests/compute/update_orchestration.rb +80 -80
  94. data/lib/fog/oraclecloud/requests/compute/update_ssh_key.rb +49 -49
  95. data/lib/fog/oraclecloud/requests/database/backup_instance.rb +45 -45
  96. data/lib/fog/oraclecloud/requests/database/create_instance.rb +101 -101
  97. data/lib/fog/oraclecloud/requests/database/create_snapshot.rb +50 -50
  98. data/lib/fog/oraclecloud/requests/database/delete_instance.rb +26 -26
  99. data/lib/fog/oraclecloud/requests/database/delete_snapshot.rb +26 -26
  100. data/lib/fog/oraclecloud/requests/database/get_instance.rb +62 -62
  101. data/lib/fog/oraclecloud/requests/database/get_instance_from_job.rb +31 -31
  102. data/lib/fog/oraclecloud/requests/database/get_snapshot.rb +43 -43
  103. data/lib/fog/oraclecloud/requests/database/list_backups.rb +39 -39
  104. data/lib/fog/oraclecloud/requests/database/list_instances.rb +29 -29
  105. data/lib/fog/oraclecloud/requests/database/list_patches.rb +51 -51
  106. data/lib/fog/oraclecloud/requests/database/list_recoveries.rb +40 -40
  107. data/lib/fog/oraclecloud/requests/database/list_servers.rb +27 -27
  108. data/lib/fog/oraclecloud/requests/database/list_snapshots.rb +27 -27
  109. data/lib/fog/oraclecloud/requests/database/recover_instance.rb +83 -83
  110. data/lib/fog/oraclecloud/requests/database/scale_instance.rb +40 -40
  111. data/lib/fog/oraclecloud/requests/java/create_instance.rb +156 -87
  112. data/lib/fog/oraclecloud/requests/java/delete_instance.rb +37 -37
  113. data/lib/fog/oraclecloud/requests/java/get_instance.rb +43 -43
  114. data/lib/fog/oraclecloud/requests/java/get_server.rb +42 -42
  115. data/lib/fog/oraclecloud/requests/java/list_instances.rb +29 -29
  116. data/lib/fog/oraclecloud/requests/java/list_servers.rb +30 -30
  117. data/lib/fog/oraclecloud/requests/java/scale_a_node.rb +45 -45
  118. data/lib/fog/oraclecloud/requests/java/scale_in_a_cluster.rb +35 -35
  119. data/lib/fog/oraclecloud/requests/java/scale_out_a_cluster.rb +38 -38
  120. data/lib/fog/oraclecloud/requests/soa/create_instance.rb +71 -71
  121. data/lib/fog/oraclecloud/requests/soa/delete_instance.rb +35 -35
  122. data/lib/fog/oraclecloud/requests/soa/get_instance.rb +42 -42
  123. data/lib/fog/oraclecloud/requests/soa/get_job_status.rb +22 -22
  124. data/lib/fog/oraclecloud/requests/soa/list_instances.rb +29 -29
  125. data/lib/fog/oraclecloud/requests/storage/create_container.rb +41 -41
  126. data/lib/fog/oraclecloud/requests/storage/delete_container.rb +15 -15
  127. data/lib/fog/oraclecloud/requests/storage/get_container.rb +63 -63
  128. data/lib/fog/oraclecloud/requests/storage/list_containers.rb +27 -27
  129. data/lib/fog/oraclecloud/soa.rb +106 -106
  130. data/lib/fog/oraclecloud/storage.rb +98 -98
  131. data/lib/fog/oraclecloud/version.rb +5 -5
  132. data/tests/helper.rb +5 -3
  133. data/tests/helpers/mock_helper.rb +14 -14
  134. data/tests/requests/compute_tests.rb +9 -9
  135. data/tests/requests/database_tests.rb +241 -241
  136. data/tests/requests/instance_tests.rb +68 -61
  137. data/tests/requests/java_tests.rb +149 -109
  138. data/tests/requests/orchestrations_tests.rb +90 -90
  139. data/tests/requests/soa_tests.rb +151 -151
  140. data/tests/requests/ssh_keys_tests.rb +53 -53
  141. data/tests/requests/storage_tests.rb +54 -54
  142. metadata +17 -3
@@ -1,22 +1,22 @@
1
- require 'fog/core/collection'
2
-
3
- module Fog
4
- module OracleCloud
5
- class Database
6
- class Snapshots < Fog::Collection
7
-
8
- model Fog::OracleCloud::Database::Snapshot
9
-
10
- def all(db_name)
11
- data = service.list_snapshots(db_name).body
12
- load(data)
13
- end
14
-
15
- def get(db_name, snapshot_name)
16
- new(service.get_snapshot(db_name, snapshot_name).body)
17
- end
18
-
19
- end
20
- end
21
- end
22
- end
1
+ require 'fog/core/collection'
2
+
3
+ module Fog
4
+ module OracleCloud
5
+ class Database
6
+ class Snapshots < Fog::Collection
7
+
8
+ model Fog::OracleCloud::Database::Snapshot
9
+
10
+ def all(db_name)
11
+ data = service.list_snapshots(db_name).body
12
+ load(data)
13
+ end
14
+
15
+ def get(db_name, snapshot_name)
16
+ new(service.get_snapshot(db_name, snapshot_name).body)
17
+ end
18
+
19
+ end
20
+ end
21
+ end
22
+ end
@@ -1,17 +1,17 @@
1
- require 'fog/compute/models/server'
2
-
3
- module Fog
4
- module OracleCloud
5
- class Java
6
- class Database < Fog::Model
7
- identity :service_name
8
-
9
- attribute :infra
10
- attribute :connect_string
11
- attribute :version
12
- attribute :pdb
13
-
14
- end
15
- end
16
- end
17
- end
1
+ require 'fog/compute/models/server'
2
+
3
+ module Fog
4
+ module OracleCloud
5
+ class Java
6
+ class Database < Fog::Model
7
+ identity :service_name
8
+
9
+ attribute :infra
10
+ attribute :connect_string
11
+ attribute :version
12
+ attribute :pdb
13
+
14
+ end
15
+ end
16
+ end
17
+ end
@@ -1,17 +1,17 @@
1
- require 'fog/core/collection'
2
-
3
- module Fog
4
- module OracleCloud
5
- class Java
6
- class Databases < Fog::Collection
7
-
8
- model Fog::OracleCloud::Java::Database
9
-
10
- def all(service_name)
11
- # data = service.list_databases(service_name).body['servers']
12
- # load(data)
13
- end
14
- end
15
- end
16
- end
17
- end
1
+ require 'fog/core/collection'
2
+
3
+ module Fog
4
+ module OracleCloud
5
+ class Java
6
+ class Databases < Fog::Collection
7
+
8
+ model Fog::OracleCloud::Java::Database
9
+
10
+ def all(service_name)
11
+ # data = service.list_databases(service_name).body['servers']
12
+ # load(data)
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -1,265 +1,269 @@
1
- require 'fog/core/model'
2
-
3
- module Fog
4
- module OracleCloud
5
- class Java
6
- class Instance < Fog::Model
7
- identity :service_name, :aliases=>['name', 'serviceName']
8
-
9
-
10
- attribute :created_by
11
-
12
- attribute :auto_update
13
- attribute :cluster_name, :aliases=>'clusterName'
14
- attribute :compliance_status
15
- attribute :compliance_status_desc
16
- attribute :compute_site_name
17
- attribute :content_url
18
- attribute :creation_job_id
19
- attribute :creation_time
20
- attribute :db_associations
21
- attribute :db_info
22
- attribute :db_service_name
23
- attribute :deletion_job_id
24
- attribute :description
25
- attribute :domain_mode, :aliases=>'domainMode'
26
- attribute :edition
27
- attribute :error_status_desc
28
- attribute :fmw_control_url
29
- attribute :last_modified_time
30
- attribute :level
31
- attribute :lifecycle_control_job_id
32
- attribute :num_ip_reservations
33
- attribute :num_nodes, :aliases=>'managedServerCount'
34
- attribute :options
35
- attribute :otd_admin_url
36
- attribute :otd_provisioned
37
- attribute :otd_shape
38
- attribute :otd_strorage_size
39
- attribute :psm_plugin_version
40
- attribute :sample_app_url
41
- attribute :secure_content_url
42
- attribute :service_components
43
- attribute :service_type
44
- attribute :service_uri
45
- attribute :shape
46
- attribute :status
47
- attribute :subscription_type, :aliases=>['subscriptionType']
48
- attribute :uri
49
- attribute :version
50
- attribute :wls_admin_url
51
- attribute :wls_deployment_channel_port
52
- attribute :wls_version, :aliases=>'wlsVersion'
53
- attribute :domain_name, :aliases=>'domainName'
54
- attribute :pdb_name, :aliases=>['pdbName', 'pdb_service_name']
55
-
56
-
57
- # The following are only used to create an instance and are not returned in the list action
58
- attribute :cloud_storage_container, :aliases=>'cloudStorageContainer'
59
- attribute :cloud_storage_user, :aliases=>'cloudStorageUser'
60
- attribute :cloud_storage_pwd, :aliases=>'cloudStoragePassword'
61
- attribute :admin_username, :aliases=>'adminUserName'
62
- attribute :admin_password, :aliases=>'adminPassword'
63
- attribute :ssh_key, :aliases=>'vmPublicKey'
64
- attribute :cloud_storage_container_if_missing, :aliases=>'cloudStorageContainerIfMissing'
65
- attribute :enable_admin_console, :aliases=>'enableAdminConsole'
66
- attribute :provision_otd, :aliases=>'provisionOTD'
67
- attribute :sample_app_deployment_requested, :aliases=>'sampleAppDeploymentRequested'
68
- attribute :admin_port, :aliases=>'adminPort'
69
- attribute :app_dbs, :aliases=>'appDBs'
70
- attribute :backup_volume_size, :aliases=>'backupVolumeSize'
71
- attribute :content_port, :aliases=>'contentPort'
72
- attribute :dba_name, :aliases=>'dbaName'
73
- attribute :dba_password, :aliases=>'dbaPassword'
74
- attribute :domain_partition_count, :aliases=>'domainPartitionCount'
75
- attribute :domain_volume_size, :aliases=>'domainVolumeSize'
76
- attribute :ip_reservations, :aliases=>'ipReservations'
77
- attribute :ms_initial_heap_mb, :aliases=>'msInitialHeapMB'
78
- attribute :ms_jvm_args, :aliases=>'msJvmArgs'
79
- attribute :ms_max_heap_mb, :aliases=>'msMaxHeapMB'
80
- attribute :ms_max_perm_mb, :aliases=>'msMaxPermMB'
81
- attribute :ms_perm_mb, :aliases=>'msPermMb'
82
- attribute :node_manager_password, :aliases=>'nodeManagerPassword'
83
- attribute :node_manager_port, :aliases=>'nodeManagerPort'
84
- attribute :node_manager_user_name, :aliases=>'nodeManagerUserName'
85
- attribute :overwrite_ms_jvm_args, :aliases=>'overwriteMsJvmArgs'
86
- attribute :secured_admin_port, :aliases=>'securedAdminPort'
87
- attribute :secured_content_port, :aliases=>'securedContentPort'
88
-
89
- # The following are used to delete an instance and are not returned in the list action
90
- attribute :force_delete
91
-
92
- def level=(value)
93
- if %w(PAAS BASIC).include? value then
94
- attributes[:level]=value
95
- else
96
- raise ArgumentError, "Invalid level. Valid values - PAAS or BASIC"
97
- end
98
- end
99
-
100
- def subscription_type=(value)
101
- if %w(HOURLY MONTHLY).include? value then
102
- attributes[:subscription_type]=value
103
- else
104
- raise ArgumentError, "Invalid subscription type. Valid values - HOURLY or MONTHLY"
105
- end
106
- end
107
-
108
- def domain_mode=(value)
109
- if value.to_s == '' then value = 'DEVELOPMENT' end
110
- if %w(DEVELOPMENT PRODUCTION).include? value then
111
- attributes[:domain_mode]=value
112
- else
113
- raise ArgumentError, "Invalid domain mode '#{value}'. Valid values - DEVELOPMENT or PRODUCTION"
114
- end
115
- end
116
-
117
- def edition=(value)
118
- if value.to_s == '' then value = 'EE' end
119
- if %w(SE EE SUITE).include? value then
120
- attributes[:edition]=value
121
- else
122
- raise ArgumentError, "Invalid edition. Valid values - SE, EE or SUITE"
123
- end
124
- end
125
-
126
-
127
- def shape=(value)
128
- if %w(oc3 oc4 oc5 oc6 oc1m oc2m oc3m oc4m).include? value then
129
- attributes[:shape]=value
130
- else
131
- raise ArgumentError, "Invalid Shape. Valid values - oc3, oc4, oc5, oc6, oc1m, oc2m, oc3m or oc4m"
132
- end
133
- end
134
-
135
- def num_nodes=(value)
136
- if value.nil? then value = 1 end
137
- if value.to_i.is_a? Integer then
138
- attributes[:num_nodes] = value.to_i
139
- else
140
- raise ArgumentError, "Invalid server count (#{value}). Valid values - 1, 2, 4 or 8"
141
- end
142
- end
143
-
144
- def initialize(attributes={})
145
- level ||= 'PAAS'
146
- subscription_type ||= 'HOURLY'
147
- edition ||= 'EE'
148
-
149
- super
150
- end
151
-
152
- def save
153
- #identity ? update : create
154
- create
155
- end
156
-
157
- def ready?
158
- status == "Running"
159
- end
160
-
161
- def stopping?
162
- status == 'Maintenance' || status == 'Terminating'
163
- end
164
-
165
- def stopped?
166
- status == 'Stopped'
167
- end
168
-
169
- def servers
170
- service.servers.all(service_name)
171
- end
172
-
173
- def destroy
174
- requires :service_name, :dba_name, :dba_password
175
- service.delete_instance(service_name, dba_name, dba_password, :force_delete => force_delete).body
176
- end
177
-
178
- def scale_out_a_cluster(cluster_name, create_cluster_if_missing)
179
- requires :service_name
180
- service.scale_out_a_cluster(service_name, cluster_name, create_cluster_if_missing).body
181
- end
182
-
183
- private
184
-
185
- def create
186
- requires :service_name, :dba_name, :dba_password, :db_service_name, :shape, :version, :ssh_key, :admin_password, :admin_username
187
-
188
- #data = service.create_instance(service_name, cloud_storage_container, cloud_storage_user, cloud_storage_password, dba_name, dba_password, db_servicename, shape, version, vm_public_key,
189
- # :level => level,
190
- # :subscriptionType => subscription_type,
191
- # :description => description)
192
-
193
- if cloud_storage_container.nil? then
194
- cloud_storage_if_missing = true
195
- stor_name = "#{service_name}_Backup"
196
- else
197
- stor_name = cloud_storage_container
198
- end
199
- stor_user = cloud_storage_user || service.username
200
- stor_pwd = cloud_storage_pwd || service.password
201
-
202
- params = {
203
- :serviceName => service_name,
204
- :cloudStorageContainer => stor_name,
205
- :cloudStoragePassword => stor_user,
206
- :cloudStorageUser => stor_pwd,
207
- :cloudStorageContainerIfMissing => cloud_storage_if_missing,
208
- :description => description,
209
- :enableAdminConsole => enable_admin_console.nil? ? true : enable_admin_console,
210
- :provisionOTD => provision_otd.nil? ? true : provision_otd,
211
- :sampleAppDeploymentRequested => sample_app_deployment_requested.nil? ? true : sample_app_deployment_requested,
212
- :subscriptionType => subscription_type || 'HOURLY',
213
- :level => level || 'PAAS',
214
- }
215
- options = {
216
- :adminPassword => admin_password,
217
- :adminPort => admin_port,
218
- :adminUserName => admin_username,
219
- :backupVolumeSize => backup_volume_size,
220
- :clusterName => cluster_name,
221
- :contentPort => content_port,
222
- :dbaName => dba_name,
223
- :dbaPassword => dba_password,
224
- :dbServiceName => db_service_name,
225
- :deploymentChannelPort => wls_deployment_channel_port,
226
- :domainMode => domain_mode,
227
- :domainName => domain_name,
228
- :domainPartitionCount => domain_partition_count,
229
- :domainVolumeSize => domain_volume_size,
230
- :edition => edition || 'EE',
231
- :ipReservations => ip_reservations,
232
- :managedServerCount => num_nodes || 1,
233
- :msInitialHeapMB => ms_initial_heap_mb,
234
- :msJvmArgs => ms_jvm_args,
235
- :msMaxHeapMB => ms_max_heap_mb,
236
- :msMaxPermMB => ms_max_perm_mb,
237
- :msPermMb => ms_perm_mb,
238
- :nodeManagerPassword => node_manager_password,
239
- :nodeManagerPort => node_manager_port,
240
- :nodeManagerUserName => node_manager_user_name,
241
- :overwriteMsJvmArgs => overwrite_ms_jvm_args,
242
- :pdbName => pdb_name,
243
- :securedAdminPort => secured_admin_port,
244
- :securedContentPort => secured_content_port,
245
- :shape => shape,
246
- :VMsPublicKey => ssh_key,
247
- :version => version
248
- }
249
-
250
- if app_dbs and app_dbs.is_a? Array and app_dbs.size >= 1
251
- options[:appDBs] = []
252
- app_dbs.each { |db| options[:appDBs].push({
253
- :dbaName => db.username,
254
- :dbaPassword => db.password,
255
- :dbServiceName => db.service_name,
256
- }) }
257
- end
258
- data = service.create_instance(params, options)
259
-
260
- end
261
-
262
- end
263
- end
264
- end
265
- end
1
+ require 'fog/core/model'
2
+
3
+ module Fog
4
+ module OracleCloud
5
+ class Java
6
+ class Instance < Fog::Model
7
+ identity :service_name, :aliases=>['name', 'serviceName']
8
+
9
+
10
+ attribute :created_by
11
+
12
+ attribute :auto_update
13
+ attribute :cluster_name, :aliases=>'clusterName'
14
+ attribute :compliance_status
15
+ attribute :compliance_status_desc
16
+ attribute :compute_site_name
17
+ attribute :content_url
18
+ attribute :creation_job_id
19
+ attribute :creation_time
20
+ attribute :db_associations
21
+ attribute :db_info
22
+ attribute :db_service_name
23
+ attribute :deletion_job_id
24
+ attribute :description
25
+ attribute :domain_mode, :aliases=>'domainMode'
26
+ attribute :edition
27
+ attribute :error_status_desc
28
+ attribute :fmw_control_url
29
+ attribute :last_modified_time
30
+ attribute :level
31
+ attribute :lifecycle_control_job_id
32
+ attribute :num_ip_reservations
33
+ attribute :num_nodes, :aliases=>'managedServerCount'
34
+ attribute :options
35
+ attribute :otd_admin_url
36
+ attribute :otd_provisioned
37
+ attribute :otd_shape
38
+ attribute :otd_strorage_size
39
+ attribute :psm_plugin_version
40
+ attribute :sample_app_url
41
+ attribute :secure_content_url
42
+ attribute :service_components
43
+ attribute :service_type
44
+ attribute :service_uri
45
+ attribute :shape
46
+ attribute :status
47
+ attribute :subscription_type, :aliases=>['subscriptionType']
48
+ attribute :uri
49
+ attribute :version
50
+ attribute :wls_admin_url
51
+ attribute :wls_deployment_channel_port
52
+ attribute :wls_version, :aliases=>'wlsVersion'
53
+ attribute :domain_name, :aliases=>'domainName'
54
+ attribute :pdb_name, :aliases=>['pdbName', 'pdb_service_name']
55
+
56
+
57
+ # The following are only used to create an instance and are not returned in the list action
58
+ attribute :cloud_storage_container, :aliases=>'cloudStorageContainer'
59
+ attribute :cloud_storage_user, :aliases=>'cloudStorageUser'
60
+ attribute :cloud_storage_pwd, :aliases=>'cloudStoragePassword'
61
+ attribute :admin_username, :aliases=>'adminUserName'
62
+ attribute :admin_password, :aliases=>'adminPassword'
63
+ attribute :ssh_key, :aliases=>'vmPublicKey'
64
+ attribute :cloud_storage_container_if_missing, :aliases=>'cloudStorageContainerIfMissing'
65
+ attribute :enable_admin_console, :aliases=>'enableAdminConsole'
66
+ attribute :provision_otd, :aliases=>'provisionOTD'
67
+ attribute :sample_app_deployment_requested, :aliases=>'sampleAppDeploymentRequested'
68
+ attribute :admin_port, :aliases=>'adminPort'
69
+ attribute :app_dbs, :aliases=>'appDBs'
70
+ attribute :backup_volume_size, :aliases=>'backupVolumeSize'
71
+ attribute :content_port, :aliases=>'contentPort'
72
+ attribute :dba_name, :aliases=>'dbaName'
73
+ attribute :dba_password, :aliases=>'dbaPassword'
74
+ attribute :domain_partition_count, :aliases=>'domainPartitionCount'
75
+ attribute :domain_volume_size, :aliases=>'domainVolumeSize'
76
+ attribute :ip_reservations, :aliases=>'ipReservations'
77
+ attribute :ms_initial_heap_mb, :aliases=>'msInitialHeapMB'
78
+ attribute :ms_jvm_args, :aliases=>'msJvmArgs'
79
+ attribute :ms_max_heap_mb, :aliases=>'msMaxHeapMB'
80
+ attribute :ms_max_perm_mb, :aliases=>'msMaxPermMB'
81
+ attribute :ms_perm_mb, :aliases=>'msPermMb'
82
+ attribute :node_manager_password, :aliases=>'nodeManagerPassword'
83
+ attribute :node_manager_port, :aliases=>'nodeManagerPort'
84
+ attribute :node_manager_user_name, :aliases=>'nodeManagerUserName'
85
+ attribute :overwrite_ms_jvm_args, :aliases=>'overwriteMsJvmArgs'
86
+ attribute :secured_admin_port, :aliases=>'securedAdminPort'
87
+ attribute :secured_content_port, :aliases=>'securedContentPort'
88
+
89
+ # The following are used to delete an instance and are not returned in the list action
90
+ attribute :force_delete
91
+
92
+ def level=(value)
93
+ if %w(PAAS BASIC).include? value then
94
+ attributes[:level]=value
95
+ else
96
+ raise ArgumentError, "Invalid level. Valid values - PAAS or BASIC"
97
+ end
98
+ end
99
+
100
+ def subscription_type=(value)
101
+ if %w(HOURLY MONTHLY).include? value then
102
+ attributes[:subscription_type]=value
103
+ else
104
+ raise ArgumentError, "Invalid subscription type. Valid values - HOURLY or MONTHLY"
105
+ end
106
+ end
107
+
108
+ def domain_mode=(value)
109
+ if value.to_s == '' then value = 'DEVELOPMENT' end
110
+ if %w(DEVELOPMENT PRODUCTION).include? value then
111
+ attributes[:domain_mode]=value
112
+ else
113
+ raise ArgumentError, "Invalid domain mode '#{value}'. Valid values - DEVELOPMENT or PRODUCTION"
114
+ end
115
+ end
116
+
117
+ def edition=(value)
118
+ if value.to_s == '' then value = 'EE' end
119
+ if %w(SE EE SUITE).include? value then
120
+ attributes[:edition]=value
121
+ else
122
+ raise ArgumentError, "Invalid edition. Valid values - SE, EE or SUITE"
123
+ end
124
+ end
125
+
126
+
127
+ def shape=(value)
128
+ if %w(oc3 oc4 oc5 oc6 oc1m oc2m oc3m oc4m).include? value then
129
+ attributes[:shape]=value
130
+ else
131
+ raise ArgumentError, "Invalid Shape. Valid values - oc3, oc4, oc5, oc6, oc1m, oc2m, oc3m or oc4m"
132
+ end
133
+ end
134
+
135
+ def num_nodes=(value)
136
+ if value.nil? then value = 1 end
137
+ if value.to_i.is_a? Integer then
138
+ attributes[:num_nodes] = value.to_i
139
+ else
140
+ raise ArgumentError, "Invalid server count (#{value}). Valid values - 1, 2, 4 or 8"
141
+ end
142
+ end
143
+
144
+ def initialize(attributes={})
145
+ level ||= 'PAAS'
146
+ subscription_type ||= 'HOURLY'
147
+ edition ||= 'EE'
148
+
149
+ super
150
+ end
151
+
152
+ def save
153
+ #identity ? update : create
154
+ create
155
+ end
156
+
157
+ def ready?
158
+ status == "Running"
159
+ end
160
+
161
+ def stopping?
162
+ status == 'Maintenance' || status == 'Terminating'
163
+ end
164
+
165
+ def stopped?
166
+ status == 'Stopped'
167
+ end
168
+
169
+ def servers
170
+ service.servers.all(service_name)
171
+ end
172
+
173
+ def access_rules
174
+ service.access_rules(:instance => self)
175
+ end
176
+
177
+ def destroy
178
+ requires :service_name, :dba_name, :dba_password
179
+ service.delete_instance(service_name, dba_name, dba_password, :force_delete => force_delete).body
180
+ end
181
+
182
+ def scale_out_a_cluster(cluster_name, create_cluster_if_missing)
183
+ requires :service_name
184
+ service.scale_out_a_cluster(service_name, cluster_name, create_cluster_if_missing).body
185
+ end
186
+
187
+ private
188
+
189
+ def create
190
+ requires :service_name, :dba_name, :dba_password, :db_service_name, :shape, :version, :ssh_key, :admin_password, :admin_username
191
+
192
+ #data = service.create_instance(service_name, cloud_storage_container, cloud_storage_user, cloud_storage_password, dba_name, dba_password, db_servicename, shape, version, vm_public_key,
193
+ # :level => level,
194
+ # :subscriptionType => subscription_type,
195
+ # :description => description)
196
+
197
+ if cloud_storage_container.nil? then
198
+ cloud_storage_if_missing = true
199
+ stor_name = "#{service_name}_Backup"
200
+ else
201
+ stor_name = cloud_storage_container
202
+ end
203
+ stor_user = cloud_storage_user || service.username
204
+ stor_pwd = cloud_storage_pwd || service.password
205
+
206
+ params = {
207
+ :serviceName => service_name,
208
+ :cloudStorageContainer => stor_name,
209
+ :cloudStoragePassword => stor_user,
210
+ :cloudStorageUser => stor_pwd,
211
+ :cloudStorageContainerIfMissing => cloud_storage_if_missing,
212
+ :description => description,
213
+ :enableAdminConsole => enable_admin_console.nil? ? true : enable_admin_console,
214
+ :provisionOTD => provision_otd.nil? ? true : provision_otd,
215
+ :sampleAppDeploymentRequested => sample_app_deployment_requested.nil? ? true : sample_app_deployment_requested,
216
+ :subscriptionType => subscription_type || 'HOURLY',
217
+ :level => level || 'PAAS',
218
+ }
219
+ options = {
220
+ :adminPassword => admin_password,
221
+ :adminPort => admin_port,
222
+ :adminUserName => admin_username,
223
+ :backupVolumeSize => backup_volume_size,
224
+ :clusterName => cluster_name,
225
+ :contentPort => content_port,
226
+ :dbaName => dba_name,
227
+ :dbaPassword => dba_password,
228
+ :dbServiceName => db_service_name,
229
+ :deploymentChannelPort => wls_deployment_channel_port,
230
+ :domainMode => domain_mode,
231
+ :domainName => domain_name,
232
+ :domainPartitionCount => domain_partition_count,
233
+ :domainVolumeSize => domain_volume_size,
234
+ :edition => edition || 'EE',
235
+ :ipReservations => ip_reservations,
236
+ :managedServerCount => num_nodes || 1,
237
+ :msInitialHeapMB => ms_initial_heap_mb,
238
+ :msJvmArgs => ms_jvm_args,
239
+ :msMaxHeapMB => ms_max_heap_mb,
240
+ :msMaxPermMB => ms_max_perm_mb,
241
+ :msPermMb => ms_perm_mb,
242
+ :nodeManagerPassword => node_manager_password,
243
+ :nodeManagerPort => node_manager_port,
244
+ :nodeManagerUserName => node_manager_user_name,
245
+ :overwriteMsJvmArgs => overwrite_ms_jvm_args,
246
+ :pdbName => pdb_name,
247
+ :securedAdminPort => secured_admin_port,
248
+ :securedContentPort => secured_content_port,
249
+ :shape => shape,
250
+ :VMsPublicKey => ssh_key,
251
+ :version => version
252
+ }
253
+
254
+ if app_dbs and app_dbs.is_a? Array and app_dbs.size >= 1
255
+ options[:appDBs] = []
256
+ app_dbs.each { |db| options[:appDBs].push({
257
+ :dbaName => db.username,
258
+ :dbaPassword => db.password,
259
+ :dbServiceName => db.service_name,
260
+ }) }
261
+ end
262
+ data = service.create_instance(params, options)
263
+
264
+ end
265
+
266
+ end
267
+ end
268
+ end
269
+ end