Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(1051)

Side by Side Diff: environs/cloudinit.go

Issue 92610045: New utils/proxy package.
Patch Set: New utils/proxy package. Created 10 years, 10 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « container/lxc/lxc_test.go ('k') | environs/cloudinit/cloudinit.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 Canonical Ltd. 1 // Copyright 2013 Canonical Ltd.
2 // Licensed under the AGPLv3, see LICENCE file for details. 2 // Licensed under the AGPLv3, see LICENCE file for details.
3 3
4 package environs 4 package environs
5 5
6 import ( 6 import (
7 "fmt" 7 "fmt"
8 8
9 "github.com/juju/errors" 9 "github.com/juju/errors"
10 10
11 "launchpad.net/juju-core/agent" 11 "launchpad.net/juju-core/agent"
12 coreCloudinit "launchpad.net/juju-core/cloudinit" 12 coreCloudinit "launchpad.net/juju-core/cloudinit"
13 "launchpad.net/juju-core/constraints" 13 "launchpad.net/juju-core/constraints"
14 "launchpad.net/juju-core/environs/cloudinit" 14 "launchpad.net/juju-core/environs/cloudinit"
15 "launchpad.net/juju-core/environs/config" 15 "launchpad.net/juju-core/environs/config"
16 "launchpad.net/juju-core/juju/osenv"
17 "launchpad.net/juju-core/names" 16 "launchpad.net/juju-core/names"
18 "launchpad.net/juju-core/state" 17 "launchpad.net/juju-core/state"
19 "launchpad.net/juju-core/state/api" 18 "launchpad.net/juju-core/state/api"
20 "launchpad.net/juju-core/state/api/params" 19 "launchpad.net/juju-core/state/api/params"
21 "launchpad.net/juju-core/utils" 20 "launchpad.net/juju-core/utils"
21 "launchpad.net/juju-core/utils/proxy"
22 ) 22 )
23 23
24 // DataDir is the default data directory. 24 // DataDir is the default data directory.
25 // Tests can override this where needed, so they don't need to mess with global 25 // Tests can override this where needed, so they don't need to mess with global
26 // system state. 26 // system state.
27 var DataDir = agent.DefaultDataDir 27 var DataDir = agent.DefaultDataDir
28 28
29 // CloudInitOutputLog is the default cloud-init-output.log file path. 29 // CloudInitOutputLog is the default cloud-init-output.log file path.
30 const CloudInitOutputLog = "/var/log/cloud-init-output.log" 30 const CloudInitOutputLog = "/var/log/cloud-init-output.log"
31 31
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 68
69 // PopulateMachineConfig is called both from the FinishMachineConfig below, 69 // PopulateMachineConfig is called both from the FinishMachineConfig below,
70 // which does have access to the environment config, and from the container 70 // which does have access to the environment config, and from the container
71 // provisioners, which don't have access to the environment config. Everything 71 // provisioners, which don't have access to the environment config. Everything
72 // that is needed to provision a container needs to be returned to the 72 // that is needed to provision a container needs to be returned to the
73 // provisioner in the ContainerConfig structure. Those values are then used to 73 // provisioner in the ContainerConfig structure. Those values are then used to
74 // call this function. 74 // call this function.
75 func PopulateMachineConfig(mcfg *cloudinit.MachineConfig, 75 func PopulateMachineConfig(mcfg *cloudinit.MachineConfig,
76 providerType, authorizedKeys string, 76 providerType, authorizedKeys string,
77 sslHostnameVerification bool, 77 sslHostnameVerification bool,
78 » proxy, aptProxy osenv.ProxySettings, 78 » proxySettings, aptProxySettings proxy.Settings,
79 ) error { 79 ) error {
80 if authorizedKeys == "" { 80 if authorizedKeys == "" {
81 return fmt.Errorf("environment configuration has no authorized-k eys") 81 return fmt.Errorf("environment configuration has no authorized-k eys")
82 } 82 }
83 mcfg.AuthorizedKeys = authorizedKeys 83 mcfg.AuthorizedKeys = authorizedKeys
84 if mcfg.AgentEnvironment == nil { 84 if mcfg.AgentEnvironment == nil {
85 mcfg.AgentEnvironment = make(map[string]string) 85 mcfg.AgentEnvironment = make(map[string]string)
86 } 86 }
87 mcfg.AgentEnvironment[agent.ProviderType] = providerType 87 mcfg.AgentEnvironment[agent.ProviderType] = providerType
88 mcfg.AgentEnvironment[agent.ContainerType] = string(mcfg.MachineContaine rType) 88 mcfg.AgentEnvironment[agent.ContainerType] = string(mcfg.MachineContaine rType)
89 mcfg.DisableSSLHostnameVerification = !sslHostnameVerification 89 mcfg.DisableSSLHostnameVerification = !sslHostnameVerification
90 » mcfg.ProxySettings = proxy 90 » mcfg.ProxySettings = proxySettings
91 » mcfg.AptProxySettings = aptProxy 91 » mcfg.AptProxySettings = aptProxySettings
92 return nil 92 return nil
93 } 93 }
94 94
95 // FinishMachineConfig sets fields on a MachineConfig that can be determined by 95 // FinishMachineConfig sets fields on a MachineConfig that can be determined by
96 // inspecting a plain config.Config and the machine constraints at the last 96 // inspecting a plain config.Config and the machine constraints at the last
97 // moment before bootstrapping. It assumes that the supplied Config comes from 97 // moment before bootstrapping. It assumes that the supplied Config comes from
98 // an environment that has passed through all the validation checks in the 98 // an environment that has passed through all the validation checks in the
99 // Bootstrap func, and that has set an agent-version (via finding the tools to, 99 // Bootstrap func, and that has set an agent-version (via finding the tools to,
100 // use for bootstrap, or otherwise). 100 // use for bootstrap, or otherwise).
101 // TODO(fwereade) This function is not meant to be "good" in any serious way: 101 // TODO(fwereade) This function is not meant to be "good" in any serious way:
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 if err := configureCloudinit(mcfg, cloudcfg); err != nil { 180 if err := configureCloudinit(mcfg, cloudcfg); err != nil {
181 return nil, err 181 return nil, err
182 } 182 }
183 data, err := cloudcfg.Render() 183 data, err := cloudcfg.Render()
184 logger.Tracef("Generated cloud init:\n%s", string(data)) 184 logger.Tracef("Generated cloud init:\n%s", string(data))
185 if err != nil { 185 if err != nil {
186 return nil, err 186 return nil, err
187 } 187 }
188 return utils.Gzip(data), nil 188 return utils.Gzip(data), nil
189 } 189 }
OLDNEW
« no previous file with comments | « container/lxc/lxc_test.go ('k') | environs/cloudinit/cloudinit.go » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b