2626from aleph .sdk .query .filters import MessageFilter
2727from aleph .sdk .query .responses import PriceResponse
2828from aleph .sdk .types import StorageEnum
29- from aleph .sdk .utils import calculate_firmware_hash
29+ from aleph .sdk .utils import calculate_firmware_hash , safe_getattr
3030from aleph_message .models import InstanceMessage , StoreMessage
3131from aleph_message .models .base import Chain , MessageType
3232from aleph_message .models .execution .base import Payment , PaymentType
5858from aleph_client .commands .utils import (
5959 filter_only_valid_messages ,
6060 get_or_prompt_volumes ,
61- safe_getattr ,
6261 setup_logging ,
6362 str_to_datetime ,
6463 validate_ssh_pubkey_file ,
@@ -117,6 +116,7 @@ async def create(
117116 None ,
118117 help = help_strings .IMMUTABLE_VOLUME ,
119118 ),
119+ crn_auto_tac : bool = typer .Option (False , help = help_strings .CRN_AUTO_TAC ),
120120 channel : Optional [str ] = typer .Option (default = settings .DEFAULT_CHANNEL , help = help_strings .CHANNEL ),
121121 private_key : Optional [str ] = typer .Option (settings .PRIVATE_KEY_STRING , help = help_strings .PRIVATE_KEY ),
122122 private_key_file : Optional [Path ] = typer .Option (settings .PRIVATE_KEY_FILE , help = help_strings .PRIVATE_KEY_FILE ),
@@ -342,6 +342,7 @@ async def create(
342342 crn_info .get ("computing" , {}).get ("ENABLE_CONFIDENTIAL_COMPUTING" , False )
343343 ),
344344 gpu_support = bool (crn_info .get ("computing" , {}).get ("ENABLE_GPU_SUPPORT" , False )),
345+ terms_and_conditions = crn_info .get ("terms_and_conditions" ),
345346 )
346347 echo ("\n * Selected CRN *" )
347348 crn .display_crn_specs ()
@@ -413,6 +414,15 @@ async def create(
413414 device_id = selected_gpu .device_id ,
414415 )
415416 ]
417+ if crn .terms_and_conditions :
418+ accepted = await crn .display_terms_and_conditions (auto_accept = crn_auto_tac )
419+ if accepted is None :
420+ echo ("Failed to fetch terms and conditions.\n Contact support or use a different CRN." )
421+ raise typer .Exit (1 )
422+ elif not accepted :
423+ echo ("Terms & Conditions rejected: instance creation aborted." )
424+ raise typer .Exit (1 )
425+ echo ("Terms & Conditions accepted." )
416426
417427 async with AuthenticatedAlephHttpClient (account = account , api_server = settings .API_HOST ) as client :
418428 payment = Payment (
@@ -437,7 +447,12 @@ async def create(
437447 payment = payment ,
438448 requirements = (
439449 HostRequirements (
440- node = NodeRequirements (node_hash = crn .hash ),
450+ node = NodeRequirements (
451+ node_hash = crn .hash ,
452+ terms_and_conditions = (
453+ ItemHash (crn .terms_and_conditions ) if crn .terms_and_conditions else None
454+ ),
455+ ),
441456 gpu = gpu_requirement ,
442457 )
443458 if crn
@@ -734,6 +749,19 @@ async def _show_instances(messages: List[InstanceMessage], node_list: NodeInfo):
734749 Text (str (info ["ipv6_logs" ])),
735750 style = "bright_yellow" if len (str (info ["ipv6_logs" ]).split (":" )) == 8 else "dark_orange" ,
736751 ),
752+ (
753+ Text .assemble (
754+ Text (
755+ f"\n [{ '✅' if info ['terms_and_conditions' ]['accepted' ] else '❌' } ] Accepted Terms & Conditions:\n "
756+ ),
757+ Text (
758+ f"{ info ['terms_and_conditions' ]['url' ]} " ,
759+ style = "orange1" ,
760+ ),
761+ )
762+ if info ["terms_and_conditions" ]["hash" ]
763+ else ""
764+ ),
737765 )
738766 table .add_row (instance , specifications , status_column )
739767 table .add_section ()
@@ -1197,6 +1225,7 @@ async def confidential_create(
11971225 None ,
11981226 help = help_strings .IMMUTABLE_VOLUME ,
11991227 ),
1228+ crn_auto_tac : bool = typer .Option (False , help = help_strings .CRN_AUTO_TAC ),
12001229 channel : Optional [str ] = typer .Option (default = settings .DEFAULT_CHANNEL , help = help_strings .CHANNEL ),
12011230 private_key : Optional [str ] = typer .Option (settings .PRIVATE_KEY_STRING , help = help_strings .PRIVATE_KEY ),
12021231 private_key_file : Optional [Path ] = typer .Option (settings .PRIVATE_KEY_FILE , help = help_strings .PRIVATE_KEY_FILE ),
@@ -1228,6 +1257,7 @@ async def confidential_create(
12281257 ssh_pubkey_file = ssh_pubkey_file ,
12291258 crn_hash = crn_hash ,
12301259 crn_url = crn_url ,
1260+ crn_auto_tac = crn_auto_tac ,
12311261 confidential = True ,
12321262 confidential_firmware = confidential_firmware ,
12331263 gpu = gpu ,
0 commit comments