Skip to content
Permalink
Browse files

new: added unreachable property to enforcer (#313)

  • Loading branch information...
primalmotion committed May 2, 2019
1 parent a9a529d commit 1d51c4be06dbf402a7bad464b4f228e94fb09fa9
Showing with 63 additions and 9 deletions.
  1. +6 −1 doc/documentation.md
  2. +47 −7 enforcer.go
  3. +10 −1 specs/enforcer.spec
@@ -1406,7 +1406,7 @@ Namespace tag attached to an entity.

NormalizedTags contains the list of normalized tags of the entities.

##### `operationalStatus` `emum(Registered | Connected | Disconnected | Initialized | Unknown)`
##### `operationalStatus` `emum(Registered | Connected | Disconnected | Initialized)`

OperationalStatus tells the status of the enforcer.

@@ -1430,6 +1430,11 @@ datapath and its signed by the private CA.
startTime holds the time this enforcerd was started. This time-stamp is reported
by the enforcer and is is preserved across disconnects.

##### `unreachable` `boolean` [`autogenerated`,`read_only`]

Control plane will set this value to true if it hasn't heard from the enforcer
for more than 5m.

##### `updateAvailable` `boolean`

Tells if the the version of enforcerd is outdated and should be updated.
@@ -37,9 +37,6 @@ const (

// EnforcerOperationalStatusRegistered represents the value Registered.
EnforcerOperationalStatusRegistered EnforcerOperationalStatusValue = "Registered"

// EnforcerOperationalStatusUnknown represents the value Unknown.
EnforcerOperationalStatusUnknown EnforcerOperationalStatusValue = "Unknown"
)

// EnforcerIdentity represents the Identity of the object.
@@ -218,6 +215,10 @@ type Enforcer struct {
// by the enforcer and is is preserved across disconnects.
StartTime time.Time `json:"startTime" msgpack:"startTime" bson:"starttime" mapstructure:"startTime,omitempty"`

// Control plane will set this value to true if it hasn't heard from the enforcer
// for more than 5m.
Unreachable bool `json:"unreachable" msgpack:"unreachable" bson:"unreachable" mapstructure:"unreachable,omitempty"`

// Tells if the the version of enforcerd is outdated and should be updated.
UpdateAvailable bool `json:"updateAvailable" msgpack:"updateAvailable" bson:"updateavailable" mapstructure:"updateAvailable,omitempty"`

@@ -249,8 +250,8 @@ func NewEnforcer() *Enforcer {
EnforcementStatus: EnforcerEnforcementStatusInactive,
NormalizedTags: []string{},
OperationalStatus: EnforcerOperationalStatusRegistered,
LastValidHostServices: HostServicesList{},
Metadata: []string{},
LastValidHostServices: HostServicesList{},
}
}

@@ -504,6 +505,7 @@ func (o *Enforcer) ToSparse(fields ...string) elemental.SparseIdentifiable {
Protected: &o.Protected,
PublicToken: &o.PublicToken,
StartTime: &o.StartTime,
Unreachable: &o.Unreachable,
UpdateAvailable: &o.UpdateAvailable,
UpdateIdempotencyKey: &o.UpdateIdempotencyKey,
UpdateTime: &o.UpdateTime,
@@ -573,6 +575,8 @@ func (o *Enforcer) ToSparse(fields ...string) elemental.SparseIdentifiable {
sp.PublicToken = &(o.PublicToken)
case "startTime":
sp.StartTime = &(o.StartTime)
case "unreachable":
sp.Unreachable = &(o.Unreachable)
case "updateAvailable":
sp.UpdateAvailable = &(o.UpdateAvailable)
case "updateIdempotencyKey":
@@ -683,6 +687,9 @@ func (o *Enforcer) Patch(sparse elemental.SparseIdentifiable) {
if so.StartTime != nil {
o.StartTime = *so.StartTime
}
if so.Unreachable != nil {
o.Unreachable = *so.Unreachable
}
if so.UpdateAvailable != nil {
o.UpdateAvailable = *so.UpdateAvailable
}
@@ -758,7 +765,7 @@ func (o *Enforcer) Validate() error {
errors = errors.Append(err)
}

if err := elemental.ValidateStringInList("operationalStatus", string(o.OperationalStatus), []string{"Registered", "Connected", "Disconnected", "Initialized", "Unknown"}, false); err != nil {
if err := elemental.ValidateStringInList("operationalStatus", string(o.OperationalStatus), []string{"Registered", "Connected", "Disconnected", "Initialized"}, false); err != nil {
errors = errors.Append(err)
}

@@ -854,6 +861,8 @@ func (o *Enforcer) ValueForAttribute(name string) interface{} {
return o.PublicToken
case "startTime":
return o.StartTime
case "unreachable":
return o.Unreachable
case "updateAvailable":
return o.UpdateAvailable
case "updateIdempotencyKey":
@@ -1172,7 +1181,7 @@ with the '@' prefix, and should only be used by external systems.`,
Type: "list",
},
"OperationalStatus": elemental.AttributeSpecification{
AllowedChoices: []string{"Registered", "Connected", "Disconnected", "Initialized", "Unknown"},
AllowedChoices: []string{"Registered", "Connected", "Disconnected", "Initialized"},
ConvertedName: "OperationalStatus",
DefaultValue: EnforcerOperationalStatusRegistered,
Description: `OperationalStatus tells the status of the enforcer.`,
@@ -1218,6 +1227,18 @@ by the enforcer and is is preserved across disconnects.`,
Stored: true,
Type: "time",
},
"Unreachable": elemental.AttributeSpecification{
AllowedChoices: []string{},
Autogenerated: true,
ConvertedName: "Unreachable",
Description: `Control plane will set this value to true if it hasn't heard from the enforcer
for more than 5m.`,
Exposed: true,
Name: "unreachable",
ReadOnly: true,
Stored: true,
Type: "boolean",
},
"UpdateAvailable": elemental.AttributeSpecification{
AllowedChoices: []string{},
ConvertedName: "UpdateAvailable",
@@ -1585,7 +1606,7 @@ with the '@' prefix, and should only be used by external systems.`,
Type: "list",
},
"operationalstatus": elemental.AttributeSpecification{
AllowedChoices: []string{"Registered", "Connected", "Disconnected", "Initialized", "Unknown"},
AllowedChoices: []string{"Registered", "Connected", "Disconnected", "Initialized"},
ConvertedName: "OperationalStatus",
DefaultValue: EnforcerOperationalStatusRegistered,
Description: `OperationalStatus tells the status of the enforcer.`,
@@ -1631,6 +1652,18 @@ by the enforcer and is is preserved across disconnects.`,
Stored: true,
Type: "time",
},
"unreachable": elemental.AttributeSpecification{
AllowedChoices: []string{},
Autogenerated: true,
ConvertedName: "Unreachable",
Description: `Control plane will set this value to true if it hasn't heard from the enforcer
for more than 5m.`,
Exposed: true,
Name: "unreachable",
ReadOnly: true,
Stored: true,
Type: "boolean",
},
"updateavailable": elemental.AttributeSpecification{
AllowedChoices: []string{},
ConvertedName: "UpdateAvailable",
@@ -1862,6 +1895,10 @@ type SparseEnforcer struct {
// by the enforcer and is is preserved across disconnects.
StartTime *time.Time `json:"startTime,omitempty" msgpack:"startTime,omitempty" bson:"starttime,omitempty" mapstructure:"startTime,omitempty"`

// Control plane will set this value to true if it hasn't heard from the enforcer
// for more than 5m.
Unreachable *bool `json:"unreachable,omitempty" msgpack:"unreachable,omitempty" bson:"unreachable,omitempty" mapstructure:"unreachable,omitempty"`

// Tells if the the version of enforcerd is outdated and should be updated.
UpdateAvailable *bool `json:"updateAvailable,omitempty" msgpack:"updateAvailable,omitempty" bson:"updateavailable,omitempty" mapstructure:"updateAvailable,omitempty"`

@@ -2005,6 +2042,9 @@ func (o *SparseEnforcer) ToPlain() elemental.PlainIdentifiable {
if o.StartTime != nil {
out.StartTime = *o.StartTime
}
if o.Unreachable != nil {
out.Unreachable = *o.Unreachable
}
if o.UpdateAvailable != nil {
out.UpdateAvailable = *o.UpdateAvailable
}
@@ -187,7 +187,6 @@ attributes:
- Connected
- Disconnected
- Initialized
- Unknown
default_value: Registered
filterable: true

@@ -211,6 +210,16 @@ attributes:
stored: true
orderable: true

- name: unreachable
description: |-
Control plane will set this value to true if it hasn't heard from the enforcer
for more than 5m.
type: boolean
exposed: true
stored: true
read_only: true
autogenerated: true

- name: updateAvailable
description: Tells if the the version of enforcerd is outdated and should be updated.
type: boolean

0 comments on commit 1d51c4b

Please sign in to comment.
You can’t perform that action at this time.