diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..0cf1043 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,95 @@ +name: Build and Release + +on: + push: + tags: + - 'v*' + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: '1.22.3' + + - name: Cache Go modules + uses: actions/cache@v3 + with: + path: | + ~/go/pkg/mod + ./.cache/go-build + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go- + + - name: Install dependencies + run: go mod tidy + + - name: Build for Linux (amd64) + run: GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -ldflags "-w -s" -o dist/osssh-linux-amd64 cmd/osssh/osssh.go + + - name: Build for Linux (aarch64) + run: GOOS=linux GOARCH=arm64 CGO_ENABLED=0 go build -ldflags "-w -s" -o dist/osssh-linux-arm64 cmd/osssh/osssh.go + + - name: Build for macOS (amd64) + run: GOOS=darwin GOARCH=amd64 CGO_ENABLED=0 go build -ldflags "-w -s" -o dist/osssh-darwin-amd64 cmd/osssh/osssh.go + + - name: Build for macOS (aarch64) + run: GOOS=darwin GOARCH=arm64 CGO_ENABLED=0 go build -ldflags "-w -s" -o dist/osssh-darwin-arm64 cmd/osssh/osssh.go + + - name: Create release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ github.ref }} + release_name: Release ${{ github.ref }} + draft: false + prerelease: false + + - name: Upload Linux Binary (amd64) + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: dist/osssh-linux-amd64 + asset_name: osssh-linux-amd64 + asset_content_type: application/octet-stream + + - name: Upload Linux Binary (aarch64) + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: dist/osssh-linux-arm64 + asset_name: osssh-linux-arm64 + asset_content_type: application/octet-stream + + - name: Upload macOS Binary (amd64) + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: dist/osssh-darwin-amd64 + asset_name: osssh-darwin-amd64 + asset_content_type: application/octet-stream + + - name: Upload macOS Binary (aarch64) + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: dist/osssh-darwin-arm64 + asset_name: osssh-darwin-arm64 + asset_content_type: application/octet-stream diff --git a/.gitignore b/.gitignore index 2518e23..c4807a4 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -.vscode/** \ No newline at end of file +.vscode/** +.dist/** \ No newline at end of file diff --git a/go.mod b/go.mod index d947727..13fb815 100644 --- a/go.mod +++ b/go.mod @@ -1,17 +1,17 @@ module github.com/modzilla99/osssh -go 1.21.3 +go 1.22.3 require ( - github.com/gophercloud/gophercloud v1.7.0 - github.com/gophercloud/utils v0.0.0-20231010081019-80377eca5d56 + github.com/gophercloud/gophercloud/v2 v2.0.0-beta.2 + github.com/gophercloud/utils/v2 v2.0.0-20240506072225-f79c3b81b6bf + github.com/hashicorp/go-uuid v1.0.3 + golang.org/x/crypto v0.23.0 ) require ( - github.com/hashicorp/go-uuid v1.0.3 // indirect github.com/mitchellh/go-homedir v1.1.0 // indirect - golang.org/x/crypto v0.15.0 // indirect - golang.org/x/sys v0.14.0 // indirect - golang.org/x/text v0.14.0 // indirect - gopkg.in/yaml.v2 v2.4.0 // indirect + golang.org/x/sys v0.20.0 // indirect + golang.org/x/text v0.15.0 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index 0db4555..e378f47 100644 --- a/go.sum +++ b/go.sum @@ -1,50 +1,20 @@ -github.com/gophercloud/gophercloud v1.3.0/go.mod h1:aAVqcocTSXh2vYFZ1JTvx4EQmfgzxRcNupUfxZbBNDM= -github.com/gophercloud/gophercloud v1.7.0 h1:fyJGKh0LBvIZKLvBWvQdIgkaV5yTM3Jh9EYUh+UNCAs= -github.com/gophercloud/gophercloud v1.7.0/go.mod h1:aAVqcocTSXh2vYFZ1JTvx4EQmfgzxRcNupUfxZbBNDM= -github.com/gophercloud/utils v0.0.0-20231010081019-80377eca5d56 h1:sH7xkTfYzxIEgzq1tDHIMKRh1vThOEOGNsettdEeLbE= -github.com/gophercloud/utils v0.0.0-20231010081019-80377eca5d56/go.mod h1:VSalo4adEk+3sNkmVJLnhHoOyOYYS8sTWLG4mv5BKto= +github.com/gophercloud/gophercloud/v2 v2.0.0-beta.2 h1:JWv6L7eg3+aIS57n11YlVvtn1pVCKpVlMo24ANj/OVc= +github.com/gophercloud/gophercloud/v2 v2.0.0-beta.2/go.mod h1:Sy5GHwY4iazyaRf94rzL/VxJToVWn8WnIH+1cXqoAks= +github.com/gophercloud/utils/v2 v2.0.0-20240506072225-f79c3b81b6bf h1:rUkY7wUpz8dOPdjG5sJyL/+/e+lgumBg5yk46w4yOtc= +github.com/gophercloud/utils/v2 v2.0.0-20240506072225-f79c3b81b6bf/go.mod h1:KtcoIkIhkgguzWu1S5lK629+tjnGlByoGFNYswjRHOo= github.com/hashicorp/go-uuid v1.0.3 h1:2gKiV6YVmrJ1i2CKKa9obLvRieoRGviZFL26PcT/Co8= github.com/hashicorp/go-uuid v1.0.3/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= -github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/crypto v0.15.0 h1:frVn1TEaCEaZcn3Tmd7Y2b5KKPaZ+I32Q2OA3kYp5TA= -golang.org/x/crypto v0.15.0/go.mod h1:4ChreQoLWfG3xLDer1WdlH5NdlQ3+mwnQq1YTKY+72g= -golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -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-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.2.0 h1:ljd4t30dBnAvMZaQCevtY0xLLD0A+bRZXbgLMLU1F/A= -golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.14.0 h1:Vz7Qs629MkJkGyHxUlRHizWJRG2j8fbQKjELVSNhy7Q= -golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.4.0 h1:BrVqGRd7+k1DiOgtnFvAkoQEWQvBc25ouMJM6429SFg= -golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= -golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/crypto v0.23.0 h1:dIJU/v2J8Mdglj/8rJ6UUOM3Zc9zLZxVZwwxMooUSAI= +golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8= +golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y= +golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/term v0.20.0 h1:VnkxpohqXaOBYJtBmEppKUG6mXpi+4O6purfc2+sMhw= +golang.org/x/term v0.20.0/go.mod h1:8UkIAJTvZgivsXaD6/pH6U9ecQzZ45awqEOzuCvwpFY= +golang.org/x/text v0.15.0 h1:h1V/4gjBv8v9cjcR6+AR5+/cIYK5N/WAgiv4xlsEtAk= +golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= -gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/internal/openstack/client/neutron.go b/internal/openstack/client/neutron.go new file mode 100644 index 0000000..4a346ae --- /dev/null +++ b/internal/openstack/client/neutron.go @@ -0,0 +1,63 @@ +package openstack + +import ( + "context" + "fmt" + + "github.com/gophercloud/gophercloud/v2" + "github.com/gophercloud/gophercloud/v2/openstack/networking/v2/ports" + "github.com/gophercloud/gophercloud/v2/pagination" + "github.com/gophercloud/utils/v2/openstack/clientconfig" + "github.com/modzilla99/osssh/types/openstack/neutron" +) + +func (c *OpenStackClient) GetNeutronClient() (*gophercloud.ServiceClient, error) { + n, err := clientconfig.NewServiceClient(context.Background(), "network", c.auth) + if err != nil { + fmt.Println("Error getting Neutron client: ", err) + } + return n, err +} + +func getNeutronPortByServerID(c *gophercloud.ServiceClient, id string) (*neutron.Port, error) { + s := ports.ListOpts{ + DeviceID: id, + } + p, err := ports.List(c, s).AllPages(context.TODO()) + if err != nil { + return nil, err + } + ap, err := extractPorts(p) + if err != nil { + return nil, err + } + if len(ap) == 0 { + return nil, fmt.Errorf("no ports found") + } + return &ap[0], nil +} + +func getNeutronDistributedPortByNetworkID(c *gophercloud.ServiceClient, id string) (*neutron.Port, error) { + s := ports.ListOpts{ + NetworkID: id, + DeviceOwner: "network:distributed", + } + pa, err := ports.List(c, s).AllPages(context.TODO()) + if err != nil { + return nil, err + } + p, err := extractPorts(pa) + if err != nil { + return nil, err + } + if len(p) == 0 { + return nil, fmt.Errorf("unable to retrieve distributed port") + } + return &p[0], nil +} + +func extractPorts(r pagination.Page) ([]neutron.Port, error) { + var s []neutron.Port + err := ports.ExtractPortsInto(r, &s) + return s, err +} \ No newline at end of file diff --git a/internal/openstack/client/nova.go b/internal/openstack/client/nova.go new file mode 100644 index 0000000..fb70cca --- /dev/null +++ b/internal/openstack/client/nova.go @@ -0,0 +1,26 @@ +package openstack + +import ( + "context" + + "github.com/gophercloud/gophercloud/v2" + "github.com/gophercloud/gophercloud/v2/openstack/compute/v2/servers" + "github.com/gophercloud/utils/v2/openstack/clientconfig" + "github.com/modzilla99/osssh/types/openstack/nova" +) + +func (c *OpenStackClient) GetNovaClient() (*gophercloud.ServiceClient, error) { + return clientconfig.NewServiceClient(context.Background(), "compute", c.auth) +} + +func getServerByID(c *gophercloud.ServiceClient, id string) (*nova.Server, error) { + s := &nova.Server{} + if err := servers.Get(context.TODO(), c, id).ExtractInto(s); err != nil { + return nil, err + } + return s, nil +} + +func getHypervisorFromServer(s *nova.Server) string { + return s.HypervisorHostname +} \ No newline at end of file diff --git a/internal/openstack/client/openstack.go b/internal/openstack/client/openstack.go index 450d5d6..38803e5 100644 --- a/internal/openstack/client/openstack.go +++ b/internal/openstack/client/openstack.go @@ -1,13 +1,11 @@ package openstack import ( + "context" "fmt" - "github.com/gophercloud/gophercloud" - "github.com/gophercloud/gophercloud/openstack/networking/v2/ports" - "github.com/gophercloud/gophercloud/pagination" - "github.com/gophercloud/utils/openstack/clientconfig" - "github.com/modzilla99/osssh/types/openstack/neutron" + "github.com/gophercloud/gophercloud/v2" + "github.com/gophercloud/utils/v2/openstack/clientconfig" ) type Info struct { @@ -36,91 +34,47 @@ func CreateClient() (*OpenStackClient, error) { } func authenticate(o *clientconfig.ClientOpts) (provider *gophercloud.ProviderClient, err error) { - provider, err = clientconfig.AuthenticatedClient(o) + provider, err = clientconfig.AuthenticatedClient(context.Background(), o) if err != nil { if err.Error() == "You must provide exactly one of DomainID or DomainName in a Scope with ProjectName" { o.AuthInfo.DomainName = "default" - return clientconfig.AuthenticatedClient(o) + return clientconfig.AuthenticatedClient(context.Background(), o) } return nil, err } return provider, nil } -func (c *OpenStackClient) GetNeutronClient() (*gophercloud.ServiceClient, error) { - n, err := clientconfig.NewServiceClient("network", c.auth) - if err != nil { - fmt.Println("Error getting Neutron client: ", err) - } - return n, err -} - -func (c *OpenStackClient) GetNovaClient() (*gophercloud.ServiceClient, error) { - return clientconfig.NewServiceClient("compute", c.auth) -} - func GetInfo(osc *OpenStackClient, uuid string) (*Info, error) { fmt.Print("Fetching data from OpenStack...") - n, err := osc.GetNeutronClient() - if err != nil { - return nil, err - } - pS, err := getNeutronPortByServerID(n, uuid) - if err != nil { - return nil, err - } - pD, err := getNeutronDistributedPortByNetworkID(n, pS.NetworkID) + neutron, err := osc.GetNeutronClient() if err != nil { return nil, err } - fmt.Println("Done") - return &Info{ - IPAddress: pS.FixedIPs[0].IPAddress, - HypervisorHostname: pS.HostID, - MetadataPort: pD.DeviceID, - }, nil -} - -func getNeutronPortByServerID(c *gophercloud.ServiceClient, id string) (*neutron.Port, error) { - s := ports.ListOpts{ - DeviceID: id, - } - p, err := ports.List(c, s).AllPages() + nova, err := osc.GetNovaClient() if err != nil { return nil, err } - ap, err := extractPorts(p) + + s, err := getServerByID(nova, uuid) if err != nil { return nil, err } - if len(ap) == 0 { - return nil, fmt.Errorf("no ports found") - } - return &ap[0], nil -} -func getNeutronDistributedPortByNetworkID(c *gophercloud.ServiceClient, id string) (*neutron.Port, error) { - s := ports.ListOpts{ - NetworkID: id, - DeviceOwner: "network:distributed", - } - pa, err := ports.List(c, s).AllPages() + pS, err := getNeutronPortByServerID(neutron, uuid) if err != nil { return nil, err } - p, err := extractPorts(pa) + pD, err := getNeutronDistributedPortByNetworkID(neutron, pS.NetworkID) if err != nil { return nil, err } - if len(p) == 0 { - return nil, fmt.Errorf("unable to retrieve distributed port") - } - return &p[0], nil -} -func extractPorts(r pagination.Page) ([]neutron.Port, error) { - var s []neutron.Port - err := ports.ExtractPortsInto(r, &s) - return s, err -} \ No newline at end of file + fmt.Println("Done") + return &Info{ + IPAddress: pS.FixedIPs[0].IPAddress, + HypervisorHostname: getHypervisorFromServer(s), + MetadataPort: pD.DeviceID, + }, nil +} diff --git a/internal/openstack/ports/ports.go b/internal/openstack/ports/ports.go deleted file mode 100644 index 5b8bac5..0000000 --- a/internal/openstack/ports/ports.go +++ /dev/null @@ -1,28 +0,0 @@ -package ports - -import "github.com/gophercloud/gophercloud/openstack/networking/v2/ports" - -type ListOpts struct { - Status string `q:"status"` - Name string `q:"name"` - Description string `q:"description"` - AdminStateUp *bool `q:"admin_state_up"` - NetworkID string `q:"network_id"` - TenantID string `q:"tenant_id"` - ProjectID string `q:"project_id"` - DeviceOwner string `q:"device_owner"` - MACAddress string `q:"mac_address"` - ID string `q:"id"` - DeviceID string `q:"device_id"` - Limit int `q:"limit"` - Marker string `q:"marker"` - SortKey string `q:"sort_key"` - SortDir string `q:"sort_dir"` - Tags string `q:"tags"` - TagsAny string `q:"tags-any"` - NotTags string `q:"not-tags"` - NotTagsAny string `q:"not-tags-any"` - SecurityGroups []string `q:"security_groups"` - FixedIPs []ports.FixedIPOpts - HostID string `q:"host_id"` -} \ No newline at end of file diff --git a/types/openstack/nova/server.go b/types/openstack/nova/server.go new file mode 100644 index 0000000..b9e944c --- /dev/null +++ b/types/openstack/nova/server.go @@ -0,0 +1,28 @@ +package nova + +import "time" + +type Server struct { + ID string `json:"id"` + TenantID string `json:"tenant_id"` + UserID string `json:"user_id"` + Name string `json:"name"` + Updated time.Time `json:"updated"` + Created time.Time `json:"created"` + HostID string `json:"hostid"` + HypervisorHostname string `json:"OS-EXT-SRV-ATTR:hypervisor_hostname"` + Status string `json:"status"` + Progress int `json:"progress"` + AccessIPv4 string `json:"accessIPv4"` + AccessIPv6 string `json:"accessIPv6"` + Image map[string]interface{} `json:"-"` + Flavor map[string]interface{} `json:"flavor"` + Addresses map[string]interface{} `json:"addresses"` + Metadata map[string]string `json:"metadata"` + Links []interface{} `json:"links"` + KeyName string `json:"key_name"` + AdminPass string `json:"adminPass"` + SecurityGroups []map[string]interface{} `json:"security_groups"` + Tags *[]string `json:"tags"` + ServerGroups *[]string `json:"server_groups"` +} \ No newline at end of file