~sandy-walsh/nova/zones

« back to all changes in this revision

Viewing changes to bin/nova-manage

  • Committer: Sandy Walsh
  • Date: 2011-02-17 21:39:03 UTC
  • mfrom: (635.1.60 nova)
  • Revision ID: sandy.walsh@rackspace.com-20110217213903-swehe88wea8inxow
changed from 003-004 migration

Show diffs side-by-side

added added

removed removed

Lines of Context:
433
433
                    "nova-api server on this host.")
434
434
 
435
435
 
 
436
class FixedIpCommands(object):
 
437
    """Class for managing fixed ip."""
 
438
 
 
439
    def list(self, host=None):
 
440
        """Lists all fixed ips (optionally by host) arguments: [host]"""
 
441
        ctxt = context.get_admin_context()
 
442
        if host == None:
 
443
            fixed_ips = db.fixed_ip_get_all(ctxt)
 
444
        else:
 
445
            fixed_ips = db.fixed_ip_get_all_by_host(ctxt, host)
 
446
 
 
447
        print "%-18s\t%-15s\t%-17s\t%-15s\t%s" % (_('network'),
 
448
                                                  _('IP address'),
 
449
                                                  _('MAC address'),
 
450
                                                  _('hostname'),
 
451
                                                  _('host'))
 
452
        for fixed_ip in fixed_ips:
 
453
            hostname = None
 
454
            host = None
 
455
            mac_address = None
 
456
            if fixed_ip['instance']:
 
457
                instance = fixed_ip['instance']
 
458
                hostname = instance['hostname']
 
459
                host = instance['host']
 
460
                mac_address = instance['mac_address']
 
461
            print "%-18s\t%-15s\t%-17s\t%-15s\t%s" % (
 
462
                                  fixed_ip['network']['cidr'],
 
463
                                  fixed_ip['address'],
 
464
                                  mac_address, hostname, host)
 
465
 
 
466
 
436
467
class FloatingIpCommands(object):
437
468
    """Class for managing floating ip."""
438
469
 
472
503
    """Class for managing networks."""
473
504
 
474
505
    def create(self, fixed_range=None, num_networks=None,
475
 
               network_size=None, vlan_start=None, vpn_start=None,
476
 
               fixed_range_v6=None):
 
506
               network_size=None, vlan_start=None,
 
507
               vpn_start=None, fixed_range_v6=None, label='public'):
477
508
        """Creates fixed ips for host by range
478
509
        arguments: [fixed_range=FLAG], [num_networks=FLAG],
479
510
                   [network_size=FLAG], [vlan_start=FLAG],
495
526
                                    cidr=fixed_range,
496
527
                                    num_networks=int(num_networks),
497
528
                                    network_size=int(network_size),
 
529
                                    vlan_start=int(vlan_start),
 
530
                                    vpn_start=int(vpn_start),
498
531
                                    cidr_v6=fixed_range_v6,
499
 
                                    vlan_start=int(vlan_start),
500
 
                                    vpn_start=int(vpn_start))
 
532
                                    label=label)
 
533
 
 
534
    def list(self):
 
535
        """List all created networks"""
 
536
        print "%-18s\t%-15s\t%-15s\t%-15s" % (_('network'),
 
537
                                              _('netmask'),
 
538
                                              _('start address'),
 
539
                                              'DNS')
 
540
        for network in db.network_get_all(context.get_admin_context()):
 
541
            print "%-18s\t%-15s\t%-15s\t%-15s" % (network.cidr,
 
542
                                network.netmask,
 
543
                                network.dhcp_start,
 
544
                                network.dns)
501
545
 
502
546
 
503
547
class ServiceCommands(object):
579
623
        ctxt = context.get_admin_context()
580
624
        volume = db.volume_get(ctxt, param2id(volume_id))
581
625
        host = volume['host']
 
626
 
 
627
        if not host:
 
628
            print "Volume not yet assigned to host."
 
629
            print "Deleting volume from database and skipping rpc."
 
630
            db.volume_destroy(ctxt, param2id(volume_id))
 
631
            return
 
632
 
582
633
        if volume['status'] == 'in-use':
583
634
            print "Volume is in-use."
584
635
            print "Detach volume from instance and then try again."
615
666
    ('role', RoleCommands),
616
667
    ('shell', ShellCommands),
617
668
    ('vpn', VpnCommands),
 
669
    ('fixed', FixedIpCommands),
618
670
    ('floating', FloatingIpCommands),
619
671
    ('network', NetworkCommands),
620
672
    ('service', ServiceCommands),