saklient 0.0.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.
- checksums.yaml +7 -0
- data/.gitignore +21 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +43 -0
- data/Rakefile +1 -0
- data/config.sh.sample +5 -0
- data/example.rb +83 -0
- data/example.sh +6 -0
- data/lib/saklient/cloud/api.rb +382 -0
- data/lib/saklient/cloud/client.rb +111 -0
- data/lib/saklient/cloud/enums/eappliance_class.rb +39 -0
- data/lib/saklient/cloud/enums/eavailability.rb +79 -0
- data/lib/saklient/cloud/enums/edisk_connection.rb +39 -0
- data/lib/saklient/cloud/enums/escope.rb +39 -0
- data/lib/saklient/cloud/enums/escript_class.rb +39 -0
- data/lib/saklient/cloud/enums/eserver_instance_status.rb +44 -0
- data/lib/saklient/cloud/enums/estorage_class.rb +34 -0
- data/lib/saklient/cloud/errors/access_api_key_disabled_exception.rb +23 -0
- data/lib/saklient/cloud/errors/access_sakura_exception.rb +23 -0
- data/lib/saklient/cloud/errors/access_staff_exception.rb +23 -0
- data/lib/saklient/cloud/errors/access_token_exception.rb +23 -0
- data/lib/saklient/cloud/errors/access_xhr_or_api_key_exception.rb +23 -0
- data/lib/saklient/cloud/errors/account_not_found_exception.rb +23 -0
- data/lib/saklient/cloud/errors/account_not_specified_exception.rb +23 -0
- data/lib/saklient/cloud/errors/ambiguous_identifier_exception.rb +23 -0
- data/lib/saklient/cloud/errors/ambiguous_zone_exception.rb +23 -0
- data/lib/saklient/cloud/errors/api_proxy_timeout_exception.rb +23 -0
- data/lib/saklient/cloud/errors/api_proxy_timeout_non_get_exception.rb +23 -0
- data/lib/saklient/cloud/errors/archive_is_incomplete_exception.rb +23 -0
- data/lib/saklient/cloud/errors/boot_failure_by_lock_exception.rb +23 -0
- data/lib/saklient/cloud/errors/boot_failure_in_group_exception.rb +23 -0
- data/lib/saklient/cloud/errors/busy_exception.rb +23 -0
- data/lib/saklient/cloud/errors/cant_resize_smaller_exception.rb +23 -0
- data/lib/saklient/cloud/errors/cdrom_device_locked_exception.rb +23 -0
- data/lib/saklient/cloud/errors/cdrom_disabled_exception.rb +23 -0
- data/lib/saklient/cloud/errors/cdrom_in_use_exception.rb +23 -0
- data/lib/saklient/cloud/errors/cdrom_is_incomplete_exception.rb +23 -0
- data/lib/saklient/cloud/errors/connect_to_same_switch_exception.rb +23 -0
- data/lib/saklient/cloud/errors/contract_creation_exception.rb +23 -0
- data/lib/saklient/cloud/errors/copy_to_itself_exception.rb +23 -0
- data/lib/saklient/cloud/errors/delete_disk_b4_template_exception.rb +23 -0
- data/lib/saklient/cloud/errors/delete_ip_v6_nets_first_exception.rb +23 -0
- data/lib/saklient/cloud/errors/delete_res_b4_account_exception.rb +23 -0
- data/lib/saklient/cloud/errors/delete_router_b4_switch_exception.rb +23 -0
- data/lib/saklient/cloud/errors/delete_static_route_first_exception.rb +23 -0
- data/lib/saklient/cloud/errors/disabled_in_sandbox_exception.rb +23 -0
- data/lib/saklient/cloud/errors/disconnect_b4_delete_exception.rb +23 -0
- data/lib/saklient/cloud/errors/disconnect_b4_update_exception.rb +23 -0
- data/lib/saklient/cloud/errors/disk_connection_limit_exception.rb +23 -0
- data/lib/saklient/cloud/errors/disk_is_copying_exception.rb +23 -0
- data/lib/saklient/cloud/errors/disk_is_not_available_exception.rb +23 -0
- data/lib/saklient/cloud/errors/disk_license_mismatch_exception.rb +23 -0
- data/lib/saklient/cloud/errors/disk_or_ss_in_migration_exception.rb +23 -0
- data/lib/saklient/cloud/errors/disk_stock_run_out_exception.rb +23 -0
- data/lib/saklient/cloud/errors/dns_aaaa_record_not_found_exception.rb +23 -0
- data/lib/saklient/cloud/errors/dns_arecord_not_found_exception.rb +23 -0
- data/lib/saklient/cloud/errors/dns_ptr_update_failure_exception.rb +23 -0
- data/lib/saklient/cloud/errors/dont_create_in_sandbox_exception.rb +23 -0
- data/lib/saklient/cloud/errors/duplicate_account_code_exception.rb +23 -0
- data/lib/saklient/cloud/errors/duplicate_entry_exception.rb +23 -0
- data/lib/saklient/cloud/errors/duplicate_user_code_exception.rb +23 -0
- data/lib/saklient/cloud/errors/file_not_uploaded_exception.rb +23 -0
- data/lib/saklient/cloud/errors/filter_array_comparison_exception.rb +23 -0
- data/lib/saklient/cloud/errors/filter_bad_operator_exception.rb +23 -0
- data/lib/saklient/cloud/errors/filter_null_comparison_exception.rb +23 -0
- data/lib/saklient/cloud/errors/filter_unknown_operator_exception.rb +23 -0
- data/lib/saklient/cloud/errors/ftp_cannot_close_exception.rb +23 -0
- data/lib/saklient/cloud/errors/ftp_is_already_close_exception.rb +23 -0
- data/lib/saklient/cloud/errors/ftp_is_already_open_exception.rb +23 -0
- data/lib/saklient/cloud/errors/ftp_must_be_closed_exception.rb +23 -0
- data/lib/saklient/cloud/errors/host_operation_failure_exception.rb +23 -0
- data/lib/saklient/cloud/errors/illegal_das_usage_exception.rb +23 -0
- data/lib/saklient/cloud/errors/in_migration_exception.rb +23 -0
- data/lib/saklient/cloud/errors/invalid_format_exception.rb +23 -0
- data/lib/saklient/cloud/errors/invalid_param_comb_exception.rb +23 -0
- data/lib/saklient/cloud/errors/invalid_range_exception.rb +23 -0
- data/lib/saklient/cloud/errors/invalid_uri_argument_exception.rb +23 -0
- data/lib/saklient/cloud/errors/ip_v6_net_already_attached_exception.rb +23 -0
- data/lib/saklient/cloud/errors/limit_count_in_account_exception.rb +23 -0
- data/lib/saklient/cloud/errors/limit_count_in_member_exception.rb +23 -0
- data/lib/saklient/cloud/errors/limit_count_in_network_exception.rb +23 -0
- data/lib/saklient/cloud/errors/limit_count_in_router_exception.rb +23 -0
- data/lib/saklient/cloud/errors/limit_count_in_zone_exception.rb +23 -0
- data/lib/saklient/cloud/errors/limit_memory_in_account_exception.rb +23 -0
- data/lib/saklient/cloud/errors/limit_size_in_account_exception.rb +23 -0
- data/lib/saklient/cloud/errors/missing_iso_image_exception.rb +23 -0
- data/lib/saklient/cloud/errors/missing_param_exception.rb +23 -0
- data/lib/saklient/cloud/errors/must_be_of_same_zone_exception.rb +23 -0
- data/lib/saklient/cloud/errors/no_display_response_exception.rb +23 -0
- data/lib/saklient/cloud/errors/not_for_router_exception.rb +23 -0
- data/lib/saklient/cloud/errors/not_replicating_exception.rb +23 -0
- data/lib/saklient/cloud/errors/not_with_hybridconn_exception.rb +23 -0
- data/lib/saklient/cloud/errors/old_storage_plan_exception.rb +23 -0
- data/lib/saklient/cloud/errors/operation_failure_exception.rb +23 -0
- data/lib/saklient/cloud/errors/operation_timeout_exception.rb +23 -0
- data/lib/saklient/cloud/errors/original_hash_mismatch_exception.rb +23 -0
- data/lib/saklient/cloud/errors/packet_filter_applying_exception.rb +23 -0
- data/lib/saklient/cloud/errors/packet_filter_version_mismatch_exception.rb +23 -0
- data/lib/saklient/cloud/errors/param_ip_not_found_exception.rb +23 -0
- data/lib/saklient/cloud/errors/param_res_not_found_exception.rb +23 -0
- data/lib/saklient/cloud/errors/payment_credit_card_exception.rb +23 -0
- data/lib/saklient/cloud/errors/payment_payment_exception.rb +23 -0
- data/lib/saklient/cloud/errors/payment_registration_exception.rb +23 -0
- data/lib/saklient/cloud/errors/payment_tel_certification_exception.rb +23 -0
- data/lib/saklient/cloud/errors/payment_unpayable_exception.rb +23 -0
- data/lib/saklient/cloud/errors/penalty_operation_exception.rb +23 -0
- data/lib/saklient/cloud/errors/replica_already_exists_exception.rb +23 -0
- data/lib/saklient/cloud/errors/replica_not_found_exception.rb +23 -0
- data/lib/saklient/cloud/errors/res_already_connected_exception.rb +23 -0
- data/lib/saklient/cloud/errors/res_already_disconnected_exception.rb +23 -0
- data/lib/saklient/cloud/errors/res_already_exists_exception.rb +23 -0
- data/lib/saklient/cloud/errors/res_used_in_zone_exception.rb +23 -0
- data/lib/saklient/cloud/errors/resource_path_not_found_exception.rb +23 -0
- data/lib/saklient/cloud/errors/run_out_of_ip_address_exception.rb +23 -0
- data/lib/saklient/cloud/errors/same_license_required_exception.rb +23 -0
- data/lib/saklient/cloud/errors/server_could_not_stop_exception.rb +23 -0
- data/lib/saklient/cloud/errors/server_is_cleaning_exception.rb +23 -0
- data/lib/saklient/cloud/errors/server_operation_failure_exception.rb +23 -0
- data/lib/saklient/cloud/errors/server_power_must_be_down_exception.rb +23 -0
- data/lib/saklient/cloud/errors/server_power_must_be_up_exception.rb +23 -0
- data/lib/saklient/cloud/errors/service_temporarily_unavailable_exception.rb +23 -0
- data/lib/saklient/cloud/errors/size_mismatch_exception.rb +23 -0
- data/lib/saklient/cloud/errors/snapshot_in_migration_exception.rb +23 -0
- data/lib/saklient/cloud/errors/still_creating_exception.rb +23 -0
- data/lib/saklient/cloud/errors/storage_abnormal_exception.rb +23 -0
- data/lib/saklient/cloud/errors/storage_operation_failure_exception.rb +23 -0
- data/lib/saklient/cloud/errors/switch_hybrid_connected_exception.rb +23 -0
- data/lib/saklient/cloud/errors/template_ftp_is_open_exception.rb +23 -0
- data/lib/saklient/cloud/errors/template_is_incomplete_exception.rb +23 -0
- data/lib/saklient/cloud/errors/too_many_request_exception.rb +23 -0
- data/lib/saklient/cloud/errors/unknown_exception.rb +23 -0
- data/lib/saklient/cloud/errors/unknown_os_type_exception.rb +23 -0
- data/lib/saklient/cloud/errors/unsupported_res_class_exception.rb +23 -0
- data/lib/saklient/cloud/errors/user_not_specified_exception.rb +23 -0
- data/lib/saklient/cloud/errors/vnc_proxy_request_failure_exception.rb +23 -0
- data/lib/saklient/cloud/models/model.rb +348 -0
- data/lib/saklient/cloud/models/model_appliance.rb +161 -0
- data/lib/saklient/cloud/models/model_archive.rb +207 -0
- data/lib/saklient/cloud/models/model_disk.rb +200 -0
- data/lib/saklient/cloud/models/model_disk_plan.rb +156 -0
- data/lib/saklient/cloud/models/model_icon.rb +178 -0
- data/lib/saklient/cloud/models/model_iface.rb +115 -0
- data/lib/saklient/cloud/models/model_ipv6_net.rb +106 -0
- data/lib/saklient/cloud/models/model_iso_image.rb +207 -0
- data/lib/saklient/cloud/models/model_router.rb +148 -0
- data/lib/saklient/cloud/models/model_router_plan.rb +106 -0
- data/lib/saklient/cloud/models/model_script.rb +178 -0
- data/lib/saklient/cloud/models/model_server.rb +237 -0
- data/lib/saklient/cloud/models/model_server_plan.rb +119 -0
- data/lib/saklient/cloud/models/model_swytch.rb +138 -0
- data/lib/saklient/cloud/models/query_params.rb +44 -0
- data/lib/saklient/cloud/product.rb +95 -0
- data/lib/saklient/cloud/resources/appliance.rb +551 -0
- data/lib/saklient/cloud/resources/archive.rb +861 -0
- data/lib/saklient/cloud/resources/disk.rb +802 -0
- data/lib/saklient/cloud/resources/disk_config.rb +353 -0
- data/lib/saklient/cloud/resources/disk_plan.rb +194 -0
- data/lib/saklient/cloud/resources/ftp_info.rb +93 -0
- data/lib/saklient/cloud/resources/icon.rb +268 -0
- data/lib/saklient/cloud/resources/iface.rb +329 -0
- data/lib/saklient/cloud/resources/ipv4_net.rb +275 -0
- data/lib/saklient/cloud/resources/ipv6_net.rb +238 -0
- data/lib/saklient/cloud/resources/iso_image.rb +666 -0
- data/lib/saklient/cloud/resources/resource.rb +287 -0
- data/lib/saklient/cloud/resources/router.rb +508 -0
- data/lib/saklient/cloud/resources/router_plan.rb +230 -0
- data/lib/saklient/cloud/resources/script.rb +554 -0
- data/lib/saklient/cloud/resources/server.rb +730 -0
- data/lib/saklient/cloud/resources/server_instance.rb +217 -0
- data/lib/saklient/cloud/resources/server_plan.rb +285 -0
- data/lib/saklient/cloud/resources/swytch.rb +521 -0
- data/lib/saklient/errors/exception_factory.rb +532 -0
- data/lib/saklient/errors/http_bad_gateway_exception.rb +21 -0
- data/lib/saklient/errors/http_bad_request_exception.rb +21 -0
- data/lib/saklient/errors/http_conflict_exception.rb +21 -0
- data/lib/saklient/errors/http_exception.rb +27 -0
- data/lib/saklient/errors/http_expectation_failed_exception.rb +21 -0
- data/lib/saklient/errors/http_failed_dependency_exception.rb +21 -0
- data/lib/saklient/errors/http_forbidden_exception.rb +21 -0
- data/lib/saklient/errors/http_gateway_timeout_exception.rb +21 -0
- data/lib/saklient/errors/http_gone_exception.rb +21 -0
- data/lib/saklient/errors/http_http_version_not_supported_exception.rb +21 -0
- data/lib/saklient/errors/http_insufficient_storage_exception.rb +21 -0
- data/lib/saklient/errors/http_internal_server_error_exception.rb +21 -0
- data/lib/saklient/errors/http_length_required_exception.rb +21 -0
- data/lib/saklient/errors/http_locked_exception.rb +21 -0
- data/lib/saklient/errors/http_method_not_allowed_exception.rb +21 -0
- data/lib/saklient/errors/http_not_acceptable_exception.rb +21 -0
- data/lib/saklient/errors/http_not_extended_exception.rb +21 -0
- data/lib/saklient/errors/http_not_found_exception.rb +21 -0
- data/lib/saklient/errors/http_not_implemented_exception.rb +21 -0
- data/lib/saklient/errors/http_payment_required_exception.rb +21 -0
- data/lib/saklient/errors/http_precondition_failed_exception.rb +21 -0
- data/lib/saklient/errors/http_proxy_authentication_required_exception.rb +21 -0
- data/lib/saklient/errors/http_request_entity_too_large_exception.rb +21 -0
- data/lib/saklient/errors/http_request_timeout_exception.rb +21 -0
- data/lib/saklient/errors/http_request_uri_too_long_exception.rb +21 -0
- data/lib/saklient/errors/http_requested_range_not_satisfiable_exception.rb +21 -0
- data/lib/saklient/errors/http_service_unavailable_exception.rb +21 -0
- data/lib/saklient/errors/http_unauthorized_exception.rb +21 -0
- data/lib/saklient/errors/http_unprocessable_entity_exception.rb +21 -0
- data/lib/saklient/errors/http_unsupported_media_type_exception.rb +21 -0
- data/lib/saklient/errors/http_upgrade_required_exception.rb +21 -0
- data/lib/saklient/errors/http_variant_also_negotiates_exception.rb +21 -0
- data/lib/saklient/errors/saklient_exception.rb +22 -0
- data/lib/saklient/util.rb +121 -0
- data/lib/saklient/version.rb +5 -0
- data/saklient.gemspec +24 -0
- data/spec/archive_spec.rb +141 -0
- data/spec/enum_spec.rb +24 -0
- data/spec/exception_spec.rb +25 -0
- data/spec/iso_image_spec.rb +172 -0
- data/spec/router_spec.rb +124 -0
- data/spec/server_spec.rb +261 -0
- data/spec/util_spec.rb +72 -0
- data/test-sshkey.txt +27 -0
- metadata +281 -0
@@ -0,0 +1,730 @@
|
|
1
|
+
# -*- encoding: UTF-8 -*-
|
2
|
+
|
3
|
+
require_relative '../../errors/saklient_exception'
|
4
|
+
require_relative '../client'
|
5
|
+
require_relative 'resource'
|
6
|
+
require_relative 'icon'
|
7
|
+
require_relative 'disk'
|
8
|
+
require_relative 'iface'
|
9
|
+
require_relative 'server_plan'
|
10
|
+
require_relative 'server_instance'
|
11
|
+
require_relative 'iso_image'
|
12
|
+
require_relative '../enums/eserver_instance_status'
|
13
|
+
require_relative '../enums/eavailability'
|
14
|
+
require_relative '../models/model_disk'
|
15
|
+
require_relative '../models/model_iface'
|
16
|
+
|
17
|
+
module Saklient
|
18
|
+
module Cloud
|
19
|
+
module Resources
|
20
|
+
|
21
|
+
# サーバの実体1つに対応し, 属性の取得や操作を行うためのクラス.
|
22
|
+
class Server < Saklient::Cloud::Resources::Resource
|
23
|
+
|
24
|
+
protected
|
25
|
+
|
26
|
+
# ID
|
27
|
+
#
|
28
|
+
# @return [String]
|
29
|
+
attr_accessor :m_id
|
30
|
+
|
31
|
+
# 名前
|
32
|
+
#
|
33
|
+
# @return [String]
|
34
|
+
attr_accessor :m_name
|
35
|
+
|
36
|
+
# 説明
|
37
|
+
#
|
38
|
+
# @return [String]
|
39
|
+
attr_accessor :m_description
|
40
|
+
|
41
|
+
# タグ
|
42
|
+
#
|
43
|
+
# @return [Array<String>]
|
44
|
+
attr_accessor :m_tags
|
45
|
+
|
46
|
+
# アイコン
|
47
|
+
#
|
48
|
+
# @return [Icon]
|
49
|
+
attr_accessor :m_icon
|
50
|
+
|
51
|
+
# プラン
|
52
|
+
#
|
53
|
+
# @return [ServerPlan]
|
54
|
+
attr_accessor :m_plan
|
55
|
+
|
56
|
+
# インタフェース
|
57
|
+
#
|
58
|
+
# @return [Array<Iface>]
|
59
|
+
attr_accessor :m_ifaces
|
60
|
+
|
61
|
+
# インスタンス情報
|
62
|
+
#
|
63
|
+
# @return [ServerInstance]
|
64
|
+
attr_accessor :m_instance
|
65
|
+
|
66
|
+
# 有効状態 {Saklient::Cloud::Enums::EAvailability}
|
67
|
+
#
|
68
|
+
# @return [String]
|
69
|
+
attr_accessor :m_availability
|
70
|
+
|
71
|
+
# @private
|
72
|
+
# @return [String]
|
73
|
+
def _api_path
|
74
|
+
return '/server'
|
75
|
+
end
|
76
|
+
|
77
|
+
# @private
|
78
|
+
# @return [String]
|
79
|
+
def _root_key
|
80
|
+
return 'Server'
|
81
|
+
end
|
82
|
+
|
83
|
+
# @private
|
84
|
+
# @return [String]
|
85
|
+
def _root_key_m
|
86
|
+
return 'Servers'
|
87
|
+
end
|
88
|
+
|
89
|
+
public
|
90
|
+
|
91
|
+
# @private
|
92
|
+
# @return [String]
|
93
|
+
def _class_name
|
94
|
+
return 'Server'
|
95
|
+
end
|
96
|
+
|
97
|
+
# @private
|
98
|
+
# @return [String]
|
99
|
+
def _id
|
100
|
+
return get_id
|
101
|
+
end
|
102
|
+
|
103
|
+
# このローカルオブジェクトに現在設定されているリソース情報をAPIに送信し, 新規作成または上書き保存します.
|
104
|
+
#
|
105
|
+
# @return [Server] this
|
106
|
+
def save
|
107
|
+
return _save
|
108
|
+
end
|
109
|
+
|
110
|
+
# 最新のリソース情報を再取得します.
|
111
|
+
#
|
112
|
+
# @return [Server] this
|
113
|
+
def reload
|
114
|
+
return _reload
|
115
|
+
end
|
116
|
+
|
117
|
+
# @private
|
118
|
+
# @param [Saklient::Cloud::Client] client
|
119
|
+
# @param [any] obj
|
120
|
+
# @param [bool] wrapped
|
121
|
+
def initialize(client, obj, wrapped = false)
|
122
|
+
super(client)
|
123
|
+
Saklient::Util::validate_type(client, 'Saklient::Cloud::Client')
|
124
|
+
Saklient::Util::validate_type(wrapped, 'bool')
|
125
|
+
api_deserialize(obj, wrapped)
|
126
|
+
end
|
127
|
+
|
128
|
+
# サーバが起動しているときtrueを返します.
|
129
|
+
#
|
130
|
+
# @return [bool]
|
131
|
+
def is_up
|
132
|
+
return get_instance.is_up
|
133
|
+
end
|
134
|
+
|
135
|
+
# サーバが停止しているときtrueを返します.
|
136
|
+
#
|
137
|
+
# @return [bool]
|
138
|
+
def is_down
|
139
|
+
return get_instance.is_down
|
140
|
+
end
|
141
|
+
|
142
|
+
# サーバを起動します.
|
143
|
+
#
|
144
|
+
# @return [Server] this
|
145
|
+
def boot
|
146
|
+
@_client.request('PUT', _api_path + '/' + Saklient::Util::url_encode(_id) + '/power')
|
147
|
+
return reload
|
148
|
+
end
|
149
|
+
|
150
|
+
# サーバをシャットダウンします.
|
151
|
+
#
|
152
|
+
# @return [Server] this
|
153
|
+
def shutdown
|
154
|
+
@_client.request('DELETE', _api_path + '/' + Saklient::Util::url_encode(_id) + '/power')
|
155
|
+
return reload
|
156
|
+
end
|
157
|
+
|
158
|
+
# サーバを強制停止します.
|
159
|
+
#
|
160
|
+
# @return [Server] this
|
161
|
+
def stop
|
162
|
+
@_client.request('DELETE', _api_path + '/' + Saklient::Util::url_encode(_id) + '/power', { Force: true })
|
163
|
+
return reload
|
164
|
+
end
|
165
|
+
|
166
|
+
# サーバを強制再起動します.
|
167
|
+
#
|
168
|
+
# @return [Server] this
|
169
|
+
def reboot
|
170
|
+
@_client.request('PUT', _api_path + '/' + Saklient::Util::url_encode(_id) + '/reset')
|
171
|
+
return reload
|
172
|
+
end
|
173
|
+
|
174
|
+
# サーバが停止するまで待機します.
|
175
|
+
#
|
176
|
+
# @yield [Saklient::Cloud::Resources::Server, bool]
|
177
|
+
# @yieldreturn [void]
|
178
|
+
# @param [Fixnum] timeoutSec
|
179
|
+
# @return [void] 成功時はtrue, タイムアウトやエラーによる失敗時はfalseを返します.
|
180
|
+
def after_down(timeoutSec, &callback)
|
181
|
+
Saklient::Util::validate_type(timeoutSec, 'Fixnum')
|
182
|
+
Saklient::Util::validate_type(callback, 'Proc')
|
183
|
+
after_status(Saklient::Cloud::Enums::EServerInstanceStatus::down, timeoutSec, &callback)
|
184
|
+
end
|
185
|
+
|
186
|
+
protected
|
187
|
+
|
188
|
+
# サーバが指定のステータスに遷移するまで待機します.
|
189
|
+
#
|
190
|
+
# @private
|
191
|
+
# @yield [Saklient::Cloud::Resources::Server, bool]
|
192
|
+
# @yieldreturn [void]
|
193
|
+
# @param [String] status
|
194
|
+
# @param [Fixnum] timeoutSec
|
195
|
+
# @return [void]
|
196
|
+
def after_status(status, timeoutSec, &callback)
|
197
|
+
Saklient::Util::validate_type(status, 'String')
|
198
|
+
Saklient::Util::validate_type(timeoutSec, 'Fixnum')
|
199
|
+
Saklient::Util::validate_type(callback, 'Proc')
|
200
|
+
ret = sleep_until(status, timeoutSec)
|
201
|
+
callback.call(self, ret)
|
202
|
+
end
|
203
|
+
|
204
|
+
public
|
205
|
+
|
206
|
+
# サーバが停止するまで待機します.
|
207
|
+
#
|
208
|
+
# @param [Fixnum] timeoutSec
|
209
|
+
# @return [bool] 成功時はtrue, タイムアウトやエラーによる失敗時はfalseを返します.
|
210
|
+
def sleep_until_down(timeoutSec = 180)
|
211
|
+
Saklient::Util::validate_type(timeoutSec, 'Fixnum')
|
212
|
+
return sleep_until(Saklient::Cloud::Enums::EServerInstanceStatus::down, timeoutSec)
|
213
|
+
end
|
214
|
+
|
215
|
+
protected
|
216
|
+
|
217
|
+
# サーバが指定のステータスに遷移するまで待機します.
|
218
|
+
#
|
219
|
+
# @private
|
220
|
+
# @param [String] status
|
221
|
+
# @param [Fixnum] timeoutSec
|
222
|
+
# @return [bool]
|
223
|
+
def sleep_until(status, timeoutSec = 180)
|
224
|
+
Saklient::Util::validate_type(status, 'String')
|
225
|
+
Saklient::Util::validate_type(timeoutSec, 'Fixnum')
|
226
|
+
step = 3
|
227
|
+
while 0 < timeoutSec do
|
228
|
+
reload
|
229
|
+
s = get_instance.status
|
230
|
+
s = Saklient::Cloud::Enums::EServerInstanceStatus::down if (s).nil?
|
231
|
+
return true if s == status
|
232
|
+
timeoutSec -= step
|
233
|
+
sleep step if 0 < timeoutSec
|
234
|
+
end
|
235
|
+
return false
|
236
|
+
end
|
237
|
+
|
238
|
+
public
|
239
|
+
|
240
|
+
# サーバプランを変更します.
|
241
|
+
#
|
242
|
+
# 成功時はリソースIDが変わることにご注意ください.
|
243
|
+
#
|
244
|
+
# @param [ServerPlan] planTo
|
245
|
+
# @return [Server] this
|
246
|
+
def change_plan(planTo)
|
247
|
+
Saklient::Util::validate_type(planTo, 'Saklient::Cloud::Resources::ServerPlan')
|
248
|
+
path = _api_path + '/' + Saklient::Util::url_encode(_id) + '/to/plan/' + Saklient::Util::url_encode(planTo._id)
|
249
|
+
result = @_client.request('PUT', path)
|
250
|
+
api_deserialize(result, true)
|
251
|
+
return self
|
252
|
+
end
|
253
|
+
|
254
|
+
# サーバに接続されているディスクのリストを取得します.
|
255
|
+
#
|
256
|
+
# @return [Array<Disk>]
|
257
|
+
def find_disks
|
258
|
+
model = Saklient::Util::create_class_instance('saklient.cloud.models.Model_Disk', [@_client])
|
259
|
+
return model.with_server_id(_id).find
|
260
|
+
end
|
261
|
+
|
262
|
+
# サーバにインタフェースを1つ増設し, それを取得します.
|
263
|
+
#
|
264
|
+
# @return [Iface] 増設されたインタフェース
|
265
|
+
def add_iface
|
266
|
+
model = Saklient::Util::create_class_instance('saklient.cloud.models.Model_Iface', [@_client])
|
267
|
+
res = model.create
|
268
|
+
res.set_property('serverId', _id)
|
269
|
+
return res.save
|
270
|
+
end
|
271
|
+
|
272
|
+
# サーバにISOイメージを挿入します.
|
273
|
+
#
|
274
|
+
# @param [IsoImage] iso
|
275
|
+
# @return [Server] this
|
276
|
+
def insert_iso_image(iso)
|
277
|
+
Saklient::Util::validate_type(iso, 'Saklient::Cloud::Resources::IsoImage')
|
278
|
+
path = _api_path + '/' + Saklient::Util::url_encode(_id) + '/cdrom'
|
279
|
+
q = { CDROM: { ID: iso._id } }
|
280
|
+
@_client.request('PUT', path, q)
|
281
|
+
reload
|
282
|
+
return self
|
283
|
+
end
|
284
|
+
|
285
|
+
# サーバに挿入されているISOイメージを排出します.
|
286
|
+
#
|
287
|
+
# @return [Server] this
|
288
|
+
def eject_iso_image
|
289
|
+
path = _api_path + '/' + Saklient::Util::url_encode(_id) + '/cdrom'
|
290
|
+
@_client.request('DELETE', path)
|
291
|
+
reload
|
292
|
+
return self
|
293
|
+
end
|
294
|
+
|
295
|
+
protected
|
296
|
+
|
297
|
+
# @return [bool]
|
298
|
+
attr_accessor :n_id
|
299
|
+
|
300
|
+
# (This method is generated in Translator_default#buildImpl)
|
301
|
+
#
|
302
|
+
# @private
|
303
|
+
# @return [String]
|
304
|
+
def get_id
|
305
|
+
return @m_id
|
306
|
+
end
|
307
|
+
|
308
|
+
public
|
309
|
+
|
310
|
+
# ID
|
311
|
+
#
|
312
|
+
# @return [String]
|
313
|
+
attr_reader :id
|
314
|
+
|
315
|
+
def id
|
316
|
+
get_id
|
317
|
+
end
|
318
|
+
|
319
|
+
protected
|
320
|
+
|
321
|
+
# @return [bool]
|
322
|
+
attr_accessor :n_name
|
323
|
+
|
324
|
+
# (This method is generated in Translator_default#buildImpl)
|
325
|
+
#
|
326
|
+
# @private
|
327
|
+
# @return [String]
|
328
|
+
def get_name
|
329
|
+
return @m_name
|
330
|
+
end
|
331
|
+
|
332
|
+
# (This method is generated in Translator_default#buildImpl)
|
333
|
+
#
|
334
|
+
# @private
|
335
|
+
# @param [String] v
|
336
|
+
# @return [String]
|
337
|
+
def set_name(v)
|
338
|
+
Saklient::Util::validate_type(v, 'String')
|
339
|
+
@m_name = v
|
340
|
+
@n_name = true
|
341
|
+
return @m_name
|
342
|
+
end
|
343
|
+
|
344
|
+
public
|
345
|
+
|
346
|
+
# 名前
|
347
|
+
#
|
348
|
+
# @return [String]
|
349
|
+
attr_accessor :name
|
350
|
+
|
351
|
+
def name
|
352
|
+
get_name
|
353
|
+
end
|
354
|
+
|
355
|
+
def name=(v)
|
356
|
+
set_name(v)
|
357
|
+
end
|
358
|
+
|
359
|
+
protected
|
360
|
+
|
361
|
+
# @return [bool]
|
362
|
+
attr_accessor :n_description
|
363
|
+
|
364
|
+
# (This method is generated in Translator_default#buildImpl)
|
365
|
+
#
|
366
|
+
# @private
|
367
|
+
# @return [String]
|
368
|
+
def get_description
|
369
|
+
return @m_description
|
370
|
+
end
|
371
|
+
|
372
|
+
# (This method is generated in Translator_default#buildImpl)
|
373
|
+
#
|
374
|
+
# @private
|
375
|
+
# @param [String] v
|
376
|
+
# @return [String]
|
377
|
+
def set_description(v)
|
378
|
+
Saklient::Util::validate_type(v, 'String')
|
379
|
+
@m_description = v
|
380
|
+
@n_description = true
|
381
|
+
return @m_description
|
382
|
+
end
|
383
|
+
|
384
|
+
public
|
385
|
+
|
386
|
+
# 説明
|
387
|
+
#
|
388
|
+
# @return [String]
|
389
|
+
attr_accessor :description
|
390
|
+
|
391
|
+
def description
|
392
|
+
get_description
|
393
|
+
end
|
394
|
+
|
395
|
+
def description=(v)
|
396
|
+
set_description(v)
|
397
|
+
end
|
398
|
+
|
399
|
+
protected
|
400
|
+
|
401
|
+
# @return [bool]
|
402
|
+
attr_accessor :n_tags
|
403
|
+
|
404
|
+
# (This method is generated in Translator_default#buildImpl)
|
405
|
+
#
|
406
|
+
# @private
|
407
|
+
# @return [Array<String>]
|
408
|
+
def get_tags
|
409
|
+
return @m_tags
|
410
|
+
end
|
411
|
+
|
412
|
+
# (This method is generated in Translator_default#buildImpl)
|
413
|
+
#
|
414
|
+
# @private
|
415
|
+
# @param [Array<String>] v
|
416
|
+
# @return [Array<String>]
|
417
|
+
def set_tags(v)
|
418
|
+
Saklient::Util::validate_type(v, 'Array')
|
419
|
+
@m_tags = v
|
420
|
+
@n_tags = true
|
421
|
+
return @m_tags
|
422
|
+
end
|
423
|
+
|
424
|
+
public
|
425
|
+
|
426
|
+
# タグ
|
427
|
+
#
|
428
|
+
# @return [Array<String>]
|
429
|
+
attr_accessor :tags
|
430
|
+
|
431
|
+
def tags
|
432
|
+
get_tags
|
433
|
+
end
|
434
|
+
|
435
|
+
def tags=(v)
|
436
|
+
set_tags(v)
|
437
|
+
end
|
438
|
+
|
439
|
+
protected
|
440
|
+
|
441
|
+
# @return [bool]
|
442
|
+
attr_accessor :n_icon
|
443
|
+
|
444
|
+
# (This method is generated in Translator_default#buildImpl)
|
445
|
+
#
|
446
|
+
# @private
|
447
|
+
# @return [Icon]
|
448
|
+
def get_icon
|
449
|
+
return @m_icon
|
450
|
+
end
|
451
|
+
|
452
|
+
# (This method is generated in Translator_default#buildImpl)
|
453
|
+
#
|
454
|
+
# @private
|
455
|
+
# @param [Icon] v
|
456
|
+
# @return [Icon]
|
457
|
+
def set_icon(v)
|
458
|
+
Saklient::Util::validate_type(v, 'Saklient::Cloud::Resources::Icon')
|
459
|
+
@m_icon = v
|
460
|
+
@n_icon = true
|
461
|
+
return @m_icon
|
462
|
+
end
|
463
|
+
|
464
|
+
public
|
465
|
+
|
466
|
+
# アイコン
|
467
|
+
#
|
468
|
+
# @return [Icon]
|
469
|
+
attr_accessor :icon
|
470
|
+
|
471
|
+
def icon
|
472
|
+
get_icon
|
473
|
+
end
|
474
|
+
|
475
|
+
def icon=(v)
|
476
|
+
set_icon(v)
|
477
|
+
end
|
478
|
+
|
479
|
+
protected
|
480
|
+
|
481
|
+
# @return [bool]
|
482
|
+
attr_accessor :n_plan
|
483
|
+
|
484
|
+
# (This method is generated in Translator_default#buildImpl)
|
485
|
+
#
|
486
|
+
# @private
|
487
|
+
# @return [ServerPlan]
|
488
|
+
def get_plan
|
489
|
+
return @m_plan
|
490
|
+
end
|
491
|
+
|
492
|
+
# (This method is generated in Translator_default#buildImpl)
|
493
|
+
#
|
494
|
+
# @private
|
495
|
+
# @param [ServerPlan] v
|
496
|
+
# @return [ServerPlan]
|
497
|
+
def set_plan(v)
|
498
|
+
Saklient::Util::validate_type(v, 'Saklient::Cloud::Resources::ServerPlan')
|
499
|
+
raise Saklient::Errors::SaklientException.new('immutable_field', 'Immutable fields cannot be modified after the resource creation: ' + 'Saklient::Cloud::Resources::Server#plan') if !@is_new
|
500
|
+
@m_plan = v
|
501
|
+
@n_plan = true
|
502
|
+
return @m_plan
|
503
|
+
end
|
504
|
+
|
505
|
+
public
|
506
|
+
|
507
|
+
# プラン
|
508
|
+
#
|
509
|
+
# @return [ServerPlan]
|
510
|
+
attr_accessor :plan
|
511
|
+
|
512
|
+
def plan
|
513
|
+
get_plan
|
514
|
+
end
|
515
|
+
|
516
|
+
def plan=(v)
|
517
|
+
set_plan(v)
|
518
|
+
end
|
519
|
+
|
520
|
+
protected
|
521
|
+
|
522
|
+
# @return [bool]
|
523
|
+
attr_accessor :n_ifaces
|
524
|
+
|
525
|
+
# (This method is generated in Translator_default#buildImpl)
|
526
|
+
#
|
527
|
+
# @private
|
528
|
+
# @return [Array<Iface>]
|
529
|
+
def get_ifaces
|
530
|
+
return @m_ifaces
|
531
|
+
end
|
532
|
+
|
533
|
+
public
|
534
|
+
|
535
|
+
# インタフェース
|
536
|
+
#
|
537
|
+
# @return [Array<Iface>]
|
538
|
+
attr_reader :ifaces
|
539
|
+
|
540
|
+
def ifaces
|
541
|
+
get_ifaces
|
542
|
+
end
|
543
|
+
|
544
|
+
protected
|
545
|
+
|
546
|
+
# @return [bool]
|
547
|
+
attr_accessor :n_instance
|
548
|
+
|
549
|
+
# (This method is generated in Translator_default#buildImpl)
|
550
|
+
#
|
551
|
+
# @private
|
552
|
+
# @return [ServerInstance]
|
553
|
+
def get_instance
|
554
|
+
return @m_instance
|
555
|
+
end
|
556
|
+
|
557
|
+
public
|
558
|
+
|
559
|
+
# インスタンス情報
|
560
|
+
#
|
561
|
+
# @return [ServerInstance]
|
562
|
+
attr_reader :instance
|
563
|
+
|
564
|
+
def instance
|
565
|
+
get_instance
|
566
|
+
end
|
567
|
+
|
568
|
+
protected
|
569
|
+
|
570
|
+
# @return [bool]
|
571
|
+
attr_accessor :n_availability
|
572
|
+
|
573
|
+
# (This method is generated in Translator_default#buildImpl)
|
574
|
+
#
|
575
|
+
# @private
|
576
|
+
# @return [String]
|
577
|
+
def get_availability
|
578
|
+
return @m_availability
|
579
|
+
end
|
580
|
+
|
581
|
+
public
|
582
|
+
|
583
|
+
# 有効状態 {Saklient::Cloud::Enums::EAvailability}
|
584
|
+
#
|
585
|
+
# @return [String]
|
586
|
+
attr_reader :availability
|
587
|
+
|
588
|
+
def availability
|
589
|
+
get_availability
|
590
|
+
end
|
591
|
+
|
592
|
+
protected
|
593
|
+
|
594
|
+
# (This method is generated in Translator_default#buildImpl)
|
595
|
+
#
|
596
|
+
# @param [any] r
|
597
|
+
def api_deserialize_impl(r)
|
598
|
+
@is_new = (r).nil?
|
599
|
+
r = {} if @is_new
|
600
|
+
@is_incomplete = false
|
601
|
+
if Saklient::Util::exists_path(r, 'ID')
|
602
|
+
@m_id = (Saklient::Util::get_by_path(r, 'ID')).nil? ? nil : Saklient::Util::get_by_path(r, 'ID').to_s
|
603
|
+
else
|
604
|
+
@m_id = nil
|
605
|
+
@is_incomplete = true
|
606
|
+
end
|
607
|
+
@n_id = false
|
608
|
+
if Saklient::Util::exists_path(r, 'Name')
|
609
|
+
@m_name = (Saklient::Util::get_by_path(r, 'Name')).nil? ? nil : Saklient::Util::get_by_path(r, 'Name').to_s
|
610
|
+
else
|
611
|
+
@m_name = nil
|
612
|
+
@is_incomplete = true
|
613
|
+
end
|
614
|
+
@n_name = false
|
615
|
+
if Saklient::Util::exists_path(r, 'Description')
|
616
|
+
@m_description = (Saklient::Util::get_by_path(r, 'Description')).nil? ? nil : Saklient::Util::get_by_path(r, 'Description').to_s
|
617
|
+
else
|
618
|
+
@m_description = nil
|
619
|
+
@is_incomplete = true
|
620
|
+
end
|
621
|
+
@n_description = false
|
622
|
+
if Saklient::Util::exists_path(r, 'Tags')
|
623
|
+
if (Saklient::Util::get_by_path(r, 'Tags')).nil?
|
624
|
+
@m_tags = []
|
625
|
+
else
|
626
|
+
@m_tags = []
|
627
|
+
for t in Saklient::Util::get_by_path(r, 'Tags')
|
628
|
+
v1 = nil
|
629
|
+
v1 = (t).nil? ? nil : t.to_s
|
630
|
+
@m_tags << v1
|
631
|
+
end
|
632
|
+
end
|
633
|
+
else
|
634
|
+
@m_tags = nil
|
635
|
+
@is_incomplete = true
|
636
|
+
end
|
637
|
+
@n_tags = false
|
638
|
+
if Saklient::Util::exists_path(r, 'Icon')
|
639
|
+
@m_icon = (Saklient::Util::get_by_path(r, 'Icon')).nil? ? nil : Saklient::Cloud::Resources::Icon.new(@_client, Saklient::Util::get_by_path(r, 'Icon'))
|
640
|
+
else
|
641
|
+
@m_icon = nil
|
642
|
+
@is_incomplete = true
|
643
|
+
end
|
644
|
+
@n_icon = false
|
645
|
+
if Saklient::Util::exists_path(r, 'ServerPlan')
|
646
|
+
@m_plan = (Saklient::Util::get_by_path(r, 'ServerPlan')).nil? ? nil : Saklient::Cloud::Resources::ServerPlan.new(@_client, Saklient::Util::get_by_path(r, 'ServerPlan'))
|
647
|
+
else
|
648
|
+
@m_plan = nil
|
649
|
+
@is_incomplete = true
|
650
|
+
end
|
651
|
+
@n_plan = false
|
652
|
+
if Saklient::Util::exists_path(r, 'Interfaces')
|
653
|
+
if (Saklient::Util::get_by_path(r, 'Interfaces')).nil?
|
654
|
+
@m_ifaces = []
|
655
|
+
else
|
656
|
+
@m_ifaces = []
|
657
|
+
for t in Saklient::Util::get_by_path(r, 'Interfaces')
|
658
|
+
v2 = nil
|
659
|
+
v2 = (t).nil? ? nil : Saklient::Cloud::Resources::Iface.new(@_client, t)
|
660
|
+
@m_ifaces << v2
|
661
|
+
end
|
662
|
+
end
|
663
|
+
else
|
664
|
+
@m_ifaces = nil
|
665
|
+
@is_incomplete = true
|
666
|
+
end
|
667
|
+
@n_ifaces = false
|
668
|
+
if Saklient::Util::exists_path(r, 'Instance')
|
669
|
+
@m_instance = (Saklient::Util::get_by_path(r, 'Instance')).nil? ? nil : Saklient::Cloud::Resources::ServerInstance.new(@_client, Saklient::Util::get_by_path(r, 'Instance'))
|
670
|
+
else
|
671
|
+
@m_instance = nil
|
672
|
+
@is_incomplete = true
|
673
|
+
end
|
674
|
+
@n_instance = false
|
675
|
+
if Saklient::Util::exists_path(r, 'Availability')
|
676
|
+
@m_availability = (Saklient::Util::get_by_path(r, 'Availability')).nil? ? nil : Saklient::Util::get_by_path(r, 'Availability').to_s
|
677
|
+
else
|
678
|
+
@m_availability = nil
|
679
|
+
@is_incomplete = true
|
680
|
+
end
|
681
|
+
@n_availability = false
|
682
|
+
end
|
683
|
+
|
684
|
+
# @private
|
685
|
+
# @param [bool] withClean
|
686
|
+
# @return [any]
|
687
|
+
def api_serialize_impl(withClean = false)
|
688
|
+
Saklient::Util::validate_type(withClean, 'bool')
|
689
|
+
missing = []
|
690
|
+
ret = {}
|
691
|
+
Saklient::Util::set_by_path(ret, 'ID', @m_id) if withClean || @n_id
|
692
|
+
if withClean || @n_name
|
693
|
+
Saklient::Util::set_by_path(ret, 'Name', @m_name)
|
694
|
+
else
|
695
|
+
missing << 'name' if @is_new
|
696
|
+
end
|
697
|
+
Saklient::Util::set_by_path(ret, 'Description', @m_description) if withClean || @n_description
|
698
|
+
if withClean || @n_tags
|
699
|
+
Saklient::Util::set_by_path(ret, 'Tags', [])
|
700
|
+
for r1 in @m_tags
|
701
|
+
v = nil
|
702
|
+
v = r1
|
703
|
+
ret[:Tags] << v
|
704
|
+
end
|
705
|
+
end
|
706
|
+
Saklient::Util::set_by_path(ret, 'Icon', withClean ? ((@m_icon).nil? ? nil : @m_icon.api_serialize(withClean)) : ((@m_icon).nil? ? { ID: '0' } : @m_icon.api_serialize_id)) if withClean || @n_icon
|
707
|
+
if withClean || @n_plan
|
708
|
+
Saklient::Util::set_by_path(ret, 'ServerPlan', withClean ? ((@m_plan).nil? ? nil : @m_plan.api_serialize(withClean)) : ((@m_plan).nil? ? { ID: '0' } : @m_plan.api_serialize_id))
|
709
|
+
else
|
710
|
+
missing << 'plan' if @is_new
|
711
|
+
end
|
712
|
+
if withClean || @n_ifaces
|
713
|
+
Saklient::Util::set_by_path(ret, 'Interfaces', [])
|
714
|
+
for r2 in @m_ifaces
|
715
|
+
v = nil
|
716
|
+
v = withClean ? ((r2).nil? ? nil : r2.api_serialize(withClean)) : ((r2).nil? ? { ID: '0' } : r2.api_serialize_id)
|
717
|
+
ret[:Interfaces] << v
|
718
|
+
end
|
719
|
+
end
|
720
|
+
Saklient::Util::set_by_path(ret, 'Instance', withClean ? ((@m_instance).nil? ? nil : @m_instance.api_serialize(withClean)) : ((@m_instance).nil? ? { ID: '0' } : @m_instance.api_serialize_id)) if withClean || @n_instance
|
721
|
+
Saklient::Util::set_by_path(ret, 'Availability', @m_availability) if withClean || @n_availability
|
722
|
+
raise Saklient::Errors::SaklientException.new('required_field', 'Required fields must be set before the Server creation: ' + missing.join(', ')) if missing.length > 0
|
723
|
+
return ret
|
724
|
+
end
|
725
|
+
|
726
|
+
end
|
727
|
+
|
728
|
+
end
|
729
|
+
end
|
730
|
+
end
|