diff --git a/cmd/ignite-spawn/ignite-spawn.go b/cmd/ignite-spawn/ignite-spawn.go
index 331e26860..88ad2908e 100644
--- a/cmd/ignite-spawn/ignite-spawn.go
+++ b/cmd/ignite-spawn/ignite-spawn.go
@@ -101,6 +101,7 @@ func patchStopped(vm *api.VM) error {
patchVM.Status.Running = false
patchVM.Status.IPAddresses = nil
patchVM.Status.Runtime = nil
+ patchVM.Status.StartTime = nil
return nil
})
}
diff --git a/cmd/ignite/run/ps.go b/cmd/ignite/run/ps.go
index 4c7a8f180..e78212a16 100644
--- a/cmd/ignite/run/ps.go
+++ b/cmd/ignite/run/ps.go
@@ -1,6 +1,8 @@
package run
import (
+ "fmt"
+
api "github.com/weaveworks/ignite/pkg/apis/ignite"
"github.com/weaveworks/ignite/pkg/filter"
"github.com/weaveworks/ignite/pkg/providers"
@@ -26,12 +28,22 @@ func Ps(po *psOptions) error {
o := util.NewOutput()
defer o.Flush()
- o.Write("VM ID", "IMAGE", "KERNEL", "CREATED", "SIZE", "CPUS", "MEMORY", "RUNNING", "IPS", "PORTS", "NAME")
+ o.Write("VM ID", "IMAGE", "KERNEL", "SIZE", "CPUS", "MEMORY", "CREATED", "STATUS", "IPS", "PORTS", "NAME")
for _, vm := range po.allVMs {
- o.Write(vm.GetUID(), vm.Spec.Image.OCIClaim.Ref, vm.Spec.Kernel.OCIClaim.Ref, vm.GetCreated(),
- vm.Spec.DiskSize, vm.Spec.CPUs, vm.Spec.Memory, vm.Running(), vm.Status.IPAddresses,
+ o.Write(vm.GetUID(), vm.Spec.Image.OCIClaim.Ref, vm.Spec.Kernel.OCIClaim.Ref,
+ vm.Spec.DiskSize, vm.Spec.CPUs, vm.Spec.Memory, vm.GetCreated(), formatStatus(vm), vm.Status.IPAddresses,
vm.Spec.Network.Ports, vm.GetName())
}
return nil
}
+
+func formatStatus(vm *api.VM) (s string) {
+ if vm.Running() {
+ s = fmt.Sprintf("Up %s", vm.Status.StartTime)
+ } else {
+ s = "Stopped"
+ }
+
+ return
+}
diff --git a/docs/api/ignite_v1alpha2.md b/docs/api/ignite_v1alpha2.md
index 39804e14e..cb0e35c0f 100644
--- a/docs/api/ignite_v1alpha2.md
+++ b/docs/api/ignite_v1alpha2.md
@@ -496,12 +496,13 @@ type VMSpec struct {
VMSpec describes the configuration of a VM
-## type [VMStatus](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/types.go?s=9422:9702#L266)
+## type [VMStatus](https://github.com/weaveworks/ignite/tree/master/pkg/apis/ignite/v1alpha2/types.go?s=9422:9761#L266)
``` go
type VMStatus struct {
Running bool `json:"running"`
Runtime *Runtime `json:"runtime,omitempty"`
+ StartTime *meta.Time `json:"startTime,omitempty"`
IPAddresses meta.IPAddresses `json:"ipAddresses,omitempty"`
Image OCIImageSource `json:"image"`
Kernel OCIImageSource `json:"kernel"`
diff --git a/pkg/apis/ignite/types.go b/pkg/apis/ignite/types.go
index db201f6f9..cfc862635 100644
--- a/pkg/apis/ignite/types.go
+++ b/pkg/apis/ignite/types.go
@@ -266,6 +266,7 @@ type Runtime struct {
type VMStatus struct {
Running bool `json:"running"`
Runtime *Runtime `json:"runtime,omitempty"`
+ StartTime *meta.Time `json:"startTime,omitempty"`
IPAddresses meta.IPAddresses `json:"ipAddresses,omitempty"`
Image OCIImageSource `json:"image"`
Kernel OCIImageSource `json:"kernel"`
diff --git a/pkg/apis/ignite/v1alpha1/zz_generated.conversion.go b/pkg/apis/ignite/v1alpha1/zz_generated.conversion.go
index 2ed73a373..7fb3f107e 100644
--- a/pkg/apis/ignite/v1alpha1/zz_generated.conversion.go
+++ b/pkg/apis/ignite/v1alpha1/zz_generated.conversion.go
@@ -763,6 +763,7 @@ func autoConvert_v1alpha1_VMStatus_To_ignite_VMStatus(in *VMStatus, out *ignite.
func autoConvert_ignite_VMStatus_To_v1alpha1_VMStatus(in *ignite.VMStatus, out *VMStatus, s conversion.Scope) error {
// WARNING: in.Running requires manual conversion: does not exist in peer-type
// WARNING: in.Runtime requires manual conversion: does not exist in peer-type
+ // WARNING: in.StartTime requires manual conversion: does not exist in peer-type
out.IPAddresses = *(*metav1alpha1.IPAddresses)(unsafe.Pointer(&in.IPAddresses))
if err := Convert_ignite_OCIImageSource_To_v1alpha1_OCIImageSource(&in.Image, &out.Image, s); err != nil {
return err
diff --git a/pkg/apis/ignite/v1alpha2/types.go b/pkg/apis/ignite/v1alpha2/types.go
index 5a4aba74a..2002656e5 100644
--- a/pkg/apis/ignite/v1alpha2/types.go
+++ b/pkg/apis/ignite/v1alpha2/types.go
@@ -266,6 +266,7 @@ type Runtime struct {
type VMStatus struct {
Running bool `json:"running"`
Runtime *Runtime `json:"runtime,omitempty"`
+ StartTime *meta.Time `json:"startTime,omitempty"`
IPAddresses meta.IPAddresses `json:"ipAddresses,omitempty"`
Image OCIImageSource `json:"image"`
Kernel OCIImageSource `json:"kernel"`
diff --git a/pkg/apis/ignite/v1alpha2/zz_generated.conversion.go b/pkg/apis/ignite/v1alpha2/zz_generated.conversion.go
index 9f71e6a91..9208be57e 100644
--- a/pkg/apis/ignite/v1alpha2/zz_generated.conversion.go
+++ b/pkg/apis/ignite/v1alpha2/zz_generated.conversion.go
@@ -836,6 +836,7 @@ func Convert_ignite_VMSpec_To_v1alpha2_VMSpec(in *ignite.VMSpec, out *VMSpec, s
func autoConvert_v1alpha2_VMStatus_To_ignite_VMStatus(in *VMStatus, out *ignite.VMStatus, s conversion.Scope) error {
out.Running = in.Running
out.Runtime = (*ignite.Runtime)(unsafe.Pointer(in.Runtime))
+ out.StartTime = (*v1alpha1.Time)(unsafe.Pointer(in.StartTime))
out.IPAddresses = *(*v1alpha1.IPAddresses)(unsafe.Pointer(&in.IPAddresses))
if err := Convert_v1alpha2_OCIImageSource_To_ignite_OCIImageSource(&in.Image, &out.Image, s); err != nil {
return err
@@ -854,6 +855,7 @@ func Convert_v1alpha2_VMStatus_To_ignite_VMStatus(in *VMStatus, out *ignite.VMSt
func autoConvert_ignite_VMStatus_To_v1alpha2_VMStatus(in *ignite.VMStatus, out *VMStatus, s conversion.Scope) error {
out.Running = in.Running
out.Runtime = (*Runtime)(unsafe.Pointer(in.Runtime))
+ out.StartTime = (*v1alpha1.Time)(unsafe.Pointer(in.StartTime))
out.IPAddresses = *(*v1alpha1.IPAddresses)(unsafe.Pointer(&in.IPAddresses))
if err := Convert_ignite_OCIImageSource_To_v1alpha2_OCIImageSource(&in.Image, &out.Image, s); err != nil {
return err
diff --git a/pkg/apis/ignite/v1alpha2/zz_generated.deepcopy.go b/pkg/apis/ignite/v1alpha2/zz_generated.deepcopy.go
index b5f33cc8f..aff460033 100644
--- a/pkg/apis/ignite/v1alpha2/zz_generated.deepcopy.go
+++ b/pkg/apis/ignite/v1alpha2/zz_generated.deepcopy.go
@@ -451,6 +451,11 @@ func (in *VMStatus) DeepCopyInto(out *VMStatus) {
*out = new(Runtime)
**out = **in
}
+ if in.StartTime != nil {
+ in, out := &in.StartTime, &out.StartTime
+ *out = new(v1alpha1.Time)
+ (*in).DeepCopyInto(*out)
+ }
if in.IPAddresses != nil {
in, out := &in.IPAddresses, &out.IPAddresses
*out = make(v1alpha1.IPAddresses, len(*in))
diff --git a/pkg/apis/ignite/zz_generated.deepcopy.go b/pkg/apis/ignite/zz_generated.deepcopy.go
index f4ddc1f97..7d95e39ff 100644
--- a/pkg/apis/ignite/zz_generated.deepcopy.go
+++ b/pkg/apis/ignite/zz_generated.deepcopy.go
@@ -451,6 +451,11 @@ func (in *VMStatus) DeepCopyInto(out *VMStatus) {
*out = new(Runtime)
**out = **in
}
+ if in.StartTime != nil {
+ in, out := &in.StartTime, &out.StartTime
+ *out = new(v1alpha1.Time)
+ (*in).DeepCopyInto(*out)
+ }
if in.IPAddresses != nil {
in, out := &in.IPAddresses, &out.IPAddresses
*out = make(v1alpha1.IPAddresses, len(*in))
diff --git a/pkg/openapi/openapi_generated.go b/pkg/openapi/openapi_generated.go
index 660904fe0..f4c6b0111 100644
--- a/pkg/openapi/openapi_generated.go
+++ b/pkg/openapi/openapi_generated.go
@@ -1382,6 +1382,11 @@ func schema_pkg_apis_ignite_v1alpha2_VMStatus(ref common.ReferenceCallback) comm
Ref: ref("github.com/weaveworks/ignite/pkg/apis/ignite/v1alpha2.Runtime"),
},
},
+ "startTime": {
+ SchemaProps: spec.SchemaProps{
+ Ref: ref("github.com/weaveworks/ignite/pkg/apis/meta/v1alpha1.Time"),
+ },
+ },
"ipAddresses": {
SchemaProps: spec.SchemaProps{
Type: []string{"array"},
@@ -1410,7 +1415,7 @@ func schema_pkg_apis_ignite_v1alpha2_VMStatus(ref common.ReferenceCallback) comm
},
},
Dependencies: []string{
- "github.com/weaveworks/ignite/pkg/apis/ignite/v1alpha2.OCIImageSource", "github.com/weaveworks/ignite/pkg/apis/ignite/v1alpha2.Runtime"},
+ "github.com/weaveworks/ignite/pkg/apis/ignite/v1alpha2.OCIImageSource", "github.com/weaveworks/ignite/pkg/apis/ignite/v1alpha2.Runtime", "github.com/weaveworks/ignite/pkg/apis/meta/v1alpha1.Time"},
}
}
diff --git a/pkg/operations/start.go b/pkg/operations/start.go
index 6b26b22b6..e904b6cdc 100644
--- a/pkg/operations/start.go
+++ b/pkg/operations/start.go
@@ -10,6 +10,7 @@ import (
log "github.com/sirupsen/logrus"
api "github.com/weaveworks/ignite/pkg/apis/ignite"
+ meta "github.com/weaveworks/ignite/pkg/apis/meta/v1alpha1"
"github.com/weaveworks/ignite/pkg/constants"
"github.com/weaveworks/ignite/pkg/dmlegacy"
"github.com/weaveworks/ignite/pkg/logs"
@@ -110,6 +111,10 @@ func StartVM(vm *api.VM, debug bool) error {
// Set the container ID for the VM
vm.Status.Runtime = &api.Runtime{ID: containerID}
+ // Set the start time for the VM
+ startTime := meta.Timestamp()
+ vm.Status.StartTime = &startTime
+
if vm.Spec.Network.Mode == api.NetworkModeCNI {
if err := providers.NetworkPlugin.SetupContainerNetwork(containerID); err != nil {
return err