~james-page/ubuntu/wily/juju-core/mir-fixes

« back to all changes in this revision

Viewing changes to src/launchpad.net/juju-core/state/unit.go

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2014-03-28 08:58:42 UTC
  • mfrom: (1.1.21)
  • Revision ID: package-import@ubuntu.com-20140328085842-cyzrgc120bdfxwj0
Tags: 1.17.7-0ubuntu1
* New upstream point release, including fixes for:
  - no debug log with all providers on Ubuntu 14.04 (LP: #1294776).
* d/control: Add cpu-checker dependency to juju-local (LP: #1297077).

Show diffs side-by-side

added added

removed removed

Lines of Context:
562
562
                StatusInfo: info,
563
563
                StatusData: data,
564
564
        }
565
 
        if err := doc.validateSet(); err != nil {
 
565
        if err := doc.validateSet(false); err != nil {
566
566
                return err
567
567
        }
568
568
        ops := []txn.Op{{
991
991
        return &cons, nil
992
992
}
993
993
 
994
 
// AssignToNewMachineOrContainer assigns the unit to a new machine, with constraints
995
 
// determined according to the service and environment constraints at the time of unit creation.
996
 
// If a container is required, a clean, empty machine instance is required on which to create
997
 
// the container. An existing clean, empty instance is first searched for, and if not found,
998
 
// a new one is created.
 
994
// AssignToNewMachineOrContainer assigns the unit to a new machine,
 
995
// with constraints determined according to the service and
 
996
// environment constraints at the time of unit creation. If a
 
997
// container is required, a clean, empty machine instance is required
 
998
// on which to create the container. An existing clean, empty instance
 
999
// is first searched for, and if not found, a new one is created.
999
1000
func (u *Unit) AssignToNewMachineOrContainer() (err error) {
1000
1001
        defer assignContextf(&err, u, "new machine or container")
1001
1002
        if u.doc.Principal != "" {
1026
1027
        } else if err != nil {
1027
1028
                return err
1028
1029
        }
 
1030
        svc, err := u.Service()
 
1031
        if err != nil {
 
1032
                return err
 
1033
        }
 
1034
        includeNetworks, excludeNetworks, err := svc.Networks()
 
1035
        if err != nil {
 
1036
                return err
 
1037
        }
1029
1038
        template := MachineTemplate{
1030
 
                Series:      u.doc.Series,
1031
 
                Constraints: *cons,
1032
 
                Jobs:        []MachineJob{JobHostUnits},
 
1039
                Series:          u.doc.Series,
 
1040
                Constraints:     *cons,
 
1041
                Jobs:            []MachineJob{JobHostUnits},
 
1042
                IncludeNetworks: includeNetworks,
 
1043
                ExcludeNetworks: excludeNetworks,
1033
1044
        }
1034
1045
        err = u.assignToNewMachine(template, host.Id, *cons.Container)
1035
1046
        if err == machineNotCleanErr {
1059
1070
        if cons.HasContainer() {
1060
1071
                containerType = *cons.Container
1061
1072
        }
 
1073
        svc, err := u.Service()
 
1074
        if err != nil {
 
1075
                return err
 
1076
        }
 
1077
        includeNetworks, excludeNetworks, err := svc.Networks()
 
1078
        if err != nil {
 
1079
                return err
 
1080
        }
1062
1081
        template := MachineTemplate{
1063
 
                Series:      u.doc.Series,
1064
 
                Constraints: *cons,
1065
 
                Jobs:        []MachineJob{JobHostUnits},
 
1082
                Series:          u.doc.Series,
 
1083
                Constraints:     *cons,
 
1084
                Jobs:            []MachineJob{JobHostUnits},
 
1085
                IncludeNetworks: includeNetworks,
 
1086
                ExcludeNetworks: excludeNetworks,
1066
1087
        }
1067
1088
        return u.assignToNewMachine(template, "", containerType)
1068
1089
}