Esempio n. 1
0
function onapp_UnsuspendAccount($params)
{
    global $_LANG;
    if (wrapper_check()) {
        return wrapper_check();
    }
    $status = serviceStatus($params['serviceid']);
    serviceStatus($params['serviceid'], 'Active');
    $vm = get_vm($params['serviceid']);
    if ($vm->_obj->_id && $vm->_obj->_suspended) {
        $vm->_obj->auth($params['serverip'] ? $params['serverip'] : $params['serverhostname'], $params['serverusername'], $params['serverpassword']);
        $vm->_obj->suspend();
        if (!is_null($vm->error)) {
            return is_array($vm->error) ? $_LANG["onappcantdeletevm"] . "<br/>\n " . implode(', ', $vm->error) : $_LANG["onappcantdeletevm"] . $vm->error;
        } elseif (!is_null($vm->_obj->error)) {
            return is_array($vm->_obj->error) ? $_LANG["onappcantdeletevm"] . "<br/>\n " . implode(', ', $vm->_obj->error) : $_LANG["onappcantdeletevm"] . $vm->_obj->error;
        }
    } else {
        return $_LANG['onappvmalreadyactive'];
    }
    serviceStatus($params['serviceid'], 'Suspended');
    return 'success';
}
Esempio n. 2
0
function get_vm_interface($service_id)
{
    $vm = get_vm($service_id);
    $service = get_service($service_id);
    $network = new ONAPP_VirtualMachine_NetworkInterface();
    $onapp_config = get_onapp_config($service['serverid']);
    $network->auth($onapp_config["adress"], $onapp_config['username'], $onapp_config['password']);
    $network->_virtual_machine_id = $vm->_id;
    $networks = $network->getList();
    foreach ($networks as $net) {
        if ($net->_primary == true) {
            $result = $net;
        }
    }
    $result->auth($onapp_config["adress"], $onapp_config['username'], $onapp_config['password']);
    return $result;
}
Esempio n. 3
0
/**
 * Action delete backup
 */
function _action_backup_delete($id, $backupid)
{
    if (is_null($backupid)) {
        return array('error' => 'Backup ID not set');
    }
    $vm = get_vm($id);
    $service = get_service($id);
    $onapp_config = get_onapp_config($service['serverid']);
    $backup = new ONAPP_VirtualMachine_Backup();
    $backup->_id = $backupid;
    $user = get_onapp_client($id);
    $backup->auth($onapp_config["adress"], $user["email"], $user["password"]);
    $backup->delete();
    if (!is_null($backup->error)) {
        return array('error' => is_array($backup->error) ? "Can't create Backup<br/>\n " . implode('.<br>', $backup->error) : "Can't create Backup'" . $backup->error);
    } else {
        return true;
    }
}