命令行操作

环境变量

# cat admin-openrc.sh 
export OS_PROJECT_DOMAIN_NAME=Default
export OS_USER_DOMAIN_NAME=Default
export OS_PROJECT_NAME=admin
export OS_USERNAME=admin
export OS_PASSWORD=Abc12345
export OS_AUTH_URL=https://192.168.226.110:35357/v3
export OS_CACERT=/etc/keystone/ssl/ca.crt
export OS_AUTH_TYPE=password
export OS_IDENTITY_API_VERSION=3
export OS_REGION_NAME=RegionOne
export OS_IMAGE_API_VERSION=2
export OS_VOLUME_API_VERSION=3
export IRONIC_API_VERSION=1.22

glance

上传镜像

glance image-create --name dahua_p8500 --visibility public --progress --disk-format=raw --container-format bare --file dahua_p8500_50G.raw 
glance image-create --file cirros-0.3.4-x86_64-disk.img.raw --name cirros --disk-format raw --container-format bare --visibility public --progress --property hypervisor_type=kvm

Nova常用

重置虚拟机状态

nova reset-state dc21fc3f-40a6-48f7-b98d-1bec92b99726 --active

开关所有虚拟机

替换 xiecd 为你相关查询 开机 start 关机 stop

for i in `nova list --all | grep xiecd | awk {'print $2'}`; do echo $i; nova start $i; sleep 5; done

删除虚拟机

nova delete ed3a405e-2dc9-49ae-bf89-4785b60efe6f

创建云硬盘

 cinder create --source-volid f381219a-6426-403d-8ff8-2a720a5e92f1 --volume-type nova_ip_sas --name Fhzz-vm01 1024

创建云主机

nova boot xiecd --flavor m1.large --block-device source=image,id=ef2fe1fc-35ce-42e3-b0bd-f91b51177247,dest=volume,size=5,shutdown=remove,bootindex=0 --nic net-id=a690235d-8418-4975-af2d-841984da0b88 --availability nova --config-drive true --admin-pass xiecd.com
nova boot YS-Win2k8-vm14 --flavor 4V8G500G --boot-volume ec9d2688-c6ee-48b3-8af3-f77539ee626e --security-groups default --nic net-id=7c54dac4-57ff-4f30-9ed4-493613360ad7,v4-fixed-ip=66.0.34.63 --availability nova --config-drive true --admin-pass Fh123456