Create server 2

Method URI Description
POST /v2/{tenant_id}/servers Creates a server.

Normal response codes: 202

CAUTION:

  • When an instance created using a Linux image is started or restarted, the sshd settings are initialized, and it may no longer be possible to log in to the instance. Refer to "Reboot server" for details on the required tasks.
  • When the password of the user who registered (imported) the image is changed, the image can no longer be used. When the password of the user who registered (imported) the image is changed, the image can no longer be used.
    • The location of the image following the change of image UUID and user authentication information
    • The image UUID that was registered (imported) following the change of image UUID and user authentication information
  • If the following message is displayed after instance creation as a "message" for the instance whose "status" is "ERROR" or "fault", please re-create an instance according to the procedure described in "Create server 1".

    "Block Device Mapping is Invalid: Volume <Volume uuid> did not finish being

    created even after we waited <Elapsed time (seconds)> seconds or <Volume status confirmation frequency> attempts."

Request

This table shows the URI parameters for the create server request:

Name Type Description
{tenant_id} String Project ID

This table shows the body parameters for the create server request:

Name Type Description
security_group String

(Optional)

One or more security_group objects. Specify the name of the security group in the name attribute. If you omit this attribute, the server is created in the default security group.

Specify a security group for which TCP communication is permitted for the following IP address and port number.

IP address: 169.254.169.254

Port number: 80

If TCP communication is not permitted, the host name (computer name) and administrator password may not be set when creating an instance.

user_data String

(Optional)

Configuration information or scripts to use upon launch. Must be Base64 encoded.

