From ceaa125915c4f1432ba802396a84a6204a6678df Mon Sep 17 00:00:00 2001 From: Chris Behrens Date: Thu, 5 Aug 2010 10:30:06 -0500 Subject: added bin/nova-listinstances, which is mostly just a duplication of euca-describe-instances but doesn't go through the API. --- bin/nova-listinstances | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100755 bin/nova-listinstances (limited to 'bin') diff --git a/bin/nova-listinstances b/bin/nova-listinstances new file mode 100755 index 000000000..2f8ff28f9 --- /dev/null +++ b/bin/nova-listinstances @@ -0,0 +1,19 @@ +#!/usr/bin/python + +# +# Duplicates the functionality of euca-describe-instances, but doesn't require +# going through the API. Does a direct query to the datastore. This is +# mostly a test program written for the scheduler +# + +from nova.compute import model + +data_needed = ['image_id', 'memory_kb', 'local_gb', 'node_name', 'vcpus'] + +instances = model.InstanceDirectory().all + +for instance in instances: + print 'Instance: %s' % instance['instance_id'] + for x in data_needed: + print ' %s: %s' % (x, instance[x]) + -- cgit From f42be0875d06a5d3ec0d5304d2f01a41b1f6a477 Mon Sep 17 00:00:00 2001 From: Chris Behrens Date: Thu, 5 Aug 2010 16:11:59 -0500 Subject: almost there on random scheduler. not pushing to correct compute node topic, yet, apparently... --- bin/nova-scheduler | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100755 bin/nova-scheduler (limited to 'bin') diff --git a/bin/nova-scheduler b/bin/nova-scheduler new file mode 100755 index 000000000..1ad41bbd3 --- /dev/null +++ b/bin/nova-scheduler @@ -0,0 +1,32 @@ +#!/usr/bin/env python +# vim: tabstop=4 shiftwidth=4 softtabstop=4 + +# Copyright 2010 United States Government as represented by the +# Administrator of the National Aeronautics and Space Administration. +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +""" + Twistd daemon for the nova scheduler nodes. +""" + +from nova import twistd +from nova.scheduler import service + + +if __name__ == '__main__': + twistd.serve(__file__) + +if __name__ == '__builtin__': + application = service.SchedulerService.create() -- cgit From 094d64334e419d86a550c913ea4f0b8f086777bd Mon Sep 17 00:00:00 2001 From: Chris Behrens Date: Fri, 6 Aug 2010 18:10:41 -0500 Subject: fix copyrights for new files, etc --- bin/nova-listinstances | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'bin') diff --git a/bin/nova-listinstances b/bin/nova-listinstances index 2f8ff28f9..386283d2f 100755 --- a/bin/nova-listinstances +++ b/bin/nova-listinstances @@ -1,4 +1,19 @@ -#!/usr/bin/python +#!/usr/bin/env python +# vim: tabstop=4 shiftwidth=4 softtabstop=4 + +# Copyright (c) 2010 Openstack, LLC. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. # # Duplicates the functionality of euca-describe-instances, but doesn't require @@ -6,6 +21,10 @@ # mostly a test program written for the scheduler # +""" +List instances by doing a direct query to the datastore +""" + from nova.compute import model data_needed = ['image_id', 'memory_kb', 'local_gb', 'node_name', 'vcpus'] -- cgit From 8eb531becb7e67169fddb8f7d1547589ab733dc7 Mon Sep 17 00:00:00 2001 From: Vishvananda Ishaya Date: Tue, 17 Aug 2010 20:33:37 -0700 Subject: almost there --- bin/nova-dhcpbridge | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'bin') diff --git a/bin/nova-dhcpbridge b/bin/nova-dhcpbridge index f70a4482c..593811598 100755 --- a/bin/nova-dhcpbridge +++ b/bin/nova-dhcpbridge @@ -34,7 +34,6 @@ from nova import flags from nova import rpc from nova import utils from nova.network import linux_net -from nova.network import model from nova.network import service FLAGS = flags.FLAGS @@ -43,11 +42,12 @@ FLAGS = flags.FLAGS def add_lease(_mac, ip, _hostname, _interface): """Set the IP that was assigned by the DHCP server.""" if FLAGS.fake_rabbit: + logging.debug("leasing_ip") service.VlanNetworkService().lease_ip(ip) else: rpc.cast("%s.%s" % (FLAGS.network_topic, FLAGS.node_name), {"method": "lease_ip", - "args": {"fixed_ip": ip}}) + "args": {"fixed_ip_str": ip}}) def old_lease(_mac, _ip, _hostname, _interface): @@ -58,20 +58,18 @@ def old_lease(_mac, _ip, _hostname, _interface): def del_lease(_mac, ip, _hostname, _interface): """Called when a lease expires.""" if FLAGS.fake_rabbit: + logging.debug("releasing_ip") service.VlanNetworkService().release_ip(ip) else: rpc.cast("%s.%s" % (FLAGS.network_topic, FLAGS.node_name), {"method": "release_ip", - "args": {"fixed_ip": ip}}) + "args": {"fixed_ip_str": ip}}) def init_leases(interface): """Get the list of hosts for an interface.""" - net = model.get_network_by_interface(interface) - res = "" - for address in net.assigned_objs: - res += "%s\n" % linux_net.host_dhcp(address) - return res + network = service.get_network_by_interface(interface) + return linux_net.get_dhcp_hosts(network) def main(): @@ -80,6 +78,9 @@ def main(): utils.default_flagfile(flagfile) argv = FLAGS(sys.argv) interface = os.environ.get('DNSMASQ_INTERFACE', 'br0') + LOG_FILENAME = 'example.log' + logging.basicConfig(filename=LOG_FILENAME,level=logging.DEBUG) + logging.debug("this is a test") if int(os.environ.get('TESTING', '0')): FLAGS.fake_rabbit = True FLAGS.redis_db = 8 -- cgit From 62e3bab39fcd9628325c3a16d4b76b5e82e35099 Mon Sep 17 00:00:00 2001 From: Vishvananda Ishaya Date: Wed, 18 Aug 2010 02:07:04 -0700 Subject: network tests pass --- bin/nova-dhcpbridge | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'bin') diff --git a/bin/nova-dhcpbridge b/bin/nova-dhcpbridge index 593811598..266fd70ce 100755 --- a/bin/nova-dhcpbridge +++ b/bin/nova-dhcpbridge @@ -81,13 +81,17 @@ def main(): LOG_FILENAME = 'example.log' logging.basicConfig(filename=LOG_FILENAME,level=logging.DEBUG) logging.debug("this is a test") + sqlfile = os.environ.get('SQL_DB', '') if int(os.environ.get('TESTING', '0')): + logging.debug("fake rabbit is true") FLAGS.fake_rabbit = True FLAGS.redis_db = 8 - FLAGS.network_size = 32 + FLAGS.network_size = 16 FLAGS.connection_type = 'fake' FLAGS.fake_network = True FLAGS.auth_driver = 'nova.auth.ldapdriver.FakeLdapDriver' + FLAGS.num_networks = 5 + FLAGS.sql_connection = 'sqlite:///%s' % sqlfile action = argv[1] if action in ['add', 'del', 'old']: mac = argv[2] -- cgit From f7c556324d52095323ec18296c4064e5bb626c96 Mon Sep 17 00:00:00 2001 From: Vishvananda Ishaya Date: Wed, 18 Aug 2010 17:38:51 -0700 Subject: fixing more network issues --- bin/nova-dhcpbridge | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'bin') diff --git a/bin/nova-dhcpbridge b/bin/nova-dhcpbridge index 266fd70ce..bd8fd9785 100755 --- a/bin/nova-dhcpbridge +++ b/bin/nova-dhcpbridge @@ -35,6 +35,7 @@ from nova import rpc from nova import utils from nova.network import linux_net from nova.network import service +from nova import datastore # for redis_db flag FLAGS = flags.FLAGS @@ -43,6 +44,8 @@ def add_lease(_mac, ip, _hostname, _interface): """Set the IP that was assigned by the DHCP server.""" if FLAGS.fake_rabbit: logging.debug("leasing_ip") + print FLAGS.redis_db + print FLAGS.sql_connection service.VlanNetworkService().lease_ip(ip) else: rpc.cast("%s.%s" % (FLAGS.network_topic, FLAGS.node_name), @@ -78,12 +81,8 @@ def main(): utils.default_flagfile(flagfile) argv = FLAGS(sys.argv) interface = os.environ.get('DNSMASQ_INTERFACE', 'br0') - LOG_FILENAME = 'example.log' - logging.basicConfig(filename=LOG_FILENAME,level=logging.DEBUG) - logging.debug("this is a test") sqlfile = os.environ.get('SQL_DB', '') if int(os.environ.get('TESTING', '0')): - logging.debug("fake rabbit is true") FLAGS.fake_rabbit = True FLAGS.redis_db = 8 FLAGS.network_size = 16 @@ -91,7 +90,8 @@ def main(): FLAGS.fake_network = True FLAGS.auth_driver = 'nova.auth.ldapdriver.FakeLdapDriver' FLAGS.num_networks = 5 - FLAGS.sql_connection = 'sqlite:///%s' % sqlfile + FLAGS.sql_connection = 'mysql://root@localhost/test' + #FLAGS.sql_connection = 'sqlite:///%s' % sqlfile action = argv[1] if action in ['add', 'del', 'old']: mac = argv[2] -- cgit From b8747fb38eb1234744cdda85cb20bd27cd7fa9e8 Mon Sep 17 00:00:00 2001 From: Eric Day Date: Wed, 18 Aug 2010 17:39:12 -0700 Subject: More bin/ pep8/pylint cleanup. --- bin/nova-compute | 2 +- bin/nova-dhcpbridge | 14 +++++++------- bin/nova-import-canonical-imagestore | 4 ++-- bin/nova-instancemonitor | 5 +++-- bin/nova-manage | 6 +++--- bin/nova-network | 1 + bin/nova-objectstore | 2 +- bin/nova-volume | 2 +- 8 files changed, 19 insertions(+), 17 deletions(-) (limited to 'bin') diff --git a/bin/nova-compute b/bin/nova-compute index e0c12354f..ed9a55565 100755 --- a/bin/nova-compute +++ b/bin/nova-compute @@ -29,4 +29,4 @@ if __name__ == '__main__': twistd.serve(__file__) if __name__ == '__builtin__': - application = service.ComputeService.create() + application = service.ComputeService.create() # pylint: disable-msg=C0103 diff --git a/bin/nova-dhcpbridge b/bin/nova-dhcpbridge index f70a4482c..1f2ed4f89 100755 --- a/bin/nova-dhcpbridge +++ b/bin/nova-dhcpbridge @@ -40,29 +40,29 @@ from nova.network import service FLAGS = flags.FLAGS -def add_lease(_mac, ip, _hostname, _interface): +def add_lease(_mac, ip_address, _hostname, _interface): """Set the IP that was assigned by the DHCP server.""" if FLAGS.fake_rabbit: - service.VlanNetworkService().lease_ip(ip) + service.VlanNetworkService().lease_ip(ip_address) else: rpc.cast("%s.%s" % (FLAGS.network_topic, FLAGS.node_name), {"method": "lease_ip", - "args": {"fixed_ip": ip}}) + "args": {"fixed_ip": ip_address}}) -def old_lease(_mac, _ip, _hostname, _interface): +def old_lease(_mac, _ip_address, _hostname, _interface): """Do nothing, just an old lease update.""" logging.debug("Adopted old lease or got a change of mac/hostname") -def del_lease(_mac, ip, _hostname, _interface): +def del_lease(_mac, ip_address, _hostname, _interface): """Called when a lease expires.""" if FLAGS.fake_rabbit: - service.VlanNetworkService().release_ip(ip) + service.VlanNetworkService().release_ip(ip_address) else: rpc.cast("%s.%s" % (FLAGS.network_topic, FLAGS.node_name), {"method": "release_ip", - "args": {"fixed_ip": ip}}) + "args": {"fixed_ip": ip_address}}) def init_leases(interface): diff --git a/bin/nova-import-canonical-imagestore b/bin/nova-import-canonical-imagestore index 5165109b2..e6931d9db 100755 --- a/bin/nova-import-canonical-imagestore +++ b/bin/nova-import-canonical-imagestore @@ -35,12 +35,12 @@ from nova.objectstore import image FLAGS = flags.FLAGS -api_url = 'https://imagestore.canonical.com/api/dashboard' +API_URL = 'https://imagestore.canonical.com/api/dashboard' def get_images(): """Get a list of the images from the imagestore URL.""" - images = json.load(urllib2.urlopen(api_url))['images'] + images = json.load(urllib2.urlopen(API_URL))['images'] images = [img for img in images if img['title'].find('amd64') > -1] return images diff --git a/bin/nova-instancemonitor b/bin/nova-instancemonitor index 911fb6f42..fbac58889 100755 --- a/bin/nova-instancemonitor +++ b/bin/nova-instancemonitor @@ -35,9 +35,10 @@ if __name__ == '__main__': if __name__ == '__builtin__': logging.warn('Starting instance monitor') - m = monitor.InstanceMonitor() + # pylint: disable-msg=C0103 + monitor = monitor.InstanceMonitor() # This is the parent service that twistd will be looking for when it # parses this file, return it so that we can get it into globals below application = service.Application('nova-instancemonitor') - m.setServiceParent(application) + monitor.setServiceParent(application) diff --git a/bin/nova-manage b/bin/nova-manage index 071436b13..33141a49e 100755 --- a/bin/nova-manage +++ b/bin/nova-manage @@ -211,7 +211,7 @@ class ProjectCommands(object): f.write(zip_file) -categories = [ +CATEGORIES = [ ('user', UserCommands), ('project', ProjectCommands), ('role', RoleCommands), @@ -258,11 +258,11 @@ def main(): if len(argv) < 1: print script_name + " category action []" print "Available categories:" - for k, _ in categories: + for k, _ in CATEGORIES: print "\t%s" % k sys.exit(2) category = argv.pop(0) - matches = lazy_match(category, categories) + matches = lazy_match(category, CATEGORIES) # instantiate the command group object category, fn = matches[0] command_object = fn() diff --git a/bin/nova-network b/bin/nova-network index ba9063f56..5753aafbe 100755 --- a/bin/nova-network +++ b/bin/nova-network @@ -33,4 +33,5 @@ if __name__ == '__main__': twistd.serve(__file__) if __name__ == '__builtin__': + # pylint: disable-msg=C0103 application = service.type_to_class(FLAGS.network_type).create() diff --git a/bin/nova-objectstore b/bin/nova-objectstore index 02f2bcb48..afcf13e24 100755 --- a/bin/nova-objectstore +++ b/bin/nova-objectstore @@ -35,4 +35,4 @@ if __name__ == '__main__': if __name__ == '__builtin__': utils.default_flagfile() - application = handler.get_application() + application = handler.get_application() # pylint: disable-msg=C0103 diff --git a/bin/nova-volume b/bin/nova-volume index f7a8fad37..8ef006ebc 100755 --- a/bin/nova-volume +++ b/bin/nova-volume @@ -29,4 +29,4 @@ if __name__ == '__main__': twistd.serve(__file__) if __name__ == '__builtin__': - application = service.VolumeService.create() + application = service.VolumeService.create() # pylint: disable-msg=C0103 -- cgit From 9ab034f8b0cb0946e1fdf44937cce58b53e7530b Mon Sep 17 00:00:00 2001 From: Vishvananda Ishaya Date: Wed, 18 Aug 2010 18:03:58 -0700 Subject: last few test fixes --- bin/nova-dhcpbridge | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'bin') diff --git a/bin/nova-dhcpbridge b/bin/nova-dhcpbridge index bd8fd9785..b17a56e6e 100755 --- a/bin/nova-dhcpbridge +++ b/bin/nova-dhcpbridge @@ -44,7 +44,9 @@ def add_lease(_mac, ip, _hostname, _interface): """Set the IP that was assigned by the DHCP server.""" if FLAGS.fake_rabbit: logging.debug("leasing_ip") - print FLAGS.redis_db + from nova import models + print models.FixedIp.count() + print models.Network.count() print FLAGS.sql_connection service.VlanNetworkService().lease_ip(ip) else: @@ -81,7 +83,6 @@ def main(): utils.default_flagfile(flagfile) argv = FLAGS(sys.argv) interface = os.environ.get('DNSMASQ_INTERFACE', 'br0') - sqlfile = os.environ.get('SQL_DB', '') if int(os.environ.get('TESTING', '0')): FLAGS.fake_rabbit = True FLAGS.redis_db = 8 @@ -90,8 +91,13 @@ def main(): FLAGS.fake_network = True FLAGS.auth_driver = 'nova.auth.ldapdriver.FakeLdapDriver' FLAGS.num_networks = 5 - FLAGS.sql_connection = 'mysql://root@localhost/test' - #FLAGS.sql_connection = 'sqlite:///%s' % sqlfile + path = os.path.abspath(os.path.join(os.path.dirname(__file__), + '..', + '_trial_temp', + 'nova.sqlite')) + print path + FLAGS.sql_connection = 'sqlite:///%s' % path + #FLAGS.sql_connection = 'mysql://root@localhost/test' action = argv[1] if action in ['add', 'del', 'old']: mac = argv[2] -- cgit From 47e98cdae2a6233cb475c34207758a29c0ef7a4c Mon Sep 17 00:00:00 2001 From: Eric Day Date: Wed, 18 Aug 2010 18:25:16 -0700 Subject: Removed old cloud_topic queue setup, it is no longer used. --- bin/nova-api | 8 -------- 1 file changed, 8 deletions(-) (limited to 'bin') diff --git a/bin/nova-api b/bin/nova-api index 13baf22a7..a3ad5a0e1 100755 --- a/bin/nova-api +++ b/bin/nova-api @@ -26,7 +26,6 @@ from tornado import httpserver from tornado import ioloop from nova import flags -from nova import rpc from nova import server from nova import utils from nova.endpoint import admin @@ -43,14 +42,7 @@ def main(_argv): 'Admin': admin.AdminController()} _app = api.APIServerApplication(controllers) - conn = rpc.Connection.instance() - consumer = rpc.AdapterConsumer(connection=conn, - topic=FLAGS.cloud_topic, - proxy=controllers['Cloud']) - io_inst = ioloop.IOLoop.instance() - _injected = consumer.attach_to_tornado(io_inst) - http_server = httpserver.HTTPServer(_app) http_server.listen(FLAGS.cc_port) logging.debug('Started HTTP server on %s', FLAGS.cc_port) -- cgit From 78c2175898a468ae734e27dfbc8f5b70f90fd477 Mon Sep 17 00:00:00 2001 From: Vishvananda Ishaya Date: Mon, 23 Aug 2010 13:55:16 -0700 Subject: Refactored network model access into data abstraction layer. Also changed the name to floating_ip. --- bin/nova-dhcpbridge | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'bin') diff --git a/bin/nova-dhcpbridge b/bin/nova-dhcpbridge index b17a56e6e..8008100f6 100755 --- a/bin/nova-dhcpbridge +++ b/bin/nova-dhcpbridge @@ -25,9 +25,9 @@ import logging import os import sys -#TODO(joshua): there is concern that the user dnsmasq runs under will not -# have nova in the path. This should be verified and if it is -# not true the ugly line below can be removed +# TODO(joshua): there is concern that the user dnsmasq runs under will not +# have nova in the path. This should be verified and if it is +# not true the ugly line below can be removed sys.path.append(os.path.abspath(os.path.join(__file__, "../../"))) from nova import flags @@ -36,6 +36,7 @@ from nova import utils from nova.network import linux_net from nova.network import service from nova import datastore # for redis_db flag +from nova.auth import manager # for auth flags FLAGS = flags.FLAGS @@ -43,16 +44,16 @@ FLAGS = flags.FLAGS def add_lease(_mac, ip, _hostname, _interface): """Set the IP that was assigned by the DHCP server.""" if FLAGS.fake_rabbit: - logging.debug("leasing_ip") + logging.debug("leasing ip") from nova import models print models.FixedIp.count() print models.Network.count() print FLAGS.sql_connection - service.VlanNetworkService().lease_ip(ip) + service.VlanNetworkService().lease_fixed_ip(ip) else: rpc.cast("%s.%s" % (FLAGS.network_topic, FLAGS.node_name), - {"method": "lease_ip", - "args": {"fixed_ip_str": ip}}) + {"method": "lease_fixed_ip", + "args": {"address": ip}}) def old_lease(_mac, _ip, _hostname, _interface): @@ -63,12 +64,12 @@ def old_lease(_mac, _ip, _hostname, _interface): def del_lease(_mac, ip, _hostname, _interface): """Called when a lease expires.""" if FLAGS.fake_rabbit: - logging.debug("releasing_ip") - service.VlanNetworkService().release_ip(ip) + logging.debug("releasing ip") + service.VlanNetworkService().release_fixed_ip(ip) else: rpc.cast("%s.%s" % (FLAGS.network_topic, FLAGS.node_name), - {"method": "release_ip", - "args": {"fixed_ip_str": ip}}) + {"method": "release_fixed_ip", + "args": {"address": ip}}) def init_leases(interface): -- cgit From d832003f1743ab0e1c4ef935f3e4f1d02691bc39 Mon Sep 17 00:00:00 2001 From: Vishvananda Ishaya Date: Tue, 24 Aug 2010 01:30:48 -0700 Subject: typo in release_ip --- bin/nova-dhcpbridge | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bin') diff --git a/bin/nova-dhcpbridge b/bin/nova-dhcpbridge index cd0917390..018293e24 100755 --- a/bin/nova-dhcpbridge +++ b/bin/nova-dhcpbridge @@ -70,7 +70,7 @@ def del_lease(_mac, ip_address, _hostname, _interface): else: rpc.cast("%s.%s" % (FLAGS.network_topic, FLAGS.node_name), {"method": "release_fixed_ip", - "args": {"fixed_ip": ip_address}}) + "args": {"address": ip_address}}) def init_leases(interface): -- cgit From a6784ba13821dccfb852cff3ca16f7db30bb3c05 Mon Sep 17 00:00:00 2001 From: Vishvananda Ishaya Date: Wed, 25 Aug 2010 16:44:10 -0700 Subject: network tests pass again --- bin/nova-dhcpbridge | 4 ---- 1 file changed, 4 deletions(-) (limited to 'bin') diff --git a/bin/nova-dhcpbridge b/bin/nova-dhcpbridge index 018293e24..6747a3a0e 100755 --- a/bin/nova-dhcpbridge +++ b/bin/nova-dhcpbridge @@ -46,10 +46,6 @@ def add_lease(_mac, ip_address, _hostname, _interface): """Set the IP that was assigned by the DHCP server.""" if FLAGS.fake_rabbit: logging.debug("leasing ip") - from nova import models - print models.FixedIp.count() - print models.Network.count() - print FLAGS.sql_connection service.VlanNetworkService().lease_fixed_ip(ip_address) else: rpc.cast("%s.%s" % (FLAGS.network_topic, FLAGS.node_name), -- cgit From fab0bbaca8d6cf34f131c4426463bf5c76a0477f Mon Sep 17 00:00:00 2001 From: Vishvananda Ishaya Date: Sun, 29 Aug 2010 18:53:47 -0700 Subject: tests pass --- bin/nova-dhcpbridge | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'bin') diff --git a/bin/nova-dhcpbridge b/bin/nova-dhcpbridge index 6747a3a0e..52ec2d497 100755 --- a/bin/nova-dhcpbridge +++ b/bin/nova-dhcpbridge @@ -34,23 +34,23 @@ from nova import db from nova import flags from nova import rpc from nova import utils -from nova.network import linux_net -from nova.network import service from nova import datastore # for redis_db flag from nova.auth import manager # for auth flags +from nova.network import manager # for network flags FLAGS = flags.FLAGS - def add_lease(_mac, ip_address, _hostname, _interface): """Set the IP that was assigned by the DHCP server.""" if FLAGS.fake_rabbit: logging.debug("leasing ip") - service.VlanNetworkService().lease_fixed_ip(ip_address) + network_manager = utils.import_object(FLAGS.network_manager) + network_manager.lease_fixed_ip(None, ip_address) else: rpc.cast("%s.%s" % (FLAGS.network_topic, FLAGS.node_name), {"method": "lease_fixed_ip", - "args": {"address": ip_address}}) + "args": {"context": None, + "address": ip_address}}) def old_lease(_mac, _ip_address, _hostname, _interface): @@ -62,20 +62,24 @@ def del_lease(_mac, ip_address, _hostname, _interface): """Called when a lease expires.""" if FLAGS.fake_rabbit: logging.debug("releasing ip") - service.VlanNetworkService().release_fixed_ip(ip_address) + network_manager = utils.import_object(FLAGS.network_manager) + network_manager.release_fixed_ip(None, ip_address) else: rpc.cast("%s.%s" % (FLAGS.network_topic, FLAGS.node_name), {"method": "release_fixed_ip", - "args": {"address": ip_address}}) + "args": {"context": None, + "address": ip_address}}) def init_leases(interface): """Get the list of hosts for an interface.""" network_ref = db.network_get_by_bridge(None, interface) - return linux_net.get_dhcp_hosts(None, network_ref['id']) + network_manager = utils.import_object(FLAGS.network_manager) + return network_manager.driver.get_dhcp_hosts(None, network_ref['id']) def main(): + global network_manager """Parse environment and arguments and call the approproate action.""" flagfile = os.environ.get('FLAGFILE', FLAGS.dhcpbridge_flagfile) utils.default_flagfile(flagfile) @@ -93,7 +97,6 @@ def main(): '..', '_trial_temp', 'nova.sqlite')) - print path FLAGS.sql_connection = 'sqlite:///%s' % path #FLAGS.sql_connection = 'mysql://root@localhost/test' action = argv[1] -- cgit From 9c98cfb47175ca9ace5c0bd731085896303e3e7b Mon Sep 17 00:00:00 2001 From: Vishvananda Ishaya Date: Mon, 30 Aug 2010 00:55:19 -0700 Subject: instance runs --- bin/nova-compute | 2 +- bin/nova-network | 3 +-- bin/nova-volume | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) (limited to 'bin') diff --git a/bin/nova-compute b/bin/nova-compute index ed9a55565..cf9de9bbf 100755 --- a/bin/nova-compute +++ b/bin/nova-compute @@ -29,4 +29,4 @@ if __name__ == '__main__': twistd.serve(__file__) if __name__ == '__builtin__': - application = service.ComputeService.create() # pylint: disable-msg=C0103 + application = service.ComputeService.create() # pylint: disable=C0103 diff --git a/bin/nova-network b/bin/nova-network index 5753aafbe..6434b6ec3 100755 --- a/bin/nova-network +++ b/bin/nova-network @@ -33,5 +33,4 @@ if __name__ == '__main__': twistd.serve(__file__) if __name__ == '__builtin__': - # pylint: disable-msg=C0103 - application = service.type_to_class(FLAGS.network_type).create() + application = service.NetworkService.create() # pylint: disable-msg=C0103 diff --git a/bin/nova-volume b/bin/nova-volume index 8ef006ebc..25b5871a3 100755 --- a/bin/nova-volume +++ b/bin/nova-volume @@ -29,4 +29,4 @@ if __name__ == '__main__': twistd.serve(__file__) if __name__ == '__builtin__': - application = service.VolumeService.create() # pylint: disable-msg=C0103 + application = service.VolumeService.create() # pylint: disable-msg=C0103 -- cgit From 40899259205561b43791f1540ec3f9100a4869d1 Mon Sep 17 00:00:00 2001 From: Vishvananda Ishaya Date: Mon, 30 Aug 2010 09:03:43 -0700 Subject: ip addresses work now --- bin/nova-dhcpbridge | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'bin') diff --git a/bin/nova-dhcpbridge b/bin/nova-dhcpbridge index 52ec2d497..a794db271 100755 --- a/bin/nova-dhcpbridge +++ b/bin/nova-dhcpbridge @@ -36,6 +36,7 @@ from nova import rpc from nova import utils from nova import datastore # for redis_db flag from nova.auth import manager # for auth flags +from nova.network import linux_net from nova.network import manager # for network flags FLAGS = flags.FLAGS @@ -74,8 +75,7 @@ def del_lease(_mac, ip_address, _hostname, _interface): def init_leases(interface): """Get the list of hosts for an interface.""" network_ref = db.network_get_by_bridge(None, interface) - network_manager = utils.import_object(FLAGS.network_manager) - return network_manager.driver.get_dhcp_hosts(None, network_ref['id']) + return linux_net.get_dhcp_hosts(None, network_ref['id']) def main(): -- cgit From b4c5c97160a6b71d37b7655c6b4039baf4ff0969 Mon Sep 17 00:00:00 2001 From: Vishvananda Ishaya Date: Mon, 30 Aug 2010 17:58:02 -0700 Subject: more pep8 --- bin/nova-dhcpbridge | 7 ++++--- bin/nova-manage | 4 ++-- bin/nova-objectstore | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) (limited to 'bin') diff --git a/bin/nova-dhcpbridge b/bin/nova-dhcpbridge index a794db271..c416d07a7 100755 --- a/bin/nova-dhcpbridge +++ b/bin/nova-dhcpbridge @@ -34,13 +34,14 @@ from nova import db from nova import flags from nova import rpc from nova import utils -from nova import datastore # for redis_db flag -from nova.auth import manager # for auth flags +from nova import datastore # for redis_db flag +from nova.auth import manager # for auth flags from nova.network import linux_net -from nova.network import manager # for network flags +from nova.network import manager # for network flags FLAGS = flags.FLAGS + def add_lease(_mac, ip_address, _hostname, _interface): """Set the IP that was assigned by the DHCP server.""" if FLAGS.fake_rabbit: diff --git a/bin/nova-manage b/bin/nova-manage index 145294d3d..7f20531dc 100755 --- a/bin/nova-manage +++ b/bin/nova-manage @@ -56,8 +56,8 @@ class VpnCommands(object): vpn = self._vpn_for(project.id) if vpn: command = "ping -c1 -w1 %s > /dev/null; echo $?" - out, _err = utils.execute( command % vpn['private_dns_name'], - check_exit_code=False) + out, _err = utils.execute(command % vpn['private_dns_name'], + check_exit_code=False) if out.strip() == '0': net = 'up' else: diff --git a/bin/nova-objectstore b/bin/nova-objectstore index afcf13e24..7cb718b6f 100755 --- a/bin/nova-objectstore +++ b/bin/nova-objectstore @@ -35,4 +35,4 @@ if __name__ == '__main__': if __name__ == '__builtin__': utils.default_flagfile() - application = handler.get_application() # pylint: disable-msg=C0103 + application = handler.get_application() # pylint: disable-msg=C0103 -- cgit From 116402306e0d7703645e786b7cf0833a113b8d13 Mon Sep 17 00:00:00 2001 From: Vishvananda Ishaya Date: Thu, 2 Sep 2010 11:25:10 -0700 Subject: updated models a bit and removed service classes --- bin/nova-compute | 4 ++-- bin/nova-network | 8 ++------ bin/nova-volume | 4 ++-- 3 files changed, 6 insertions(+), 10 deletions(-) (limited to 'bin') diff --git a/bin/nova-compute b/bin/nova-compute index cf9de9bbf..cc4c9e2ff 100755 --- a/bin/nova-compute +++ b/bin/nova-compute @@ -21,12 +21,12 @@ Twistd daemon for the nova compute nodes. """ +from nova import service from nova import twistd -from nova.compute import service if __name__ == '__main__': twistd.serve(__file__) if __name__ == '__builtin__': - application = service.ComputeService.create() # pylint: disable=C0103 + application = service.Service.create() # pylint: disable=C0103 diff --git a/bin/nova-network b/bin/nova-network index 6434b6ec3..040b35e04 100755 --- a/bin/nova-network +++ b/bin/nova-network @@ -21,16 +21,12 @@ Twistd daemon for the nova network nodes. """ -from nova import flags +from nova import service from nova import twistd -from nova.network import service - -FLAGS = flags.FLAGS - if __name__ == '__main__': twistd.serve(__file__) if __name__ == '__builtin__': - application = service.NetworkService.create() # pylint: disable-msg=C0103 + application = service.Service.create() # pylint: disable-msg=C0103 diff --git a/bin/nova-volume b/bin/nova-volume index 25b5871a3..fac4b5d01 100755 --- a/bin/nova-volume +++ b/bin/nova-volume @@ -21,12 +21,12 @@ Twistd daemon for the nova volume nodes. """ +from nova import service from nova import twistd -from nova.volume import service if __name__ == '__main__': twistd.serve(__file__) if __name__ == '__builtin__': - application = service.VolumeService.create() # pylint: disable-msg=C0103 + application = service.Service.create() # pylint: disable-msg=C0103 -- cgit From 7edff9298f7f01e158f90c93432384903d71e033 Mon Sep 17 00:00:00 2001 From: Vishvananda Ishaya Date: Thu, 2 Sep 2010 11:32:37 -0700 Subject: scheduler + unittests --- bin/nova-scheduler | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'bin') diff --git a/bin/nova-scheduler b/bin/nova-scheduler index 1ad41bbd3..97f98b17f 100755 --- a/bin/nova-scheduler +++ b/bin/nova-scheduler @@ -21,12 +21,12 @@ Twistd daemon for the nova scheduler nodes. """ +from nova import service from nova import twistd -from nova.scheduler import service if __name__ == '__main__': twistd.serve(__file__) if __name__ == '__builtin__': - application = service.SchedulerService.create() + application = service.Service.create() -- cgit From 66ed706a2f7ee8a6b4703de988b4d7ef0826fc2a Mon Sep 17 00:00:00 2001 From: Vishvananda Ishaya Date: Thu, 2 Sep 2010 23:13:12 -0700 Subject: removed model from nova-manage --- bin/nova-manage | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'bin') diff --git a/bin/nova-manage b/bin/nova-manage index 7f20531dc..055f2c3a9 100755 --- a/bin/nova-manage +++ b/bin/nova-manage @@ -25,10 +25,10 @@ import sys import time +from nova import db from nova import flags from nova import utils from nova.auth import manager -from nova.compute import model from nova.cloudpipe import pipelib from nova.endpoint import cloud @@ -41,7 +41,6 @@ class VpnCommands(object): def __init__(self): self.manager = manager.AuthManager() - self.instdir = model.InstanceDirectory() self.pipe = pipelib.CloudPipe(cloud.CloudController()) def list(self): @@ -73,9 +72,8 @@ class VpnCommands(object): def _vpn_for(self, project_id): """Get the VPN instance for a project ID.""" - for instance in self.instdir.all: - if ('image_id' in instance.state - and instance['image_id'] == FLAGS.vpn_image_id + for instance in db.instance_get_all(): + if (instance['image_id'] == FLAGS.vpn_image_id and not instance['state_description'] in ['shutting_down', 'shutdown'] and instance['project_id'] == project_id): -- cgit From 22aa51638dc221e78de60f7e2ddb10eb0ddf4db3 Mon Sep 17 00:00:00 2001 From: Vishvananda Ishaya Date: Fri, 3 Sep 2010 00:53:41 -0700 Subject: removed extra file and updated sql note --- bin/nova-listinstances | 38 -------------------------------------- 1 file changed, 38 deletions(-) delete mode 100755 bin/nova-listinstances (limited to 'bin') diff --git a/bin/nova-listinstances b/bin/nova-listinstances deleted file mode 100755 index 386283d2f..000000000 --- a/bin/nova-listinstances +++ /dev/null @@ -1,38 +0,0 @@ -#!/usr/bin/env python -# vim: tabstop=4 shiftwidth=4 softtabstop=4 - -# Copyright (c) 2010 Openstack, LLC. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -# -# Duplicates the functionality of euca-describe-instances, but doesn't require -# going through the API. Does a direct query to the datastore. This is -# mostly a test program written for the scheduler -# - -""" -List instances by doing a direct query to the datastore -""" - -from nova.compute import model - -data_needed = ['image_id', 'memory_kb', 'local_gb', 'node_name', 'vcpus'] - -instances = model.InstanceDirectory().all - -for instance in instances: - print 'Instance: %s' % instance['instance_id'] - for x in data_needed: - print ' %s: %s' % (x, instance[x]) - -- cgit From 96682df90fbeb3b533aa0c351176e3ef412f5446 Mon Sep 17 00:00:00 2001 From: Vishvananda Ishaya Date: Tue, 7 Sep 2010 19:48:38 -0700 Subject: dhcpbridge fixes from review --- bin/nova-dhcpbridge | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'bin') diff --git a/bin/nova-dhcpbridge b/bin/nova-dhcpbridge index c416d07a7..980da1ce0 100755 --- a/bin/nova-dhcpbridge +++ b/bin/nova-dhcpbridge @@ -34,12 +34,13 @@ from nova import db from nova import flags from nova import rpc from nova import utils -from nova import datastore # for redis_db flag -from nova.auth import manager # for auth flags from nova.network import linux_net -from nova.network import manager # for network flags FLAGS = flags.FLAGS +flags.DECLARE('auth_driver', 'nova.auth.manager') +flags.DECLARE('redis_db', 'nova.datastore') +flags.DECLARE('network_size', 'nova.network.manager') +flags.DECLARE('num_networks', 'nova.network.manager') def add_lease(_mac, ip_address, _hostname, _interface): @@ -80,7 +81,6 @@ def init_leases(interface): def main(): - global network_manager """Parse environment and arguments and call the approproate action.""" flagfile = os.environ.get('FLAGFILE', FLAGS.dhcpbridge_flagfile) utils.default_flagfile(flagfile) @@ -99,7 +99,6 @@ def main(): '_trial_temp', 'nova.sqlite')) FLAGS.sql_connection = 'sqlite:///%s' % path - #FLAGS.sql_connection = 'mysql://root@localhost/test' action = argv[1] if action in ['add', 'del', 'old']: mac = argv[2] -- cgit From f2a3f9a622613ec1575e70ac9fe9655b485d9a6d Mon Sep 17 00:00:00 2001 From: Soren Hansen Date: Wed, 8 Sep 2010 10:45:39 +0200 Subject: Make the scripts in bin/ detect if they're being run from a bzr checkout or an extracted release tarball or whatever and adjust PYTHONPATH accordingly. --- bin/nova-api | 10 ++++++++++ bin/nova-api-new | 11 +++++++++++ bin/nova-compute | 11 +++++++++++ bin/nova-dhcpbridge | 11 +++++++---- bin/nova-import-canonical-imagestore | 8 ++++++++ bin/nova-instancemonitor | 10 ++++++++++ bin/nova-manage | 9 +++++++++ bin/nova-network | 11 +++++++++++ bin/nova-objectstore | 11 +++++++++++ bin/nova-volume | 11 +++++++++++ 10 files changed, 99 insertions(+), 4 deletions(-) (limited to 'bin') diff --git a/bin/nova-api b/bin/nova-api index a3ad5a0e1..ede09d38c 100755 --- a/bin/nova-api +++ b/bin/nova-api @@ -22,9 +22,19 @@ Tornado daemon for the main API endpoint. """ import logging +import os +import sys from tornado import httpserver from tornado import ioloop +# 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... +possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]), + os.pardir, + os.pardir)) +if os.path.exists(os.path.join(possible_topdir, 'nova', '__init__.py')): + sys.path.insert(0, possible_topdir) + from nova import flags from nova import server from nova import utils diff --git a/bin/nova-api-new b/bin/nova-api-new index fda42339c..8625c487f 100755 --- a/bin/nova-api-new +++ b/bin/nova-api-new @@ -21,6 +21,17 @@ Nova API daemon. """ +import os +import sys + +# 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... +possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]), + os.pardir, + os.pardir)) +if os.path.exists(os.path.join(possible_topdir, 'nova', '__init__.py')): + sys.path.insert(0, possible_topdir) + from nova import api from nova import flags from nova import utils diff --git a/bin/nova-compute b/bin/nova-compute index ed9a55565..631d2c85c 100755 --- a/bin/nova-compute +++ b/bin/nova-compute @@ -21,6 +21,17 @@ Twistd daemon for the nova compute nodes. """ +import os +import sys + +# 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... +possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]), + os.pardir, + os.pardir)) +if os.path.exists(os.path.join(possible_topdir, 'nova', '__init__.py')): + sys.path.insert(0, possible_topdir) + from nova import twistd from nova.compute import service diff --git a/bin/nova-dhcpbridge b/bin/nova-dhcpbridge index 1f2ed4f89..0c3d987a7 100755 --- a/bin/nova-dhcpbridge +++ b/bin/nova-dhcpbridge @@ -25,10 +25,13 @@ import logging import os import sys -#TODO(joshua): there is concern that the user dnsmasq runs under will not -# have nova in the path. This should be verified and if it is -# not true the ugly line below can be removed -sys.path.append(os.path.abspath(os.path.join(__file__, "../../"))) +# 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... +possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]), + os.pardir, + os.pardir)) +if os.path.exists(os.path.join(possible_topdir, 'nova', '__init__.py')): + sys.path.insert(0, possible_topdir) from nova import flags from nova import rpc diff --git a/bin/nova-import-canonical-imagestore b/bin/nova-import-canonical-imagestore index 2bc61cf0c..4ed9e8365 100755 --- a/bin/nova-import-canonical-imagestore +++ b/bin/nova-import-canonical-imagestore @@ -29,6 +29,14 @@ import subprocess import sys import urllib2 +# 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... +possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]), + os.pardir, + os.pardir)) +if os.path.exists(os.path.join(possible_topdir, 'nova', '__init__.py')): + sys.path.insert(0, possible_topdir) + from nova import flags from nova import utils from nova.objectstore import image diff --git a/bin/nova-instancemonitor b/bin/nova-instancemonitor index fbac58889..094da4033 100755 --- a/bin/nova-instancemonitor +++ b/bin/nova-instancemonitor @@ -21,9 +21,19 @@ Daemon for Nova RRD based instance resource monitoring. """ +import os import logging +import sys from twisted.application import service +# 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... +possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]), + os.pardir, + os.pardir)) +if os.path.exists(os.path.join(possible_topdir, 'nova', '__init__.py')): + sys.path.insert(0, possible_topdir) + from nova import twistd from nova.compute import monitor diff --git a/bin/nova-manage b/bin/nova-manage index 145294d3d..d2fd49d8d 100755 --- a/bin/nova-manage +++ b/bin/nova-manage @@ -22,9 +22,18 @@ Connects to the running ADMIN api in the api daemon. """ +import os import sys import time +# 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... +possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]), + os.pardir, + os.pardir)) +if os.path.exists(os.path.join(possible_topdir, 'nova', '__init__.py')): + sys.path.insert(0, possible_topdir) + from nova import flags from nova import utils from nova.auth import manager diff --git a/bin/nova-network b/bin/nova-network index 5753aafbe..307795d7b 100755 --- a/bin/nova-network +++ b/bin/nova-network @@ -21,6 +21,17 @@ Twistd daemon for the nova network nodes. """ +import os +import sys + +# 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... +possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]), + os.pardir, + os.pardir)) +if os.path.exists(os.path.join(possible_topdir, 'nova', '__init__.py')): + sys.path.insert(0, possible_topdir) + from nova import flags from nova import twistd diff --git a/bin/nova-objectstore b/bin/nova-objectstore index afcf13e24..447ef9055 100755 --- a/bin/nova-objectstore +++ b/bin/nova-objectstore @@ -21,6 +21,17 @@ Twisted daemon for nova objectstore. Supports S3 API. """ +import os +import sys + +# 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... +possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]), + os.pardir, + os.pardir)) +if os.path.exists(os.path.join(possible_topdir, 'nova', '__init__.py')): + sys.path.insert(0, possible_topdir) + from nova import flags from nova import utils from nova import twistd diff --git a/bin/nova-volume b/bin/nova-volume index 8ef006ebc..f8e2e1744 100755 --- a/bin/nova-volume +++ b/bin/nova-volume @@ -21,6 +21,17 @@ Twistd daemon for the nova volume nodes. """ +import os +import sys + +# 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... +possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]), + os.pardir, + os.pardir)) +if os.path.exists(os.path.join(possible_topdir, 'nova', '__init__.py')): + sys.path.insert(0, possible_topdir) + from nova import twistd from nova.volume import service -- cgit From 83402810be11111e3f61f3a9c3771bb96161e551 Mon Sep 17 00:00:00 2001 From: Vishvananda Ishaya Date: Thu, 9 Sep 2010 02:30:07 -0700 Subject: put soren's fancy path code in scheduler bin as well --- bin/nova-scheduler | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'bin') diff --git a/bin/nova-scheduler b/bin/nova-scheduler index 97f98b17f..38a8f213f 100755 --- a/bin/nova-scheduler +++ b/bin/nova-scheduler @@ -21,6 +21,17 @@ Twistd daemon for the nova scheduler nodes. """ +import os +import sys + +# 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... +possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]), + os.pardir, + os.pardir)) +if os.path.exists(os.path.join(possible_topdir, 'nova', '__init__.py')): + sys.path.insert(0, possible_topdir) + from nova import service from nova import twistd -- cgit From 33631c21e71d85910a20997881735aa43160d36a Mon Sep 17 00:00:00 2001 From: Vishvananda Ishaya Date: Thu, 9 Sep 2010 07:47:30 -0700 Subject: floating ip commands --- bin/nova-manage | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'bin') diff --git a/bin/nova-manage b/bin/nova-manage index ecef5d555..408a2d9c8 100755 --- a/bin/nova-manage +++ b/bin/nova-manage @@ -26,6 +26,8 @@ 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... possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]), @@ -218,12 +220,41 @@ class ProjectCommands(object): with open(filename, 'w') as f: f.write(zip_file) +class FloatingIpCommands(object): + """Class for managing floating ip.""" + + def create(self, host, range): + """Creates floating ips for host by range + arguments: host ip_range""" + for address in IPy.IP(range): + db.floating_ip_create(None, {'address': str(address), + 'host': host}) + + def delete(self, ip_range): + """Deletes floating ips by range + arguments: range""" + for address in IPy.IP(ip_range): + db.floating_ip_destroy(None, str(address)) + + + def list(self, host=None): + """Lists all floating ips (optionally by host) + arguments: [host]""" + if host == None: + floating_ips = db.floating_ip_get_all(None) + else: + floating_ips = db.floating_ip_get_all_by_host(None, host) + for floating_ip in floating_ips: + print "%s\t%s\ti-%s" % (floating_ip['host'], + floating_ip['address'], + floating_ip['instance_id']) CATEGORIES = [ ('user', UserCommands), ('project', ProjectCommands), ('role', RoleCommands), ('vpn', VpnCommands), + ('floating', FloatingIpCommands) ] -- cgit From 4dcc4bc4b459b454431ca60bec0dead2146f52af Mon Sep 17 00:00:00 2001 From: Vishvananda Ishaya Date: Thu, 9 Sep 2010 07:53:57 -0700 Subject: list command for floating ips --- bin/nova-manage | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'bin') diff --git a/bin/nova-manage b/bin/nova-manage index 408a2d9c8..56191252a 100755 --- a/bin/nova-manage +++ b/bin/nova-manage @@ -245,9 +245,12 @@ class FloatingIpCommands(object): else: floating_ips = db.floating_ip_get_all_by_host(None, host) for floating_ip in floating_ips: - print "%s\t%s\ti-%s" % (floating_ip['host'], - floating_ip['address'], - floating_ip['instance_id']) + instance = None + if floating_ip['fixed_ip']: + instance = floating_ip['fixed_ip']['instance']['str_id'] + print "%s\t%s\t%s" % (floating_ip['host'], + floating_ip['address'], + instance) CATEGORIES = [ ('user', UserCommands), -- cgit From 214f15b5eac2100937473ee8990f8ec8a31fb142 Mon Sep 17 00:00:00 2001 From: Vishvananda Ishaya Date: Fri, 10 Sep 2010 12:25:45 -0700 Subject: dhcpbridge needed host instead of node name --- bin/nova-dhcpbridge | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'bin') diff --git a/bin/nova-dhcpbridge b/bin/nova-dhcpbridge index c4795cca2..42eaf4bcb 100755 --- a/bin/nova-dhcpbridge +++ b/bin/nova-dhcpbridge @@ -53,7 +53,7 @@ def add_lease(_mac, ip_address, _hostname, _interface): network_manager = utils.import_object(FLAGS.network_manager) network_manager.lease_fixed_ip(None, ip_address) else: - rpc.cast("%s.%s" % (FLAGS.network_topic, FLAGS.node_name), + rpc.cast("%s.%s" % (FLAGS.network_topic, FLAGS.host), {"method": "lease_fixed_ip", "args": {"context": None, "address": ip_address}}) @@ -71,7 +71,7 @@ def del_lease(_mac, ip_address, _hostname, _interface): network_manager = utils.import_object(FLAGS.network_manager) network_manager.release_fixed_ip(None, ip_address) else: - rpc.cast("%s.%s" % (FLAGS.network_topic, FLAGS.node_name), + rpc.cast("%s.%s" % (FLAGS.network_topic, FLAGS.host), {"method": "release_fixed_ip", "args": {"context": None, "address": ip_address}}) -- cgit From 9003fe35cfd2a6daa49d717bf256f2229171f7c6 Mon Sep 17 00:00:00 2001 From: Vishvananda Ishaya Date: Sat, 11 Sep 2010 00:16:12 -0700 Subject: improved network error case handling for fixed ips --- bin/nova-dhcpbridge | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'bin') diff --git a/bin/nova-dhcpbridge b/bin/nova-dhcpbridge index 42eaf4bcb..2f75bf43b 100755 --- a/bin/nova-dhcpbridge +++ b/bin/nova-dhcpbridge @@ -46,16 +46,17 @@ flags.DECLARE('network_size', 'nova.network.manager') flags.DECLARE('num_networks', 'nova.network.manager') -def add_lease(_mac, ip_address, _hostname, _interface): +def add_lease(mac, ip_address, _hostname, _interface): """Set the IP that was assigned by the DHCP server.""" if FLAGS.fake_rabbit: logging.debug("leasing ip") network_manager = utils.import_object(FLAGS.network_manager) - network_manager.lease_fixed_ip(None, ip_address) + network_manager.lease_fixed_ip(None, mac, ip_address) else: rpc.cast("%s.%s" % (FLAGS.network_topic, FLAGS.host), {"method": "lease_fixed_ip", "args": {"context": None, + "mac": mac, "address": ip_address}}) @@ -64,16 +65,17 @@ def old_lease(_mac, _ip_address, _hostname, _interface): logging.debug("Adopted old lease or got a change of mac/hostname") -def del_lease(_mac, ip_address, _hostname, _interface): +def del_lease(mac, ip_address, _hostname, _interface): """Called when a lease expires.""" if FLAGS.fake_rabbit: logging.debug("releasing ip") network_manager = utils.import_object(FLAGS.network_manager) - network_manager.release_fixed_ip(None, ip_address) + network_manager.release_fixed_ip(None, mac, ip_address) else: rpc.cast("%s.%s" % (FLAGS.network_topic, FLAGS.host), {"method": "release_fixed_ip", "args": {"context": None, + "mac": mac, "address": ip_address}}) -- cgit From fe78b3651c9064e527b8e3b74d7669d3d364daab Mon Sep 17 00:00:00 2001 From: Vishvananda Ishaya Date: Sat, 11 Sep 2010 04:06:22 -0700 Subject: typo fixes, add flag to nova-dhcpbridge --- bin/nova-dhcpbridge | 1 + 1 file changed, 1 insertion(+) (limited to 'bin') diff --git a/bin/nova-dhcpbridge b/bin/nova-dhcpbridge index 2f75bf43b..a127ed03c 100755 --- a/bin/nova-dhcpbridge +++ b/bin/nova-dhcpbridge @@ -44,6 +44,7 @@ flags.DECLARE('auth_driver', 'nova.auth.manager') flags.DECLARE('redis_db', 'nova.datastore') flags.DECLARE('network_size', 'nova.network.manager') flags.DECLARE('num_networks', 'nova.network.manager') +flags.DECLARE('update_dhcp_on_disassociate', 'nova.network.manager') def add_lease(mac, ip_address, _hostname, _interface): -- cgit From 3dbb3fa96779fbed89251a7c24455acbddc013e5 Mon Sep 17 00:00:00 2001 From: Vishvananda Ishaya Date: Sat, 11 Sep 2010 20:05:32 -0700 Subject: fixed reversed args in nova-manage project environment --- bin/nova-manage | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bin') diff --git a/bin/nova-manage b/bin/nova-manage index 325245ac4..1c6dc03ac 100755 --- a/bin/nova-manage +++ b/bin/nova-manage @@ -252,7 +252,7 @@ class ProjectCommands(object): def environment(self, project_id, user_id, filename='novarc'): """Exports environment variables to an sourcable file arguments: project_id user_id [filename='novarc]""" - rc = self.manager.get_environment_rc(project_id, user_id) + rc = self.manager.get_environment_rc(user_id, project_id) with open(filename, 'w') as f: f.write(rc) -- cgit From dff482e992b25580728955ae83ea2e38a18e7736 Mon Sep 17 00:00:00 2001 From: Vishvananda Ishaya Date: Sat, 11 Sep 2010 20:54:12 -0700 Subject: manage command for project quotas --- bin/nova-manage | 37 +++++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 10 deletions(-) (limited to 'bin') diff --git a/bin/nova-manage b/bin/nova-manage index 325245ac4..c7ef33a48 100755 --- a/bin/nova-manage +++ b/bin/nova-manage @@ -50,7 +50,6 @@ """ CLI interface for nova management. - Connects to the running ADMIN api in the api daemon. """ import os @@ -68,7 +67,9 @@ if os.path.exists(os.path.join(possible_topdir, 'nova', '__init__.py')): sys.path.insert(0, possible_topdir) from nova import db +from nova import exception from nova import flags +from nova import quota from nova import utils from nova.auth import manager from nova.cloudpipe import pipelib @@ -186,6 +187,13 @@ class RoleCommands(object): class UserCommands(object): """Class for managing users.""" + @staticmethod + def _print_export(user): + """Print export variables to use with API.""" + print 'export EC2_ACCESS_KEY=%s' % user.access + print 'export EC2_SECRET_KEY=%s' % user.secret + + def __init__(self): self.manager = manager.AuthManager() @@ -193,13 +201,13 @@ class UserCommands(object): """creates a new admin and prints exports arguments: name [access] [secret]""" user = self.manager.create_user(name, access, secret, True) - print_export(user) + self._print_export(user) def create(self, name, access=None, secret=None): """creates a new user and prints exports arguments: name [access] [secret]""" user = self.manager.create_user(name, access, secret, False) - print_export(user) + self._print_export(user) def delete(self, name): """deletes an existing user @@ -211,7 +219,7 @@ class UserCommands(object): arguments: name""" user = self.manager.get_user(name) if user: - print_export(user) + self._print_export(user) else: print "User %s doesn't exist" % name @@ -222,12 +230,6 @@ class UserCommands(object): print user.name -def print_export(user): - """Print export variables to use with API.""" - print 'export EC2_ACCESS_KEY=%s' % user.access - print 'export EC2_SECRET_KEY=%s' % user.secret - - class ProjectCommands(object): """Class for managing projects.""" @@ -262,6 +264,19 @@ class ProjectCommands(object): for project in self.manager.get_projects(): print project.name + def quota(self, project_id, key=None, value=None): + """Set or display quotas for project + arguments: project_id [key] [value]""" + if key: + quo = {'project_id': project_id, key: value} + try: + db.quota_update(None, project_id, quo) + except exception.NotFound: + db.quota_create(None, quo) + project_quota = quota._get_quota(None, project_id) + for key, value in project_quota.iteritems(): + print '%s: %s' % (key, value) + def remove(self, project, user): """Removes user from project arguments: project user""" @@ -274,6 +289,7 @@ class ProjectCommands(object): with open(filename, 'w') as f: f.write(zip_file) + class FloatingIpCommands(object): """Class for managing floating ip.""" @@ -306,6 +322,7 @@ class FloatingIpCommands(object): floating_ip['address'], instance) + CATEGORIES = [ ('user', UserCommands), ('project', ProjectCommands), -- cgit From c35f0961a030ebefb19c0fbf4a666a0d6ce6be4c Mon Sep 17 00:00:00 2001 From: Jesse Andrews Date: Mon, 13 Sep 2010 00:06:32 -0700 Subject: add a shell to nova-manage, which respects flags (taken from django) --- bin/nova-manage | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) (limited to 'bin') diff --git a/bin/nova-manage b/bin/nova-manage index d2fd49d8d..6e5266767 100755 --- a/bin/nova-manage +++ b/bin/nova-manage @@ -17,6 +17,37 @@ # License for the specific language governing permissions and limitations # under the License. +# Interactive shell based on Django: +# +# Copyright (c) 2005, the Lawrence Journal-World +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, +# this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# 3. Neither the name of Django nor the names of its contributors may be used +# to endorse or promote products derived from this software without +# specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + """ CLI interface for nova management. Connects to the running ADMIN api in the api daemon. @@ -103,6 +134,29 @@ class VpnCommands(object): self.pipe.launch_vpn_instance(project_id) +class ShellCommands(object): + def run(self): + "Runs a Python interactive interpreter. Tries to use IPython, if it's available." + try: + import IPython + # Explicitly pass an empty list as arguments, because otherwise IPython + # would use sys.argv from this script. + shell = IPython.Shell.IPShell(argv=[]) + shell.mainloop() + except ImportError: + import code + try: # Try activating rlcompleter, because it's handy. + import readline + except ImportError: + pass + else: + # We don't have to wrap the following import in a 'try', because + # we already know 'readline' was imported successfully. + import rlcompleter + readline.parse_and_bind("tab:complete") + code.interact() + + class RoleCommands(object): """Class for managing roles.""" @@ -225,6 +279,7 @@ CATEGORIES = [ ('user', UserCommands), ('project', ProjectCommands), ('role', RoleCommands), + ('shell', ShellCommands), ('vpn', VpnCommands), ] -- cgit From 86cd30b749e6da78d4ceb6c77f2116975429a81a Mon Sep 17 00:00:00 2001 From: Vishvananda Ishaya Date: Mon, 13 Sep 2010 01:15:35 -0700 Subject: renamed _get_quota to get_quota and moved int(size) into quota.py --- bin/nova-manage | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bin') diff --git a/bin/nova-manage b/bin/nova-manage index c7ef33a48..824e00ac5 100755 --- a/bin/nova-manage +++ b/bin/nova-manage @@ -273,7 +273,7 @@ class ProjectCommands(object): db.quota_update(None, project_id, quo) except exception.NotFound: db.quota_create(None, quo) - project_quota = quota._get_quota(None, project_id) + project_quota = quota.get_quota(None, project_id) for key, value in project_quota.iteritems(): print '%s: %s' % (key, value) -- cgit From 0936150221713d775a5cad4a2e978980c32b21c1 Mon Sep 17 00:00:00 2001 From: Jesse Andrews Date: Mon, 13 Sep 2010 23:56:32 -0700 Subject: now we can run files - thanks vish --- bin/nova-manage | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'bin') diff --git a/bin/nova-manage b/bin/nova-manage index 6e5266767..26f75faf7 100755 --- a/bin/nova-manage +++ b/bin/nova-manage @@ -156,6 +156,11 @@ class ShellCommands(object): readline.parse_and_bind("tab:complete") code.interact() + def script(self, path): + """Runs the script from the specifed path with flags set properly. + arguments: path""" + exec(compile(open(path).read(), path, 'exec'), locals(), globals()) + class RoleCommands(object): """Class for managing roles.""" -- cgit From 6186634c0f8d6a44323fe1f7b2530528a539c64c Mon Sep 17 00:00:00 2001 From: Vishvananda Ishaya Date: Tue, 21 Sep 2010 11:12:04 -0700 Subject: bpython is amazing --- bin/nova-manage | 51 ++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 42 insertions(+), 9 deletions(-) (limited to 'bin') diff --git a/bin/nova-manage b/bin/nova-manage index 26f75faf7..d23818348 100755 --- a/bin/nova-manage +++ b/bin/nova-manage @@ -135,15 +135,48 @@ class VpnCommands(object): class ShellCommands(object): - def run(self): - "Runs a Python interactive interpreter. Tries to use IPython, if it's available." - try: - import IPython - # Explicitly pass an empty list as arguments, because otherwise IPython - # would use sys.argv from this script. - shell = IPython.Shell.IPShell(argv=[]) - shell.mainloop() - except ImportError: + def bpython(self): + """Runs a bpython shell. + + Falls back to Ipython/python shell if unavailable""" + self.run('bpython') + + def ipython(self): + """Runs an Ipython shell. + + Falls back to Python shell if unavailable""" + self.run('ipython') + + def python(self): + """Runs an python shell. + + Falls back to Python shell if unavailable""" + self.run('python') + + def run(self, shell=None): + """Runs a Python interactive interpreter. + + args: [shell=bpython]""" + if not shell: + shell = 'bpython' + + if shell == 'bpython': + try: + import bpython + bpython.embed() + except ImportError: + shell = 'ipython' + if shell == 'ipython': + try: + import IPython + # Explicitly pass an empty list as arguments, because otherwise IPython + # would use sys.argv from this script. + shell = IPython.Shell.IPShell(argv=[]) + shell.mainloop() + except ImportError: + shell = 'python' + + if shell == 'python': import code try: # Try activating rlcompleter, because it's handy. import readline -- cgit From b68b73d08155483d19f4088baa6a4ffe73ef5f1d Mon Sep 17 00:00:00 2001 From: Vishvananda Ishaya Date: Tue, 21 Sep 2010 14:36:06 -0700 Subject: typo s/an/a --- bin/nova-manage | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bin') diff --git a/bin/nova-manage b/bin/nova-manage index 4ae2f20dc..c5c7322bf 100755 --- a/bin/nova-manage +++ b/bin/nova-manage @@ -149,7 +149,7 @@ class ShellCommands(object): self.run('ipython') def python(self): - """Runs an python shell. + """Runs a python shell. Falls back to Python shell if unavailable""" self.run('python') -- cgit From 54122c0a156d1562be76dfde41bd62006f9ed426 Mon Sep 17 00:00:00 2001 From: Eric Day Date: Wed, 22 Sep 2010 17:54:57 -0700 Subject: Various loose ends for endpoint and tornado removal cleanup, including cloudpipe API addition, rpc.call() cleanup by removing tornado ioloop, and fixing bin/* programs. Tornado still exists as part of some test cases and those should be reworked to not require it. --- bin/nova-api | 47 ++++++++++++++--------------------------------- bin/nova-api-new | 45 --------------------------------------------- bin/nova-manage | 3 +-- 3 files changed, 15 insertions(+), 80 deletions(-) delete mode 100755 bin/nova-api-new (limited to 'bin') diff --git a/bin/nova-api b/bin/nova-api index ede09d38c..8625c487f 100755 --- a/bin/nova-api +++ b/bin/nova-api @@ -1,31 +1,28 @@ #!/usr/bin/env python +# pylint: disable-msg=C0103 # vim: tabstop=4 shiftwidth=4 softtabstop=4 # Copyright 2010 United States Government as represented by the # Administrator of the National Aeronautics and Space Administration. # All Rights Reserved. # -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at # -# http://www.apache.org/licenses/LICENSE-2.0 +# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. """ -Tornado daemon for the main API endpoint. +Nova API daemon. """ -import logging import os import sys -from tornado import httpserver -from tornado import ioloop # 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... @@ -35,30 +32,14 @@ possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]), if os.path.exists(os.path.join(possible_topdir, 'nova', '__init__.py')): sys.path.insert(0, possible_topdir) +from nova import api from nova import flags -from nova import server from nova import utils -from nova.endpoint import admin -from nova.endpoint import api -from nova.endpoint import cloud +from nova import wsgi FLAGS = flags.FLAGS - - -def main(_argv): - """Load the controllers and start the tornado I/O loop.""" - controllers = { - 'Cloud': cloud.CloudController(), - 'Admin': admin.AdminController()} - _app = api.APIServerApplication(controllers) - - io_inst = ioloop.IOLoop.instance() - http_server = httpserver.HTTPServer(_app) - http_server.listen(FLAGS.cc_port) - logging.debug('Started HTTP server on %s', FLAGS.cc_port) - io_inst.start() - +flags.DEFINE_integer('api_port', 8773, 'API port') if __name__ == '__main__': utils.default_flagfile() - server.serve('nova-api', main) + wsgi.run_server(api.API(), FLAGS.api_port) diff --git a/bin/nova-api-new b/bin/nova-api-new deleted file mode 100755 index 8625c487f..000000000 --- a/bin/nova-api-new +++ /dev/null @@ -1,45 +0,0 @@ -#!/usr/bin/env python -# pylint: disable-msg=C0103 -# vim: tabstop=4 shiftwidth=4 softtabstop=4 - -# Copyright 2010 United States Government as represented by the -# Administrator of the National Aeronautics and Space Administration. -# All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -""" -Nova API daemon. -""" - -import os -import sys - -# 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... -possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]), - os.pardir, - os.pardir)) -if os.path.exists(os.path.join(possible_topdir, 'nova', '__init__.py')): - sys.path.insert(0, possible_topdir) - -from nova import api -from nova import flags -from nova import utils -from nova import wsgi - -FLAGS = flags.FLAGS -flags.DEFINE_integer('api_port', 8773, 'API port') - -if __name__ == '__main__': - utils.default_flagfile() - wsgi.run_server(api.API(), FLAGS.api_port) diff --git a/bin/nova-manage b/bin/nova-manage index 824e00ac5..baa1cb4db 100755 --- a/bin/nova-manage +++ b/bin/nova-manage @@ -73,7 +73,6 @@ from nova import quota from nova import utils from nova.auth import manager from nova.cloudpipe import pipelib -from nova.endpoint import cloud FLAGS = flags.FLAGS @@ -84,7 +83,7 @@ class VpnCommands(object): def __init__(self): self.manager = manager.AuthManager() - self.pipe = pipelib.CloudPipe(cloud.CloudController()) + self.pipe = pipelib.CloudPipe() def list(self): """Print a listing of the VPNs for all projects.""" -- cgit From 24f589d421be9a15ad941c34128b4fa0bdc28db4 Mon Sep 17 00:00:00 2001 From: Michael Gundlach Date: Thu, 23 Sep 2010 09:13:27 -0400 Subject: Apply vish's patch --- bin/nova-api-new | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'bin') diff --git a/bin/nova-api-new b/bin/nova-api-new index 8625c487f..6f25ad8c7 100755 --- a/bin/nova-api-new +++ b/bin/nova-api-new @@ -34,12 +34,11 @@ if os.path.exists(os.path.join(possible_topdir, 'nova', '__init__.py')): from nova import api from nova import flags -from nova import utils from nova import wsgi FLAGS = flags.FLAGS flags.DEFINE_integer('api_port', 8773, 'API port') if __name__ == '__main__': - utils.default_flagfile() + FLAGS(sys.argv) wsgi.run_server(api.API(), FLAGS.api_port) -- cgit From ebf71b08efc6ab3c590f71715aa16b925f17c38e Mon Sep 17 00:00:00 2001 From: Soren Hansen Date: Thu, 23 Sep 2010 15:47:29 +0200 Subject: Wrap WSGI container in server.serve to make it properly handle command line arguments as well as daemonise properly. Moved api and wsgi imports in the main() function to delay their inclusion until after python-daemon has closed all the file descriptors. Without this, eventlet's epoll fd gets opened before daemonize is called and thus its fd gets closed leading to very, very, very confusing errors. --- bin/nova-api-new | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'bin') diff --git a/bin/nova-api-new b/bin/nova-api-new index 6f25ad8c7..a5027700b 100755 --- a/bin/nova-api-new +++ b/bin/nova-api-new @@ -32,13 +32,18 @@ possible_topdir = os.path.normpath(os.path.join(os.path.abspath(sys.argv[0]), if os.path.exists(os.path.join(possible_topdir, 'nova', '__init__.py')): sys.path.insert(0, possible_topdir) -from nova import api from nova import flags -from nova import wsgi +from nova import utils +from nova import server FLAGS = flags.FLAGS flags.DEFINE_integer('api_port', 8773, 'API port') -if __name__ == '__main__': - FLAGS(sys.argv) +def main(_args): + from nova import api + from nova import wsgi wsgi.run_server(api.API(), FLAGS.api_port) + +if __name__ == '__main__': + utils.default_flagfile() + server.serve('nova-api', main) -- cgit From 90669318581554a72890a6fd9c6837deb86c7e4c Mon Sep 17 00:00:00 2001 From: Michael Gundlach Date: Thu, 23 Sep 2010 10:19:27 -0400 Subject: Spot-fix endpoint reference --- bin/nova-manage | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bin') diff --git a/bin/nova-manage b/bin/nova-manage index 824e00ac5..e9219c515 100755 --- a/bin/nova-manage +++ b/bin/nova-manage @@ -73,7 +73,7 @@ from nova import quota from nova import utils from nova.auth import manager from nova.cloudpipe import pipelib -from nova.endpoint import cloud +from nova.api.ec2 import cloud FLAGS = flags.FLAGS -- cgit From e4cb0d3a93ddc4cae40c4a8c570c7e7d2a0061ff Mon Sep 17 00:00:00 2001 From: Vishvananda Ishaya Date: Tue, 28 Sep 2010 10:34:32 -0700 Subject: get rid of network indexes and make networks into a pool --- bin/nova-manage | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) (limited to 'bin') diff --git a/bin/nova-manage b/bin/nova-manage index baa1cb4db..40d690e30 100755 --- a/bin/nova-manage +++ b/bin/nova-manage @@ -72,6 +72,7 @@ from nova import flags from nova import quota from nova import utils from nova.auth import manager +from nova.network import manager as network_manager from nova.cloudpipe import pipelib @@ -321,6 +322,25 @@ class FloatingIpCommands(object): floating_ip['address'], instance) +class NetworkCommands(object): + """Class for managing networks.""" + + def create(self, num_networks=None, network_size=None, + vlan_start=None, vpn_start=None): + """Creates floating ips for host by range + arguments: [num_networks=FLAG], [network_size=FLAG], + [vlan_start=FLAG, vpn_start=FLAG]""" + if not num_networks: + num_networks = FLAGS.num_networks + if not network_size: + network_size = FLAGS.network_size + if not vlan_start: + vlan_start = FLAGS.vlan_start + if not vpn_start: + vpn_start = FLAGS.vpn_start + net_manager = network_manager.VlanManager() + net_manager.create_networks(None, int(num_networks), int(network_size), + int(vlan_start), int(vpn_start)) CATEGORIES = [ ('user', UserCommands), @@ -328,7 +348,8 @@ CATEGORIES = [ ('role', RoleCommands), ('shell', ShellCommands), ('vpn', VpnCommands), - ('floating', FloatingIpCommands) + ('floating', FloatingIpCommands), + ('network', NetworkCommands) ] @@ -394,9 +415,9 @@ def main(): fn(*argv) sys.exit(0) except TypeError: - print "Wrong number of arguments supplied" + print "Possible wrong number of arguments supplied" print "%s %s: %s" % (category, action, fn.__doc__) - sys.exit(2) + raise if __name__ == '__main__': main() -- cgit From 08a6dc59add5d72c6d925d1ca43868557a4b3148 Mon Sep 17 00:00:00 2001 From: Todd Willey Date: Tue, 28 Sep 2010 15:54:05 -0400 Subject: Hook the AuthManger#modify_user method into nova-manage commands. --- bin/nova-manage | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'bin') diff --git a/bin/nova-manage b/bin/nova-manage index baa1cb4db..da18e7d1b 100755 --- a/bin/nova-manage +++ b/bin/nova-manage @@ -228,6 +228,19 @@ class UserCommands(object): for user in self.manager.get_users(): print user.name + def modify(self, name, access_key, secret_key, is_admin): + """update a users keys & admin flag + arguments: accesskey secretkey admin + leave any field blank to ignore it, admin should be 'T', 'F', or blank + """ + if not is_admin: + is_admin = None + elif is_admin.upper()[0] == 'T': + is_admin = True + else: + is_admin = False + print "is_admin: %r" % is_admin + self.manager.modify_user(name, access_key, secret_key, is_admin) class ProjectCommands(object): """Class for managing projects.""" -- cgit From 2327378a1e5c9fa942d56001919caaeb1be1c7cb Mon Sep 17 00:00:00 2001 From: Devin Carlen Date: Tue, 28 Sep 2010 18:38:19 -0700 Subject: Removed str_id from FixedIp references --- bin/nova-manage | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bin') diff --git a/bin/nova-manage b/bin/nova-manage index baa1cb4db..d0fde6f17 100755 --- a/bin/nova-manage +++ b/bin/nova-manage @@ -316,7 +316,7 @@ class FloatingIpCommands(object): for floating_ip in floating_ips: instance = None if floating_ip['fixed_ip']: - instance = floating_ip['fixed_ip']['instance']['str_id'] + instance = floating_ip['fixed_ip']['instance']['address'] print "%s\t%s\t%s" % (floating_ip['host'], floating_ip['address'], instance) -- cgit From e3102b6b9be148597a2f502d2b2baf750ecc0a34 Mon Sep 17 00:00:00 2001 From: Devin Carlen Date: Tue, 28 Sep 2010 18:43:36 -0700 Subject: Fixed tests --- bin/nova-manage | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bin') diff --git a/bin/nova-manage b/bin/nova-manage index d0fde6f17..a5087bfec 100755 --- a/bin/nova-manage +++ b/bin/nova-manage @@ -316,7 +316,7 @@ class FloatingIpCommands(object): for floating_ip in floating_ips: instance = None if floating_ip['fixed_ip']: - instance = floating_ip['fixed_ip']['instance']['address'] + instance = floating_ip['fixed_ip']['instance']['ec2_id'] print "%s\t%s\t%s" % (floating_ip['host'], floating_ip['address'], instance) -- cgit From 724c15b6583b47baabd2f01090580cb248ad1244 Mon Sep 17 00:00:00 2001 From: Todd Willey Date: Wed, 29 Sep 2010 14:12:02 -0400 Subject: Remove debuggish print statement. --- bin/nova-manage | 1 - 1 file changed, 1 deletion(-) (limited to 'bin') diff --git a/bin/nova-manage b/bin/nova-manage index 7a9a4c3d1..bf3c67612 100755 --- a/bin/nova-manage +++ b/bin/nova-manage @@ -277,7 +277,6 @@ class UserCommands(object): is_admin = True else: is_admin = False - print "is_admin: %r" % is_admin self.manager.modify_user(name, access_key, secret_key, is_admin) class ProjectCommands(object): -- cgit From c9d2b8bcb365f326a47df93920c11be2ca054b18 Mon Sep 17 00:00:00 2001 From: Vishvananda Ishaya Date: Thu, 30 Sep 2010 23:04:53 -0700 Subject: Fixed flat network manager with network index gone. Both managers use ips created through nova manage. Use of project_get_network is minimized to make way for managers that would prefer to use cluste or host based ips instead of project based ips. --- bin/nova-manage | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'bin') diff --git a/bin/nova-manage b/bin/nova-manage index d421b997a..6da2efe95 100755 --- a/bin/nova-manage +++ b/bin/nova-manage @@ -375,11 +375,14 @@ class FloatingIpCommands(object): class NetworkCommands(object): """Class for managing networks.""" - def create(self, num_networks=None, network_size=None, - vlan_start=None, vpn_start=None): - """Creates floating ips for host by range - arguments: [num_networks=FLAG], [network_size=FLAG], - [vlan_start=FLAG, vpn_start=FLAG]""" + def create(self, fixed_range=None, num_networks=None, + network_size=None, vlan_start=None, vpn_start=None): + """Creates fixed ips for host by range + arguments: [fixed_range=FLAG], [num_networks=FLAG], + [network_size=FLAG], [vlan_start=FLAG], + [vpn_start=FLAG]""" + if not fixed_range: + fixed_range = FLAGS.fixed_range if not num_networks: num_networks = FLAGS.num_networks if not network_size: @@ -388,9 +391,10 @@ class NetworkCommands(object): vlan_start = FLAGS.vlan_start if not vpn_start: vpn_start = FLAGS.vpn_start - net_manager = network_manager.VlanManager() - net_manager.create_networks(None, int(num_networks), int(network_size), - int(vlan_start), int(vpn_start)) + net_manager = utils.import_object(FLAGS.network_manager) + net_manager.create_networks(None, fixed_range, int(num_networks), + int(network_size), int(vlan_start), + int(vpn_start)) CATEGORIES = [ ('user', UserCommands), -- cgit From 65e2bbc31a7e4ea5d8f9456c2ea5b54715305d11 Mon Sep 17 00:00:00 2001 From: Ewan Mellor Date: Sun, 3 Oct 2010 12:41:07 +0100 Subject: Bug #654023: nova-manage vpn commands broken, resulting in erroneous "Wrong number of arguments supplied" message Add a context of None to the call to db.instance_get_all. This is deprecated, but it's what all the other calls in this file do, and it's better than exploding, so it will do for now. --- bin/nova-manage | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bin') diff --git a/bin/nova-manage b/bin/nova-manage index bf3c67612..0b5869dfd 100755 --- a/bin/nova-manage +++ b/bin/nova-manage @@ -114,7 +114,7 @@ class VpnCommands(object): def _vpn_for(self, project_id): """Get the VPN instance for a project ID.""" - for instance in db.instance_get_all(): + for instance in db.instance_get_all(None): if (instance['image_id'] == FLAGS.vpn_image_id and not instance['state_description'] in ['shutting_down', 'shutdown'] -- cgit From 4fa2258af9fb130be1650372cf48be39e83451e5 Mon Sep 17 00:00:00 2001 From: Ewan Mellor Date: Sun, 3 Oct 2010 13:12:32 +0100 Subject: Bug #654025: nova-manage project zip and nova-manage vpn list broken by change in DB semantics when networks are missing Catch exception.NotFound when getting project VPN data. This is in two places: nova-manage as part of its vpn list command, and auth.manager.AuthManager.get_credentials. Also, document the behaviour of db.api.project_get_network. --- bin/nova-manage | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'bin') diff --git a/bin/nova-manage b/bin/nova-manage index bf3c67612..5293fc942 100755 --- a/bin/nova-manage +++ b/bin/nova-manage @@ -88,11 +88,16 @@ class VpnCommands(object): def list(self): """Print a listing of the VPNs for all projects.""" print "%-12s\t" % 'project', - print "%-12s\t" % 'ip:port', + print "%-20s\t" % 'ip:port', print "%s" % 'state' for project in self.manager.get_projects(): print "%-12s\t" % project.name, - print "%s:%s\t" % (project.vpn_ip, project.vpn_port), + + try: + s = "%s:%s" % (project.vpn_ip, project.vpn_port) + except exception.NotFound: + s = "None" + print "%-20s\t" % s, vpn = self._vpn_for(project.id) if vpn: -- cgit From a0498717e470eb6fd52a4f26101c3513d90a3974 Mon Sep 17 00:00:00 2001 From: Ewan Mellor Date: Sun, 3 Oct 2010 13:17:20 +0100 Subject: Bug #654034: nova-manage doesn't honour --verbose flag Honour the --verbose flag by setting the logging level to DEBUG. --- bin/nova-manage | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'bin') diff --git a/bin/nova-manage b/bin/nova-manage index bf3c67612..ce87b9437 100755 --- a/bin/nova-manage +++ b/bin/nova-manage @@ -52,6 +52,7 @@ CLI interface for nova management. """ +import logging import os import sys import time @@ -417,6 +418,10 @@ def main(): """Parse options and call the appropriate class/method.""" utils.default_flagfile('/etc/nova/nova-manage.conf') argv = FLAGS(sys.argv) + + if FLAGS.verbose: + logging.getLogger().setLevel(logging.DEBUG) + script_name = argv.pop(0) if len(argv) < 1: print script_name + " category action []" -- cgit