[lxc-devel] [lxd/master] lxd: Renames instance package to types
tomponline on Github
lxc-bot at linuxcontainers.org
Mon Sep 16 09:01:04 UTC 2019
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 514 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20190916/76604027/attachment-0001.bin>
-------------- next part --------------
From 49ba8f46f4e050806c488fb5facd3c4d1ee48397 Mon Sep 17 00:00:00 2001
From: Thomas Parrott <tomp at tomp.uk>
Date: Mon, 16 Sep 2019 09:58:51 +0100
Subject: [PATCH] lxd: Renames instance package to types and changes import
alias to instanceDBTypes
This is to accommodate the Instance interface being added to the lxd/instance package without creating import loops.
Signed-off-by: Thomas Parrott <tomp at tomp.uk>
---
lxd/api_internal.go | 6 ++--
lxd/cluster/connect.go | 4 +--
lxd/container.go | 10 +++---
lxd/container_lxc.go | 6 ++--
lxd/container_post.go | 4 +--
lxd/container_test.go | 32 +++++++++----------
lxd/containers_get.go | 16 +++++-----
lxd/containers_post.go | 12 +++----
lxd/db/containers.go | 32 +++++++++----------
lxd/db/containers_test.go | 20 ++++++------
lxd/db/images.go | 14 ++++----
lxd/db/instances.mapper.go | 4 +--
lxd/db/snapshots_test.go | 6 ++--
lxd/device/device_instance_id.go | 4 +--
lxd/device/disk.go | 4 +--
lxd/device/gpu.go | 4 +--
lxd/device/infiniband_physical.go | 4 +--
lxd/device/infiniband_sriov.go | 4 +--
lxd/device/nic_bridged.go | 4 +--
lxd/device/nic_ipvlan.go | 4 +--
lxd/device/nic_macvlan.go | 4 +--
lxd/device/nic_p2p.go | 4 +--
lxd/device/nic_physical.go | 4 +--
lxd/device/nic_sriov.go | 4 +--
lxd/device/proxy.go | 4 +--
lxd/device/unix_common.go | 4 +--
lxd/device/usb.go | 4 +--
lxd/images.go | 10 +++---
.../{instance.go => types/instance_types.go} | 0
lxd/logging.go | 4 +--
lxd/main_activateifneeded.go | 4 +--
lxd/response.go | 4 +--
lxd/storage_lvm_utils.go | 4 +--
lxd/storage_migration.go | 4 +--
34 files changed, 126 insertions(+), 126 deletions(-)
rename lxd/instance/{instance.go => types/instance_types.go} (100%)
diff --git a/lxd/api_internal.go b/lxd/api_internal.go
index 06b05f3f35..ad74e0d05a 100644
--- a/lxd/api_internal.go
+++ b/lxd/api_internal.go
@@ -22,7 +22,7 @@ import (
"github.com/lxc/lxd/lxd/db/node"
"github.com/lxc/lxd/lxd/db/query"
deviceConfig "github.com/lxc/lxd/lxd/device/config"
- "github.com/lxc/lxd/lxd/instance"
+ instanceDBTypes "github.com/lxc/lxd/lxd/instance/types"
"github.com/lxc/lxd/lxd/project"
driver "github.com/lxc/lxd/lxd/storage"
"github.com/lxc/lxd/shared"
@@ -906,7 +906,7 @@ func internalImport(d *Daemon, r *http.Request) Response {
BaseImage: baseImage,
Config: backup.Container.Config,
CreationDate: backup.Container.CreatedAt,
- Type: instance.TypeContainer,
+ Type: instanceDBTypes.TypeContainer,
Description: backup.Container.Description,
Devices: deviceConfig.NewDevices(backup.Container.Devices),
Ephemeral: backup.Container.Ephemeral,
@@ -1012,7 +1012,7 @@ func internalImport(d *Daemon, r *http.Request) Response {
BaseImage: baseImage,
Config: snap.Config,
CreationDate: snap.CreatedAt,
- Type: instance.TypeContainer,
+ Type: instanceDBTypes.TypeContainer,
Snapshot: true,
Devices: deviceConfig.NewDevices(snap.Devices),
Ephemeral: snap.Ephemeral,
diff --git a/lxd/cluster/connect.go b/lxd/cluster/connect.go
index 6f26255894..0ac689e919 100644
--- a/lxd/cluster/connect.go
+++ b/lxd/cluster/connect.go
@@ -7,7 +7,7 @@ import (
lxd "github.com/lxc/lxd/client"
"github.com/lxc/lxd/lxd/db"
- "github.com/lxc/lxd/lxd/instance"
+ instanceDBTypes "github.com/lxc/lxd/lxd/instance/types"
"github.com/lxc/lxd/shared"
"github.com/lxc/lxd/shared/api"
"github.com/pkg/errors"
@@ -38,7 +38,7 @@ func Connect(address string, cert *shared.CertInfo, notify bool) (lxd.InstanceSe
// running the container with the given name. If it's not the local node will
// connect to it and return the connected client, otherwise it will just return
// nil.
-func ConnectIfContainerIsRemote(cluster *db.Cluster, project, name string, cert *shared.CertInfo, instanceType instance.Type) (lxd.InstanceServer, error) {
+func ConnectIfContainerIsRemote(cluster *db.Cluster, project, name string, cert *shared.CertInfo, instanceType instanceDBTypes.Type) (lxd.InstanceServer, error) {
var address string // Node address
err := cluster.Transaction(func(tx *db.ClusterTx) error {
var err error
diff --git a/lxd/container.go b/lxd/container.go
index dc97c5686c..f34ba574a3 100644
--- a/lxd/container.go
+++ b/lxd/container.go
@@ -20,7 +20,7 @@ import (
"github.com/lxc/lxd/lxd/db"
"github.com/lxc/lxd/lxd/device"
"github.com/lxc/lxd/lxd/device/config"
- "github.com/lxc/lxd/lxd/instance"
+ instanceDBTypes "github.com/lxc/lxd/lxd/instance/types"
"github.com/lxc/lxd/lxd/state"
"github.com/lxc/lxd/lxd/sys"
"github.com/lxc/lxd/lxd/task"
@@ -293,7 +293,7 @@ type container interface {
Location() string
Project() string
Name() string
- Type() instance.Type
+ Type() instanceDBTypes.Type
Description() string
Architecture() int
CreationDate() time.Time
@@ -452,7 +452,7 @@ func containerCreateFromImage(d *Daemon, args db.ContainerArgs, hash string, tra
}
// Validate the type of the image matches the type of the instance.
- imgType, err := instance.New(img.Type)
+ imgType, err := instanceDBTypes.New(img.Type)
if err != nil {
return nil, err
}
@@ -1094,7 +1094,7 @@ func containerLoadByProject(s *state.State, project string) ([]container, error)
err := s.Cluster.Transaction(func(tx *db.ClusterTx) error {
filter := db.InstanceFilter{
Project: project,
- Type: instance.TypeContainer,
+ Type: instanceDBTypes.TypeContainer,
}
var err error
cts, err = tx.InstanceList(filter)
@@ -1162,7 +1162,7 @@ func containerLoadNodeAll(s *state.State) ([]container, error) {
}
// Load all containers of this nodes under the given project.
-func containerLoadNodeProjectAll(s *state.State, project string, instanceType instance.Type) ([]container, error) {
+func containerLoadNodeProjectAll(s *state.State, project string, instanceType instanceDBTypes.Type) ([]container, error) {
// Get all the container arguments
var cts []db.Instance
err := s.Cluster.Transaction(func(tx *db.ClusterTx) error {
diff --git a/lxd/container_lxc.go b/lxd/container_lxc.go
index 140b735cd6..083d6f8427 100644
--- a/lxd/container_lxc.go
+++ b/lxd/container_lxc.go
@@ -30,7 +30,7 @@ import (
"github.com/lxc/lxd/lxd/db/query"
"github.com/lxc/lxd/lxd/device"
"github.com/lxc/lxd/lxd/device/config"
- "github.com/lxc/lxd/lxd/instance"
+ instanceDBTypes "github.com/lxc/lxd/lxd/instance/types"
"github.com/lxc/lxd/lxd/maas"
"github.com/lxc/lxd/lxd/project"
"github.com/lxc/lxd/lxd/state"
@@ -595,7 +595,7 @@ func containerLXCInstantiate(s *state.State, args db.ContainerArgs) *containerLX
type containerLXC struct {
// Properties
architecture int
- dbType instance.Type
+ dbType instanceDBTypes.Type
snapshot bool
creationDate time.Time
lastUsedDate time.Time
@@ -633,7 +633,7 @@ type containerLXC struct {
expiryDate time.Time
}
-func (c *containerLXC) Type() instance.Type {
+func (c *containerLXC) Type() instanceDBTypes.Type {
return c.dbType
}
diff --git a/lxd/container_post.go b/lxd/container_post.go
index e428b0d098..8492a6d495 100644
--- a/lxd/container_post.go
+++ b/lxd/container_post.go
@@ -14,7 +14,7 @@ import (
lxd "github.com/lxc/lxd/client"
"github.com/lxc/lxd/lxd/cluster"
"github.com/lxc/lxd/lxd/db"
- "github.com/lxc/lxd/lxd/instance"
+ instanceDBTypes "github.com/lxc/lxd/lxd/instance/types"
driver "github.com/lxc/lxd/lxd/storage"
"github.com/lxc/lxd/shared"
"github.com/lxc/lxd/shared/api"
@@ -400,7 +400,7 @@ func containerPostClusteringMigrate(d *Daemon, c container, oldName, newName, ne
}
// Special case migrating a container backed by ceph across two cluster nodes.
-func containerPostClusteringMigrateWithCeph(d *Daemon, c container, project, oldName, newName, newNode string, instanceType instance.Type) Response {
+func containerPostClusteringMigrateWithCeph(d *Daemon, c container, project, oldName, newName, newNode string, instanceType instanceDBTypes.Type) Response {
run := func(*operation) error {
// If source node is online (i.e. we're serving the request on
// it, and c != nil), let's unmap the RBD volume locally
diff --git a/lxd/container_test.go b/lxd/container_test.go
index 878b88b24c..b79445f616 100644
--- a/lxd/container_test.go
+++ b/lxd/container_test.go
@@ -8,7 +8,7 @@ import (
"github.com/lxc/lxd/lxd/db"
"github.com/lxc/lxd/lxd/device/config"
- "github.com/lxc/lxd/lxd/instance"
+ instanceDBTypes "github.com/lxc/lxd/lxd/instance/types"
driver "github.com/lxc/lxd/lxd/storage"
"github.com/lxc/lxd/shared"
"github.com/lxc/lxd/shared/api"
@@ -21,7 +21,7 @@ type containerTestSuite struct {
func (suite *containerTestSuite) TestContainer_ProfilesDefault() {
args := db.ContainerArgs{
- Type: instance.TypeContainer,
+ Type: instanceDBTypes.TypeContainer,
Ephemeral: false,
Name: "testFoo",
}
@@ -63,7 +63,7 @@ func (suite *containerTestSuite) TestContainer_ProfilesMulti() {
}()
args := db.ContainerArgs{
- Type: instance.TypeContainer,
+ Type: instanceDBTypes.TypeContainer,
Ephemeral: false,
Profiles: []string{"default", "unprivileged"},
Name: "testFoo",
@@ -86,7 +86,7 @@ func (suite *containerTestSuite) TestContainer_ProfilesMulti() {
func (suite *containerTestSuite) TestContainer_ProfilesOverwriteDefaultNic() {
args := db.ContainerArgs{
- Type: instance.TypeContainer,
+ Type: instanceDBTypes.TypeContainer,
Ephemeral: false,
Config: map[string]string{"security.privileged": "true"},
Devices: config.Devices{
@@ -116,7 +116,7 @@ func (suite *containerTestSuite) TestContainer_ProfilesOverwriteDefaultNic() {
func (suite *containerTestSuite) TestContainer_LoadFromDB() {
args := db.ContainerArgs{
- Type: instance.TypeContainer,
+ Type: instanceDBTypes.TypeContainer,
Ephemeral: false,
Config: map[string]string{"security.privileged": "true"},
Devices: config.Devices{
@@ -154,7 +154,7 @@ func (suite *containerTestSuite) TestContainer_LoadFromDB() {
func (suite *containerTestSuite) TestContainer_Path_Regular() {
// Regular
args := db.ContainerArgs{
- Type: instance.TypeContainer,
+ Type: instanceDBTypes.TypeContainer,
Ephemeral: false,
Name: "testFoo",
}
@@ -170,7 +170,7 @@ func (suite *containerTestSuite) TestContainer_Path_Regular() {
func (suite *containerTestSuite) TestContainer_LogPath() {
args := db.ContainerArgs{
- Type: instance.TypeContainer,
+ Type: instanceDBTypes.TypeContainer,
Ephemeral: false,
Name: "testFoo",
}
@@ -184,7 +184,7 @@ func (suite *containerTestSuite) TestContainer_LogPath() {
func (suite *containerTestSuite) TestContainer_IsPrivileged_Privileged() {
args := db.ContainerArgs{
- Type: instance.TypeContainer,
+ Type: instanceDBTypes.TypeContainer,
Ephemeral: false,
Config: map[string]string{"security.privileged": "true"},
Name: "testFoo",
@@ -199,7 +199,7 @@ func (suite *containerTestSuite) TestContainer_IsPrivileged_Privileged() {
func (suite *containerTestSuite) TestContainer_IsPrivileged_Unprivileged() {
args := db.ContainerArgs{
- Type: instance.TypeContainer,
+ Type: instanceDBTypes.TypeContainer,
Ephemeral: false,
Config: map[string]string{"security.privileged": "false"},
Name: "testFoo",
@@ -214,7 +214,7 @@ func (suite *containerTestSuite) TestContainer_IsPrivileged_Unprivileged() {
func (suite *containerTestSuite) TestContainer_Rename() {
args := db.ContainerArgs{
- Type: instance.TypeContainer,
+ Type: instanceDBTypes.TypeContainer,
Ephemeral: false,
Name: "testFoo",
}
@@ -229,7 +229,7 @@ func (suite *containerTestSuite) TestContainer_Rename() {
func (suite *containerTestSuite) TestContainer_findIdmap_isolated() {
c1, err := containerCreateInternal(suite.d.State(), db.ContainerArgs{
- Type: instance.TypeContainer,
+ Type: instanceDBTypes.TypeContainer,
Name: "isol-1",
Config: map[string]string{
"security.idmap.isolated": "true",
@@ -239,7 +239,7 @@ func (suite *containerTestSuite) TestContainer_findIdmap_isolated() {
defer c1.Delete()
c2, err := containerCreateInternal(suite.d.State(), db.ContainerArgs{
- Type: instance.TypeContainer,
+ Type: instanceDBTypes.TypeContainer,
Name: "isol-2",
Config: map[string]string{
"security.idmap.isolated": "true",
@@ -270,7 +270,7 @@ func (suite *containerTestSuite) TestContainer_findIdmap_isolated() {
func (suite *containerTestSuite) TestContainer_findIdmap_mixed() {
c1, err := containerCreateInternal(suite.d.State(), db.ContainerArgs{
- Type: instance.TypeContainer,
+ Type: instanceDBTypes.TypeContainer,
Name: "isol-1",
Config: map[string]string{
"security.idmap.isolated": "false",
@@ -280,7 +280,7 @@ func (suite *containerTestSuite) TestContainer_findIdmap_mixed() {
defer c1.Delete()
c2, err := containerCreateInternal(suite.d.State(), db.ContainerArgs{
- Type: instance.TypeContainer,
+ Type: instanceDBTypes.TypeContainer,
Name: "isol-2",
Config: map[string]string{
"security.idmap.isolated": "true",
@@ -311,7 +311,7 @@ func (suite *containerTestSuite) TestContainer_findIdmap_mixed() {
func (suite *containerTestSuite) TestContainer_findIdmap_raw() {
c1, err := containerCreateInternal(suite.d.State(), db.ContainerArgs{
- Type: instance.TypeContainer,
+ Type: instanceDBTypes.TypeContainer,
Name: "isol-1",
Config: map[string]string{
"security.idmap.isolated": "false",
@@ -350,7 +350,7 @@ func (suite *containerTestSuite) TestContainer_findIdmap_maxed() {
for i := 0; i < 7; i++ {
c, err := containerCreateInternal(suite.d.State(), db.ContainerArgs{
- Type: instance.TypeContainer,
+ Type: instanceDBTypes.TypeContainer,
Name: fmt.Sprintf("isol-%d", i),
Config: map[string]string{
"security.idmap.isolated": "true",
diff --git a/lxd/containers_get.go b/lxd/containers_get.go
index 8d42f15da3..de41dd1478 100644
--- a/lxd/containers_get.go
+++ b/lxd/containers_get.go
@@ -15,7 +15,7 @@ import (
"github.com/lxc/lxd/lxd/cluster"
"github.com/lxc/lxd/lxd/db"
"github.com/lxc/lxd/lxd/db/query"
- "github.com/lxc/lxd/lxd/instance"
+ instanceDBTypes "github.com/lxc/lxd/lxd/instance/types"
"github.com/lxc/lxd/shared"
"github.com/lxc/lxd/shared/api"
"github.com/lxc/lxd/shared/logger"
@@ -24,19 +24,19 @@ import (
// urlInstanceTypeDetect detects what sort of instance type filter is being requested. Either
// explicitly via the instance-type query param or implicitly via the endpoint URL used.
-func urlInstanceTypeDetect(r *http.Request) (instance.Type, error) {
+func urlInstanceTypeDetect(r *http.Request) (instanceDBTypes.Type, error) {
reqInstanceType := r.URL.Query().Get("instance-type")
if strings.HasPrefix(mux.CurrentRoute(r).GetName(), "container") {
- return instance.TypeContainer, nil
+ return instanceDBTypes.TypeContainer, nil
} else if reqInstanceType != "" {
- instanceType, err := instance.New(reqInstanceType)
+ instanceType, err := instanceDBTypes.New(reqInstanceType)
if err != nil {
- return instance.TypeAny, err
+ return instanceDBTypes.TypeAny, err
}
return instanceType, nil
}
- return instance.TypeAny, nil
+ return instanceDBTypes.TypeAny, nil
}
func containersGet(d *Daemon, r *http.Request) Response {
@@ -292,7 +292,7 @@ func doContainersGet(d *Daemon, r *http.Request) (interface{}, error) {
// Fetch information about the containers on the given remote node, using the
// rest API and with a timeout of 30 seconds.
-func doContainersGetFromNode(project, node string, cert *shared.CertInfo, instanceType instance.Type) ([]api.Instance, error) {
+func doContainersGetFromNode(project, node string, cert *shared.CertInfo, instanceType instanceDBTypes.Type) ([]api.Instance, error) {
f := func() ([]api.Instance, error) {
client, err := cluster.Connect(node, cert, true)
if err != nil {
@@ -329,7 +329,7 @@ func doContainersGetFromNode(project, node string, cert *shared.CertInfo, instan
return containers, err
}
-func doContainersFullGetFromNode(project, node string, cert *shared.CertInfo, instanceType instance.Type) ([]api.InstanceFull, error) {
+func doContainersFullGetFromNode(project, node string, cert *shared.CertInfo, instanceType instanceDBTypes.Type) ([]api.InstanceFull, error) {
f := func() ([]api.InstanceFull, error) {
client, err := cluster.Connect(node, cert, true)
if err != nil {
diff --git a/lxd/containers_post.go b/lxd/containers_post.go
index 753db8b259..7ba41721e3 100644
--- a/lxd/containers_post.go
+++ b/lxd/containers_post.go
@@ -20,7 +20,7 @@ import (
"github.com/lxc/lxd/lxd/cluster"
"github.com/lxc/lxd/lxd/db"
"github.com/lxc/lxd/lxd/device/config"
- "github.com/lxc/lxd/lxd/instance"
+ instanceDBTypes "github.com/lxc/lxd/lxd/instance/types"
"github.com/lxc/lxd/lxd/migration"
"github.com/lxc/lxd/shared"
"github.com/lxc/lxd/shared/api"
@@ -93,7 +93,7 @@ func createFromImage(d *Daemon, project string, req *api.InstancesPost) Response
return BadRequest(fmt.Errorf("Must specify one of alias, fingerprint or properties for init from image"))
}
- dbType, err := instance.New(string(req.Type))
+ dbType, err := instanceDBTypes.New(string(req.Type))
if err != nil {
return BadRequest(err)
}
@@ -155,7 +155,7 @@ func createFromImage(d *Daemon, project string, req *api.InstancesPost) Response
}
func createFromNone(d *Daemon, project string, req *api.InstancesPost) Response {
- dbType, err := instance.New(string(req.Type))
+ dbType, err := instanceDBTypes.New(string(req.Type))
if err != nil {
return BadRequest(err)
}
@@ -214,7 +214,7 @@ func createFromMigration(d *Daemon, project string, req *api.InstancesPost) Resp
req.Profiles = []string{"default"}
}
- dbType, err := instance.New(string(req.Type))
+ dbType, err := instanceDBTypes.New(string(req.Type))
if err != nil {
return BadRequest(err)
}
@@ -567,12 +567,12 @@ func createFromCopy(d *Daemon, project string, req *api.InstancesPost) Response
}
}
- dbType, err := instance.New(string(req.Type))
+ dbType, err := instanceDBTypes.New(string(req.Type))
if err != nil {
return BadRequest(err)
}
- if dbType != instance.TypeAny && dbType != source.Type() {
+ if dbType != instanceDBTypes.TypeAny && dbType != source.Type() {
return BadRequest(fmt.Errorf("Instance type should not be specified or should match source type"))
}
diff --git a/lxd/db/containers.go b/lxd/db/containers.go
index 9bda7f6e3f..de77da3fc3 100644
--- a/lxd/db/containers.go
+++ b/lxd/db/containers.go
@@ -10,7 +10,7 @@ import (
"github.com/lxc/lxd/lxd/db/query"
"github.com/lxc/lxd/lxd/device/config"
deviceConfig "github.com/lxc/lxd/lxd/device/config"
- "github.com/lxc/lxd/lxd/instance"
+ instanceDBTypes "github.com/lxc/lxd/lxd/instance/types"
"github.com/lxc/lxd/shared"
"github.com/lxc/lxd/shared/api"
"github.com/lxc/lxd/shared/logger"
@@ -70,7 +70,7 @@ type Instance struct {
Project string `db:"primary=yes&join=projects.name"`
Name string `db:"primary=yes"`
Node string `db:"join=nodes.name"`
- Type instance.Type
+ Type instanceDBTypes.Type
Snapshot bool
Architecture int
Ephemeral bool
@@ -89,7 +89,7 @@ type InstanceFilter struct {
Project string
Name string
Node string
- Type instance.Type
+ Type instanceDBTypes.Type
}
// ContainerToArgs is a convenience to convert the new Container db struct into
@@ -127,7 +127,7 @@ type ContainerArgs struct {
// Don't set manually
ID int
Node string
- Type instance.Type
+ Type instanceDBTypes.Type
Snapshot bool
// Creation only
@@ -168,14 +168,14 @@ SELECT instances.name FROM instances
JOIN projects ON projects.id = instances.project_id
WHERE projects.name = ? AND instances.type = ?
`
- return query.SelectStrings(c.tx, stmt, project, instance.TypeContainer)
+ return query.SelectStrings(c.tx, stmt, project, instanceDBTypes.TypeContainer)
}
// ContainerNodeAddress returns the address of the node hosting the container
// with the given name in the given project.
//
// It returns the empty string if the container is hosted on this node.
-func (c *ClusterTx) ContainerNodeAddress(project string, name string, instanceType instance.Type) (string, error) {
+func (c *ClusterTx) ContainerNodeAddress(project string, name string, instanceType instanceDBTypes.Type) (string, error) {
var stmt string
args := make([]interface{}, 0, 4) // Expect up to 4 filters.
@@ -186,7 +186,7 @@ func (c *ClusterTx) ContainerNodeAddress(project string, name string, instanceTy
args = append(args, project)
// Instance type filter.
- if instanceType != instance.TypeAny {
+ if instanceType != instanceDBTypes.TypeAny {
filters.WriteString(" AND instances.type = ?")
args = append(args, instanceType)
}
@@ -264,7 +264,7 @@ SELECT nodes.id, nodes.address
// string, to distinguish it from remote nodes.
//
// Containers whose node is down are addeded to the special address "0.0.0.0".
-func (c *ClusterTx) ContainersListByNodeAddress(project string, instanceType instance.Type) (map[string][]string, error) {
+func (c *ClusterTx) ContainersListByNodeAddress(project string, instanceType instanceDBTypes.Type) (map[string][]string, error) {
offlineThreshold, err := c.NodeOfflineThreshold()
if err != nil {
return nil, err
@@ -278,7 +278,7 @@ func (c *ClusterTx) ContainersListByNodeAddress(project string, instanceType ins
args = append(args, project)
// Instance type filter.
- if instanceType != instance.TypeAny {
+ if instanceType != instanceDBTypes.TypeAny {
filters.WriteString(" AND instances.type = ?")
args = append(args, instanceType)
}
@@ -364,7 +364,7 @@ func (c *ClusterTx) ContainerListExpanded() ([]Instance, error) {
// ContainersByNodeName returns a map associating each container to the name of
// its node.
-func (c *ClusterTx) ContainersByNodeName(project string, instanceType instance.Type) (map[string]string, error) {
+func (c *ClusterTx) ContainersByNodeName(project string, instanceType instanceDBTypes.Type) (map[string]string, error) {
args := make([]interface{}, 0, 2) // Expect up to 2 filters.
var filters strings.Builder
@@ -373,7 +373,7 @@ func (c *ClusterTx) ContainersByNodeName(project string, instanceType instance.T
args = append(args, project)
// Instance type filter.
- if instanceType != instance.TypeAny {
+ if instanceType != instanceDBTypes.TypeAny {
filters.WriteString(" AND instances.type = ?")
args = append(args, instanceType)
}
@@ -532,14 +532,14 @@ func (c *ClusterTx) ContainerNodeList() ([]Instance, error) {
}
filter := InstanceFilter{
Node: node,
- Type: instance.TypeContainer,
+ Type: instanceDBTypes.TypeContainer,
}
return c.InstanceList(filter)
}
// ContainerNodeProjectList returns all container objects on the local node within the given project.
-func (c *ClusterTx) ContainerNodeProjectList(project string, instanceType instance.Type) ([]Instance, error) {
+func (c *ClusterTx) ContainerNodeProjectList(project string, instanceType instanceDBTypes.Type) ([]Instance, error) {
node, err := c.NodeName()
if err != nil {
return nil, errors.Wrap(err, "Local node name")
@@ -839,7 +839,7 @@ func (c *Cluster) ContainerConfig(id int) (map[string]string, error) {
// use it for new code.
func (c *Cluster) LegacyContainersList() ([]string, error) {
q := fmt.Sprintf("SELECT name FROM instances WHERE type=? ORDER BY name")
- inargs := []interface{}{instance.TypeContainer}
+ inargs := []interface{}{instanceDBTypes.TypeContainer}
var container string
outfmt := []interface{}{container}
result, err := queryScan(c.db, q, inargs, outfmt)
@@ -866,7 +866,7 @@ FROM instances_snapshots
JOIN instances ON instances.id = instances_snapshots.instance_id
WHERE type=? ORDER BY instances.name, instances_snapshots.name
`)
- inargs := []interface{}{instance.TypeContainer}
+ inargs := []interface{}{instanceDBTypes.TypeContainer}
var container string
var snapshot string
outfmt := []interface{}{container, snapshot}
@@ -885,7 +885,7 @@ WHERE type=? ORDER BY instances.name, instances_snapshots.name
// ContainersNodeList returns the names of all the containers of the given type
// running on the local node.
-func (c *Cluster) ContainersNodeList(instanceType instance.Type) ([]string, error) {
+func (c *Cluster) ContainersNodeList(instanceType instanceDBTypes.Type) ([]string, error) {
q := fmt.Sprintf("SELECT name FROM instances WHERE type=? AND node_id=? ORDER BY name")
inargs := []interface{}{instanceType, c.nodeID}
var container string
diff --git a/lxd/db/containers_test.go b/lxd/db/containers_test.go
index ef829b9e37..49baa05bf6 100644
--- a/lxd/db/containers_test.go
+++ b/lxd/db/containers_test.go
@@ -8,7 +8,7 @@ import (
"github.com/stretchr/testify/require"
"github.com/lxc/lxd/lxd/db"
- "github.com/lxc/lxd/lxd/instance"
+ instanceDBTypes "github.com/lxc/lxd/lxd/instance/types"
"github.com/lxc/lxd/shared/api"
)
@@ -32,7 +32,7 @@ func TestContainerList(t *testing.T) {
addContainerDevice(t, tx, "c2", "eth0", "nic", nil)
addContainerDevice(t, tx, "c3", "root", "disk", map[string]string{"x": "y"})
- filter := db.InstanceFilter{Type: instance.TypeContainer}
+ filter := db.InstanceFilter{Type: instanceDBTypes.TypeContainer}
containers, err := tx.InstanceList(filter)
require.NoError(t, err)
assert.Len(t, containers, 3)
@@ -74,7 +74,7 @@ func TestContainerList_FilterByNode(t *testing.T) {
filter := db.InstanceFilter{
Project: "default",
Node: "node2",
- Type: instance.TypeContainer,
+ Type: instanceDBTypes.TypeContainer,
}
containers, err := tx.InstanceList(filter)
@@ -119,7 +119,7 @@ func TestInstanceList_ContainerWithSameNameInDifferentProjects(t *testing.T) {
Project: "blah",
Name: "c1",
Node: "none",
- Type: instance.TypeContainer,
+ Type: instanceDBTypes.TypeContainer,
Architecture: 1,
Ephemeral: false,
Stateful: true,
@@ -134,7 +134,7 @@ func TestInstanceList_ContainerWithSameNameInDifferentProjects(t *testing.T) {
Project: "test",
Name: "c1",
Node: "none",
- Type: instance.TypeContainer,
+ Type: instanceDBTypes.TypeContainer,
Architecture: 1,
Ephemeral: false,
Stateful: true,
@@ -173,7 +173,7 @@ func TestInstanceListExpanded(t *testing.T) {
Project: "default",
Name: "c1",
Node: "none",
- Type: instance.TypeContainer,
+ Type: instanceDBTypes.TypeContainer,
Architecture: 1,
Ephemeral: false,
Stateful: true,
@@ -313,7 +313,7 @@ func TestContainersListByNodeAddress(t *testing.T) {
addContainer(t, tx, nodeID3, "c3")
addContainer(t, tx, nodeID2, "c4")
- result, err := tx.ContainersListByNodeAddress("default", instance.TypeContainer)
+ result, err := tx.ContainersListByNodeAddress("default", instanceDBTypes.TypeContainer)
require.NoError(t, err)
assert.Equal(
t,
@@ -337,7 +337,7 @@ func TestContainersByNodeName(t *testing.T) {
addContainer(t, tx, nodeID2, "c1")
addContainer(t, tx, nodeID1, "c2")
- result, err := tx.ContainersByNodeName("default", instance.TypeContainer)
+ result, err := tx.ContainersByNodeName("default", instanceDBTypes.TypeContainer)
require.NoError(t, err)
assert.Equal(
t,
@@ -398,7 +398,7 @@ func TestContainersNodeList(t *testing.T) {
})
require.NoError(t, err)
- names, err := cluster.ContainersNodeList(instance.TypeContainer)
+ names, err := cluster.ContainersNodeList(instanceTypess.TypeContainer)
require.NoError(t, err)
assert.Equal(t, names, []string{"c1"})
}
@@ -450,7 +450,7 @@ func addContainer(t *testing.T, tx *db.ClusterTx, nodeID int64, name string) {
stmt := `
INSERT INTO instances(node_id, name, architecture, type, project_id) VALUES (?, ?, 1, ?, 1)
`
- _, err := tx.Tx().Exec(stmt, nodeID, name, instance.TypeContainer)
+ _, err := tx.Tx().Exec(stmt, nodeID, name, instanceDBTypes.TypeContainer)
require.NoError(t, err)
}
diff --git a/lxd/db/images.go b/lxd/db/images.go
index 294ec0a348..af5b911455 100644
--- a/lxd/db/images.go
+++ b/lxd/db/images.go
@@ -8,7 +8,7 @@ import (
"github.com/pkg/errors"
"github.com/lxc/lxd/lxd/db/query"
- "github.com/lxc/lxd/lxd/instance"
+ instanceDBTypes "github.com/lxc/lxd/lxd/instance/types"
"github.com/lxc/lxd/shared/api"
"github.com/lxc/lxd/shared/osarch"
)
@@ -157,10 +157,10 @@ func (c *Cluster) ImageSourceGet(imageID int) (int, api.ImageSource, error) {
// cached image that matches the given remote details (server, protocol and
// alias). Return the fingerprint linked to the matching entry, if any.
func (c *Cluster) ImageSourceGetCachedFingerprint(server string, protocol string, alias string, typeName string) (string, error) {
- imageType := instance.TypeAny
+ imageType := instanceDBTypes.TypeAny
if typeName != "" {
var err error
- imageType, err = instance.New(typeName)
+ imageType, err = instanceDBTypes.New(typeName)
if err != nil {
return "", err
}
@@ -431,7 +431,7 @@ func (c *Cluster) imageFill(id int, image *api.Image, create, expire, used, uplo
}
image.Architecture, _ = osarch.ArchitectureName(arch)
- image.Type = instance.Type(imageType).String()
+ image.Type = instanceDBTypes.Type(imageType).String()
// The upload date is enforced by NOT NULL in the schema, so it can never be nil.
image.UploadedAt = *upload
@@ -647,7 +647,7 @@ func (c *Cluster) ImageAliasGet(project, name string, isTrustedClient bool) (int
entry.Name = name
entry.Target = fingerprint
entry.Description = description
- entry.Type = instance.Type(imageType).String()
+ entry.Type = instanceDBTypes.Type(imageType).String()
return id, entry, nil
}
@@ -807,10 +807,10 @@ func (c *Cluster) ImageInsert(project, fp string, fname string, sz int64, public
arch = 0
}
- imageType := instance.TypeAny
+ imageType := instanceDBTypes.TypeAny
if typeName != "" {
var err error
- imageType, err = instance.New(typeName)
+ imageType, err = instanceDBTypes.New(typeName)
if err != nil {
return err
}
diff --git a/lxd/db/instances.mapper.go b/lxd/db/instances.mapper.go
index 74389ef9e7..8fb29c96c8 100644
--- a/lxd/db/instances.mapper.go
+++ b/lxd/db/instances.mapper.go
@@ -10,7 +10,7 @@ import (
"github.com/lxc/lxd/lxd/db/cluster"
"github.com/lxc/lxd/lxd/db/query"
- "github.com/lxc/lxd/lxd/instance"
+ instanceDBTypes "github.com/lxc/lxd/lxd/instance/types"
"github.com/lxc/lxd/shared/api"
)
@@ -166,7 +166,7 @@ func (c *ClusterTx) InstanceList(filter InstanceFilter) ([]Instance, error) {
if filter.Node != "" {
criteria["Node"] = filter.Node
}
- if filter.Type != instance.TypeAny {
+ if filter.Type != instanceDBTypes.TypeAny {
criteria["Type"] = filter.Type
}
diff --git a/lxd/db/snapshots_test.go b/lxd/db/snapshots_test.go
index 0ef5121170..6c34db19cd 100644
--- a/lxd/db/snapshots_test.go
+++ b/lxd/db/snapshots_test.go
@@ -8,7 +8,7 @@ import (
"github.com/stretchr/testify/require"
"github.com/lxc/lxd/lxd/db"
- "github.com/lxc/lxd/lxd/instance"
+ instanceDBTypes "github.com/lxc/lxd/lxd/instance/types"
"github.com/lxc/lxd/shared/api"
)
@@ -97,7 +97,7 @@ func TestInstanceSnapshotList_SameNameInDifferentProjects(t *testing.T) {
Project: "default",
Name: "i1",
Node: "none",
- Type: instance.TypeContainer,
+ Type: instanceDBTypes.TypeContainer,
Architecture: 1,
Ephemeral: false,
Stateful: true,
@@ -110,7 +110,7 @@ func TestInstanceSnapshotList_SameNameInDifferentProjects(t *testing.T) {
Project: "p1",
Name: "i1",
Node: "none",
- Type: instance.TypeContainer,
+ Type: instanceDBTypes.TypeContainer,
Architecture: 1,
Ephemeral: false,
Stateful: true,
diff --git a/lxd/device/device_instance_id.go b/lxd/device/device_instance_id.go
index c92bb6ae95..7f83824b1f 100644
--- a/lxd/device/device_instance_id.go
+++ b/lxd/device/device_instance_id.go
@@ -2,7 +2,7 @@ package device
import (
"github.com/lxc/lxd/lxd/device/config"
- "github.com/lxc/lxd/lxd/instance"
+ instanceDBTypes "github.com/lxc/lxd/lxd/instance/types"
)
// InstanceIdentifier is an interface that allows us to identify an Instance and its properties.
@@ -10,7 +10,7 @@ import (
// independent of when they're called in the instance lifecycle.
type InstanceIdentifier interface {
Name() string
- Type() instance.Type
+ Type() instanceDBTypes.Type
Project() string
DevicesPath() string
RootfsPath() string
diff --git a/lxd/device/disk.go b/lxd/device/disk.go
index a695d0a0c4..92c455cba0 100644
--- a/lxd/device/disk.go
+++ b/lxd/device/disk.go
@@ -14,7 +14,7 @@ import (
"github.com/lxc/lxd/lxd/db"
"github.com/lxc/lxd/lxd/device/config"
- "github.com/lxc/lxd/lxd/instance"
+ instanceDBTypes "github.com/lxc/lxd/lxd/instance/types"
"github.com/lxc/lxd/lxd/util"
"github.com/lxc/lxd/shared"
"github.com/lxc/lxd/shared/logger"
@@ -44,7 +44,7 @@ func (d *disk) isRequired() bool {
// validateConfig checks the supplied config for correctness.
func (d *disk) validateConfig() error {
- if d.instance.Type() != instance.TypeContainer {
+ if d.instance.Type() != instanceDBTypes.TypeContainer {
return ErrUnsupportedDevType
}
diff --git a/lxd/device/gpu.go b/lxd/device/gpu.go
index fdcfa69846..2b8142ee8e 100644
--- a/lxd/device/gpu.go
+++ b/lxd/device/gpu.go
@@ -11,7 +11,7 @@ import (
"golang.org/x/sys/unix"
- "github.com/lxc/lxd/lxd/instance"
+ instanceDBTypes "github.com/lxc/lxd/lxd/instance/types"
"github.com/lxc/lxd/lxd/resources"
"github.com/lxc/lxd/shared"
)
@@ -31,7 +31,7 @@ type gpu struct {
// validateConfig checks the supplied config for correctness.
func (d *gpu) validateConfig() error {
- if d.instance.Type() != instance.TypeContainer {
+ if d.instance.Type() != instanceDBTypes.TypeContainer {
return ErrUnsupportedDevType
}
diff --git a/lxd/device/infiniband_physical.go b/lxd/device/infiniband_physical.go
index 9c181be6e8..0592a460b3 100644
--- a/lxd/device/infiniband_physical.go
+++ b/lxd/device/infiniband_physical.go
@@ -3,7 +3,7 @@ package device
import (
"fmt"
- "github.com/lxc/lxd/lxd/instance"
+ instanceDBTypes "github.com/lxc/lxd/lxd/instance/types"
"github.com/lxc/lxd/lxd/resources"
"github.com/lxc/lxd/shared"
)
@@ -14,7 +14,7 @@ type infinibandPhysical struct {
// validateConfig checks the supplied config for correctness.
func (d *infinibandPhysical) validateConfig() error {
- if d.instance.Type() != instance.TypeContainer {
+ if d.instance.Type() != instanceDBTypes.TypeContainer {
return ErrUnsupportedDevType
}
diff --git a/lxd/device/infiniband_sriov.go b/lxd/device/infiniband_sriov.go
index 6d96b0c4aa..d531e64d58 100644
--- a/lxd/device/infiniband_sriov.go
+++ b/lxd/device/infiniband_sriov.go
@@ -3,7 +3,7 @@ package device
import (
"fmt"
- "github.com/lxc/lxd/lxd/instance"
+ instanceDBTypes "github.com/lxc/lxd/lxd/instance/types"
"github.com/lxc/lxd/lxd/resources"
"github.com/lxc/lxd/shared"
"github.com/lxc/lxd/shared/api"
@@ -15,7 +15,7 @@ type infinibandSRIOV struct {
// validateConfig checks the supplied config for correctness.
func (d *infinibandSRIOV) validateConfig() error {
- if d.instance.Type() != instance.TypeContainer {
+ if d.instance.Type() != instanceDBTypes.TypeContainer {
return ErrUnsupportedDevType
}
diff --git a/lxd/device/nic_bridged.go b/lxd/device/nic_bridged.go
index f1e834d263..6a3620516e 100644
--- a/lxd/device/nic_bridged.go
+++ b/lxd/device/nic_bridged.go
@@ -21,7 +21,7 @@ import (
"github.com/lxc/lxd/lxd/device/config"
"github.com/lxc/lxd/lxd/dnsmasq"
- "github.com/lxc/lxd/lxd/instance"
+ instanceDBTypes "github.com/lxc/lxd/lxd/instance/types"
"github.com/lxc/lxd/lxd/iptables"
"github.com/lxc/lxd/shared"
"github.com/lxc/lxd/shared/logger"
@@ -47,7 +47,7 @@ type nicBridged struct {
// validateConfig checks the supplied config for correctness.
func (d *nicBridged) validateConfig() error {
- if d.instance.Type() != instance.TypeContainer {
+ if d.instance.Type() != instanceDBTypes.TypeContainer {
return ErrUnsupportedDevType
}
diff --git a/lxd/device/nic_ipvlan.go b/lxd/device/nic_ipvlan.go
index 66b547c12b..74098696da 100644
--- a/lxd/device/nic_ipvlan.go
+++ b/lxd/device/nic_ipvlan.go
@@ -4,7 +4,7 @@ import (
"fmt"
"strings"
- "github.com/lxc/lxd/lxd/instance"
+ instanceDBTypes "github.com/lxc/lxd/lxd/instance/types"
"github.com/lxc/lxd/shared"
)
@@ -18,7 +18,7 @@ func (d *nicIPVLAN) CanHotPlug() (bool, []string) {
// validateConfig checks the supplied config for correctness.
func (d *nicIPVLAN) validateConfig() error {
- if d.instance.Type() != instance.TypeContainer {
+ if d.instance.Type() != instanceDBTypes.TypeContainer {
return ErrUnsupportedDevType
}
diff --git a/lxd/device/nic_macvlan.go b/lxd/device/nic_macvlan.go
index 60f731f52e..9b890f3fd8 100644
--- a/lxd/device/nic_macvlan.go
+++ b/lxd/device/nic_macvlan.go
@@ -3,7 +3,7 @@ package device
import (
"fmt"
- "github.com/lxc/lxd/lxd/instance"
+ instanceDBTypes "github.com/lxc/lxd/lxd/instance/types"
"github.com/lxc/lxd/shared"
)
@@ -13,7 +13,7 @@ type nicMACVLAN struct {
// validateConfig checks the supplied config for correctness.
func (d *nicMACVLAN) validateConfig() error {
- if d.instance.Type() != instance.TypeContainer {
+ if d.instance.Type() != instanceDBTypes.TypeContainer {
return ErrUnsupportedDevType
}
diff --git a/lxd/device/nic_p2p.go b/lxd/device/nic_p2p.go
index 35b7d7e815..8421e436af 100644
--- a/lxd/device/nic_p2p.go
+++ b/lxd/device/nic_p2p.go
@@ -4,7 +4,7 @@ import (
"fmt"
"github.com/lxc/lxd/lxd/device/config"
- "github.com/lxc/lxd/lxd/instance"
+ instanceDBTypes "github.com/lxc/lxd/lxd/instance/types"
"github.com/lxc/lxd/shared"
)
@@ -14,7 +14,7 @@ type nicP2P struct {
// validateConfig checks the supplied config for correctness.
func (d *nicP2P) validateConfig() error {
- if d.instance.Type() != instance.TypeContainer {
+ if d.instance.Type() != instanceDBTypes.TypeContainer {
return ErrUnsupportedDevType
}
diff --git a/lxd/device/nic_physical.go b/lxd/device/nic_physical.go
index 41e8ce4b90..fd4f67c66c 100644
--- a/lxd/device/nic_physical.go
+++ b/lxd/device/nic_physical.go
@@ -3,7 +3,7 @@ package device
import (
"fmt"
- "github.com/lxc/lxd/lxd/instance"
+ instanceDBTypes "github.com/lxc/lxd/lxd/instance/types"
"github.com/lxc/lxd/shared"
)
@@ -13,7 +13,7 @@ type nicPhysical struct {
// validateConfig checks the supplied config for correctness.
func (d *nicPhysical) validateConfig() error {
- if d.instance.Type() != instance.TypeContainer {
+ if d.instance.Type() != instanceDBTypes.TypeContainer {
return ErrUnsupportedDevType
}
diff --git a/lxd/device/nic_sriov.go b/lxd/device/nic_sriov.go
index c63401acfa..213e451f0f 100644
--- a/lxd/device/nic_sriov.go
+++ b/lxd/device/nic_sriov.go
@@ -13,7 +13,7 @@ import (
"strings"
"time"
- "github.com/lxc/lxd/lxd/instance"
+ instanceDBTypes "github.com/lxc/lxd/lxd/instance/types"
"github.com/lxc/lxd/shared"
)
@@ -23,7 +23,7 @@ type nicSRIOV struct {
// validateConfig checks the supplied config for correctness.
func (d *nicSRIOV) validateConfig() error {
- if d.instance.Type() != instance.TypeContainer {
+ if d.instance.Type() != instanceDBTypes.TypeContainer {
return ErrUnsupportedDevType
}
diff --git a/lxd/device/proxy.go b/lxd/device/proxy.go
index 2efd0f9b09..854fc5672c 100644
--- a/lxd/device/proxy.go
+++ b/lxd/device/proxy.go
@@ -15,7 +15,7 @@ import (
"golang.org/x/sys/unix"
"gopkg.in/lxc/go-lxc.v2"
- "github.com/lxc/lxd/lxd/instance"
+ instanceDBTypes "github.com/lxc/lxd/lxd/instance/types"
"github.com/lxc/lxd/lxd/iptables"
"github.com/lxc/lxd/lxd/project"
"github.com/lxc/lxd/shared"
@@ -40,7 +40,7 @@ type proxyProcInfo struct {
// validateConfig checks the supplied config for correctness.
func (d *proxy) validateConfig() error {
- if d.instance.Type() != instance.TypeContainer {
+ if d.instance.Type() != instanceDBTypes.TypeContainer {
return ErrUnsupportedDevType
}
diff --git a/lxd/device/unix_common.go b/lxd/device/unix_common.go
index 09ae89dcdf..16c9dbfdfc 100644
--- a/lxd/device/unix_common.go
+++ b/lxd/device/unix_common.go
@@ -6,7 +6,7 @@ import (
"strings"
"github.com/lxc/lxd/lxd/device/config"
- "github.com/lxc/lxd/lxd/instance"
+ instanceDBTypes "github.com/lxc/lxd/lxd/instance/types"
"github.com/lxc/lxd/shared"
)
@@ -39,7 +39,7 @@ func (d *unixCommon) isRequired() bool {
// validateConfig checks the supplied config for correctness.
func (d *unixCommon) validateConfig() error {
- if d.instance.Type() != instance.TypeContainer {
+ if d.instance.Type() != instanceDBTypes.TypeContainer {
return ErrUnsupportedDevType
}
diff --git a/lxd/device/usb.go b/lxd/device/usb.go
index 4a1ad538f5..fe906190b7 100644
--- a/lxd/device/usb.go
+++ b/lxd/device/usb.go
@@ -8,7 +8,7 @@ import (
"strings"
"github.com/lxc/lxd/lxd/device/config"
- "github.com/lxc/lxd/lxd/instance"
+ instanceDBTypes "github.com/lxc/lxd/lxd/instance/types"
"github.com/lxc/lxd/shared"
)
@@ -43,7 +43,7 @@ func (d *usb) isRequired() bool {
// validateConfig checks the supplied config for correctness.
func (d *usb) validateConfig() error {
- if d.instance.Type() != instance.TypeContainer {
+ if d.instance.Type() != instanceDBTypes.TypeContainer {
return ErrUnsupportedDevType
}
diff --git a/lxd/images.go b/lxd/images.go
index e15cefbfb6..8525e09f33 100644
--- a/lxd/images.go
+++ b/lxd/images.go
@@ -28,7 +28,7 @@ import (
lxd "github.com/lxc/lxd/client"
"github.com/lxc/lxd/lxd/cluster"
"github.com/lxc/lxd/lxd/db"
- "github.com/lxc/lxd/lxd/instance"
+ instanceDBTypes "github.com/lxc/lxd/lxd/instance/types"
"github.com/lxc/lxd/lxd/node"
"github.com/lxc/lxd/lxd/state"
"github.com/lxc/lxd/lxd/task"
@@ -475,9 +475,9 @@ func getImgPostInfo(d *Daemon, r *http.Request, builddir string, project string,
}
if part.FormName() == "rootfs" {
- info.Type = instance.TypeContainer.String()
+ info.Type = instanceDBTypes.TypeContainer.String()
} else if part.FormName() == "rootfs.img" {
- info.Type = instance.TypeVM.String()
+ info.Type = instanceDBTypes.TypeVM.String()
} else {
logger.Error("Invalid multipart image")
return nil, fmt.Errorf("Invalid multipart image")
@@ -865,12 +865,12 @@ func getImageMetadata(fname string) (*api.ImageMetadata, string, error) {
if strings.HasPrefix(hdr.Name, "rootfs/") || strings.HasPrefix(hdr.Name, "./rootfs/") {
hasRoot = true
- imageType = instance.TypeContainer.String()
+ imageType = instanceDBTypes.TypeContainer.String()
}
if hdr.Name == "rootfs.img" || hdr.Name == "./rootfs.img" {
hasRoot = true
- imageType = instance.TypeVM.String()
+ imageType = instanceDBTypes.TypeVM.String()
}
if hasMeta && hasRoot {
diff --git a/lxd/instance/instance.go b/lxd/instance/types/instance_types.go
similarity index 100%
rename from lxd/instance/instance.go
rename to lxd/instance/types/instance_types.go
diff --git a/lxd/logging.go b/lxd/logging.go
index 162ad51a3d..c8ea74d407 100644
--- a/lxd/logging.go
+++ b/lxd/logging.go
@@ -7,7 +7,7 @@ import (
"time"
"github.com/lxc/lxd/lxd/db"
- "github.com/lxc/lxd/lxd/instance"
+ instanceDBTypes "github.com/lxc/lxd/lxd/instance/types"
"github.com/lxc/lxd/lxd/state"
"github.com/lxc/lxd/lxd/task"
"github.com/lxc/lxd/shared"
@@ -53,7 +53,7 @@ func expireLogs(ctx context.Context, state *state.State) error {
var containers []string
ch := make(chan struct{})
go func() {
- containers, err = state.Cluster.ContainersNodeList(instance.TypeContainer)
+ containers, err = state.Cluster.ContainersNodeList(instanceDBTypes.TypeContainer)
ch <- struct{}{}
}()
select {
diff --git a/lxd/main_activateifneeded.go b/lxd/main_activateifneeded.go
index 16196ef827..4220577e21 100644
--- a/lxd/main_activateifneeded.go
+++ b/lxd/main_activateifneeded.go
@@ -10,7 +10,7 @@ import (
lxd "github.com/lxc/lxd/client"
"github.com/lxc/lxd/lxd/db"
- "github.com/lxc/lxd/lxd/instance"
+ instanceDBTypes "github.com/lxc/lxd/lxd/instance/types"
"github.com/lxc/lxd/lxd/node"
"github.com/lxc/lxd/shared"
"github.com/lxc/lxd/shared/idmap"
@@ -112,7 +112,7 @@ func (c *cmdActivateifneeded) Run(cmd *cobra.Command, args []string) error {
var containers []db.Instance
err = d.cluster.Transaction(func(tx *db.ClusterTx) error {
- filter := db.InstanceFilter{Type: instance.TypeContainer}
+ filter := db.InstanceFilter{Type: instanceDBTypes.TypeContainer}
var err error
containers, err = tx.InstanceList(filter)
return err
diff --git a/lxd/response.go b/lxd/response.go
index 7bca1b4e17..deb24c7101 100644
--- a/lxd/response.go
+++ b/lxd/response.go
@@ -18,7 +18,7 @@ import (
lxd "github.com/lxc/lxd/client"
"github.com/lxc/lxd/lxd/cluster"
"github.com/lxc/lxd/lxd/db"
- "github.com/lxc/lxd/lxd/instance"
+ instanceDBTypes "github.com/lxc/lxd/lxd/instance/types"
"github.com/lxc/lxd/lxd/util"
"github.com/lxc/lxd/shared"
"github.com/lxc/lxd/shared/api"
@@ -192,7 +192,7 @@ func ForwardedResponseIfTargetIsRemote(d *Daemon, request *http.Request) Respons
// ForwardedResponseIfContainerIsRemote redirects a request to the node running
// the container with the given name. If the container is local, nothing gets
// done and nil is returned.
-func ForwardedResponseIfContainerIsRemote(d *Daemon, r *http.Request, project, name string, instanceType instance.Type) (Response, error) {
+func ForwardedResponseIfContainerIsRemote(d *Daemon, r *http.Request, project, name string, instanceType instanceDBTypes.Type) (Response, error) {
cert := d.endpoints.NetworkCert()
client, err := cluster.ConnectIfContainerIsRemote(d.cluster, project, name, cert, instanceType)
if err != nil {
diff --git a/lxd/storage_lvm_utils.go b/lxd/storage_lvm_utils.go
index 7ea61f13f2..aab5504a90 100644
--- a/lxd/storage_lvm_utils.go
+++ b/lxd/storage_lvm_utils.go
@@ -11,7 +11,7 @@ import (
"github.com/pkg/errors"
"github.com/lxc/lxd/lxd/db"
- "github.com/lxc/lxd/lxd/instance"
+ instanceDBTypes "github.com/lxc/lxd/lxd/instance/types"
"github.com/lxc/lxd/lxd/project"
"github.com/lxc/lxd/lxd/state"
driver "github.com/lxc/lxd/lxd/storage"
@@ -722,7 +722,7 @@ func storageLVMThinpoolExists(vgName string, poolName string) (bool, error) {
func storageLVMGetThinPoolUsers(s *state.State) ([]string, error) {
results := []string{}
- cNames, err := s.Cluster.ContainersNodeList(instance.TypeContainer)
+ cNames, err := s.Cluster.ContainersNodeList(instanceDBTypes.TypeContainer)
if err != nil {
return results, err
}
diff --git a/lxd/storage_migration.go b/lxd/storage_migration.go
index 218458d118..fcb5d8a143 100644
--- a/lxd/storage_migration.go
+++ b/lxd/storage_migration.go
@@ -8,7 +8,7 @@ import (
"github.com/lxc/lxd/lxd/db"
deviceConfig "github.com/lxc/lxd/lxd/device/config"
- "github.com/lxc/lxd/lxd/instance"
+ instanceDBTypes "github.com/lxc/lxd/lxd/instance/types"
"github.com/lxc/lxd/lxd/migration"
"github.com/lxc/lxd/lxd/project"
driver "github.com/lxc/lxd/lxd/storage"
@@ -199,7 +199,7 @@ func snapshotProtobufToContainerArgs(project string, containerName string, snap
args := db.ContainerArgs{
Architecture: int(snap.GetArchitecture()),
Config: config,
- Type: instance.TypeContainer,
+ Type: instanceDBTypes.TypeContainer,
Snapshot: true,
Devices: devices,
Ephemeral: snap.GetEphemeral(),
More information about the lxc-devel
mailing list