94
97
flags.DECLARE('fixed_range_v6', 'nova.network.manager')
100
def param2id(object_id):
101
"""Helper function to convert various id types to internal id.
102
args: [object_id], e.g. 'vol-0000000a' or 'volume-0000000a' or '10'
105
return ec2_id_to_id(object_id)
107
return int(object_id)
97
110
class VpnCommands(object):
98
111
"""Class for managing VPNs."""
519
532
print re.sub('#012', "\n", "\n".join(lines))
535
class DbCommands(object):
536
"""Class for managing the database."""
541
def sync(self, version=None):
542
"""Sync the database up to the most recent version."""
543
return migration.db_sync(version)
546
"""Print the current database version."""
547
print migration.db_version()
550
class VolumeCommands(object):
551
"""Methods for dealing with a cloud in an odd state"""
553
def delete(self, volume_id):
554
"""Delete a volume, bypassing the check that it
556
args: volume_id_id"""
557
ctxt = context.get_admin_context()
558
volume = db.volume_get(ctxt, param2id(volume_id))
559
host = volume['host']
560
if volume['status'] == 'in-use':
561
print "Volume is in-use."
562
print "Detach volume from instance and then try again."
566
db.queue_get_for(ctxt, FLAGS.volume_topic, host),
567
{"method": "delete_volume",
568
"args": {"volume_id": volume['id']}})
570
def reattach(self, volume_id):
571
"""Re-attach a volume that has previously been attached
572
to an instance. Typically called after a compute host
574
args: volume_id_id"""
575
ctxt = context.get_admin_context()
576
volume = db.volume_get(ctxt, param2id(volume_id))
577
if not volume['instance_id']:
578
print "volume is not attached to an instance"
580
instance = db.instance_get(ctxt, volume['instance_id'])
581
host = instance['host']
583
db.queue_get_for(ctxt, FLAGS.compute_topic, host),
584
{"method": "attach_volume",
585
"args": {"instance_id": instance['id'],
586
"volume_id": volume['id'],
587
"mountpoint": volume['mountpoint']}})
523
591
('user', UserCommands),
524
592
('project', ProjectCommands),
528
596
('floating', FloatingIpCommands),
529
597
('network', NetworkCommands),
530
598
('service', ServiceCommands),
531
('log', LogCommands)]
599
('log', LogCommands),
601
('volume', VolumeCommands)]
534
604
def lazy_match(name, key_value_tuples):