github.com/vmware/govmomi@v0.43.0/simulator/vpx/alarm_manager.go (about)

     1  /*
     2  Copyright (c) 2024-2024 VMware, Inc. All Rights Reserved.
     3  
     4  Licensed under the Apache License, Version 2.0 (the "License");
     5  you may not use this file except in compliance with the License.
     6  You may obtain a copy of the License at
     7  
     8  http://www.apache.org/licenses/LICENSE-2.0
     9  
    10  Unless required by applicable law or agreed to in writing, software
    11  distributed under the License is distributed on an "AS IS" BASIS,
    12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  See the License for the specific language governing permissions and
    14  limitations under the License.
    15  */
    16  
    17  package vpx
    18  
    19  import (
    20  	"time"
    21  
    22  	"github.com/vmware/govmomi/vim25/mo"
    23  	"github.com/vmware/govmomi/vim25/types"
    24  )
    25  
    26  // Alarm captured using:
    27  // govc alarm.info -dump -n alarm.VmErrorAlarm -n alarm.HostErrorAlarm
    28  var Alarm = []mo.Alarm{
    29  	{
    30  		ExtensibleManagedObject: mo.ExtensibleManagedObject{
    31  			Self:           types.ManagedObjectReference{Type: "Alarm", Value: "alarm-384", ServerGUID: ""},
    32  			Value:          nil,
    33  			AvailableField: nil,
    34  		},
    35  		Info: types.AlarmInfo{
    36  			AlarmSpec: types.AlarmSpec{
    37  				Name:        "vcsim VM Alarm",
    38  				SystemName:  "",
    39  				Description: "vcsim alarm for Virtual Machines",
    40  				Enabled:     true,
    41  				Expression: &types.OrAlarmExpression{
    42  					AlarmExpression: types.AlarmExpression{},
    43  					Expression: []types.BaseAlarmExpression{
    44  						&types.EventAlarmExpression{
    45  							AlarmExpression: types.AlarmExpression{},
    46  							Comparisons:     nil,
    47  							EventType:       "EventEx",
    48  							EventTypeId:     "vcsim.vm.success",
    49  							ObjectType:      "VirtualMachine",
    50  							Status:          "green",
    51  						},
    52  						&types.EventAlarmExpression{
    53  							AlarmExpression: types.AlarmExpression{},
    54  							Comparisons:     nil,
    55  							EventType:       "EventEx",
    56  							EventTypeId:     "vcsim.vm.failure",
    57  							ObjectType:      "VirtualMachine",
    58  							Status:          "yellow",
    59  						},
    60  						&types.EventAlarmExpression{
    61  							AlarmExpression: types.AlarmExpression{},
    62  							Comparisons:     nil,
    63  							EventType:       "EventEx",
    64  							EventTypeId:     "vcsim.vm.fatal",
    65  							ObjectType:      "VirtualMachine",
    66  							Status:          "red",
    67  						},
    68  					},
    69  				},
    70  				Action:          nil,
    71  				ActionFrequency: 0,
    72  				Setting: &types.AlarmSetting{
    73  					ToleranceRange:     0,
    74  					ReportingFrequency: 300,
    75  				},
    76  			},
    77  			Key:              "",
    78  			Alarm:            types.ManagedObjectReference{Type: "Alarm", Value: "alarm-384", ServerGUID: ""},
    79  			Entity:           types.ManagedObjectReference{Type: "Folder", Value: "group-d1", ServerGUID: ""},
    80  			LastModifiedTime: time.Now(),
    81  			LastModifiedUser: "VSPHERE.LOCAL\\Administrator",
    82  			CreationEventId:  0,
    83  		},
    84  	},
    85  	{
    86  		ExtensibleManagedObject: mo.ExtensibleManagedObject{
    87  			Self:           types.ManagedObjectReference{Type: "Alarm", Value: "alarm-11", ServerGUID: ""},
    88  			Value:          nil,
    89  			AvailableField: nil,
    90  		},
    91  		Info: types.AlarmInfo{
    92  			AlarmSpec: types.AlarmSpec{
    93  				Name:        "Host error",
    94  				SystemName:  "alarm.HostErrorAlarm",
    95  				Description: "Default alarm to monitor host error and warning events",
    96  				Enabled:     true,
    97  				Expression: &types.OrAlarmExpression{
    98  					AlarmExpression: types.AlarmExpression{},
    99  					Expression: []types.BaseAlarmExpression{
   100  						&types.EventAlarmExpression{
   101  							AlarmExpression: types.AlarmExpression{},
   102  							Comparisons:     nil,
   103  							EventType:       "GeneralHostErrorEvent",
   104  							EventTypeId:     "",
   105  							ObjectType:      "HostSystem",
   106  							Status:          "",
   107  						},
   108  						&types.EventAlarmExpression{
   109  							AlarmExpression: types.AlarmExpression{},
   110  							Comparisons:     nil,
   111  							EventType:       "GeneralHostWarningEvent",
   112  							EventTypeId:     "",
   113  							ObjectType:      "HostSystem",
   114  							Status:          "",
   115  						},
   116  					},
   117  				},
   118  				Action: &types.GroupAlarmAction{
   119  					AlarmAction: types.AlarmAction{},
   120  					Action: []types.BaseAlarmAction{
   121  						&types.AlarmTriggeringAction{
   122  							AlarmAction: types.AlarmAction{},
   123  							Action:      &types.SendSNMPAction{},
   124  							TransitionSpecs: []types.AlarmTriggeringActionTransitionSpec{
   125  								{
   126  									StartState: "yellow",
   127  									FinalState: "red",
   128  									Repeats:    true,
   129  								},
   130  							},
   131  							Green2yellow: false,
   132  							Yellow2red:   false,
   133  							Red2yellow:   false,
   134  							Yellow2green: false,
   135  						},
   136  					},
   137  				},
   138  				ActionFrequency: 0,
   139  				Setting: &types.AlarmSetting{
   140  					ToleranceRange:     0,
   141  					ReportingFrequency: 300,
   142  				},
   143  			},
   144  			Key:              "",
   145  			Alarm:            types.ManagedObjectReference{Type: "Alarm", Value: "alarm-11", ServerGUID: ""},
   146  			Entity:           types.ManagedObjectReference{Type: "Folder", Value: "group-d1", ServerGUID: ""},
   147  			LastModifiedTime: time.Now(),
   148  			LastModifiedUser: "",
   149  			CreationEventId:  0,
   150  		},
   151  	},
   152  	{
   153  		ExtensibleManagedObject: mo.ExtensibleManagedObject{
   154  			Self:           types.ManagedObjectReference{Type: "Alarm", Value: "alarm-12", ServerGUID: ""},
   155  			Value:          nil,
   156  			AvailableField: nil,
   157  		},
   158  		Info: types.AlarmInfo{
   159  			AlarmSpec: types.AlarmSpec{
   160  				Name:        "Virtual machine error",
   161  				SystemName:  "alarm.VmErrorAlarm",
   162  				Description: "Default alarm to monitor virtual machine error and warning events",
   163  				Enabled:     true,
   164  				Expression: &types.OrAlarmExpression{
   165  					AlarmExpression: types.AlarmExpression{},
   166  					Expression: []types.BaseAlarmExpression{
   167  						&types.EventAlarmExpression{
   168  							AlarmExpression: types.AlarmExpression{},
   169  							Comparisons:     nil,
   170  							EventType:       "GeneralVmErrorEvent",
   171  							EventTypeId:     "",
   172  							ObjectType:      "VirtualMachine",
   173  							Status:          "",
   174  						},
   175  						&types.EventAlarmExpression{
   176  							AlarmExpression: types.AlarmExpression{},
   177  							Comparisons:     nil,
   178  							EventType:       "GeneralVmWarningEvent",
   179  							EventTypeId:     "",
   180  							ObjectType:      "VirtualMachine",
   181  							Status:          "",
   182  						},
   183  					},
   184  				},
   185  				Action: &types.GroupAlarmAction{
   186  					AlarmAction: types.AlarmAction{},
   187  					Action: []types.BaseAlarmAction{
   188  						&types.AlarmTriggeringAction{
   189  							AlarmAction: types.AlarmAction{},
   190  							Action:      &types.SendSNMPAction{},
   191  							TransitionSpecs: []types.AlarmTriggeringActionTransitionSpec{
   192  								{
   193  									StartState: "yellow",
   194  									FinalState: "red",
   195  									Repeats:    true,
   196  								},
   197  							},
   198  							Green2yellow: false,
   199  							Yellow2red:   false,
   200  							Red2yellow:   false,
   201  							Yellow2green: false,
   202  						},
   203  					},
   204  				},
   205  				ActionFrequency: 0,
   206  				Setting: &types.AlarmSetting{
   207  					ToleranceRange:     0,
   208  					ReportingFrequency: 300,
   209  				},
   210  			},
   211  			Key:              "",
   212  			Alarm:            types.ManagedObjectReference{Type: "Alarm", Value: "alarm-12", ServerGUID: ""},
   213  			Entity:           types.ManagedObjectReference{Type: "Folder", Value: "group-d1", ServerGUID: ""},
   214  			LastModifiedTime: time.Now(),
   215  			LastModifiedUser: "",
   216  			CreationEventId:  0,
   217  		},
   218  	},
   219  }