add SUV backend information and JSON API for getting SUV details
This commit is contained in:
parent
5e70c59ed6
commit
dd21d24856
@ -55,7 +55,7 @@ System::$BeforeLaunchEventHandler = function($path)
|
|||||||
}
|
}
|
||||||
else if ($path[0] == "suv")
|
else if ($path[0] == "suv")
|
||||||
{
|
{
|
||||||
if (count($path) == 2 && ($path[1] == "suvinfo.html" || $path[1] == "phpinfo.html"))
|
if (count($path) == 2 && ($path[1] == "suvinfo.html" || $path[1] == "phpinfo.html" || $path[1] == "suvinfo.json"))
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
<Website>
|
<Website>
|
||||||
<Pages>
|
<Pages>
|
||||||
<Page FileName="suv/suvinfo.html" CodeBehindClassName="Mocha\UI\Pages\SUVPage" />
|
<Page FileName="suv/suvinfo.html" CodeBehindClassName="Mocha\UI\Pages\SUVPage" />
|
||||||
|
<Page FileName="suv/suvinfo.json" CodeBehindClassName="Mocha\UI\Pages\SUVPage" />
|
||||||
<Page FileName="suv/phpinfo.html" CodeBehindClassName="Mocha\UI\Pages\SUVPage" />
|
<Page FileName="suv/phpinfo.html" CodeBehindClassName="Mocha\UI\Pages\SUVPage" />
|
||||||
</Pages>
|
</Pages>
|
||||||
</Website>
|
</Website>
|
||||||
@ -32,6 +32,93 @@
|
|||||||
|
|
||||||
class SUVPage extends WebPage
|
class SUVPage extends WebPage
|
||||||
{
|
{
|
||||||
|
|
||||||
|
private function getTenants() : array
|
||||||
|
{
|
||||||
|
$tenants = array();
|
||||||
|
$use_dotnet = true;
|
||||||
|
|
||||||
|
if ($use_dotnet)
|
||||||
|
{
|
||||||
|
// using .NET OMS
|
||||||
|
$curl = curl_init("http://localhost:4436/tenants");
|
||||||
|
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
|
||||||
|
if ($curl == false)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$result = curl_exec($curl);
|
||||||
|
$json = json_decode($result, true);
|
||||||
|
if ($json["result"] == "success")
|
||||||
|
{
|
||||||
|
foreach ($json["tenants"] as $tenant)
|
||||||
|
{
|
||||||
|
$tenants[] = array
|
||||||
|
(
|
||||||
|
"name" => $tenant,
|
||||||
|
"status" => "Active",
|
||||||
|
"tenantType" => "Development",
|
||||||
|
"dataCenter" => "Local",
|
||||||
|
"charge" => "No Charge",
|
||||||
|
"initialTerm" => null,
|
||||||
|
"renewalTerm" => null,
|
||||||
|
"tenantStartDate" => null,
|
||||||
|
"tenantExpirationDate" => null,
|
||||||
|
"purpose" => ""
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
global $pdo;
|
||||||
|
if ($pdo !== null)
|
||||||
|
{
|
||||||
|
global $basepath;
|
||||||
|
|
||||||
|
$query = "SELECT * FROM mocha_tenants";
|
||||||
|
$stmt = $pdo->prepare($query);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
$result = $stmt->execute();
|
||||||
|
$rows = $stmt->fetchAll();
|
||||||
|
foreach ($rows as $values)
|
||||||
|
{
|
||||||
|
if ($values["is_library"] != 0)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$tenants[] = array
|
||||||
|
(
|
||||||
|
"name" => $values["tenant_name"],
|
||||||
|
"status" => "Active",
|
||||||
|
"tenantType" => "Development",
|
||||||
|
"dataCenter" => "Local",
|
||||||
|
"charge" => "No Charge",
|
||||||
|
"initialTerm" => null,
|
||||||
|
"renewalTerm" => null,
|
||||||
|
"tenantStartDate" => null,
|
||||||
|
"tenantExpirationDate" => null,
|
||||||
|
"purpose" => $values["tenant_purpose"]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (\Exception $ex)
|
||||||
|
{
|
||||||
|
// echo ("<tr><td colspan=\"10\">" . $ex . "</td></tr>");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// FIXME : use mocha-dotnet
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $tenants;
|
||||||
|
}
|
||||||
|
|
||||||
protected function OnPreRender(CancelEventArgs $e)
|
protected function OnPreRender(CancelEventArgs $e)
|
||||||
{
|
{
|
||||||
global $basepath;
|
global $basepath;
|
||||||
@ -69,6 +156,56 @@
|
|||||||
phpinfo();
|
phpinfo();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
else if ($path[1] == "suvinfo.json")
|
||||||
|
{
|
||||||
|
header("Content-Type: application/json");
|
||||||
|
|
||||||
|
$suvtype_file = "/etc/mocha/suvtype";
|
||||||
|
$backend = null;
|
||||||
|
if (file_exists($suvtype_file))
|
||||||
|
{
|
||||||
|
$backend = file_get_contents($suvtype_file);
|
||||||
|
}
|
||||||
|
|
||||||
|
$json = array
|
||||||
|
(
|
||||||
|
"name" => "suv",
|
||||||
|
"description" => "",
|
||||||
|
"backend" => $backend,
|
||||||
|
"hostName" => $_SERVER["SERVER_NAME"],
|
||||||
|
"environmentVersion" => 58132,
|
||||||
|
"confidenceLevel" => "prod",
|
||||||
|
"status" => "completed",
|
||||||
|
"tenants" => array
|
||||||
|
(
|
||||||
|
array
|
||||||
|
(
|
||||||
|
"name" => "super",
|
||||||
|
"status" => "active",
|
||||||
|
"tenantType" => "development",
|
||||||
|
"dataCenter" => "local",
|
||||||
|
"charge" => "noCharge",
|
||||||
|
"initialTerm" => "",
|
||||||
|
"renewalTerm" => "",
|
||||||
|
"tenantStartDate" => "",
|
||||||
|
"tenantExpirationDate" => "",
|
||||||
|
"purpose" => ""
|
||||||
|
)
|
||||||
|
),
|
||||||
|
"database" => array
|
||||||
|
(
|
||||||
|
"backend" => "mysql",
|
||||||
|
"userName" => System::GetConfigurationValue("Database.UserName"),
|
||||||
|
"hostName" => System::GetConfigurationValue("Database.ServerName"),
|
||||||
|
"portNumber" => intval(System::GetConfigurationValue("Database.PortNumber")),
|
||||||
|
"status" => "running"
|
||||||
|
)
|
||||||
|
);
|
||||||
|
echo (json_encode($json));
|
||||||
|
|
||||||
|
$e->Handled = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$ctx = new OmsContext();
|
$ctx = new OmsContext();
|
||||||
|
|
||||||
@ -234,6 +371,30 @@ EOF
|
|||||||
<td>Name</td>
|
<td>Name</td>
|
||||||
<td>suv</td>
|
<td>suv</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Description</td>
|
||||||
|
<td><?php
|
||||||
|
$suvtype_file = "/etc/mocha/suvdesc";
|
||||||
|
if (file_exists($suvtype_file))
|
||||||
|
{
|
||||||
|
echo (file_get_contents($suvtype_file));
|
||||||
|
}
|
||||||
|
?></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Backend</td>
|
||||||
|
<td><?php
|
||||||
|
$suvtype_file = "/etc/mocha/suvtype";
|
||||||
|
if (file_exists($suvtype_file))
|
||||||
|
{
|
||||||
|
echo (file_get_contents($suvtype_file));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
echo ("(unknown)");
|
||||||
|
}
|
||||||
|
?></td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>Instance Id</td>
|
<td>Instance Id</td>
|
||||||
<td><?php echo($_SERVER["SERVER_NAME"]); ?></td>
|
<td><?php echo($_SERVER["SERVER_NAME"]); ?></td>
|
||||||
@ -291,81 +452,25 @@ EOF
|
|||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<?php
|
<?php
|
||||||
$use_dotnet = true;
|
|
||||||
|
|
||||||
if ($use_dotnet)
|
|
||||||
{
|
|
||||||
// using .NET OMS
|
|
||||||
$curl = curl_init("http://localhost:4436/tenants");
|
|
||||||
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
|
|
||||||
if ($curl == false)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$result = curl_exec($curl);
|
|
||||||
$json = json_decode($result, true);
|
|
||||||
if ($json["result"] == "success")
|
|
||||||
{
|
|
||||||
foreach ($json["tenants"] as $tenant)
|
|
||||||
{
|
|
||||||
?>
|
|
||||||
<tr>
|
|
||||||
<td><?php echo($tenant); ?></td>
|
|
||||||
<td>Active</td>
|
|
||||||
<td>Development</td>
|
|
||||||
<td>Local</td>
|
|
||||||
<td>No Charge</td>
|
|
||||||
<td></td>
|
|
||||||
<td></td>
|
|
||||||
<td></td>
|
|
||||||
<td></td>
|
|
||||||
<td></td>
|
|
||||||
</tr>
|
|
||||||
<?php
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
global $pdo;
|
|
||||||
if ($pdo !== null) {
|
|
||||||
global $basepath;
|
global $basepath;
|
||||||
|
$tenants = $this->getTenants();
|
||||||
$query = "SELECT * FROM mocha_tenants";
|
foreach ($tenants as $tenant)
|
||||||
$stmt = $pdo->prepare($query);
|
{
|
||||||
try {
|
|
||||||
$result = $stmt->execute();
|
|
||||||
$rows = $stmt->fetchAll();
|
|
||||||
foreach ($rows as $values) {
|
|
||||||
if ($values["is_library"] != 0) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
?>
|
?>
|
||||||
<tr>
|
<tr>
|
||||||
<td><a class="uwt-external-link" target="_blank" href="<?php echo ("https://" . $basepath . "/" . $values["tenant_name"]); ?>"><?php echo ($values["tenant_name"]); ?></a></td>
|
<td><a class="uwt-external-link" target="_blank" href="<?php echo ("https://" . $basepath . "/" . $tenant["name"]); ?>"><?php echo ($tenant["name"]); ?></a></td>
|
||||||
<td>Active</td>
|
<td><?php echo($tenant["status"]); ?></td>
|
||||||
<td>Development</td>
|
<td><?php echo($tenant["tenantType"]); ?></td>
|
||||||
<td>Local</td>
|
<td><?php echo($tenant["dataCenter"]); ?></td>
|
||||||
<td>No Charge</td>
|
<td><?php echo($tenant["charge"]); ?></td>
|
||||||
<td></td>
|
<td><?php echo($tenant["initialTerm"]); ?></td>
|
||||||
<td></td>
|
<td><?php echo($tenant["renewalTerm"]); ?></td>
|
||||||
<td></td>
|
<td><?php echo($tenant["tenantStartDate"]); ?></td>
|
||||||
<td></td>
|
<td><?php echo($tenant["tenantExpirationDate"]); ?></td>
|
||||||
<td><?php echo ($values["tenant_purpose"]); ?></td>
|
<td><?php echo($tenant["purpose"]); ?></td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
} catch (\Exception $ex) {
|
|
||||||
echo ("<tr><td colspan=\"10\">" . $ex . "</td></tr>");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// FIXME : use mocha-dotnet
|
|
||||||
}
|
|
||||||
}
|
|
||||||
?>
|
?>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user