Add Checkpoint properties
This commit is contained in:
parent
ff4ee87140
commit
79378fe268
2 changed files with 49 additions and 1 deletions
|
@ -2,9 +2,26 @@ package gonetworkmanager
|
||||||
|
|
||||||
import "github.com/godbus/dbus"
|
import "github.com/godbus/dbus"
|
||||||
|
|
||||||
type Checkpoint interface {
|
const (
|
||||||
|
CheckpointInterface = NetworkManagerInterface + ".Checkpoint"
|
||||||
|
|
||||||
|
/* Properties */
|
||||||
|
CheckpointPropertyDevices = CheckpointInterface + ".Devices" // readable ao
|
||||||
|
CheckpointPropertyCreated = CheckpointInterface + ".Created" // readable x
|
||||||
|
CheckpointPropertyRollbackTimeout = CheckpointInterface + ".RollbackTimeout" // readable u
|
||||||
|
)
|
||||||
|
|
||||||
|
type Checkpoint interface {
|
||||||
GetPath() dbus.ObjectPath
|
GetPath() dbus.ObjectPath
|
||||||
|
|
||||||
|
// Array of object paths for devices which are part of this checkpoint.
|
||||||
|
GetPropertyDevices() []Device
|
||||||
|
|
||||||
|
// The timestamp (in CLOCK_BOOTTIME milliseconds) of checkpoint creation.
|
||||||
|
GetPropertyCreated() int64
|
||||||
|
|
||||||
|
// Timeout in seconds for automatic rollback, or zero.
|
||||||
|
GetPropertyRollbackTimeout() uint32
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewCheckpoint(objectPath dbus.ObjectPath) (Checkpoint, error) {
|
func NewCheckpoint(objectPath dbus.ObjectPath) (Checkpoint, error) {
|
||||||
|
@ -16,6 +33,29 @@ type checkpoint struct {
|
||||||
dbusBase
|
dbusBase
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *checkpoint) GetPropertyDevices() []Device {
|
||||||
|
devicesPaths := c.getSliceObjectProperty(CheckpointPropertyDevices)
|
||||||
|
devices := make([]Device, len(devicesPaths))
|
||||||
|
|
||||||
|
var err error
|
||||||
|
for i, path := range devicesPaths {
|
||||||
|
devices[i], err = NewDevice(path)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return devices
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *checkpoint) GetPropertyCreated() int64 {
|
||||||
|
return c.getInt64Property(CheckpointPropertyCreated)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *checkpoint) GetPropertyRollbackTimeout() uint32 {
|
||||||
|
return c.getUint32Property(CheckpointPropertyRollbackTimeout)
|
||||||
|
}
|
||||||
|
|
||||||
func (c *checkpoint) GetPath() dbus.ObjectPath {
|
func (c *checkpoint) GetPath() dbus.ObjectPath {
|
||||||
return c.obj.Path()
|
return c.obj.Path()
|
||||||
}
|
}
|
||||||
|
|
8
utils.go
8
utils.go
|
@ -140,6 +140,14 @@ func (d *dbusBase) getUint32Property(iface string) uint32 {
|
||||||
return value
|
return value
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (d *dbusBase) getInt64Property(iface string) int64 {
|
||||||
|
value, ok := d.getProperty(iface).(int64)
|
||||||
|
if !ok {
|
||||||
|
panic(makeErrVariantType(iface))
|
||||||
|
}
|
||||||
|
return value
|
||||||
|
}
|
||||||
|
|
||||||
func (d *dbusBase) getSliceUint32Property(iface string) []uint32 {
|
func (d *dbusBase) getSliceUint32Property(iface string) []uint32 {
|
||||||
value, ok := d.getProperty(iface).([]uint32)
|
value, ok := d.getProperty(iface).([]uint32)
|
||||||
if !ok {
|
if !ok {
|
||||||
|
|
Reference in a new issue