Skip to content
This repository has been archived by the owner on Nov 8, 2019. It is now read-only.

Commit

Permalink
Merge pull request #97 from ingrammicro/release/nimbostratus
Browse files Browse the repository at this point in the history
Release/nimbostratus
  • Loading branch information
pbanos authored Mar 25, 2019
2 parents c3ec001 + 02814da commit 3e47ef2
Show file tree
Hide file tree
Showing 47 changed files with 2,923 additions and 279 deletions.
8 changes: 7 additions & 1 deletion Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,7 @@
[[constraint]]
name = "github.com/pmezard/go-difflib"
revision = "792786c7400a136282c1664665ae0a8db921c6c2"

[[constraint]]
branch = "master"
name = "github.com/allan-simon/go-singleinstance"
262 changes: 141 additions & 121 deletions README.md

Large diffs are not rendered by default.

93 changes: 93 additions & 0 deletions api/blueprint/bootstrapping_api.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
package blueprint

import (
"encoding/json"
"fmt"

log "github.com/Sirupsen/logrus"
"github.com/ingrammicro/concerto/api/types"
"github.com/ingrammicro/concerto/utils"
)


// BootstrappingService manages bootstrapping operations
type BootstrappingService struct {
concertoService utils.ConcertoService
}

// NewBootstrappingService returns a bootstrapping service
func NewBootstrappingService(concertoService utils.ConcertoService) (*BootstrappingService, error) {
if concertoService == nil {
return nil, fmt.Errorf("must initialize ConcertoService before using it")
}

return &BootstrappingService{
concertoService: concertoService,
}, nil

}

// GetBootstrappingConfiguration returns the list of policy files as a JSON response with the desired configuration changes
func (bs *BootstrappingService) GetBootstrappingConfiguration() (bootstrappingConfigurations *types.BootstrappingConfiguration, status int, err error) {
log.Debug("GetBootstrappingConfiguration")

data, status, err := bs.concertoService.Get("/blueprint/configuration")
if err != nil {
return nil, status, err
}

if err = utils.CheckStandardStatus(status, data); err != nil {
return nil, status, err
}

if err = json.Unmarshal(data, &bootstrappingConfigurations); err != nil {
return nil, status, err
}

return bootstrappingConfigurations, status, nil
}

// ReportBootstrappingAppliedConfiguration
func (bs *BootstrappingService) ReportBootstrappingAppliedConfiguration(BootstrappingAppliedConfigurationVector *map[string]interface{}) (err error) {
log.Debug("ReportBootstrappingAppliedConfiguration")

data, status, err := bs.concertoService.Put("/blueprint/applied_configuration", BootstrappingAppliedConfigurationVector)
if err != nil {
return err
}

if err = utils.CheckStandardStatus(status, data); err != nil {
return err
}

return nil
}

// ReportBootstrappingLog reports a policy files application result
func (bs *BootstrappingService) ReportBootstrappingLog(BootstrappingContinuousReportVector *map[string]interface{}) (command *types.BootstrappingContinuousReport, status int, err error) {
log.Debug("ReportBootstrappingLog")

data, status, err := bs.concertoService.Post("/blueprint/bootstrap_logs", BootstrappingContinuousReportVector)
if err != nil {
return nil, status, err
}

if err = json.Unmarshal(data, &command); err != nil {
return nil, status, err
}

return command, status, nil
}


// DownloadPolicyfile gets a file from given url saving file into given file path
func (bs *BootstrappingService) DownloadPolicyfile(url string, filePath string) (realFileName string, status int, err error) {
log.Debug("DownloadPolicyfile")

realFileName, status, err = bs.concertoService.GetFile(url, filePath)
if err != nil {
return realFileName, status, err
}

return realFileName, status, nil
}
Loading

0 comments on commit 3e47ef2

Please sign in to comment.