Example #1
0
    def _add_resources(self, ping, pong):
        if not utils.ping_include_resources(ping):
            return

        physical_host = Config.physical_host()

        compute = {
            'type': 'host',
            'kind': LIBVIRT_KIND,
            'name': Config.hostname() + '/libvirt',
            'uuid': LibvirtConfig.libvirt_uuid(),
            'physicalHostUuid': physical_host['uuid'],
            'data': {
                'libvirt': {
                    'type': self.get_default_type()
                }
            }
        }

        resources = [physical_host, compute]

        for driver in pool_drivers():
            for pool in driver.discover(compute):
                data = utils.get_map_value(pool, 'data', 'libvirt')
                data['driver'] = driver.driver_name()

                resources.append(pool)

        utils.ping_add_resources(pong, *resources)
Example #2
0
    def _add_resources(self, ping, pong):
        if not utils.ping_include_resources(ping):
            return

        physical_host = Config.physical_host()

        compute = {
            'type': 'host',
            'kind': LIBVIRT_KIND,
            'name': Config.hostname() + '/libvirt',
            'uuid': LibvirtConfig.libvirt_uuid(),
            'physicalHostUuid': physical_host['uuid'],
            'data': {
                'libvirt': {
                    'type': self.get_default_type()
                }
            }
        }

        resources = [physical_host, compute]

        for driver in pool_drivers():
            for pool in driver.discover(compute):
                data = utils.get_map_value(pool, 'data', 'libvirt')
                data['driver'] = driver.driver_name()

                resources.append(pool)

        utils.ping_add_resources(pong, *resources)
Example #3
0
    def _add_resources(self, ping, pong):
        if not utils.ping_include_resources(ping):
            return

        stats = None
        if utils.ping_include_stats(ping):
            try:
                stats = self.host_info.collect_data()
            except:
                log.exception("Error getting host info stats")

        physical_host = Config.physical_host()

        compute = {
            'type': 'host',
            'kind': 'docker',
            'name': Config.hostname(),
            'createLabels': self._get_host_create_labels(),
            'labels': self._get_host_labels(),
            'physicalHostUuid': physical_host['uuid'],
            'uuid': DockerConfig.docker_uuid(),
            'info': stats
        }

        pool = {
            'type': 'storagePool',
            'kind': 'docker',
            'name': compute['name'] + ' Storage Pool',
            'hostUuid': compute['uuid'],
            'uuid': compute['uuid'] + '-pool'
        }

        resolved_ip = socket.gethostbyname(DockerConfig.docker_host_ip())

        ip = {
            'type': 'ipAddress',
            'uuid': resolved_ip,
            'address': resolved_ip,
            'hostUuid': compute['uuid'],
        }

        proxy = Config.host_proxy()
        if proxy is not None:
            compute['apiProxy'] = proxy

        utils.ping_add_resources(pong, physical_host, compute, pool, ip)
Example #4
0
    def _add_resources(self, ping, pong):
        if not utils.ping_include_resources(ping):
            return

        stats = None
        if utils.ping_include_stats(ping):
            try:
                stats = self.host_info.collect_data()
            except:
                log.exception("Error getting host info stats")

        physical_host = Config.physical_host()

        compute = {
            'type': 'host',
            'kind': 'docker',
            'hostname': Config.hostname(),
            'createLabels': self._get_host_create_labels(),
            'labels': self._get_host_labels(),
            'physicalHostUuid': physical_host['uuid'],
            'uuid': DockerConfig.docker_uuid(),
            'info': stats
        }

        pool = {
            'type': 'storagePool',
            'kind': 'docker',
            'name': compute['hostname'] + ' Storage Pool',
            'hostUuid': compute['uuid'],
            'uuid': compute['uuid'] + '-pool'
        }

        resolved_ip = socket.gethostbyname(DockerConfig.docker_host_ip())

        ip = {
            'type': 'ipAddress',
            'uuid': resolved_ip,
            'address': resolved_ip,
            'hostUuid': compute['uuid'],
        }

        proxy = Config.host_proxy()
        if proxy is not None:
            compute['apiProxy'] = proxy

        utils.ping_add_resources(pong, physical_host, compute, pool, ip)
Example #5
0
    def _add_instances(self, ping, pong):
        if not utils.ping_include_instances(ping):
            return

        utils.ping_add_resources(pong, {"type": "hostUuid", "uuid": DockerConfig.docker_uuid()})

        containers = []
        running, nonrunning = self._get_all_containers_by_state()

        for key, container in running.iteritems():
            self.add_container("running", container, containers)

        for key, container in nonrunning.iteritems():
            self.add_container("stopped", container, containers)

        utils.ping_add_resources(pong, *containers)
        utils.ping_set_option(pong, "instances", True)
Example #6
0
    def _add_instances(self, ping, pong):
        if not utils.ping_include_instances(ping):
            return

        conn = LibvirtConnection.open(self.get_default_type())
        vms = []

        for vm in conn.listAllDomains(0):
            name = vm.name()

            if utils.is_uuid(name) and _is_running(conn, vm):
                vms.append({
                    'type': 'instance',
                    'uuid': name,
                    'state': 'running'
                })

        utils.ping_add_resources(pong, *vms)
        utils.ping_set_option(pong, 'instances', True)
