From ecf8608a84960496c6c8e350f99d53537e4581c8 Mon Sep 17 00:00:00 2001 From: Vishvananda Ishaya Date: Tue, 3 Aug 2010 14:31:47 -0700 Subject: Huge network refactor, Round I Made network into its own binary Made simple network a plugabble class Fixed unittests Moved various classes around Moved mac generation into network class --- bin/nova-dhcpbridge | 22 ++++++++++++---------- bin/nova-network | 11 +++++++++-- 2 files changed, 21 insertions(+), 12 deletions(-) (limited to 'bin') diff --git a/bin/nova-dhcpbridge b/bin/nova-dhcpbridge index 0db241b5e..b3e7d456a 100755 --- a/bin/nova-dhcpbridge +++ b/bin/nova-dhcpbridge @@ -35,32 +35,34 @@ sys.path.append(os.path.abspath(os.path.join(__file__, "../../"))) from nova import flags from nova import rpc from nova import utils -from nova.compute import linux_net -from nova.compute import network - +from nova.network import linux_net +from nova.network import model +from nova.network import service FLAGS = flags.FLAGS def add_lease(mac, ip, hostname, interface): if FLAGS.fake_rabbit: - network.lease_ip(ip) + service.VlanNetworkService().lease_ip(ip) else: - rpc.cast(FLAGS.cloud_topic, {"method": "lease_ip", - "args" : {"address": ip}}) + rpc.cast("%s.%s" (FLAGS.network_topic, FLAGS.node_name), + {"method": "lease_ip", + "args" : {"fixed_ip": ip}}) def old_lease(mac, ip, hostname, interface): logging.debug("Adopted old lease or got a change of mac/hostname") def del_lease(mac, ip, hostname, interface): if FLAGS.fake_rabbit: - network.release_ip(ip) + service.VlanNetworkService().release_ip(ip) else: - rpc.cast(FLAGS.cloud_topic, {"method": "release_ip", - "args" : {"address": ip}}) + rpc.cast("%s.%s" (FLAGS.network_topic, FLAGS.node_name), + {"method": "release_ip", + "args" : {"fixed_ip": ip}}) def init_leases(interface): - net = network.get_network_by_interface(interface) + net = model.get_network_by_interface(interface) res = "" for host_name in net.hosts: res += "%s\n" % linux_net.hostDHCP(net, host_name, net.hosts[host_name]) diff --git a/bin/nova-network b/bin/nova-network index 52d6cb70a..b2e2cf173 100755 --- a/bin/nova-network +++ b/bin/nova-network @@ -21,12 +21,19 @@ Twistd daemon for the nova network nodes. """ +from nova import flags from nova import twistd -from nova.network import service +from nova import utils +FLAGS = flags.FLAGS + +flags.DEFINE_string('network_service', + 'nova.network.service.VlanNetworkService', + 'Service Class for Networking') + if __name__ == '__main__': twistd.serve(__file__) if __name__ == '__builtin__': - application = service.NetworkService.create() + application = utils.import_class(FLAGS.network_service).create() -- cgit From 576dade1d53814416977522637bea9e3c32e5483 Mon Sep 17 00:00:00 2001 From: Vishvananda Ishaya Date: Tue, 3 Aug 2010 15:13:07 -0700 Subject: change network_service flag to network_type and don't take full class name --- bin/nova-network | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'bin') diff --git a/bin/nova-network b/bin/nova-network index b2e2cf173..1d620b525 100755 --- a/bin/nova-network +++ b/bin/nova-network @@ -25,15 +25,17 @@ from nova import flags from nova import twistd from nova import utils +from nova.network import service FLAGS = flags.FLAGS -flags.DEFINE_string('network_service', - 'nova.network.service.VlanNetworkService', - 'Service Class for Networking') if __name__ == '__main__': twistd.serve(__file__) if __name__ == '__builtin__': - application = utils.import_class(FLAGS.network_service).create() + t = FLAGS.network_type + if t == 'flat': + application = service.FlatNetworkService.create() + elif t == 'vlan': + application = service.VlanNetworkService.create() -- cgit From 9a038d2b81163d3e658e4fb3be4f8c14aa3b5fab Mon Sep 17 00:00:00 2001 From: Vishvananda Ishaya Date: Wed, 4 Aug 2010 15:44:23 -0700 Subject: fixed tests, moved compute network config call, added notes, made inject option into a boolean --- bin/nova-network | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'bin') diff --git a/bin/nova-network b/bin/nova-network index 1d620b525..ba9063f56 100755 --- a/bin/nova-network +++ b/bin/nova-network @@ -23,7 +23,6 @@ from nova import flags from nova import twistd -from nova import utils from nova.network import service @@ -34,8 +33,4 @@ if __name__ == '__main__': twistd.serve(__file__) if __name__ == '__builtin__': - t = FLAGS.network_type - if t == 'flat': - application = service.FlatNetworkService.create() - elif t == 'vlan': - application = service.VlanNetworkService.create() + application = service.type_to_class(FLAGS.network_type).create() -- cgit From d1709793045de2f77f4a1fb06f63d27cbcf640d1 Mon Sep 17 00:00:00 2001 From: Vishvananda Ishaya Date: Wed, 4 Aug 2010 18:37:00 -0700 Subject: clean up nova-manage. If vpn data isn't set for user it skips it --- bin/nova-manage | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) (limited to 'bin') diff --git a/bin/nova-manage b/bin/nova-manage index b0f0029ed..7835c7a77 100755 --- a/bin/nova-manage +++ b/bin/nova-manage @@ -29,16 +29,12 @@ from nova import flags from nova import utils from nova.auth import manager from nova.compute import model -from nova.compute import network from nova.cloudpipe import pipelib from nova.endpoint import cloud FLAGS = flags.FLAGS -class NetworkCommands(object): - def restart(self): - network.restart_nets() class VpnCommands(object): def __init__(self): @@ -170,6 +166,13 @@ class ProjectCommands(object): arguments: name""" self.manager.delete_project(name) + 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) + with open(filename, 'w') as f: + f.write(rc) + def list(self): """lists all projects arguments: """ @@ -182,14 +185,11 @@ class ProjectCommands(object): self.manager.remove_from_project(user, project) def zip(self, project_id, user_id, filename='nova.zip'): - """exports credentials for user to a zip file + """exports credentials for project to a zip file arguments: project_id user_id [filename='nova.zip]""" - project = self.manager.get_project(project_id) - if project: - with open(filename, 'w') as f: - f.write(project.get_credentials(user_id)) - else: - print "Project %s doesn't exist" % project + zip = self.manager.get_credentials(project_id, user_id) + with open(filename, 'w') as f: + f.write(zip) def usage(script_name): @@ -197,7 +197,6 @@ def usage(script_name): categories = [ - ('network', NetworkCommands), ('user', UserCommands), ('project', ProjectCommands), ('role', RoleCommands), -- cgit