示例#1
0
def main():
    """Start the squid service."""
    development_ports()

    service_name, config_template = sys.argv[1:3]
    squid_bin = "/usr/sbin/squid3"
    port = settings.STORAGE_PROXY_PORT
    if not port:
        port = allocate_ports()[0]
        register_local_port(service_name, port, ssl=False)

    tmp_dir = utils.get_tmpdir()
    conffile_path = os.path.join(tmp_dir, '%s.conf' % service_name)
    s3_dstssl = int(settings.aws.S3_PORT) == 443 and "ssl" or ""
    swift_dstssl = int(settings.aws.KEYSTONE_PORT) == 443 and "ssl" or ""

    with open(conffile_path, 'w') as config_out:
        with open(config_template, 'r') as config_in:
            config_out.write(config_in.read().format(
                s3_dstdomain=settings.aws.S3_HOST,
                s3_dstport=settings.aws.S3_PORT,
                s3_dstssl=s3_dstssl,
                swift_dstdomain=settings.aws.KEYSTONE_HOST,
                swift_dstport=settings.aws.KEYSTONE_PORT,
                swift_dstssl=swift_dstssl,
                service_name=service_name,
                tmpdir=tmp_dir,
                port=port))

    subprocess.call([squid_bin, '-f', conffile_path, '-z'])
    os.execvp(squid_bin, [squid_bin, '-f', conffile_path,
                          '-N', '-Y', '-C'])
    def ensure_port_tmpdir(self):
        """Ensure that tmp dir exists."""
        tmpdir = utils.get_tmpdir()
        if not os.path.exists(tmpdir):
            os.mkdir(tmpdir)

        return tmpdir
    def ensure_port_tmpdir(self):
        """Ensure that tmp dir exists."""
        tmpdir = utils.get_tmpdir()
        if not os.path.exists(tmpdir):
            os.mkdir(tmpdir)

        return tmpdir
def start():
    """Start Postgres."""
    sock_dir = os.path.join(get_tmpdir(), "db1")
    data_dir = os.path.join(sock_dir, "data")
    pidfile = os.path.join(data_dir, "postmaster.pid")

    if is_running("postgres", pidfile, "postgres"):
        print "Postgres already up & running."
        return 0

    pg_bin = None
    for path in ("/usr/lib/postgresql/9.1/bin",
                 "/usr/lib/postgresql/8.4/bin"):
        if os.path.isdir(path):
            pg_bin = path
            break

    if pg_bin is None:
        print "Cannot find valid parent for PGBINDIR"
        return 1

    pg_port = local.allocate_ports(1)[0]
    local.register_local_port("postgres", pg_port)
    os_exec(os.path.join(pg_bin, "postgres"),
            "-D", data_dir,
            "-k", sock_dir,
            "-i", "-h", "127.0.0.1",
            "-p", str(pg_port))
示例#5
0
def main():
    """Start the squid service."""
    service_name, config_template = sys.argv[1:3]
    squid_bin = "/usr/sbin/squid3"
    port = config.storage_proxy.port
    if not port:
        port = allocate_ports()[0]
        register_local_port(service_name, port, ssl=False)

    tmp_dir = utils.get_tmpdir()
    conffile_path = os.path.join(tmp_dir, '%s.conf' % service_name)
    with open(conffile_path, 'w') as config_out:
        with open(config_template, 'r') as config_in:
            config_out.write(config_in.read().format(
                s3_dstdomain=config.aws_s3.host,
                s3_dstport=config.aws_s3.port,
                s3_dstssl=int(config.aws_s3.port) == 443 and "ssl" or "",
                swift_dstdomain=config.keystone.host,
                swift_dstport=config.keystone.port,
                swift_dstssl=int(config.keystone.port) == 443 and "ssl" or "",
                service_name=service_name,
                tmpdir=tmp_dir,
                port=port))

    subprocess.call([squid_bin, '-f', conffile_path, '-z'])
    os.execvp(squid_bin, [squid_bin, '-f', conffile_path,
                          '-N', '-Y', '-C'])