Example #7
0
    def _add_instances(self, ping, pong):
        if not utils.ping_include_instances(ping):
            return

        conn = LibvirtConnection.open(self.get_default_type())
        vms = []

        for vm in conn.listAllDomains(0):
            name = vm.name()

            if utils.is_uuid(name) and _is_running(conn, vm):
                vms.append({
                    'type': 'instance',
                    'uuid': name,
                    'state': 'running'
                })

        utils.ping_add_resources(pong, *vms)
        utils.ping_set_option(pong, 'instances', True)
Example #8
0
    def _add_resources(self, ping, pong):
        if not utils.ping_include_resources(ping):
            return

        stats = None
        if utils.ping_include_stats(ping):
            try:
                stats = self.host_info.collect_data()
            except:
                log.exception("Error geting host info stats")

        physical_host = Config.physical_host()

        compute = {
            "type": "host",
            "kind": "docker",
            "name": Config.hostname(),
            "labels": Config.labels(),
            "physicalHostUuid": physical_host["uuid"],
            "uuid": DockerConfig.docker_uuid(),
            "info": stats,
        }

        pool = {
            "type": "storagePool",
            "kind": "docker",
            "name": compute["name"] + " Storage Pool",
            "hostUuid": compute["uuid"],
            "uuid": compute["uuid"] + "-pool",
        }

        ip = {
            "type": "ipAddress",
            "uuid": DockerConfig.docker_host_ip(),
            "address": DockerConfig.docker_host_ip(),
            "hostUuid": compute["uuid"],
        }

        proxy = Config.host_proxy()
        if proxy is not None:
            compute["apiProxy"] = proxy

        utils.ping_add_resources(pong, physical_host, compute, pool, ip)
Example #9
0
    def _add_instances(self, ping, pong):
        if not utils.ping_include_instances(ping):
            return

        utils.ping_add_resources(pong, {
            'type': 'hostUuid',
            'uuid': DockerConfig.docker_uuid()
        })

        containers = []
        running, nonrunning = self._get_all_containers_by_state()

        for key, container in running.iteritems():
            self.add_container('running', container, containers)

        for key, container in nonrunning.iteritems():
            self.add_container('stopped', container, containers)

        utils.ping_add_resources(pong, *containers)
        utils.ping_set_option(pong, 'instances', True)
Example #10
0
    def _add_instances(self, ping, pong):
        if not utils.ping_include_instances(ping):
            return

        utils.ping_add_resources(pong, {
            'type': 'hostUuid',
            'uuid': DockerConfig.docker_uuid()
        })

        containers = []
        running, nonrunning = self._get_all_containers_by_state()

        for key, container in running.iteritems():
            self.add_container('running', container, containers)

        for key, container in nonrunning.iteritems():
            self.add_container('stopped', container, containers)

        utils.ping_add_resources(pong, *containers)
        utils.ping_set_option(pong, 'instances', True)
Example #11
0
    def _add_instances(self, ping, pong):
        if not utils.ping_include_instances(ping):
            return

        containers = []
        for c in docker_client().containers():
            names = c.get('Names')
            if names is None:
                continue

            for name in names:
                if name.startswith('/'):
                    name = name[1:]
                    if utils.is_uuid(name):
                        containers.append({
                            'type': 'instance',
                            'uuid': name,
                            'state': 'running'
                        })

        utils.ping_add_resources(pong, *containers)
        utils.ping_set_option(pong, 'instances', True)
Example #12
0
    def _add_instances(self, ping, pong):
        if not utils.ping_include_instances(ping):
            return

        containers = []
        for c in docker_client().containers():
            names = c.get('Names')
            if names is None:
                continue

            for name in names:
                if name.startswith('/'):
                    name = name[1:]
                    if utils.is_uuid(name):
                        containers.append({
                            'type': 'instance',
                            'uuid': name,
                            'state': 'running'
                        })

        utils.ping_add_resources(pong, *containers)
        utils.ping_set_option(pong, 'instances', True)
Example #13
0
    def _add_resources(self, ping, pong):
        if not utils.ping_include_resources(ping):
            return

        physical_host = Config.physical_host()

        compute = {
            'type': 'host',
            'kind': 'docker',
            'name': Config.hostname() + '/docker',
            'physicalHostUuid': physical_host['uuid'],
            'uuid': DockerConfig.docker_uuid()
        }

        pool = {
            'type': 'storagePool',
            'kind': 'docker',
            'name': compute['name'] + ' Storage Pool',
            'hostUuid': compute['uuid'],
            'uuid': compute['uuid'] + '-pool'
        }

        utils.ping_add_resources(pong, physical_host, compute, pool)
Example #14
0
    def _add_resources(self, ping, pong):
        if not utils.ping_include_resources(ping):
            return

        physical_host = Config.physical_host()

        compute = {
            'type': 'host',
            'kind': 'docker',
            'name': Config.hostname(),
            'physicalHostUuid': physical_host['uuid'],
            'uuid': DockerConfig.docker_uuid()
        }

        pool = {
            'type': 'storagePool',
            'kind': 'docker',
            'name': compute['name'] + ' Storage Pool',
            'hostUuid': compute['uuid'],
            'uuid': compute['uuid'] + '-pool'
        }

        utils.ping_add_resources(pong, physical_host, compute, pool)