Example #1
0
    def _get_zone(self, req, osd):
        """get zone name from server name"""
        zone = ''
        context = req.environ["vsm.context"]
        host = self._get_server(osd)
        if not host:
            return zone

        node = db.init_node_get_by_host(context=context, host=host)
        if node and node.zone:
            zone = node.zone.name

        return zone
Example #2
0
File: osds.py Project: hl10502/vsm
    def _get_zone(self, req, osd):
        """get zone name from server name"""
        zone = ''
        context = req.environ["vsm.context"]
        host = self._get_server(osd)
        if not host:
            return zone

        node = db.init_node_get_by_host(context=context, host=host)
        if node and node.zone:
            zone = node.zone.name

        return zone
Example #3
0
    def _running_on_this_host(self, context, service_topic):
        running_on_this_host = False
        host_list = []
        sers = db.service_get_all_by_topic(context, service_topic)
        for ser in sers:
            init_node = db.init_node_get_by_host(context, ser['host'])
            if utils.service_is_up(ser) and init_node and init_node['status'] == "Active":
                host_list.append(ser['host'])

        host_list.sort()
        if len(host_list) == 0:
            return False

        select_host = random.randint(0, len(host_list)-1)
        if host_list[select_host] == FLAGS.host:
            running_on_this_host = True

        return running_on_this_host
    def _running_on_this_host(self, context, service_topic):
        running_on_this_host = False
        host_list = []
        sers = db.service_get_all_by_topic(context, service_topic)
        for ser in sers:
            init_node = db.init_node_get_by_host(context, ser['host'])
            if utils.service_is_up(ser) and init_node and init_node['status'] == "Active":
                host_list.append(ser['host'])

        host_list.sort()
        if len(host_list) == 0:
            return False

        select_host = random.randint(0, len(host_list)-1)
        if host_list[select_host] == FLAGS.host:
            running_on_this_host = True

        return running_on_this_host
Example #5
0
 def init_node_get_by_host(self, context, host):
     """Get init node by host name."""
     return db.init_node_get_by_host(context, host)
 def init_node_get_by_host(self, context, host):
     """Get init node by host name."""
     return db.init_node_get_by_host(context, host)