#
# Oracle Disk
#
from vcpsdk.plugins.spec_disk import VcpSpecResourceDisk
CCI_VERSION = "1.0"
BUILD_VERSION = "20200331"
[ドキュメント]
class VcpSpecResourceOracleDisk(VcpSpecResourceDisk):
"""
サンプルコード
.. code-block:: python
spec = sdk.get_spec("oracle_disk", "small")
#
# 変更できること
#
# spec.num_disks = 1
# OracleCloud のコピー元の Volume の OCID を指定
# spec.cloud_image = 'ocid1.volume.oc1.region.abxhi....'
# spec.size_in_gbs = 50 # 50 GB and 32768 GB
"""
version = CCI_VERSION + "+" + BUILD_VERSION
def __init__(self, provider_name, flavor, config_dir):
# flavor から spec を設定
super().__init__(provider_name, flavor, config_dir)
# spec attributes名の設定チェックの回避
super().__setattr__("oracle_cci_", None)
# credentail情報は、vcp_config から設定
self.oracle_cci_ = {"cci_version": CCI_VERSION}
self.oracle_cci_["user_ocid"] = self.vcp_config_["oracle"]["user_ocid"]
self.oracle_cci_["fingerprint"] = self.vcp_config_["oracle"]["fingerprint"]
self.oracle_cci_["private_key"] = self.vcp_config_["oracle"]["private_key"]
# flavorから初期化
self.oracle_cci_["size_in_gbs"] = self.flavor_["size_in_gbs"]
self.oracle_cci_["cloud_image"] = "default"
def __str__(self):
text = """
========================
{provider_name}
------------------------
{unit_info}""".format(
provider_name=self.unit_cci_["cloud_provider"], unit_info=super().__str__()
)
text += """
size_in_gbs: {size_in_gbs}
cloud_image: {cloud_image}""".format_map(
self.oracle_cci_
)
text += """
tags: {}
========================""".format(
self.tags_cci_
)
return text
[ドキュメント]
def cci(self, name):
"""
CCI生成
:param name: unit名
:return: CCI文字列
"""
# cloud parameter 情報
my_cci = super().cci(name)
# yaml schema check
self.cci_schema_.validate(self.oracle_cci_, "oracle_disk")
# cloud_params
my_cci += """
cloud_provider: oracle
cloud_params:
cci_version: "{cci_version}"
size_in_gbs: {size_in_gbs}
cloud_image: {cloud_image}
user_ocid: {user_ocid}
fingerprint: {fingerprint}
private_key: {private_key}""".format_map(
self.oracle_cci_
)
# cloud tagのcci文字列生成
my_cci += self.cci_tags()
return my_cci
# property: size_in_gbs
@property
def size_in_gbs(self):
"""
OracleCloudに依存するdisk size (単位:GB)
.. note::
* VCP SDK flavorで設定可能
"""
return self.oracle_cci_["size_in_gbs"]
@size_in_gbs.setter
def size_in_gbs(self, v):
"""
デスクサイズ
"""
self.oracle_cci_["size_in_gbs"] = v
# property: cloud_image
@property
def cloud_image(self):
"""
OracleCloudに依存するコピー元の Volume の OCID
"""
return self.oracle_cci_["cloud_image"]
@cloud_image.setter
def cloud_image(self, v):
self.oracle_cci_["cloud_image"] = v
def __setattr__(self, name, value):
"""
spec の attributes に不正な値を設定した場合に例外を発生
:param name: attributes名
:param value: 設定値
"""
if not hasattr(self, name):
raise AttributeError("spec resource has no attributes!! [{}]".format(name))
super().__setattr__(name, value)