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KqwjEXfT
21
Y0jwPfBH8J2p84Dj2avPYQKBgEnFNjcDFXHbqTcHE2boCZwuRYfy//JJtGxdPzS5
22
BnCqy63fpazUfd5C8qpEAdgOmXm32p/Uxk2VyTV3aJ/x96DfodZJ84mj/NjH42K9
23
7nXOh/MKZcxCx4C5OE9ti575R5dVnyJUldjQl6eM83cyilEY7ZNjpym9xZJgRMQz
24
ogw1AoGAQSZ/9BhH7XywifPh8M8a17dzDoex9ps/c9ayZFKfifi4fDOFyBovVDLx
25
GMPoeFyR60DjmRFRTPpt7yYDwFOSGLo90M6JAFyZeh86S/Xt6Zi6Fcd6+/VLejMY
26
CSlI/8vIgi5E1YZiT2I4joSUIzaa2lmoGZsSTiDjIxWUuqh3J3k=
27
-----END RSA PRIVATE KEY-----
/dev/null
1
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDUsjUNXcojhi1yrMYO6lC8jx6q1REcXBD/8yXAW8Iw2kIQVyvT9/J8FlzJ0FVPYYrs0yB49Pd6/j6ewgkpcZcVdzcS9XltUIhHPtZD7r3bOG6LgHFP8oeO5hLB5TE0IiCpxyoeddocpX87ItE89x9wW7GfD9CMAmMFyscg22kxVTXwQ4GebKBoIVcI912iy92ZXfc2apU5h58YD7oQkfOhomYMEbisgiUb+cHbYrBudtSzhUofN7AjpBlZx2kjq3l9GpJQDJlx/evhsHugvV79HoXrY+8wL/ixkRdcfoH5IuodQ0FAyPLnTazSDDuARWW5y+XZbUtJx3nL1a+hijYH root@fab1
b/snf-deploy/snfdeploy/__init__.py
16 16

  
17 17
def print_available_actions(command):
18 18

  
19
  if command == "keygen":
20
    print """
21
Usage: snf-deploy keygen [--force]
22

  
23
  Generate new ssh keys (both rsa and dsa keypairs)
24

  
25
  """
26

  
19 27
  if command == "vcluster":
20 28
    print """
21 29
Usage: snf-deploy vcluster
......
372 380
  parser.add_argument("--vnc", dest="vnc",
373 381
                      default=False, action="store_true",
374 382
                      help="Wheter virtual nodes will have a vnc console or not")
375
  parser.add_argument("-k", "--keygen", dest="keygen",
383
  parser.add_argument("--force", dest="force",
376 384
                      default=False, action="store_true",
377
                      help="Whether to create new ssh key pairs")
385
                      help="Force the creation of new ssh key pairs")
378 386

  
379 387
  parser.add_argument("-i", "--ssh-key", dest="ssh_key",
380 388
                      default=None,
......
399 407
                      choices=["packages", "vcluster", "prepare",
400 408
                               "synnefo", "backend", "ganeti",
401 409
                               "run", "cleanup", "test",
402
                               "all", "add"],
410
                               "all", "add", "keygen"],
403 411
                      help="Run on of the supported deployment commands")
404 412

  
405 413
  # available actions for the run command
......
487 495
    return ret
488 496

  
489 497

  
490
def create_keys(args, env):
498
def must_create_keys(force, env):
499
    """Check if we need to create ssh keys
500

  
501
    If force is true we are going to overide the old keys.
502
    Else if there are already generated keys to use, don't create new ones.
503

  
504
    """
505
    if force:
506
        return True
507
    d = os.path.join(env.templates, "root/.ssh")
508
    auth_keys_exists = os.path.exists(os.path.join(d, "authorized_keys"))
509
    dsa_exists = os.path.exists(os.path.join(d, "id_dsa"))
510
    dsa_pub_exists = os.path.exists(os.path.join(d, "id_dsa.pub"))
511
    rsa_exists = os.path.exists(os.path.join(d, "id_rsa"))
512
    rsa_pub_exists = os.path.exists(os.path.join(d, "id_rsa.pub"))
513
    # If any of the above doesn't exist return True
514
    return not (dsa_exists and dsa_pub_exists
515
                and rsa_exists and rsa_pub_exists
516
                and auth_keys_exists)
517

  
518

  
519
def do_create_keys(args, env):
491 520
  d = os.path.join(env.templates, "root/.ssh")
492 521
  a = os.path.join(d, "authorized_keys")
493 522
  for t in ("dsa", "rsa"):
......
541 570
  create_dir(env.run, False)
542 571
  create_dir(env.dns, False)
543 572

  
573
  # Check if there are keys to use
574
  if args.command == "keygen":
575
    if must_create_keys(args.force, env):
576
      do_create_keys(args, env)
577
      return 0
578
    else:
579
      print "Keys already existed.. aborting"
580
      return 1
581
  else:
582
    if (args.key_inject and (args.ssh_key is None)
583
        and must_create_keys(False, env)):
584
      print "No ssh keys to use. Run `snf-deploy keygen' first."
585
      return 1
586

  
544 587
  if args.command == "test":
545 588
    conf.print_config()
546 589

  
547 590
  if args.command == "cleanup":
548 591
    cleanup(args, env)
549 592

  
550
  if args.keygen:
551
    create_keys(args, env)
552

  
553 593
  if args.command == "packages":
554 594
    create_dir(env.packages, True)
555 595
    get_packages(args, env)

Also available in: Unified diff