BMM entity should exist in a location, not in a group (#31)

* For now, BMM entity should exist in a location, not in a group. Also improved checks to prevent AVs when pointer fields are null.

* Added go.sum

Co-authored-by: Davut Karabay <davutk@microsoft.com>
This commit is contained in:
davutkarabay 2021-03-05 14:26:46 -08:00 коммит произвёл GitHub
Родитель 836663e841
Коммит 99011e8013
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
4 изменённых файлов: 94 добавлений и 77 удалений

21
go.sum
Просмотреть файл

@ -7,11 +7,13 @@ github.com/Azure/go-autorest/autorest/date v0.1.0/go.mod h1:plvfp3oPSKwf2DNjlBjW
github.com/Azure/go-autorest/autorest/date v0.2.0 h1:yW+Zlqf26583pE43KhfnhFcdmSWlm5Ew6bxipnr/tbM=
github.com/Azure/go-autorest/autorest/date v0.2.0/go.mod h1:vcORJHLJEh643/Ioh9+vPmf1Ij9AEBM5FuBIXLmIy0g=
github.com/Azure/go-autorest/autorest/mocks v0.1.0/go.mod h1:OTyCOPRA2IgIlWxVYxBee2F5Gr4kF2zd2J5cFRaIDN0=
github.com/Azure/go-autorest/autorest/mocks v0.2.0 h1:Ww5g4zThfD/6cLb4z6xxgeyDa7QDkizMkJKe0ysZXp0=
github.com/Azure/go-autorest/autorest/mocks v0.2.0/go.mod h1:OTyCOPRA2IgIlWxVYxBee2F5Gr4kF2zd2J5cFRaIDN0=
github.com/Azure/go-autorest/logger v0.1.0 h1:ruG4BSDXONFRrZZJ2GUXDiUyVpayPmb1GnWeHDdaNKY=
github.com/Azure/go-autorest/logger v0.1.0/go.mod h1:oExouG+K6PryycPJfVSxi/koC6LSNgds39diKLz7Vrc=
github.com/Azure/go-autorest/tracing v0.5.0 h1:TRn4WjSnkcSy5AEG3pnbtFSwNtwzjr4VYyQflFE619k=
github.com/Azure/go-autorest/tracing v0.5.0/go.mod h1:r/s2XiOKccPW3HrqB+W0TQzfbtp2fGCgRFtBroKn4Dk=
github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
@ -28,6 +30,7 @@ github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3Ee
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM=
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
@ -44,6 +47,7 @@ github.com/go-logr/logr v0.1.0/go.mod h1:ixOQHD9gLJUVQQ2ZOR7zLEifBX6tGkNJF4QyIY7
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4=
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58=
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
@ -62,7 +66,9 @@ github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5a
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.0 h1:/QaMHBdZ26BB3SSst0Iwl10Epc+xhTquomWX0oZEB6w=
github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8=
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs=
@ -73,22 +79,21 @@ github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T
github.com/jmespath/go-jmespath v0.3.0 h1:OS12ieG61fsCg5+qLJ+SsW9NicxNkg3b25OyT2yCeUc=
github.com/jmespath/go-jmespath v0.3.0/go.mod h1:9QtRXoHjLGCJ5IBSaohpXITPlowMeeYCZ7fLUTSywik=
github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo=
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/magiconair/properties v1.8.1 h1:ZC2Vc7/ZFkGmsVC9KvOjumD+G5lXy2RtTKyzRKO2BQ4=
github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
github.com/microsoft/moc v0.10.7-alpha.2 h1:S14zvhQxV9egx7AOJlXwU1seRGh1s5caV/G1aMGHfC0=
github.com/microsoft/moc v0.10.7-alpha.2/go.mod h1:2/6wA6NZ+3X1MfBxkNYGeAJaChXmH3qfK7eMEGKslFI=
github.com/microsoft/moc v0.10.7-alpha.4 h1:FZkHH29+6tQA2SP/nRMLt2dBLE2MXaWn+fYm1b1V1/w=
github.com/microsoft/moc v0.10.7-alpha.4/go.mod h1:D8xNkWHFHrgd0E6ol885gfsQRFhJoy0fU+RyTf9FS7U=
github.com/microsoft/moc v0.10.7-alpha.5 h1:J2RRXbZ9v+0/QX9/lvB4Sx8YblBi7dDEoce8bq5fpPo=
github.com/microsoft/moc v0.10.7-alpha.5/go.mod h1:D8xNkWHFHrgd0E6ol885gfsQRFhJoy0fU+RyTf9FS7U=
github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE=
@ -100,6 +105,7 @@ github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/9
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDft0ttaMvbicHlPoso=
@ -115,7 +121,9 @@ github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6So
github.com/satori/go.uuid v1.2.0 h1:0uYX9dsZ2yD7q2RtLRtPSdGDWzjeM3TbMJP9utgA0ww=
github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0=
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM=
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s=
github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM=
github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
@ -132,6 +140,7 @@ github.com/spf13/viper v1.6.2/go.mod h1:t3iDnF5Jlj76alVNuyFBk5oUMCvsrkbvZK0WQdfD
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4=
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s=
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
@ -169,8 +178,6 @@ golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5h
golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c h1:VwygUrnw9jn88c4u8GD3rZQbqrP/tgas88tPUbBxQrk=
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210216224549-f992740a1bac h1:9glrpwtNjBYgRpb67AZJKHfzj1stG/8BL5H7In2oTC4=
golang.org/x/sys v0.0.0-20210216224549-f992740a1bac/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
@ -186,6 +193,7 @@ golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
@ -211,6 +219,7 @@ google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlba
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/ini.v1 v1.51.0 h1:AQvPpx3LzTDM0AjnIRlVFwFFGC+npRopjZxLJj6gdno=
gopkg.in/ini.v1 v1.51.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=

Просмотреть файл

@ -13,48 +13,52 @@ import (
wssdcloudcompute "github.com/microsoft/moc/rpc/cloudagent/compute"
)
func (c *client) getWssdBareMetalMachine(bmm *compute.BareMetalMachine, group string) (*wssdcloudcompute.BareMetalMachine, error) {
func (c *client) getWssdBareMetalMachine(bmm *compute.BareMetalMachine, location string) (*wssdcloudcompute.BareMetalMachine, error) {
if bmm.Name == nil {
return nil, errors.Wrapf(errors.InvalidInput, "Bare Metal Machine name is missing")
}
if len(group) == 0 {
return nil, errors.Wrapf(errors.InvalidGroup, "Group not specified")
}
storageConfig, err := c.getWssdBareMetalMachineStorageConfiguration(bmm.StorageProfile)
if err != nil {
return nil, errors.Wrapf(err, "Failed to get Storage Configuration")
}
hardwareConfig, err := c.getWssdBareMetalMachineHardwareConfiguration(bmm)
if err != nil {
return nil, errors.Wrapf(err, "Failed to get Hardware Configuration")
}
securityConfig, err := c.getWssdBareMetalMachineSecurityConfiguration(bmm)
if err != nil {
return nil, errors.Wrapf(err, "Failed to get Security Configuration")
}
osConfig, err := c.getWssdBareMetalMachineOSConfiguration(bmm.OsProfile)
if err != nil {
return nil, errors.Wrapf(err, "Failed to get OS Configuration")
}
networkConfig, err := c.getWssdBareMetalMachineNetworkConfiguration(bmm.NetworkProfile)
if err != nil {
return nil, errors.Wrapf(err, "Failed to get Network Configuration")
if len(location) == 0 {
return nil, errors.Wrapf(errors.InvalidInput, "Location not specified")
}
bmmOut := wssdcloudcompute.BareMetalMachine{
Name: *bmm.Name,
Storage: storageConfig,
Hardware: hardwareConfig,
Security: securityConfig,
Os: osConfig,
Network: networkConfig,
GroupName: group,
Tags: getWssdTags(bmm.Tags),
Name: *bmm.Name,
LocationName: location,
Tags: getWssdTags(bmm.Tags),
}
if bmm.Host != nil && bmm.Host.ID != nil {
bmmOut.NodeName = *bmm.Host.ID
if bmm.BareMetalMachineProperties != nil {
storageConfig, err := c.getWssdBareMetalMachineStorageConfiguration(bmm.StorageProfile)
if err != nil {
return nil, errors.Wrapf(err, "Failed to get Storage Configuration")
}
hardwareConfig, err := c.getWssdBareMetalMachineHardwareConfiguration(bmm)
if err != nil {
return nil, errors.Wrapf(err, "Failed to get Hardware Configuration")
}
securityConfig, err := c.getWssdBareMetalMachineSecurityConfiguration(bmm)
if err != nil {
return nil, errors.Wrapf(err, "Failed to get Security Configuration")
}
osConfig, err := c.getWssdBareMetalMachineOSConfiguration(bmm.OsProfile)
if err != nil {
return nil, errors.Wrapf(err, "Failed to get OS Configuration")
}
networkConfig, err := c.getWssdBareMetalMachineNetworkConfiguration(bmm.NetworkProfile)
if err != nil {
return nil, errors.Wrapf(err, "Failed to get Network Configuration")
}
bmmOut.Storage = storageConfig
bmmOut.Hardware = hardwareConfig
bmmOut.Security = securityConfig
bmmOut.Os = osConfig
bmmOut.Network = networkConfig
if bmm.Host != nil && bmm.Host.ID != nil {
bmmOut.NodeName = *bmm.Host.ID
}
}
if bmm.Version != nil {
@ -64,10 +68,6 @@ func (c *client) getWssdBareMetalMachine(bmm *compute.BareMetalMachine, group st
bmmOut.Status.Version.Number = *bmm.Version
}
if bmm.Location != nil {
bmmOut.LocationName = *bmm.Location
}
return &bmmOut, nil
}
@ -245,7 +245,7 @@ func (c *client) getWssdBareMetalMachineOSConfiguration(s *compute.BareMetalMach
// Conversion functions from wssdcloudcompute to compute
func (c *client) getBareMetalMachine(bmm *wssdcloudcompute.BareMetalMachine, group string) *compute.BareMetalMachine {
func (c *client) getBareMetalMachine(bmm *wssdcloudcompute.BareMetalMachine, location string) *compute.BareMetalMachine {
return &compute.BareMetalMachine{
Name: &bmm.Name,
ID: &bmm.Id,
@ -372,12 +372,20 @@ func (c *client) getBareMetalMachineLinuxConfiguration(linuxConfiguration *wssdc
return lc
}
func (c *client) getBareMetalMachineOSProfile(o *wssdcloudcompute.BareMetalMachineOperatingSystemConfiguration) *compute.BareMetalMachineOSProfile {
return &compute.BareMetalMachineOSProfile{
ComputerName: &o.ComputerName,
AdminUsername: &o.Administrator.Username,
AdminPassword: &o.Administrator.Password,
CustomData: &o.CustomData,
LinuxConfiguration: c.getBareMetalMachineLinuxConfiguration(o.LinuxConfiguration),
func (c *client) getBareMetalMachineOSProfile(osConfiguration *wssdcloudcompute.BareMetalMachineOperatingSystemConfiguration) *compute.BareMetalMachineOSProfile {
op := &compute.BareMetalMachineOSProfile{
ComputerName: &osConfiguration.ComputerName,
CustomData: &osConfiguration.CustomData,
LinuxConfiguration: c.getBareMetalMachineLinuxConfiguration(osConfiguration.LinuxConfiguration),
}
if osConfiguration.Administrator != nil {
op.AdminUsername = &osConfiguration.Administrator.Username
}
if osConfiguration.Administrator != nil {
op.AdminPassword = &osConfiguration.Administrator.Password
}
return op
}

Просмотреть файл

@ -32,21 +32,21 @@ func NewBareMetalMachineClient(cloudFQDN string, authorizer auth.Authorizer) (*B
}
// Get methods invokes the client Get method
func (c *BareMetalMachineClient) Get(ctx context.Context, group, name string) (*[]compute.BareMetalMachine, error) {
return c.internal.Get(ctx, group, name)
func (c *BareMetalMachineClient) Get(ctx context.Context, location, name string) (*[]compute.BareMetalMachine, error) {
return c.internal.Get(ctx, location, name)
}
// CreateOrUpdate methods invokes create or update on the client
func (c *BareMetalMachineClient) CreateOrUpdate(ctx context.Context, group, name string, compute *compute.BareMetalMachine) (*compute.BareMetalMachine, error) {
return c.internal.CreateOrUpdate(ctx, group, name, compute)
func (c *BareMetalMachineClient) CreateOrUpdate(ctx context.Context, location, name string, compute *compute.BareMetalMachine) (*compute.BareMetalMachine, error) {
return c.internal.CreateOrUpdate(ctx, location, name, compute)
}
// Delete methods invokes delete of the compute resource
func (c *BareMetalMachineClient) Delete(ctx context.Context, group string, name string) error {
return c.internal.Delete(ctx, group, name)
func (c *BareMetalMachineClient) Delete(ctx context.Context, location string, name string) error {
return c.internal.Delete(ctx, location, name)
}
// Query method invokes the client Get method and uses the provided query to filter the returned results
func (c *BareMetalMachineClient) Query(ctx context.Context, group, query string) (*[]compute.BareMetalMachine, error) {
return c.internal.Query(ctx, group, query)
func (c *BareMetalMachineClient) Query(ctx context.Context, location, query string) (*[]compute.BareMetalMachine, error) {
return c.internal.Query(ctx, location, query)
}

Просмотреть файл

@ -32,8 +32,8 @@ func newBareMetalMachineClient(subID string, authorizer auth.Authorizer) (*clien
}
// Get
func (c *client) Get(ctx context.Context, group, name string) (*[]compute.BareMetalMachine, error) {
request, err := c.getBareMetalMachineRequest(wssdcloudproto.Operation_GET, group, name, nil)
func (c *client) Get(ctx context.Context, location, name string) (*[]compute.BareMetalMachine, error) {
request, err := c.getBareMetalMachineRequest(wssdcloudproto.Operation_GET, location, name, nil)
if err != nil {
return nil, err
}
@ -41,12 +41,12 @@ func (c *client) Get(ctx context.Context, group, name string) (*[]compute.BareMe
if err != nil {
return nil, err
}
return c.getBareMetalMachineFromResponse(response, group), nil
return c.getBareMetalMachineFromResponse(response, location), nil
}
// CreateOrUpdate
func (c *client) CreateOrUpdate(ctx context.Context, group, name string, sg *compute.BareMetalMachine) (*compute.BareMetalMachine, error) {
request, err := c.getBareMetalMachineRequest(wssdcloudproto.Operation_POST, group, name, sg)
func (c *client) CreateOrUpdate(ctx context.Context, location, name string, sg *compute.BareMetalMachine) (*compute.BareMetalMachine, error) {
request, err := c.getBareMetalMachineRequest(wssdcloudproto.Operation_POST, location, name, sg)
if err != nil {
return nil, err
}
@ -54,7 +54,7 @@ func (c *client) CreateOrUpdate(ctx context.Context, group, name string, sg *com
if err != nil {
return nil, err
}
bmms := c.getBareMetalMachineFromResponse(response, group)
bmms := c.getBareMetalMachineFromResponse(response, location)
if len(*bmms) == 0 {
return nil, fmt.Errorf("Creation of Bare Metal Machine failed to unknown reason.")
}
@ -63,8 +63,8 @@ func (c *client) CreateOrUpdate(ctx context.Context, group, name string, sg *com
}
// Delete methods invokes create or update on the client
func (c *client) Delete(ctx context.Context, group, name string) error {
bmms, err := c.Get(ctx, group, name)
func (c *client) Delete(ctx context.Context, location, name string) error {
bmms, err := c.Get(ctx, location, name)
if err != nil {
return err
}
@ -72,7 +72,7 @@ func (c *client) Delete(ctx context.Context, group, name string) error {
return fmt.Errorf("Bare Metal Machine [%s] not found", name)
}
request, err := c.getBareMetalMachineRequest(wssdcloudproto.Operation_DELETE, group, name, &(*bmms)[0])
request, err := c.getBareMetalMachineRequest(wssdcloudproto.Operation_DELETE, location, name, &(*bmms)[0])
if err != nil {
return err
}
@ -82,8 +82,8 @@ func (c *client) Delete(ctx context.Context, group, name string) error {
}
// Query
func (c *client) Query(ctx context.Context, group, query string) (*[]compute.BareMetalMachine, error) {
bmms, err := c.Get(ctx, group, "")
func (c *client) Query(ctx context.Context, location, query string) (*[]compute.BareMetalMachine, error) {
bmms, err := c.Get(ctx, location, "")
if err != nil {
return nil, err
}
@ -102,27 +102,27 @@ func (c *client) Query(ctx context.Context, group, query string) (*[]compute.Bar
}
// Private methods
func (c *client) getBareMetalMachineFromResponse(response *wssdcloudcompute.BareMetalMachineResponse, group string) *[]compute.BareMetalMachine {
func (c *client) getBareMetalMachineFromResponse(response *wssdcloudcompute.BareMetalMachineResponse, location string) *[]compute.BareMetalMachine {
bmms := []compute.BareMetalMachine{}
for _, bmm := range response.GetBareMetalMachines() {
bmms = append(bmms, *(c.getBareMetalMachine(bmm, group)))
bmms = append(bmms, *(c.getBareMetalMachine(bmm, location)))
}
return &bmms
}
func (c *client) getBareMetalMachineRequest(opType wssdcloudproto.Operation, group, name string, bmm *compute.BareMetalMachine) (*wssdcloudcompute.BareMetalMachineRequest, error) {
func (c *client) getBareMetalMachineRequest(opType wssdcloudproto.Operation, location, name string, bmm *compute.BareMetalMachine) (*wssdcloudcompute.BareMetalMachineRequest, error) {
request := &wssdcloudcompute.BareMetalMachineRequest{
OperationType: opType,
BareMetalMachines: []*wssdcloudcompute.BareMetalMachine{},
}
var err error
wssdbmm := &wssdcloudcompute.BareMetalMachine{
Name: name,
GroupName: group,
Name: name,
LocationName: location,
}
if bmm != nil {
wssdbmm, err = c.getWssdBareMetalMachine(bmm, group)
wssdbmm, err = c.getWssdBareMetalMachine(bmm, location)
if err != nil {
return nil, err
}