-
-
Notifications
You must be signed in to change notification settings - Fork 168
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #252 from stgraber/migrate
Add support for migrating from LXD COPR
- Loading branch information
Showing
3 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,5 +17,6 @@ type Source interface { | |
var sources = []Source{ | ||
&srcSnap{}, | ||
&srcDeb{}, | ||
&srcCOPR{}, | ||
&srcManual{}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package main | ||
|
||
import ( | ||
"github.com/canonical/lxd/client" | ||
|
||
"github.com/lxc/incus/shared/subprocess" | ||
"github.com/lxc/incus/shared/util" | ||
) | ||
|
||
type srcCOPR struct{} | ||
|
||
func (s *srcCOPR) Present() bool { | ||
// Validate that the RPM package is installed. | ||
_, err := subprocess.RunCommand("rpm", "-q", "lxd") | ||
if err != nil { | ||
return false | ||
} | ||
|
||
if !util.PathExists("/run/lxd.socket") { | ||
return false | ||
} | ||
|
||
return true | ||
} | ||
|
||
func (s *srcCOPR) Name() string { | ||
return "COPR package" | ||
} | ||
|
||
func (s *srcCOPR) Stop() error { | ||
_, err := subprocess.RunCommand("systemctl", "stop", "lxd-containers.service", "lxd.service", "lxd.socket") | ||
return err | ||
} | ||
|
||
func (s *srcCOPR) Start() error { | ||
_, err := subprocess.RunCommand("systemctl", "start", "lxd.socket", "lxd-containers.service") | ||
return err | ||
} | ||
|
||
func (s *srcCOPR) Purge() error { | ||
_, err := subprocess.RunCommand("dnf", "remove", "-y", "lxd") | ||
return err | ||
} | ||
|
||
func (s *srcCOPR) Connect() (lxd.InstanceServer, error) { | ||
return lxd.ConnectLXDUnix("/run/lxd.socket", nil) | ||
} | ||
|
||
func (s *srcCOPR) Paths() (*DaemonPaths, error) { | ||
return &DaemonPaths{ | ||
Daemon: "/var/lib/lxd/", | ||
Logs: "/var/log/lxd/", | ||
Cache: "/var/cache/lxd/", | ||
}, nil | ||
} |