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 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 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 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 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 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