コード例 #1
0
    def _write_cluster_info(self):
        """Write cluster info into DB.

        Info includes:

            cluster_name
            file_system
            public_address
            secondary_public_address
            cluster_address
        """
        cluster_info = self._cluster_info['cluster']

        LOG.info(' cluster_info to db = %s' % \
            json.dumps(cluster_info, sort_keys=True, indent=4))

        cluster_name = cluster_info['cluster_name']

        cluster_ref = db.cluster_get_by_name(self._context,
                                             cluster_name)

        if not cluster_ref:
            LOG.info(' Have not find cluster = %s' % cluster_name)
            LOG.info(' Before Writing cluster = %s' % \
            json.dumps(cluster_info, sort_keys=True, indent=4))
            db.cluster_create(self._context, cluster_info)
        else:
            # NOTE we update the cluster info in DB.
            LOG.info(' Find cluster name = %s' % cluster_name)
            db.cluster_update(self._context,
                              cluster_ref['id'],
                              cluster_info)
            # If we find the cluster, we also return the keyring.admin
            # info for storage nodes.
            info_dict = cluster_ref['info_dict']
            if info_dict:
                LOG.info('Get info dict from DB.')
                keyring_admin = json.loads(info_dict).get('keyring_admin', None)
                self._cluster_info['keyring_admin'] = keyring_admin
            else:
                LOG.info('Can not get keyring from DB.')
            return True
コード例 #2
0
    def _write_cluster_info(self):
        """Write cluster info into DB.

        Info includes:

            cluster_name
            file_system
            public_address
            secondary_public_address
            cluster_address
        """
        cluster_info = self._cluster_info['cluster']

        LOG.info(' cluster_info to db = %s' % \
            json.dumps(cluster_info, sort_keys=True, indent=4))

        cluster_name = cluster_info['cluster_name']

        cluster_ref = db.cluster_get_by_name(self._context, cluster_name)

        if not cluster_ref:
            LOG.info(' Have not find cluster = %s' % cluster_name)
            LOG.info(' Before Writing cluster = %s' % \
            json.dumps(cluster_info, sort_keys=True, indent=4))
            db.cluster_create(self._context, cluster_info)
        else:
            # NOTE we update the cluster info in DB.
            LOG.info(' Find cluster name = %s' % cluster_name)
            db.cluster_update(self._context, cluster_ref['id'], cluster_info)
            # If we find the cluster, we also return the keyring.admin
            # info for storage nodes.
            info_dict = cluster_ref['info_dict']
            if info_dict:
                LOG.info('Get info dict from DB.')
                keyring_admin = json.loads(info_dict).get(
                    'keyring_admin', None)
                self._cluster_info['keyring_admin'] = keyring_admin
            else:
                LOG.info('Can not get keyring from DB.')
            return True
コード例 #3
0
 def cluster_create(self, context, values):
     return db.cluster_create(context, values)
コード例 #4
0
 def cluster_create(self, context, values):
     return db.cluster_create(context, values)