(一)openstack的命令帮助:

(1)使用帮助命令:

①命令后面加help格式:

1、neutron help|grep router //类似这样的格式帮助就能得到对应的功能

2、glance help image-update //类似这样的帮助


[] 是可选命令

<> 是必须命令




②使用帮助命令:

1、nova help boot {boot是nova的一个子命令},一般情况下查子命令的帮助,就是nova help boot,然后就能得到他的语法结构

[root@controller ~(keystone_user1)]# nova help boot

usage: nova boot [--flavor <flavor>] [--image <image>]

[--image-with <key=value>] [--boot-volume <volume_id>]

[--snapshot <snapshot_id>] [--min-count <number>]

[--max-count <number>] [--meta <key=value>]

[--file <dst-path=src-path>] [--key-name <key-name>]

[--user-data <user-data>]

[--availability-zone <availability-zone>]

[--security-groups <security-groups>]

[--block-device-mapping <dev-name=mapping>]

[--block-device key1=value1[,key2=value2...]]

[--swap <swap_size>]

[--ephemeral size=<size>[,format=<format>]]

[--hint <key=value>]

[--nic <net-id=net-uuid,v4-fixed-ip=ip-addr,v6-fixed-ip=ip-addr,port-id=port-uuid>]

[--config-drive <value>] [--poll]

<name>



2、nova boot --flavor web1 --image web1 --key-name key01 --security-groups sec01 --nic net-id=ef08363a-c9d7-4fc1-99f5-bc80c0043a29 web1 //启动一个云主机



Boot a new server.


Positional arguments:

<name> Name for the new server


Optional arguments:

--flavor <flavor> Name or ID of flavor (see 'nova flavor-list').

--image <image> Name or ID of image (see 'nova image-list').

