コード例 #1
0
ファイル: compute.py プロジェクト: assimilator101/cattle
    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)
コード例 #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)
コード例 #3
0
ファイル: compute.py プロジェクト: cjellick/python-agent
    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)
コード例 #4
0
ファイル: compute.py プロジェクト: jimengliu/python-agent
    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)
コード例 #5
0
ファイル: compute.py プロジェクト: dx9/python-agent
    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)
コード例 #6
0
ファイル: compute.py プロジェクト: assimilator101/cattle
    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)
コード例 #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)
コード例 #8
0
ファイル: compute.py プロジェクト: dx9/python-agent
    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)
コード例 #9
0
ファイル: compute.py プロジェクト: cjellick/python-agent
    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)
コード例 #10
0
ファイル: compute.py プロジェクト: jimengliu/python-agent
    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)
コード例 #11
0
ファイル: compute.py プロジェクト: th3architect/cattle
    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)
コード例 #12
0
ファイル: compute.py プロジェクト: pranavs18/python-agent
    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)
コード例 #13
0
ファイル: compute.py プロジェクト: th3architect/cattle
    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)
コード例 #14
0
ファイル: compute.py プロジェクト: pranavs18/python-agent
    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)