~ubuntu-branches/ubuntu/saucy/nova/saucy-proposed

« back to all changes in this revision

Viewing changes to bin/nova-manage

  • Committer: Package Import Robot
  • Author(s): Chuck Short
  • Date: 2012-05-24 13:12:53 UTC
  • mfrom: (1.1.55)
  • Revision ID: package-import@ubuntu.com-20120524131253-ommql08fg1en06ut
Tags: 2012.2~f1-0ubuntu1
* New upstream release.
* Prepare for quantal:
  - Dropped debian/patches/upstream/0006-Use-project_id-in-ec2.cloud._format_image.patch
  - Dropped debian/patches/upstream/0005-Populate-image-properties-with-project_id-again.patch
  - Dropped debian/patches/upstream/0004-Fixed-bug-962840-added-a-test-case.patch
  - Dropped debian/patches/upstream/0003-Allow-unprivileged-RADOS-users-to-access-rbd-volumes.patch
  - Dropped debian/patches/upstream/0002-Stop-libvirt-test-from-deleting-instances-dir.patch
  - Dropped debian/patches/upstream/0001-fix-bug-where-nova-ignores-glance-host-in-imageref.patch 
  - Dropped debian/patches/0001-fix-useexisting-deprecation-warnings.patch
* debian/control: Add python-keystone as a dependency. (LP: #907197)
* debian/patches/kombu_tests_timeout.patch: Refreshed.
* debian/nova.conf, debian/nova-common.postinst: Convert to new ini
  file configuration
* debian/patches/nova-manage_flagfile_location.patch: Refreshed

Show diffs side-by-side

added added

removed removed

Lines of Context:
76
76
 
77
77
gettext.install('nova', unicode=1)
78
78
 
 
79
from nova.api.ec2 import ec2utils
 
80
from nova.auth import manager
79
81
from nova.compat import flagfile
 
82
from nova.compute import instance_types
80
83
from nova import context
81
84
from nova import crypto
82
85
from nova import db
 
86
from nova.db import migration
83
87
from nova import exception
84
88
from nova import flags
85
89
from nova import log as logging
 
90
from nova.openstack.common import importutils
86
91
from nova import quota
87
92
from nova import rpc
 
93
from nova.scheduler import rpcapi as scheduler_rpcapi
88
94
from nova import utils
89
95
from nova import version
90
 
from nova.api.ec2 import ec2utils
91
 
from nova.auth import manager
92
 
from nova.compute import instance_types
93
 
from nova.db import migration
94
96
from nova.volume import volume_types
95
97
 
96
98
FLAGS = flags.FLAGS
740
742
        # check for certain required inputs
741
743
        if not label:
742
744
            raise exception.NetworkNotCreated(req='--label')
 
745
        # Size of "label" column in nova.networks is 255, hence the restriction
 
746
        if len(label) > 255:
 
747
            reason = _("Maximum allowed length for 'label' is 255.")
 
748
            raise exception.InvalidInput(reason=reason)
743
749
        if not (fixed_range_v4 or fixed_range_v6):
744
750
            req = '--fixed_range_v4 or --fixed_range_v6'
745
751
            raise exception.NetworkNotCreated(req=req)
790
796
            fixed_cidr = netaddr.IPNetwork(fixed_cidr)
791
797
 
792
798
        # create the network
793
 
        net_manager = utils.import_object(FLAGS.network_manager)
 
799
        net_manager = importutils.import_object(FLAGS.network_manager)
794
800
        net_manager.create_networks(context.get_admin_context(),
795
801
                                    label=label,
796
802
                                    cidr=fixed_range_v4,
859
865
        if fixed_range is None and uuid is None:
860
866
            raise Exception("Please specify either fixed_range or uuid")
861
867
 
862
 
        net_manager = utils.import_object(FLAGS.network_manager)
 
868
        net_manager = importutils.import_object(FLAGS.network_manager)
863
869
        if "QuantumManager" in FLAGS.network_manager:
864
870
            if uuid is None:
865
871
                raise Exception("UUID is required to delete Quantum Networks")
1016
1022
        :param host: hostname.
1017
1023
 
1018
1024
        """
1019
 
        result = rpc.call(context.get_admin_context(),
1020
 
                     FLAGS.scheduler_topic,
1021
 
                     {"method": "show_host_resources",
1022
 
                      "args": {"host": host}})
 
1025
        rpcapi = scheduler_rpcapi.SchedulerAPI()
 
1026
        result = rpcapi.show_host_resources(context.get_admin_context(),
 
1027
                                            host=host)
1023
1028
 
1024
1029
        if not isinstance(result, dict):
1025
1030
            print _('An unexpected error has occurred.')
1113
1118
        pass
1114
1119
 
1115
1120
    def list(self):
1116
 
        print _("%s (%s)") %\
1117
 
                (version.version_string(), version.version_string_with_vcs())
 
1121
        print _("%(version)s (%(vcs)s)") % \
 
1122
                {'version': version.version_string(),
 
1123
                 'vcs': version.version_string_with_vcs()}
1118
1124
 
1119
1125
    def __call__(self):
1120
1126
        self.list()
1612
1618
    ('floating', FloatingIpCommands),
1613
1619
    ('host', HostCommands),
1614
1620
    ('instance_type', InstanceTypeCommands),
 
1621
    ('logs', GetLogCommands),
1615
1622
    ('network', NetworkCommands),
1616
1623
    ('project', ProjectCommands),
1617
1624
    ('role', RoleCommands),
1623
1630
    ('vm', VmCommands),
1624
1631
    ('volume', VolumeCommands),
1625
1632
    ('vpn', VpnCommands),
1626
 
    ('logs', GetLogCommands)]
 
1633
]
1627
1634
 
1628
1635
 
1629
1636
def lazy_match(name, key_value_tuples):
1659
1666
 
1660
1667
def main():
1661
1668
    """Parse options and call the appropriate class/method."""
1662
 
    flagfile = utils.default_flagfile('/etc/nova/nova.conf')
 
1669
    cfgfile = utils.default_cfgfile('/etc/nova/nova.conf')
1663
1670
 
1664
 
    if flagfile and not os.access(flagfile, os.R_OK):
1665
 
        st = os.stat(flagfile)
1666
 
        print "Could not read %s. Re-running with sudo" % flagfile
 
1671
    if cfgfile and not os.access(cfgfile, os.R_OK):
 
1672
        st = os.stat(cfgfile)
 
1673
        print "Could not read %s. Re-running with sudo" % cfgfile
1667
1674
        try:
1668
1675
            os.execvp('sudo', ['sudo', '-u', '#%s' % st.st_uid] + sys.argv)
1669
1676
        except Exception:
1670
1677
            print 'sudo failed, continuing as if nothing happened'
1671
1678
 
 
1679
    rpc.register_opts(FLAGS)
 
1680
 
1672
1681
    try:
1673
1682
        argv = FLAGS(sys.argv)
1674
1683
        logging.setup()
1677
1686
            print _('Please re-run nova-manage as root.')
1678
1687
            sys.exit(2)
1679
1688
        raise
1680
 
 
1681
1689
    script_name = argv.pop(0)
1682
1690
    if len(argv) < 1:
1683
 
        print _("\nOpenStack Nova version: %s (%s)\n") %\
1684
 
                (version.version_string(), version.version_string_with_vcs())
 
1691
        print _("\nOpenStack Nova version: %(version)s (%(vcs)s)\n") % \
 
1692
                {'version': version.version_string(),
 
1693
                 'vcs': version.version_string_with_vcs()}
1685
1694
        print script_name + " category action [<args>]"
1686
1695
        print _("Available categories:")
1687
1696
        for k, _v in CATEGORIES:
1721
1730
    for k, v in fn_kwargs.items():
1722
1731
        if v is None:
1723
1732
            del fn_kwargs[k]
1724
 
        else:
 
1733
        elif isinstance(v, basestring):
1725
1734
            fn_kwargs[k] = v.decode('utf-8')
 
1735
        else:
 
1736
            fn_kwargs[k] = v
1726
1737
 
1727
1738
    fn_args = [arg.decode('utf-8') for arg in fn_args]
1728
1739