API¶
MAX_WORKERS
module-attribute
¶
Ctx ¶
MachineOpts ¶
Applicable options to filter machines by
Example
render ¶
Returns the correct deployment based on type of step
Parameters:
Name | Type | Description | Default |
---|---|---|---|
template |
Path
|
path to template file |
required |
context |
Ctx
|
mapping of key,value to expose in template |
required |
Returns:
Type | Description |
---|---|
str
|
Rendered template string |
Source code in ogc/deployer.py
__filter_machines ¶
Filters machines by instance_id or all if none is provided
Parameters:
Name | Type | Description | Default |
---|---|---|---|
kwargs |
MachineOpts
|
Machine filter options |
{}
|
Returns:
Type | Description |
---|---|
list[MachineModel]
|
List of machines |
Source code in ogc/deployer.py
ssh_hook ¶
ssh ¶
Opens SSH connection to a machine
Pass in a mapping of options to filter machines, a single machine must be queried
Parameters:
Name | Type | Description | Default |
---|---|---|---|
provisioner |
BaseProvisioner
|
provisioner |
required |
kwargs |
MachineOpts
|
Mapping of options to pass to |
{}
|
Source code in ogc/deployer.py
up_hook ¶
up ¶
Bring up machines
Parameters:
Name | Type | Description | Default |
---|---|---|---|
provisioner |
BaseProvisioner
|
provisioner |
required |
kwargs |
MachineOpts
|
Mapping of options to pass to |
{}
|
Returns:
Type | Description |
---|---|
bool
|
True if successful, False otherwise. |
Source code in ogc/deployer.py
down_hook ¶
down ¶
Tear down machines
Pass in a optional mapping of options to filter machines
Parameters:
Name | Type | Description | Default |
---|---|---|---|
provisioner |
BaseProvisioner
|
Provisioner |
required |
kwargs |
MachineOpts
|
Mapping of options to pass to |
{}
|
Example
Returns:
Type | Description |
---|---|
bool
|
True if successful, False otherwise. |
Source code in ogc/deployer.py
ls_hook ¶
ls ¶
Return a list of machines for deployment
Pass in a mapping of options to filter machines
Parameters:
Name | Type | Description | Default |
---|---|---|---|
provisioner |
BaseProvisioner
|
Provisioner |
required |
kwargs |
MachineOpts
|
Mapping of options to pass to |
{}
|
Example
> ogc ubuntu.py ls -v -o limit=8
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ ID ┃ Name ┃ Created ┃ Status ┃ Labels ┃ Connection ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┩
│ 5407368969918077947 │ ogc-ubuntu-ogc-f664-000 │ an hour ago │ running │ division=engineering,org=obs,team=observability,project=perf │ ssh -i /Users/adam/.ssh/id_rsa_libcloud ubuntu@34.134.169.153 │
├────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ 3631668729125788664 │ ogc-ubuntu-ogc-f664-001 │ an hour ago │ running │ division=engineering,org=obs,team=observability,project=perf │ ssh -i /Users/adam/.ssh/id_rsa_libcloud ubuntu@34.133.188.125 │
├────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ 3575202029581097972 │ ogc-ubuntu-ogc-f664-002 │ an hour ago │ running │ division=engineering,org=obs,team=observability,project=perf │ ssh -i /Users/adam/.ssh/id_rsa_libcloud ubuntu@104.155.176.229 │
├────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ 4961396037101018096 │ ogc-ubuntu-ogc-f664-003 │ an hour ago │ running │ division=engineering,org=obs,team=observability,project=perf │ ssh -i /Users/adam/.ssh/id_rsa_libcloud ubuntu@34.71.231.9 │
├────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ 6845512080056900556 │ ogc-ubuntu-ogc-f664-004 │ an hour ago │ running │ division=engineering,org=obs,team=observability,project=perf │ ssh -i /Users/adam/.ssh/id_rsa_libcloud ubuntu@34.170.61.39 │
├────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ 8257796978812902341 │ ogc-ubuntu-ogc-f664-006 │ an hour ago │ running │ division=engineering,org=obs,team=observability,project=perf │ ssh -i /Users/adam/.ssh/id_rsa_libcloud ubuntu@34.170.252.152 │
├────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ 4654244594843638721 │ ogc-ubuntu-ogc-f664-007 │ an hour ago │ running │ division=engineering,org=obs,team=observability,project=perf │ ssh -i /Users/adam/.ssh/id_rsa_libcloud ubuntu@34.133.234.5 │
├────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ 2604966443513535453 │ ogc-ubuntu-ogc-f664-008 │ an hour ago │ running │ division=engineering,org=obs,team=observability,project=perf │ ssh -i /Users/adam/.ssh/id_rsa_libcloud ubuntu@35.226.159.94 │
└────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
Node Count: 8
Suppressing the output is useful if you are using the framework programatically.
from ogc import ls, fs, init, exec
deployment = init(
layout_model=dict(
instance_size="e2-standard-4",
name="ubuntu-ogc",
provider="google",
remote_path="/home/ubuntu/ogc",
runs_on="ubuntu-2004-lts",
scale=9,
scripts="fixtures/ex_deploy_ubuntu",
username="ubuntu",
ssh_private_key=fs.expand_path("~/.ssh/id_rsa_libcloud"),
ssh_public_key=fs.expand_path("~/.ssh/id_rsa_libcloud.pub"),
ports=["22:22", "80:80", "443:443", "5601:5601"],
tags=[],
labels=dict(
division="engineering", org="obs", team="observability", project="perf"
),
),
)
def uname(**kwargs: str):
kwargs.update({"cmd": "uname -a"})
output = exec(deployment, **kwargs)
if output:
print("commands executed successfully")
Execute the above:
> ogc ubuntu.py uname -v
[19:20:14] INFO Establing provider connection...
[19:20:25] INFO Executing commands across 1 node(s)
[19:20:27] DEBUG {'exit_code': 0, 'out': "Linux ogc-ubuntu-ogc-bb60-000 5.15.0-1027-gcp #34~20.04.1-Ubuntu SMP Mon Jan 9
18:40:09 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux", 'error': '', 'cmd': '/usr/bin/ssh -o
StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i /root/.ssh/id_ed25519
ubuntu@34.27.170.121 uname -a'}
commands executed successfully
Returns:
Type | Description |
---|---|
list[MachineModel] | None
|
List of deployed machines |
Source code in ogc/deployer.py
216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 |
|
exec_hook ¶
exec ¶
Execute commands on node(s)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
provisioner |
BaseProvisioner
|
provisioner |
required |
kwargs |
MachineOpts
|
Options to exec |
{}
|
Example
Returns:
Type | Description |
---|---|
bool
|
True if succesful, False otherwise. |
Source code in ogc/deployer.py
367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 |
|
exec_scripts_hook ¶
exec_scripts ¶
Execute scripts
Executing scripts/templates on a node.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
provisioner |
BaseProvisioner
|
provisioner |
required |
kwargs |
MachineOpts
|
Options to exec_scripts |
{}
|
Example
Returns:
Type | Description |
---|---|
bool
|
True if succesful, False otherwise. |
Source code in ogc/deployer.py
458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 |
|