機械翻訳について

22 起動プラン

このセクションでは、起動プランを使用してインスタンスを作成するために使用できるCompute Classic CLIコマンドについて説明します。

起動プランは1つ以上のインスタンスのプロパティを定義するJSON形式のファイルです。 起動プランを使用して、複数の非永続インスタンスをCompute Classicですばやく作成および開始することができます。 起動プランJSONファイルを再利用して、JSONファイルで指定された属性とプロビジョニング順序に基づいてインスタンスを新たに作成することはできますが、起動プラン自体はCompute Classicでは維持されません。

この節で説明するCLIコマンドを実行する前に、CLIクライアントをインストールして、「CLIを使用するための準備」で説明されているように必要な環境変数を設定していることを確認してください。

コマンド

launch-plan add

このセクションでは、起動プランを使用してインスタンスを作成するために使用できるCompute Classic CLIコマンドについて説明します。

起動プランは、作成するインスタンスのプロビジョニング順序と属性を指定します。 起動プランJSONファイルを再利用して、JSONファイルに指定された属性とプロビジョニング順序に基づいて新しいインスタンスを作成することはできますが、起動プラン自体はCompute Classicでは維持されません。

インスタンスを作成すると、Compute Classicがリソースを割り当ててインスタンスを作成する準備をするため、初期状態はpreparingになります。 次に、状態は「initializing」に変わり、指定したイメージがインストール中であることを示します。 初期化が完了すると、インスタンスの状態はrunningに変わり、OSが起動したことを示します。 インスタンスがrunning状態のときは、それに接続して使用し、アプリケーションを実行できます。 initializingステージが完了した時点からインスタンスを削除するまで、インスタンスに対して請求されます。

前提条件

  • インスタンスの作成時に使用する必要なネットワーク・オブジェクトとストレージ・オブジェクトを作成します。

  • JSONファイルを作成して、作成するCompute Classicインスタンスの属性を指定します。 Oracle Cloud Infrastructure Compute Classicの使用」「起動プランに指定されたインスタンス属性」を参照してください。

  • JSONファイルを作成したら、それを検証する必要があります。 これは、JSONLintなどのサードパーティ・ツールか、または任意の他の検証ツールを使用して行うことができます。 JSON形式が有効でない場合は、オーケストレーションを追加するとエラー・メッセージが表示されます。

必要なロール

このタスクを実行するには、Compute_Operationsのロールが必要です。 このロールが自分に割り当てられていない場合または不確実な場合は、システム管理者にOracle Cloud 「Infrastructure Classicコンソール」でそのロールが割り当てられていることを確認するように依頼してください。 「Oracle Cloudの管理とモニタリング」「ユーザー・ロールの変更」を参照してください。

構文

次のいずれかの構文を使用します。

  • opc compute launch-plan add --request-body=FILE.json

    この構文では、filenameは、起動プランの属性を含むJSON形式のファイルの完全なパスと名前です。 起動プランJSONファイルで指定できる属性については、Oracle Cloud Infrastructure Compute Classicの使用」「起動プランに指定されたインスタンス属性」を参照してください。

  • opc compute launch-plan add instances [--relationships relationship.json]

このコマンドのパラメータとオプションのヘルプについては、-hオプションを指定してコマンドを実行してください。

例1: 単一のJSONファイルにインスタンス属性を指定

opc -f json compute launch-plan add --request-body=launchplan.json

launchplan.jsonの例

以下は、異なるIPアドレスとシェイプを持ち、同じSSHキーと同じイメージを使用する2つのインスタンスの属性を示すJSON形式のファイルの例です。

{
  "instances": [
    {
      "shape": "oc3",
      "imagelist": "/oracle/public/oel_6.4_2GB_v1",
      "name": "/Compute-acme/jack.jones@example.com/dev-vm",
      "label": "dev-vm",
      "sshkeys": [
        "/Compute-acme/jack.jones@example.com/ssh-key1"
      ],
      "networking": {
        "eth0": {
          "seclists": [
            "/Compute-acme/default/default"
          ],
          "nat": "ippool:/oracle/public/ippool"
        }
      }
    },
    {
      "shape": "oc4",
      "imagelist": "/oracle/public/oel_6.4_2GB_v1",
      "name": "/Compute-acme/jack.jones@example.com/prod-vm",
      "label": "prod-vm",
      "sshkeys": [
        "/Compute-acme/jack.jones@example.com/ssh-key1"
      ],
      "networking": {
        "eth0": {
          "seclists": [
            "/Compute-acme/default/default"
          ],
          "nat": "ippool:/oracle/public/ippool"
        }
      }
    }
  ],
  "relationships": [
    {
      "instances": [
        "dev-vm",
        "prod-vm"
      ],
      "type": "different_node"
    }
  ]
}