The main formats that are supported are as follows:

  • Linux:
    • Shell script (begins with #!)
  • Windows:
    • PowerShell (begins with #ps1_sysnative or #ps1_x86)
    • Windows batch (begins with rem cmd)

If Linux, cloud-config files can also be specified, but since verification has not been completed, we recommend using Shell scripts.

availability_zone String

(Optional)

The availability zone in which to launch the server.
server ServerForCreate server.
imageRef String The image reference for the desired image for your server instance.

Specify as an ID or full URL.

flavorRef String The flavor reference for the desired flavor for your server instance.

Specify as an ID or full URL.

key_name String

(Optional)

Assigns the public key of the named keypair to the server.

networks String

(Optional)

A networks object. By default, the server instance is provisioned with all isolated networks for the project.

Optionally, you can create one or more NICs on the server.

To provision the server instance with a NIC for a network, specify the UUID of the network in the uuid attribute in a networks object.

To provision the server instance with a NIC for an already existing port, specify the port-id in the port attribute in a networks object.

You can specify multiple NICs on the server.

Ensure that the network is specified.

To set the following information for a virtual server, a virtual router must be connected to the network that the virtual server will be connected to.
  • Host name (computer name)
  • Administrator password
  • Authentication key (key pair)
uuid String

(Optional)

To provision the server instance with a NIC for a network, specify the UUID of the network in the uuid attribute in a networks object. Required if you omit the port attribute.

If the network includes multiple subnets, IP addresses will be allocated from any subnet. To allocate an IP address of a specific subnet, create a port in advance, and specify the uuid of that port in port.

port String

(Optional)

To provision the server instance with a NIC for an already existing port, specify the port-id in the port attribute in a networks object. Required if you omit the uuid attribute.
fixed_ip String

(Optional)

A fixed IPv4 address for the NIC.
name String The server name.

This information is also used as the computer name/host name.

If 64 characters or more are specified:

  • Windows:

    The computer name will be the default name set by Windows.

  • Linux:

    The host name will be "host-fixedIpAddressOfEth0".

The string set for the computer name/host name is changed as follows:

  • Spaces ( ) and underscores (_) are replaced with hyphens (-)
  • Uppercase letters are replaced with lowercase letters
  • Symbols other than periods (.) and hyphens (-) are removed
  • Periods (.) are removed from the beginning and end of the string, and strings consisting of hyphens (-) are removed
  • In Windows, if the string contains a period (.) anywhere other than at the beginning or end, then the characters preceding the period (.) will be used for the name.
metadata String

(Optional)

Metadata key and value pairs. The maximum size of the metadata key and value is 255 bytes each.
  • Windows:

    To specify a password of an instance, specify the "admin_pass" key.

    The specified password will be set for users specified in cloudbase-init.

    Check with the image provider regarding users who are specified for cloudbase-init.

    Example setting: "metadata": {"admin_pass": "passwordSetForInstance"}

  • To use the automatic failover feature, specify "fcx.autofailover": "true".

    specify "fcx.autofailover": "true".

    However, instances that satisfy the following conditions are excluded from recovery by the operator. Users must either re-create such instances, or delete them.

    • "fcx.autofailover": "false" has been set, or,
    • the instance is a target of auto scaling, or,
    • the status of the instance is ERROR
block_device_mapping_v2 String Enables booting the server from a volume when additional parameters are given.
device_name String Describes a path to the device for the volume you want to use to boot the server.

Specify this item in /dev/vddeviceName format. /dev/vd is fixed, and for deviceName, specify one or more characters (lowercase only) that are valid as a device name.

Note: When using a number in the device name of the system volume, perform specification using the following format.

"/dev/vd" + one or more alphabetical characters (lowercase only) + number (ensure there are no alphabetical characters between numbers)

Example: /dev/vda0 , /dev/vda1 , etc.

When creating an instance that is allocated multiple volumes, for the boot volume, specify the character with highest priority among the device names of all volumes.

The order of priority is a > b > c > ...

source_type String Describes the volume source type for the volume. Choices are "snapshot", "volume", or "image".
destination_type String Specifies the connection destination ("volume").
delete_on_termination bool

(Optional)

Specifies whether volumes created during the instance creation will be deleted when the instance is deleted.

When "True" is specified, volumes during instance creation will also be deleted when the instance is deleted.

When "False" is specified, the volumes created during instance creation will not be deleted when the instance is deleted.

If not specified, "False" (do not delete) will be used.

The volume where snapshots are collected will not be deleted even if "True" is specified.

boot_index String Specifies the device start order. Specify sequential values, starting from 0. For the boot disk, specify "0".
config_drive String

(Optional)

Only "false" can be specified.
uuid uuid Specifies the UUID of the resource specified for source_type.
volume_size String Specify the volume size in GB.

This item must be specified when "image" is specified for source_type. Specify a value equal to or higher than the min_disk parameter of the image to be used. If the min_disk parameter of the image to be used has not been specified or is "0", check the minimum size with the image provider and specify the value accordingly.

If "volume" was specified for source_type, this item will be ignored even if a value is specified.

If "snapshot" was specified for source_type, and this item is omitted, the volume size of the snapshot collection source will be used.

volume_type String

(Optional)

Specify the volume type.

Only when "image" is specified for source_type will a volume with the specified volume type be created. If omitted, "M1" is used.

If "volume" was specified for source_type, the specified value will be ignored as it is not possible to change the volume type.

If "snapshot" was specified for source_type, a volume with the volume type of the snapshot source will be created. This item will be ignored even if a value is specified.

Example. Create server: JSON request


{
	"server": {
		"name": "new-server-test",
		"imageRef": "b5660a6e-4b46-4be3-9707-6b47221b454f",
		"flavorRef": "2",
		"key_name": "keypair1",
		"metadata": {
			"My Server Name": "Apache1"
		}
	}
}
     

Response

Example. Create server: JSON response


{
	"server": {
		"OS-DCF:diskConfig": "AUTO",
		"adminPass": "CQH9gWzgkVno",
		"id": "324dfb7d-f4a9-419a-9a19-237df04b443b",
		"links": [
			{
				"href": "http://openstack.example.com/v2/openstack/servers/324dfb7d-f4a9-419a-9a19-237df04b443b",
				"rel": "self"
			},
			{
				"href": "http://openstack.example.com/openstack/servers/324dfb7d-f4a9-419a-9a19-237df04b443b",
				"rel": "bookmark"
			}
		]
	}
}