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

Feature/90 Bootstrap command to drive chef-zero-based configuration #91

Merged
merged 20 commits into from
Mar 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
715e84c
Initial commit (issue #90)
Feb 19, 2019
be2f4f2
Renamed structs (issue #90)
Mar 4, 2019
d87d56e
Refactorized mechanism to download file (issue #90)
Mar 4, 2019
87af58e
Changed strategy for cleaning (issue #90)
Mar 4, 2019
d25d8e6
General review and refactoring task (issue #90)
Mar 5, 2019
9201451
Updated routine approach (issue #90)
Mar 5, 2019
54a1d11
Some refactor of agent bootstrapping command including error processi…
pbanos Mar 6, 2019
1bf8859
Ensure a single instance of the bootstrapping command works at a time…
pbanos Mar 6, 2019
5365e95
Fix bootstrapping issues (issue #90)
pbanos Mar 6, 2019
b5ced19
Make bootstrapping report applied policyfiles when some fail (issue #90)
pbanos Mar 6, 2019
b8f8aaa
Refactored single instance management (issue #90)
Mar 6, 2019
b51bed7
Make more readable the processing error messages (issue #90)
Mar 6, 2019
8a22cbe
Added context management (issue #90)
pcantera Mar 7, 2019
5607bf0
Refactor bootstrapping workspace dir management (issue #90)
pbanos Mar 7, 2019
4556ce1
Added test cases (issue #90)
pcantera Mar 7, 2019
1955329
Remove scripts boot execution in bootstrapping and move config files …
pbanos Mar 8, 2019
0ec978e
Completed test cases (issue #90)
pcantera Mar 11, 2019
4be9ada
Updated bootstrapping process to works in windows platform (Issue #90)
Mar 14, 2019
041df51
Removed unused variable (issue #90)
pcantera Mar 18, 2019
2ad5989
Have bootstrapping server command rename policyfile dir for chef runs…
pbanos Mar 19, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ Extract the contents with your zip compressor of choice and continue using the s

### Configuration

IMCO CLI configuration will usually be located in your personal folder under `.concerto`. If you are using root, CLI will look for contiguration files under `/etc/imco`.
IMCO CLI configuration will usually be located in your personal folder under `.concerto`. If you are using root, CLI will look for contiguration files under `/etc/cio`.
We will assume that you are not root, so create the folder and drop the certificates to this location:

```bash
Expand Down Expand Up @@ -184,7 +184,7 @@ If you got an error executing IMCO CLI:
- check that your internet connection can reach `clients.{IMCO_DOMAIN}`
- make sure that your firewall lets you access to <https://clients.{IMCO_DOMAIN}:886>
- check that `client.xml` is pointing to the correct certificates location
- if `concerto` executes but only shows server commands, you are probably trying to use `concerto` from a commissioned server, and the configuration is being read from `/etc/imco`. If that's the case, you should leave `concerto` configuration untouched so that server commands are available for our remote management.
- if `concerto` executes but only shows server commands, you are probably trying to use `concerto` from a commissioned server, and the configuration is being read from `/etc/cio`. If that's the case, you should leave `concerto` configuration untouched so that server commands are available for our remote management.

## Usage

Expand Down
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