# Openstack commands ##### ##### Nova: - **List of instances** ```shell openstack server list nova list ``` - **Details on a specific instance** ```shell openstack server show nova show ``` - **Rebuild an instance** ```shell openstack server rebuild --image nova rebuild ``` - **Rebuild an instance with metadata** ```shell openstack server set --property nova meta set nova rebuild --meta ``` - **Attach a port to an instance** ```shell nova interface-attach --port-id ``` - **Create a instance from a availability zone** ```shell nova boot --availability-zone nova:metal01: --flavor --image --nic net-id=,v4-fixed-ip= openstack server create --availability-zone nova:metal01: --flavor --image --nic net-id=,v4-fixed-ip= ``` - **Create a instance with meta property, sec group, fixed ip, ssh-key** ``` openstack server create --image --flavor --nic net-id=,v4-fixed-ip= --property --security-group --key-name vmname ``` - **Create a instance** ```shell openstack server create --image --flavor vmname ``` - **Remove error state from instance** ```shell nova reset-state --active ``` - **Change the flavour (resize)** ```shell openstack server resize --flavor ``` ##### Neutron: - **List of subnets and network ID** ```shell openstack network list neutron net-list ``` - **List of subnets, their IDs and allocation pools:** ```shell openstack subnet list neutron subnet-list ``` - **List ports** ```shell openstack port list neutron port-list ``` - **Create port** ```shell openstack port create --network --fixed-ip subnet=,ip-address= neutron port-create --fixed-ip subnet_id=,ip_address= ``` - **Update or Set/Unset port** ```shell neutron port-update --fixed-ip subnet_id=,ip_address= --fixed-ip subnet_id=,ip_address= openstack port set --fixed-ip subnet=,ip-address= openstack port unset --fixed-ip subnet=,ip-address= ``` - **Get details on a port** ```shell openstack port show neutron port-show ``` - Allowed address pairs - (Allows one port to add additional IP/MAC address pairs on that port to allow traffic that matches those specified values.) ``` neutron port-update --allowed-address-pairs type=dict list=true ip_address='0.0.0.0/0' ``` ##### Glance: - **List images** ```shell openstack image list glance image-list ``` - **Get details on an image** ```shell glance image-show ``` - **Upload a image** ```shell openstack image create --disk-format qcow2 --container-format bare --public --file ./centos7.qcow2 centos7-image ``` - **Delete** ```shell openstack image delete ``` - **Download a image** ```shell glance image-download --file img.qcow2 ``` - **Change state** ```shell cinder reset-state --state in-use ``` ##### Other: - **List flavors** ```shell openstack flavor list ``` - **List keypairs** ```shell openstack keypair list ``` - **List Security groups** ```shell openstack security group list ``` ##### **Cinder** ``` openstack volume set --state error ``` **Stop a migraion** **Remove the active volume from the migration state** ``` cinder reset-state --reset-migration-status ``` **find the volume in the attaching state and remove it** ``` openstack volume list ``` ``` cinder reset-state --state error ``` ``` cinder reset-state --reset-migration-status ``` ``` openstack volume delete ```