ConfigWriter.AddInstance check instance mac
ConfigWriter.AddInstance check instance mac

There is a race condition in CreateInstance, since the mac address is
generated early and only added to the config (and thus really assured to
be unique) only at this point. Since it's possible that another instance
gets the same mac address in the meantime with this check we'll make the
instance creation fail before modifying the config data and thus having
a wrong in-memory config (which is bad!!).

Note that the same race condition exists, for example, in
SetInstanceParams, and should be fully addressed by a way to revert
config changes if writing them fails!

Reviewed-by: iustin


ganeti-github-testing/ganeti-test-1,leshchevds/ganeti,grnet/snf-ganeti,apyrgio/snf-ganeti,yiannist/ganeti,apyrgio/snf-ganeti,bitemyapp/ganeti,bitemyapp/ganeti,leshchevds/ganeti,onponomarev/ganeti,mbakke/ganeti,yiannist/ganeti,ganeti/ganeti,apyrgio/ganeti,mbakke/ganeti,grnet/snf-ganeti,onponomarev/ganeti,yiannist/ganeti,leshchevds/ganeti,andir/ganeti,ganeti/ganeti,ganeti/ganeti,andir/ganeti,dimara/ganeti,mbakke/ganeti,ganeti-github-testing/ganeti-test-1,apyrgio/ganeti,andir/ganeti,dimara/ganeti