例2: コマンドラインでのインスタンス属性の指定

opc -f json compute launch-plan add file://launch_instances.json --relationships file://relationship.json

JSONファイルの例

以下は、指定されたインスタンス属性を持つ2つのインスタンスを作成するためにlaunch_instances.jsonファイルで指定されたインスタンス属性の例を示しています。 これらのインスタンス間の関係は、relationship.jsonファイルで定義されています。

launch_instances.jsonファイルの例

{
  "instances": [
    {
      "shape": "oc3",
      "imagelist": "/oracle/public/oel6",
      "name": "/Compute-acme/jack.jones@example.com/dev-vm",
      "label": "dev-vm",
      "sshkeys": [
        "/Compute-acme/jack.jones@example.com/ssh-key1"
      ],
      "networking": {
        "eth0": {
          "seclists": [
            "/Compute-acme/default/default"
          ],
          "nat": "ippool:/oracle/public/ippool"
        }
      }
    },
    {
      "shape": "oc4",
      "imagelist": "/oracle/public/oel6",
      "name": "/Compute-acme/jack.jones@example.com/prod-vm",
      "label": "prod-vm",
      "sshkeys": [
        "/Compute-acme/jack.jones@example.com/ssh-key1"
      ],
      "networking": {
        "eth0": {
          "seclists": [
            "/Compute-acme/default/default"
          ],
          "nat": "ippool:/oracle/public/ippool"
        }
      }
    }
  ]
}

relationship.jsonファイルの例

{
	"relationships": [{
		"instances": [
			"dev-vm",
			"prod-vm"
		],
		"type": "different_node"
	}]
}

サンプル出力

読みやすくするため、一部の行は省略記号(...)を使用して省略されています。 実際の環境でコマンドを実行すると、完全な出力が表示されます。

