Compare commits
6 Commits
v1.6.0-zet
...
v1.6.5
| Author | SHA1 | Date | |
|---|---|---|---|
| b069c31745 | |||
| 2953ef0a85 | |||
| 50a4d5ade2 | |||
| 1575b75fa6 | |||
| 35fa4af0d6 | |||
| d3e6309ef8 |
37
CHANGELOG.md
37
CHANGELOG.md
@@ -1,32 +1,7 @@
|
||||
## Version 1.6.0
|
||||
## Version 1.6.5
|
||||
|
||||
### Bugfix
|
||||
- Fix cloudaApi/client and cloudapi/legacy-client, the cyclicity of sending requests has been removed
|
||||
- Edit description field SSLSkipVerify in cloudapi/config/config and cloudapi/config/legacy-config
|
||||
- Remove tags required fields ExtNetID VINSID Start in model CreateRequest in cloudapi/lb/create
|
||||
- Add tags required fields BindingName BindingAddress BindingPort in model FrontendBindRequest in cloudapi/lb/frontend_bind
|
||||
- Add tags required fields BindingAddress BindingPort in model FrontendBindUpdateRequest in cloudapi/lb/frontend_bind_update
|
||||
|
||||
### Feature
|
||||
- Add field UserData in cloudapi/bservice/group_add
|
||||
- Add fields VinsId, LbSysctlParams, HighlyAvailable, AdditionalSANs, InitConfiguration, ClusterConfiguration, KubeletConfiguration, KubeProxyConfiguration, JoinConfiguration, UserData, ExtNetOnly, OidcCertificate in model request cloudapi/k8s/create
|
||||
- Add field Externalip in model ItemDetailedInfo in cloudapi/k8s/models
|
||||
- Add fields SysctlParams, HighlyAvailable in model CreateRequest in cloudapi/lb/create
|
||||
- Add fields BackendHAIP, FrontendHAIP, PartK8s, SysctlParams in model RecordLB in cloudapi/lb/models
|
||||
- Add models InfoStack, ItemStack, ListStacks cloudapi/stack/models
|
||||
- Add field Routes and type Route in CreateInAccountRequest and CreateInRGRequest models in cloudapi/vins/create_in_rg and /cloudapi/vins/create_in_account
|
||||
- Add field Enabled in model ItemVNFInterface
|
||||
- Add fields Routes in models RecordNAT, RecordDHCP, RecordGW and add type ListStaticRoutes, ListRoutes, ItemRoutes in cloudapi/vins/models
|
||||
|
||||
- Added new endpoints:
|
||||
- cloudapi/k8s/get_worker_nodes_meta_data
|
||||
- cloudapi/k8s/update_worker_nodes_meta_data
|
||||
- cloudapi/lb/make_highly_available
|
||||
- cloudapi/lb/updateSysctParams
|
||||
- cloudapi/stack/get
|
||||
- cloudapi/stack/list
|
||||
- cloudapi/vins/static_route_list
|
||||
- cloudapi/vins/static_route_access_grant
|
||||
- cloudapi/vins/static_route_access_revoke
|
||||
- cloudapi/vins/static_route_add
|
||||
- cloudapi/vins/static_route_del
|
||||
## 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
|
||||
333
client.go
333
client.go
@@ -15,9 +15,9 @@ import (
|
||||
"time"
|
||||
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/k8s"
|
||||
k8s_ca "repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/k8s"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker"
|
||||
|
||||
k8s_cb"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker/k8s"
|
||||
"github.com/google/go-querystring/query"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/config"
|
||||
)
|
||||
@@ -71,114 +71,253 @@ func (dc *DecortClient) CloudBroker() *cloudbroker.CloudBroker {
|
||||
|
||||
// DecortApiCall method for sending requests to the platform
|
||||
func (dc *DecortClient) DecortApiCall(ctx context.Context, method, url string, params interface{}) ([]byte, error) {
|
||||
if k8sCreateReq, ok := params.(k8s.CreateRequest); ok {
|
||||
k8sCaCreateReq, okCa := params.(k8s_ca.CreateRequest)
|
||||
k8sCbCreateReq, okCb := params.(k8s_cb.CreateRequest)
|
||||
|
||||
if okCa {
|
||||
reqBody := &bytes.Buffer{}
|
||||
writer := multipart.NewWriter(reqBody)
|
||||
if k8sCreateReq.OidcCertificate != "" {
|
||||
if k8sCaCreateReq.OidcCertificate != "" {
|
||||
part, _ := writer.CreateFormFile("oidcCertificate", "ca.crt")
|
||||
_, _ =io.Copy(part, strings.NewReader(k8sCreateReq.OidcCertificate))
|
||||
_, _ = io.Copy(part, strings.NewReader(k8sCaCreateReq.OidcCertificate))
|
||||
}
|
||||
|
||||
_= writer.WriteField("name", k8sCreateReq.Name)
|
||||
_= writer.WriteField("rgId", strconv.FormatUint(k8sCreateReq.RGID, 10))
|
||||
_= writer.WriteField("k8ciId", strconv.FormatUint(k8sCreateReq.K8SCIID, 10))
|
||||
_= writer.WriteField("workerGroupName", k8sCreateReq.WorkerGroupName)
|
||||
_= writer.WriteField("networkPlugin", k8sCreateReq.NetworkPlugin)
|
||||
_ = writer.WriteField("name", k8sCaCreateReq.Name)
|
||||
_ = writer.WriteField("rgId", strconv.FormatUint(k8sCaCreateReq.RGID, 10))
|
||||
_ = writer.WriteField("k8ciId", strconv.FormatUint(k8sCaCreateReq.K8SCIID, 10))
|
||||
_ = writer.WriteField("workerGroupName", k8sCaCreateReq.WorkerGroupName)
|
||||
_ = writer.WriteField("networkPlugin", k8sCaCreateReq.NetworkPlugin)
|
||||
|
||||
if k8sCreateReq.MasterSEPID != 0 {
|
||||
_= writer.WriteField("masterSepId", strconv.FormatUint(k8sCreateReq.MasterSEPID, 10))
|
||||
if k8sCaCreateReq.MasterSEPID != 0 {
|
||||
_ = writer.WriteField("masterSepId", strconv.FormatUint(k8sCaCreateReq.MasterSEPID, 10))
|
||||
}
|
||||
if k8sCreateReq.MasterSEPPool != "" {
|
||||
_= writer.WriteField("masterSepPool", k8sCreateReq.MasterSEPPool)
|
||||
if k8sCaCreateReq.MasterSEPPool != "" {
|
||||
_ = writer.WriteField("masterSepPool", k8sCaCreateReq.MasterSEPPool)
|
||||
}
|
||||
if k8sCreateReq.WorkerSEPID != 0 {
|
||||
_= writer.WriteField("workerSepId", strconv.FormatUint(k8sCreateReq.WorkerSEPID, 10))
|
||||
if k8sCaCreateReq.WorkerSEPID != 0 {
|
||||
_ = writer.WriteField("workerSepId", strconv.FormatUint(k8sCaCreateReq.WorkerSEPID, 10))
|
||||
}
|
||||
if k8sCreateReq.WorkerSEPPool != "" {
|
||||
_= writer.WriteField("workerSepPool", k8sCreateReq.WorkerSEPPool)
|
||||
if k8sCaCreateReq.WorkerSEPPool != "" {
|
||||
_ = writer.WriteField("workerSepPool", k8sCaCreateReq.WorkerSEPPool)
|
||||
}
|
||||
|
||||
if k8sCreateReq.Labels != nil {
|
||||
for _, v := range k8sCreateReq.Labels {
|
||||
_= writer.WriteField("labels", v)
|
||||
if k8sCaCreateReq.Labels != nil {
|
||||
for _, v := range k8sCaCreateReq.Labels {
|
||||
_ = writer.WriteField("labels", v)
|
||||
}
|
||||
}
|
||||
if k8sCreateReq.Taints != nil {
|
||||
for _, v := range k8sCreateReq.Taints {
|
||||
_= writer.WriteField("taints", v)
|
||||
if k8sCaCreateReq.Taints != nil {
|
||||
for _, v := range k8sCaCreateReq.Taints {
|
||||
_ = writer.WriteField("taints", v)
|
||||
}
|
||||
}
|
||||
if k8sCreateReq.Annotations != nil {
|
||||
for _, v := range k8sCreateReq.Annotations {
|
||||
_= writer.WriteField("annotations", v)
|
||||
if k8sCaCreateReq.Annotations != nil {
|
||||
for _, v := range k8sCaCreateReq.Annotations {
|
||||
_ = writer.WriteField("annotations", v)
|
||||
}
|
||||
}
|
||||
|
||||
if k8sCreateReq.MasterCPU != 0 {
|
||||
_= writer.WriteField("masterCpu", strconv.FormatUint(uint64(k8sCreateReq.MasterCPU), 10))
|
||||
if k8sCaCreateReq.MasterCPU != 0 {
|
||||
_ = writer.WriteField("masterCpu", strconv.FormatUint(uint64(k8sCaCreateReq.MasterCPU), 10))
|
||||
}
|
||||
if k8sCreateReq.MasterNum != 0 {
|
||||
_= writer.WriteField("masterNum", strconv.FormatUint(uint64(k8sCreateReq.MasterNum), 10))
|
||||
if k8sCaCreateReq.MasterNum != 0 {
|
||||
_ = writer.WriteField("masterNum", strconv.FormatUint(uint64(k8sCaCreateReq.MasterNum), 10))
|
||||
}
|
||||
if k8sCreateReq.MasterRAM != 0 {
|
||||
_= writer.WriteField("masterRam", strconv.FormatUint(uint64(k8sCreateReq.MasterRAM), 10))
|
||||
if k8sCaCreateReq.MasterRAM != 0 {
|
||||
_ = writer.WriteField("masterRam", strconv.FormatUint(uint64(k8sCaCreateReq.MasterRAM), 10))
|
||||
}
|
||||
if k8sCreateReq.MasterDisk != 0 {
|
||||
_= writer.WriteField("masterDisk", strconv.FormatUint(uint64(k8sCreateReq.MasterDisk), 10))
|
||||
if k8sCaCreateReq.MasterDisk != 0 {
|
||||
_ = writer.WriteField("masterDisk", strconv.FormatUint(uint64(k8sCaCreateReq.MasterDisk), 10))
|
||||
}
|
||||
if k8sCreateReq.WorkerCPU != 0 {
|
||||
_= writer.WriteField("workerCpu", strconv.FormatUint(uint64(k8sCreateReq.WorkerCPU), 10))
|
||||
if k8sCaCreateReq.WorkerCPU != 0 {
|
||||
_ = writer.WriteField("workerCpu", strconv.FormatUint(uint64(k8sCaCreateReq.WorkerCPU), 10))
|
||||
}
|
||||
if k8sCreateReq.WorkerNum != 0 {
|
||||
_= writer.WriteField("workerNum", strconv.FormatUint(uint64(k8sCreateReq.WorkerNum), 10))
|
||||
if k8sCaCreateReq.WorkerNum != 0 {
|
||||
_ = writer.WriteField("workerNum", strconv.FormatUint(uint64(k8sCaCreateReq.WorkerNum), 10))
|
||||
}
|
||||
if k8sCreateReq.WorkerRAM != 0 {
|
||||
_= writer.WriteField("workerRam", strconv.FormatUint(uint64(k8sCreateReq.WorkerRAM), 10))
|
||||
if k8sCaCreateReq.WorkerRAM != 0 {
|
||||
_ = writer.WriteField("workerRam", strconv.FormatUint(uint64(k8sCaCreateReq.WorkerRAM), 10))
|
||||
}
|
||||
if k8sCreateReq.WorkerDisk != 0 {
|
||||
_= writer.WriteField("workerDisk", strconv.FormatUint(uint64(k8sCreateReq.WorkerDisk), 10))
|
||||
if k8sCaCreateReq.WorkerDisk != 0 {
|
||||
_ = writer.WriteField("workerDisk", strconv.FormatUint(uint64(k8sCaCreateReq.WorkerDisk), 10))
|
||||
}
|
||||
if k8sCreateReq.ExtNetID != 0 {
|
||||
_= writer.WriteField("extnetId", strconv.FormatUint(k8sCreateReq.ExtNetID, 10))
|
||||
if k8sCaCreateReq.ExtNetID != 0 {
|
||||
_ = writer.WriteField("extnetId", strconv.FormatUint(k8sCaCreateReq.ExtNetID, 10))
|
||||
}
|
||||
if k8sCreateReq.VinsId != 0 {
|
||||
_= writer.WriteField("vinsId", strconv.FormatUint(k8sCreateReq.VinsId, 10))
|
||||
if k8sCaCreateReq.VinsId != 0 {
|
||||
_ = writer.WriteField("vinsId", strconv.FormatUint(k8sCaCreateReq.VinsId, 10))
|
||||
}
|
||||
if !k8sCreateReq.WithLB {
|
||||
_= writer.WriteField("withLB", strconv.FormatBool(k8sCreateReq.WithLB))
|
||||
if !k8sCaCreateReq.WithLB {
|
||||
_ = writer.WriteField("withLB", strconv.FormatBool(k8sCaCreateReq.WithLB))
|
||||
}
|
||||
|
||||
_= writer.WriteField("highlyAvailable", strconv.FormatBool(k8sCreateReq.HighlyAvailable))
|
||||
_ = writer.WriteField("highlyAvailableLB", strconv.FormatBool(k8sCaCreateReq.HighlyAvailable))
|
||||
|
||||
if k8sCreateReq.AdditionalSANs != nil {
|
||||
for _, v := range k8sCreateReq.AdditionalSANs {
|
||||
_= writer.WriteField("additionalSANs", v)
|
||||
if k8sCaCreateReq.AdditionalSANs != nil {
|
||||
for _, v := range k8sCaCreateReq.AdditionalSANs {
|
||||
_ = writer.WriteField("additionalSANs", v)
|
||||
}
|
||||
}
|
||||
if k8sCreateReq.InitConfiguration != "" {
|
||||
_= writer.WriteField("initConfiguration", k8sCreateReq.InitConfiguration)
|
||||
if k8sCaCreateReq.InitConfiguration != "" {
|
||||
_ = writer.WriteField("initConfiguration", k8sCaCreateReq.InitConfiguration)
|
||||
}
|
||||
if k8sCreateReq.ClusterConfiguration != "" {
|
||||
_= writer.WriteField("clusterConfiguration", k8sCreateReq.ClusterConfiguration)
|
||||
if k8sCaCreateReq.ClusterConfiguration != "" {
|
||||
_ = writer.WriteField("clusterConfiguration", k8sCaCreateReq.ClusterConfiguration)
|
||||
}
|
||||
if k8sCreateReq.KubeletConfiguration != "" {
|
||||
_= writer.WriteField("kubeletConfiguration", k8sCreateReq.KubeletConfiguration)
|
||||
if k8sCaCreateReq.KubeletConfiguration != "" {
|
||||
_ = writer.WriteField("kubeletConfiguration", k8sCaCreateReq.KubeletConfiguration)
|
||||
}
|
||||
if k8sCreateReq.KubeProxyConfiguration != "" {
|
||||
_= writer.WriteField("kubeProxyConfiguration", k8sCreateReq.KubeProxyConfiguration)
|
||||
if k8sCaCreateReq.KubeProxyConfiguration != "" {
|
||||
_ = writer.WriteField("kubeProxyConfiguration", k8sCaCreateReq.KubeProxyConfiguration)
|
||||
}
|
||||
if k8sCreateReq.JoinConfiguration != "" {
|
||||
_= writer.WriteField("joinConfiguration", k8sCreateReq.JoinConfiguration)
|
||||
if k8sCaCreateReq.JoinConfiguration != "" {
|
||||
_ = writer.WriteField("joinConfiguration", k8sCaCreateReq.JoinConfiguration)
|
||||
}
|
||||
if k8sCreateReq.Description != "" {
|
||||
_= writer.WriteField("desc", k8sCreateReq.Description)
|
||||
if k8sCaCreateReq.Description != "" {
|
||||
_ = writer.WriteField("desc", k8sCaCreateReq.Description)
|
||||
}
|
||||
if k8sCreateReq.UserData != "" {
|
||||
_= writer.WriteField("userData", k8sCreateReq.UserData)
|
||||
if k8sCaCreateReq.UserData != "" {
|
||||
_ = writer.WriteField("userData", k8sCaCreateReq.UserData)
|
||||
}
|
||||
|
||||
_= writer.WriteField("extnetOnly", strconv.FormatBool(k8sCreateReq.ExtNetOnly))
|
||||
_= writer.FormDataContentType()
|
||||
_ = writer.WriteField("extnetOnly", strconv.FormatBool(k8sCaCreateReq.ExtNetOnly))
|
||||
_ = writer.FormDataContentType()
|
||||
|
||||
ct := writer.FormDataContentType()
|
||||
|
||||
writer.Close()
|
||||
req, err := http.NewRequestWithContext(ctx, method, dc.decortURL+"/restmachine"+url, reqBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err = dc.getToken(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
resp, err := dc.domp(req, ct)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
respBytes, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if resp.StatusCode != 200 {
|
||||
return nil, errors.New(string(respBytes))
|
||||
}
|
||||
|
||||
return respBytes, nil
|
||||
} else if okCb {
|
||||
reqBody := &bytes.Buffer{}
|
||||
writer := multipart.NewWriter(reqBody)
|
||||
if k8sCbCreateReq.OidcCertificate != "" {
|
||||
part, _ := writer.CreateFormFile("oidcCertificate", "ca.crt")
|
||||
_, _ = io.Copy(part, strings.NewReader(k8sCbCreateReq.OidcCertificate))
|
||||
}
|
||||
|
||||
_ = writer.WriteField("name", k8sCbCreateReq.Name)
|
||||
_ = writer.WriteField("rgId", strconv.FormatUint(k8sCbCreateReq.RGID, 10))
|
||||
_ = writer.WriteField("k8ciId", strconv.FormatUint(k8sCbCreateReq.K8CIID, 10))
|
||||
_ = writer.WriteField("workerGroupName", k8sCbCreateReq.WorkerGroupName)
|
||||
_ = writer.WriteField("networkPlugin", k8sCbCreateReq.NetworkPlugin)
|
||||
|
||||
if k8sCbCreateReq.MasterSEPID != 0 {
|
||||
_ = writer.WriteField("masterSepId", strconv.FormatUint(k8sCbCreateReq.MasterSEPID, 10))
|
||||
}
|
||||
if k8sCbCreateReq.MasterSEPPool != "" {
|
||||
_ = writer.WriteField("masterSepPool", k8sCbCreateReq.MasterSEPPool)
|
||||
}
|
||||
if k8sCbCreateReq.WorkerSEPID != 0 {
|
||||
_ = writer.WriteField("workerSepId", strconv.FormatUint(k8sCbCreateReq.WorkerSEPID, 10))
|
||||
}
|
||||
if k8sCbCreateReq.WorkerSEPPool != "" {
|
||||
_ = writer.WriteField("workerSepPool", k8sCbCreateReq.WorkerSEPPool)
|
||||
}
|
||||
|
||||
if k8sCbCreateReq.Labels != nil {
|
||||
for _, v := range k8sCbCreateReq.Labels {
|
||||
_ = writer.WriteField("labels", v)
|
||||
}
|
||||
}
|
||||
if k8sCbCreateReq.Taints != nil {
|
||||
for _, v := range k8sCbCreateReq.Taints {
|
||||
_ = writer.WriteField("taints", v)
|
||||
}
|
||||
}
|
||||
if k8sCbCreateReq.Annotations != nil {
|
||||
for _, v := range k8sCbCreateReq.Annotations {
|
||||
_ = writer.WriteField("annotations", v)
|
||||
}
|
||||
}
|
||||
|
||||
if k8sCbCreateReq.MasterCPU != 0 {
|
||||
_ = writer.WriteField("masterCpu", strconv.FormatUint(k8sCbCreateReq.MasterCPU, 10))
|
||||
}
|
||||
if k8sCbCreateReq.MasterNum != 0 {
|
||||
_ = writer.WriteField("masterNum", strconv.FormatUint(k8sCbCreateReq.MasterNum, 10))
|
||||
}
|
||||
if k8sCbCreateReq.MasterRAM != 0 {
|
||||
_ = writer.WriteField("masterRam", strconv.FormatUint(k8sCbCreateReq.MasterRAM, 10))
|
||||
}
|
||||
if k8sCbCreateReq.MasterDisk != 0 {
|
||||
_ = writer.WriteField("masterDisk", strconv.FormatUint(k8sCbCreateReq.MasterDisk, 10))
|
||||
}
|
||||
if k8sCbCreateReq.WorkerCPU != 0 {
|
||||
_ = writer.WriteField("workerCpu", strconv.FormatUint(k8sCbCreateReq.WorkerCPU, 10))
|
||||
}
|
||||
if k8sCbCreateReq.WorkerNum != 0 {
|
||||
_ = writer.WriteField("workerNum", strconv.FormatUint(k8sCbCreateReq.WorkerNum, 10))
|
||||
}
|
||||
if k8sCbCreateReq.WorkerRAM != 0 {
|
||||
_ = writer.WriteField("workerRam", strconv.FormatUint(k8sCbCreateReq.WorkerRAM, 10))
|
||||
}
|
||||
if k8sCbCreateReq.WorkerDisk != 0 {
|
||||
_ = writer.WriteField("workerDisk", strconv.FormatUint(k8sCbCreateReq.WorkerDisk, 10))
|
||||
}
|
||||
if k8sCbCreateReq.ExtNetID != 0 {
|
||||
_ = writer.WriteField("extnetId", strconv.FormatUint(k8sCbCreateReq.ExtNetID, 10))
|
||||
}
|
||||
if k8sCbCreateReq.VinsId != 0 {
|
||||
_ = writer.WriteField("vinsId", strconv.FormatUint(k8sCbCreateReq.VinsId, 10))
|
||||
}
|
||||
if !k8sCbCreateReq.WithLB {
|
||||
_ = writer.WriteField("withLB", strconv.FormatBool(k8sCbCreateReq.WithLB))
|
||||
}
|
||||
|
||||
_ = writer.WriteField("highlyAvailableLB", strconv.FormatBool(k8sCbCreateReq.HighlyAvailable))
|
||||
|
||||
if k8sCbCreateReq.AdditionalSANs != nil {
|
||||
for _, v := range k8sCbCreateReq.AdditionalSANs {
|
||||
_ = writer.WriteField("additionalSANs", v)
|
||||
}
|
||||
}
|
||||
if k8sCbCreateReq.InitConfiguration != "" {
|
||||
_ = writer.WriteField("initConfiguration", k8sCbCreateReq.InitConfiguration)
|
||||
}
|
||||
if k8sCbCreateReq.ClusterConfiguration != "" {
|
||||
_ = writer.WriteField("clusterConfiguration", k8sCbCreateReq.ClusterConfiguration)
|
||||
}
|
||||
if k8sCbCreateReq.KubeletConfiguration != "" {
|
||||
_ = writer.WriteField("kubeletConfiguration", k8sCbCreateReq.KubeletConfiguration)
|
||||
}
|
||||
if k8sCbCreateReq.KubeProxyConfiguration != "" {
|
||||
_ = writer.WriteField("kubeProxyConfiguration", k8sCbCreateReq.KubeProxyConfiguration)
|
||||
}
|
||||
if k8sCbCreateReq.JoinConfiguration != "" {
|
||||
_ = writer.WriteField("joinConfiguration", k8sCbCreateReq.JoinConfiguration)
|
||||
}
|
||||
if k8sCbCreateReq.Description != "" {
|
||||
_ = writer.WriteField("desc", k8sCbCreateReq.Description)
|
||||
}
|
||||
if k8sCbCreateReq.UserData != "" {
|
||||
_ = writer.WriteField("userData", k8sCbCreateReq.UserData)
|
||||
}
|
||||
|
||||
_ = writer.WriteField("extnetOnly", strconv.FormatBool(k8sCbCreateReq.ExtNetOnly))
|
||||
_ = writer.FormDataContentType()
|
||||
|
||||
ct := writer.FormDataContentType()
|
||||
|
||||
@@ -281,24 +420,24 @@ func (dc *DecortClient) do(req *http.Request) (*http.Response, error) {
|
||||
req.Header.Add("Authorization", "bearer "+dc.cfg.Token)
|
||||
req.Header.Set("Accept", "application/json")
|
||||
|
||||
var resp *http.Response
|
||||
var err error
|
||||
// var resp *http.Response
|
||||
// var err error
|
||||
buf, _ := io.ReadAll(req.Body)
|
||||
req = req.Clone(req.Context())
|
||||
// req = req.Clone(req.Context())
|
||||
|
||||
for i := uint64(0); i < dc.cfg.Retries; i++ {
|
||||
req.Body = io.NopCloser(bytes.NewBuffer(buf))
|
||||
resp, err = dc.client.Do(req)
|
||||
// for i := uint64(0); i < dc.cfg.Retries; i++ {
|
||||
req.Body = io.NopCloser(bytes.NewBuffer(buf))
|
||||
resp, err := dc.client.Do(req)
|
||||
|
||||
// if err == nil {
|
||||
if resp.StatusCode == 200 {
|
||||
return resp, err
|
||||
}
|
||||
respBytes, _ := io.ReadAll(resp.Body)
|
||||
err = fmt.Errorf("%s", respBytes)
|
||||
resp.Body.Close()
|
||||
// }
|
||||
// if err == nil {
|
||||
if resp.StatusCode == 200 {
|
||||
return resp, err
|
||||
}
|
||||
respBytes, _ := io.ReadAll(resp.Body)
|
||||
err = fmt.Errorf("%s", respBytes)
|
||||
resp.Body.Close()
|
||||
// }
|
||||
// }
|
||||
|
||||
return nil, fmt.Errorf("could not execute request: %w", err)
|
||||
}
|
||||
@@ -308,24 +447,24 @@ func (dc *DecortClient) domp(req *http.Request, ctype string) (*http.Response, e
|
||||
req.Header.Add("Authorization", "bearer "+dc.cfg.Token)
|
||||
req.Header.Set("Accept", "application/json")
|
||||
|
||||
var resp *http.Response
|
||||
var err error
|
||||
// var resp *http.Response
|
||||
// var err error
|
||||
buf, _ := io.ReadAll(req.Body)
|
||||
req = req.Clone(req.Context())
|
||||
// req = req.Clone(req.Context())
|
||||
|
||||
for i := uint64(0); i < dc.cfg.Retries; i++ {
|
||||
req.Body = io.NopCloser(bytes.NewBuffer(buf))
|
||||
resp, err = dc.client.Do(req)
|
||||
// for i := uint64(0); i < dc.cfg.Retries; i++ {
|
||||
req.Body = io.NopCloser(bytes.NewBuffer(buf))
|
||||
resp, err := dc.client.Do(req)
|
||||
|
||||
// if err == nil {
|
||||
if resp.StatusCode == 200 {
|
||||
return resp, err
|
||||
}
|
||||
respBytes, _ := io.ReadAll(resp.Body)
|
||||
err = fmt.Errorf("%s", respBytes)
|
||||
resp.Body.Close()
|
||||
// }
|
||||
// if err == nil {
|
||||
if resp.StatusCode == 200 {
|
||||
return resp, err
|
||||
}
|
||||
respBytes, _ := io.ReadAll(resp.Body)
|
||||
err = fmt.Errorf("%s", respBytes)
|
||||
resp.Body.Close()
|
||||
// }
|
||||
// }
|
||||
|
||||
return nil, fmt.Errorf("could not execute request: %w", err)
|
||||
}
|
||||
|
||||
176
legacy-client.go
176
legacy-client.go
@@ -7,8 +7,10 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"mime/multipart"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
@@ -16,6 +18,7 @@ import (
|
||||
"github.com/google/go-querystring/query"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/config"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudapi/k8s"
|
||||
"repository.basistech.ru/BASIS/decort-golang-sdk/pkg/cloudbroker"
|
||||
)
|
||||
|
||||
@@ -68,6 +71,148 @@ func (ldc *LegacyDecortClient) CloudBroker() *cloudbroker.CloudBroker {
|
||||
|
||||
// DecortApiCall method for sending requests to the platform
|
||||
func (ldc *LegacyDecortClient) DecortApiCall(ctx context.Context, method, url string, params interface{}) ([]byte, error) {
|
||||
if k8sCreateReq, ok := params.(k8s.CreateRequest); ok {
|
||||
reqBody := &bytes.Buffer{}
|
||||
writer := multipart.NewWriter(reqBody)
|
||||
if k8sCreateReq.OidcCertificate != "" {
|
||||
part, _ := writer.CreateFormFile("oidcCertificate", "ca.crt")
|
||||
_, _ = io.Copy(part, strings.NewReader(k8sCreateReq.OidcCertificate))
|
||||
}
|
||||
|
||||
_ = writer.WriteField("name", k8sCreateReq.Name)
|
||||
_ = writer.WriteField("rgId", strconv.FormatUint(k8sCreateReq.RGID, 10))
|
||||
_ = writer.WriteField("k8ciId", strconv.FormatUint(k8sCreateReq.K8SCIID, 10))
|
||||
_ = writer.WriteField("workerGroupName", k8sCreateReq.WorkerGroupName)
|
||||
_ = writer.WriteField("networkPlugin", k8sCreateReq.NetworkPlugin)
|
||||
|
||||
if k8sCreateReq.MasterSEPID != 0 {
|
||||
_ = writer.WriteField("masterSepId", strconv.FormatUint(k8sCreateReq.MasterSEPID, 10))
|
||||
}
|
||||
if k8sCreateReq.MasterSEPPool != "" {
|
||||
_ = writer.WriteField("masterSepPool", k8sCreateReq.MasterSEPPool)
|
||||
}
|
||||
if k8sCreateReq.WorkerSEPID != 0 {
|
||||
_ = writer.WriteField("workerSepId", strconv.FormatUint(k8sCreateReq.WorkerSEPID, 10))
|
||||
}
|
||||
if k8sCreateReq.WorkerSEPPool != "" {
|
||||
_ = writer.WriteField("workerSepPool", k8sCreateReq.WorkerSEPPool)
|
||||
}
|
||||
|
||||
if k8sCreateReq.Labels != nil {
|
||||
for _, v := range k8sCreateReq.Labels {
|
||||
_ = writer.WriteField("labels", v)
|
||||
}
|
||||
}
|
||||
if k8sCreateReq.Taints != nil {
|
||||
for _, v := range k8sCreateReq.Taints {
|
||||
_ = writer.WriteField("taints", v)
|
||||
}
|
||||
}
|
||||
if k8sCreateReq.Annotations != nil {
|
||||
for _, v := range k8sCreateReq.Annotations {
|
||||
_ = writer.WriteField("annotations", v)
|
||||
}
|
||||
}
|
||||
|
||||
if k8sCreateReq.MasterCPU != 0 {
|
||||
_ = writer.WriteField("masterCpu", strconv.FormatUint(uint64(k8sCreateReq.MasterCPU), 10))
|
||||
}
|
||||
if k8sCreateReq.MasterNum != 0 {
|
||||
_ = writer.WriteField("masterNum", strconv.FormatUint(uint64(k8sCreateReq.MasterNum), 10))
|
||||
}
|
||||
if k8sCreateReq.MasterRAM != 0 {
|
||||
_ = writer.WriteField("masterRam", strconv.FormatUint(uint64(k8sCreateReq.MasterRAM), 10))
|
||||
}
|
||||
if k8sCreateReq.MasterDisk != 0 {
|
||||
_ = writer.WriteField("masterDisk", strconv.FormatUint(uint64(k8sCreateReq.MasterDisk), 10))
|
||||
}
|
||||
if k8sCreateReq.WorkerCPU != 0 {
|
||||
_ = writer.WriteField("workerCpu", strconv.FormatUint(uint64(k8sCreateReq.WorkerCPU), 10))
|
||||
}
|
||||
if k8sCreateReq.WorkerNum != 0 {
|
||||
_ = writer.WriteField("workerNum", strconv.FormatUint(uint64(k8sCreateReq.WorkerNum), 10))
|
||||
}
|
||||
if k8sCreateReq.WorkerRAM != 0 {
|
||||
_ = writer.WriteField("workerRam", strconv.FormatUint(uint64(k8sCreateReq.WorkerRAM), 10))
|
||||
}
|
||||
if k8sCreateReq.WorkerDisk != 0 {
|
||||
_ = writer.WriteField("workerDisk", strconv.FormatUint(uint64(k8sCreateReq.WorkerDisk), 10))
|
||||
}
|
||||
if k8sCreateReq.ExtNetID != 0 {
|
||||
_ = writer.WriteField("extnetId", strconv.FormatUint(k8sCreateReq.ExtNetID, 10))
|
||||
}
|
||||
if k8sCreateReq.VinsId != 0 {
|
||||
_ = writer.WriteField("vinsId", strconv.FormatUint(k8sCreateReq.VinsId, 10))
|
||||
}
|
||||
if !k8sCreateReq.WithLB {
|
||||
_ = writer.WriteField("withLB", strconv.FormatBool(k8sCreateReq.WithLB))
|
||||
}
|
||||
|
||||
_ = writer.WriteField("highlyAvailableLB", strconv.FormatBool(k8sCreateReq.HighlyAvailable))
|
||||
|
||||
if k8sCreateReq.AdditionalSANs != nil {
|
||||
for _, v := range k8sCreateReq.AdditionalSANs {
|
||||
_ = writer.WriteField("additionalSANs", v)
|
||||
}
|
||||
}
|
||||
if k8sCreateReq.InitConfiguration != "" {
|
||||
_ = writer.WriteField("initConfiguration", k8sCreateReq.InitConfiguration)
|
||||
}
|
||||
if k8sCreateReq.ClusterConfiguration != "" {
|
||||
_ = writer.WriteField("clusterConfiguration", k8sCreateReq.ClusterConfiguration)
|
||||
}
|
||||
if k8sCreateReq.KubeletConfiguration != "" {
|
||||
_ = writer.WriteField("kubeletConfiguration", k8sCreateReq.KubeletConfiguration)
|
||||
}
|
||||
if k8sCreateReq.KubeProxyConfiguration != "" {
|
||||
_ = writer.WriteField("kubeProxyConfiguration", k8sCreateReq.KubeProxyConfiguration)
|
||||
}
|
||||
if k8sCreateReq.JoinConfiguration != "" {
|
||||
_ = writer.WriteField("joinConfiguration", k8sCreateReq.JoinConfiguration)
|
||||
}
|
||||
if k8sCreateReq.Description != "" {
|
||||
_ = writer.WriteField("desc", k8sCreateReq.Description)
|
||||
}
|
||||
if k8sCreateReq.UserData != "" {
|
||||
_ = writer.WriteField("userData", k8sCreateReq.UserData)
|
||||
}
|
||||
|
||||
_ = writer.WriteField("extnetOnly", strconv.FormatBool(k8sCreateReq.ExtNetOnly))
|
||||
_ = writer.FormDataContentType()
|
||||
|
||||
ct := writer.FormDataContentType()
|
||||
|
||||
if err := ldc.getToken(ctx); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
_ = writer.WriteField("authkey", ldc.cfg.Token)
|
||||
|
||||
writer.Close()
|
||||
|
||||
req, err := http.NewRequestWithContext(ctx, method, ldc.decortURL+"/restmachine"+url, reqBody)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
resp, err := ldc.domp(req, ct)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
respBytes, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if resp.StatusCode != 200 {
|
||||
return nil, errors.New(string(respBytes))
|
||||
}
|
||||
|
||||
return respBytes, nil
|
||||
}
|
||||
|
||||
values, err := query.Values(params)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -140,10 +285,10 @@ func (ldc *LegacyDecortClient) do(req *http.Request) (*http.Response, error) {
|
||||
// var resp *http.Response
|
||||
// var err error
|
||||
buf, _ := io.ReadAll(req.Body)
|
||||
req = req.Clone(req.Context())
|
||||
// req = req.Clone(req.Context())
|
||||
|
||||
// for i := uint64(0); i < ldc.cfg.Retries; i++ {
|
||||
req = req.Clone(req.Context())
|
||||
|
||||
req.Body = io.NopCloser(bytes.NewBuffer(buf))
|
||||
resp, err := ldc.client.Do(req)
|
||||
|
||||
@@ -159,3 +304,30 @@ func (ldc *LegacyDecortClient) do(req *http.Request) (*http.Response, error) {
|
||||
|
||||
return nil, fmt.Errorf("could not execute request: %w", err)
|
||||
}
|
||||
|
||||
func (ldc *LegacyDecortClient) domp(req *http.Request, ctype string) (*http.Response, error) {
|
||||
req.Header.Add("Content-Type", ctype)
|
||||
req.Header.Add("Authorization", "bearer "+ldc.cfg.Token)
|
||||
req.Header.Set("Accept", "application/json")
|
||||
|
||||
// var resp *http.Response
|
||||
// var err error
|
||||
buf, _ := io.ReadAll(req.Body)
|
||||
// req = req.Clone(req.Context())
|
||||
|
||||
// for i := uint64(0); i < ldc.cfg.Retries; i++ {
|
||||
req.Body = io.NopCloser(bytes.NewBuffer(buf))
|
||||
resp, err := ldc.client.Do(req)
|
||||
|
||||
// if err == nil {
|
||||
if resp.StatusCode == 200 {
|
||||
return resp, err
|
||||
}
|
||||
respBytes, _ := io.ReadAll(resp.Body)
|
||||
err = fmt.Errorf("%s", respBytes)
|
||||
resp.Body.Close()
|
||||
// }
|
||||
// }
|
||||
|
||||
return nil, fmt.Errorf("could not execute request: %w", err)
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ type Resource struct {
|
||||
DiskSize float64 `json:"disksize"`
|
||||
|
||||
// Max disk size
|
||||
DiskSizeMax uint64 `json:"disksizemax"`
|
||||
DiskSizeMax float64 `json:"disksizemax"`
|
||||
|
||||
// Number of External IPs
|
||||
ExtIPs int64 `json:"extips"`
|
||||
@@ -126,10 +126,10 @@ type RecordResourceConsumption struct {
|
||||
// Information about resources
|
||||
type ItemResourceConsumption struct {
|
||||
// Current information about resources
|
||||
Current Resource `json:"Current"`
|
||||
Consumed Resource `json:"consumed"`
|
||||
|
||||
// Reserved information about resources
|
||||
Reserved Resource `json:"Reserved"`
|
||||
Reserved Resource `json:"reserved"`
|
||||
|
||||
// Account ID
|
||||
AccountID uint64 `json:"id"`
|
||||
|
||||
@@ -22,9 +22,9 @@ type ListPCIDeviceRequest struct {
|
||||
// Required: false
|
||||
DevID uint64 `url:"devId,omitempty" json:"devId,omitempty"`
|
||||
|
||||
// Find by type
|
||||
// Find by name
|
||||
// Required: false
|
||||
Type string `url:"type,omitempty" json:"type,omitempty"`
|
||||
Name string `url:"name,omitempty" json:"name,omitempty"`
|
||||
|
||||
// Find by status
|
||||
// Required: false
|
||||
|
||||
@@ -111,11 +111,11 @@ type CreateRequest struct {
|
||||
|
||||
// Custom sysctl values for Load Balancer instance. Applied on boot
|
||||
// Required: false
|
||||
LbSysctlParams string `url:"-" json:"lbSysctlParams,omitempty" validate:"omitempty,dive"`
|
||||
LbSysctlParams string `url:"lbSysctlParams,omitempty" json:"lbSysctlParams,omitempty"`
|
||||
|
||||
// Use Highly Available schema for LB deploy
|
||||
// Required: false
|
||||
HighlyAvailable bool `url:"highlyAvailable,omitempty" json:"highlyAvailable,omitempty"`
|
||||
HighlyAvailable bool `url:"highlyAvailableLB,omitempty" json:"highlyAvailableLB,omitempty"`
|
||||
|
||||
// Optional extra Subject Alternative Names (SANs) to use for the API Server serving certificate. Can be both IP addresses and DNS names
|
||||
// Required: false
|
||||
|
||||
@@ -32,10 +32,6 @@ type ListDeletedRequest struct {
|
||||
// Required: false
|
||||
BasicServiceID uint64 `url:"basicServiceId,omitempty" json:"basicServiceId,omitempty"`
|
||||
|
||||
// Find by status
|
||||
// Required: false
|
||||
Status string `url:"status,omitempty" json:"status,omitempty"`
|
||||
|
||||
// Find by techStatus
|
||||
// Required: false
|
||||
TechStatus string `url:"techStatus,omitempty" json:"techStatus,omitempty"`
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -6,7 +6,7 @@ type RecordLB struct {
|
||||
HAMode bool `json:"HAmode"`
|
||||
|
||||
// Access Control List
|
||||
ACL []interface{} `json:"acl"`
|
||||
ACL interface{} `json:"acl"`
|
||||
|
||||
// BackendHAIP
|
||||
BackendHAIP string `json:"backendHAIP"`
|
||||
@@ -78,7 +78,7 @@ type RecordLB struct {
|
||||
Status string `json:"status"`
|
||||
|
||||
// Sysctl Params
|
||||
SysctlParams []interface{} `json:"sysctlParams"`
|
||||
SysctlParams interface{} `json:"sysctlParams"`
|
||||
|
||||
// Tech status
|
||||
TechStatus string `json:"techStatus"`
|
||||
|
||||
@@ -13,6 +13,14 @@ type AffinityGroupsListRequest struct {
|
||||
// Resource group ID
|
||||
// Required: true
|
||||
RGID uint64 `url:"rgId" json:"rgId" validate:"required"`
|
||||
|
||||
// Page number
|
||||
// Required: false
|
||||
Page uint64 `url:"page,omitempty" json:"page,omitempty"`
|
||||
|
||||
// Page size
|
||||
// Required: false
|
||||
Size uint64 `url:"size,omitempty" json:"size,omitempty"`
|
||||
}
|
||||
|
||||
// AffinityGroupsList gets all currently defined affinity groups in this resource group with compute IDs
|
||||
|
||||
@@ -48,10 +48,10 @@ type Resources struct {
|
||||
// Detailed information about resource consumption
|
||||
type ItemResourceConsumption struct {
|
||||
// Consumed information about resources
|
||||
Consumed Resource `json:"Consumed"`
|
||||
Consumed Resource `json:"consumed"`
|
||||
|
||||
// Reserved information about resources
|
||||
Reserved Resource `json:"Reserved"`
|
||||
Reserved Resource `json:"reserved"`
|
||||
|
||||
// Resource limits
|
||||
ResourceLimits ResourceLimits `json:"resourceLimits"`
|
||||
@@ -333,7 +333,7 @@ type ListAffinityGroupsComputes []ItemAffinityGroupComputes
|
||||
|
||||
type ListAffinityGroups struct {
|
||||
// Data
|
||||
Data map[string][]uint64 `json:"data"`
|
||||
Data []map[string][]uint64 `json:"data"`
|
||||
|
||||
// Entry count
|
||||
EntryCount uint64 `json:"entryCount"`
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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()
|
||||
|
||||
|
||||
@@ -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"`
|
||||
|
||||
// Meta
|
||||
Meta []interface{} `json:"_meta"`
|
||||
|
||||
// API URL
|
||||
APIURL string `json:"apiUrl"`
|
||||
|
||||
// API key
|
||||
APIKey string `json:"apikey"`
|
||||
|
||||
// App ID
|
||||
AppID string `json:"appId"`
|
||||
|
||||
// CPU allocation ratio
|
||||
CPUAllocationRatio float64 `json:"cpu_allocation_ratio"`
|
||||
|
||||
// Description
|
||||
Description string `json:"desc"`
|
||||
|
||||
// Descr
|
||||
Descr string `json:"descr"`
|
||||
|
||||
// Drivers
|
||||
Drivers []string `json:"drivers"`
|
||||
|
||||
// Eco
|
||||
Eco interface{} `json:"eco"`
|
||||
|
||||
// Error
|
||||
Error uint64 `json:"error"`
|
||||
|
||||
// Grid ID
|
||||
GID uint64 `json:"gid"`
|
||||
|
||||
// GID
|
||||
GUID uint64 `json:"guid"`
|
||||
|
||||
// ID
|
||||
ID uint64 `json:"id"`
|
||||
|
||||
// List image IDs
|
||||
Images []uint64 `json:"images"`
|
||||
|
||||
// Login
|
||||
Login string `json:"login"`
|
||||
|
||||
// Mem allocation ratio
|
||||
// Required: false
|
||||
MemAllocationRatio float64 `json:"mem_allocation_ratio"`
|
||||
|
||||
// Name
|
||||
Name string `json:"name"`
|
||||
|
||||
// Password
|
||||
Password string `json:"passwd"`
|
||||
|
||||
// Reference ID
|
||||
ReferenceID string `json:"referenceId"`
|
||||
|
||||
// Status
|
||||
Status string `json:"status"`
|
||||
|
||||
// Type
|
||||
Type string `json:"type"`
|
||||
} `json:"data"`
|
||||
// Data
|
||||
Data []ItemListStacks `json:"data"`
|
||||
|
||||
// Entry count
|
||||
EntryCount uint64 `json:"entryCount"`
|
||||
}
|
||||
|
||||
// Detailed information about image
|
||||
type ItemListStacks struct {
|
||||
// CKey
|
||||
CKey string `json:"_ckey"`
|
||||
|
||||
// Meta
|
||||
Meta []interface{} `json:"_meta"`
|
||||
|
||||
// API URL
|
||||
APIURL string `json:"apiUrl"`
|
||||
|
||||
// API key
|
||||
APIKey string `json:"apikey"`
|
||||
|
||||
// App ID
|
||||
AppID string `json:"appId"`
|
||||
|
||||
// CPU allocation ratio
|
||||
CPUAllocationRatio float64 `json:"cpu_allocation_ratio"`
|
||||
|
||||
// Description
|
||||
Description string `json:"desc"`
|
||||
|
||||
// Descr
|
||||
Descr string `json:"descr"`
|
||||
|
||||
// Drivers
|
||||
Drivers []string `json:"drivers"`
|
||||
|
||||
// Eco
|
||||
Eco interface{} `json:"eco"`
|
||||
|
||||
// Error
|
||||
Error uint64 `json:"error"`
|
||||
|
||||
// Grid ID
|
||||
GID uint64 `json:"gid"`
|
||||
|
||||
// GID
|
||||
GUID uint64 `json:"guid"`
|
||||
|
||||
// ID
|
||||
ID uint64 `json:"id"`
|
||||
|
||||
// List image IDs
|
||||
Images []uint64 `json:"images"`
|
||||
|
||||
// Login
|
||||
Login string `json:"login"`
|
||||
|
||||
// Mem allocation ratio
|
||||
MemAllocationRatio float64 `json:"mem_allocation_ratio"`
|
||||
|
||||
// Name
|
||||
Name string `json:"name"`
|
||||
|
||||
// Packegas
|
||||
Packages Packages `json:"packages"`
|
||||
|
||||
// Password
|
||||
Password string `json:"passwd"`
|
||||
|
||||
// Reference ID
|
||||
ReferenceID string `json:"referenceId"`
|
||||
|
||||
// Status
|
||||
Status string `json:"status"`
|
||||
|
||||
// Type
|
||||
Type string `json:"type"`
|
||||
}
|
||||
|
||||
// Package
|
||||
type Packages struct {
|
||||
// LibvirtBin
|
||||
LibvirtBin LibvirtBin `json:"libvirt-bin"`
|
||||
|
||||
// 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"`
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ type CreateRequest struct {
|
||||
|
||||
// Name for first worker group created with cluster
|
||||
// Required: true
|
||||
WorkerGroupName string `url:"workerGroupName" json:"workerGroupName" validate:"required, workerGroupName"`
|
||||
WorkerGroupName string `url:"workerGroupName" json:"workerGroupName" validate:"required,workerGroupName"`
|
||||
|
||||
// Network plugin
|
||||
// Must be one of these values: flunnel, weawenet, calico
|
||||
@@ -113,11 +113,11 @@ type CreateRequest struct {
|
||||
|
||||
// Custom sysctl values for Load Balancer instance. Applied on boot
|
||||
// Required: false
|
||||
LbSysctlParams string `url:"-" json:"lbSysctlParams,omitempty" validate:"omitempty,dive"`
|
||||
LbSysctlParams string `url:"lbSysctlParams,omitempty" json:"lbSysctlParams,omitempty"`
|
||||
|
||||
// Use Highly Available schema for LB deploy
|
||||
// Required: false
|
||||
HighlyAvailable bool `url:"highlyAvailable,omitempty" json:"highlyAvailable,omitempty"`
|
||||
HighlyAvailable bool `url:"highlyAvailableLB,omitempty" json:"highlyAvailableLB,omitempty"`
|
||||
|
||||
// Optional extra Subject Alternative Names (SANs) to use for the API Server serving certificate. Can be both IP addresses and DNS names
|
||||
// Required: false
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -16,11 +16,11 @@ type HighlyAvailableRequest struct {
|
||||
}
|
||||
|
||||
// Make Load Balancer Highly available
|
||||
func (l LB) HighlyAvailable(ctx context.Context, req HighlyAvailableRequest) (uint64, error) {
|
||||
func (l LB) HighlyAvailable(ctx context.Context, req HighlyAvailableRequest) (bool, error) {
|
||||
err := validators.ValidateRequest(req)
|
||||
if err != nil {
|
||||
for _, validationError := range validators.GetErrors(err) {
|
||||
return 0, validators.ValidationError(validationError)
|
||||
return false, validators.ValidationError(validationError)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,12 +28,12 @@ func (l LB) HighlyAvailable(ctx context.Context, req HighlyAvailableRequest) (ui
|
||||
|
||||
res, err := l.client.DecortApiCall(ctx, http.MethodPost, url, req)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
return false, err
|
||||
}
|
||||
|
||||
result, err := strconv.ParseUint(string(res), 10, 64)
|
||||
result, err := strconv.ParseBool(string(res))
|
||||
if err != nil {
|
||||
return 0, err
|
||||
return false, err
|
||||
}
|
||||
|
||||
return result, nil
|
||||
|
||||
@@ -154,7 +154,10 @@ type RecordLB struct {
|
||||
Meta []interface{} `json:"_meta"`
|
||||
|
||||
// Access Control List
|
||||
ACL []interface{} `json:"acl"`
|
||||
ACL interface{} `json:"acl"`
|
||||
|
||||
// BackendHAIP
|
||||
BackendHAIP string `json:"backendHAIP"`
|
||||
|
||||
// List of load balancer backends
|
||||
Backends ListBackends `json:"backends"`
|
||||
@@ -171,6 +174,9 @@ type RecordLB struct {
|
||||
// External network ID
|
||||
ExtNetID uint64 `json:"extnetId"`
|
||||
|
||||
// FrontendHAIP
|
||||
FrontendHAIP string `json:"frontendHAIP"`
|
||||
|
||||
// List of load balancer frontends
|
||||
Frontends ListFrontends `json:"frontends"`
|
||||
|
||||
@@ -208,7 +214,7 @@ type RecordLB struct {
|
||||
Status string `json:"status"`
|
||||
|
||||
// Sysctl Params
|
||||
SysctlParams []string `json:"sysctlParams"`
|
||||
SysctlParams interface{} `json:"sysctlParams"`
|
||||
|
||||
// Tech status
|
||||
TechStatus string `json:"techStatus"`
|
||||
@@ -223,7 +229,10 @@ type ItemLBList struct {
|
||||
HAMode bool `json:"HAmode"`
|
||||
|
||||
// Access Control List
|
||||
ACL []interface{} `json:"acl"`
|
||||
ACL interface{} `json:"acl"`
|
||||
|
||||
// BackendHAIP
|
||||
BackendHAIP string `json:"backendHAIP"`
|
||||
|
||||
// List of load balancer backends
|
||||
Backends ListBackends `json:"backends"`
|
||||
@@ -252,6 +261,9 @@ type ItemLBList struct {
|
||||
// External network ID
|
||||
ExtNetID uint64 `json:"extnetId"`
|
||||
|
||||
// FrontendHAIP
|
||||
FrontendHAIP string `json:"frontendHAIP"`
|
||||
|
||||
// List of load balancer frontends
|
||||
Frontends ListFrontends `json:"frontends"`
|
||||
|
||||
@@ -286,7 +298,7 @@ type ItemLBList struct {
|
||||
Status string `json:"status"`
|
||||
|
||||
// Sysctl Params
|
||||
SysctlParams []string `json:"sysctlParams"`
|
||||
SysctlParams interface{} `json:"sysctlParams"`
|
||||
|
||||
// Tech status
|
||||
TechStatus string `json:"techStatus"`
|
||||
|
||||
@@ -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"`
|
||||
|
||||
|
||||
Reference in New Issue
Block a user