merge with trunk r1601
This commit is contained in:
1
Authors
1
Authors
@@ -12,6 +12,7 @@ Armando Migliaccio <Armando.Migliaccio@eu.citrix.com>
|
|||||||
Arvind Somya <asomya@cisco.com>
|
Arvind Somya <asomya@cisco.com>
|
||||||
Bilal Akhtar <bilalakhtar@ubuntu.com>
|
Bilal Akhtar <bilalakhtar@ubuntu.com>
|
||||||
Brad Hall <brad@nicira.com>
|
Brad Hall <brad@nicira.com>
|
||||||
|
Brad McConnell <bmcconne@rackspace.com>
|
||||||
Brian Lamar <brian.lamar@rackspace.com>
|
Brian Lamar <brian.lamar@rackspace.com>
|
||||||
Brian Schott <bschott@isi.edu>
|
Brian Schott <bschott@isi.edu>
|
||||||
Brian Waldon <brian.waldon@rackspace.com>
|
Brian Waldon <brian.waldon@rackspace.com>
|
||||||
|
|||||||
@@ -61,6 +61,7 @@ import math
|
|||||||
import netaddr
|
import netaddr
|
||||||
from optparse import OptionParser
|
from optparse import OptionParser
|
||||||
import os
|
import os
|
||||||
|
import StringIO
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
|
|
||||||
@@ -274,6 +275,58 @@ class ShellCommands(object):
|
|||||||
arguments: path"""
|
arguments: path"""
|
||||||
exec(compile(open(path).read(), path, 'exec'), locals(), globals())
|
exec(compile(open(path).read(), path, 'exec'), locals(), globals())
|
||||||
|
|
||||||
|
@args('--filename', dest='filename', metavar='<path>', default=False,
|
||||||
|
help='Export file path')
|
||||||
|
def export(self, filename):
|
||||||
|
"""Export Nova users into a file that can be consumed by Keystone"""
|
||||||
|
|
||||||
|
def create_file(filename):
|
||||||
|
data = generate_data()
|
||||||
|
with open(filename, 'w') as f:
|
||||||
|
f.write(data.getvalue())
|
||||||
|
|
||||||
|
def tenants(data, am):
|
||||||
|
for project in am.get_projects():
|
||||||
|
print >> data, ("tenant add '%s'" %
|
||||||
|
(project.name))
|
||||||
|
for u in project.member_ids:
|
||||||
|
user = am.get_user(u)
|
||||||
|
print >> data, ("user add '%s' '%s' '%s'" %
|
||||||
|
(user.name, user.access, project.name))
|
||||||
|
print >> data, ("credentials add 'EC2' '%s:%s' '%s' '%s'" %
|
||||||
|
(user.access, project.id, user.secret, project.id))
|
||||||
|
|
||||||
|
def roles(data, am):
|
||||||
|
for role in am.get_roles():
|
||||||
|
print >> data, ("role add '%s'" % (role))
|
||||||
|
|
||||||
|
def grant_roles(data, am):
|
||||||
|
roles = am.get_roles()
|
||||||
|
for project in am.get_projects():
|
||||||
|
for u in project.member_ids:
|
||||||
|
user = am.get_user(u)
|
||||||
|
for role in db.user_get_roles_for_project(ctxt, u,
|
||||||
|
project.id):
|
||||||
|
print >> data, ("role grant '%s', '%s', '%s')," %
|
||||||
|
(user.name, role, project.name))
|
||||||
|
print >> data
|
||||||
|
|
||||||
|
def generate_data():
|
||||||
|
data = StringIO.StringIO()
|
||||||
|
am = manager.AuthManager()
|
||||||
|
tenants(data, am)
|
||||||
|
roles(data, am)
|
||||||
|
grant_roles(data, am)
|
||||||
|
data.seek(0)
|
||||||
|
return data
|
||||||
|
|
||||||
|
ctxt = context.get_admin_context()
|
||||||
|
if filename:
|
||||||
|
create_file(filename)
|
||||||
|
else:
|
||||||
|
data = generate_data()
|
||||||
|
print data.getvalue()
|
||||||
|
|
||||||
|
|
||||||
class RoleCommands(object):
|
class RoleCommands(object):
|
||||||
"""Class for managing roles."""
|
"""Class for managing roles."""
|
||||||
@@ -685,7 +738,7 @@ class NetworkCommands(object):
|
|||||||
help='Multi host')
|
help='Multi host')
|
||||||
@args('--dns1', dest="dns1", metavar="<DNS Address>", help='First DNS')
|
@args('--dns1', dest="dns1", metavar="<DNS Address>", help='First DNS')
|
||||||
@args('--dns2', dest="dns2", metavar="<DNS Address>", help='Second DNS')
|
@args('--dns2', dest="dns2", metavar="<DNS Address>", help='Second DNS')
|
||||||
@args('--uuid', dest="net_uuid", metavar="<network uuid>",
|
@args('--uuid', dest="uuid", metavar="<network uuid>",
|
||||||
help='Network UUID')
|
help='Network UUID')
|
||||||
@args('--project_id', dest="project_id", metavar="<project id>",
|
@args('--project_id', dest="project_id", metavar="<project id>",
|
||||||
help='Project id')
|
help='Project id')
|
||||||
@@ -710,16 +763,7 @@ class NetworkCommands(object):
|
|||||||
bridge_required = ['nova.network.manager.FlatManager',
|
bridge_required = ['nova.network.manager.FlatManager',
|
||||||
'nova.network.manager.FlatDHCPManager']
|
'nova.network.manager.FlatDHCPManager']
|
||||||
if FLAGS.network_manager in bridge_required:
|
if FLAGS.network_manager in bridge_required:
|
||||||
# TODO(tr3buchet) - swap print statement and following line for
|
raise exception.NetworkNotCreated(req='--bridge')
|
||||||
# raise statement in diablo 4
|
|
||||||
print _('--bridge parameter required or FLAG '
|
|
||||||
'flat_network_bridge must be set to create networks\n'
|
|
||||||
'WARNING! ACHTUNG! Setting the bridge to br100 '
|
|
||||||
'automatically is deprecated and will be removed in '
|
|
||||||
'Diablo milestone 4. Prepare yourself accordingly.')
|
|
||||||
time.sleep(10)
|
|
||||||
bridge = 'br100'
|
|
||||||
#raise exception.NetworkNotCreated(req='--bridge')
|
|
||||||
|
|
||||||
bridge_interface = bridge_interface or FLAGS.flat_interface or \
|
bridge_interface = bridge_interface or FLAGS.flat_interface or \
|
||||||
FLAGS.vlan_interface
|
FLAGS.vlan_interface
|
||||||
|
|||||||
@@ -1033,8 +1033,8 @@ class ComputeTestCase(test.TestCase):
|
|||||||
'get_instance_uuids_by_ip_filter',
|
'get_instance_uuids_by_ip_filter',
|
||||||
network_manager.get_instance_uuids_by_ip_filter)
|
network_manager.get_instance_uuids_by_ip_filter)
|
||||||
self.stubs.Set(network_manager.db,
|
self.stubs.Set(network_manager.db,
|
||||||
'instance_get_uuids_by_ids',
|
'instance_get_id_to_uuid_mapping',
|
||||||
db.instance_get_uuids_by_ids)
|
db.instance_get_id_to_uuid_mapping)
|
||||||
|
|
||||||
instance_id1 = self._create_instance({'display_name': 'woot',
|
instance_id1 = self._create_instance({'display_name': 'woot',
|
||||||
'id': 0})
|
'id': 0})
|
||||||
|
|||||||
@@ -18,6 +18,8 @@
|
|||||||
|
|
||||||
"""Unit tests for the DB API"""
|
"""Unit tests for the DB API"""
|
||||||
|
|
||||||
|
import datetime
|
||||||
|
|
||||||
from nova import test
|
from nova import test
|
||||||
from nova import context
|
from nova import context
|
||||||
from nova import db
|
from nova import db
|
||||||
@@ -92,6 +94,32 @@ class DbApiTestCase(test.TestCase):
|
|||||||
db.instance_destroy(self.context, inst1.id)
|
db.instance_destroy(self.context, inst1.id)
|
||||||
result = db.instance_get_all_by_filters(self.context.elevated(), {})
|
result = db.instance_get_all_by_filters(self.context.elevated(), {})
|
||||||
self.assertEqual(2, len(result))
|
self.assertEqual(2, len(result))
|
||||||
self.assertEqual(result[0].id, inst1.id)
|
self.assertIn(inst1.id, [result[0].id, result[1].id])
|
||||||
self.assertEqual(result[1].id, inst2.id)
|
self.assertIn(inst2.id, [result[0].id, result[1].id])
|
||||||
self.assertTrue(result[0].deleted)
|
if inst1.id == result[0].id:
|
||||||
|
self.assertTrue(result[0].deleted)
|
||||||
|
else:
|
||||||
|
self.assertTrue(result[1].deleted)
|
||||||
|
|
||||||
|
def test_migration_get_all_unconfirmed(self):
|
||||||
|
ctxt = context.get_admin_context()
|
||||||
|
|
||||||
|
# Ensure no migrations are returned.
|
||||||
|
results = db.migration_get_all_unconfirmed(ctxt, 10)
|
||||||
|
self.assertEqual(0, len(results))
|
||||||
|
|
||||||
|
# Ensure one migration older than 10 seconds is returned.
|
||||||
|
updated_at = datetime.datetime(2000, 01, 01, 12, 00, 00)
|
||||||
|
values = {"status": "FINISHED", "updated_at": updated_at}
|
||||||
|
migration = db.migration_create(ctxt, values)
|
||||||
|
results = db.migration_get_all_unconfirmed(ctxt, 10)
|
||||||
|
self.assertEqual(1, len(results))
|
||||||
|
db.migration_update(ctxt, migration.id, {"status": "CONFIRMED"})
|
||||||
|
|
||||||
|
# Ensure the new migration is not returned.
|
||||||
|
updated_at = datetime.datetime.utcnow()
|
||||||
|
values = {"status": "FINISHED", "updated_at": updated_at}
|
||||||
|
migration = db.migration_create(ctxt, values)
|
||||||
|
results = db.migration_get_all_unconfirmed(ctxt, 10)
|
||||||
|
self.assertEqual(0, len(results))
|
||||||
|
db.migration_update(ctxt, migration.id, {"status": "CONFIRMED"})
|
||||||
|
|||||||
@@ -176,6 +176,10 @@ class _VirtDriverTestCase(test.TestCase):
|
|||||||
def test_poll_rescued_instances(self):
|
def test_poll_rescued_instances(self):
|
||||||
self.connection.poll_rescued_instances(10)
|
self.connection.poll_rescued_instances(10)
|
||||||
|
|
||||||
|
@catch_notimplementederror
|
||||||
|
def test_poll_unconfirmed_resizes(self):
|
||||||
|
self.connection.poll_unconfirmed_resizes(10)
|
||||||
|
|
||||||
@catch_notimplementederror
|
@catch_notimplementederror
|
||||||
def test_migrate_disk_and_power_off(self):
|
def test_migrate_disk_and_power_off(self):
|
||||||
instance_ref = test_utils.get_test_instance()
|
instance_ref = test_utils.get_test_instance()
|
||||||
|
|||||||
Reference in New Issue
Block a user