Added commands to work with keypairs
This commit is contained in:
parent
16b083ddca
commit
0ce3f97910
@ -92,6 +92,9 @@ You'll find complete documentation on the shell by running
|
|||||||
ipgroup-delete Delete an IP group.
|
ipgroup-delete Delete an IP group.
|
||||||
ipgroup-list Show IP groups.
|
ipgroup-list Show IP groups.
|
||||||
ipgroup-show Show details about a particular IP group.
|
ipgroup-show Show details about a particular IP group.
|
||||||
|
keypair-add Create a new key pair for use with instances
|
||||||
|
keypair-delete Delete keypair by its id
|
||||||
|
keypair-list Show a list of keypairs for a user
|
||||||
list List active servers.
|
list List active servers.
|
||||||
migrate Migrate a server to a new host in the same zone.
|
migrate Migrate a server to a new host in the same zone.
|
||||||
reboot Reboot a server.
|
reboot Reboot a server.
|
||||||
@ -113,6 +116,7 @@ You'll find complete documentation on the shell by running
|
|||||||
zone-info Show the capabilities for this Zone.
|
zone-info Show the capabilities for this Zone.
|
||||||
zone-list List all the immediate Child Zones.
|
zone-list List all the immediate Child Zones.
|
||||||
|
|
||||||
|
|
||||||
Optional arguments:
|
Optional arguments:
|
||||||
--username USERNAME Defaults to env[NOVA_USERNAME].
|
--username USERNAME Defaults to env[NOVA_USERNAME].
|
||||||
--apikey APIKEY Defaults to env[NOVA_API_KEY].
|
--apikey APIKEY Defaults to env[NOVA_API_KEY].
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
"""
|
"""
|
||||||
Keypair interface (1.1 extension).
|
Keypair interface (1.1 extension).
|
||||||
"""
|
"""
|
||||||
|
import os
|
||||||
|
|
||||||
from novaclient import base
|
from novaclient import base
|
||||||
|
|
||||||
@ -50,7 +51,7 @@ class KeypairManager(base.ManagerWithFind):
|
|||||||
Create a keypair
|
Create a keypair
|
||||||
|
|
||||||
:param name: name for the keypair to create
|
:param name: name for the keypair to create
|
||||||
:param public_key: existing public key to import
|
:param public_key: path to a public ssh key.
|
||||||
"""
|
"""
|
||||||
body = {'keypair': {'name': name}}
|
body = {'keypair': {'name': name}}
|
||||||
if public_key:
|
if public_key:
|
||||||
|
@ -207,7 +207,7 @@ def do_zone_boot(cs, args):
|
|||||||
min_count=min_count,
|
min_count=min_count,
|
||||||
max_count=max_count)
|
max_count=max_count)
|
||||||
print "Reservation ID=", reservation_id
|
print "Reservation ID=", reservation_id
|
||||||
|
|
||||||
|
|
||||||
def _translate_flavor_keys(collection):
|
def _translate_flavor_keys(collection):
|
||||||
convert = [('ram', 'memory_mb'), ('disk', 'local_gb')]
|
convert = [('ram', 'memory_mb'), ('disk', 'local_gb')]
|
||||||
@ -703,3 +703,39 @@ def do_remove_fixed_ip(cs, args):
|
|||||||
"""Remove an IP address from a server."""
|
"""Remove an IP address from a server."""
|
||||||
server = _find_server(cs, args.server)
|
server = _find_server(cs, args.server)
|
||||||
server.remove_fixed_ip(args.address)
|
server.remove_fixed_ip(args.address)
|
||||||
|
|
||||||
|
|
||||||
|
@utils.arg('name', metavar='<name>', help='Name of key.')
|
||||||
|
@utils.arg('--pub_key', metavar='<pub_key>', help='Path to a public ssh key.', default=None)
|
||||||
|
def do_keypair_add(cs, args):
|
||||||
|
"""Create a new key pair for use with instances"""
|
||||||
|
name = args.name
|
||||||
|
pub_key = args.pub_key
|
||||||
|
|
||||||
|
if pub_key:
|
||||||
|
try:
|
||||||
|
with open(pub_key) as f:
|
||||||
|
pub_key = f.read()
|
||||||
|
except IOError, e:
|
||||||
|
raise exceptions.CommandError("Can't open or read '%s': %s" % (pub_key, e))
|
||||||
|
|
||||||
|
keypair = cs.keypairs.create(name, pub_key)
|
||||||
|
|
||||||
|
if not pub_key:
|
||||||
|
private_key = keypair.private_key
|
||||||
|
print private_key
|
||||||
|
|
||||||
|
|
||||||
|
@utils.arg('name', metavar='<name>', help='Keypair name to delete.')
|
||||||
|
def do_keypair_delete(cs, args):
|
||||||
|
"""Delete keypair by its id"""
|
||||||
|
name = args.name
|
||||||
|
cs.keypairs.delete(name)
|
||||||
|
|
||||||
|
|
||||||
|
def do_keypair_list(cs, args):
|
||||||
|
"""Print a list of keypairs for a user"""
|
||||||
|
keypairs = cs.keypairs.list()
|
||||||
|
columns = ['Name', 'Fingerprint']
|
||||||
|
utils.print_list(keypairs, columns)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user