示例#6
0
def main():
    """Start the squid service."""
    service_name, config_template = sys.argv[1:3]
    squid_bin = "/usr/sbin/squid3"
    port = config.storage_proxy.port
    if not port:
        port = allocate_ports()[0]
        register_local_port(service_name, port, ssl=False)

    tmp_dir = utils.get_tmpdir()
    conffile_path = os.path.join(tmp_dir, '%s.conf' % service_name)
    with open(conffile_path, 'w') as config_out:
        with open(config_template, 'r') as config_in:
            config_out.write(config_in.read().format(
                s3_dstdomain=config.aws_s3.host,
                s3_dstport=config.aws_s3.port,
                s3_dstssl=int(config.aws_s3.port) == 443 and "ssl" or "",
                swift_dstdomain=config.keystone.host,
                swift_dstport=config.keystone.port,
                swift_dstssl=int(config.keystone.port) == 443 and "ssl" or "",
                service_name=service_name,
                tmpdir=tmp_dir,
                port=port))

    subprocess.call([squid_bin, '-f', conffile_path, '-z'])
    os.execvp(squid_bin, [squid_bin, '-f', conffile_path, '-N', '-Y', '-C'])
示例#7
0
def start():
    """Start Postgres."""
    sock_dir = os.path.join(get_tmpdir(), "db1")
    data_dir = os.path.join(sock_dir, "data")
    pidfile = os.path.join(data_dir, "postmaster.pid")

    if is_running("postgres", pidfile, "postgres"):
        print "Postgres already up & running."
        return 0

    pg_bin = None
    for path in ("/usr/lib/postgresql/9.1/bin", "/usr/lib/postgresql/8.4/bin"):
        if os.path.isdir(path):
            pg_bin = path
            break

    if pg_bin is None:
        print "Cannot find valid parent for PGBINDIR"
        return 1

    pg_port = local.allocate_ports(1)[0]
    local.register_local_port("postgres", pg_port)
    os_exec(os.path.join(pg_bin, "postgres"), "-D", data_dir, "-k", sock_dir,
            "-i", "-h", "127.0.0.1", "-p", str(pg_port))
示例#8
0
#
# For further info, check  http://launchpad.net/magicicada-server

"""Start txstatsd."""

import sys
import os
import socket
import time
import platform

from utilities.utils import get_tmpdir
import utilities.localendpoints as local


TMP_DIR = get_tmpdir()
statsd_log = os.path.join(TMP_DIR, "statsd.log")

# allocate and register port
statsd_port, = local.allocate_ports(1)
local.register_local_port("statsd", statsd_port)

# wait for graphite to be done
carbon_port = local.get_local_port("carbon_pickle_receiver")
s = socket.socket()
for i in range(30):
    try:
        s.connect(("localhost", carbon_port))
        break
    except socket.error:
        time.sleep(2)
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# For further info, check  http://launchpad.net/magicicada-server
"""Start supervisord."""

import os
import sys

from utilities.utils import os_exec, is_running, get_tmpdir, get_rootdir
import utilities.localendpoints as local

ROOT_DIR = get_rootdir()
TMP_DIR = get_tmpdir()


def write_conf(tpl, inet_http_server_port):
    """Write out filled in conf template in tmp."""
    template = open(os.path.join(ROOT_DIR, tpl)).read()

    template_vars = {
        'inet_http_server_port': inet_http_server_port,
        'basepath': ROOT_DIR,
        'tmp_dir': TMP_DIR,
        'pythonpath': ':'.join(filter(None, sys.path)),
    }

    conf = template % template_vars
示例#10
0
 def test_db_dir(self):
     """Test db_dir points to tmp inside config.root."""
     expected = os.path.join(get_tmpdir(), 'db')
     self.assertTrue(db_dir.startswith(expected),
                     'db_dir (%r) must start with %r' % (db_dir, expected))
示例#11
0
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# For further info, check  http://launchpad.net/filesync-server

"""Database connection specific configuration settings."""

import os
import urllib

from config import config
from utilities.utils import get_tmpdir
from utilities.localendpoints import get_local_server

db_dir = os.path.abspath(os.path.join(get_tmpdir(), 'db1'))
conn_settings = None


def get_connection_settings():
    """Get a dict of connections settings."""
    global conn_settings
    if conn_settings is None:

        # try to get live config from db server, else defaults
        local_server = get_local_server("postgres")
        if local_server is not None:
            default_host, default_port = local_server.split(":")
            default_port = int(default_port)
        else:
            default_host = None
示例#12
0
 def test_db_dir(self):
     """Test db_dir points to tmp inside config.root."""
     expected = os.path.join(get_tmpdir(), 'db')
     self.assertTrue(db_dir.startswith(expected),
                     'db_dir (%r) must start with %r' % (db_dir, expected))