Ejemplo n.º 1
0
def main():
    global_conf.logging()

    utils.default_flagfile("nova.conf")
    flags.FLAGS(sys.argv)
    FLAGS = flags.FLAGS
    conf = global_conf._conf
    for param in ("rabbit_host", "rabbit_port", "rabbit_userid",
                  "rabbit_password", "rabbit_virtual_host",
                  "rabbit_durable_queues", "control_exchange"):
        conf[param] = getattr(FLAGS, param)

    nova_api_config = ConfigParser()
    nova_api_config.read(["/etc/nova/api-paste.ini"])
    keystone_conf = {}
    conf_map = {
        "auth_uri": "auth_uri",
        "admin_tenant_name": "tenant_name",
        "admin_user": "******",
        "admin_password": "******"
    }
    for param_nova, param_client in conf_map.iteritems():
        try:
            value = nova_api_config.get("filter:authtoken", param_nova)
        except Exception as e:
            print e
        else:
            keystone_conf[param_client] = value
    conf["keystone_conf"] = keystone_conf
    json.dump(conf, open(CONFIG_FILE, "w"), indent=4, sort_keys=True)
Ejemplo n.º 2
0
def main():
    global_conf.logging()

    utils.default_flagfile("nova.conf")
    flags.FLAGS(sys.argv)
    FLAGS = flags.FLAGS
    conf = global_conf._conf
    for param in ("rabbit_host",
                  "rabbit_port",
                  "rabbit_userid",
                  "rabbit_password",
                  "rabbit_virtual_host",
                  "rabbit_durable_queues",
                  "control_exchange"):
        conf[param] = getattr(FLAGS, param)

    nova_api_config = ConfigParser()
    nova_api_config.read(["/etc/nova/api-paste.ini"])
    keystone_conf = {}
    conf_map = {"auth_uri": "auth_uri",
                "admin_tenant_name": "tenant_name",
                "admin_user": "******",
                "admin_password": "******"}
    for param_nova, param_client in conf_map.iteritems():
        try:
            value = nova_api_config.get("filter:authtoken", param_nova)
        except Exception as e:
            print e
        else:
            keystone_conf[param_client] = value
    conf["keystone_conf"] = keystone_conf
    json.dump(conf, open(CONFIG_FILE, "w"), indent=4, sort_keys=True)
Ejemplo n.º 3
0
 def load_nova_conf(self):
     try:
         from nova import flags
         from nova import utils
         utils.default_flagfile(self.nova_conf)
         flags.FLAGS(sys.argv)
         self._FLAGS = flags.FLAGS
     except Exception:
         LOG.exception("cannot load nova flags")
Ejemplo n.º 4
0
 def load_nova_conf(self):
     try:
         from nova import flags
         from nova import utils
         utils.default_flagfile(self.nova_conf)
         flags.FLAGS(sys.argv)
         self._FLAGS = flags.FLAGS
     except Exception:
         LOG.exception("cannot load nova flags")
Ejemplo n.º 5
0
def connect_db():
    keystone.manage.parse_args(None)

    from nova import flags
    from nova import utils
    FLAGS = flags.FLAGS
    utils.default_flagfile()
    flags.FLAGS(sys.argv)
    global nova_engine
    nova_engine = get_engine()
Ejemplo n.º 6
0
def connect_db():
    keystone.manage.parse_args(None)

    from nova import flags
    from nova import utils
    FLAGS = flags.FLAGS
    utils.default_flagfile()
    flags.FLAGS(sys.argv)
    global nova_engine
    nova_engine = get_engine()
Ejemplo n.º 7
0
import datetime
from decimal import Decimal
import unittest
import sys

from dough import context as dough_context
from dough import db
from dough import exception

from nova import flags
from nova import utils
from nova.db.sqlalchemy.session import get_engine

utils.default_flagfile(filename='/etc/dough/dough.conf')
flags.FLAGS(sys.argv)

FLAGS = flags.FLAGS


class DBApiTestCase(unittest.TestCase):

    def setUp(self):
        super(DBApiTestCase, self).setUp()
        engine = get_engine()
        self.connection = engine.connect()
        self.tenant_id = 'atenant'
        self.context = dough_context.get_context(tenant_id=self.tenant_id)
        self.resource_uuid = 'a-fake-uuid-0'
        self.resource_name = 'a_fake_name_0'
        self.region_name = 'default'
        self.item_name = 'instance'
Ejemplo n.º 8
0
    if opts.ssl_only and not os.path.exists(opts.cert):
        parser.error("SSL only and %s not found" % opts.cert)

    # Parse host:port and convert ports to numbers
    if args[0].count(':') > 0:
        opts.listen_host, opts.listen_port = args[0].rsplit(':', 1)
    else:
        opts.listen_host, opts.listen_port = '', args[0]

    try:
        opts.listen_port = int(opts.listen_port)
    except:
        parser.error("Error parsing listen port")

    # Dummy values that wsproxy expects
    opts.target_host = 'ignore'
    opts.target_port = 'ignore'

    # Setup flags
    utils.default_flagfile()
    FLAGS(sys.argv)

    # FIXME - the proxy base class does not recognize the flagfile
    # option so remove if present
    if opts.__dict__.get('flagfile'):
        del opts.__dict__['flagfile']

    # Create and start the NovaWebSockets proxy
    server = NovaWebSocketProxy(**opts.__dict__)
    server.start_server()
