Launching an Instance from an Image

You need the parameters gathered in Launching Instances to proceed: flavor, image, key pair, security group, and a private network ID.

Launch an instance using the following command:

$ openstack server create <INSTANCE_NAME>\
   --flavor <FLAVOR> \
   --image <IMAGE> \
   --key-name <KEY_NAME> \
   --security-group <SEC_GROUP_NAME> \
   --nic net-id=<NET_UUID>

You can provide additional information using the following options:

Option Description
--user-data <USER_DATA_FILE> User data in a local file
--property KEY=VALUE Metadata key and value pairs
--meta description="My Server" A description for your server
--config-drive true Write metadata to a configuration drive that attaches to the instance when it boots

You can also place up to 5 arbitrary local files into the instance file system at creation time by using the --file <dst-path=src-path> option. If you have a special authorized keys file to put on the instance rather than using the regular SSH key injection, you can use the --file option.

$ openstack server create --image ubuntu-cloudimage --flavor 1 vm-name \
    --file /root/.ssh/authorized_keys=special_authorized_keysfile

Once you receive the new server properties from the launch, you can begin to perform additional tasks using the field values:

  • adminPass—Use the password to log in to your server.
  • id—Use the ID to retrieve server details or to delete your server.
  • status—Indicates the status of the server.
    • A BUILD status indicates that the instance has started, but is not yet online.
    • An ACTIVE status indicates that the instance is active.

Example: Launch the MyCirrosServer instance

This example uses the following information gathered to launch the instance:

Parameter Value
flavor m1.small
flavor ID 1
image cirros-0.3.2-x86_64-uec
image ID 397e713c-b
security group default
key KeyPair01
user data file cloudinit.file
  1. Launch the instance on a private network using the gathered information.

    $ openstack server create --flavor 1 \
       --image 397e713c-b \
       --security-groups default --key-name KeyPair01 \
       --user-data cloudinit.file \
       --nic net-id=PRIVATE_NET_ID\
       myCirrosServer
    
    +-------------------------------------+-------------------------------------+
    | Field                               | Value                               |
    +-------------------------------------+-------------------------------------+
    | OS-EXT-STS:task_state               | scheduling                          |
    | image                               | cirros-0.3.2-x86_64-uec             |
    | OS-EXT-STS:vm_state                 | building                            |
    | OS-EXT-SRV-ATTR:instance_name       | instance-00000002                   |
    | flavor                              | m1.small                            |
    | id                                  | <instance_id>                       |
    | security_groups                     | [{u'name': u'default'}]             |
    | user_id                             |                                     |
    | OS-DCF:diskConfig                   | MANUAL                              |
    | accessIPv4                          |                                     |
    | accessIPv6                          |                                     |
    | progress                            | 0                                   |
    | OS-EXT-STS:power_state              | 0                                   |
    | OS-EXT-AZ:availability_zone         | nova                                |
    | config_drive                        |                                     |
    | status                              | BUILD                               |
    | updated                             | 2013-07-16T16:25:34Z                |
    | hostId                              |                                     |
    | OS-EXT-SRV-ATTR:host                | None                                |
    | key_name                            | KeyPair01                           |
    | OS-EXT-SRV-ATTR:hypervisor_hostname | None                                |
    | name                                | myCirrosServer                      |
    | adminPass                           | tVs5pL8HcPGw                        |
    | tenant_id                           | <tenant_id>                         |
    | created                             | 2013-07-16T16:25:34Z                |
    | metadata                            | {u'KEY': u'VALUE'}                  |
    +-------------------------------------+-------------------------------------+
    
  2. Verify that your new instance is online by using the server list command.

    $ openstack server list
    +---------------+----------------------+--------+------------------+
    | ID            | Name                 | Status | Networks         |
    +---------------+----------------------+--------+------------------+
    | <instance_id> | myCirrosServer       | ACTIVE | private=10.0.0.4 |
    | <instance_id> | myInstanceFromVolume | ACTIVE | private=10.0.0.5 |
    +---------------+----------------------+--------+------------------+
    

    The image list shows the ID, name, status, and the private IP addresses for all instances in the project to which you belong. The Networks column also includes public IP addresses, if assigned. If the status for the new instance is ACTIVE, the instance is online.

  3. Copy the server ID value from the id field. Use the ID to retrieve server details and perform other tasks.

    $ openstack server show <INSTANCE_ID>
    
  4. Access the instance remotely using a floating IP address created on the public network and log in using SSH. See Managing IP Addresses. Use the ssh command and your keypair file to make a secure connection to the instance.

    $ ssh -i MyKey.pem cloud@10.0.0.2
    

    Note
    If you did not provide a key pair, security groups, or rules, you can access the instance only from inside the cloud through VNC. Even pinging the instance is not possible.