diff --git a/mocha-php/src/mocha-php/include/BeforeLaunchEvent.inc.php b/mocha-php/src/mocha-php/include/BeforeLaunchEvent.inc.php
index c80a6ac..6f4ca79 100644
--- a/mocha-php/src/mocha-php/include/BeforeLaunchEvent.inc.php
+++ b/mocha-php/src/mocha-php/include/BeforeLaunchEvent.inc.php
@@ -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;
diff --git a/mocha-php/src/mocha-php/ui/pages/SUVPage.phpx b/mocha-php/src/mocha-php/ui/pages/SUVPage.phpx
index ec31b21..a5fb258 100644
--- a/mocha-php/src/mocha-php/ui/pages/SUVPage.phpx
+++ b/mocha-php/src/mocha-php/ui/pages/SUVPage.phpx
@@ -1,6 +1,7 @@
+
\ No newline at end of file
diff --git a/mocha-php/src/mocha-php/ui/pages/SUVPage.phpx.php b/mocha-php/src/mocha-php/ui/pages/SUVPage.phpx.php
index c5b98fd..33d27fa 100644
--- a/mocha-php/src/mocha-php/ui/pages/SUVPage.phpx.php
+++ b/mocha-php/src/mocha-php/ui/pages/SUVPage.phpx.php
@@ -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 ("
| " . $ex . " |
");
+ }
+ }
+ 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
Name |
suv |
+
+ | Description |
+ |
+
+
+ | Backend |
+ |
+
| Instance Id |
|
@@ -291,80 +452,24 @@ EOF
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)
- {
- ?>
-
- |
- Active |
- Development |
- Local |
- No Charge |
- |
- |
- |
- |
- |
-
- prepare($query);
- try {
- $result = $stmt->execute();
- $rows = $stmt->fetchAll();
- foreach ($rows as $values) {
- if ($values["is_library"] != 0) {
- continue;
- }
- ?>
-
- | "> |
- Active |
- Development |
- Local |
- No Charge |
- |
- |
- |
- |
- |
-
- " . $ex . " | ");
- }
- }
- else
- {
- // FIXME : use mocha-dotnet
- }
+ ?>
+
+ | "> |
+ |
+ |
+ |
+ |
+ |
+ |
+ |
+ |
+ |
+
+