当前位置: 首页>>代码示例>>Python>>正文


Python env.get方法代码示例

本文整理汇总了Python中fabric.api.env.get方法的典型用法代码示例。如果您正苦于以下问题:Python env.get方法的具体用法?Python env.get怎么用?Python env.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在fabric.api.env的用法示例。


在下文中一共展示了env.get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __call__

# 需要导入模块: from fabric.api import env [as 别名]
# 或者: from fabric.api.env import get [as 别名]
def __call__(self):
        query = self.query
        environment = self.environment
        if environment is _default_environment:
            environment = env.get('chef_environment', DEFAULT_ENVIRONMENT)
        if environment:
            query += ' AND chef_environment:%s' % environment
        for row in Search('node', query, api=self.api):
            if row:
                if callable(self.hostname_attr):
                    val = self.hostname_attr(row.object)
                    if val:
                        yield val
                else:
                    for attr in self.hostname_attr:
                        try:
                            val =  row.object.attributes.get_dotted(attr)
                            if val: # Don't ever give out '' or None, since it will error anyway
                                yield val
                                break
                        except KeyError:
                            pass # Move on to the next
                    else:
                        raise ChefError('Cannot find a usable hostname attribute for node %s', row.object) 
开发者ID:awslabs,项目名称:lambda-chef-node-cleanup,代码行数:26,代码来源:fabric.py

示例2: setup_env

# 需要导入模块: from fabric.api import env [as 别名]
# 或者: from fabric.api.env import get [as 别名]
def setup_env(deployment_name):
    deployment = DEPLOYMENTS.get(deployment_name)


    if deployment is None:
        exit_with_error('Deployment "%s" not found.' % deployment_name)

    if 'kc_virtualenv_name' in deployment:
        deployment['virtualenv_name'] = deployment['kc_virtualenv_name']

    env.update(deployment)

    check_key_filename(deployment_name)

    env.virtualenv = os.path.join('/home', 'ubuntu', '.virtualenvs',
                                  env.kc_virtualenv_name, 'bin', 'activate')

    env.pip_requirements_file = os.path.join(env.kc_path,
                                             'requirements/base.pip')
    env.template_dir = 'onadata/libs/custom_template'
    env.template_repo = os.path.join(env.home, 'kobocat-template') 
开发者ID:awemulya,项目名称:kobo-predict,代码行数:23,代码来源:fabfile.py

示例3: login

# 需要导入模块: from fabric.api import env [as 别名]
# 或者: from fabric.api.env import get [as 别名]
def login(self, **kwargs):
        """
        Identical to :meth:`dockermap.client.base.DockerClientWrapper.login` with two enhancements:

        * additional logging;
        * login parameters can be passed through ``kwargs``, or set as default using the following ``env``
          variables:

          * ``env.docker_registry_user`` (kwarg: ``username``),
          * ``env.docker_registry_password`` (kwarg: ``password``),
          * ``env.docker_registry_mail`` (kwarg: ``email``),
          * ``env.docker_registry_repository`` (kwarg: ``registry``),
          * ``env.docker_registry_insecure`` (kwarg: ``insecure_registry``).
        """
        c_user = kwargs.pop('username', env.get('docker_registry_user'))
        c_pass = kwargs.pop('password', env.get('docker_registry_password'))
        c_mail = kwargs.pop('email', env.get('docker_registry_mail'))
        c_registry = kwargs.pop('registry', env.get('docker_registry_repository'))
        c_insecure = kwargs.pop('insecure_registry', env.get('docker_registry_insecure'))
        if super(DockerFabricClient, self).login(c_user, password=c_pass, email=c_mail, registry=c_registry,
                                                 insecure_registry=c_insecure, **kwargs):
            self.push_log("Login at registry '{0}' succeeded.".format(c_registry))
            return True
        self.push_log("Login at registry '{0}' failed.".format(c_registry))
        return False 
开发者ID:merll,项目名称:docker-fabric,代码行数:27,代码来源:apiclient.py

示例4: get_connection