from nova import utils

from nova.virt.xenapi import connection as xenapi_conn


flags.DECLARE("resize_confirm_window", "nova.compute.manager")
flags.DECLARE("xenapi_connection_url", "nova.virt.xenapi.connection")
flags.DECLARE("xenapi_connection_username", "nova.virt.xenapi.connection")
flags.DECLARE("xenapi_connection_password", "nova.virt.xenapi.connection")

FLAGS = flags.FLAGS
# NOTE(sirp): Nova futzs with the sys.argv in order to provide default
# flagfile. To isolate this awful practice, we're supplying a dummy
# argument list.
dummy = ["fakearg"]
utils.default_flagfile(args=dummy)
FLAGS(dummy)


class UnrecognizedNameLabel(Exception):
    pass


def parse_options():
    """Generate command line options."""

    ALLOWED_COMMANDS = ["list-vdis", "clean-vdis", "list-instances",
                        "clean-instances", "test"]
    arg_str = "|".join(ALLOWED_COMMANDS)
    parser = optparse.OptionParser("%prog [options] [" + arg_str + "]")
    parser.add_option("--verbose", action="store_true")
Ejemplo n.º 10
0
flags.DECLARE('num_networks', 'nova.network.manager')
flags.DECLARE('multi_host', 'nova.network.manager')
flags.DECLARE('network_size', 'nova.network.manager')
flags.DECLARE('vlan_start', 'nova.network.manager')
flags.DECLARE('vpn_start', 'nova.network.manager')
flags.DECLARE('default_floating_pool', 'nova.network.manager')
flags.DECLARE('public_interface', 'nova.network.linux_net')

# Decorators for actions
def args(*args, **kwargs):
    def _decorator(func):
        func.__dict__.setdefault('options', []).insert(0, (args, kwargs))
        return func
    return _decorator

flagfile = utils.default_flagfile('/etc/nova/nova.conf')

if flagfile and not os.access(flagfile, os.R_OK):
    st = os.stat(flagfile)
    print "Could not read %s. Re-running with sudo" % flagfile
    try:
        os.execvp('sudo', ['sudo', '-u', '#%s' % st.st_uid] + sys.argv)
    except Exception:
        print 'sudo failed, continuing as if nothing happened'
try:
    argv = FLAGS(sys.argv)
    logging.setup()
except IOError, e:
    if e.errno == errno.EACCES:
        print _('Please re-run nova-manage as root.')
        sys.exit(2)
        else:
            nose_args.append(arg)

    # Many of the test decorators depend on configuration values, so before
    # start importing modules we have to load the test config followed by the
    # flag files.

    from tests import WHITE_BOX

    if WHITE_BOX:  # If white-box testing, set up the flags.
        # Set up the flag file values, which we need to call certain Nova code.
        from tests.util import test_config
        nova_conf = test_config.values["nova_conf"]

        from nova import utils
        utils.default_flagfile(str(nova_conf))

        from nova import flags
        FLAGS = flags.FLAGS
        FLAGS(sys.argv)

    # Set up the report, and print out how we're running the tests.
    from tests.util import report
    from datetime import datetime
    report.log("Reddwarf Integration Tests, %s" % datetime.now())
    report.log("Invoked via command: " + str(sys.argv))
    report.log("Groups = " + str(groups))
    report.log("Test conf file = %s" % os.environ["TEST_CONF"])
    if WHITE_BOX:
        report.log("")
        report.log("Test FLAG file = %s" % nova_conf)
Ejemplo n.º 12
0
from nova import utils

from nova.virt import xenapi_conn


flags.DECLARE("resize_confirm_window", "nova.compute.manager")
flags.DECLARE("xenapi_connection_url", "nova.virt.xenapi_conn")
flags.DECLARE("xenapi_connection_username", "nova.virt.xenapi_conn")
flags.DECLARE("xenapi_connection_password", "nova.virt.xenapi_conn")

FLAGS = flags.FLAGS
# NOTE(sirp): Nova futzs with the sys.argv in order to provide default
# flagfile. To isolate this awful practice, we're supplying a dummy
# argument list.
dummy = ["fakearg"]
utils.default_flagfile(args=dummy)
FLAGS(dummy)


class UnrecognizedNameLabel(Exception):
    pass


def parse_options():
    """Generate command line options."""

    ALLOWED_COMMANDS = ["list-vdis", "clean-vdis", "list-instances",
                        "clean-instances", "test"]
    arg_str = "|".join(ALLOWED_COMMANDS)
    parser = optparse.OptionParser("%prog [options] [" + arg_str + "]")
    parser.add_option("--verbose", action="store_true")
from nova import flags

from nova import db
from nova import context
from nova import log as logging
from nova import utils
from nova import version
from nova.compute import manager as compute_manager

__worker__ = None
__lock__ = threading.Lock()

