The image service comes with a tool called glance-replicator that can be used to populate a new glance server using the images stored in an existing glance server. The images in the replicated glance server preserve the uuids, metadata, and image data from the original. Running the tool will output a set of commands that it supports:
$ glance-replicator Usage: glance-replicator <command> [options] [args] Commands: help <command> Output help for one of the commands below compare What is missing from the slave glance? dump Dump the contents of a glance instance to local disk. livecopy Load the contents of one glance instance into another. load Load the contents of a local directory into glance. size Determine the size of a glance instance if dumped to disk. Options: --version show program's version number and exit -h, --help show this help message and exit -c CHUNKSIZE, --chunksize=CHUNKSIZE Amount of data to transfer per HTTP write -d, --debug Print debugging information -D DONTREPLICATE, --dontreplicate=DONTREPLICATE List of fields to not replicate -m, --metaonly Only replicate metadata, not images -l LOGFILE, --logfile=LOGFILE Path of file to log to -s, --syslog Log to syslog instead of a file -t TOKEN, --token=TOKEN Pass in your authentication token if you have one. If you use this option the same token is used for both the master and the slave. -M MASTERTOKEN, --mastertoken=MASTERTOKEN Pass in your authentication token if you have one. This is the token used for the master. -S SLAVETOKEN, --slavetoken=SLAVETOKEN Pass in your authentication token if you have one. This is the token used for the slave. -v, --verbose Print more verbose output
The replicator supports the following commands:
glance-replicator livecopyfromserver:port
toserver:port
fromserver:port
: the location of the master glance instancetoserver:port
: the location of the slave glance instance.
Take a copy of the fromserver, and dump it onto the
toserver. Only images visible to the user running the
replicator will be copied if glance is configured to
use the Identity service (keystone) for
authentication. Only images active on
fromserver
are copied
across. The copy is done "on-the-wire" so there are no
large temporary files on the machine running the
replicator to clean up.
glance-replicator dumpserver:port
path
server:port
: the location of the glance instance.path
: a directory on disk to contain the data.
Do the same thing as livecopy, but dump the contents of the glance server to a directory on disk. This includes metadata and image data. Depending on the size of the local glance repository, the resulting dump may consume a large amount of local storage. Therefore, we recommend you use the size comamnd first to determine the size of the resulting dump.
glance-replicator load server:port path
server:port
: the location of the glance instance.path
: a directory on disk containing the data.
Load the contents of a local directory into glance.
The dump and load are useful when replicating across two glance servers where a direct connection across the two glance hosts is impossible or too slow.
glance-replicator comparefromserver:port
toserver:port
fromserver:port
: the location of the master glance instance.toserver:port
: the location of the slave glance instance.
The compare command will show you the differences between the two servers, which is effectively a dry run of the livecopy command.
glance-replicator size
server:port
: the location of the glance instance.
The size command will tell you how much disk is going to be used by image data in either a dump or a livecopy. Note that this will provide raw number of bytes that would be written to the destination, it has no information about the redundancy costs associated with glance-registry back-ends that use replication for redundancy, such as Swift or Ceph.
Assuming you have a primary glance service running
on a node called
primary.example.com
with
glance-api service running on port
9292
(the default port) and you
want to replicate its contents to a secondary glance
service running on a node called
secondary.example.com
, also on
port 9292, you will first need to get authentication
tokens from keystone for the primary and secondary
glance server and then you can use the
glance-replicator livecopy
command.
The following example assumes that you have a
credentials file for your primary cloud called
primary.openrc
and one for
your secondary cloud called
secondary.openrc
.
$ source primary.openrc $ keystone token-get +-----------+----------------------------------+ | Property | Value | +-----------+----------------------------------+ | expires | 2012-11-16T03:13:08Z | | id | 8a5d3afb5095430891f33f69a2791463 | | tenant_id | dba21b41af584daeac5782ca15a77a25 | | user_id | add2ece6b1f94866994d3a3e3beb3d47 | +-----------+----------------------------------+ $ PRIMARY_AUTH_TOKEN=8e97fa8bcf4443cfbd3beb9079c7142f
$ source secondary.openrc $ keystone token-get +-----------+----------------------------------+ | Property | Value | +-----------+----------------------------------+ | expires | 2012-11-16T03:13:08Z | | id | 29f777ac2c9b41a6b4ee9c3e6b85f98a | | tenant_id | fbde89d638d947a19545b0f387ffea4d | | user_id | 4a7a48e7d62e4b428c78d02c1968ca7b | +-----------+----------------------------------+ $ SECONDARY_AUTH_TOKEN=29f777ac2c9b41a6b4ee9c3e6b85f98a
$ glance-replicator livecopy primary.example.com:9292 secondary.example.com:9292 -M ${PRIMARY_AUTH_TOKEN} -S ${SECONDARY_AUTH_TOKEN}