AbstractDBObject - 전역
AbstractDBObject 스크립트 포함은 데이터베이스의 레코드를 기반으로 클래스에 대한 공통 메서드를 제공합니다.
이 스크립트 포함을 기본 클래스로 사용하여 데이터베이스 객체 클래스를 직접 만들 수 있습니다.
AbstractDBObject - isValid()
현재 데이터베이스 기록이 유효한지 확인합니다.
IPService - 전역 또한 참조하십시오.
| 이름 | 유형 | 설명 |
|---|---|---|
| 없음 |
| 유형 | 설명 |
|---|---|
| 부울 | 데이터베이스 기록이 유효하면 True, 그렇지 않으면 False입니다. 데이터베이스 기록이 유효한지 여부를 나타내는 플래그입니다. 유효한 값은 다음과 같습니다.
|
다음 예제에서는 IP Services [cmdb_ip_service] 테이블에서 IPService() 클래스를 사용하여 유효한 인스턴스 목록을 가져오는 방법을 보여 줍니다. IPService 클래스는 AbstractDBObject() 클래스를 확장합니다.
/**
* IPService class Encapsulates the notion of an IP Service. Instances in which isValid() returns true have the
* following properties initialized:
* sysID: sys_id of this record
* port: the TCP or UDP port used by the service
* protocol: protocol used by the service ("UDP", "TCP", or "TCP/UDP")
* name: short name or handle
* serviceName: long, descriptive English name
* creates: table that this service creates entries in
* description: description
*/
var result = [];
// Array of sys_id's from the IP Service class which we want to get the abstract details
var list = ['db9840e10ab3015500f5e3fe8f78da42', 'a1505ebc7782330099808d1168106179', 'abc05ebc7782330099808d1168106112'];
// query for the records on the list
var ipservice = new GlideRecord('cmdb_ip_service');
ipservice.addQuery('sys_id', 'IN', list.toString());
ipservice.query();
while (ipservice.next()) {
var ip = new IPService(ipservice); // IPService class extends AbstractDBObject class and this class
if (ip.isValid()) // check whether the record is valid or not
result.push(ip); // if valid get the properties for
}
gs.info(JSON.stringify(result, null, 2));
출력:
[
{
"valid": true,
"sysID": "a1505ebc7782330099808d1168106179",
"port": "8882",
"protocol": "TCP",
"name": "blkbry-uem-enroll",
"serviceName": "Blackberry Enrollment Request",
"creates": null,
"description": null
},
{
"valid": true,
"sysID": "db9840e10ab3015500f5e3fe8f78da42",
"port": "548",
"protocol": "TCP",
"name": "afp",
"serviceName": "Apple File Protocol",
"creates": null,
"description": null
}
]