Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Paste
P8848
export.php -- emergency generation of static configs from dbctl data
Active
Public
Actions
Authored by
CDanis
on Aug 1 2019, 3:47 PM.
Edit Paste
Archive Paste
View Raw File
Subscribe
Mute Notifications
Award Token
Flag For Later
Tags
None
Subscribers
None
#!/usr/bin/php
<?php
// This script takes dbctl-JSON-formatted configuration, as produced by e.g.
// dbctl -s eqiad config get
// and transforms it into PHP suitable for pasting into db-eqiad.php in an
// emergency.
// It can also read the JSON 'restore' files output by dbctl config commit,
// with some help from jq:
// jq '.eqiad' /var/cache/conftool/dbconfig/FOO.json
$argc
==
2
or
die
(
"usage: $argv[0] INPUT-JSON-FILE
\n
"
);
$inputfilename
=
$argv
[
1
]
or
die
;
$data
=
json_decode
(
file_get_contents
(
$inputfilename
),
TRUE
);
$data
!=
NULL
or
die
;
$readOnlyBySection
=
$data
[
'readOnlyBySection'
];
$groupLoadsBySection
=
$data
[
'groupLoadsBySection'
];
$sectionLoads
=
[];
foreach
(
$data
[
'sectionLoads'
]
as
$section
=>
$loads
)
{
$sectionLoads
[
$section
]
=
array_merge
(
$loads
[
0
],
$loads
[
1
]);
}
print
'$wgLBFactoryConf[
\'
sectionLoads
\'
] = '
;
var_export
(
$sectionLoads
);
print
";
\n
"
;
print
'$wgLBFactoryConf[
\'
readOnlyBySection
\'
] = '
;
var_export
(
$readOnlyBySection
);
print
";
\n
"
;
print
'$wgLBFactoryConf[
\'
groupLoadsBySection
\'
] = '
;
var_export
(
$groupLoadsBySection
);
print
";
\n
"
;
Event Timeline
CDanis
created this paste.
Aug 1 2019, 3:47 PM
CDanis
changed the title of this paste from
dbctl export.php
to
export.php -- emergency generation of static configs from dbctl data
.
Aug 1 2019, 9:29 PM
CDanis
edited the content of this paste.
(Show Details)
Log In to Comment