Esempio n. 1
0
from nova import db as nova_db
from glance.db.sqlalchemy import api as glance_db
from glance.openstack.common import cfg as glance_cfg

import glance.db.sqlalchemy.models as glance_model 

import functools
import nova.context as context
import nova.flags as nova_flags
import simplejson as json
import datetime
import sqlalchemy
import utils.logging_utils as logging


LOG = logging.getLogger(__name__, 'db_client.log')

#Force read configuration files
nova_flags.parse_args(['compute', '--config-file', '/etc/nova/nova.conf'], None)
glance_cfg.CONF(['glance', '--config-file', '/etc/glance/glance-api.conf'])

# setup database engine
glance_db.configure_db()

logging.setLevel('sqlalchemy.orm', "WARNING")
logging.setLevel('sqlalchemy.engine', "WARNING")
logging.setLevel(__name__, 'DEBUG')


def to_json(res, ignore_types=()):
    if not res:
Esempio n. 2
0
@author: chenshunzi
'''
import os
import fnmatch
import simplejson as json
import datetime
import optparse
import utils.logging_utils as logging
import codecs
import sys

#Change stdout encoding.
sys.stdout = codecs.getwriter('utf8')(sys.stdout)

logging.config_as_default()
LOG = logging.getLogger("sync_file", "sync_file.log")


def get_parser():
    parser = optparse.OptionParser(usage='''
        Utility for synchronize files between folders.
    ''')
    parser.add_option('-s', '--source', action='store', type='string', dest='src',
                     default='.',
                     help='source folder')
    parser.add_option('-d', '--dest', action='store', type='string', dest='dest',
                      help='destination folder')
    parser.add_option('-p', '--pattern', action='append', type='string', dest='pattern',
                      default=['*'], help='filter files by pattern')
    parser.add_option('-f', '--file', action='store', type='string', dest='fname',
                      default=None, help='file name for the result file')
Esempio n. 3
0
'''


import os
import optparse
import utils.logging_utils as logging
import codecs
import sys
import shutil


#Change stdout encoding.
sys.stdout = codecs.getwriter('utf8')(sys.stdout)

logging.config_as_default()
LOG = logging.getLogger("project_creation", "project_creation.log")


IGNORE_LIST = [u'target']


def _formalize(path):
    path = os.path.abspath(path)
    path = unicode(path)
    if not path.endswith(os.path.sep):
        path += os.path.sep
    return path
    

def _last_folder(path):
    return path[path.rfind(os.path.sep) + 1]
Esempio n. 4
0
@author: chenshunzi
'''

import utils.logging_utils as logging
import subprocess
import simplejson as json
import optparse
import os
from keystone import config
from keystone.common import sql
from keystone.token.backends.sql import TokenModel


logging.config_as_default()
LOG = logging.getLogger(__name__, 'simpleclient.log')
Popen = subprocess.Popen
CONF = config.CONF
try:
    CONF(project='keystone')
except TypeError:
    CONF()


def request(url, method='GET', body=None, headers={}, conn_cache=None):
    '''
    Make request and return the response as result.
    
    @param url: full path, like 'http://123.com/action?param=value'.
    @param body: should be a string.
    @param conn_cache: a dictionary where connections are looked up by network locations of