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")
|
||||
{
|
||||
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;
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
<Website>
|
||||
<Pages>
|
||||
<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" />
|
||||
</Pages>
|
||||
</Website>
|
||||
@ -32,6 +32,93 @@
|
||||
|
||||
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)
|
||||
{
|
||||
global $basepath;
|
||||
@ -69,7 +156,57 @@
|
||||
phpinfo();
|
||||
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();
|
||||
|
||||
$htmlRenderer = new HTMLRenderer($ctx, true);
|
||||
@ -234,6 +371,30 @@ EOF
|
||||
<td>Name</td>
|
||||
<td>suv</td>
|
||||
</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>
|
||||
<td>Instance Id</td>
|
||||
<td><?php echo($_SERVER["SERVER_NAME"]); ?></td>
|
||||
@ -291,80 +452,24 @@ EOF
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
$use_dotnet = true;
|
||||
|
||||
if ($use_dotnet)
|
||||
global $basepath;
|
||||
$tenants = $this->getTenants();
|
||||
foreach ($tenants as $tenant)
|
||||
{
|
||||
// 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;
|
||||
|
||||
$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;
|
||||
}
|
||||
?>
|
||||
<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>Active</td>
|
||||
<td>Development</td>
|
||||
<td>Local</td>
|
||||
<td>No Charge</td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td><?php echo ($values["tenant_purpose"]); ?></td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
} catch (\Exception $ex) {
|
||||
echo ("<tr><td colspan=\"10\">" . $ex . "</td></tr>");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// FIXME : use mocha-dotnet
|
||||
}
|
||||
?>
|
||||
<tr>
|
||||
<td><a class="uwt-external-link" target="_blank" href="<?php echo ("https://" . $basepath . "/" . $tenant["name"]); ?>"><?php echo ($tenant["name"]); ?></a></td>
|
||||
<td><?php echo($tenant["status"]); ?></td>
|
||||
<td><?php echo($tenant["tenantType"]); ?></td>
|
||||
<td><?php echo($tenant["dataCenter"]); ?></td>
|
||||
<td><?php echo($tenant["charge"]); ?></td>
|
||||
<td><?php echo($tenant["initialTerm"]); ?></td>
|
||||
<td><?php echo($tenant["renewalTerm"]); ?></td>
|
||||
<td><?php echo($tenant["tenantStartDate"]); ?></td>
|
||||
<td><?php echo($tenant["tenantExpirationDate"]); ?></td>
|
||||
<td><?php echo($tenant["purpose"]); ?></td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</tbody>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user