genvid.toolbox.BastionAPI
- class genvid.toolbox.BastionAPI(use_wan=False, **kwargs)
ベースクラス:
BaseHttpApiTool
,ConsulTool
Bastion API のクライアント。
バージョン 1.20.0 で変更: use_wan アドレスパラメータを追加。デフォルトは False。True の場合、TaggedAddresses "wan" を使用して bastion-api をリソルブ。
- NAME = 'bastion-api'
このツールのロガー名。子 class (children) で再定義する必要があります。
- get_bastion_version(timeout=0.0) str
このbastion インスタンスのバージョンを取得します。
- パラメータ
timeout -- サービスが準備完了になるまでの待機時間のタイムアウト。
バージョン 1.20.0 で追加.
- get_links(category: str = '', link_id: str = '', timeout=0.0)
リンクのリストを取得する。
- パラメータ
category -- リンクのカテゴリ。
link_id -- リンクの ID。
timeout -- タイムアウト (秒)。
- 戻り値
文字列のリスト。
- get_backend(backend_id: str, timeout=0.0) dict
バックエンドテンプレートを取得する。
- パラメータ
backend_id -- バックエンド ID
timeout -- タイムアウト (秒)。
- add_backend(backend_id: str, backend_type: str, variables: dict = {}, timeout=0.0)
新しいバックエンドテンプレートを追加。
- パラメータ
backend_id -- バックエンド ID
backend_type -- バックエンドのタイプ。
variables -- バックエンドのデフォルト値のリスト。
timeout -- タイムアウト (秒)。
- update_backend(backend_id: str, backend_type: str, variables: dict = {}, timeout=0.0)
既存のバックエンドテンプレートを更新する。
- パラメータ
backend_id -- バックエンド ID
backend_type -- バックエンドのタイプ。
variables -- バックエンドのデフォルト値のリスト。
timeout -- タイムアウト (秒)。
- delete_backend(backend_id: str, timeout=0.0)
バックエンドテンプレートを削除する。
- パラメータ
backend_id -- バックエンド ID
timeout -- タイムアウト (秒)。
- get_clusters(timeout=0.0, *, query_parameters: str = '') List[dict]
BastionAPI にすべてのクラスタを照会する。
- パラメータ
query_parameters -- 文字列。リクエスト URL の末尾に追加される
?
で始まり、クエリパラメータと解釈される。timeout -- 試行を中止するまでの最大待機時間。
バージョン 1.21.0 で変更:
query_parameters
キーワードのみの引数を追加し、クエリの詳細なカスタマイズができるようになりました。
- get_cluster(cluster_id: str, timeout=0.0) dict
クラスタを取得する。
- パラメータ
cluster_id -- クラスタ ID。
timeout -- タイムアウト (秒)。
- set_cluster(cluster_id: str, backend_id: str = 'default', backend_variables: dict = {}, category: str = '', is_static: bool = False, static_output: dict = {}, timeout=0.0) None
クラスタを作成する。
- パラメータ
cluster_id -- クラスタ ID。
backend_id -- バックエンド ID
backend_variables -- バックエンド変数。
category -- クラスタのカテゴリ。
is_static -- クラスタが静的かどうか。
static_output -- 静的クラスタの出力。Terraform に似ています。
timeout -- タイムアウト (秒)。
バージョン 1.13.0 で変更: is_static と server_public_ips の新しい引数。
- delete_cluster(cluster_id: str, force: bool = False, timeout=0.0) None
クラスタを削除する。
- パラメータ
cluster_id -- クラスタ ID。
force -- クラスタを強制的に削除する
timeout -- タイムアウト (秒)。
- update_cluster_static(cluster_id: str, output: dict = {}, timeout=0.0) None
静的なクラスタを更新します。
- パラメータ
cluster_id -- クラスタ ID。
output -- 静的クラスタの出力。Terraform に似ています。
timeout -- タイムアウト (秒)。
バージョン 1.42.0 で追加.
- cluster_get_setup_jobs(cluster_id: str, timeout=0.0) List[dict]
セットアップジョブのリストを取得する。
- パラメータ
cluster_id -- クラスタ ID。
timeout -- タイムアウト (秒)。
- 戻り値
セットアップジョブの定義のリスト。
- cluster_set_setup_jobs(cluster_id: str, jobs: List[dict], timeout=0.0)
セットアップジョブのリストを設定する。
- パラメータ
cluster_id -- クラスタ ID。
jobs -- セットアップジョブの定義のリスト。
timeout -- タイムアウト (秒)。
- cluster_do_setup(cluster_id, timeout=0.0)
クラスタに setup を実行する。このアクションは、cluster-api を開始するために使用する。
- パラメータ
cluster_id -- クラスタ ID。
timeout -- タイムアウト (秒)。
- 戻り値
- cluster_do_clean(cluster_id, timeout=0.0)
クラスタに clean を実行する。このアクションは、Nomad のすべてのジョブを停止し、Consul KV を削除する。
- パラメータ
cluster_id -- クラスタ ID。
timeout -- タイムアウト (秒)。
- 戻り値
- get_cluster_service(cluster_id, service_id, timeout=0.0) List[str]
サービスアドレスを取得する。
- パラメータ
cluster_id -- クラスタ ID。
service_id -- サービス ID。
timeout -- タイムアウト (秒)。
- 戻り値
- get_cluster_images(cluster_id, timeout=0.0) dict
複数のイメージの定義を取得する。
- パラメータ
cluster_id -- クラスタ ID。
timeout -- タイムアウト (秒)。
- 戻り値
イメージ定義に関連付けられたデータ。
- set_cluster_images(cluster_id, data: dict, timeout=0.0)
複数のイメージの定義を設定する。
- パラメータ
cluster_id -- クラスタ ID。
data -- イメージに関連付けられたデータ。
timeout -- タイムアウト (秒)。
- delete_cluster_images(cluster_id, timeout=0.0)
複数のイメージの定義を削除する。
- パラメータ
cluster_id -- クラスタ ID。
timeout -- タイムアウト (秒)。
- delete_cluster_image(cluster_id, image_id: str, timeout=0.0)
リンク定義を削除する。
- パラメータ
cluster_id -- クラスタ ID。
image_id -- 画像 ID
timeout -- タイムアウト (秒)。
- get_global(timeout=0.0, retry_request: bool = False) dict
グローバル設定を取得する。
- パラメータ
timeout -- タイムアウト (秒)。
- set_global(bastion_id: str, timeout=0.0)
グローバル設定を設定する。
- パラメータ
bastion_id -- bastion ID。複数の bastion を隔離させるために使用します。
timeout -- タイムアウト (秒)。
- terraform_get_modules(prefix: str = '', timeout=0.0) List[dict]
モジュールのリストを返す。
- パラメータ
prefix -- モジュールをフィルタリングするプレフィックス。
timeout -- タイムアウト (秒)。
- 戻り値
モジュールのリスト。
- terraform_get_module(moduleId: str, timeout=0.0) dict
モジュールの情報を返す。
- パラメータ
moduleId -- モジュールパス。
timeout -- タイムアウト (秒)。
- 戻り値
モジュールの定義。
- terraform_get_repositories(timeout=0.0) Dict[str, dict]
Terraform レポジトリのリストを返す。
- パラメータ
timeout -- タイムアウト (秒)。
- 戻り値
名前によるレポジトリの map。
- terraform_add_repository(name: str, config: dict, timeout=0.0) dict
レポジトリを追加する。
- パラメータ
name -- レポジトリのユニーク名。
config -- レポジトリ設定を含むディレクトリ。
- 戻り値
レポジトリ設定。
- terraform_update_repository(name: str, config: dict = {}, timeout=0.0) dict
既存のレポジトリを更新する。
- パラメータ
name -- レポジトリ名。
config -- レポジトリ構成の辞書 (オプション)。
- 戻り値
レポジトリ設定。
- terraform_remove_repository(name: str, timeout=0.0) dict
レポジトリを削除する。
- パラメータ
name -- レポジトリ名。
- 戻り値
レポジトリ設定。
- terraform_get_instances(timeout=0.0) List[dict]
Terraform インスタンスを取得する。
- パラメータ
timeout -- タイムアウト (秒)。
- terraform_get_instance(instance_id: str, timeout=0.0) dict
指定した Terraform インスタンスを取得する。
- パラメータ
instance_id -- インスタンス ID。
timeout -- タイムアウト (秒)。
- terraform_get_global_tfvars(timeout=0.0) dict
グローバル tfvars コンテンツを取得する。
- パラメータ
timeout -- タイムアウト (秒)。
- terraform_set_global_tfvars(tfvars: dict, timeout=0.0) str
グローバル tfvars のコンテンツを設定します。
- パラメータ
tfvars -- tfvars のコンテンツ。
timeout -- タイムアウト (秒)。
- terraform_clean_global_tfvars(timeout=0.0) str
グローバル tfvars コンテンツを消去する。
- パラメータ
timeout -- タイムアウト (秒)。
- terraform_get_instance_tfvars_default(instance_id: str, timeout=0.0) str
インスタンス tfvars コンテンツを取得する。
- パラメータ
instance_id -- インスタンス ID。
timeout -- タイムアウト (秒)。
- terraform_get_instance_tfvars(instance_id: str, timeout=0.0) str
インスタンス tfvars コンテンツを取得する。
- パラメータ
instance_id -- インスタンス ID。
timeout -- タイムアウト (秒)。
- terraform_set_instance_tfvars(instance_id: str, tfvars: dict, timeout=0.0)
インスタンス tfvars のコンテンツを設定する。
- パラメータ
instance_id -- インスタンス ID。
tfvars -- tfvars のコンテンツ。
timeout -- タイムアウト (秒)。
- terraform_get_instance_schema(instance_id: str, timeout=0.0) str
変数のインスタンススキーマを取得します。
- パラメータ
instance_id -- インスタンス ID。
timeout -- タイムアウト (秒)。
- terraform_get_instance_content(instance_id: str, content_id: str, timeout=0.0)
.tf.json Terraform ファイルコンテンツを取得する。
- パラメータ
instance_id -- インスタンス ID。
content_id -- Terraform ファイル ID。
timeout -- タイムアウト (秒)。
- 戻り値
指定ファイルの中身 (JSON)。
- terraform_set_instance_content(instance_id: str, content_id: str, content: dict, timeout=0.0)
.tf.json Terraform ファイルコンテンツを設定する。
- パラメータ
instance_id -- インスタンス ID。
content_id -- Terraform ファイル ID。
content -- Terraform ファイルの中身。
timeout -- タイムアウト (秒)。
- terraform_delete_instance_content(instance_id: str, content_id: str, timeout=0.0)
.tf.json Terraform ファイルコンテンツを削除する。
- パラメータ
instance_id -- インスタンス ID。
content_id -- Terraform ファイル ID。
timeout -- タイムアウト (秒)。
- terraform_get_instance_status(instance_id: str, timeout=0.0) dict
インスタンスのステータスを取得します。
インスタンスのステータスは、次の通りです。
VOID: インスタンスが存在しません。
EMPTY: インスタンスが存在するが、初期化されていない。
- DOWN: インスタンスが初期化されているが、リソースが
含まれていない。
UP: インスタンスがいくつかのリソースを制御しています。
BUSY: インスタンスがコマンドを実行中です。
ERROR: ステータスの取得中にエラーが発生しました。
INVALID: インスタンスの現在のステータスが不明です。
- パラメータ
instance_id -- インスタンス ID。
timeout -- タイムアウト (秒)。
- 戻り値
単一キー status の辞書。
- terraform_wait_on_instance(instance_id: str, *, timeout: int = 60, increment: int = 1)
特定インスタンスがTerraform コマンド実行完了を待機。
具体的には、コマンドが 'BUSY' 以外に変化するのを待ちます。
- パラメータ
instance_id -- 待機するインスタンスの ID。
timeout -- 最大待機時間。
increment -- 各ステータスクエリ間の待機時間。
- terraform_do_instance_get(instance_id: str, timeout=0.0) dict
インスタンスに terraform get を実行する。
- パラメータ
instance_id -- インスタンス ID。
timeout -- タイムアウト (秒)。
- terraform_get_providers(instance_id: str, *, timeout=0.0) Sequence[TerraformProvider]
指定のインスタンスが通知されているすべてのプロバイダを取得。
- パラメータ
instance_id -- 処理を行うクラスタのインスタンス ID。
timeout -- タイムアウト (秒)。
- 戻り値
既知のプロバイダ (シーケンス)
- terraform_get_default_providers(*, timeout=0.0) Sequence[TerraformProvider]
すべてのプロバイダのグローバルなデフォルト構成を取得する。
- パラメータ
timeout -- タイムアウト (秒)。
- 戻り値
既知のプロバイダ (シーケンス)
- terraform_put_providers(instance_id: str, providers: Iterable[TerraformProvider], *, timeout=0.0) dict
指定のインスタンスのすべてのプロバイダ構成をオーバーライドする。
- パラメータ
instance_id -- 処理を行うクラスタのインスタンス ID。
providers -- 使用する新しいプロバイダ構成。
timeout -- タイムアウト (秒)。
- 戻り値
bastion API の応答。 {} となります。
- terraform_put_default_providers(providers: Iterable[TerraformProvider], *, timeout=0.0) dict
すべてのプロバイダのグローバルなデフォルト構成をオーバーライドする。
- パラメータ
providers -- 使用する新しいプロバイダ構成。
timeout -- タイムアウト (秒)。
- 戻り値
bastion API の応答。 {} となります。
- terraform_delete_providers(instance_id: str, *, timeout=0.0) dict
指定のインスタンスのすべてのプロバイダ構成をオーバーライドする。
- パラメータ
instance_id -- 処理を行うクラスタのインスタンス ID。
timeout -- タイムアウト (秒)。
- 戻り値
bastion API の応答。 {} となります。
- terraform_delete_default_providers(*, timeout=0.0) dict
すべてのプロバイダのグローバルなデフォルト構成を削除する。
- パラメータ
timeout -- タイムアウト (秒)。
- 戻り値
bastion API の応答。 {} となります。
- terraform_get_provider(instance_id: str, provider_name: str, provider_alias: Optional[str] = None, *, timeout=0.0) TerraformProvider
指定のクラスタの指定のプロバイダ構成を取得する。
- パラメータ
instance_id -- 処理を行うクラスタのインスタンス ID。
provider_name -- プロバイダ名。
provider_alias -- プロバイダのオプションエイリアス。
timeout -- タイムアウト (秒)。
- 戻り値
一致するプロバイダ。
- terraform_get_default_provider(provider_name: str, provider_alias: Optional[str] = None, *, timeout=0.0) Sequence[TerraformProvider]
指定のプロバイダのグローバルなデフォルト構成を取得する。
- パラメータ
provider_name -- プロバイダ名。
provider_alias -- プロバイダのオプションエイリアス。
timeout -- タイムアウト (秒)。
- 戻り値
一致するプロバイダ。
- terraform_put_provider(instance_id: str, provider: TerraformProvider, *, timeout=0.0) dict
指定のインスタンスのプロバイダ構成をオーバーライドする。
- パラメータ
instance_id -- 処理を行うクラスタのインスタンス ID。
provider -- バックエンドに送信するプロバイダ構成。
timeout -- タイムアウト (秒)。
- 戻り値
bastion API の応答。 {} となります。
- terraform_put_default_provider(provider: TerraformProvider, *, timeout=0.0) dict
指定のプロバイダのグローバルなデフォルト構成をオーバーライドする。
- パラメータ
providers -- 使用する新しいプロバイダ構成。
timeout -- タイムアウト (秒)。
- 戻り値
bastion API の応答。 {} となります。
- terraform_delete_provider(instance_id: str, provider_name: str, provider_alias: Optional[str] = None, *, timeout=0.0) dict
指定のクラスタの指定のプロバイダを削除する。
- パラメータ
instance_id -- 処理を行うクラスタのインスタンス ID。
provider_name -- プロバイダ名。
provider_alias -- プロバイダのオプションエイリアス。
timeout -- タイムアウト (秒)。
- 戻り値
bastion API の応答。 {} となります。
- terraform_delete_default_provider(provider_name: str, provider_alias: Optional[str] = None, *, timeout=0.0) dict
指定のプロバイダのグローバルなデフォルト構成を削除する。
- パラメータ
provider_name -- プロバイダ名。
provider_alias -- プロバイダのオプションエイリアス。
timeout -- タイムアウト (秒)。
- 戻り値
bastion API の応答。 {} となります。
- terraform_do_instance_import_module(instance_id: str, module_path: str = 'cluster/default', timeout=0.0, force: bool = False, **kwargs) dict
インスタンスに terraform init を実行する。
- パラメータ
instance_id -- インスタンス ID。
module_path -- 使用するモジュール。
timeout -- タイムアウト (秒)。
force -- クラスタがエラー状態であっても、強制的にインポートを行う。
- terraform_do_instance_init(instance_id: str, timeout: float = 0.0, force: bool = False) dict
インスタンスに terraform init を実行する。
- パラメータ
instance_id -- インスタンス ID。
timeout -- タイムアウト (秒)。
force -- クラスタがエラー状態であっても、強制的に初期化を行う。
- terraform_do_instance_refresh(instance_id: str, timeout=0.0) dict
インスタンスに terraform refresh を実行する。
- パラメータ
instance_id -- インスタンス ID。
timeout -- タイムアウト (秒)。
- terraform_regenerate_instance(instance_id: str, timeout=0.0) dict
インスタンスの Terraform 作業ディレクトリを再生成する。
- パラメータ
instance_id -- インスタンスの ID。
timeout -- タイムアウト (秒)。
バージョン 1.21 で追加.
- terraform_do_instance_plan(instance_id: str, destroy: bool = False, timeout=0.0) dict
インスタンスに terraform plan を実行する。
- パラメータ
instance_id -- インスタンス ID。
destroy -- destroy plan を実行する。
timeout -- タイムアウト (秒)。
- terraform_do_instance_apply(instance_id: str, timeout=0.0) dict
インスタンスに terraform apply を実行する。
- パラメータ
instance_id -- インスタンス ID。
timeout -- タイムアウト (秒)。
- terraform_do_instance_apply_plan(instance_id: str, plan_file: str, timeout=0.0) dict
gicen プランファイルのインスタンスに terraform apply を実行します。プランファイル名は通常、plan コマンドのコマンド ID になります。
- パラメータ
instance_id -- インスタンス ID。
plan_file -- プランファイル名。
timeout -- タイムアウト (秒)。
- terraform_do_instance_destroy(instance_id: str, timeout=0.0) dict
インスタンスに terraform destroy を実行する。
- パラメータ
instance_id -- インスタンス ID。
timeout -- タイムアウト (秒)。
- terraform_do_instance_output(instance_id: str, timeout=0.0) dict
terraform output コマンドを返す。
- パラメータ
instance_id -- インスタンス ID。
timeout -- タイムアウト (秒)。
- terraform_get_instance_commands(instance_id: str, current: bool = True, timeout=0.0) List[dict]
Terraform インスタンスに関連するコマンドを取得する。
- パラメータ
instance_id -- インスタンス ID。
current -- True の場合、実行中のコマンドのみを返す。
timeout -- タイムアウト (秒)。
- terraform_get_instance_command(instance_id: str, command_id: str, timeout=0.0) dict
インスタンス ID とコマンド ID のコマンドベースを取得する。
- パラメータ
instance_id -- インスタンス ID。
command_id -- コマンド ID。
timeout -- タイムアウト (秒)。
- terraform_wait_instance_command(instance_id: str, command_id: str, timeout=0.0) dict
インスタンス ID とコマンド ID のコマンドベースを取得する。
- パラメータ
instance_id -- インスタンス ID。
command_id -- コマンド ID。
timeout -- タイムアウト (秒)。
- terraform_get_instance_command_log(instance_id: str, command_id: str, origin: str = 'start', offset: int = 0, size: int = 20000, timeout=0.0) dict
インスタンスのコマンドログを取得する。
- パラメータ
instance_id -- インスタンス ID。
command_id -- コマンド ID。
origin -- ログが 開始 からか、終了 からか。
offset -- 原点に関連するオフセット。
size -- 戻り値の最大サイズが返されます。
timeout -- タイムアウト (秒)。
- terraform_print_command_log(instance_id: str, command_id: str, output=None, tail=False, follow=False, lines: int = 10, timeout=0.0)
出力時にコマンドログを出力する。
- パラメータ
instance_id -- インスタンス ID。
command_id -- コマンド ID。
output -- None の場合、デフォルトは stdout。
tail -- True の場合、ログの最後を出力する。
follow -- True の場合、実行中ログ表示を継続。
lines -- 表示するラインの概数。
timeout -- タイムアウト (秒)。
- get_bastion_id()
Bastion ID を取得します。
:raises RuntimeError : bastion ID が設定されていない場合。 :return : Bastion ID
- render_template(content: Optional[str] = None, templatePath: Optional[str] = None, sources: Optional[str] = None, environment: Optional[Dict[str, str]] = None, timeout=5.0) dict
サーバーで consul-template を実行し、結果を返す。
- パラメータ
content -- レンダリングされるテンプレートの内容。
templatePath
を使用する場合はNone または空でなければなりません。templatePath -- ソース内のテンプレートのパス。
content
が使用される場合は None 又は空に設定する必要があり、sources
は提供されなければなりません。sources -- ソースのためのURL
templatePath
が設定されている場合は、必ず指定してください。environment -- 環境変数の辞書です。キーと値は文字列であること。
timeout -- タイムアウト (秒)。
- 戻り値
例: { "data": "result", "stderr": "message"}
バージョン 1.33.0 で追加.
- class bastion_api.BastionAPI