public void login() throws JSONException, LoginException, IOException {
		RestClient client = new RestClient("https://" + pve_hostname
				+ ":8006/api2/json/access/ticket");
		client.addParam("username", pve_username);
		client.addParam("password", pve_password);
		client.addParam("realm", pve_realm);
		try {
			client.execute(RestClient.RequestMethod.POST);
		} catch (Exception e) {
			throw new IOException(e);
		}
		if (client.getResponseCode() == HttpURLConnection.HTTP_OK) {
			// Successfully connected
			JSONObject jObj = new JSONObject(client.getResponse());
			JSONObject data = jObj.getJSONObject("data");
			pve_login_ticket = data.getString("ticket");
			pve_login_token = data.getString("CSRFPreventionToken");
			pve_login_ticket_timestamp = new Date(); // decode from token
			return;
		} else if (client.getResponseCode() == HttpURLConnection.HTTP_INTERNAL_ERROR) {
			throw new LoginException("Login failed. Please try again");
		} else {
			throw new IOException(client.getErrorMessage());
			// error connecting to server, lets just return an error
		}
	}