From 912ec5cc2496cfaf12029ef1fa4a4bce69d93fb5 Mon Sep 17 00:00:00 2001 From: Simon Thulbourn Date: Mon, 12 Jan 2015 22:30:58 +0000 Subject: [PATCH] Stop machine from overriding an existing machine Signed-off-by: Simon Thulbourn --- commands.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/commands.go b/commands.go index 33a7efd78d..54bb575d84 100644 --- a/commands.go +++ b/commands.go @@ -180,6 +180,17 @@ func cmdCreate(c *cli.Context) { log.Fatal("You must specify a machine name") } + store := NewStore(c.GlobalString("storage-path")) + + exists, err := store.Exists(name) + if err != nil { + log.Fatal(err) + } + + if exists { + log.Fatal("There's already a machine with the same name") + } + keyExists, err := drivers.PublicKeyExists() if err != nil { log.Fatal(err) @@ -189,8 +200,6 @@ func cmdCreate(c *cli.Context) { log.Fatalf("Identity authentication public key doesn't exist at %q. Create your public key by running the \"docker\" command.", drivers.PublicKeyPath()) } - store := NewStore(c.GlobalString("storage-path")) - host, err := store.Create(name, driver, c) if err != nil { log.Errorf("Error creating host: %s", err)