コード例 #1
0
ファイル: test_utils.py プロジェクト: AsylumCorp/swift
 def test_parse_options(self):
     # use mkstemp to get a file that is definately on disk
     with NamedTemporaryFile() as f:
         conf_file = f.name
         conf, options = utils.parse_options(test_args=[conf_file])
         self.assertEquals(conf, conf_file)
         # assert defaults
         self.assertEquals(options['verbose'], False)
         self.assert_('once' not in options)
         # assert verbose as option
         conf, options = utils.parse_options(test_args=[conf_file, '-v'])
         self.assertEquals(options['verbose'], True)
         # check once option
         conf, options = utils.parse_options(test_args=[conf_file],
                                             once=True)
         self.assertEquals(options['once'], False)
         test_args = [conf_file, '--once']
         conf, options = utils.parse_options(test_args=test_args, once=True)
         self.assertEquals(options['once'], True)
         # check options as arg parsing
         test_args = [conf_file, 'once', 'plugin_name', 'verbose']
         conf, options = utils.parse_options(test_args=test_args, once=True)
         self.assertEquals(options['verbose'], True)
         self.assertEquals(options['once'], True)
         self.assertEquals(options['extra_args'], ['plugin_name'])
コード例 #2
0
ファイル: test_utils.py プロジェクト: jness/python-swift
 def test_parse_options(self):
     # use mkstemp to get a file that is definately on disk
     with NamedTemporaryFile() as f:
         conf_file = f.name
         conf, options = utils.parse_options(test_args=[conf_file])
         self.assertEquals(conf, conf_file)
         # assert defaults
         self.assertEquals(options['verbose'], False)
         self.assert_('once' not in options)
         # assert verbose as option
         conf, options = utils.parse_options(test_args=[conf_file, '-v'])
         self.assertEquals(options['verbose'], True)
         # check once option
         conf, options = utils.parse_options(test_args=[conf_file],
                                             once=True)
         self.assertEquals(options['once'], False)
         test_args = [conf_file, '--once']
         conf, options = utils.parse_options(test_args=test_args, once=True)
         self.assertEquals(options['once'], True)
         # check options as arg parsing
         test_args = [conf_file, 'once', 'plugin_name', 'verbose']
         conf, options = utils.parse_options(test_args=test_args, once=True)
         self.assertEquals(options['verbose'], True)
         self.assertEquals(options['once'], True)
         self.assertEquals(options['extra_args'], ['plugin_name'])
コード例 #3
0
def main():
    """
    cloud-connector daemon entry point.

    Loads main config file from a S3 endpoint per environment configuration and
    then starts the wsgi server.
    """

    # We need to monkeypatch out the hash validation stuff
    monkeypatch_hash_validation()

    # We need to monkeypatch swift3 request class determination so we can
    # override some behavior in multipart uploads
    monkeypatch_swift3_requests()

    env_options = get_env_options()

    get_and_write_conf_file_from_s3(env_options['CONF_NAME'],
                                    CLOUD_CONNECTOR_CONF_PATH, env_options)
    sys.argv.insert(1, CLOUD_CONNECTOR_CONF_PATH)

    conf_file, options = utils.parse_options()
    # Calling this "proxy-server" in the pipeline is a little white lie to keep
    # the swift3 pipeline check from blowing up.
    sys.exit(wsgi.run_wsgi(conf_file, 'proxy-server', **options))
コード例 #4
0
ファイル: replicator.py プロジェクト: mba811/kinetic-swift
def main():
    try:
        if not os.path.exists(sys.argv[1]):
            sys.argv.insert(1, '/etc/swift/kinetic.conf')
    except IndexError:
        pass
    parser = OptionParser("%prog CONFIG [options]")
    parser.add_option('-d', '--devices',
                      help='Replicate only given devices. '
                           'Comma-separated list')
    conf_file, options = parse_options(parser, once=True)
    run_daemon(KineticReplicator, conf_file,
               section_name='object-replicator', **options)
コード例 #5
0
def main():
    try:
        if not os.path.exists(sys.argv[1]):
            sys.argv.insert(1, '/etc/swift/kinetic.conf')
    except IndexError:
        pass
    parser = OptionParser("%prog CONFIG [options]")
    parser.add_option('-d', '--devices',
                      help='Replicate only given devices. '
                           'Comma-separated list')
    conf_file, options = parse_options(parser, once=True)
    run_daemon(KineticReplicator, conf_file,
               section_name='object-replicator', **options)
コード例 #6
0
ファイル: test_utils.py プロジェクト: colecrawford/swift
 def test_parse_options(self):
     # use mkstemp to get a file that is definately on disk
     with NamedTemporaryFile() as f:
         conf_file = f.name
         conf, options = utils.parse_options(test_args=[conf_file])
         self.assertEquals(conf, conf_file)
         # assert defaults
         self.assertEquals(options["verbose"], False)
         self.assert_("once" not in options)
         # assert verbose as option
         conf, options = utils.parse_options(test_args=[conf_file, "-v"])
         self.assertEquals(options["verbose"], True)
         # check once option
         conf, options = utils.parse_options(test_args=[conf_file], once=True)
         self.assertEquals(options["once"], False)
         test_args = [conf_file, "--once"]
         conf, options = utils.parse_options(test_args=test_args, once=True)
         self.assertEquals(options["once"], True)
         # check options as arg parsing
         test_args = [conf_file, "once", "plugin_name", "verbose"]
         conf, options = utils.parse_options(test_args=test_args, once=True)
         self.assertEquals(options["verbose"], True)
         self.assertEquals(options["once"], True)
         self.assertEquals(options["extra_args"], ["plugin_name"])
コード例 #7
0
#!/usr/bin/env python


from swift.container.replicator import ContainerReplicator
from swift.common.utils import parse_options, readconf

conf, options = parse_options(once=True)
conf = readconf(conf, section_name="container-replicator")

replicator = ContainerReplicator(conf)
replicator.run_once()
コード例 #8
0
#!/usr/bin/env python
# Copyright (c) 2014 OpenStack Foundation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.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
from swift.common.utils import parse_options
from swift.common import utils

utils.SWIFT_CONF_FILE = 'conf/swift.conf'

from swift.common.wsgi import run_wsgi

if __name__ == '__main__':
    server = sys.argv.pop(1)
    port = sys.argv.pop(1)
    conf_file, options = parse_options()
    sys.exit(run_wsgi(conf_file, server + '-server', default_port=port,
                      **options))
コード例 #9
0
#!/usr/bin/env python
# Copyright (c) 2014 OpenStack Foundation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.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
from swift.common.utils import parse_options
from swift.common import utils

utils.SWIFT_CONF_FILE = 'conf/swift.conf'

from swift.common.wsgi import run_wsgi

if __name__ == '__main__':
    server = sys.argv.pop(1)
    port = sys.argv.pop(1)
    conf_file, options = parse_options()
    sys.exit(
        run_wsgi(conf_file, server + '-server', default_port=port, **options))
コード例 #10
0
from swift.container import sharder
from swift.common.utils import parse_options, readconf

conf, options = parse_options(once=True)
conf = readconf(conf, section_name="container-sharder")

shard = sharder.ContainerSharder(conf, **options)
shard.run_once()