port
1.创建port(create)
i.随机ip
openstack port create --network public --fixed-ip subnet=sub-public ''
ii.指定ip
openstack port create --network public --fixed-ip subnet=sub-public,ip-address=192.168.130.51 ''
提示:最后的name可以为空,但一定要有
2.删除port(delete)
openstack port delete c982c77c-fe12-4e29-9916-56d466a71fe2 c7e7f6d5-20f8-4393-a917-2107b4d59250
3.修改port(set,unset)
i.添加指定ip
openstack port set --fixed-ip subnet=sub-public,ip-address=192.168.130.80 427fcb1d-9630-4219-9860-07eac298ae75
ii.删除指定ip
openstack port set --fixed-ip subnet=sub-public,ip-address=192.168.130.80 --no-fixed-ip 3310b8ed-4c72-4473-a9c7-322d36c9d805
iii.network:dhcp属性
openstack network agent list
openstack port set --device 409b88c2-7431-49b8-a272-484c524a096d --device-owner network:dhcp --fixed-ip subnet=sub-public,ip-address=192.168.130.31 --enable ''
4.查看port(list,show)
openstack port list
openstack port show 6360f7eb-a2e8-4ded-96b2-17a78b61e088
server
1.创建server(create)
i.随机ip
openstack server create --image centos7.3 --flavor m1.micro --security-group default --key-name mykey --user-data centos7_init.sh --availability-zone nova --nic net-id=f1e99b0f-9b5d-4a71-ab90-8b80cae6090c --max 10 selfservice-instance
重要参数:
--max #如果资源足够,生成最大server的数量
--user-data #初始化脚本或cloud-init配置https://docs.openstack.org/developer/python-openstackclient/command-objects/server.html#cmdoption-server-create-user-data
ii.指定ip
openstack server create --image centos7.3 --flavor m1.micro --security-group default --key-name mykey --user-data centos7_init.sh --availability-zone nova --nic net-id=f1e99b0f-9b5d-4a71-ab90-8b80cae6090c,v4-fixed-ip=192.168.130.77 selfservice-instance
2.删除server(delete)
openstack server delete 79e7923c-7f16-4483-96d4-69a139381fa6 c7e7f6d5-20f8-4393-a917-2107b4d3lkj230
3.修改server
i.添加随机fixed ip
openstack server add fixed ip ebfe4f95-1230-4121-8ec2-ead8ee92330b public
ii.删除指定fixed ip
openstack server remove fixed ip ebfe4f95-1230-4121-8ec2-ead8ee92330b 192.168.130.35
iii.调整大小(cpu,内存,磁盘)
openstack server resize --flavor m1.medium 2f164dad-7ab0-4820-a3ef-63198f34a235
openstack server resize --confirm 2f164dad-7ab0-4820-a3ef-63198f34a235
iv.重建实例(系统重装)
openstack server rebuild --image ubuntu16.04 2f164dad-7ab0-4820-a3ef-63198f34a235
v.重命名
openstack server set --name mynewname 2f164dad-7ab0-4820-a3ef-63198f34a235
vi.标识主机状态
openstack server set --state error2f164dad-7ab0-4820-a3ef-63198f34a235
openstack server set --state active 2f164dad-7ab0-4820-a3ef-63198f34a235
提示:对于正常主机实例,当状态标识为error时,并不会对主机做关闭,删除等操作,只是无法通过ssh等方式对其进行管理,当标识为active后立马一切正常。
4.查看server(list,show)
openstack server list
openstack server show 79e7923c-7f16-4483-96d4-69a139381fa6
openstack console url show mynewname
ip
openstack ip availability list
openstack ip availability show f1e99b0f-9b5d-4a71-ab90-8b80cae6090c
老版本补充:
创建网络
neutron net-create provider-194 --shared
--provider:physical_network public --provider:network_type vlan
--provider:segmentation_id 194
创建子网
neutron subnet-create provider-194 172.25.194.0/24 --name
provider-194-subnet --gateway 172.25.194.1 --allocation-pool
start=172.25.194.31,end=172.25.194.254 --dns-nameserver
172.25.130.31
创建port
neutron port-create --fixed-ip
subnet_id=86b30a7f-b0f2-4e34-aeff-ddf17a128b46,ip_address=172.25.130.103
provider-130
更新port
neutron port-update --fixed-ip
subnet_id=86b30a7f-b0f2-4e34-aeff-ddf17a128b46,ip_address=172.25.130.102
cfbb6952-bd43-49e6-8cf3-54b45da3debe
标识主机状态
nova reset-state --active 9d6fdb0d-4558-4076-8bf4-15ee333e8255