From 001618d719dd92e309cc81bd676f036ca16d9bd7 Mon Sep 17 00:00:00 2001 From: Deon George Date: Sun, 21 Apr 2024 22:10:12 +1000 Subject: [PATCH] Move zone:check to debug namespace, add address:check command --- app/Console/Commands/Debug/AddressCheck.php | 32 +++++++++++++++++++ .../Commands/{ => Debug}/ZoneCheck.php | 13 ++++---- 2 files changed, 39 insertions(+), 6 deletions(-) create mode 100644 app/Console/Commands/Debug/AddressCheck.php rename app/Console/Commands/{ => Debug}/ZoneCheck.php (83%) diff --git a/app/Console/Commands/Debug/AddressCheck.php b/app/Console/Commands/Debug/AddressCheck.php new file mode 100644 index 0000000..3ea2269 --- /dev/null +++ b/app/Console/Commands/Debug/AddressCheck.php @@ -0,0 +1,32 @@ +argument('ftn')); + + if (! $o) { + $this->error(sprintf('Address: %s doesnt exist?',$this->argument('ftn'))); + return Command::FAILURE; + } + + $this->info(sprintf('Address: %s',$o->ftn)); + $this->info(sprintf('Uplink: %s',$o->parent()?->ftn)); + $this->info(sprintf('Our Address: %s',our_address($o)?->ftn)); + $this->info(sprintf('Domain Addresses: %s',our_address($o->zone->domain)->pluck('ftn4d')->join(','))); + + return Command::SUCCESS; + } +} \ No newline at end of file diff --git a/app/Console/Commands/ZoneCheck.php b/app/Console/Commands/Debug/ZoneCheck.php similarity index 83% rename from app/Console/Commands/ZoneCheck.php rename to app/Console/Commands/Debug/ZoneCheck.php index bf2e188..43687b1 100644 --- a/app/Console/Commands/ZoneCheck.php +++ b/app/Console/Commands/Debug/ZoneCheck.php @@ -1,14 +1,14 @@ warn('Zone: '.$zo->zone_id); $this->info(sprintf('- Our address(es): %s',our_address($do)->pluck('ftn4d')->join(','))); - $this->table(['id','ftn','role','parent','region_id','host_id','hub_id','system','notes'],$zo->addresses()->FTNorder()->active()->with(['system'])->get()->transform(function($item) { + $this->table(['id','ftn','role','parent','our_address','region_id','host_id','hub_id','system','notes'],$zo->addresses()->FTNorder()->active()->with(['system'])->get()->transform(function($item) { return [ 'id'=>$item->id, 'ftn'=>$item->ftn4d, 'role'=>$item->role_name, - 'parent'=>$item->parent()?->ftn4d, + 'parent'=>($x=$item->parent())?->ftn4d, + 'our_address'=>$x ? our_address($item->parent())->ftn4d : '', 'region_id'=>$item->region_id, 'host_id'=>$item->host_id, 'hub_id'=>$item->hub_id,