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

Delta Between Two Patch Sets: state/unit.go

Issue 12235043: juju status: add service/unit filters (Closed)
Left Patch Set: juju status: add service/unit filters Created 10 years, 7 months ago
Right Patch Set: juju status: add service/unit filters Created 10 years, 7 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
LEFTRIGHT
(no file at all)
1 // Copyright 2012, 2013 Canonical Ltd. 1 // Copyright 2012, 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 state 4 package state
5 5
6 import ( 6 import (
7 stderrors "errors" 7 stderrors "errors"
8 "fmt" 8 "fmt"
9 "sort" 9 "sort"
10 "time" 10 "time"
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 PasswordHash string 86 PasswordHash string
87 } 87 }
88 88
89 // Unit represents the state of a service unit. 89 // Unit represents the state of a service unit.
90 type Unit struct { 90 type Unit struct {
91 st *State 91 st *State
92 doc unitDoc 92 doc unitDoc
93 annotator 93 annotator
94 } 94 }
95 95
96 var _ AgentEntity = (*Unit)(nil) 96 var _ AgentEntity = (*Unit)(nil)
rog 2013/08/08 07:52:43 This has moved into interface.go now.
97 97
98 func newUnit(st *State, udoc *unitDoc) *Unit { 98 func newUnit(st *State, udoc *unitDoc) *Unit {
99 unit := &Unit{ 99 unit := &Unit{
100 st: st, 100 st: st,
101 doc: *udoc, 101 doc: *udoc,
102 } 102 }
103 unit.annotator = annotator{ 103 unit.annotator = annotator{
104 globalKey: unit.globalKey(), 104 globalKey: unit.globalKey(),
105 tag: unit.Tag(), 105 tag: unit.Tag(),
106 st: st, 106 st: st,
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 // the unit. If no such entity can be determined, false is returned. 437 // the unit. If no such entity can be determined, false is returned.
438 func (u *Unit) DeployerTag() (string, bool) { 438 func (u *Unit) DeployerTag() (string, bool) {
439 if u.doc.Principal != "" { 439 if u.doc.Principal != "" {
440 return names.UnitTag(u.doc.Principal), true 440 return names.UnitTag(u.doc.Principal), true
441 } else if u.doc.MachineId != "" { 441 } else if u.doc.MachineId != "" {
442 return names.MachineTag(u.doc.MachineId), true 442 return names.MachineTag(u.doc.MachineId), true
443 } 443 }
444 return "", false 444 return "", false
445 } 445 }
446 446
447 // PrincipalName returns the name of the unit's principal.
448 // If the unit is not a subordinate, false is returned.
449 func (u *Unit) PrincipalName() (string, bool) {
450 return u.doc.Principal, u.doc.Principal != ""
451 }
452
447 // PublicAddress returns the public address of the unit and whether it is valid. 453 // PublicAddress returns the public address of the unit and whether it is valid.
448 func (u *Unit) PublicAddress() (string, bool) { 454 func (u *Unit) PublicAddress() (string, bool) {
449 return u.doc.PublicAddress, u.doc.PublicAddress != "" 455 return u.doc.PublicAddress, u.doc.PublicAddress != ""
450 } 456 }
451 457
452 // PrivateAddress returns the private address of the unit and whether it is vali d. 458 // PrivateAddress returns the private address of the unit and whether it is vali d.
453 func (u *Unit) PrivateAddress() (string, bool) { 459 func (u *Unit) PrivateAddress() (string, bool) {
454 return u.doc.PrivateAddress, u.doc.PrivateAddress != "" 460 return u.doc.PrivateAddress, u.doc.PrivateAddress != ""
455 } 461 }
456 462
(...skipping 813 matching lines...) Expand 10 before | Expand all | Expand 10 after
1270 return p1.Protocol < p2.Protocol 1276 return p1.Protocol < p2.Protocol
1271 } 1277 }
1272 return p1.Number < p2.Number 1278 return p1.Number < p2.Number
1273 } 1279 }
1274 1280
1275 // SortPorts sorts the given ports, first by protocol, 1281 // SortPorts sorts the given ports, first by protocol,
1276 // then by number. 1282 // then by number.
1277 func SortPorts(ports []instance.Port) { 1283 func SortPorts(ports []instance.Port) {
1278 sort.Sort(portSlice(ports)) 1284 sort.Sort(portSlice(ports))
1279 } 1285 }
LEFTRIGHT

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