Пример #1
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 time

from eventlet import event
from eventlet import greenthread

from entropy.openstack.common.gettextutils import _LE, _LW
from entropy.openstack.common import log as logging

LOG = logging.getLogger(__name__)

# NOTE(zyluo): This lambda function was declared to avoid mocking collisions
#              with time.time() called in the standard logging module
#              during unittests.
_ts = lambda: time.time()


class LoopingCallDone(Exception):
    """Exception to break out and stop a LoopingCallBase.

    The poll-function passed to LoopingCallBase can raise this exception to
    break out of the loop normally. This is somewhat analogous to
    StopIteration.

    An optional return-value can be included as the argument to the exception;
Пример #2
0
               help='Region name to use for OpenStack service endpoints.'),
    cfg.StrOpt('os-endpoint-type',
               default=os.environ.get('OS_ENDPOINT_TYPE', 'publicURL'),
               help='Type of endpoint in Identity service catalog to use for '
                    'communication with OpenStack services.'),
    cfg.BoolOpt('insecure',
                default=False,
                help='Disables X.509 certificate validation when an '
                     'SSL connection to Identity Service is established.'),
]
cfg.CONF.register_cli_opts(CLI_OPTIONS, group="service_credentials")

cfg.CONF.import_opt('default_log_levels',
                    'entropy.openstack.common.log')

LOG = log.getLogger(__name__)


def prepare_service(argv=None):
    cfg.CONF(project='entropy')
    log.setup('entropy')
    cfg.CONF.log_opt_values(LOG, logging.DEBUG)

    gettextutils.install('entropy')
    gettextutils.enable_lazy()

    cfg.set_defaults(log.log_opts)
    if argv is None:
        argv = sys.argv
    cfg.CONF(argv[1:], project='entropy')