# 需要导入模块: from fabric.api import env [as 别名]
# 或者: from fabric.api.env import get [as 别名]
def get_connection(self, *args, **kwargs):
        """
        Create a new connection, or return an existing one from the cache. Uses Fabric's current ``env.host_string``
        and the URL to the Docker service.

        :param args: Additional arguments for the client constructor, if a new client has to be instantiated.
        :param kwargs: Additional keyword args for the client constructor, if a new client has to be instantiated.
        """
        key = env.get('host_string'), kwargs.get('base_url', env.get('docker_base_url'))
        default_config = _get_default_config(None)
        if default_config:
            if key not in self:
                self[key] = default_config
            return default_config.get_client()
        config = self.get_or_create_connection(key, self.configuration_class, *args, **kwargs)
        return config.get_client() 
开发者ID:merll,项目名称:docker-fabric,代码行数:18,代码来源:base.py

示例5: login

# 需要导入模块: from fabric.api import env [as 别名]
# 或者: from fabric.api.env import get [as 别名]
def login(self, **kwargs):
        for key, variable in [
            ('username', 'user'),
            ('password', 'password'),
            ('email', 'mail'),
            ('registry', 'repository'),
            ('insecure_registry', 'insecure')
        ]:
            if key not in kwargs:
                env_value = env.get('docker_registry_{0}'.format(variable))
                if env_value:
                    kwargs[key] = env_value
        registry = kwargs.pop('registry', env.get('docker_registry_repository'))
        if registry:
            cmd_str = self._out.get_cmd('login', registry, **kwargs)
        else:
            cmd_str = self._out.get_cmd('login', **kwargs)
        res = self._call(cmd_str, quiet=True)
        lines = res.splitlines()
        fastprint(lines)
        return 'Login Succeeded' in lines 
开发者ID:merll,项目名称:docker-fabric,代码行数:23,代码来源:cli.py

示例6: isolate_and_get

# 需要导入模块: from fabric.api import env [as 别名]
# 或者: from fabric.api.env import get [as 别名]
def isolate_and_get(src_container, src_resources, local_dst_dir, **kwargs):
    """
    Uses :func:`copy_resources` to copy resources from a container, but afterwards generates a compressed tarball
    and downloads it.

    :param src_container: Container name or id.
    :type src_container: unicode
    :param src_resources: Resources, as (file or directory) names to copy.
    :type src_resources: iterable
    :param local_dst_dir: Local directory to store the compressed tarball in. Can also be a file name; the default file
      name is ``container_<container name>.tar.gz``.
    :type local_dst_dir: unicode
    :param kwargs: Additional kwargs for :func:`copy_resources`.
    """
    with temp_dir() as remote_tmp:
        copy_path = posixpath.join(remote_tmp, 'copy_tmp')
        archive_path = posixpath.join(remote_tmp, 'container_{0}.tar.gz'.format(src_container))
        copy_resources(src_container, src_resources, copy_path, **kwargs)
        with cd(copy_path):
            sudo(targz(archive_path, '*'))
        get(archive_path, local_dst_dir) 
开发者ID:merll,项目名称:docker-fabric,代码行数:23,代码来源:cli.py

示例7: save_image

# 需要导入模块: from fabric.api import env [as 别名]
# 或者: from fabric.api.env import get [as 别名]
def save_image(image, local_filename):
    """
    Saves a Docker image as a compressed tarball. This command line client method is a suitable alternative, if the
    Remove API method is too slow.

    :param image: Image id or tag.
    :type image: unicode
    :param local_filename: Local file name to store the image into. If this is a directory, the image will be stored
      there as a file named ``image_<Image name>.tar.gz``.
    """
    r_name, __, i_name = image.rpartition('/')
    i_name, __, __ = i_name.partition(':')
    with temp_dir() as remote_tmp:
        archive = posixpath.join(remote_tmp, 'image_{0}.tar.gz'.format(i_name))
        run('docker save {0} | gzip --stdout > {1}'.format(image, archive), shell=False)
        get(archive, local_filename) 
开发者ID:merll,项目名称:docker-fabric,代码行数:18,代码来源:cli.py

示例8: cleanup_images

