| name | fabric-configure |
| description | Generate FABRIC testbed environment setup, configuration validation, and SSH key management code |
| allowed-tools | ["Read","Grep","Glob","Write","Edit","Bash"] |
Instructions
When invoked, generate Python code (notebook cells or script) to set up and validate a FABRIC testbed environment. Ask the user whether they want Jupyter notebook cells or a standalone Python script.
Steps:
- Generate the import and FablibManager initialization
- Include
verify_and_configure() to validate the environment
- Show how to display the current configuration
- Optionally show SSH key setup if requested
Always use the canonical import:
from fabrictestbed_extensions.fablib.fablib import FablibManager
API Reference
FablibManager Constructor
FablibManager(
fabric_rc: str = None,
credmgr_host: str = None,
orchestrator_host: str = None,
core_api_host: str = None,
am_host: str = None,
token_location: str = None,
project_id: str = None,
bastion_username: str = None,
bastion_key_location: str = None,
log_level: str = "INFO",
log_file: str = "/tmp/fablib/fablib.log",
data_dir: str = "/tmp/fablib",
offline: bool = False,
auto_token_refresh: bool = True,
validate_config: bool = True,
)
Key Methods
fablib.verify_and_configure(validate_only=False) — Validates configuration; creates SSH keys and bastion config if validate_only=False
fablib.show_config(output=None, fields=None, quiet=False, pretty_names=True) — Display current configuration. output: "text", "pandas", "json"
fablib.save_config() — Write configuration to file for subsequent use
fablib.get_image_names() — Returns dict of available OS images with default users and descriptions
fablib.list_sites() — Quick test that API connectivity works
Environment Variables
The following environment variables configure FABlib (alternatively set in fabric_rc file):
| Variable | Description |
|---|
FABRIC_CREDMGR_HOST | Credential manager host |
FABRIC_ORCHESTRATOR_HOST | Orchestrator host |
FABRIC_CORE_API_HOST | Core API host |
FABRIC_TOKEN_LOCATION | Path to token file |
FABRIC_BASTION_HOST | Bastion host for SSH |
FABRIC_BASTION_USERNAME | Bastion SSH username |
FABRIC_BASTION_KEY_LOCATION | Path to bastion SSH private key |
FABRIC_SLICE_PRIVATE_KEY_FILE | Path to slice SSH private key |
FABRIC_SLICE_PUBLIC_KEY_FILE | Path to slice SSH public key |
FABRIC_PROJECT_ID | FABRIC project ID |
Patterns
Jupyter Notebook Setup
from fabrictestbed_extensions.fablib.fablib import FablibManager
fablib = FablibManager()
fablib.show_config()
fablib.verify_and_configure()
fablib.save_config()
fablib.list_sites()
Initialize with Project ID
from fabrictestbed_extensions.fablib.fablib import FablibManager
project_id = "YOUR_PROJECT_ID"
fablib = FablibManager(project_id=project_id)
fablib.show_config()
fablib.verify_and_configure()
fablib.save_config()
Standalone Script Setup
from fabrictestbed_extensions.fablib.fablib import FablibManager
def main():
fablib = FablibManager(fabric_rc="/path/to/fabric_rc")
fablib.verify_and_configure()
fablib.show_config()
sites = fablib.list_sites(output="text", quiet=False)
print("FABRIC environment configured successfully!")
if __name__ == "__main__":
main()
Custom Configuration
fablib = FablibManager(
credmgr_host="cm.fabric-testbed.net",
orchestrator_host="orchestrator.fabric-testbed.net",
core_api_host="uis.fabric-testbed.net",
token_location=os.environ["HOME"] + "/work/fabric_token.json",
bastion_username="your_username",
bastion_key_location=os.environ["HOME"] + "/.ssh/fabric_bastion_key",
project_id="your-project-id",
)
List Available Images
images = fablib.get_image_names()
for name, info in images.items():
print(f"{name}: user={info.get('default_user', 'N/A')}")