- Znuny LTS or ((OTRS)) Community Edition 6
- Add-ons
- GeneralCatalog
- ITSMCore
- ITSMConfigurationManagement
Add a new webservice by uploading the file CMDB.yml as a new webservice configuration.
| --- | |
| - Key: Vendor | |
| Name: Vendor | |
| Searchable: 1 | |
| Input: | |
| Type: Text | |
| Size: 50 | |
| MaxLength: 50 | |
| # Example for CI attribute syntax check for text and textarea fields | |
| #RegEx: ^ABC.* | |
| #RegExErrorMessage: Value must start with ABC! | |
| - Key: Model | |
| Name: Model | |
| Searchable: 1 | |
| Input: | |
| Type: Text | |
| Size: 50 | |
| MaxLength: 50 | |
| - Key: Description | |
| Name: Description | |
| Searchable: 1 | |
| Input: | |
| Type: TextArea | |
| - Key: Type | |
| Name: Type | |
| Searchable: 1 | |
| Input: | |
| Type: GeneralCatalog | |
| Class: ITSM::ConfigItem::Computer::Type | |
| Translation: 1 | |
| - Key: CustomerID | |
| Name: Customer Company | |
| Searchable: 1 | |
| Input: | |
| Type: CustomerCompany | |
| - Key: Owner | |
| Name: Owner | |
| Searchable: 1 | |
| Input: | |
| Type: Customer | |
| - Key: SerialNumber | |
| Name: Serial Number | |
| Searchable: 1 | |
| Input: | |
| Type: Text | |
| Size: 50 | |
| MaxLength: 100 | |
| - Key: OperatingSystem | |
| Name: Operating System | |
| Input: | |
| Type: Text | |
| Size: 50 | |
| MaxLength: 100 | |
| - Key: CPU | |
| Name: CPU | |
| Input: | |
| Type: Text | |
| Size: 50 | |
| MaxLength: 100 | |
| CountMax: 16 | |
| - Key: Ram | |
| Name: Ram | |
| Input: | |
| Type: Text | |
| Size: 50 | |
| MaxLength: 100 | |
| CountMax: 10 | |
| - Key: HardDisk | |
| Name: Hard Disk | |
| Input: | |
| Type: Text | |
| Size: 50 | |
| MaxLength: 100 | |
| CountMax: 10 | |
| Sub: | |
| - Key: Capacity | |
| Name: Capacity | |
| Input: | |
| Type: Text | |
| Size: 20 | |
| MaxLength: 10 | |
| - Key: FQDN | |
| Name: FQDN | |
| Searchable: 1 | |
| Input: | |
| Type: Text | |
| Size: 50 | |
| MaxLength: 100 | |
| - Key: NIC | |
| Name: Network Adapter | |
| Input: | |
| Type: Text | |
| Size: 50 | |
| MaxLength: 100 | |
| Required: 1 | |
| CountMin: 0 | |
| CountMax: 10 | |
| CountDefault: 0 | |
| Sub: | |
| - Key: IPoverDHCP | |
| Name: IP over DHCP | |
| Input: | |
| Type: GeneralCatalog | |
| Class: ITSM::ConfigItem::YesNo | |
| Translation: 1 | |
| Required: 0 | |
| - Key: IPAddress | |
| Name: IP Address | |
| Searchable: 1 | |
| Input: | |
| Type: Text | |
| Size: 40 | |
| MaxLength: 40 | |
| Required: 0 | |
| CountMin: 0 | |
| CountMax: 20 | |
| CountDefault: 0 | |
| - Key: GraphicAdapter | |
| Name: Graphic Adapter | |
| Input: | |
| Type: Text | |
| Size: 50 | |
| MaxLength: 100 | |
| - Key: OtherEquipment | |
| Name: Other Equipment | |
| Input: | |
| Type: TextArea | |
| Required: 1 | |
| CountMin: 0 | |
| CountDefault: 0 | |
| - Key: WarrantyExpirationDate | |
| Name: Warranty Expiration Date | |
| Searchable: 1 | |
| Input: | |
| Type: Date | |
| YearPeriodPast: 20 | |
| YearPeriodFuture: 10 | |
| - Key: InstallDate | |
| Name: Install Date | |
| Searchable: 1 | |
| Input: | |
| Type: Date | |
| Required: 1 | |
| YearPeriodPast: 20 | |
| YearPeriodFuture: 10 | |
| CountMin: 0 | |
| CountDefault: 0 | |
| - Key: Note | |
| Name: Note | |
| Searchable: 1 | |
| Input: | |
| Type: TextArea | |
| Required: 1 | |
| CountMin: 0 | |
| CountDefault: 0 |
| --- | |
| Debugger: | |
| DebugThreshold: debug | |
| TestMode: '0' | |
| Description: '' | |
| FrameworkVersion: 6.0.27 | |
| Provider: | |
| Operation: | |
| ConfigItemGet: | |
| Description: '' | |
| IncludeTicketData: '0' | |
| Type: ConfigItem::ConfigItemGet | |
| ConfigItemSearch: | |
| Description: '' | |
| IncludeTicketData: '0' | |
| Type: ConfigItem::ConfigItemSearch | |
| SessionCreate: | |
| Description: '' | |
| IncludeTicketData: '0' | |
| Type: Session::SessionCreate | |
| Transport: | |
| Config: | |
| AdditionalHeaders: ~ | |
| KeepAlive: '' | |
| MaxLength: '10000000' | |
| RouteOperationMapping: | |
| ConfigItemGet: | |
| ParserBackend: JSON | |
| RequestMethod: | |
| - GET | |
| Route: /ConfigItem/:ConfigItemID | |
| ConfigItemSearch: | |
| ParserBackend: JSON | |
| RequestMethod: | |
| - POST | |
| Route: /ConfigItem | |
| SessionCreate: | |
| ParserBackend: JSON | |
| RequestMethod: | |
| - POST | |
| Route: /Session | |
| Type: HTTP::REST | |
| RemoteSystem: '' | |
| Requester: | |
| Transport: | |
| Type: '' |
| $user = "xx" | |
| $pass = "xx" | |
| $uri = "https://xx.yy.zz.com/otrs/nph-genericinterface.pl/Webservice" | |
| $headers = @{} | |
| $headers.Add("Accept", "application/json") | |
| $headers.Add("Content-Type", "application/json") | |
| # Get Session | |
| $LoginDetails = @{ | |
| UserLogin = $user | |
| Password = $pass | |
| } | |
| $json = $LoginDetails | ConvertTo-Json | |
| $response = Invoke-RestMethod -Method Post -Headers $Headers -ContentType 'application/json' -Uri "$uri/CMDB/Session" -Body $json | |
| if ( $response.Error ) { | |
| $code = $response.Error.ErrorCode | |
| $message = $response.Error.ErrorMessage | |
| Write-Host "Creating session failed (${code}: $message)" | |
| exit 1 | |
| } | |
| $SessionID = $response.SessionID | |
| $Today = Get-Date -Format "yyyy-MM-dd" | |
| # Which classes to check | |
| $Classes = @("Computer") | |
| foreach ( $Class in $Classes ) { | |
| Write-Host Search for ConfigItems of class $Class | |
| # Search ConfigItems | |
| # Parameter see https://github.com/OTRS/ITSMConfigurationManagement/blob/rel-6_0/Kernel/GenericInterface/Operation/ConfigItem/ConfigItemSearch.pm#L125 | |
| $SearchParameter = @{ | |
| SessionID = $SessionID | |
| ConfigItem = @{ | |
| Class = $Class | |
| Limit = 10000 | |
| DeplStates = @( | |
| "Production" | |
| ) | |
| } | |
| } | |
| $json = $SearchParameter | ConvertTo-Json -Depth 3 | |
| $response = Invoke-RestMethod -Method Post -Headers $Headers -Uri "$uri/CMDB/ConfigItem" -Body $json | |
| if ( $response.Error ) { | |
| $code = $response.Error.ErrorCode | |
| $message = $response.Error.ErrorMessage | |
| Write-Host "Search for ConfigItems failed (${code}: $message)" | |
| exit 1 | |
| } | |
| # next iteration of no CIs found | |
| if ( !$response.ConfigItemIDs ) { | |
| continue | |
| } | |
| $ConfigItemIDs = $response.ConfigItemIDs | |
| foreach ( $ConfigItemID in $ConfigItemIDs) { | |
| Write-Host Fetching ConfigItem with ID $ConfigItemID | |
| $response = Invoke-RestMethod -Method Get -Headers $Headers -Uri "$uri/CMDB/ConfigItem/${ConfigItemID}?SessionID=${SessionID}" | |
| if ( $response.Error ) { | |
| $code = $response.Error.ErrorCode | |
| $message = $response.Error.ErrorMessage | |
| Write-Host "Get ConfigItems with id $ConfigItemID failed (${code}: $message)" | |
| continue | |
| } | |
| $ConfigItem = $response.ConfigItem | |
| Write-Host -NoNewLine CI $ConfigItem.Number ($ConfigItem.Name) "is " | |
| if ( $ConfigItem.CIXMLData.WarrantyExpirationDate -le $Today ) { | |
| Write-Host expired | |
| $UpdatedCI = @{ | |
| SessionID = $SessionID | |
| ConfigItemID = $ConfigItemID | |
| ConfigItem = @{ | |
| Class = $Class | |
| Name = $ConfigItem.Name | |
| DeplState = "Expired" | |
| InciState = $ConfigItem.InciState | |
| CIXMLData = $ConfigItem.CIXMLData | |
| } | |
| } | |
| $json = $UpdatedCI | ConvertTo-Json -Depth 5 | |
| $response = Invoke-RestMethod -Method Post -Headers $Headers -Uri "$uri/CMDB/ConfigItem/${ConfigItemID}" -Body $json | |
| if ( $response.Error ) { | |
| $code = $response.Error.ErrorCode | |
| $message = $response.Error.ErrorMessage | |
| Write-Host "Seettig ConfigItems with id $ConfigItemID to eexpired failed (${code}: $message)" | |
| continue | |
| } | |
| } else { | |
| Write-Host not expired | |
| } | |
| } | |
| } |