コード例 #1
0
ファイル: sw_update.py プロジェクト: NaiveOpenStack/stx-nfv
def get_strategies(token_id, url, strategy_name):
    """
    Software Update - Get Strategies
    """
    api_cmd = url + "/api/orchestration/%s/strategy" % strategy_name

    api_cmd_headers = dict()
    api_cmd_headers['X-Auth-Token'] = token_id

    response = rest_api.request(token_id, "GET", api_cmd, api_cmd_headers)
    if not response:
        return None

    return _get_strategy_object_from_response(response)
コード例 #2
0
ファイル: sw_update.py プロジェクト: NaiveOpenStack/stx-nfv
def abort_strategy(token_id, url, strategy_name, stage_id):
    """
    Software Update - Abort Strategy
    """
    api_cmd = url + ("/api/orchestration/%s/strategy/actions" % strategy_name)

    api_cmd_headers = dict()
    api_cmd_headers['Content-Type'] = "application/json"
    api_cmd_headers['X-Auth-Token'] = token_id

    api_cmd_payload = dict()
    api_cmd_payload['action'] = 'abort-stage'
    api_cmd_payload['stage-id'] = stage_id

    response = rest_api.request(token_id, "POST", api_cmd, api_cmd_headers,
                                json.dumps(api_cmd_payload))
    if not response:
        return None

    return _get_strategy_object_from_response(response)
コード例 #3
0
ファイル: sw_update.py プロジェクト: NaiveOpenStack/stx-nfv
def delete_strategy(token_id, url, strategy_name, force=False):
    """
    Software Update - Delete Strategy
    """
    api_cmd = url + "/api/orchestration/%s/strategy" % strategy_name

    api_cmd_headers = dict()
    api_cmd_headers['Content-Type'] = "application/json"
    api_cmd_headers['X-Auth-Token'] = token_id

    api_cmd_payload = dict()
    api_cmd_payload['force'] = force

    response = rest_api.request(token_id, "DELETE", api_cmd, api_cmd_headers,
                                json.dumps(api_cmd_payload))
    # We expect an empty response body for this request (204 NO CONTENT). If
    # there is no response body it is a 404 NOT FOUND which means there was
    # no strategy to delete.
    if response is None:
        return False

    return True
コード例 #4
0
ファイル: sw_update.py プロジェクト: NaiveOpenStack/stx-nfv
def create_strategy(token_id, url, strategy_name, controller_apply_type,
                    storage_apply_type, swift_apply_type, compute_apply_type,
                    max_parallel_compute_hosts,
                    default_instance_action, alarm_restrictions, **kwargs):
    """
    Software Update - Create Strategy
    """
    api_cmd = url + "/api/orchestration/%s/strategy" % strategy_name

    api_cmd_headers = dict()
    api_cmd_headers['Content-Type'] = "application/json"
    api_cmd_headers['X-Auth-Token'] = token_id

    api_cmd_payload = dict()
    if 'sw-patch' == strategy_name:
        api_cmd_payload['controller-apply-type'] = controller_apply_type
        api_cmd_payload['swift-apply-type'] = swift_apply_type
        api_cmd_payload['default-instance-action'] = default_instance_action
    elif 'sw-upgrade' == strategy_name:
        if 'start_upgrade' in kwargs and kwargs['start_upgrade']:
            api_cmd_payload['start-upgrade'] = True
        if 'complete_upgrade' in kwargs and kwargs['complete_upgrade']:
            api_cmd_payload['complete-upgrade'] = True
    api_cmd_payload['storage-apply-type'] = storage_apply_type
    api_cmd_payload['compute-apply-type'] = compute_apply_type
    if max_parallel_compute_hosts is not None:
        api_cmd_payload['max-parallel-compute-hosts'] = \
            max_parallel_compute_hosts
    api_cmd_payload['alarm-restrictions'] = alarm_restrictions

    response = rest_api.request(token_id, "POST", api_cmd, api_cmd_headers,
                                json.dumps(api_cmd_payload))
    if not response:
        return None

    return _get_strategy_object_from_response(response)