예제 #1
0
 def get_db_connection(self):
     if not hasattr(self.cloud.config, self.cloud.position + '_compute'):
         LOG.debug('Running on default mysql settings')
         return mysql_connector.MysqlConnector(self.config.mysql, 'nova')
     else:
         LOG.debug('Running on custom mysql settings')
         my_settings = getattr(self.cloud.config,
                               self.cloud.position + '_compute')
         return mysql_connector.MysqlConnector(my_settings,
                                               my_settings.db_name)
예제 #2
0
 def __init__(self, config, cloud):
     super(NovaCompute, self).__init__()
     self.config = config
     self.cloud = cloud
     self.identity = cloud.resources['identity']
     self.mysql_connector = mysql_connector.MysqlConnector(config.mysql,
                                                           'nova')
     self.nova_client = self.proxy(self.get_client(), config)
예제 #3
0
 def get_db_connection(db_name):
     conf_res = getattr(config, resource)
     conf = {
         k: getattr(conf_res, k, None) if getattr(conf_res, k, None)
         else config.mysql[k]
         for k in config.mysql.keys()}
     db_name_use = getattr(conf_res, 'database_name')\
         if getattr(conf_res, 'database_name', None) else db_name
     return mysql_connector.MysqlConnector(conf, db_name_use)
예제 #4
0
파일: cloud.py 프로젝트: miarmak/CloudFerry
    def init_resources(self, cloud_config):
        resources = self.resources
        self.resources = dict()
        self.mysql_connector = mysql_connector.MysqlConnector(
            getattr(self.config, "%s_mysql" % self.position), 'cinder')
        self.rbd_util = rbd_util.RbdUtil(
            getattr(self.config, "%s" % self.position), self.config.migrate)
        self.qemu_img = qemu_img.QemuImg(
            getattr(self.config, "%s" % self.position), self.config.migrate)
        self.ssh_util = ssh_util.SshUtil(
            getattr(self.config, "%s" % self.position), self.config.migrate)

        identity_conf = self.make_resource_config(self.config, self.position,
                                                  cloud_config, 'identity')
        identity = resources['identity'](identity_conf, self)
        self.resources['identity'] = identity

        for resource in resources:
            if resource != 'identity':
                resource_config = self.make_resource_config(
                    self.config, self.position, cloud_config, resource)
                self.resources[resource] = resources[resource](resource_config,
                                                               self)
예제 #5
0
 def update_column(self, table_name, column_name, new_value):
     connector = mysql_connector.MysqlConnector(self.config.mysql, 'cinder')
     connector.execute("UPDATE %s SET %s='%s'" %
                       (table_name, column_name, new_value))
예제 #6
0
 def upload_table_to_db(self, table_name, file_name):
     connector = mysql_connector.MysqlConnector(self.config.mysql, 'cinder')
     connector.execute("LOAD DATA INFILE '%s' INTO TABLE %s" %
                       (file_name, table_name))
예제 #7
0
 def download_table_from_db_to_file(self, table_name, file_name):
     connector = mysql_connector.MysqlConnector(self.config.mysql, 'cinder')
     connector.execute("SELECT * FROM %s INTO OUTFILE '%s';" %
                       (table_name, file_name))