Skip to main content

vnic_attachments

Creates, updates, deletes, gets or lists a vnic_attachments resource.

Overview​

Namevnic_attachments
TypeResource
Idoci.compute.vnic_attachments

Fields​

The following fields are returned by SELECT queries:

The VNIC attachment was retrieved.

NameDatatypeDescription
idstringThe OCID of the VNIC attachment.
availabilityDomainstringThe availability domain of the instance. Example: Uocm:PHX-AD-1
compartmentIdstringThe OCID of the compartment the VNIC attachment is in, which is the same compartment the instance is in.
displayNamestringA user-friendly name. Does not have to be unique, and it's changeable. Avoid entering confidential information.
instanceIdstringThe OCID of the instance.
lifecycleStatestringThe current state of the VNIC attachment. (ATTACHING, ATTACHED, DETACHING, DETACHED)
nicIndexinteger (int32)Which physical network interface card (NIC) the VNIC uses. Certain bare metal instance shapes have two active physical NICs (0 and 1). If you add a secondary VNIC to one of these instances, you can specify which NIC the VNIC will use. For more information, see [Virtual Network Interface Cards (VNICs)](/iaas/Content/Network/Tasks/managingVNICs.htm).
subnetIdstringThe OCID of the subnet to create the VNIC in.
timeCreatedstring (date-time)The date and time the VNIC attachment was created, in the format defined by [RFC3339](https:​//tools.ietf.org/html/rfc3339). Example: 2016-08-25T21:10:29.600Z
vlanIdstringThe OCID of the VLAN to create the VNIC in. Creating the VNIC in a VLAN (instead of a subnet) is possible only if you are an Oracle Cloud VMware Solution customer. See [Vlan](#/en/iaas/latest/Vlan). An error is returned if the instance already has a VNIC attached to it from this VLAN.
vlanTaginteger (int32)The Oracle-assigned VLAN tag of the attached VNIC. Available after the attachment process is complete. However, if the VNIC belongs to a VLAN as part of the Oracle Cloud VMware Solution, the vlanTag value is instead the value of the vlanTag attribute for the VLAN. See [Vlan](#/en/iaas/latest/Vlan). Example: 0
vnicIdstringThe OCID of the VNIC. Available after the attachment process is complete.

Methods​

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
getselectvnicAttachmentId, regionGets the information for the specified VNIC attachment.<br />
listselectcompartmentId, regionavailabilityDomain, instanceId, limit, page, vnicIdLists the VNIC attachments in the specified compartment. A VNIC attachment<br />resides in the same compartment as the attached instance. The list can be<br />filtered by instance, VNIC, or availability domain.<br />
attachinsertregion, instanceId, createVnicDetailsopc-retry-tokenCreates a secondary VNIC and attaches it to the specified instance.<br />For more information about secondary VNICs, see<br />[Virtual Network Interface Cards (VNICs)](/iaas/Content/Network/Tasks/managingVNICs.htm).<br />
detachdeletevnicAttachmentId, regionif-matchDetaches and deletes the specified secondary VNIC.<br />This operation cannot be used on the instance's primary VNIC.<br />When you terminate an instance, all attached VNICs (primary<br />and secondary) are automatically detached and deleted.<br /><br />Important: If the VNIC has a<br />[private IP](#/en/iaas/latest/PrivateIp/) that is the<br />[target of a route rule](/iaas/Content/Network/Tasks/managingroutetables.htm#privateip),<br />deleting the VNIC causes that route rule to blackhole and the traffic<br />will be dropped.<br />

Parameters​

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
compartmentIdstringThe [OCID](/iaas/Content/General/Concepts/identifiers.htm) of the compartment.
regionstringOCI region identifier (e.g. us-ashburn-1, ap-sydney-1); resolves from OCI_REGION when not supplied in the query. (default: us-ashburn-1, x-stackQL-envVar: OCI_REGION)
vnicAttachmentIdstringThe OCID of the VNIC attachment.
availabilityDomainstringThe name of the availability domain. Example: Uocm:PHX-AD-1
if-matchstringFor optimistic concurrency control. In the PUT or DELETE call for a resource, set the if-match parameter to the value of the etag from a previous GET or POST response for that resource. The resource will be updated or deleted only if the etag you provide matches the resource's current etag value.
instanceIdstringThe OCID of the instance.
limitintegerFor list pagination. The maximum number of results per page, or items to return in a paginated "List" call. For important details about how pagination works, see [List Pagination](/iaas/Content/API/Concepts/usingapi.htm#nine). Example: 50
opc-retry-tokenstringA token that uniquely identifies a request so it can be retried in case of a timeout or server error without risk of executing that same action again. Retry tokens expire after 24 hours, but can be invalidated before then due to conflicting operations (for example, if a resource has been deleted and purged from the system, then a retry of the original creation request may be rejected).
pagestringFor list pagination. The value of the opc-next-page response header from the previous "List" call. For important details about how pagination works, see [List Pagination](/iaas/Content/API/Concepts/usingapi.htm#nine).
vnicIdstringThe OCID of the VNIC.

SELECT examples​

Gets the information for the specified VNIC attachment.<br />

SELECT
id,
availabilityDomain,
compartmentId,
displayName,
instanceId,
lifecycleState,
nicIndex,
subnetId,
timeCreated,
vlanId,
vlanTag,
vnicId
FROM oci.compute.vnic_attachments
WHERE vnicAttachmentId = '{{ vnicAttachmentId }}' -- required
AND region = '{{ region }}' -- required
;

INSERT examples​

Creates a secondary VNIC and attaches it to the specified instance.<br />For more information about secondary VNICs, see<br />[Virtual Network Interface Cards (VNICs)](/iaas/Content/Network/Tasks/managingVNICs.htm).<br />

INSERT INTO oci.compute.vnic_attachments (
createVnicDetails,
displayName,
instanceId,
nicIndex,
region,
opc-retry-token
)
SELECT
'{{ createVnicDetails }}' /* required */,
'{{ displayName }}',
'{{ instanceId }}' /* required */,
{{ nicIndex }},
'{{ region }}',
'{{ opc-retry-token }}'
RETURNING
id,
availabilityDomain,
compartmentId,
displayName,
instanceId,
lifecycleState,
nicIndex,
subnetId,
timeCreated,
vlanId,
vlanTag,
vnicId
;

DELETE examples​

Detaches and deletes the specified secondary VNIC.<br />This operation cannot be used on the instance's primary VNIC.<br />When you terminate an instance, all attached VNICs (primary<br />and secondary) are automatically detached and deleted.<br /><br />Important: If the VNIC has a<br />[private IP](#/en/iaas/latest/PrivateIp/) that is the<br />[target of a route rule](/iaas/Content/Network/Tasks/managingroutetables.htm#privateip),<br />deleting the VNIC causes that route rule to blackhole and the traffic<br />will be dropped.<br />

DELETE FROM oci.compute.vnic_attachments
WHERE vnicAttachmentId = '{{ vnicAttachmentId }}' --required
AND region = '{{ region }}' --required
AND if-match = '{{ if-match }}'
;