diff options
| author | Vishvananda Ishaya <vishvananda@yahoo.com> | 2010-09-09 11:18:13 -0700 |
|---|---|---|
| committer | Vishvananda Ishaya <vishvananda@yahoo.com> | 2010-09-09 11:18:13 -0700 |
| commit | d4a7e6e22fafacb031d8b951bf1608888b4d18e3 (patch) | |
| tree | a2f34ec48384bef33c637b1def2e30fe53191f73 /bin | |
| parent | 1f1422d5f262b20f4fa6266a3d62615d013d832c (diff) | |
| parent | cb0953a578b55e873a090f2ed46e879183aa3eb0 (diff) | |
merged support code from orm branch
Diffstat (limited to 'bin')
| -rwxr-xr-x | bin/nova-manage | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/bin/nova-manage b/bin/nova-manage index ecef5d555..56191252a 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,44 @@ 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: + 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), ('project', ProjectCommands), ('role', RoleCommands), ('vpn', VpnCommands), + ('floating', FloatingIpCommands) ] |