--image-with <key=value> Image metadata property (see 'nova image-

show').

--boot-volume <volume_id> Volume ID to boot from.

--snapshot <snapshot_id> Snapshot ID to boot from (will create a

volume).

--min-count <number> Boot at least <number> servers (limited by

quota).

--max-count <number> Boot up to <number> servers (limited by

quota).

--meta <key=value> Record arbitrary key/value metadata to

/meta.js on the new server. Can be specified

multiple times.

--file <dst-path=src-path> Store arbitrary files from <src-path> locally

to <dst-path> on the new server. You may store

up to 5 files.

--key-name <key-name> Key name of keypair that should be created

earlier with the command keypair-add

--user-data <user-data> user data file to pass to be exposed by the

metadata server.

--availability-zone <availability-zone>

The availability zone for server placement.

--security-groups <security-groups>

Comma separated list of security group names.

--block-device-mapping <dev-name=mapping>

Block device mapping in the format <dev-

name>=<id>:<type>:<size(GB)>:<delete-on-

terminate>.

--block-device key1=value1[,key2=value2...]

Block device mapping with the keys: id=UUID

(image_id, snapshot_id or volume_id only if

using source image, snapshot or volume)

source=source type (image, snapshot, volume or

blank), dest=destination type of the block

device (volume or local), bus=device's bus

(e.g. uml, lxc, virtio, ...; if omitted,

hypervisor driver chooses a suitable default,

honoured only if device type is supplied)

type=device type (e.g. disk, cdrom, ...;

defaults to 'disk') device=name of the device

(e.g. vda, xda, ...; if omitted, hypervisor

driver chooses suitable device depending on

selected bus), size=size of the block device

in GB (if omitted, hypervisor driver

calculates size), format=device will be

formatted (e.g. swap, ntfs, ...; optional),

bootindex=integer used for ordering the boot

disks (for image backed instances it is equal

to 0, for others need to be specified) and

shutdown=shutdown behaviour (either preserve

or remove, for local destination set to

remove).

--swap <swap_size> Create and attach a local swap block device of

<swap_size> MB.

--ephemeral size=<size>[,format=<format>]

Create and attach a local ephemeral block

device of <size> GB and format it to <format>.

--hint <key=value> Send arbitrary key/value pairs to the

scheduler for custom use.

--nic <net-id=net-uuid,v4-fixed-ip=ip-addr,v6-fixed-ip=ip-addr,port-id=port-uuid>

Create a NIC on the server. Specify option

multiple times to create multiple NICs. net-

id: attach NIC to network with this UUID

(either port-id or net-id must be provided),

v4-fixed-ip: IPv4 fixed address for NIC

(optional), v6-fixed-ip: IPv6 fixed address

for NIC (optional), port-id: attach NIC to

port with this UUID (either port-id or net-id

must be provided).

--config-drive <value> Enable config drive

--poll Report the new server boot progress until it

completes.






(2)帮助命令实例:

①cinder help create

usage: cinder create [--snapshot-id <snapshot-id>]

[--source-volid <source-volid>] [--image-id <image-id>]

[--display-name <display-name>]

[--display-description <display-description>]

[--volume-type <volume-type>]

[--availability-zone <availability-zone>]

[--metadata [<key=value> [<key=value> ...]]]

<size>


Creates a volume.


Positional arguments:

<size> Volume size, in GBs.


Optional arguments:

--snapshot-id <snapshot-id>

Creates volume from snapshot ID. Default=None.

--source-volid <source-volid>

Creates volume from volume ID. Default=None.

--image-id <image-id>

Creates volume from image ID. Default=None.

--display-name <display-name>

Volume name. Default=None.

--display-description <display-description>

Volume description. Default=None.

--volume-type <volume-type>

Volume type. Default=None.

--availability-zone <availability-zone>

Availability zone for volume. Default=None.

--metadata [<key=value> [<key=value> ...]]

Metadata key and value pairs. Default=None.


1、 cinder create size 1 //<size> 尖括号是必选项,中括号是可选项,所以执行这个就可以






②假设要创建一个子网:{就是在要使用的命令前面加help}

neutron help subnet-create

usage: neutron subnet-create [-h] [-f {shell,table,value}] [-c COLUMN]

[--max-width <integer>] [--prefix PREFIX]

[--request-format {json,xml}]

[--tenant-id TENANT_ID] [--name NAME]

[--gateway GATEWAY_IP] [--no-gateway]

[--allocation-pool start=IP_ADDR,end=IP_ADDR]

[--host-route destination=CIDR,nexthop=IP_ADDR]

[--dns-nameserver DNS_NAMESERVER]

[--disable-dhcp] [--enable-dhcp]

[--ipv6-ra-mode {dhcpv6-stateful,dhcpv6-stateless,slaac}]

[--ipv6-address-mode {dhcpv6-stateful,dhcpv6-stateless,slaac}]

[--ip-version {4,6}]

NETWORK CIDR


Create a subnet for a given tenant.


positional arguments:

NETWORK Network ID or name this subnet belongs to.

CIDR CIDR of subnet to create.


optional arguments:

-h, --help show this help message and exit

--request-format {json,xml}

The XML or JSON request format.

--tenant-id TENANT_ID

The owner tenant ID.

--name NAME Name of this subnet.

--gateway GATEWAY_IP Gateway IP of this subnet.

--no-gateway No distribution of gateway.

--allocation-pool start=IP_ADDR,end=IP_ADDR

Allocation pool IP addresses for this subnet (This

option can be repeated).

--host-route destination=CIDR,nexthop=IP_ADDR

Additional route (This option can be repeated).

--dns-nameserver DNS_NAMESERVER

DNS name server for this subnet (This option can be

repeated).

--disable-dhcp Disable DHCP for this subnet.

--enable-dhcp Enable DHCP for this subnet.

--ipv6-ra-mode {dhcpv6-stateful,dhcpv6-stateless,slaac}

IPv6 RA (Router Advertisement) mode.

--ipv6-address-mode {dhcpv6-stateful,dhcpv6-stateless,slaac}

IPv6 address mode.

--ip-version {4,6} IP version to use, default is 4.


output formatters:

output formatter options


-f {shell,table,value}, --format {shell,table,value}

the output format, defaults to table

-c COLUMN, --column COLUMN

specify the column(s) to include, can be repeated


table formatter:

--max-width <integer>

Maximum display width, 0 to disable


shell formatter:

a format a UNIX shell can parse (variable="value")


--prefix PREFIX add a prefix to all variable names

--disable-dhcp --disable-snat --distributed

1、[root@controller ~(keystone_admin)]# neutron subnet-create --name pubsubnet01 --gateway 10.1.1.254 --allocation-pool start=10.1.1.20,end=10.1.1.30 --disable-dhcp public 10.1.1.0/24