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


Python vcloud_plugin_common.wait_for_task函数代码示例

本文整理汇总了Python中vcloud_plugin_common.wait_for_task函数的典型用法代码示例。如果您正苦于以下问题:Python wait_for_task函数的具体用法?Python wait_for_task怎么用?Python wait_for_task使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: create_volume

def create_volume(vca_client, **kwargs):
    """
        create new volume, e.g.:
        {
            'use_external_resource': False,
            'volume': {
                'name': 'some-other',
                'size': 11
            }
        }
    """
    if ctx.node.properties.get('use_external_resource'):
        ctx.logger.info("External resource has been used")
        return
    vdc_name = get_vcloud_config()['vdc']
    name = ctx.node.properties['volume']['name']
    size = ctx.node.properties['volume']['size']
    size_in_Mb = size * 1024 * 1024
    success, disk = vca_client.add_disk(vdc_name, name, size_in_Mb)
    if success:
        wait_for_task(vca_client, disk.get_Tasks()[0])
        ctx.logger.info("Volume node {} has been created".format(name))
    else:
        raise cfy_exc.NonRecoverableError(
            "Disk creation error: {0}".format(disk))
开发者ID:jalopez11,项目名称:cloudify-dependencies,代码行数:25,代码来源:volume.py

示例2: delete

def delete(vca_client, **kwargs):
    """
        delete vcloud air network
    """
    if ctx.node.properties['use_external_resource'] is True:
        del ctx.instance.runtime_properties[VCLOUD_NETWORK_NAME]
        ctx.logger.info("Network was not deleted - external resource has"
                        " been used")
        return
    network_name = get_network_name(ctx.node.properties)
    if not _dhcp_operation(vca_client, network_name, DELETE_POOL):
        return set_retry(ctx)
    ctx.logger.info("Delete network '{0}'".format(network_name))
    success, task = vca_client.delete_vdc_network(
        get_vcloud_config()['vdc'], network_name)
    if success:
        wait_for_task(vca_client, task)
        ctx.logger.info(
            "Network '{0}' has been successful deleted.".format(network_name))
    else:
        if task and CANT_DELETE in task:
            ctx.logger.info("Network {} in use. Deleting the network skipped.".
                            format(network_name))
            return
        raise cfy_exc.NonRecoverableError(
            "Could not delete network '{0}': {1}".format(network_name, task))
开发者ID:denismakogon,项目名称:tosca-vcloud-plugin,代码行数:26,代码来源:network.py

示例3: create

def create(vca_client, **kwargs):
    """create vdc"""
    config = get_vcloud_config()
    # Subscription service does not support vdc create,
    # you must use predefined vdc only
    if is_subscription(config['service_type']):
            raise cfy_exc.NonRecoverableError(
                "Unable create VDC on subscription service.")
    if ctx.node.properties.get(USE_EXTERNAL_RESOURCE):
        # use external resource, does not create anything
        res_id = ctx.node.properties[RESOURCE_ID]
        ctx.instance.runtime_properties[VDC_NAME] = res_id
        vdc = vca_client.get_vdc(res_id)
        if not vdc:
            raise cfy_exc.NonRecoverableError(
                "Unable to find external VDC {0}."
                .format(res_id))
        ctx.logger.info(
            "External resource {0} has been used".format(res_id))
    else:
        # create new vdc
        vdc_name = ctx.node.properties.get('name')
        if not vdc_name:
            raise cfy_exc.NonRecoverableError("'vdc_name' not specified.")
        task = vca_client.create_vdc(vdc_name)
        if not task:
            raise cfy_exc.NonRecoverableError("Could not create VDC: {0}"
                                              .format(error_response(vca_client)))
        wait_for_task(vca_client, task)
开发者ID:pkdevboxy,项目名称:tosca-vcloud-plugin,代码行数:29,代码来源:vdc.py

示例4: start

