Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FreeRDP/FreeRDP-WebConnect.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCosmin Munteanu <cmunteanu@cloudbasesolutions.com>2017-01-18 18:15:11 +0300
committerCosmin Munteanu <cmunteanu@cloudbasesolutions.com>2017-01-18 18:15:11 +0300
commite4492a23041aeb27f2031b9ce418a9205e9d8ea1 (patch)
treeff9f48abef1bb68ad802ea4bcd4cd5dc471ddac5
parent8113cb803db35ac3037cb6a947a4647192ff4d07 (diff)
Adds region for Openstack integration
-rw-r--r--wsgate/nova_token_auth.cpp46
-rw-r--r--wsgate/nova_token_auth.hpp3
-rw-r--r--wsgate/wsgate.ini.sample.in1
-rw-r--r--wsgate/wsgateEHS.cpp8
-rw-r--r--wsgate/wsgateEHS.hpp1
5 files changed, 45 insertions, 14 deletions
diff --git a/wsgate/nova_token_auth.cpp b/wsgate/nova_token_auth.cpp
index 94958f6..7c5cd06 100644
--- a/wsgate/nova_token_auth.cpp
+++ b/wsgate/nova_token_auth.cpp
@@ -20,6 +20,7 @@
#include <cpprest/json.h>
#include "nova_token_auth.hpp"
+#include <iostream>
using namespace pplx;
using namespace std;
@@ -39,12 +40,14 @@ private:
std::pair<std::string, std::string> get_auth_token_data_v2(std::string osAuthUrl,
std::string osUserName,
std::string osPassword,
- std::string osTenantName);
+ std::string osTenantName,
+ std::string osRegion);
std::pair<std::string, std::string> get_auth_token_data_v3(std::string osAuthUrl,
std::string osUserName,
std::string osPassword,
- std::string osTenantName);
+ std::string osTenantName,
+ std::string osRegion);
web::json::value get_console_token_data(std::string authToken,
std::string novaUrl,
@@ -56,7 +59,8 @@ public:
std::string osPassword,
std::string osTenantName,
std::string consoleToken,
- std::string keystoneVersion);
+ std::string keystoneVersion,
+ std::string osRegion);
};
@@ -88,7 +92,8 @@ json::value nova_console_token_auth_impl::get_json_from_response(
std::pair<std::string, std::string> nova_console_token_auth_impl::get_auth_token_data_v2(
string osAuthUrl, string osUserName,
- string osPassword, string osTenantName)
+ string osPassword, string osTenantName,
+ string osRegion)
{
auto jsonRequestBody = json::value::object();
auto auth = json::value::object();
@@ -114,8 +119,19 @@ std::pair<std::string, std::string> nova_console_token_auth_impl::get_auth_token
//get the nova api endpoint
for (auto serviceCatalog : response_json[U("access")][U("serviceCatalog")].as_array())
- if (serviceCatalog[U("name")].as_string() == U("nova"))
- novaUrl = serviceCatalog[U("endpoints")][0][U("adminURL")].as_string();
+ if (serviceCatalog[U("name")].as_string() == U("nova")){
+ if (osRegion.empty()){
+ novaUrl = serviceCatalog[U("endpoints")][0][U("adminURL")].as_string();
+ }
+ else{
+ for (auto endpoint : serviceCatalog[U("endpoints")].as_array()){
+ if (endpoint[U("region")].as_string() == to_string_t(osRegion)){
+ novaUrl = endpoint[U("adminURL")].as_string();
+ }
+ }
+ }
+ }
+
return std::pair<std::string, std::string>(
to_utf8string(authToken),
@@ -124,7 +140,8 @@ std::pair<std::string, std::string> nova_console_token_auth_impl::get_auth_token
std::pair<std::string, std::string> nova_console_token_auth_impl::get_auth_token_data_v3(
string osAuthUrl, string osUserName,
- string osPassword, string osTenantName)
+ string osPassword, string osTenantName,
+ string osRegion)
{
auto jsonRequestBody = json::value::object();
auto auth = json::value::object();
@@ -174,8 +191,10 @@ std::pair<std::string, std::string> nova_console_token_auth_impl::get_auth_token
for (auto serviceCatalog : response_json[U("token")][U("catalog")].as_array())
if (serviceCatalog[U("name")].as_string() == U("nova"))
for (auto endpoint : serviceCatalog[U("endpoints")].as_array())
- if (endpoint[U("interface")].as_string() == U("admin"))
- novaUrl = endpoint[U("url")].as_string();
+ if (endpoint[U("interface")].as_string() == U("admin") &&
+ (endpoint[U("region")].as_string() == to_string_t(osRegion) || osRegion.empty())){
+ novaUrl = endpoint[U("url")].as_string();
+ }
return std::pair<std::string, std::string>(
to_utf8string(authToken),
@@ -202,7 +221,8 @@ json::value nova_console_token_auth_impl::get_console_token_data(
nova_console_info nova_console_token_auth_impl::get_console_info(
std::string osAuthUrl, std::string osUserName,
std::string osPassword, std::string osTenantName,
- std::string consoleToken, std::string keystoneVersion)
+ std::string consoleToken, std::string keystoneVersion,
+ std::string osRegion)
{
std::string authToken;
std::string novaUrl;
@@ -211,13 +231,15 @@ nova_console_info nova_console_token_auth_impl::get_console_info(
std::tie(authToken, novaUrl) = get_auth_token_data_v2(osAuthUrl,
osUserName,
osPassword,
- osTenantName);
+ osTenantName,
+ osRegion);
}
else if (keystoneVersion == KEYSTONE_V3){
std::tie(authToken, novaUrl) = get_auth_token_data_v3(osAuthUrl,
osUserName,
osPassword,
- osTenantName);
+ osTenantName,
+ osRegion);
}
else{
throw std::invalid_argument("Unknown Keystone version");
diff --git a/wsgate/nova_token_auth.hpp b/wsgate/nova_token_auth.hpp
index 7711153..d8f4332 100644
--- a/wsgate/nova_token_auth.hpp
+++ b/wsgate/nova_token_auth.hpp
@@ -70,7 +70,8 @@ namespace wsgate {
std::string osPassword,
std::string osTenantName,
std::string consoleToken,
- std::string keystoneVersion) = 0;
+ std::string keystoneVersion,
+ std::string osRegion) = 0;
};
diff --git a/wsgate/wsgate.ini.sample.in b/wsgate/wsgate.ini.sample.in
index 11aca6c..c4a9c93 100644
--- a/wsgate/wsgate.ini.sample.in
+++ b/wsgate/wsgate.ini.sample.in
@@ -156,6 +156,7 @@ nofullwindowdrag = true
#username = admin
#password = secret
#tenantname = admin
+#region = optional region
[hyperv]
diff --git a/wsgate/wsgateEHS.cpp b/wsgate/wsgateEHS.cpp
index 9e6030c..bd75806 100644
--- a/wsgate/wsgateEHS.cpp
+++ b/wsgate/wsgateEHS.cpp
@@ -287,7 +287,7 @@ namespace wsgate{
nova_console_info info = token_auth->get_console_info(m_sOpenStackAuthUrl, m_sOpenStackUsername,
m_sOpenStackPassword, m_sOpenStackTenantName,
- tokenId, m_sOpenStackKeystoneVersion);
+ tokenId, m_sOpenStackKeystoneVersion, m_sOpenStackRegion);
log::info << "Host: " << info.host << " Port: " << info.port
<< " Internal access path: " << info.internal_access_path
@@ -925,6 +925,12 @@ namespace wsgate{
else {
m_sOpenStackKeystoneVersion = KEYSTONE_V2;
}
+ if (pt.get_optional<std::string>("openstack.region")) {
+ m_sOpenStackRegion.assign(pt.get<std::string>("openstack.region"));
+ }
+ else {
+ m_sOpenStackRegion.clear();
+ }
if (pt.get_optional<std::string>("hyperv.hostusername")) {
m_sHyperVHostUsername.assign(pt.get<std::string>("hyperv.hostusername"));
} else {
diff --git a/wsgate/wsgateEHS.hpp b/wsgate/wsgateEHS.hpp
index 2092412..27499e5 100644
--- a/wsgate/wsgateEHS.hpp
+++ b/wsgate/wsgateEHS.hpp
@@ -116,6 +116,7 @@ namespace wsgate{
string m_sOpenStackPassword;
string m_sOpenStackTenantName;
string m_sOpenStackKeystoneVersion;
+ string m_sOpenStackRegion;
string m_sHyperVHostUsername;
string m_sHyperVHostPassword;