@@ -42,6 +42,8 @@ def parser():
4242 ssh Open SSH or run --ssh-command; preserve remote output and exit
4343 delete Delete owned resources, subject to destruction protection
4444 smtp-test Send one explicit SMTP test using --to
45+ dns-evidence Inspect safe exact application DNS adoption evidence
46+ adopt-dns Transfer one exact existing application A record
4547 adopt-app Transfer a verified existing application after draining prior delivery
4648 adopt Recover an existing instance with matching deployment UUID tags
4749 rotate-host-key Finish bootstrap host-key migration without application changes
@@ -60,7 +62,7 @@ def parser():
6062
6163Configuration defaults to colors.yml in the current working directory.
6264Use -f to select a deployment. Run without arguments to show this help.''' )
63- p .add_argument ('command' , metavar = 'COMMAND' , choices = ['init' , 'plan' , 'converge' , 'status' , 'ssh' , 'delete' , 'adopt' , 'adopt-app' , 'smtp-test' , 'rotate-host-key' , 'vault-save' , 'vault-restore' ], help = 'Deployment or Vault command listed below' )
65+ p .add_argument ('command' , metavar = 'COMMAND' , choices = ['init' , 'plan' , 'converge' , 'status' , 'ssh' , 'delete' , 'adopt' , 'adopt-app' , 'adopt-dns' , 'dns-evidence' , ' smtp-test' , 'rotate-host-key' , 'vault-save' , 'vault-restore' ], help = 'Deployment or Vault command listed below' )
6466 p .add_argument ('-f' , '--file' , help = 'Configuration file (default: ./colors.yml in the current working directory)' )
6567 p .add_argument ('--json' , action = 'store_true' , help = 'Emit one versioned JSON result on stdout' )
6668 p .add_argument ('--verbose' , action = 'store_true' , help = 'Show safe request timings and waiting progress on stderr' )
@@ -73,6 +75,9 @@ def parser():
7375 p .add_argument ('--volume' , action = 'append' , help = 'Exact existing named volume and mount destination, NAME:/PATH (repeatable)' )
7476 p .add_argument ('--settings-sha256' , help = 'Existing ONCE settings fingerprint from status' )
7577 p .add_argument ('--previous-delivery-disabled' , action = 'store_true' , help = 'Assert previous delivery authority is disabled and drained' )
78+ for flag in ('dns-host' , 'dns-zone-id' , 'dns-record-id' , 'dns-ipv4' , 'dns-settings-sha256' ):
79+ p .add_argument ('--' + flag , help = 'Exact existing DNS evidence for adopt-dns' )
80+ p .add_argument ('--previous-dns-manager-disabled' , action = 'store_true' , help = 'Assert previous DNS authority is disabled and drained' )
7681 p .add_argument ('--document' , help = 'Vault state document to restore' )
7782 p .add_argument ('--version' , help = 'Exact Vault state version to restore' )
7883 p .add_argument ('--destination' , help = 'Recovery directory containing matching Git configuration' )
@@ -190,7 +195,7 @@ def applications(opts):
190195 def verify (opts ):
191196 results ['status' ] = host .status (results ['connection' ])
192197 from .health import verify as verify_https
193- verify_https (config )
198+ verify_https (config , results [ 'connection' ] )
194199 return dict (opts )
195200
196201 steps = {'preflight' : [preflight , 'keys' ], 'keys' : [keys , 'compute' ], 'compute' : [compute , 'host' ],
@@ -240,6 +245,23 @@ def execute(args, reporter=None):
240245
241246def _execute (args , reporter = None ):
242247 reporter = reporter or Reporter (quiet = getattr (args , "quiet" , False ), command = args .command )
248+ dns_options = ('dns_host' , 'dns_zone_id' , 'dns_record_id' , 'dns_ipv4' , 'dns_settings_sha256' , 'previous_dns_manager_disabled' )
249+ if args .command == 'dns-evidence' and (not getattr (args , 'dns_host' , None ) or any (getattr (args , key , None ) for key in dns_options [1 :])):
250+ raise DeployError ('dns-evidence requires only --dns-host.' , code = 'invalid_usage' )
251+ if args .command not in ('adopt-dns' , 'dns-evidence' ) and any (getattr (args , key , None ) for key in dns_options ):
252+ raise DeployError ('DNS adoption options require adopt-dns.' , code = 'invalid_usage' )
253+ if args .command == 'adopt-dns' :
254+ import re
255+ import ipaddress
256+ try :
257+ valid_ip = bool (ipaddress .IPv4Address (args .dns_ipv4 ))
258+ except (ValueError , TypeError ):
259+ valid_ip = False
260+ if (not all (getattr (args , key , None ) for key in dns_options ) or not valid_ip
261+ or not re .fullmatch (r'[0-9a-f]{32}' , args .dns_zone_id or '' )
262+ or not re .fullmatch (r'[0-9a-f]{32}' , args .dns_record_id or '' )
263+ or not re .fullmatch (r'[0-9a-f]{64}' , args .dns_settings_sha256 or '' )):
264+ raise DeployError ('adopt-dns requires exact host, zone/record IDs, IPv4, settings fingerprint and disabled previous DNS manager.' , code = 'invalid_usage' )
243265 adoption_options = ('app_host' , 'container_id' , 'image_id' , 'volume' , 'settings_sha256' , 'previous_delivery_disabled' )
244266 if args .command != 'adopt-app' and any (getattr (args , key , None ) for key in adoption_options ):
245267 raise DeployError ('Application adoption options require adopt-app.' , code = 'invalid_usage' )
@@ -269,7 +291,7 @@ def _execute(args, reporter=None):
269291 if smtp_timeout is not None and (args .command != 'converge' or args .dry_run
270292 or not 0 <= smtp_timeout <= 3600 ):
271293 raise DeployError ('--smtp-verification-timeout requires converge without --dry-run and 0–3600 seconds.' , code = 'invalid_usage' )
272- read_only = args .command in ('plan' , 'status' ) or args .dry_run
294+ read_only = args .command in ('plan' , 'status' , 'dns-evidence' ) or args .dry_run
273295 config_file = args .file if args .file is not None else 'colors.yml'
274296 if args .file is None and not Path (config_file ).exists ():
275297 raise DeployError ('No colors.yml found in the current directory; use -f to select a configuration.' )
@@ -306,6 +328,9 @@ def _execute(args, reporter=None):
306328 cloud_type = OCI if config ['provider-compute' ] == 'oci' else provider_class (config ['provider-compute' ])
307329 cloud = cloud_type (config , state )
308330 if read_only :
331+ if args .command == 'dns-evidence' :
332+ from .dns_adoption import inspect
333+ return inspect (config , state , cloud .connection (), args .dns_host )
309334 if args .command == 'status' :
310335 observed = cloud .inspect ()
311336 result = {'profile' : config ['profile' ], 'state' : state .safe_status (), 'resources' : observed }
@@ -364,6 +389,12 @@ def _execute(args, reporter=None):
364389 if config .get ('provider-smtp' ) != 'resend' :
365390 raise DeployError ('smtp-test requires provider-smtp: resend.' )
366391 result = host .smtp_test (cloud .connection (), Services (config , state ).smtp_settings (), args .to )
392+ elif args .command == 'adopt-dns' :
393+ from .dns_adoption import adopt
394+ result = adopt (config , state , cloud .connection (), operation , {
395+ 'host' : args .dns_host , 'zone' : args .dns_zone_id , 'record_id' : args .dns_record_id ,
396+ 'ipv4' : args .dns_ipv4 , 'settings_sha256' : args .dns_settings_sha256 ,
397+ 'previous_dns_manager_disabled' : True })
367398 elif args .command == 'adopt-app' :
368399 recorded = state .get_resource ('compute' )
369400 if not recorded or not recorded ['owned' ]:
0 commit comments