def start(vca_client, **kwargs):
    """
    power on server and wait network connection availability for host
    """
    if ctx.node.properties.get('use_external_resource'):
        ctx.logger.info('not starting server since an external server is '
                        'being used')
    else:
        vapp_name = get_vapp_name(ctx.instance.runtime_properties)
        config = get_vcloud_config()
        vdc = vca_client.get_vdc(config['vdc'])
        vapp = vca_client.get_vapp(vdc, vapp_name)
        if _vapp_is_on(vapp) is False:
            ctx.logger.info("Power-on VApp {0}".format(vapp_name))
            task = vapp.poweron()
            if not task:
                raise cfy_exc.NonRecoverableError(
                    "Could not power-on vApp. {0}".
                                                  format(error_response(vapp)))
            wait_for_task(vca_client, task)

    if not _get_state(vca_client):
        return ctx.operation.retry(
            message="Waiting for VM's configuration to complete",
            retry_after=5)
开发者ID:jalopez11,项目名称:cloudify-dependencies,代码行数:25,代码来源:server.py

示例5: del_ondemand_public_ip

def del_ondemand_public_ip(vca_client, gateway, ip, ctx):
    task = gateway.deallocate_public_ip(ip)
    if task:
        wait_for_task(vca_client, task)
        ctx.logger.info("Public IP {0} deallocated".format(ip))
    else:
        raise cfy_exc.NonRecoverableError(
            "Can't deallocate public ip {0} for ondemand service".format(ip))
开发者ID:nmishkin,项目名称:tosca-vcloud-plugin,代码行数:8,代码来源:__init__.py

示例6: _power_on_vm

def _power_on_vm(vca_client, vapp, vapp_name):
    """Poweron VM"""
    if _vapp_is_on(vapp) is False:
        ctx.logger.info("Power-on VApp {0}".format(vapp_name))
        task = vapp.poweron()
        if not task:
            raise cfy_exc.NonRecoverableError(
                "Could not power-on vApp. {0}".
                format(error_response(vapp)))
        wait_for_task(vca_client, task)
开发者ID:pkdevboxy,项目名称:tosca-vcloud-plugin,代码行数:10,代码来源:server.py

示例7: save_gateway_configuration

def save_gateway_configuration(gateway, vca_client):
    task = gateway.save_services_configuration()
    if task:
        wait_for_task(vca_client, task)
        return True
    else:
        error = taskType.parseString(gateway.response.content, True)
        if BUSY_MESSAGE in error.message:
            return False
        else:
            raise cfy_exc.NonRecoverableError(error.message)
开发者ID:nmishkin,项目名称:tosca-vcloud-plugin,代码行数:11,代码来源:__init__.py

示例8: del_ondemand_public_ip

def del_ondemand_public_ip(vca_client, gateway, ip, ctx):
    """
        try to deallocate public ip
    """
    ctx.logger.info("Try to deallocate public IP {0}".format(ip))
    task = gateway.deallocate_public_ip(ip)
    if task:
        wait_for_task(vca_client, task)
        ctx.logger.info("Public IP {0} was deallocated".format(ip))
    else:
        raise cfy_exc.NonRecoverableError(
            "Can't deallocate public ip {0}. {1} for ondemand service".
            format(ip, error_response(gateway)))
开发者ID:denismakogon,项目名称:tosca-vcloud-plugin,代码行数:13,代码来源:__init__.py

示例9: stop

def stop(vca_client, **kwargs):
    if ctx.node.properties.get('use_external_resource'):
        ctx.logger.info('not stopping server since an external server is '
                        'being used')
    else:
        vapp_name = get_vapp_name(ctx.instance.runtime_properties)
        config = get_vcloud_config()
        vdc = vca_client.get_vdc(config['vdc'])
        vapp = vca_client.get_vapp(vdc, vapp_name)
        ctx.logger.info("Power-off and undeploy VApp {0}".format(vapp_name))
        task = vapp.undeploy()
        if not task:
            raise cfy_exc.NonRecoverableError("Could not undeploy vApp")
        wait_for_task(vca_client, task)
开发者ID:nmishkin,项目名称:tosca-vcloud-plugin,代码行数:14,代码来源:server.py

示例10: delete_volume

def delete_volume(vca_client, **kwargs):
    """
        drop volume
    """
    if ctx.node.properties.get('use_external_resource'):
        ctx.logger.info("External resource has been used")
        return
    vdc_name = get_vcloud_config()['vdc']
    name = ctx.node.properties['volume']['name']
    success, task = vca_client.delete_disk(vdc_name, name)
    if success:
        wait_for_task(vca_client, task)
        ctx.logger.info("Volume node {} has been deleted".format(name))
    else:
        raise cfy_exc.NonRecoverableError(
            "Disk deletion error: {0}".format(task))
