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

Delta Between Two Patch Sets: environs/dummy/environs.go

Issue 8429044: environs: add machineNonce to StartInstance() (Closed)
Left Patch Set: Created 11 years, 12 months ago
Right Patch Set: environs: add machineNonce to StartInstance() Created 11 years, 12 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:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « [revision details] ('k') | environs/ec2/ec2.go » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 // The dummy provider implements an environment provider for testing 1 // The dummy provider implements an environment provider for testing
2 // purposes, registered with environs under the name "dummy". 2 // purposes, registered with environs under the name "dummy".
3 // 3 //
4 // The configuration YAML for the testing environment 4 // The configuration YAML for the testing environment
5 // must specify a "state-server" property with a boolean 5 // must specify a "state-server" property with a boolean
6 // value. If this is true, a state server will be started 6 // value. If this is true, a state server will be started
7 // the first time StateInfo is called on a newly reset environment. 7 // the first time StateInfo is called on a newly reset environment.
8 // 8 //
9 // The configuration data also accepts a "broken" property 9 // The configuration data also accepts a "broken" property
10 // of type boolean. If this is non-empty, any operation 10 // of type boolean. If this is non-empty, any operation
(...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after
557 } 557 }
558 558
559 func (e *environ) StartInstance(machineId, machineNonce string, series string, c ons constraints.Value, info *state.Info, apiInfo *api.Info) (environs.Instance, error) { 559 func (e *environ) StartInstance(machineId, machineNonce string, series string, c ons constraints.Value, info *state.Info, apiInfo *api.Info) (environs.Instance, error) {
560 defer delay() 560 defer delay()
561 log.Infof("environs/dummy: dummy startinstance, machine %s", machineId) 561 log.Infof("environs/dummy: dummy startinstance, machine %s", machineId)
562 if err := e.checkBroken("StartInstance"); err != nil { 562 if err := e.checkBroken("StartInstance"); err != nil {
563 return nil, err 563 return nil, err
564 } 564 }
565 e.state.mu.Lock() 565 e.state.mu.Lock()
566 defer e.state.mu.Unlock() 566 defer e.state.mu.Unlock()
567 if machineNonce == "" {
568 return nil, fmt.Errorf("cannot start instance: missing machine n once")
569 }
567 if _, ok := e.Config().CACert(); !ok { 570 if _, ok := e.Config().CACert(); !ok {
568 return nil, fmt.Errorf("no CA certificate in environment configu ration") 571 return nil, fmt.Errorf("no CA certificate in environment configu ration")
569 } 572 }
570 if info.Tag != state.MachineTag(machineId) { 573 if info.Tag != state.MachineTag(machineId) {
571 return nil, fmt.Errorf("entity tag must match started machine") 574 return nil, fmt.Errorf("entity tag must match started machine")
572 } 575 }
573 if apiInfo.Tag != state.MachineTag(machineId) { 576 if apiInfo.Tag != state.MachineTag(machineId) {
574 return nil, fmt.Errorf("entity tag must match started machine") 577 return nil, fmt.Errorf("entity tag must match started machine")
575 } 578 }
576 if strings.HasPrefix(series, "unknown") { 579 if strings.HasPrefix(series, "unknown") {
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
789 // time.Durations into this value. 792 // time.Durations into this value.
790 var providerDelay time.Duration 793 var providerDelay time.Duration
791 794
792 // pause execution to simulate the latency of a real provider 795 // pause execution to simulate the latency of a real provider
793 func delay() { 796 func delay() {
794 if providerDelay > 0 { 797 if providerDelay > 0 {
795 log.Infof("environs/dummy: pausing for %v", providerDelay) 798 log.Infof("environs/dummy: pausing for %v", providerDelay)
796 <-time.After(providerDelay) 799 <-time.After(providerDelay)
797 } 800 }
798 } 801 }
LEFTRIGHT

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