Skip to content

Commit

Permalink
Rename newLxdContainer to containerLXDLoad and move its args.
Browse files Browse the repository at this point in the history
Signed-off-by: René Jochum <rene@jochums.at>
  • Loading branch information
jochumdev committed Jul 31, 2015
1 parent 189b7ca commit 1d557f0
Show file tree
Hide file tree
Showing 17 changed files with 33 additions and 32 deletions.
2 changes: 1 addition & 1 deletion lxd/container.go
Expand Up @@ -233,7 +233,7 @@ func createcontainerLXD(
return c, nil
}

func newLxdContainer(name string, d *Daemon) (container, error) {
func containerLXDLoad(d *Daemon, name string) (container, error) {
shared.Log.Debug("Container load", log.Ctx{"container": name})

args, err := dbContainerGet(d.db, name)
Expand Down
2 changes: 1 addition & 1 deletion lxd/container_delete.go
Expand Up @@ -9,7 +9,7 @@ import (

func containerDelete(d *Daemon, r *http.Request) Response {
name := mux.Vars(r)["name"]
c, err := newLxdContainer(name, d)
c, err := containerLXDLoad(d, name)
if err != nil {
return SmartError(err)
}
Expand Down
2 changes: 1 addition & 1 deletion lxd/container_exec.go
Expand Up @@ -210,7 +210,7 @@ func (s *execWs) Do() shared.OperationResult {

func containerExecPost(d *Daemon, r *http.Request) Response {
name := mux.Vars(r)["name"]
c, err := newLxdContainer(name, d)
c, err := containerLXDLoad(d, name)
if err != nil {
return SmartError(err)
}
Expand Down
2 changes: 1 addition & 1 deletion lxd/container_file.go
Expand Up @@ -18,7 +18,7 @@ import (

func containerFileHandler(d *Daemon, r *http.Request) Response {
name := mux.Vars(r)["name"]
c, err := newLxdContainer(name, d)
c, err := containerLXDLoad(d, name)
if err != nil {
return SmartError(err)
}
Expand Down
2 changes: 1 addition & 1 deletion lxd/container_get.go
Expand Up @@ -11,7 +11,7 @@ import (

func containerGet(d *Daemon, r *http.Request) Response {
name := mux.Vars(r)["name"]
c, err := newLxdContainer(name, d)
c, err := containerLXDLoad(d, name)
if err != nil {
return SmartError(err)
}
Expand Down
2 changes: 1 addition & 1 deletion lxd/container_post.go
Expand Up @@ -12,7 +12,7 @@ import (

func containerPost(d *Daemon, r *http.Request) Response {
name := mux.Vars(r)["name"]
c, err := newLxdContainer(name, d)
c, err := containerLXDLoad(d, name)
if err != nil {
return SmartError(err)
}
Expand Down
6 changes: 3 additions & 3 deletions lxd/container_put.go
Expand Up @@ -16,7 +16,7 @@ import (
*/
func containerPut(d *Daemon, r *http.Request) Response {
name := mux.Vars(r)["name"]
c, err := newLxdContainer(name, d)
c, err := containerLXDLoad(d, name)
if err != nil {
return NotFound
}
Expand Down Expand Up @@ -64,7 +64,7 @@ func containerSnapRestore(d *Daemon, name string, snap string) error {
"snapshot": snap,
"container": name})

c, err := newLxdContainer(name, d)
c, err := containerLXDLoad(d, name)
if err != nil {
shared.Log.Error(
"RESTORE => loadcontainerLXD() failed",
Expand All @@ -75,7 +75,7 @@ func containerSnapRestore(d *Daemon, name string, snap string) error {
return err
}

source, err := newLxdContainer(snap, d)
source, err := containerLXDLoad(d, snap)
if err != nil {
shared.Debugf("RESTORE => Error: newLxdContainer() failed for snapshot", err)
return err
Expand Down
12 changes: 6 additions & 6 deletions lxd/container_snapshot.go
Expand Up @@ -24,7 +24,7 @@ func containerSnapshotsGet(d *Daemon, r *http.Request) Response {

cname := mux.Vars(r)["name"]
// Makes sure the requested container exists.
_, err = newLxdContainer(cname, d)
_, err = containerLXDLoad(d, cname)
if err != nil {
return SmartError(err)
}
Expand All @@ -45,7 +45,7 @@ func containerSnapshotsGet(d *Daemon, r *http.Request) Response {

for _, r := range results {
name = r[0].(string)
sc, err := newLxdContainer(name, d)
sc, err := containerLXDLoad(d, name)
if err != nil {
shared.Log.Error("Failed to load snapshot", log.Ctx{"snapshot": name})
continue
Expand Down Expand Up @@ -113,7 +113,7 @@ func containerSnapshotsPost(d *Daemon, r *http.Request) Response {
* 2. copy the database info over
* 3. copy over the rootfs
*/
c, err := newLxdContainer(name, d)
c, err := containerLXDLoad(d, name)
if err != nil {
return SmartError(err)
}
Expand Down Expand Up @@ -190,11 +190,11 @@ func snapshotHandler(d *Daemon, r *http.Request) Response {
containerName := mux.Vars(r)["name"]
snapshotName := mux.Vars(r)["snapshotName"]

sc, err := newLxdContainer(
sc, err := containerLXDLoad(
d,
containerName+
shared.SnapshotDelimiter+
snapshotName,
d)
snapshotName)
if err != nil {
return SmartError(err)
}
Expand Down
4 changes: 2 additions & 2 deletions lxd/container_state.go
Expand Up @@ -12,7 +12,7 @@ import (

func containerStateGet(d *Daemon, r *http.Request) Response {
name := mux.Vars(r)["name"]
c, err := newLxdContainer(name, d)
c, err := containerLXDLoad(d, name)
if err != nil {
return SmartError(err)
}
Expand All @@ -38,7 +38,7 @@ func containerStatePut(d *Daemon, r *http.Request) Response {
return BadRequest(err)
}

c, err := newLxdContainer(name, d)
c, err := containerLXDLoad(d, name)
if err != nil {
return SmartError(err)
}
Expand Down
6 changes: 3 additions & 3 deletions lxd/containers.go
Expand Up @@ -163,7 +163,7 @@ func containersWatch(d *Daemon) error {
}

for _, r := range result {
container, err := newLxdContainer(string(r[0].(string)), d)
container, err := containerLXDLoad(d, string(r[0].(string)))
if err != nil {
return err
}
Expand Down Expand Up @@ -199,7 +199,7 @@ func containersRestart(d *Daemon) error {
}

for _, r := range result {
container, err := newLxdContainer(string(r[0].(string)), d)
container, err := containerLXDLoad(d, string(r[0].(string)))
if err != nil {
return err
}
Expand All @@ -219,7 +219,7 @@ func containersShutdown(d *Daemon) error {
var wg sync.WaitGroup

for _, r := range results {
container, err := newLxdContainer(r, d)
container, err := containerLXDLoad(d, r)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion lxd/containers_get.go
Expand Up @@ -58,7 +58,7 @@ func doContainersGet(d *Daemon, recursion bool) (interface{}, error) {
}

func doContainerGet(d *Daemon, cname string) (shared.ContainerInfo, Response) {
c, err := newLxdContainer(cname, d)
c, err := containerLXDLoad(d, cname)
if err != nil {
return shared.ContainerInfo{}, SmartError(err)
}
Expand Down
10 changes: 5 additions & 5 deletions lxd/containers_post.go
Expand Up @@ -159,7 +159,7 @@ func createFromImage(d *Daemon, req *containerPostReq) Response {
return SmartError(err)
}

c, err := newLxdContainer(name, d)
c, err := containerLXDLoad(d, name)
if err != nil {
c.Delete()
return SmartError(err)
Expand Down Expand Up @@ -193,7 +193,7 @@ func createFromNone(d *Daemon, req *containerPostReq) Response {
}

run := shared.OperationWrap(func() error {
c, err := newLxdContainer(req.Name, d)
c, err := containerLXDLoad(d, req.Name)
if err != nil {
return err
}
Expand Down Expand Up @@ -230,7 +230,7 @@ func createFromMigration(d *Daemon, req *containerPostReq) Response {
return SmartError(err)
}

c, err := newLxdContainer(req.Name, d)
c, err := containerLXDLoad(d, req.Name)
if err != nil {
c.Delete()
return SmartError(err)
Expand Down Expand Up @@ -288,7 +288,7 @@ func createFromMigration(d *Daemon, req *containerPostReq) Response {
return shared.OperationError(err)
}

c, err := newLxdContainer(req.Name, d)
c, err := containerLXDLoad(d, req.Name)
if err != nil {
return shared.OperationError(err)
}
Expand All @@ -313,7 +313,7 @@ func createFromCopy(d *Daemon, req *containerPostReq) Response {
}

// Make sure the source exists.
source, err := newLxdContainer(req.Source.Source, d)
source, err := containerLXDLoad(d, req.Source.Source)
if err != nil {
return SmartError(err)
}
Expand Down
2 changes: 1 addition & 1 deletion lxd/daemon.go
Expand Up @@ -588,7 +588,7 @@ func (d *Daemon) numRunningContainers() (int, error) {

count := 0
for _, r := range results {
container, err := newLxdContainer(r, d)
container, err := containerLXDLoad(d, r)
if err != nil {
continue
}
Expand Down
4 changes: 2 additions & 2 deletions lxd/devlxd.go
Expand Up @@ -314,7 +314,7 @@ func findContainerForPid(pid int32, d *Daemon) (container, error) {
parts := strings.Split(string(cmdline), " ")
name := parts[len(parts)-1]

return newLxdContainer(name, d)
return containerLXDLoad(d, name)
}

status, err := ioutil.ReadFile(fmt.Sprintf("/proc/%d/status", pid))
Expand Down Expand Up @@ -348,7 +348,7 @@ func findContainerForPid(pid int32, d *Daemon) (container, error) {
}

for _, container := range containers {
c, err := newLxdContainer(container, d)
c, err := containerLXDLoad(d, container)
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion lxd/images.go
Expand Up @@ -168,7 +168,7 @@ func imgPostContInfo(d *Daemon, r *http.Request, req imagePostReq,
snap = fields[1]
}

c, err := newLxdContainer(name, d)
c, err := containerLXDLoad(d, name)
if err != nil {
return info, err
}
Expand Down
2 changes: 1 addition & 1 deletion lxd/networks.go
Expand Up @@ -117,7 +117,7 @@ func doNetworkGet(d *Daemon, name string) (network, error) {
} else if isBridge(iface) {
n.Type = "bridge"
for _, ct := range lxc.ActiveContainerNames(d.lxcpath) {
c, err := newLxdContainer(ct, d)
c, err := containerLXDLoad(d, ct)
if err != nil {
return network{}, err
}
Expand Down
3 changes: 2 additions & 1 deletion lxd/profiles.go
Expand Up @@ -89,8 +89,9 @@ func getRunningContainersWithProfile(d *Daemon, profile string) []container {
if err != nil {
return results
}

for _, name := range output {
c, err := newLxdContainer(name, d)
c, err := containerLXDLoad(d, name)
if err != nil {
shared.Log.Error("failed opening container", log.Ctx{"container": name})
continue
Expand Down

0 comments on commit 1d557f0

Please sign in to comment.