Compare commits

..

1 Commits

Author SHA1 Message Date
Nathan LeClaire
b409bd492c Merge pull request #3573 from aculich/patch-1
remove LTS from Ubuntu 15.10 in aws driver docs
(cherry picked from commit eeb35dd5e4)

Signed-off-by: Sven Dowideit <SvenDowideit@home.org.au>
2016-07-22 13:32:58 +10:00
15 changed files with 34 additions and 125 deletions

View File

@@ -132,7 +132,6 @@ __get_create_argument() {
'--swarm-discovery=[Discovery service to use with Swarm]:service:->swarm-service' \
'--swarm-strategy=[Define a default scheduling strategy for Swarm]:strategy:(spread binpack random)' \
'*--swarm-opt=[Define arbitrary flags for swarm]:flag' \
'*--swarm-join-opt=[Define arbitrary flags for Swarm join]:flag' \
'--swarm-host=[ip/socket to listen on for Swarm master]:host' \
'--swarm-addr=[addr to advertise for Swarm (default: detect and use the machine IP)]:address' \
'--swarm-experimental[Enable Swarm experimental features]' \

View File

@@ -105,7 +105,7 @@ Environment variables and default values:
## Default AMIs
By default, the Amazon EC2 driver will use a daily image of Ubuntu 15.10 LTS.
By default, the Amazon EC2 driver will use a daily image of Ubuntu 15.10.
| Region | AMI ID |
| -------------- | ------------ |

View File

@@ -66,19 +66,7 @@ func BootstrapCertificates(authOptions *auth.Options) error {
return errors.New("The client key already exists. Please remove it or specify a different key/cert.")
}
// Used to generate the client certificate.
certOptions := &Options{
Hosts: []string{""},
CertFile: clientCertPath,
KeyFile: clientKeyPath,
CAFile: caCertPath,
CAKeyFile: caPrivateKeyPath,
Org: org,
Bits: bits,
SwarmMaster: false,
}
if err := GenerateCert(certOptions); err != nil {
if err := GenerateCert([]string{""}, clientCertPath, clientKeyPath, caCertPath, caPrivateKeyPath, org, bits); err != nil {
return fmt.Errorf("Generating client certificate failed: %s", err)
}
}

View File

@@ -21,16 +21,9 @@ import (
var defaultGenerator = NewX509CertGenerator()
type Options struct {
Hosts []string
CertFile, KeyFile, CAFile, CAKeyFile, Org string
Bits int
SwarmMaster bool
}
type Generator interface {
GenerateCACertificate(certFile, keyFile, org string, bits int) error
GenerateCert(opts *Options) error
GenerateCert(hosts []string, certFile, keyFile, caFile, caKeyFile, org string, bits int) error
ReadTLSConfig(addr string, authOptions *auth.Options) (*tls.Config, error)
ValidateCertificate(addr string, authOptions *auth.Options) (bool, error)
}
@@ -45,8 +38,8 @@ func GenerateCACertificate(certFile, keyFile, org string, bits int) error {
return defaultGenerator.GenerateCACertificate(certFile, keyFile, org, bits)
}
func GenerateCert(opts *Options) error {
return defaultGenerator.GenerateCert(opts)
func GenerateCert(hosts []string, certFile, keyFile, caFile, caKeyFile, org string, bits int) error {
return defaultGenerator.GenerateCert(hosts, certFile, keyFile, caFile, caKeyFile, org, bits)
}
func ValidateCertificate(addr string, authOptions *auth.Options) (bool, error) {
@@ -157,24 +150,18 @@ func (xcg *X509CertGenerator) GenerateCACertificate(certFile, keyFile, org strin
// certificate authority files and stores the result in the certificate
// file and key provided. The provided host names are set to the
// appropriate certificate fields.
func (xcg *X509CertGenerator) GenerateCert(opts *Options) error {
template, err := xcg.newCertificate(opts.Org)
func (xcg *X509CertGenerator) GenerateCert(hosts []string, certFile, keyFile, caFile, caKeyFile, org string, bits int) error {
template, err := xcg.newCertificate(org)
if err != nil {
return err
}
// client
if len(opts.Hosts) == 1 && opts.Hosts[0] == "" {
if len(hosts) == 1 && hosts[0] == "" {
template.ExtKeyUsage = []x509.ExtKeyUsage{x509.ExtKeyUsageClientAuth}
template.KeyUsage = x509.KeyUsageDigitalSignature
} else { // server
template.ExtKeyUsage = []x509.ExtKeyUsage{x509.ExtKeyUsageServerAuth}
if opts.SwarmMaster {
// Extend the Swarm master's server certificate
// permissions to also be able to connect to downstream
// nodes as a client.
template.ExtKeyUsage = append(template.ExtKeyUsage, x509.ExtKeyUsageClientAuth)
}
for _, h := range opts.Hosts {
template.ExtKeyUsage = []x509.ExtKeyUsage{x509.ExtKeyUsageClientAuth, x509.ExtKeyUsageServerAuth}
for _, h := range hosts {
if ip := net.ParseIP(h); ip != nil {
template.IPAddresses = append(template.IPAddresses, ip)
} else {
@@ -183,12 +170,12 @@ func (xcg *X509CertGenerator) GenerateCert(opts *Options) error {
}
}
tlsCert, err := tls.LoadX509KeyPair(opts.CAFile, opts.CAKeyFile)
tlsCert, err := tls.LoadX509KeyPair(caFile, caKeyFile)
if err != nil {
return err
}
priv, err := rsa.GenerateKey(rand.Reader, opts.Bits)
priv, err := rsa.GenerateKey(rand.Reader, bits)
if err != nil {
return err
}
@@ -203,7 +190,7 @@ func (xcg *X509CertGenerator) GenerateCert(opts *Options) error {
return err
}
certOut, err := os.Create(opts.CertFile)
certOut, err := os.Create(certFile)
if err != nil {
return err
}
@@ -211,7 +198,7 @@ func (xcg *X509CertGenerator) GenerateCert(opts *Options) error {
pem.Encode(certOut, &pem.Block{Type: "CERTIFICATE", Bytes: derBytes})
certOut.Close()
keyOut, err := os.OpenFile(opts.KeyFile, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0600)
keyOut, err := os.OpenFile(keyFile, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0600)
if err != nil {
return err
}
@@ -225,8 +212,8 @@ func (xcg *X509CertGenerator) GenerateCert(opts *Options) error {
// ReadTLSConfig reads the tls config for a machine.
func (xcg *X509CertGenerator) ReadTLSConfig(addr string, authOptions *auth.Options) (*tls.Config, error) {
caCertPath := authOptions.CaCertPath
clientCertPath := authOptions.ClientCertPath
clientKeyPath := authOptions.ClientKeyPath
serverCertPath := authOptions.ServerCertPath
serverKeyPath := authOptions.ServerKeyPath
log.Debugf("Reading CA certificate from %s", caCertPath)
caCert, err := ioutil.ReadFile(caCertPath)
@@ -234,19 +221,19 @@ func (xcg *X509CertGenerator) ReadTLSConfig(addr string, authOptions *auth.Optio
return nil, err
}
log.Debugf("Reading client certificate from %s", clientCertPath)
clientCert, err := ioutil.ReadFile(clientCertPath)
log.Debugf("Reading server certificate from %s", serverCertPath)
serverCert, err := ioutil.ReadFile(serverCertPath)
if err != nil {
return nil, err
}
log.Debugf("Reading client key from %s", clientKeyPath)
clientKey, err := ioutil.ReadFile(clientKeyPath)
log.Debugf("Reading server key from %s", serverKeyPath)
serverKey, err := ioutil.ReadFile(serverKeyPath)
if err != nil {
return nil, err
}
return xcg.getTLSConfig(caCert, clientCert, clientKey, false)
return xcg.getTLSConfig(caCert, serverCert, serverKey, false)
}
// ValidateCertificate validate the certificate installed on the vm.

View File

@@ -56,18 +56,7 @@ func TestGenerateCert(t *testing.T) {
t.Fatal(err)
}
opts := &Options{
Hosts: []string{},
CertFile: certPath,
CAKeyFile: caKeyPath,
CAFile: caCertPath,
KeyFile: keyPath,
Org: testOrg,
Bits: bits,
SwarmMaster: false,
}
if err := GenerateCert(opts); err != nil {
if err := GenerateCert([]string{}, certPath, keyPath, caCertPath, caKeyPath, testOrg, bits); err != nil {
t.Fatal(err)
}

View File

@@ -24,7 +24,7 @@ func (fcg FakeCertGenerator) GenerateCACertificate(certFile, keyFile, org string
return nil
}
func (fcg FakeCertGenerator) GenerateCert(opts *cert.Options) error {
func (fcg FakeCertGenerator) GenerateCert(hosts []string, certFile, keyFile, caFile, caKeyFile, org string, bits int) error {
return nil
}

View File

@@ -112,9 +112,6 @@ func (r *BugsnagCrashReporter) noReportFileExist() bool {
}
func addFile(path string, metaData *bugsnag.MetaData) {
if path == "" {
return
}
file, err := os.Open(path)
if err != nil {
log.Debug(err)

View File

@@ -128,10 +128,6 @@ func (provisioner *Boot2DockerProvisioner) GetAuthOptions() auth.Options {
return provisioner.AuthOptions
}
func (provisioner *Boot2DockerProvisioner) GetSwarmOptions() swarm.Options {
return provisioner.SwarmOptions
}
func (provisioner *Boot2DockerProvisioner) GenerateDockerOptions(dockerPort int) (*DockerOptions, error) {
var (
engineCfg bytes.Buffer

View File

@@ -43,10 +43,6 @@ func (fp *FakeProvisioner) GetAuthOptions() auth.Options {
return auth.Options{}
}
func (fp *FakeProvisioner) GetSwarmOptions() swarm.Options {
return swarm.Options{}
}
func (fp *FakeProvisioner) Package(name string, action pkgaction.PackageAction) error {
return nil
}

View File

@@ -76,10 +76,6 @@ func (provisioner *GenericProvisioner) GetAuthOptions() auth.Options {
return provisioner.AuthOptions
}
func (provisioner *GenericProvisioner) GetSwarmOptions() swarm.Options {
return provisioner.SwarmOptions
}
func (provisioner *GenericProvisioner) SetOsReleaseInfo(info *OsRelease) {
provisioner.OsReleaseInfo = info
}

View File

@@ -20,8 +20,6 @@ type OsRelease struct {
AnsiColor string `osr:"ANSI_COLOR"`
Name string `osr:"NAME"`
Version string `osr:"VERSION"`
Variant string `osr:"VARIANT"`
VariantID string `osr:"VARIANT_ID"`
ID string `osr:"ID"`
IDLike string `osr:"ID_LIKE"`
PrettyName string `osr:"PRETTY_NAME"`

View File

@@ -46,17 +46,7 @@ PRETTY_NAME="CentOS Linux 7 (Core)"
ANSI_COLOR="0;31"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"
`)
fedora = []byte(`NAME=Fedora
VERSION="23 (Twenty Three)"
ID=fedora
VERSION_ID=23
VARIANT="Server Edition"
VARIANT_ID=server
PRETTY_NAME="Fedora 23 (Twenty Three)"
ANSI_COLOR="0;34"
HOME_URL="https://fedoraproject.org/"
BUG_REPORT_URL="https://bugzilla.redhat.com/"
`)
)
@@ -146,28 +136,6 @@ BUG_REPORT_URL="https://bugzilla.redhat.com/"
if !reflect.DeepEqual(*osr, expectedOsr) {
t.Fatal("Error with centos osr parsing: structs do not match")
}
osr, err = NewOsRelease(fedora)
if err != nil {
t.Fatalf("Unexpected error parsing os release: %s", err)
}
expectedOsr = OsRelease{
Name: "Fedora",
Version: "23 (Twenty Three)",
ID: "fedora",
PrettyName: "Fedora 23 (Twenty Three)",
Variant: "Server Edition",
VariantID: "server",
AnsiColor: "0;34",
VersionID: "23",
HomeURL: "https://fedoraproject.org/",
BugReportURL: "https://bugzilla.redhat.com/",
}
if !reflect.DeepEqual(*osr, expectedOsr) {
t.Fatal("Error with fedora osr parsing: structs do not match")
}
}
func TestParseLine(t *testing.T) {

View File

@@ -46,9 +46,6 @@ type Provisioner interface {
// Return the auth options used to configure remote connection for the daemon.
GetAuthOptions() auth.Options
// Get the swarm options associated with this host.
GetSwarmOptions() swarm.Options
// Run a package action e.g. install
Package(name string, action pkgaction.PackageAction) error

View File

@@ -64,7 +64,6 @@ func ConfigureAuth(p Provisioner) error {
driver := p.GetDriver()
machineName := driver.GetMachineName()
authOptions := p.GetAuthOptions()
swarmOptions := p.GetSwarmOptions()
org := mcnutils.GetUsername() + "." + machineName
bits := 2048
@@ -99,16 +98,15 @@ func ConfigureAuth(p Provisioner) error {
// TODO: Switch to passing just authOptions to this func
// instead of all these individual fields
err = cert.GenerateCert(&cert.Options{
Hosts: hosts,
CertFile: authOptions.ServerCertPath,
KeyFile: authOptions.ServerKeyPath,
CAFile: authOptions.CaCertPath,
CAKeyFile: authOptions.CaPrivateKeyPath,
Org: org,
Bits: bits,
SwarmMaster: swarmOptions.Master,
})
err = cert.GenerateCert(
hosts,
authOptions.ServerCertPath,
authOptions.ServerKeyPath,
authOptions.CaCertPath,
authOptions.CaPrivateKeyPath,
org,
bits,
)
if err != nil {
return fmt.Errorf("error generating server cert: %s", err)

View File

@@ -7,7 +7,7 @@ import (
var (
// Version should be updated by hand at each release
Version = "0.8.0-rc2"
Version = "0.7.0"
// GitCommit will be overwritten automatically by the build system
GitCommit = "HEAD"