FLAGS = flags.FLAGS
args = ['compute-metrics']
utils.default_flagfile(args=args)
print args
flags.FLAGS(args)
print FLAGS.sql_connection


class UpdateComputeNodeStatusThread(threading.Thread):
    """Updates compute node status."""

    def __init__(self, params):
        print 'starting init'
        threading.Thread.__init__(self)
        self.manager          = compute_manager.ComputeManager()
        self.running          = False
        self.shuttingdown     = False
        self.refresh_rate     = int(params['refresh_rate'])
Ejemplo n.º 14
0
from nova import flags

from nova import db
from nova import context
from nova import log as logging
from nova import utils
from nova import version
from nova.compute import manager as compute_manager

__worker__ = None
__lock__ = threading.Lock()

FLAGS = flags.FLAGS
args = ['compute-metrics']
utils.default_flagfile(args=args)
print args
flags.FLAGS(args)
print FLAGS.sql_connection


class UpdateComputeNodeStatusThread(threading.Thread):
    """Updates compute node status."""
    def __init__(self, params):
        print 'starting init'
        threading.Thread.__init__(self)
        self.manager = compute_manager.ComputeManager()
        self.running = False
        self.shuttingdown = False
        self.refresh_rate = int(params['refresh_rate'])
        self.status = {}
Ejemplo n.º 15
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.

import sys
import json
import zmq

from nova import utils
from nova import flags
from nova.openstack.common import cfg
from nova import log as logging

utils.default_flagfile(filename="/etc/dough/dough.conf")
logging.setup()


api_opts = [
    cfg.StrOpt("api_host", default="172.19.8.1", help="IP address of dough API."),
    cfg.IntOpt("api_port", default=5554, help="Port of dough api."),
]

cli_opts = [
    cfg.StrOpt("monthly_report", short="m", default="name1", help="monthly_report."),
    cfg.StrOpt("subscribe_item", short="s", default="default1", help="subscribe_item."),
    cfg.StrOpt("unsubscribe_item", short="u", default="default1", help="unsubscribe_item."),
    cfg.StrOpt("load_balancer", short="l", default="default1", help="load_balancer."),
    cfg.StrOpt("item_products", short="p", default="default1", help="item_products."),
]
Ejemplo n.º 16
0
import datetime
import unittest
import sys

from dough import context as dough_context
from dough import db
from dough import exception

from nova import flags
from nova import utils
from nova.db.sqlalchemy.session import get_engine

utils.default_flagfile(filename='/etc/dough/dough.conf')
flags.FLAGS(sys.argv)

FLAGS = flags.FLAGS


class DBApiTestCase(unittest.TestCase):
    def setUp(self):
        super(DBApiTestCase, self).setUp()
        engine = get_engine()
        self.connection = engine.connect()
        self.tenant_id = 'atenant'
        self.context = dough_context.get_context(tenant_id=self.tenant_id)
        self.resource_uuid = 'a-fake-uuid-0'
        self.resource_name = 'a_fake_name_0'
        self.region_name = 'default'
        self.item_name = 'instance'
        self.item_type_name = 'm1.tiny'
        self.payment_type_name = 'hourly'
Ejemplo n.º 17
0
    if opts.ssl_only and not os.path.exists(opts.cert):
        parser.error("SSL only and %s not found" % opts.cert)

    # Parse host:port and convert ports to numbers
    if args[0].count(':') > 0:
        opts.listen_host, opts.listen_port = args[0].rsplit(':', 1)
    else:
        opts.listen_host, opts.listen_port = '', args[0]

    try:
        opts.listen_port = int(opts.listen_port)
    except:
        parser.error("Error parsing listen port")

    # Dummy values that wsproxy expects
    opts.target_host = 'ignore'
    opts.target_port = 'ignore'

    # Setup flags
    utils.default_flagfile()
    FLAGS(sys.argv)

    # FIXME - the proxy base class does not recognize the flagfile
    # option so remove if present
    if  opts.__dict__.get('flagfile'):
        del opts.__dict__['flagfile']

    # Create and start the NovaWebSockets proxy
    server = NovaWebSocketProxy(**opts.__dict__)
    server.start_server()
Ejemplo n.º 18
0
        else:
            nose_args.append(arg)

    # Many of the test decorators depend on configuration values, so before
    # start importing modules we have to load the test config followed by the
    # flag files.

    from tests import WHITE_BOX

    if WHITE_BOX:  # If white-box testing, set up the flags.
        # Set up the flag file values, which we need to call certain Nova code.
        from tests.util import test_config
        nova_conf = test_config.values["nova_conf"]

        from nova import utils
        utils.default_flagfile(str(nova_conf))

        from nova import flags
        FLAGS = flags.FLAGS
        FLAGS(sys.argv)

    # Set up the report, and print out how we're running the tests.
    from tests.util import report
    from datetime import datetime
    report.log("Reddwarf Integration Tests, %s" % datetime.now())
    report.log("Invoked via command: " + str(sys.argv))
    report.log("Groups = " + str(groups))
    report.log("Test conf file = %s" % os.environ["TEST_CONF"])
    if WHITE_BOX:
        report.log("")
        report.log("Test FLAG file = %s" % nova_conf)