Cobalt extension for OS novaclient.
Project description
Overview
========
An extension hook for novaclient that enables it to interact with the Cobalt endpoints.
Command line usage
==================
After installing the operations provided by the Cobalt extension will be available to the
nova command line application:
# Display all of the available commands of the nova script. The gridcentric live-image-create,
# live-image-start, live-image-list, live-image-servers, live-image-delete and co-migrate
# are listed.
$ nova help
# Doing nova help <command> on any of these commands will display how to use them in detail.
$ nova help live-image-create
usage: nova live-image-create [--name <name>] <instance>
Creates a new live-image from a running instance.
Positional arguments:
<instance> ID or name of the instance from which to create the live-
image
Optional arguments:
--name <name> The name of the live-image
$ nova help live-image-start
usage: nova live-image-start [--target <target memory>]
[--name <instance name>]
[--user_data <user-data>]
[--security-groups <security groups>]
[--availability-zone <availability zone>]
[--num-instances <number>]
[--key-name <key name>] [--params <key=value>]
<live image>
Start a new instance from a live-image.
Positional arguments:
<live image> ID or name of the live-image
Optional arguments:
--target <target memory>
The memory target of the launched instance
--name <instance name>
The name of the launched instance
--user_data <user-data>
User data file to pass to be exposed by the metadata
server
--security-groups <security groups>
comma separated list of security group names.
--availability-zone <availability zone>
The availability zone for instance placement.
--num-instances <number>
Launch multiple instances at a time
--key-name <key name>
Key name of keypair that should be created earlier
with the command keypair-add
--params <key=value> Guest parameters to send to vms-agent
$ nova help live-image-delete
usage: nova live-image-delete <live-image>
Delete a live image.
Positional arguments:
<live-image> ID or name of the live-image
$ nova help co-migrate
usage: nova co-migrate [--dest <destination host>] <instance>
Migrate an instance using VMS.
Positional arguments:
<instance> ID or name of the instance to migrate
Optional arguments:
--dest <destination host>
Host to migrate to
$ nova help live-image-servers
usage: nova live-image-servers <live-image>
List instances started from this live-image.
Positional arguments:
<live-image> ID or name of the live-image
$ nova help live-image-list
usage: nova live-image-list <server>
List the live images of this instance.
Positional arguments:
<server> ID or name of the instance
Scripting usage
===============
The novaclient hooks can also be accessed directly using the python API.
user = "admin"
apikey = "admin"
project = "openstackDemo"
authurl = "http://localhost:5000/v2.0"
extensions = shell.OpenStackComputeShell()._discover_extensions("1.1")
novaclient = NovaClient(user, apikey, project, authurl, extensions=extensions,
endpoint_type=shell.DEFAULT_NOVA_ENDPOINT_TYPE,
service_type=shell.DEFAULT_NOVA_SERVICE_TYPE)
def wait_for_status(server, status):
while server.status != status:
time.sleep(30)
server = novaclient.cobalt.get(server.id)
return server
def wait_until_gone(server):
try:
while True:
server = novaclient.cobalt.get(server.id)
time.sleep(10)
except Exception, e:
# server is no longer there.
pass
# Boot a new server using flavor 1 and the image passed in as the first argument.
image_id = sys.argv[1]
flavor_id = 1
server = novaclient.servers.create("Gridcentric instance",
image_id,
flavor_id)
server = wait_for_status(server, "ACTIVE")
# Create a live image of the server. This will return an instance of the blessed_server. We need to
# wait until the live image becomes active.
live_image = novaclient.cobalt.live_image_create(server)[0]
live_image = wait_for_status(live_image, "BLESSED")
# Launch a new server based off of the live iamge. Note that we can do this
# by either calling start_live_image on the server itself, or passing the server into the
# cobalt manager.
launched_server = live_image.start_live_image()[0]
launched_server2 = novaclient.cobalt.start_live_image(live_image)[0]
# list the servers that were launched from the live_image.
for s in live_image.list_servers():
print "Server %s was launched from %s" %(s.id, live_image.id)
# Delete the launched servers.
launched_server2 = wait_for_status(launched_server2, "ACTIVE")
launched_server2.delete()
launched_server = wait_for_status(launched_server, "ACTIVE")
novaclient.servers.delete(launched_server)
# W need to ensure that the launched instances have been deleted before deleting
# the live image.
wait_until_gone(launched_server2)
wait_until_gone(launched_server)
# Delete the original server. Note we can delete this server
# and keep the blessed one around.
server.delete()
# Discard the blessed server
live_image.delete_live_image()
========
An extension hook for novaclient that enables it to interact with the Cobalt endpoints.
Command line usage
==================
After installing the operations provided by the Cobalt extension will be available to the
nova command line application:
# Display all of the available commands of the nova script. The gridcentric live-image-create,
# live-image-start, live-image-list, live-image-servers, live-image-delete and co-migrate
# are listed.
$ nova help
# Doing nova help <command> on any of these commands will display how to use them in detail.
$ nova help live-image-create
usage: nova live-image-create [--name <name>] <instance>
Creates a new live-image from a running instance.
Positional arguments:
<instance> ID or name of the instance from which to create the live-
image
Optional arguments:
--name <name> The name of the live-image
$ nova help live-image-start
usage: nova live-image-start [--target <target memory>]
[--name <instance name>]
[--user_data <user-data>]
[--security-groups <security groups>]
[--availability-zone <availability zone>]
[--num-instances <number>]
[--key-name <key name>] [--params <key=value>]
<live image>
Start a new instance from a live-image.
Positional arguments:
<live image> ID or name of the live-image
Optional arguments:
--target <target memory>
The memory target of the launched instance
--name <instance name>
The name of the launched instance
--user_data <user-data>
User data file to pass to be exposed by the metadata
server
--security-groups <security groups>
comma separated list of security group names.
--availability-zone <availability zone>
The availability zone for instance placement.
--num-instances <number>
Launch multiple instances at a time
--key-name <key name>
Key name of keypair that should be created earlier
with the command keypair-add
--params <key=value> Guest parameters to send to vms-agent
$ nova help live-image-delete
usage: nova live-image-delete <live-image>
Delete a live image.
Positional arguments:
<live-image> ID or name of the live-image
$ nova help co-migrate
usage: nova co-migrate [--dest <destination host>] <instance>
Migrate an instance using VMS.
Positional arguments:
<instance> ID or name of the instance to migrate
Optional arguments:
--dest <destination host>
Host to migrate to
$ nova help live-image-servers
usage: nova live-image-servers <live-image>
List instances started from this live-image.
Positional arguments:
<live-image> ID or name of the live-image
$ nova help live-image-list
usage: nova live-image-list <server>
List the live images of this instance.
Positional arguments:
<server> ID or name of the instance
Scripting usage
===============
The novaclient hooks can also be accessed directly using the python API.
user = "admin"
apikey = "admin"
project = "openstackDemo"
authurl = "http://localhost:5000/v2.0"
extensions = shell.OpenStackComputeShell()._discover_extensions("1.1")
novaclient = NovaClient(user, apikey, project, authurl, extensions=extensions,
endpoint_type=shell.DEFAULT_NOVA_ENDPOINT_TYPE,
service_type=shell.DEFAULT_NOVA_SERVICE_TYPE)
def wait_for_status(server, status):
while server.status != status:
time.sleep(30)
server = novaclient.cobalt.get(server.id)
return server
def wait_until_gone(server):
try:
while True:
server = novaclient.cobalt.get(server.id)
time.sleep(10)
except Exception, e:
# server is no longer there.
pass
# Boot a new server using flavor 1 and the image passed in as the first argument.
image_id = sys.argv[1]
flavor_id = 1
server = novaclient.servers.create("Gridcentric instance",
image_id,
flavor_id)
server = wait_for_status(server, "ACTIVE")
# Create a live image of the server. This will return an instance of the blessed_server. We need to
# wait until the live image becomes active.
live_image = novaclient.cobalt.live_image_create(server)[0]
live_image = wait_for_status(live_image, "BLESSED")
# Launch a new server based off of the live iamge. Note that we can do this
# by either calling start_live_image on the server itself, or passing the server into the
# cobalt manager.
launched_server = live_image.start_live_image()[0]
launched_server2 = novaclient.cobalt.start_live_image(live_image)[0]
# list the servers that were launched from the live_image.
for s in live_image.list_servers():
print "Server %s was launched from %s" %(s.id, live_image.id)
# Delete the launched servers.
launched_server2 = wait_for_status(launched_server2, "ACTIVE")
launched_server2.delete()
launched_server = wait_for_status(launched_server, "ACTIVE")
novaclient.servers.delete(launched_server)
# W need to ensure that the launched instances have been deleted before deleting
# the live image.
wait_until_gone(launched_server2)
wait_until_gone(launched_server)
# Delete the original server. Note we can delete this server
# and keep the blessed one around.
server.delete()
# Discard the blessed server
live_image.delete_live_image()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file cobalt_python_novaclient_ext-1.3.107.tar.gz
.
File metadata
- Download URL: cobalt_python_novaclient_ext-1.3.107.tar.gz
- Upload date:
- Size: 12.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 29c6ad053c8e8ab7b18da89e398ecb1202a23fcdbb5a3b8751fce29e12de9ba7 |
|
MD5 | d6924ddc923d676ed1fabb39fe107c74 |
|
BLAKE2b-256 | 739bb7cdbc82c8653a8c1507fd0da6484810cb4ec14504df0e87c3907b972471 |