<commit_before>#!/usr/bin/env python
#
# Copyright 2010 <NAME> <<EMAIL>>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# he Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

import optparse
from psphere.vim25 import Vim

def discovery(url, username, password):
    """A discovery example to print the hosts and VMs in a cluster.

    Arguments:
        url: The URL of the ESX or VIC server. e.g. (https://bennevis/sdk)
        username: The username to connect with.
        password: The password to connect with.
    """
    vim = Vim(url, username, password)

    # Find the first ClusterComputeResource
    ccs = vim.find_entity_view(view_type='ClusterComputeResource',
                               filter={'name': 'Dalley St'})
    ccs.update_view_data(properties=['name', 'host'])
    print('Cluster: %s (%s hosts)' % (ccs.name, len(ccs.host)))

    # Get the host views in one fell swoop
    # It's important to be selective about the properties that
    # are retrieved from the server. Getting all the properties
    # of some managed entities (HostSystem is one) can be very
    # costly in terms of server resources and response time.
    hosts = vim.get_mo_views(mors=ccs.host, properties=['name', 'vm'])
    for host in hosts:
        print('  Host: %s (%s VMs)' % (host.name, len(host.vm)))
        # Get the vm views in one fell swoop
        vms = vim.get_mo_views(mors=host.vm, properties=['name'])
        for vm in vms:
            print('    VM: %s' % vm.name)
    <commit_msg>Improve docstring<commit_after>#!/usr/bin/env python
#
# Copyright 2010 <NAME> <<EMAIL>>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# he Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

import optparse
from psphere.vim25 import Vim

def discovery(url, username, password):
    """An example that discovers all hosts and VMs in the specified cluster.

    Parameters
    ----------
    url : str
        The URL of the ESX or VIC server. e.g. (https://bennevis/sdk)
    username : str
        The username to connect with.
    password : str
        The password to connect with.

    """
    vim = Vim(url, username, password)

    # Find the first ClusterComputeResource
    ccs = vim.find_entity_view(view_type='ClusterComputeResource',
                               filter={'name': 'Dalley St'})
    ccs.update_view_data(properties=['name', 'host'])
    print('Cluster: %s (%s hosts)' % (ccs.name, len(ccs.host)))

    # Get the host views in one fell swoop
    # It's important to be selective about the properties that
    # are retrieved from the server. Getting all the properties
    # of some managed entities (HostSystem is one) can be very
    # costly in terms of server resources and response time.
    hosts = vim.get_mo_views(mors=ccs.host, properties=['name', 'vm'])
    for host in hosts:
        print('  Host: %s (%s VMs)' % (host.name, len(host.vm)))
        # Get the vm views in one fell swoop
        vms = vim.get_mo_views(mors=host.vm, properties=['name'])
        for vm in vms:
            print('    VM: %s' % vm.name)
    
{'fraction_non_alphanumeric': 0.09670382937469704, 'fraction_numerical': 0.0033931168201648087, 'mean_word_length': 3.038160469667319, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5594708', 'n_tokens_mistral': 1201, 'n_tokens_neox': 1166, 'n_words': 506}