#!/bin/bash

# -------------------------------------------------------------------------- #
# Copyright 2002-2025, OpenNebula Project, OpenNebula Systems                #
#                                                                            #
# Licensed under the Apache License, Version 2.0 (the "License"); you may    #
# not use this file except in compliance with the License. You may obtain    #
# a copy of the License at                                                   #
#                                                                            #
# http://www.apache.org/licenses/LICENSE-2.0                                 #
#                                                                            #
# Unless required by applicable law or agreed to in writing, software        #
# distributed under the License is distributed on an "AS IS" BASIS,          #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
# See the License for the specific language governing permissions and        #
# limitations under the License.                                             #
#--------------------------------------------------------------------------- #

if [ -z "${ONE_LOCATION}" ]; then
    MAD_LOCATION=/usr/lib/one/mads
else
    MAD_LOCATION=$ONE_LOCATION/lib/mads
fi

LOCAL_ACTIONS="deploy,shutdown,reboot,cancel,save,restore,migrate,poll"
LOCAL_ACTIONS="${LOCAL_ACTIONS},pre,post,clean,update_sg"
LOCAL_ACTIONS="${LOCAL_ACTIONS},snapshotcreate,snapshotrevert,snapshotdelete"
LOCAL_ACTIONS="${LOCAL_ACTIONS},attach_nic,detach_nic,update_nic,reset"
LOCAL_ACTIONS="${LOCAL_ACTIONS},prereconfigure,reconfigure"
LOCAL_ACTIONS="${LOCAL_ACTIONS},attach_disk,detach_disk,resize_disk,resize"

exec $MAD_LOCATION/one_vmm_exec -l $LOCAL_ACTIONS $*
