Пример #1
0
def set_vsm_conf(recv):
    """Write vsm conf files."""
    if recv is None:
        return False

    old_recv = recv
    try:
        recv = json.loads(recv)
    except TypeError:
        recv = old_recv
        LOG.info('Maybe recv is not json.')

    if not recv.get("api-paste.ini", None):
        LOG.error('Can not find content of api-paste.ini')
        raise exception.NotFound()

    if not recv.get("vsm.conf", None):
        LOG.error('Can not find content of vsm.conf')
        raise exception.NotFound()

    files = ["api-paste.ini", "vsm.conf"]
    for conf in files:
        conf_path = FLAGS.vsm_config_path + conf
        #conf_file = open(conf_path, 'w')
        #conf_file.write(recv[conf])
        utils.write_file_as_root(conf_path, recv[conf], "w")
        #conf_file.close()

    return True
Пример #2
0
    def _vsm_controller_ip(self):
        """Get the vsm's controller IP

        It's notable that this IP not just refer to vsm-api node.
        It can refer to two kinds of nodes which can reach to:

            1. Proxy Node with Load Banlance.
            2. VSM-API node. We will have multiple api node running
               in the futhure.
        """
        ip_list = self._get_segment('vsm_controller_ip')
        ip_list = ip_list['single']

        # If there are multiple controller's ip, raise error.
        # We just ignore if these IPs are refer to the same node.
        # We just support one IP here.
        if len(ip_list) > 1:
            LOG.error('Just support one controller IP for VSM.')
            raise exception.DuplicateControllerIPs()

        if len(ip_list) == 0:
            LOG.error('No controller IP for VSM.')
            raise exception.NotFound()

        return ip_list[0]
Пример #3
0
    def _check_key_words_exists(self):
        """Check all the key words are exists."""

        if not self._lines or len(self._lines) == 0:
            LOG.error('Have not read any lines from file')
            raise exception.NotFound('self._lines in parser are None.')

        #key_words = self._single_type_list + self._disk_type_list
        key_words = self._single_type_list
        for kword in key_words:
            self._check_single_key_word_exists(kword)