# This is an automatically generated code sample.
# To make this code sample work in your Oracle Cloud tenancy,
# please replace the values for any parameters whose current values do not fit
# your use case (such as resource IDs, strings containing ‘EXAMPLE’ or ‘unique_id’, and
# boolean, number, and enum parameters with values not fitting your use case).

import oci

# Create a default config using DEFAULT profile in default location
# Refer to
# https://docs.cloud.oracle.com/en-us/iaas/Content/API/Concepts/sdkconfig.htm#SDK_and_CLI_Configuration_File
# for more info
config = oci.config.from_file()


# Initialize service client with default config file
core_client = oci.core.ComputeClient(config)


# Send the request to service, some parameters are not required, see API
# doc for more info
launch_instance_response = core_client.launch_instance(
    launch_instance_details=oci.core.models.LaunchInstanceDetails(
        availability_domain="EXAMPLE-availabilityDomain-Value",
        compartment_id="ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value",
        capacity_reservation_id="ocid1.test.oc1..<unique_ID>EXAMPLE-capacityReservationId-Value",
        create_vnic_details=oci.core.models.CreateVnicDetails(
            assign_ipv6_ip=False,
            assign_public_ip=False,
            assign_private_dns_record=False,
            defined_tags={
                'EXAMPLE_KEY_g8LlN': {
                    'EXAMPLE_KEY_84bD1': 'EXAMPLE--Value'}},
            display_name="EXAMPLE-displayName-Value",
            freeform_tags={
                'EXAMPLE_KEY_uY2RW': 'EXAMPLE_VALUE_oazq08nBPoXqWm4Hiren'},
            security_attributes={
                'EXAMPLE_KEY_i9Dvb': {
                    'EXAMPLE_KEY_ztcwV': 'EXAMPLE--Value'}},
            hostname_label="EXAMPLE-hostnameLabel-Value",
            ipv6_address_ipv6_subnet_cidr_pair_details=[
                oci.core.models.Ipv6AddressIpv6SubnetCidrPairDetails(
                    ipv6_subnet_cidr="EXAMPLE-ipv6SubnetCidr-Value",
                    ipv6_address="EXAMPLE-ipv6Address-Value")],
            nsg_ids=["EXAMPLE--Value"],
            private_ip="EXAMPLE-privateIp-Value",
            skip_source_dest_check=False,
            subnet_id="ocid1.test.oc1..<unique_ID>EXAMPLE-subnetId-Value",
            vlan_id="ocid1.test.oc1..<unique_ID>EXAMPLE-vlanId-Value"),
        dedicated_vm_host_id="ocid1.test.oc1..<unique_ID>EXAMPLE-dedicatedVmHostId-Value",
        defined_tags={
            'EXAMPLE_KEY_9ZCTI': {
                'EXAMPLE_KEY_TNi1Y': 'EXAMPLE--Value'}},
        security_attributes={
            'EXAMPLE_KEY_wHnVS': {
                'EXAMPLE_KEY_SnAIl': 'EXAMPLE--Value'}},
        display_name="EXAMPLE-displayName-Value",
        extended_metadata={
            'EXAMPLE_KEY_VUXFk': 'EXAMPLE--Value'},
        fault_domain="EXAMPLE-faultDomain-Value",
        cluster_placement_group_id="ocid1.test.oc1..<unique_ID>EXAMPLE-clusterPlacementGroupId-Value",
        freeform_tags={
            'EXAMPLE_KEY_XKTpu': 'EXAMPLE_VALUE_IjfEVLfMMLqOLsde2hMH'},
        compute_cluster_id="ocid1.test.oc1..<unique_ID>EXAMPLE-computeClusterId-Value",
        hostname_label="EXAMPLE-hostnameLabel-Value",
        image_id="ocid1.test.oc1..<unique_ID>EXAMPLE-imageId-Value",
        ipxe_script="EXAMPLE-ipxeScript-Value",
        launch_options=oci.core.models.LaunchOptions(
            boot_volume_type="ISCSI",
            firmware="UEFI_64",
            network_type="E1000",
            remote_data_volume_type="SCSI",
            is_pv_encryption_in_transit_enabled=False,
            is_consistent_volume_naming_enabled=True),
        instance_options=oci.core.models.InstanceOptions(
            are_legacy_imds_endpoints_disabled=True),
        availability_config=oci.core.models.LaunchInstanceAvailabilityConfigDetails(
            is_live_migration_preferred=True,
            recovery_action="STOP_INSTANCE"),
        preemptible_instance_config=oci.core.models.PreemptibleInstanceConfigDetails(
            preemption_action=oci.core.models.TerminatePreemptionAction(
                type="TERMINATE",
                preserve_boot_volume=False)),
        metadata={
            'EXAMPLE_KEY_CQw0o': 'EXAMPLE_VALUE_1kAM5ttysKZ4VzHR9aRo'},
        agent_config=oci.core.models.LaunchInstanceAgentConfigDetails(
            is_monitoring_disabled=True,
            is_management_disabled=False,
            are_all_plugins_disabled=True,
            plugins_config=[
                oci.core.models.InstanceAgentPluginConfigDetails(
                    name="EXAMPLE-name-Value",
                    desired_state="DISABLED")]),
        shape="EXAMPLE-shape-Value",
        shape_config=oci.core.models.LaunchInstanceShapeConfigDetails(
            ocpus=1535.1438,
            vcpus=352,
            memory_in_gbs=6225.1807,
            baseline_ocpu_utilization="BASELINE_1_2",
            nvmes=5),
        source_details=oci.core.models.InstanceSourceViaImageDetails(
            source_type="image",
            boot_volume_size_in_gbs=801,
            image_id="ocid1.test.oc1..<unique_ID>EXAMPLE-imageId-Value",
            kms_key_id="ocid1.test.oc1..<unique_ID>EXAMPLE-kmsKeyId-Value",
            boot_volume_vpus_per_gb=178,
            instance_source_image_filter_details=oci.core.models.InstanceSourceImageFilterDetails(
                compartment_id="ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value",
                defined_tags_filter={
                    'EXAMPLE_KEY_Hlz4x': {
                        'EXAMPLE_KEY_fZG6t': 'EXAMPLE--Value'}},
                operating_system="EXAMPLE-operatingSystem-Value",
                operating_system_version="EXAMPLE-operatingSystemVersion-Value")),
        subnet_id="ocid1.test.oc1..<unique_ID>EXAMPLE-subnetId-Value",
        launch_volume_attachments=[
            oci.core.models.LaunchAttachIScsiVolumeDetails(
                type="iscsi",
                device="EXAMPLE-device-Value",
                display_name="EXAMPLE-displayName-Value",
                is_read_only=True,
                is_shareable=False,
                volume_id="ocid1.test.oc1..<unique_ID>EXAMPLE-volumeId-Value",
                launch_create_volume_details=oci.core.models.LaunchCreateVolumeFromAttributes(
                    volume_creation_type="ATTRIBUTES",
                    size_in_gbs=728,
                    compartment_id="ocid1.test.oc1..<unique_ID>EXAMPLE-compartmentId-Value",
                    display_name="EXAMPLE-displayName-Value",
                    kms_key_id="ocid1.test.oc1..<unique_ID>EXAMPLE-kmsKeyId-Value",
                    vpus_per_gb=873),
                use_chap=False,
                encryption_in_transit_type="NONE",
                is_agent_auto_iscsi_login_enabled=True)],
        is_pv_encryption_in_transit_enabled=True,
        platform_config=oci.core.models.AmdRomeBmGpuLaunchInstancePlatformConfig(
            type="AMD_ROME_BM_GPU",
            is_secure_boot_enabled=False,
            is_trusted_platform_module_enabled=True,
            is_measured_boot_enabled=False,
            is_memory_encryption_enabled=True,
            numa_nodes_per_socket="NPS4",
            is_symmetric_multi_threading_enabled=False,
            is_access_control_service_enabled=True,
            are_virtual_instructions_enabled=True,
            is_input_output_memory_management_unit_enabled=False,
            config_map={
                'EXAMPLE_KEY_9cD4z': 'EXAMPLE_VALUE_ToPZJnLgERUC58lMM9dY'}),
        instance_configuration_id="ocid1.test.oc1..<unique_ID>EXAMPLE-instanceConfigurationId-Value",
        licensing_configs=[
            oci.core.models.LaunchInstanceWindowsLicensingConfig(
                type="WINDOWS",
                license_type="OCI_PROVIDED")]),
    opc_retry_token="EXAMPLE-opcRetryToken-Value")

# Get the data from response
print(launch_instance_response.data)

Was this article helpful?