mirror of
https://kevinblog.sytes.net/Code/Jibo-Revival-Group/JiboExperiments.git
synced 2026-06-16 06:36:22 +00:00
Stub in framework for new .net Open Jibo cloud
This commit is contained in:
34
OpenJibo/scripts/bootstrap/Discover-JiboHosts.ps1
Normal file
34
OpenJibo/scripts/bootstrap/Discover-JiboHosts.ps1
Normal file
@@ -0,0 +1,34 @@
|
||||
param(
|
||||
[string]$LogDirectory = ".",
|
||||
[string[]]$KnownHosts = @(
|
||||
"api.jibo.com",
|
||||
"api-socket.jibo.com",
|
||||
"neo-hub.jibo.com",
|
||||
"neohub.jibo.com"
|
||||
)
|
||||
)
|
||||
|
||||
$resolved = foreach ($host in $KnownHosts) {
|
||||
try {
|
||||
$dns = Resolve-DnsName -Name $host -ErrorAction Stop
|
||||
[pscustomobject]@{
|
||||
Host = $host
|
||||
Addresses = ($dns | Where-Object { $_.IPAddress } | Select-Object -ExpandProperty IPAddress) -join ", "
|
||||
ObservedUtc = [DateTime]::UtcNow.ToString("o")
|
||||
}
|
||||
}
|
||||
catch {
|
||||
[pscustomobject]@{
|
||||
Host = $host
|
||||
Addresses = "<unresolved>"
|
||||
ObservedUtc = [DateTime]::UtcNow.ToString("o")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$resolved | Tee-Object -Variable rows | Format-Table -AutoSize
|
||||
|
||||
$outputPath = Join-Path $LogDirectory "jibo-host-discovery.json"
|
||||
$rows | ConvertTo-Json -Depth 4 | Set-Content -Path $outputPath
|
||||
|
||||
Write-Host "Saved discovery report to $outputPath"
|
||||
23
OpenJibo/scripts/bootstrap/Generate-JiboDnsOverrides.ps1
Normal file
23
OpenJibo/scripts/bootstrap/Generate-JiboDnsOverrides.ps1
Normal file
@@ -0,0 +1,23 @@
|
||||
param(
|
||||
[string]$TargetIp,
|
||||
[string[]]$HostNames = @(
|
||||
"api.jibo.com",
|
||||
"api-socket.jibo.com",
|
||||
"neo-hub.jibo.com",
|
||||
"neohub.jibo.com"
|
||||
)
|
||||
)
|
||||
|
||||
if ([string]::IsNullOrWhiteSpace($TargetIp)) {
|
||||
throw "TargetIp is required."
|
||||
}
|
||||
|
||||
$entries = foreach ($host in $HostNames) {
|
||||
[pscustomobject]@{
|
||||
Host = $host
|
||||
TargetIp = $TargetIp
|
||||
HostsFileLine = "$TargetIp`t$host"
|
||||
}
|
||||
}
|
||||
|
||||
$entries | Format-Table -AutoSize
|
||||
9
OpenJibo/scripts/bootstrap/README.md
Normal file
9
OpenJibo/scripts/bootstrap/README.md
Normal file
@@ -0,0 +1,9 @@
|
||||
# Bootstrap Scripts
|
||||
|
||||
These scripts support the first OpenJibo recovery path:
|
||||
|
||||
- discover which hosts the robot is trying to reach
|
||||
- generate DNS override records for a controlled environment
|
||||
- verify that the robot-facing domains resolve and answer as expected
|
||||
|
||||
They are intentionally non-destructive.
|
||||
30
OpenJibo/scripts/bootstrap/Test-OpenJiboRouting.ps1
Normal file
30
OpenJibo/scripts/bootstrap/Test-OpenJiboRouting.ps1
Normal file
@@ -0,0 +1,30 @@
|
||||
param(
|
||||
[string[]]$Hosts = @(
|
||||
"https://api.jibo.com/health",
|
||||
"https://api-socket.jibo.com/",
|
||||
"https://neo-hub.jibo.com/v1/proactive"
|
||||
)
|
||||
)
|
||||
|
||||
foreach ($url in $Hosts) {
|
||||
try {
|
||||
$response = Invoke-WebRequest -Uri $url -Method Get -SkipCertificateCheck -ErrorAction Stop
|
||||
[pscustomobject]@{
|
||||
Url = $url
|
||||
StatusCode = $response.StatusCode
|
||||
Success = $true
|
||||
}
|
||||
}
|
||||
catch {
|
||||
$statusCode = $null
|
||||
if ($_.Exception.Response -and $_.Exception.Response.StatusCode) {
|
||||
$statusCode = [int]$_.Exception.Response.StatusCode
|
||||
}
|
||||
|
||||
[pscustomobject]@{
|
||||
Url = $url
|
||||
StatusCode = $statusCode
|
||||
Success = $false
|
||||
}
|
||||
}
|
||||
}
|
||||
32
OpenJibo/scripts/cloud/Invoke-CloudSmoke.ps1
Normal file
32
OpenJibo/scripts/cloud/Invoke-CloudSmoke.ps1
Normal file
@@ -0,0 +1,32 @@
|
||||
param(
|
||||
[string]$BaseUrl = "http://localhost:5000"
|
||||
)
|
||||
|
||||
$checks = @(
|
||||
@{ Name = "Health"; Method = "GET"; Url = "$BaseUrl/health"; Headers = @{}; Body = $null },
|
||||
@{ Name = "CreateHubToken"; Method = "POST"; Url = "$BaseUrl/"; Headers = @{ "X-Amz-Target" = "Account_20160715.CreateHubToken"; Host = "api.jibo.com" }; Body = "{}" },
|
||||
@{ Name = "NewRobotToken"; Method = "POST"; Url = "$BaseUrl/"; Headers = @{ "X-Amz-Target" = "Notification_20160715.NewRobotToken"; Host = "api.jibo.com" }; Body = '{"deviceId":"my-robot-serial-number"}' }
|
||||
)
|
||||
|
||||
foreach ($check in $checks) {
|
||||
try {
|
||||
$response = Invoke-WebRequest -Uri $check.Url -Method $check.Method -Headers $check.Headers -Body $check.Body -ContentType "application/json"
|
||||
[pscustomobject]@{
|
||||
Name = $check.Name
|
||||
StatusCode = $response.StatusCode
|
||||
Success = $true
|
||||
}
|
||||
}
|
||||
catch {
|
||||
$statusCode = $null
|
||||
if ($_.Exception.Response -and $_.Exception.Response.StatusCode) {
|
||||
$statusCode = [int]$_.Exception.Response.StatusCode
|
||||
}
|
||||
|
||||
[pscustomobject]@{
|
||||
Name = $check.Name
|
||||
StatusCode = $statusCode
|
||||
Success = $false
|
||||
}
|
||||
}
|
||||
}
|
||||
37
OpenJibo/scripts/cloud/Invoke-ProtocolFixture.ps1
Normal file
37
OpenJibo/scripts/cloud/Invoke-ProtocolFixture.ps1
Normal file
@@ -0,0 +1,37 @@
|
||||
param(
|
||||
[string]$BaseUrl = "http://localhost:5000",
|
||||
[string]$FixturePath
|
||||
)
|
||||
|
||||
if ([string]::IsNullOrWhiteSpace($FixturePath)) {
|
||||
throw "FixturePath is required."
|
||||
}
|
||||
|
||||
$fixture = Get-Content $FixturePath | ConvertFrom-Json
|
||||
$headers = @{}
|
||||
|
||||
foreach ($property in $fixture.headers.PSObject.Properties) {
|
||||
$headers[$property.Name] = [string]$property.Value
|
||||
}
|
||||
|
||||
if (-not $headers.ContainsKey("Host") -and $fixture.host) {
|
||||
$headers["Host"] = [string]$fixture.host
|
||||
}
|
||||
|
||||
$body = ""
|
||||
if ($null -ne $fixture.body) {
|
||||
$body = $fixture.body | ConvertTo-Json -Depth 10
|
||||
}
|
||||
|
||||
$response = Invoke-WebRequest `
|
||||
-Uri ($BaseUrl + [string]$fixture.path) `
|
||||
-Method ([string]$fixture.method) `
|
||||
-Headers $headers `
|
||||
-Body $body `
|
||||
-ContentType "application/json"
|
||||
|
||||
[pscustomobject]@{
|
||||
Fixture = $FixturePath
|
||||
StatusCode = $response.StatusCode
|
||||
Body = $response.Content
|
||||
}
|
||||
8
OpenJibo/scripts/cloud/README.md
Normal file
8
OpenJibo/scripts/cloud/README.md
Normal file
@@ -0,0 +1,8 @@
|
||||
# Cloud Scripts
|
||||
|
||||
These scripts help exercise the new .NET hosted cloud locally.
|
||||
|
||||
- `Invoke-CloudSmoke.ps1`
|
||||
Runs a few quick HTTP checks against a local OpenJibo cloud instance.
|
||||
- `Invoke-ProtocolFixture.ps1`
|
||||
Replays a sanitized HTTP fixture against a running local instance.
|
||||
Reference in New Issue
Block a user