Skip to content

Commit

Permalink
DB Table Rename
Browse files Browse the repository at this point in the history
Signed-off-by: Peter Sabaini <[email protected]>
  • Loading branch information
sabaini committed Nov 2, 2023
1 parent b9fe220 commit 82099f8
Show file tree
Hide file tree
Showing 6 changed files with 427 additions and 386 deletions.
4 changes: 2 additions & 2 deletions microceph/ceph/osd.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ func AddOSD(s *state.State, data types.DiskParameter, wal *types.DiskParameter,
// Record the disk.
var nr int64
err = s.Database.Transaction(s.Context, func(ctx context.Context, tx *sql.Tx) error {
nr, err = database.CreateDiskPath(ctx, tx, database.DiskPath{Member: s.Name(), Path: data.Path})
nr, err = database.CreateDisk(ctx, tx, database.Disk{Member: s.Name(), Path: data.Path})
if err != nil {
return fmt.Errorf("Failed to record disk: %w", err)
}
Expand All @@ -332,7 +332,7 @@ func AddOSD(s *state.State, data types.DiskParameter, wal *types.DiskParameter,
revert.Add(func() {
os.RemoveAll(osdDataPath)
s.Database.Transaction(s.Context, func(ctx context.Context, tx *sql.Tx) error {
database.DeleteDiskPath(ctx, tx, s.Name(), data.Path)
database.DeleteDisk(ctx, tx, s.Name(), data.Path)
return nil
})
})
Expand Down
44 changes: 22 additions & 22 deletions microceph/database/diskpath.go → microceph/database/disk.go
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
package database

//go:generate -command mapper lxd-generate db mapper -t diskpath.mapper.go
//go:generate -command mapper lxd-generate db mapper -t disk.mapper.go
//go:generate mapper reset
//
//go:generate mapper stmt -d github.com/canonical/microcluster/cluster -e DiskPath objects table=diskpaths
//go:generate mapper stmt -d github.com/canonical/microcluster/cluster -e DiskPath objects-by-Member table=diskpaths
//go:generate mapper stmt -d github.com/canonical/microcluster/cluster -e DiskPath objects-by-Member-and-Path table=diskpaths
//go:generate mapper stmt -d github.com/canonical/microcluster/cluster -e DiskPath id table=diskpaths
//go:generate mapper stmt -d github.com/canonical/microcluster/cluster -e DiskPath create table=diskpaths
//go:generate mapper stmt -d github.com/canonical/microcluster/cluster -e DiskPath delete-by-Member table=diskpaths
//go:generate mapper stmt -d github.com/canonical/microcluster/cluster -e DiskPath delete-by-Member-and-Path table=diskpaths
//go:generate mapper stmt -d github.com/canonical/microcluster/cluster -e DiskPath update table=diskpaths
//go:generate mapper stmt -d github.com/canonical/microcluster/cluster -e Disk objects table=Disks
//go:generate mapper stmt -d github.com/canonical/microcluster/cluster -e Disk objects-by-Member table=Disks
//go:generate mapper stmt -d github.com/canonical/microcluster/cluster -e Disk objects-by-Member-and-Path table=Disks
//go:generate mapper stmt -d github.com/canonical/microcluster/cluster -e Disk id table=Disks
//go:generate mapper stmt -d github.com/canonical/microcluster/cluster -e Disk create table=Disks
//go:generate mapper stmt -d github.com/canonical/microcluster/cluster -e Disk delete-by-Member table=Disks
//go:generate mapper stmt -d github.com/canonical/microcluster/cluster -e Disk delete-by-Member-and-Path table=Disks
//go:generate mapper stmt -d github.com/canonical/microcluster/cluster -e Disk update table=Disks
//
//go:generate mapper method -i -d github.com/canonical/microcluster/cluster -e DiskPath GetMany
//go:generate mapper method -i -d github.com/canonical/microcluster/cluster -e DiskPath GetOne
//go:generate mapper method -i -d github.com/canonical/microcluster/cluster -e DiskPath ID
//go:generate mapper method -i -d github.com/canonical/microcluster/cluster -e DiskPath Exists
//go:generate mapper method -i -d github.com/canonical/microcluster/cluster -e DiskPath Create
//go:generate mapper method -i -d github.com/canonical/microcluster/cluster -e DiskPath DeleteOne-by-Member-and-Path
//go:generate mapper method -i -d github.com/canonical/microcluster/cluster -e DiskPath DeleteMany-by-Member
//go:generate mapper method -i -d github.com/canonical/microcluster/cluster -e DiskPath Update
//go:generate mapper method -i -d github.com/canonical/microcluster/cluster -e Disk GetMany
//go:generate mapper method -i -d github.com/canonical/microcluster/cluster -e Disk GetOne
//go:generate mapper method -i -d github.com/canonical/microcluster/cluster -e Disk ID
//go:generate mapper method -i -d github.com/canonical/microcluster/cluster -e Disk Exists
//go:generate mapper method -i -d github.com/canonical/microcluster/cluster -e Disk Create
//go:generate mapper method -i -d github.com/canonical/microcluster/cluster -e Disk DeleteOne-by-Member-and-Path
//go:generate mapper method -i -d github.com/canonical/microcluster/cluster -e Disk DeleteMany-by-Member
//go:generate mapper method -i -d github.com/canonical/microcluster/cluster -e Disk Update

// DiskPath is used to track the Ceph disks on a particular server.
type DiskPath struct {
// Disk is used to track the Ceph disks on a particular server.
type Disk struct {
ID int
Member string `db:"primary=yes&join=internal_cluster_members.name&joinon=diskpaths.member_id"`
Member string `db:"primary=yes&join=internal_cluster_members.name&joinon=Disks.member_id"`
Path string `db:"primary=yes"`
}

// DiskPathFilter is a required struct for use with lxd-generate. It is used for filtering fields on database fetches.
type DiskPathFilter struct {
// DiskFilter is a required struct for use with lxd-generate. It is used for filtering fields on database fetches.
type DiskFilter struct {
Member *string
Path *string
}
Loading

0 comments on commit 82099f8

Please sign in to comment.