Esempio n. 1
0
def show_strategy(os_auth_uri,
                  os_project_name,
                  os_project_domain_name,
                  os_username,
                  os_password,
                  os_user_domain_name,
                  os_region_name,
                  os_interface,
                  strategy_name,
                  details=False):
    """
    Software Update - Show Strategy
    """
    token = openstack.get_token(os_auth_uri, os_project_name,
                                os_project_domain_name, os_username,
                                os_password, os_user_domain_name)

    url = token.get_service_url(os_region_name, openstack.SERVICE.VIM,
                                openstack.SERVICE_TYPE.NFV, os_interface)
    if url is None:
        raise ValueError("NFV-VIM URL is invalid")

    strategy = sw_update.get_strategies(token.get_id(), url, strategy_name)
    if not strategy:
        print("No strategy available")
        return

    _display_strategy(strategy, details)
Esempio n. 2
0
def delete_strategy(os_auth_uri,
                    os_project_name,
                    os_project_domain_name,
                    os_username,
                    os_password,
                    os_user_domain_name,
                    os_region_name,
                    os_interface,
                    strategy_name,
                    force=False):
    """
    Software Update - Delete Strategy
    """
    token = openstack.get_token(os_auth_uri, os_project_name,
                                os_project_domain_name, os_username,
                                os_password, os_user_domain_name)

    url = token.get_service_url(os_region_name, openstack.SERVICE.VIM,
                                openstack.SERVICE_TYPE.NFV, os_interface)
    if url is None:
        raise ValueError("NFV-VIM URL is invalid")

    success = sw_update.delete_strategy(token.get_id(), url, strategy_name,
                                        force)
    if success:
        print("Strategy deleted")
        return
    else:
        raise Exception("Strategy delete failed")
Esempio n. 3
0
def abort_strategy(os_auth_uri,
                   os_project_name,
                   os_project_domain_name,
                   os_username,
                   os_password,
                   os_user_domain_name,
                   os_region_name,
                   os_interface,
                   strategy_name,
                   stage_id=None):
    """
    Software Update - Abort Strategy
    """
    token = openstack.get_token(os_auth_uri, os_project_name,
                                os_project_domain_name, os_username,
                                os_password, os_user_domain_name)

    url = token.get_service_url(os_region_name, openstack.SERVICE.VIM,
                                openstack.SERVICE_TYPE.NFV, os_interface)
    if url is None:
        raise ValueError("NFV-VIM URL is invalid")

    strategy = sw_update.abort_strategy(token.get_id(), url, strategy_name,
                                        stage_id)
    if not strategy:
        if stage_id is None:
            raise Exception("Strategy abort failed")
        else:
            raise Exception("Strategy stage %s abort failed" % stage_id)

    _display_strategy(strategy)
Esempio n. 4
0
def create_strategy(os_auth_uri, os_project_name, os_project_domain_name,
                    os_username, os_password, os_user_domain_name,
                    os_region_name, os_interface, strategy_name,
                    controller_apply_type, storage_apply_type,
                    swift_apply_type, worker_apply_type,
                    max_parallel_worker_hosts, default_instance_action,
                    alarm_restrictions, **kwargs):
    """
    Software Update - Create Strategy
    """
    token = openstack.get_token(os_auth_uri, os_project_name,
                                os_project_domain_name, os_username,
                                os_password, os_user_domain_name)

    url = token.get_service_url(os_region_name, openstack.SERVICE.VIM,
                                openstack.SERVICE_TYPE.NFV, os_interface)
    if url is None:
        raise ValueError("NFV-VIM URL is invalid")

    strategy = sw_update.create_strategy(
        token.get_id(), url, strategy_name, controller_apply_type,
        storage_apply_type, swift_apply_type, worker_apply_type,
        max_parallel_worker_hosts, default_instance_action, alarm_restrictions,
        **kwargs)
    if not strategy:
        raise Exception("Strategy creation failed")

    _display_strategy(strategy)