Changes to address_active index means our host_id needs to be unique across the zone
This commit is contained in:
@@ -10,6 +10,8 @@ use App\Models\{Address,Domain,System,Zone};
|
||||
|
||||
class NodeHierarchy extends Seeder
|
||||
{
|
||||
public const DEBUG=TRUE;
|
||||
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
@@ -45,7 +47,7 @@ class NodeHierarchy extends Seeder
|
||||
private function hierarchy(Domain $domain,int $zoneid)
|
||||
{
|
||||
$regions = [1,2];
|
||||
$hosts = [0,1];
|
||||
//$hosts = [20,30];
|
||||
$hubs = [1000,2000];
|
||||
$nodes = [1,2,3];
|
||||
$hubnodes = [-1,+1];
|
||||
@@ -63,6 +65,9 @@ class NodeHierarchy extends Seeder
|
||||
]);
|
||||
|
||||
$zo = Zone::where('zone_id',$zoneid)->where('domain_id',$domain->id)->singleOrFail();
|
||||
if (self::DEBUG)
|
||||
dump(['zo'=>$zo->zone_id,'rid'=>0,'hid'=>0,'nid'=>0]);
|
||||
|
||||
DB::table('addresses')
|
||||
->insert([
|
||||
'zone_id'=>$zo->id,
|
||||
@@ -77,8 +82,11 @@ class NodeHierarchy extends Seeder
|
||||
'updated_at'=>Carbon::now(),
|
||||
]);
|
||||
|
||||
// Nodes
|
||||
// ZC Nodes
|
||||
foreach ($nodes as $nid) {
|
||||
if (self::DEBUG)
|
||||
dump(['rid'=>$zo->zone_id,'hid'=>$zo->zone_id,'nid'=>$nid]);
|
||||
|
||||
$so = $this->system(sprintf('Node %03d:%03d/%03d.0@%s (ZC Node)',$zoneid,0,$nid,$domain->name));
|
||||
DB::table('addresses')
|
||||
->insert([
|
||||
@@ -95,15 +103,22 @@ class NodeHierarchy extends Seeder
|
||||
]);
|
||||
}
|
||||
|
||||
if (self::DEBUG)
|
||||
dump(['end'=>'nodes top']);
|
||||
|
||||
// Regions
|
||||
foreach ($regions as $rid) {
|
||||
$hostid = $rid;
|
||||
if (self::DEBUG)
|
||||
dump(['rid'=>$rid,'hid'=>$hostid,'nid'=>0]);
|
||||
|
||||
$so = $this->system(sprintf('Region %03d:%03d/%03d.0@%s',$zoneid,$rid,0,$domain->name));
|
||||
DB::table('addresses')
|
||||
->insert([
|
||||
'zone_id'=>$zo->id,
|
||||
'active'=>TRUE,
|
||||
'region_id'=>$rid,
|
||||
'host_id'=>0,
|
||||
'host_id'=>$rid,
|
||||
'node_id'=>0,
|
||||
'point_id'=>0,
|
||||
'system_id'=>$so->id,
|
||||
@@ -112,15 +127,18 @@ class NodeHierarchy extends Seeder
|
||||
'updated_at'=>Carbon::now(),
|
||||
]);
|
||||
|
||||
// Nodes
|
||||
// RC Nodes
|
||||
foreach ($nodes as $nid) {
|
||||
if (self::DEBUG)
|
||||
dump(['rid'=>$rid,'hid'=>$hostid,'nid'=>$nid]);
|
||||
|
||||
$so = $this->system(sprintf('Node %03d:%03d/%03d.0@%s (RC Node)',$zoneid,$rid,$nid,$domain->name));
|
||||
DB::table('addresses')
|
||||
->insert([
|
||||
'zone_id'=>$zo->id,
|
||||
'active'=>TRUE,
|
||||
'region_id'=>$rid,
|
||||
'host_id'=>0,
|
||||
'host_id'=>$rid,
|
||||
'node_id'=>$nid,
|
||||
'point_id'=>0,
|
||||
'system_id'=>$so->id,
|
||||
@@ -129,11 +147,16 @@ class NodeHierarchy extends Seeder
|
||||
'updated_at'=>Carbon::now(),
|
||||
]);
|
||||
}
|
||||
dump(['end'=>'NODES regions']);
|
||||
|
||||
// Hosts
|
||||
foreach ($hosts as $hid) {
|
||||
$hostid = $rid*10+$hid;
|
||||
foreach ($regions as $rrid) {
|
||||
$hostid = $rid*10+$rrid-1;
|
||||
if (self::DEBUG)
|
||||
dump(['rid'=>$rid,'hid'=>$hostid,'nid'=>0]);
|
||||
|
||||
$so = $this->system(sprintf('Host %03d:%03d/0.0@%s (Region %03d)',$zoneid,$hostid,$domain->name,$rid));
|
||||
|
||||
DB::table('addresses')
|
||||
->insert([
|
||||
'zone_id'=>$zo->id,
|
||||
@@ -150,6 +173,9 @@ class NodeHierarchy extends Seeder
|
||||
|
||||
// Nodes
|
||||
foreach ($nodes as $nid) {
|
||||
if (self::DEBUG)
|
||||
dump(['rid'=>$rid,'hid'=>$hostid,'nid'=>$nid]);
|
||||
|
||||
$so = $this->system(sprintf('Node %03d:%03d/%03d.0@%s (Region %03d) - Host Node',$zoneid,$hostid,$nid,$domain->name,$rid));
|
||||
DB::table('addresses')
|
||||
->insert([
|
||||
@@ -203,7 +229,10 @@ class NodeHierarchy extends Seeder
|
||||
}
|
||||
}
|
||||
}
|
||||
dump(['end'=>'NODES normal']);
|
||||
}
|
||||
|
||||
dump(['end'=>'heirarchy']);
|
||||
}
|
||||
|
||||
private function system(string $name): System
|
||||
|
Reference in New Issue
Block a user