开发者ID:jalopez11,项目名称:cloudify-dependencies,代码行数:16,代码来源:volume.py

示例11: delete

def delete(vca_client, **kwargs):
    if ctx.node.properties.get('use_external_resource'):
        ctx.logger.info('not deleting server since an external server is '
                        'being used')
    else:
        vapp_name = get_vapp_name(ctx.instance.runtime_properties)
        config = get_vcloud_config()
        vdc = vca_client.get_vdc(config['vdc'])
        vapp = vca_client.get_vapp(vdc, vapp_name)
        ctx.logger.info("Deleting VApp {0}".format(vapp_name))
        task = vapp.delete()
        if not task:
            raise cfy_exc.NonRecoverableError("Could not delete vApp")
        wait_for_task(vca_client, task)

    del ctx.instance.runtime_properties[VCLOUD_VAPP_NAME]
开发者ID:nmishkin,项目名称:tosca-vcloud-plugin,代码行数:16,代码来源:server.py

示例12: save_gateway_configuration

def save_gateway_configuration(gateway, vca_client):
    """
        save gateway configuration,
        return everything successfully finished
        raise NonRecoverableError - can't get task description
    """
    task = gateway.save_services_configuration()
    if task:
        wait_for_task(vca_client, task)
        return True
    else:
        error = taskType.parseString(gateway.response.content, True)
        if BUSY_MESSAGE in error.message:
            return False
        else:
            raise cfy_exc.NonRecoverableError(error.message)
开发者ID:kemiz,项目名称:tosca-vcloud-plugin,代码行数:16,代码来源:__init__.py

示例13: delete

def delete(vca_client, **kwargs):
    """
        delete vcloud air network
    """
    if ctx.node.properties["use_external_resource"] is True:
        del ctx.instance.runtime_properties[VCLOUD_NETWORK_NAME]
        ctx.logger.info("Network was not deleted - external resource has" " been used")
        return
    network_name = get_network_name(ctx.node.properties)
    _dhcp_operation(vca_client, network_name, DELETE_POOL)
    success, task = vca_client.delete_vdc_network(get_vcloud_config()["vdc"], network_name)
    if success:
        ctx.logger.info("Network {0} has been successful deleted.".format(network_name))
    else:
        raise cfy_exc.NonRecoverableError("Could not delete network {0}".format(network_name))
    wait_for_task(vca_client, task)
开发者ID:rbramwell,项目名称:tosca-vcloud-plugin,代码行数:16,代码来源:network.py

示例14: delete

def delete(vca_client, **kwargs):
    """delete vdc"""
    # external resource - no actions
    if ctx.node.properties.get(USE_EXTERNAL_RESOURCE):
        ctx.logger.info('Not deleting VDC since an external VDC is '
                        'being used')
    else:
        # created in our workflow
        vdc_name = ctx.node.properties.get('name')
        status, task = vca_client.delete_vdc(vdc_name)
        if not status:
            raise cfy_exc.NonRecoverableError("Could not delete VDC: {0}"
                                              .format(error_response(vca_client)))
        wait_for_task(vca_client, task)
    # clean up runtime_properties
    if VDC_NAME in ctx.instance.runtime_properties:
        del ctx.instance.runtime_properties[VDC_NAME]
开发者ID:pkdevboxy,项目名称:tosca-vcloud-plugin,代码行数:17,代码来源:vdc.py

示例15: get_ondemand_public_ip

def get_ondemand_public_ip(vca_client, gateway, ctx):
    old_public_ips = set(gateway.get_public_ips())
    task = gateway.allocate_public_ip()
    if task:
        wait_for_task(vca_client, task)
    else:
        raise cfy_exc.NonRecoverableError(
            "Can't get public ip for ondemand service")
    # update gateway for new IP address
    gateway = vca_client.get_gateways(get_vcloud_config()['vdc'])[0]
    new_public_ips = set(gateway.get_public_ips())
    new_ip = new_public_ips - old_public_ips
    if new_ip:
        ctx.logger.info("Assign public IP {0}".format(new_ip))
    else:
        raise cfy_exc.NonRecoverableError(
            "Can't get new public IP address")
    return list(new_ip)[0]
开发者ID:nmishkin,项目名称:tosca-vcloud-plugin,代码行数:18,代码来源:__init__.py


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