From b069c3174573156108397c670701915da7662195 Mon Sep 17 00:00:00 2001 From: Nikita Sorokin Date: Wed, 11 Oct 2023 12:18:27 +0300 Subject: [PATCH] v1.6.5 --- CHANGELOG.md | 14 +- pkg/cloudapi/k8s/workers_group_add.go | 4 + pkg/cloudbroker/grid/filter.go | 9 ++ pkg/cloudbroker/grid/filter_test.go | 8 + pkg/cloudbroker/image/models.go | 193 +++++++++++++++++------ pkg/cloudbroker/k8s/workers_group_add.go | 4 + pkg/cloudbroker/stack/models.go | 18 ++- 7 files changed, 185 insertions(+), 65 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1e501b5..6571ce4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,9 +1,7 @@ -## Version 1.6.4 +## Version 1.6.5 -### Bugfix -- Fixed type field DiskSizeMax in Resource model in cloudapi/account/models. Rename field ItemResourceConsumption model and rename json's tags in cloudapi/account/models -- Rename field in ListPCIDeviceRequest model in cloudapi/compute/list_pci_device -- Delete excess field in ListDeletedRequest model in cloudapi/k8s/list_deleted -- Add fields Page and Size in AffinityGroupsListRequest model in cloudapi/lb/affinity_groups_list -- Fixed type field Data in ListAffinityGroups model in cloudapi/lb/models -- Rename in ItemResourceConsumption model json's tags in cloudapi/rg/models +## Feature +- Add field and type LibvirtDaemon in model Packages in cloudbroker/stack/models +- Add field and type Packages in model ItemListStacks in cloudbroker/image/models. Add fields and type LibvirtBin, LibvirtDaemon, Lvm2Lockd, OpenvswitchCommon, OpenvswitchSwitch, QemuSystemX86, Sanlock +- Add filter ByGID in cloudbroker/grid/filters +- Add field userData in models WorkersGroupAddRequest in cloudapi/k8s and cloudbroker/k8s \ No newline at end of file diff --git a/pkg/cloudapi/k8s/workers_group_add.go b/pkg/cloudapi/k8s/workers_group_add.go index acb421b..843d7e1 100644 --- a/pkg/cloudapi/k8s/workers_group_add.go +++ b/pkg/cloudapi/k8s/workers_group_add.go @@ -56,6 +56,10 @@ type WorkersGroupAddRequest struct { // Worker node boot disk size in GB If 0 is specified, size is defined by the OS image size // Required: false WorkerDisk uint64 `url:"workerDisk,omitempty" json:"workerDisk,omitempty"` + + // Meta data for working group computes, format YAML "user_data": 1111 + // Required: false + UserData string `url:"userData,omitempty" json:"userData,omitempty"` } // WorkersGroupAdd adds workers group to Kubernetes cluster diff --git a/pkg/cloudbroker/grid/filter.go b/pkg/cloudbroker/grid/filter.go index a509797..8b80e14 100644 --- a/pkg/cloudbroker/grid/filter.go +++ b/pkg/cloudbroker/grid/filter.go @@ -9,6 +9,15 @@ func (lg ListGrids) FilterByID(id uint64) ListGrids { return lg.FilterFunc(predicate) } +// FilterByGID returns ListGrids with specified GID. +func (lg ListGrids) FilterByGID(gid uint64) ListGrids { + predicate := func(rg ItemGridList) bool { + return rg.GID == gid + } + + return lg.FilterFunc(predicate) +} + // FilterByName returns ListGrids with specified Name. func (lg ListGrids) FilterByName(name string) ListGrids { predicate := func(rg ItemGridList) bool { diff --git a/pkg/cloudbroker/grid/filter_test.go b/pkg/cloudbroker/grid/filter_test.go index 1e85d57..f69a387 100644 --- a/pkg/cloudbroker/grid/filter_test.go +++ b/pkg/cloudbroker/grid/filter_test.go @@ -106,6 +106,14 @@ func TestFilterByID(t *testing.T) { } } +func TestFilterByGID(t *testing.T) { + actual := grids.FilterByGID(777).FindOne() + + if actual.GID != 777 { + t.Fatal("expected ID 777, found: ", actual.GID) + } +} + func TestFilterByName(t *testing.T) { actual := grids.FilterByName("gamma").FindOne() diff --git a/pkg/cloudbroker/image/models.go b/pkg/cloudbroker/image/models.go index 3a4e955..14824da 100644 --- a/pkg/cloudbroker/image/models.go +++ b/pkg/cloudbroker/image/models.go @@ -176,10 +176,10 @@ type GUID string func (r *GUID) UnmarshalJSON(b []byte) error { if b[0] == '"' { - *r = GUID(string(b[1:len(b)-1])) + *r = GUID(string(b[1 : len(b)-1])) return nil } - + *r = GUID(string(b)) return nil @@ -190,74 +190,167 @@ type ListHistory []History // List stacks type ListStacks struct { - Data []struct { - // CKey - CKey string `json:"_ckey"` + // Data + Data []ItemListStacks `json:"data"` - // Meta - Meta []interface{} `json:"_meta"` + // Entry count + EntryCount uint64 `json:"entryCount"` +} - // API URL - APIURL string `json:"apiUrl"` +// Detailed information about image +type ItemListStacks struct { + // CKey + CKey string `json:"_ckey"` - // API key - APIKey string `json:"apikey"` + // Meta + Meta []interface{} `json:"_meta"` + + // API URL + APIURL string `json:"apiUrl"` + + // API key + APIKey string `json:"apikey"` + + // App ID + AppID string `json:"appId"` - // App ID - AppID string `json:"appId"` + // CPU allocation ratio + CPUAllocationRatio float64 `json:"cpu_allocation_ratio"` - // CPU allocation ratio - CPUAllocationRatio float64 `json:"cpu_allocation_ratio"` + // Description + Description string `json:"desc"` - // Description - Description string `json:"desc"` + // Descr + Descr string `json:"descr"` + + // Drivers + Drivers []string `json:"drivers"` - // Descr - Descr string `json:"descr"` + // Eco + Eco interface{} `json:"eco"` - // Drivers - Drivers []string `json:"drivers"` + // Error + Error uint64 `json:"error"` - // Eco - Eco interface{} `json:"eco"` + // Grid ID + GID uint64 `json:"gid"` - // Error - Error uint64 `json:"error"` + // GID + GUID uint64 `json:"guid"` - // Grid ID - GID uint64 `json:"gid"` + // ID + ID uint64 `json:"id"` - // GID - GUID uint64 `json:"guid"` + // List image IDs + Images []uint64 `json:"images"` - // ID - ID uint64 `json:"id"` + // Login + Login string `json:"login"` - // List image IDs - Images []uint64 `json:"images"` + // Mem allocation ratio + MemAllocationRatio float64 `json:"mem_allocation_ratio"` - // Login - Login string `json:"login"` + // Name + Name string `json:"name"` - // Mem allocation ratio - // Required: false - MemAllocationRatio float64 `json:"mem_allocation_ratio"` + // Packegas + Packages Packages `json:"packages"` - // Name - Name string `json:"name"` + // Password + Password string `json:"passwd"` - // Password - Password string `json:"passwd"` + // Reference ID + ReferenceID string `json:"referenceId"` - // Reference ID - ReferenceID string `json:"referenceId"` + // Status + Status string `json:"status"` - // Status - Status string `json:"status"` + // Type + Type string `json:"type"` +} - // Type - Type string `json:"type"` - } `json:"data"` +// Package +type Packages struct { + // LibvirtBin + LibvirtBin LibvirtBin `json:"libvirt-bin"` - EntryCount uint64 `json:"entryCount"` + // LibvirtDaemon + LibvirtDaemon LibvirtDaemon `json:"libvirt-daemon"` + + // Lvm2Lockd + Lvm2Lockd Lvm2Lockd `json:"lvm2-lockd"` + + // OpenvswitchCommon + OpenvswitchCommon OpenvswitchCommon `json:"openvswitch-common"` + + // OpenvswitchSwitch + OpenvswitchSwitch OpenvswitchSwitch `json:"openvswitch-switch"` + + // QemuSystemX86 + QemuSystemX86 QemuSystemX86 `json:"qemu-system-x86"` + + // Sanlock + Sanlock Sanlock `json:"sanlock"` +} + +// LibvirtBin +type LibvirtBin struct { + // InstalledSize + InstalledSize string `json:"installed_size"` + + // Version + Ver string `json:"ver"` +} + +type LibvirtDaemon struct { + // InstalledSize + InstalledSize string `json:"installed_size"` + + // Version + Ver string `json:"ver"` +} + +// Lvm2Lockd +type Lvm2Lockd struct { + // InstalledSize + InstalledSize string `json:"installed_size"` + + // Version + Ver string `json:"ver"` +} + +// OpenvswitchCommon +type OpenvswitchCommon struct { + // InstalledSize + InstalledSize string `json:"installed_size"` + + // Version + Ver string `json:"ver"` +} + +// OpenvswitchSwitch +type OpenvswitchSwitch struct { + // InstalledSize + InstalledSize string `json:"installed_size"` + + // Version + Ver string `json:"ver"` +} + +// QemuSystemX86 +type QemuSystemX86 struct { + // InstalledSize + InstalledSize string `json:"installed_size"` + + // Version + Ver string `json:"ver"` +} + +// Sanlock +type Sanlock struct { + // InstalledSize + InstalledSize string `json:"installed_size"` + + // Version + Ver string `json:"ver"` } diff --git a/pkg/cloudbroker/k8s/workers_group_add.go b/pkg/cloudbroker/k8s/workers_group_add.go index 3f2516f..3f501b9 100644 --- a/pkg/cloudbroker/k8s/workers_group_add.go +++ b/pkg/cloudbroker/k8s/workers_group_add.go @@ -58,6 +58,10 @@ type WorkersGroupAddRequest struct { // Worker node boot disk size in GB If 0 is specified, size is defined by the OS image size // Required: false WorkerDisk uint64 `url:"workerDisk,omitempty" json:"workerDisk,omitempty"` + + // Meta data for working group computes, format YAML "user_data": 1111 + // Required: false + UserData string `url:"userData,omitempty" json:"userData,omitempty"` } // WorkersGroupAdd adds workers group to kubernetes cluster diff --git a/pkg/cloudbroker/stack/models.go b/pkg/cloudbroker/stack/models.go index 39ecf12..3613ea1 100644 --- a/pkg/cloudbroker/stack/models.go +++ b/pkg/cloudbroker/stack/models.go @@ -43,6 +43,7 @@ type InfoStack struct { // ID ID uint64 `json:"id"` + // List image IDs Images []uint64 `json:"images"` @@ -73,7 +74,6 @@ type InfoStack struct { // List of stacks type ListStacks struct { - //List Data []InfoStack `json:"data"` @@ -83,10 +83,12 @@ type ListStacks struct { // Package type Packages struct { - // LibvirtBin LibvirtBin LibvirtBin `json:"libvirt-bin"` + // LibvirtDaemon + LibvirtDaemon LibvirtDaemon `json:"libvirt-daemon"` + // Lvm2Lockd Lvm2Lockd Lvm2Lockd `json:"lvm2-lockd"` @@ -105,7 +107,14 @@ type Packages struct { // LibvirtBin type LibvirtBin struct { + // InstalledSize + InstalledSize string `json:"installed_size"` + + // Version + Ver string `json:"ver"` +} +type LibvirtDaemon struct { // InstalledSize InstalledSize string `json:"installed_size"` @@ -115,7 +124,6 @@ type LibvirtBin struct { // Lvm2Lockd type Lvm2Lockd struct { - // InstalledSize InstalledSize string `json:"installed_size"` @@ -125,7 +133,6 @@ type Lvm2Lockd struct { // OpenvswitchCommon type OpenvswitchCommon struct { - // InstalledSize InstalledSize string `json:"installed_size"` @@ -135,7 +142,6 @@ type OpenvswitchCommon struct { // OpenvswitchSwitch type OpenvswitchSwitch struct { - // InstalledSize InstalledSize string `json:"installed_size"` @@ -145,7 +151,6 @@ type OpenvswitchSwitch struct { // QemuSystemX86 type QemuSystemX86 struct { - // InstalledSize InstalledSize string `json:"installed_size"` @@ -155,7 +160,6 @@ type QemuSystemX86 struct { // Sanlock type Sanlock struct { - // InstalledSize InstalledSize string `json:"installed_size"`