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

Delta Between Two Patch Sets: state/machine.go

Issue 6299073: state: automatically assign machines to subsidiary units from their principal units.
Left Patch Set: state: automatically assign machines to subsidiary units from their principal units. Created 12 years, 9 months ago
Right Patch Set: state: automatically assign machines to subsidiary units from their principal units. Created 12 years, 9 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:
Right: Side by side diff | Download
« no previous file with change/comment | « [revision details] ('k') | state/service.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
(no file at all)
1 // launchpad.net/juju/state 1 // launchpad.net/juju/state
2 // 2 //
3 // Copyright (c) 2011-2012 Canonical Ltd. 3 // Copyright (c) 2011-2012 Canonical Ltd.
4 4
5 package state 5 package state
6 6
7 import ( 7 import (
8 "fmt" 8 "fmt"
9 "launchpad.net/juju-core/juju/state/presence" 9 "launchpad.net/juju-core/juju/state/presence"
10 "path" 10 "path"
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 func (m *Machine) Units() ([]*Unit, error) { 69 func (m *Machine) Units() ([]*Unit, error) {
70 topology, err := readTopology(m.st.zk) 70 topology, err := readTopology(m.st.zk)
71 if err != nil { 71 if err != nil {
72 return nil, err 72 return nil, err
73 } 73 }
74 keys := topology.UnitsForMachine(m.key) 74 keys := topology.UnitsForMachine(m.key)
75 units := make([]*Unit, len(keys)) 75 units := make([]*Unit, len(keys))
76 for i, key := range keys { 76 for i, key := range keys {
77 units[i], err = m.st.unitFromKey(topology, key) 77 units[i], err = m.st.unitFromKey(topology, key)
78 if err != nil { 78 if err != nil {
79 » » » // If UnitsForMachine is returning keys that don't 79 » » » return nil, fmt.Errorf("inconsistent topology: %v", err)
80 » » » // exist, then something is badly wrong.
81 » » » panic(err)
82 } 80 }
83 } 81 }
84 return units, nil 82 return units, nil
85 } 83 }
86 84
87 // SetInstanceId sets the provider specific machine id for this machine. 85 // SetInstanceId sets the provider specific machine id for this machine.
88 func (m *Machine) SetInstanceId(id string) error { 86 func (m *Machine) SetInstanceId(id string) error {
89 config, err := readConfigNode(m.st.zk, m.zkPath()) 87 config, err := readConfigNode(m.st.zk, m.zkPath())
90 if err != nil { 88 if err != nil {
91 return err 89 return err
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 if i < 0 || err != nil { 123 if i < 0 || err != nil {
126 panic("keySeq: invalid key: " + key) 124 panic("keySeq: invalid key: " + key)
127 } 125 }
128 return int(id64) 126 return int(id64)
129 } 127 }
130 128
131 // machineKey returns the machine key corresponding to machineId. 129 // machineKey returns the machine key corresponding to machineId.
132 func machineKey(machineId int) string { 130 func machineKey(machineId int) string {
133 return fmt.Sprintf("machine-%010d", machineId) 131 return fmt.Sprintf("machine-%010d", machineId)
134 } 132 }
LEFTRIGHT

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