# 需要导入模块: from fabric.api import env [as 别名]
# 或者: from fabric.api.env import get [as 别名]
def cleanup_images(remove_old=False, **kwargs):
    """
    Removes all images that have no name, and that are not references as dependency by any other named image. Similar
    to the ``prune`` functionality in newer Docker versions, but supports more filters.

    :param remove_old: Also remove images that do have a name, but no `latest` tag.
    :type remove_old: bool
    """
    keep_tags = env.get('docker_keep_tags')
    if keep_tags is not None:
        kwargs.setdefault('keep_tags', keep_tags)
    removed_images = docker_fabric().cleanup_images(remove_old=remove_old, **kwargs)
    if kwargs.get('list_only'):
        puts('Unused images:')
        for image_name in removed_images:
            fastprint(image_name, end='\n') 
开发者ID:merll,项目名称:docker-fabric,代码行数:18,代码来源:tasks.py

示例9: container_fabric

# 需要导入模块: from fabric.api import env [as 别名]
# 或者: from fabric.api.env import get [as 别名]
def container_fabric(container_maps=None, docker_client=None, clients=None, client_implementation=None):
    """
    :param container_maps: Container map or a tuple / list thereof.
    :type container_maps: list[dockermap.map.config.main.ContainerMap] | dockermap.map.config.main.ContainerMap
    :param docker_client: Default Docker client instance.
    :type docker_client: dockerfabric.base.FabricClientConfiguration or docker.docker.Client
    :param clients: Optional dictionary of Docker client configuration objects.
    :type clients: dict[unicode | str, dockerfabric.base.FabricClientConfiguration]
    :param client_implementation: Client implementation to use (API or CLI).
    :type client_implementation: unicode | str
    :return: Container mapping client.
    :rtype: dockerfabric.base.FabricContainerClient
    """
    ci = client_implementation or env.get('docker_fabric_implementation') or CLIENT_API
    if ci == CLIENT_API:
        return ContainerApiFabricClient(container_maps, docker_client, clients)
    elif ci == CLIENT_CLI:
        return ContainerCliFabricClient(container_maps, docker_client, clients)
    raise ValueError("Invalid client implementation.", ci) 
开发者ID:merll,项目名称:docker-fabric,代码行数:21,代码来源:api.py

示例10: setup_fake_manifest_certificate

# 需要导入模块: from fabric.api import env [as 别名]
# 或者: from fabric.api.env import get [as 别名]
def setup_fake_manifest_certificate(certificate_url=None):
    """Task to setup a fake manifest certificate

    Allows accepting modified (UUID) redhat-manifest by using a
    fake-manifest-ca.crt

    """
    certificate_url = certificate_url or os.environ.get(
        'FAKE_MANIFEST_CERT_URL')
    if certificate_url is None:
        print('You should specify the fake certificate URL')
        sys.exit(1)

    run('wget -O /etc/candlepin/certs/upstream/fake_manifest.crt '
        '{certificate_url}'.format(certificate_url=certificate_url))

    manage_daemon('restart', 'tomcat6' if distro_info()[1] <= 6 else 'tomcat') 
开发者ID:SatelliteQE,项目名称:automation-tools,代码行数:19,代码来源:__init__.py

示例11: generate_capsule_certs

# 需要导入模块: from fabric.api import env [as 别名]
# 或者: from fabric.api.env import get [as 别名]
def generate_capsule_certs(capsule_fqdn=None, sat_version=None):
    """Generate Capsule Certs required for Capsule Installation.

    CAPSULE_FQDN
        CAPSULE FQDN for which certs needs to be created.
    SATELLITE_VERSION
        SATELLITE_VERSION for which the capsule certs needs to be created.

    """
    capsule_fqdn = capsule_fqdn or os.environ.get('CAPSULE_FQDN')
    sat_version = sat_version or os.environ.get('SATELLITE_VERSION')

    run('capsule-certs-generate --foreman-proxy-fqdn {0}'
        ' --certs-tar "/var/www/html/pub/{0}-certs.tar" > '
        '/var/www/html/pub/{0}-out.txt'
        .format(capsule_fqdn))
    run('cat /var/www/html/pub/{0}-out.txt|'
        'grep -v help | grep -v log | grep -A 10 "satellite-installer'
        '" > /var/www/html/pub/capsule_script.sh'
        .format(capsule_fqdn))
    run('chmod +x /var/www/html/pub/capsule_script.sh')
    run('sed -i \'s|/var/www/html/pub/{0}-certs.tar|/root/{0}-certs.tar|\' '
        '"/var/www/html/pub/capsule_script.sh"'
        .format(capsule_fqdn)) 