{
 "instances": [
  {
   "account": "/Compute-acme/default",
   "attributes": {
    "sshkeys": [
     "ssh-rsa AAAAB3NzaC1y..."
    ]
   },
   "availability_domain": null,
   "boot_order": [],
   "cluster": null,
   "cluster_uri": null,
   "console": null,
   "delete_requested": null,
   "desired_state": "running",
   "disk_attach": "",
   "domain": "compute-acme.oraclecloud.internal.",
   "entry": 1,
   "error_exception": null,
   "error_reason": "",
   "fingerprint": "",
   "higgs": null,
   "hostname": "a83333.compute-acme.oraclecloud.internal.",
   "hypervisor": {
    "mode": "hvm"
   },
   "hypervisor_type": null,
   "id": "7221d5b3-1770-4a34-9a24-ab6a0e0ed871",
   "image_format": "raw",
   "imagelist": "/oracle/public/oel6",
   "ip": "0.0.0.0",
   "label": "dev-vm",
   "last_seen": null,
   "last_state_change_time": null,
   "launch_context": "1703085e6316f319d1f3b16fe5669f73be229b",
   "metrics": null,
   "name": "/Compute-acme/jack.jones@example.com/dev-vm/7221d5b3-1770-4a34-9a24-ab6a0e0ed871",
   "nat_associations": null,
   "networking": {
    "eth0": {
     "dns": [
      "a83333.compute-acme.oraclecloud.internal."
     ],
     "model": "",
     "nat": "ippool:/oracle/public/ippool",
     "seclists": [
      "/Compute-acme/default/default"
     ],
     "vethernet": "/oracle/public/default"
    }
   },
   "node": null,
   "node_uuid": null,
   "numerical_priority": 100,
   "placement_requirements": [
    "/system/compute/placement/default",
    "/system/compute/allow_instances"
   ],
   "platform": "linux",
   "priority": "/oracle/public/default",
   "quota": "/Compute-acme",
   "quota_reservation": null,
   "relationships": [],
   "resolvers": null,
   "resource_requirements": {
    "compressed_size": 376848450,
    "cpus": 2.0,
    "decompressed_size": 5905612288,
    "gpus": 0,
    "io": 200,
    "is_root_ssd": false,
    "ram": 7680,
    "root_disk_size": 0,
    "ssd_data_size": 0
   },
   "reverse_dns": true,
   "seclist_associations": null,
   "shape": "oc3",
   "site": "",
   "sshkeys": [
    "/Compute-acme/jack.jones@example.com/ssh-key1"
   ],
   "start_requested": false,
   "start_time": "2017-03-08T09:29:58Z",
   "state": "queued",
   "storage_attachment_associations": [],
   "storage_attachments": [],
   "suspend_file": null,
   "suspend_requested": false,
   "tags": [],
   "target_node": null,
   "tracking_id": null,
   "uri": "http://api-z999.compute.us0.oraclecloud.com/instance/Compute-acme/jack.jones@example.com/dev-vm/7221d5b3-1770-4a34-9a24-ab6a0e0ed871",
   "vcable_id": null,
   "vethernets": null,
   "virtio": null,
   "vnc": "",
   "vnc_key": null
  },
  {
   "account": "/Compute-acme/default",
   "attributes": {
    "sshkeys": [
     "ssh-rsa AAAAB3NzaC..."
    ]
   },
   "availability_domain": null,
   "boot_order": [],
   "cluster": null,
   "cluster_uri": null,
   "console": null,
   "delete_requested": null,
   "desired_state": "running",
   "disk_attach": "",
   "domain": "compute-acme.oraclecloud.internal.",
   "entry": 1,
   "error_exception": null,
   "error_reason": "",
   "fingerprint": "",
   "higgs": null,
   "hostname": "f12678.compute-acme.oraclecloud.internal.",
   "hypervisor": {
    "mode": "hvm"
   },
   "hypervisor_type": null,
   "id": "fb68c7c1-e61f-4090-b46c-bfd5ba5a699b",
   "image_format": "raw",
   "imagelist": "/oracle/public/oel6",
   "ip": "0.0.0.0",
   "label": "prod-vm",
   "last_seen": null,
   "last_state_change_time": null,
   "launch_context": "1703085e6316f319d1f3b16fe5669f73be229b",
   "metrics": null,
   "name": "/Compute-acme/jack.jones@example.com/prod-vm/fb68c7c1-e61f-4090-b46c-bfd5ba5a699b",
   "nat_associations": null,
   "networking": {
    "eth0": {
     "dns": [
      "f12678.compute-acme.oraclecloud.internal."
     ],
     "model": "",
     "nat": "ippool:/oracle/public/ippool",
     "seclists": [
      "/Compute-acme/default/default"
     ],
     "vethernet": "/oracle/public/default"
    }
   },
   "node": null,
   "node_uuid": null,
   "numerical_priority": 100,
   "placement_requirements": [
    "/system/compute/placement/default",
    "/system/compute/allow_instances"
   ],
   "platform": "linux",
   "priority": "/oracle/public/default",
   "quota": "/Compute-acme",
   "quota_reservation": null,
   "relationships": [],
   "resolvers": null,
   "resource_requirements": {
    "compressed_size": 376848450,
    "cpus": 4.0,
    "decompressed_size": 5905612288,
    "gpus": 0,
    "io": 400,
    "is_root_ssd": false,
    "ram": 15360,
    "root_disk_size": 0,
    "ssd_data_size": 0
   },
   "reverse_dns": true,
   "seclist_associations": null,
   "shape": "oc4",
   "site": "",
   "sshkeys": [
    "/Compute-acme/jack.jones@example.com/ssh-key1"
   ],
   "start_requested": false,
   "start_time": "2017-03-08T09:29:58Z",
   "state": "queued",
   "storage_attachment_associations": [],
   "storage_attachments": [],
   "suspend_file": null,
   "suspend_requested": false,
   "tags": [],
   "target_node": null,
   "tracking_id": null,
   "uri": "http://api-z999.compute.us0.oraclecloud.com/instance/Compute-acme/jack.jones@example.com/prod-vm/fb68c7c1-e61f-4090-b46c-bfd5ba5a699b",
   "vcable_id": null,
   "vethernets": null,
   "virtio": null,
   "vnc": "",
   "vnc_key": null
  }
 ],
 "relationships": [
  {
   "instances": [
    "dev-vm",
    "prod-vm"
   ],
   "type": "different_node"
  }
 ]
}