summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorDonal Lafferty <donal.lafferty@citrix.com>2011-06-27 15:22:15 +0100
committerDonal Lafferty <donal.lafferty@citrix.com>2011-06-27 15:22:15 +0100
commitd7844ecbf5dff67d22beaaff90f0bfa3acb4362a (patch)
tree413dd7858fdfbd8e214378e3102273f74be7ea71 /bin
parent81894967d8b6920f7cf1b64636a7c4f531e81bde (diff)
parent8a8c013cd4513b07e936125a23188e7608f40d58 (diff)
Pulled trunk, merged boot from ISO changes.
Diffstat (limited to 'bin')
-rwxr-xr-xbin/nova-dhcpbridge7
-rwxr-xr-xbin/nova-manage153
2 files changed, 121 insertions, 39 deletions
diff --git a/bin/nova-dhcpbridge b/bin/nova-dhcpbridge
index f42dfd6b5..5926b97de 100755
--- a/bin/nova-dhcpbridge
+++ b/bin/nova-dhcpbridge
@@ -108,6 +108,13 @@ def main():
interface = os.environ.get('DNSMASQ_INTERFACE', FLAGS.dnsmasq_interface)
if int(os.environ.get('TESTING', '0')):
from nova.tests import fake_flags
+
+ #if FLAGS.fake_rabbit:
+ # LOG.debug(_("leasing ip"))
+ # network_manager = utils.import_object(FLAGS.network_manager)
+ ## reload(fake_flags)
+ # from nova.tests import fake_flags
+
action = argv[1]
if action in ['add', 'del', 'old']:
mac = argv[2]
diff --git a/bin/nova-manage b/bin/nova-manage
index e3ed7b9d0..02f20347d 100755
--- a/bin/nova-manage
+++ b/bin/nova-manage
@@ -53,15 +53,14 @@
CLI interface for nova management.
"""
-import datetime
import gettext
import glob
import json
+import netaddr
import os
import sys
import time
-import IPy
# If ../nova/__init__.py exists, add ../ to Python search path, so that
# it will override what happens to be installed in /usr/(local/)lib/python...
@@ -78,6 +77,7 @@ from nova import crypto
from nova import db
from nova import exception
from nova import flags
+from nova import image
from nova import log as logging
from nova import quota
from nova import rpc
@@ -96,8 +96,8 @@ flags.DECLARE('network_size', 'nova.network.manager')
flags.DECLARE('vlan_start', 'nova.network.manager')
flags.DECLARE('vpn_start', 'nova.network.manager')
flags.DECLARE('fixed_range_v6', 'nova.network.manager')
-flags.DECLARE('images_path', 'nova.image.local')
-flags.DECLARE('libvirt_type', 'nova.virt.libvirt_conn')
+flags.DECLARE('gateway_v6', 'nova.network.manager')
+flags.DECLARE('libvirt_type', 'nova.virt.libvirt.connection')
flags.DEFINE_flag(flags.HelpFlag())
flags.DEFINE_flag(flags.HelpshortFlag())
flags.DEFINE_flag(flags.HelpXMLFlag())
@@ -257,6 +257,11 @@ class RoleCommands(object):
"""adds role to user
if project is specified, adds project specific role
arguments: user, role [project]"""
+ if project:
+ projobj = self.manager.get_project(project)
+ if not projobj.has_member(user):
+ print "%s not a member of %s" % (user, project)
+ return
self.manager.add_role(user, role, project)
def has(self, user, role, project=None):
@@ -417,12 +422,16 @@ class ProjectCommands(object):
arguments: project_id [key] [value]"""
ctxt = context.get_admin_context()
if key:
+ if value.lower() == 'unlimited':
+ value = None
try:
db.quota_update(ctxt, project_id, key, value)
except exception.ProjectQuotaNotFound:
db.quota_create(ctxt, project_id, key, value)
- project_quota = quota.get_quota(ctxt, project_id)
+ project_quota = quota.get_project_quotas(ctxt, project_id)
for key, value in project_quota.iteritems():
+ if value is None:
+ value = 'unlimited'
print '%s: %s' % (key, value)
def remove(self, project_id, user_id):
@@ -509,7 +518,7 @@ class FloatingIpCommands(object):
def create(self, host, range):
"""Creates floating ips for host by range
arguments: host ip_range"""
- for address in IPy.IP(range):
+ for address in netaddr.IPNetwork(range):
db.floating_ip_create(context.get_admin_context(),
{'address': str(address),
'host': host})
@@ -517,7 +526,7 @@ class FloatingIpCommands(object):
def delete(self, ip_range):
"""Deletes floating ips by range
arguments: range"""
- for address in IPy.IP(ip_range):
+ for address in netaddr.IPNetwork(ip_range):
db.floating_ip_destroy(context.get_admin_context(),
str(address))
@@ -532,7 +541,7 @@ class FloatingIpCommands(object):
for floating_ip in floating_ips:
instance = None
if floating_ip['fixed_ip']:
- instance = floating_ip['fixed_ip']['instance']['ec2_id']
+ instance = floating_ip['fixed_ip']['instance']['hostname']
print "%s\t%s\t%s" % (floating_ip['host'],
floating_ip['address'],
instance)
@@ -541,13 +550,10 @@ class FloatingIpCommands(object):
class NetworkCommands(object):
"""Class for managing networks."""
- def create(self, fixed_range=None, num_networks=None,
- network_size=None, vlan_start=None,
- vpn_start=None, fixed_range_v6=None, label='public'):
- """Creates fixed ips for host by range
- arguments: fixed_range=FLAG, [num_networks=FLAG],
- [network_size=FLAG], [vlan_start=FLAG],
- [vpn_start=FLAG], [fixed_range_v6=FLAG]"""
+ def create(self, fixed_range=None, num_networks=None, network_size=None,
+ vlan_start=None, vpn_start=None, fixed_range_v6=None,
+ gateway_v6=None, label='public'):
+ """Creates fixed ips for host by range"""
if not fixed_range:
msg = _('Fixed range in the form of 10.0.0.0/8 is '
'required to create networks.')
@@ -563,6 +569,8 @@ class NetworkCommands(object):
vpn_start = FLAGS.vpn_start
if not fixed_range_v6:
fixed_range_v6 = FLAGS.fixed_range_v6
+ if not gateway_v6:
+ gateway_v6 = FLAGS.gateway_v6
net_manager = utils.import_object(FLAGS.network_manager)
try:
net_manager.create_networks(context.get_admin_context(),
@@ -572,6 +580,7 @@ class NetworkCommands(object):
vlan_start=int(vlan_start),
vpn_start=int(vpn_start),
cidr_v6=fixed_range_v6,
+ gateway_v6=gateway_v6,
label=label)
except ValueError, e:
print e
@@ -685,7 +694,7 @@ class ServiceCommands(object):
"""Show a list of all running services. Filter by host & service name.
args: [host] [service]"""
ctxt = context.get_admin_context()
- now = datetime.datetime.utcnow()
+ now = utils.utcnow()
services = db.service_get_all(ctxt)
if host:
services = [s for s in services if s['host'] == host]
@@ -869,7 +878,7 @@ class InstanceTypeCommands(object):
try:
instance_types.create(name, memory, vcpus, local_gb,
flavorid, swap, rxtx_quota, rxtx_cap)
- except exception.InvalidInputException:
+ except exception.InvalidInput:
print "Must supply valid parameters to create instance_type"
print e
sys.exit(1)
@@ -932,7 +941,7 @@ class ImageCommands(object):
"""Methods for dealing with a cloud in an odd state"""
def __init__(self, *args, **kwargs):
- self.image_service = utils.import_object(FLAGS.image_service)
+ self.image_service = image.get_default_image_service()
def _register(self, container_format, disk_format,
path, owner, name=None, is_public='T',
@@ -1051,16 +1060,6 @@ class ImageCommands(object):
machine_images = {}
other_images = {}
directory = os.path.abspath(directory)
- # NOTE(vish): If we're importing from the images path dir, attempt
- # to move the files out of the way before importing
- # so we aren't writing to the same directory. This
- # may fail if the dir was a mointpoint.
- if (FLAGS.image_service == 'nova.image.local.LocalImageService'
- and directory == os.path.abspath(FLAGS.images_path)):
- new_dir = "%s_bak" % directory
- os.rename(directory, new_dir)
- os.mkdir(directory)
- directory = new_dir
for fn in glob.glob("%s/*/info.json" % directory):
try:
image_path = os.path.join(fn.rpartition('/')[0], 'image')
@@ -1077,24 +1076,100 @@ class ImageCommands(object):
self._convert_images(machine_images)
+class AgentBuildCommands(object):
+ """Class for managing agent builds."""
+
+ def create(self, os, architecture, version, url, md5hash,
+ hypervisor='xen'):
+ """Creates a new agent build.
+ arguments: os architecture version url md5hash [hypervisor='xen']"""
+ ctxt = context.get_admin_context()
+ agent_build = db.agent_build_create(ctxt,
+ {'hypervisor': hypervisor,
+ 'os': os,
+ 'architecture': architecture,
+ 'version': version,
+ 'url': url,
+ 'md5hash': md5hash})
+
+ def delete(self, os, architecture, hypervisor='xen'):
+ """Deletes an existing agent build.
+ arguments: os architecture [hypervisor='xen']"""
+ ctxt = context.get_admin_context()
+ agent_build_ref = db.agent_build_get_by_triple(ctxt,
+ hypervisor, os, architecture)
+ db.agent_build_destroy(ctxt, agent_build_ref['id'])
+
+ def list(self, hypervisor=None):
+ """Lists all agent builds.
+ arguments: <none>"""
+ fmt = "%-10s %-8s %12s %s"
+ ctxt = context.get_admin_context()
+ by_hypervisor = {}
+ for agent_build in db.agent_build_get_all(ctxt):
+ buildlist = by_hypervisor.get(agent_build.hypervisor)
+ if not buildlist:
+ buildlist = by_hypervisor[agent_build.hypervisor] = []
+
+ buildlist.append(agent_build)
+
+ for key, buildlist in by_hypervisor.iteritems():
+ if hypervisor and key != hypervisor:
+ continue
+
+ print "Hypervisor: %s" % key
+ print fmt % ('-' * 10, '-' * 8, '-' * 12, '-' * 32)
+ for agent_build in buildlist:
+ print fmt % (agent_build.os, agent_build.architecture,
+ agent_build.version, agent_build.md5hash)
+ print ' %s' % agent_build.url
+
+ print
+
+ def modify(self, os, architecture, version, url, md5hash,
+ hypervisor='xen'):
+ """Update an existing agent build.
+ arguments: os architecture version url md5hash [hypervisor='xen']
+ """
+ ctxt = context.get_admin_context()
+ agent_build_ref = db.agent_build_get_by_triple(ctxt,
+ hypervisor, os, architecture)
+ db.agent_build_update(ctxt, agent_build_ref['id'],
+ {'version': version,
+ 'url': url,
+ 'md5hash': md5hash})
+
+
+class ConfigCommands(object):
+ """Class for exposing the flags defined by flag_file(s)."""
+
+ def __init__(self):
+ pass
+
+ def list(self):
+ print FLAGS.FlagsIntoString()
+
+
CATEGORIES = [
- ('user', UserCommands),
('account', AccountCommands),
- ('project', ProjectCommands),
- ('role', RoleCommands),
- ('shell', ShellCommands),
- ('vpn', VpnCommands),
+ ('agent', AgentBuildCommands),
+ ('config', ConfigCommands),
+ ('db', DbCommands),
('fixed', FixedIpCommands),
+ ('flavor', InstanceTypeCommands),
('floating', FloatingIpCommands),
+ ('instance_type', InstanceTypeCommands),
+ ('image', ImageCommands),
('network', NetworkCommands),
- ('vm', VmCommands),
+ ('project', ProjectCommands),
+ ('role', RoleCommands),
('service', ServiceCommands),
- ('db', DbCommands),
+ ('shell', ShellCommands),
+ ('user', UserCommands),
+ ('version', VersionCommands),
+ ('vm', VmCommands),
('volume', VolumeCommands),
- ('instance_type', InstanceTypeCommands),
- ('image', ImageCommands),
- ('flavor', InstanceTypeCommands),
- ('version', VersionCommands)]
+ ('vpn', VpnCommands)]
def lazy_match(name, key_value_tuples):