private JSONObject pve_action(String Path, RestClient.RequestMethod method,
			Map<String, String> data) throws JSONException, LoginException, IOException {
		pve_check_login_ticket();
		if (!Path.startsWith("/"))
			Path = "/".concat(Path);
		RestClient client = new RestClient("https://" + this.pve_hostname + ":8006/api2/json"
				+ Path);
		if (!method.equals(RestClient.RequestMethod.GET))
			client.addHeader("CSRFPreventionToken", pve_login_token);
		client.addHeader("Cookie", "PVEAuthCookie=" + pve_login_ticket);
		if (data != null)
			for (Map.Entry<String, String> entry : data.entrySet()) {
				client.addParam(entry.getKey(), entry.getValue());
			}
		try {
			client.execute(method);
		} catch (Exception e) {
			throw new IOException(e);
		}
		if (client.getResponseCode() == HttpURLConnection.HTTP_OK) {
			// Successfully connected
			return new JSONObject(client.getResponse());
		} else if (client.getResponseCode() == HttpURLConnection.HTTP_UNAUTHORIZED) {
			throw new LoginException(client.getErrorMessage());
		} else if (client.getResponseCode() == HttpURLConnection.HTTP_BAD_REQUEST) {
			// TODO: find a better exception
			throw new IOException(client.getErrorMessage());
		} else {
			throw new IOException(client.getErrorMessage());
			// error connecting to server, lets just return an error
		}
	}