[OpenStack] OpenStack Essex - Glance 安装部署与命令行详解

 Glance

Install glance using the following command:

sudo apt-get install glance glance-api glance-client glance-common glance-registry python-glance

运行结果:
localadmin@OpenStack-1:~$ sudo apt-get install glance glance-api glance-client glance-common glance-registry python-glance
[sudo] password for localadmin:
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
  libyaml-0-2 python-amqplib python-anyjson python-dateutil python-kombu python-xattr python-yaml
Suggested packages:
  python-amqplib-doc python-boto python-couchdb python-kombu-doc python-pymongo
The following NEW packages will be installed:
  glance glance-api glance-client glance-common glance-registry libyaml-0-2 python-amqplib python-anyjson python-dateutil python-glance python-kombu python-xattr
  python-yaml
0 upgraded, 13 newly installed, 0 to remove and 3 not upgraded.
Need to get 649 kB of archives.
After this operation, 3,709 kB of additional disk space will be used.
Do you want to continue [Y/n]? y
Get:1 http://mirrors.163.com/ubuntu/ precise/main libyaml-0-2 amd64 0.1.4-2 [56.9 kB]
Get:2 http://mirrors.163.com/ubuntu/ precise/main python-amqplib all 1.0.0+ds-1 [34.5 kB]
Get:3 http://mirrors.163.com/ubuntu/ precise/main python-anyjson all 0.3.1-1build1 [7,208 B]
Get:4 http://mirrors.163.com/ubuntu/ precise/main python-dateutil all 1.5-1 [54.2 kB]
Get:5 http://mirrors.163.com/ubuntu/ precise/main python-kombu all 1.4.3-1 [94.1 kB]
Get:6 http://mirrors.163.com/ubuntu/ precise/main python-xattr amd64 0.6.2-1ubuntu1 [13.9 kB]
Get:7 http://mirrors.163.com/ubuntu/ precise/main python-yaml amd64 3.10-2 [122 kB]
Get:8 http://mirrors.163.com/ubuntu/ precise-proposed/main python-glance all 2012.1-0ubuntu2.1 [229 kB]
Get:9 http://mirrors.163.com/ubuntu/ precise-proposed/main glance-common all 2012.1-0ubuntu2.1 [6,506 B]
Get:10 http://mirrors.163.com/ubuntu/ precise-proposed/main glance-api all 2012.1-0ubuntu2.1 [12.1 kB]
Get:11 http://mirrors.163.com/ubuntu/ precise-proposed/main glance-registry all 2012.1-0ubuntu2.1 [4,700 B]
Get:12 http://mirrors.163.com/ubuntu/ precise-proposed/main glance all 2012.1-0ubuntu2.1 [1,742 B]
Get:13 http://mirrors.163.com/ubuntu/ precise-proposed/main glance-client all 2012.1-0ubuntu2.1 [10.8 kB]
Fetched 649 kB in 10s (64.0 kB/s)
Selecting previously unselected package libyaml-0-2.
(Reading database ... 52116 files and directories currently installed.)
Unpacking libyaml-0-2 (from .../libyaml-0-2_0.1.4-2_amd64.deb) ...
Selecting previously unselected package python-amqplib.
Unpacking python-amqplib (from .../python-amqplib_1.0.0+ds-1_all.deb) ...
Selecting previously unselected package python-anyjson.
Unpacking python-anyjson (from .../python-anyjson_0.3.1-1build1_all.deb) ...
Selecting previously unselected package python-dateutil.
Unpacking python-dateutil (from .../python-dateutil_1.5-1_all.deb) ...
Selecting previously unselected package python-kombu.
Unpacking python-kombu (from .../python-kombu_1.4.3-1_all.deb) ...
Selecting previously unselected package python-xattr.
Unpacking python-xattr (from .../python-xattr_0.6.2-1ubuntu1_amd64.deb) ...
Selecting previously unselected package python-yaml.
Unpacking python-yaml (from .../python-yaml_3.10-2_amd64.deb) ...
Selecting previously unselected package python-glance.
Unpacking python-glance (from .../python-glance_2012.1-0ubuntu2.1_all.deb) ...
Selecting previously unselected package glance-common.
Unpacking glance-common (from .../glance-common_2012.1-0ubuntu2.1_all.deb) ...
Selecting previously unselected package glance-api.
Unpacking glance-api (from .../glance-api_2012.1-0ubuntu2.1_all.deb) ...
Selecting previously unselected package glance-registry.
Unpacking glance-registry (from .../glance-registry_2012.1-0ubuntu2.1_all.deb) ...
Selecting previously unselected package glance.
Unpacking glance (from .../glance_2012.1-0ubuntu2.1_all.deb) ...
Selecting previously unselected package glance-client.
Unpacking glance-client (from .../glance-client_2012.1-0ubuntu2.1_all.deb) ...
Processing triggers for man-db ...
Processing triggers for ureadahead ...
ureadahead will be reprofiled on next reboot
Setting up libyaml-0-2 (0.1.4-2) ...
Setting up python-amqplib (1.0.0+ds-1) ...
Setting up python-anyjson (0.3.1-1build1) ...
Setting up python-dateutil (1.5-1) ...
Setting up python-kombu (1.4.3-1) ...
Setting up python-xattr (0.6.2-1ubuntu1) ...
Setting up python-yaml (3.10-2) ...
Setting up python-glance (2012.1-0ubuntu2.1) ...
Setting up glance-common (2012.1-0ubuntu2.1) ...
Adding system user `glance' (UID 109) ...
Adding new user `glance' (UID 109) with group `glance' ...
Not creating home directory `/var/lib/glance'.
Setting up glance-api (2012.1-0ubuntu2.1) ...
glance-api start/running, process 2001
Setting up glance-registry (2012.1-0ubuntu2.1) ...
glance-registry start/running, process 2053
Setting up glance (2012.1-0ubuntu2.1) ...
Setting up glance-client (2012.1-0ubuntu2.1) ...
Processing triggers for libc-bin ...
ldconfig deferred processing now taking place
 
 

 Glance Configuration

Glance uses SQLite by default. MySQL and PostgreSQL can also be configured to work with Glance.

Open /etc/glance/glance-api-paste.ini and at the end of the file, edit the following lines:

admin_tenant_name = %SERVICE_TENANT_NAME%
admin_user = %SERVICE_USER%
admin_password = %SERVICE_PASSWORD%

These values have to be modified as per the configurations made earlier. The admin_tenant_name will be 'service', admin_user will be 'glance' and admin_password is 'glance'.

After editing, the lines should be as follows:

admin_tenant_name = service
admin_user = glance
admin_password = glance

Now open /etc/glance/glance-registry-paste.ini and make similar changes at the end of the file.

Open the file /etc/glance/glance-registry.conf and edit the line which contains the option "sql_connection =" to this:

sql_connection = mysql://glancedbadmin:[email protected]/glance

In order to tell glance to use keystone for authentication, add the following lines at the end of the file.

[paste_deploy]
flavor = keystone

Open /etc/glance/glance-api.conf and add the following lines at the end of the document.

[paste_deploy]
flavor = keystone

Create glance schema in the MySQL database.:

sudo glance-manage version_control 0
sudo glance-manage db_sync

Restart glance-api and glance-registry after making the above changes.

sudo restart glance-api
sudo restart glance-registry

Export the following environment variables.

   export SERVICE_TOKEN=admin
export OS_TENANT_NAME=admin
export OS_USERNAME=admin
export OS_PASSWORD=admin
export OS_AUTH_URL="http://localhost:5000/v2.0/"
export SERVICE_ENDPOINT=http://localhost:35357/v2.0

Alternatively, you can add these variables to ~/.bashrc.

To test if glance is setup correectly execute the following command.

glance index

The above command will not return any output. The output of the last command executed can be known from its return code - echo $?. If the return code is zero, then glance is setup properly and connects with Keystone.

With glance configured properly and using keystone as the authentication mechanism, now we can upload images to glance. This has been explained in detail in "Image Management" chapter.

 

localadmin@OpenStack-1:~$ glance
Usage: glance <command> [options] [args]

Commands:

    help <command>  Output help for one of the commands below

    add             Adds a new image to Glance

    update          Updates an image's metadata in Glance

    delete          Deletes an image from Glance

    index           Return brief information about images in Glance

    details         Return detailed information about images in
                    Glance

    show            Show detailed information about an image in
                    Glance

    clear           Removes all images and metadata from Glance


Member Commands:

    image-members    List members an image is shared with

    member-images    List images shared with a member

    member-add       Grants a member access to an image

    member-delete    Revokes a member's access to an image

    members-replace  Replaces all membership for an image

Options:
  --version             show program's version number and exit
  -h, --help            show this help message and exit
  --silent-upload       disable progress bar animation and information during
                        upload
  -v, --verbose         Print more verbose output
  -d, --debug           Print more verbose output
  -H ADDRESS, --host=ADDRESS
                        Address of Glance API host. Default: 0.0.0.0
  -p PORT, --port=PORT  Port the Glance API host listens on. Default: 9292
  --ssl                 Use SSL when talking to Glance API host
  -U URL, --url=URL     URL of Glance service. This option can be used to
                        specify the hostname, port and protocol (http/https)
                        of the glance server, for example -U
                        https://localhost:9292/v1 Default: None. If given,
                        this option will override settings for --host, --port,
                        and --ssl.
  -k, --insecure        Explicitly allow glance to perform "insecure" SSL
                        (https) requests. The server's certificate will not be
                        verified against any certificate authorities. This
                        option should be used with caution.
  -A TOKEN, --os_auth_token=TOKEN, --auth_token=TOKEN
                        Authentication token to use to identify the client to
                        the glance server.  --auth_tokenis deprecated and will
                        be removed
  -I USER, --os_username=USER
                        User name used to acquire an authentication token
  -K PASSWORD, --os_password=PASSWORD
                        Password used to acquire an authentication token
  -R REGION, --os_region_name=REGION
                        Region name. When using keystone authentication
                        version 2.0 or later this identifies the region name
                        to use when selecting the service endpoint. A region
                        name must be provided if more than one region endpoint
                        is available
  -T TENANT, --os_tenant_name=TENANT
                        Tenant name
  -N AUTH_URL, --os_auth_url=AUTH_URL
                        Authentication URL
  -S STRATEGY, --os_auth_strategy=STRATEGY
                        Authentication strategy (keystone or noauth)
  --limit=LIMIT         Page size to use while requesting image metadata
  --marker=MARKER       Image index after which to begin pagination
  --sort_key=KEY        Sort results by this image attribute.
  --sort_dir=[desc|asc]
                        Sort results in this direction.
  -f, --force           Prevent select actions from requesting user
                        confirmation
  --dry-run             Don't actually execute the command, just print output
                        showing what WOULD happen.
  --can-share           Allow member to further share image.

 

转载于:https://www.cnblogs.com/licheng/archive/2012/06/04/2534628.html

猜你喜欢

转载自blog.csdn.net/weixin_34353714/article/details/92627816