开发者ID:SatelliteQE,项目名称:automation-tools,代码行数:26,代码来源:__init__.py

示例12: cleanup_idm

# 需要导入模块: from fabric.api import env [as 别名]
# 或者: from fabric.api.env import get [as 别名]
def cleanup_idm(hostname, idm_password=None):
    """Clean up the IDM server of any previous entries.

    Expects the following environment variables:

    IDM_PASSWORD
        IDM Server Password to fetch a token.

    """
    if idm_password is None:
        idm_password = os.environ.get('IDM_PASSWORD')
    if hostname is None:
        print('Please provide the hostname entry to delete.')
        sys.exit(1)
    run('echo {0} | kinit admin'.format(idm_password))
    run('ipa host-del {0}'.format(hostname), warn_only=True) 
开发者ID:SatelliteQE,项目名称:automation-tools,代码行数:18,代码来源:__init__.py

示例13: enroll_idm

# 需要导入模块: from fabric.api import env [as 别名]
# 或者: from fabric.api.env import get [as 别名]
def enroll_idm(idm_password=None):
    """Enroll the Satellite6 Server to an IDM Server.

    Expects the following environment variables:

    IDM_PASSWORD
        IDM Server Password to fetch a token.

    """
    # NOTE: Works only when Satellite6 and IDM domains are same and the
    # first nameserver in /etc/resolv.conf file points to the IDM server.
    if idm_password is None:
        idm_password = os.environ.get('IDM_PASSWORD')
    run('yum -y --disableplugin=foreman-protector install ipa-client ipa-admintools')
    run('ipa-client-install --password={0} --principal admin '
        '--unattended --no-ntp'.format(idm_password))
    result = run('id admin')
    if result.succeeded:
        print('Enrollment of Satellite6 Server to IDM is successfully '
              'completed.') 
开发者ID:SatelliteQE,项目名称:automation-tools,代码行数:22,代码来源:__init__.py

示例14: configure_idm_external_auth

# 需要导入模块: from fabric.api import env [as 别名]
# 或者: from fabric.api.env import get [as 别名]
def configure_idm_external_auth(idm_password=None):
    """Configure the Satellite6 Server for External Authentication.

    Expects the following environment variables:

    IDM_PASSWORD
        IDM Server Password to fetch a token.

    """
    result = run('id admin')
    if result.failed:
        print('Please execute enroll_idm before configuring External Auth')
        sys.exit(1)
    if idm_password is None:
        idm_password = os.environ.get('IDM_PASSWORD')
    run('echo {0} | kinit admin'.format(idm_password))
    run('ipa service-add HTTP/$(hostname)')
    run('satellite-installer --foreman-ipa-authentication=true')
    run('foreman-maintain service restart') 
开发者ID:SatelliteQE,项目名称:automation-tools,代码行数:21,代码来源:__init__.py

示例15: update_rhsm_stage

# 需要导入模块: from fabric.api import env [as 别名]
# 或者: from fabric.api.env import get [as 别名]
def update_rhsm_stage():
    """Updates the host to point to stage

    The following environment variables affect this command:

    RHN_STAGE_SERVER
        Stage content server
    CDN_STAGE_URL
        Stage content baseurl

    """
    rhn_stage_server = os.environ.get('RHN_STAGE_SERVER')
    cdn_stage_url = os.environ.get('CDN_STAGE_URL')
    if rhn_stage_server is None or cdn_stage_url is None:
        print('RHN_STAGE and CDN_STAGE_URL are required to continue')
        sys.exit(1)
    run("sed -i -e 's/^hostname.*/hostname={0}/' "
        "/etc/rhsm/rhsm.conf".format(rhn_stage_server))
    run("sed -i -e 's|^baseurl.*|baseurl={0}|' "
        "/etc/rhsm/rhsm.conf".format(cdn_stage_url))
    manage_daemon('restart', 'rhsmcertd') 
开发者ID:SatelliteQE,项目名称:automation-tools,代码行数:23,代码来源:__init__.py


注:本文中的fabric.api.env.get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。