fix context in bin files
This commit is contained in:
		@@ -60,8 +60,7 @@ def add_lease(mac, ip_address, _hostname, _interface):
 | 
			
		||||
        rpc.cast(context.get_admin_context(),
 | 
			
		||||
                 "%s.%s" % (FLAGS.network_topic, FLAGS.host),
 | 
			
		||||
                 {"method": "lease_fixed_ip",
 | 
			
		||||
                  "args": {"context": None,
 | 
			
		||||
                           "mac": mac,
 | 
			
		||||
                  "args": {"mac": mac,
 | 
			
		||||
                           "address": ip_address}})
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -82,8 +81,7 @@ def del_lease(mac, ip_address, _hostname, _interface):
 | 
			
		||||
        rpc.cast(context.get_admin_context(),
 | 
			
		||||
                 "%s.%s" % (FLAGS.network_topic, FLAGS.host),
 | 
			
		||||
                 {"method": "release_fixed_ip",
 | 
			
		||||
                  "args": {"context": None,
 | 
			
		||||
                           "mac": mac,
 | 
			
		||||
                  "args": {"mac": mac,
 | 
			
		||||
                           "address": ip_address}})
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -67,13 +67,13 @@ 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 context
 | 
			
		||||
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.network import manager as network_manager
 | 
			
		||||
from nova.cloudpipe import pipelib
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -121,7 +121,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(None):
 | 
			
		||||
        for instance in db.instance_get_all(context.get_admin_context()):
 | 
			
		||||
            if (instance['image_id'] == FLAGS.vpn_image_id
 | 
			
		||||
                and not instance['state_description'] in
 | 
			
		||||
                    ['shutting_down', 'shutdown']
 | 
			
		||||
@@ -323,13 +323,14 @@ class ProjectCommands(object):
 | 
			
		||||
    def quota(self, project_id, key=None, value=None):
 | 
			
		||||
        """Set or display quotas for project
 | 
			
		||||
        arguments: project_id [key] [value]"""
 | 
			
		||||
        ctxt = context.get_admin_context()
 | 
			
		||||
        if key:
 | 
			
		||||
            quo = {'project_id': project_id, key: value}
 | 
			
		||||
            try:
 | 
			
		||||
                db.quota_update(None, project_id, quo)
 | 
			
		||||
                db.quota_update(ctxt, project_id, quo)
 | 
			
		||||
            except exception.NotFound:
 | 
			
		||||
                db.quota_create(None, quo)
 | 
			
		||||
        project_quota = quota.get_quota(None, project_id)
 | 
			
		||||
                db.quota_create(ctxt, quo)
 | 
			
		||||
        project_quota = quota.get_quota(ctxt, project_id)
 | 
			
		||||
        for key, value in project_quota.iteritems():
 | 
			
		||||
            print '%s: %s' % (key, value)
 | 
			
		||||
 | 
			
		||||
@@ -353,23 +354,26 @@ class FloatingIpCommands(object):
 | 
			
		||||
        """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),
 | 
			
		||||
            db.floating_ip_create(context.get_admin_context(),
 | 
			
		||||
                                  {'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))
 | 
			
		||||
            db.floating_ip_destroy(context.get_admin_context(),
 | 
			
		||||
                                   str(address))
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    def list(self, host=None):
 | 
			
		||||
        """Lists all floating ips (optionally by host)
 | 
			
		||||
        arguments: [host]"""
 | 
			
		||||
        ctxt = context.get_admin_context()
 | 
			
		||||
        if host == None:
 | 
			
		||||
            floating_ips = db.floating_ip_get_all(None)
 | 
			
		||||
            floating_ips = db.floating_ip_get_all(ctxt)
 | 
			
		||||
        else:
 | 
			
		||||
            floating_ips = db.floating_ip_get_all_by_host(None, host)
 | 
			
		||||
            floating_ips = db.floating_ip_get_all_by_host(ctxt, host)
 | 
			
		||||
        for floating_ip in floating_ips:
 | 
			
		||||
            instance = None
 | 
			
		||||
            if floating_ip['fixed_ip']:
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user