Пример #1
0
    def test_host_inventory_get_with_disabled_inventory(self):
        """
        test host_inventory_get with a host with inventory disabled
        """
        module_return = False
        query_return = {
            "jsonrpc":
            "2.0",
            "result": [{
                "hostid": "10258",
                "proxy_hostid": "0",
                "host": "master",
                "status": "0",
                "disable_until": "1517766661",
                "error":
                "Get value from agent failed: cannot connect to [[10.0.2.15]:10050]: [111] Connection refused",
                "available": "2",
                "errors_from": "1516087871",
                "lastaccess": "0",
                "ipmi_authtype": "-1",
                "ipmi_privilege": "2",
                "ipmi_username": "",
                "ipmi_password": "",
                "ipmi_disable_until": "0",
                "ipmi_available": "0",
                "snmp_disable_until": "0",
                "snmp_available": "0",
                "maintenanceid": "0",
                "maintenance_status": "0",
                "maintenance_type": "0",
                "maintenance_from": "0",
                "ipmi_errors_from": "0",
                "snmp_errors_from": "0",
                "ipmi_error": "",
                "snmp_error": "",
                "jmx_disable_until": "0",
                "jmx_available": "0",
                "jmx_errors_from": "0",
                "jmx_error": "",
                "name": "master",
                "flags": "0",
                "templateid": "0",
                "description": "",
                "tls_connect": "1",
                "tls_accept": "1",
                "tls_issuer": "",
                "tls_subject": "",
                "tls_psk_identity": "",
                "tls_psk": "",
                "inventory": [],
            }],
            "id":
            1,
        }

        with patch.object(zabbix, "_query", return_value=query_return):
            with patch.object(zabbix, "_login", return_value=CONN_ARGS):
                self.assertEqual(
                    zabbix.host_inventory_get("12345", **CONN_ARGS),
                    module_return)
Пример #2
0
def test_host_inventory_get_with_a_missing_host(conn_args, query_return,
                                                mock_login):
    """
    test host_inventory_get with a non-existent host
    """
    module_return = False
    query_return({
        "jsonrpc": "2.0",
        "result": [],
        "id": 0,
    })

    assert zabbix.host_inventory_get("12345", **conn_args) == module_return
Пример #3
0
    def test_host_inventory_get_with_a_missing_host(self):
        """
        test host_inventory_get with a non-existent host
        """
        module_return = False
        query_return = {
            "jsonrpc": "2.0",
            "result": [],
            "id": 0,
        }

        with patch.object(zabbix, "_query", return_value=query_return):
            with patch.object(zabbix, "_login", return_value=CONN_ARGS):
                self.assertEqual(
                    zabbix.host_inventory_get("12345", **CONN_ARGS),
                    module_return)
Пример #4
0
    def test_host_inventory_get(self):
        """
        test host_inventory_get
        """
        module_return = {
            "poc_2_email": "",
            "poc_2_phone_b": "",
            "site_country": "",
            "poc_2_screen": "",
            "poc_2_notes": "",
            "poc_1_screen": "",
            "hardware": "",
            "software_app_a": "",
            "software_app_b": "",
            "software_app_c": "",
            "software_app_d": "",
            "os_short": "",
            "site_zip": "",
            "poc_2_name": "",
            "os_full": "",
            "host_netmask": "",
            "host_router": "",
            "url_c": "",
            "date_hw_install": "",
            "poc_1_phone_b": "",
            "poc_1_phone_a": "",
            "poc_1_cell": "",
            "type_full": "",
            "location_lat": "",
            "vendor": "",
            "contact": "",
            "site_rack": "",
            "location": "",
            "poc_2_cell": "",
            "date_hw_expiry": "",
            "installer_name": "",
            "type": "",
            "contract_number": "",
            "deployment_status": "",
            "site_notes": "",
            "inventory_mode": "0",
            "oob_ip": "",
            "host_networks": "",
            "hardware_full": "",
            "poc_2_phone_a": "",
            "poc_1_name": "",
            "site_state": "",
            "chassis": "",
            "software_app_e": "",
            "site_address_b": "",
            "site_address_a": "",
            "date_hw_decomm": "",
            "date_hw_purchase": "",
            "location_lon": "",
            "hw_arch": "",
            "software_full": "",
            "asset_tag": "",
            "oob_router": "",
            "hostid": "10258",
            "poc_1_email": "",
            "name": "",
            "poc_1_notes": "",
            "serialno_b": "",
            "notes": "",
            "oob_netmask": "",
            "alias": "other thing",
            "tag": "",
            "macaddress_b": "",
            "macaddress_a": "",
            "site_city": "",
            "site_address_c": "",
            "model": "",
            "serialno_a": "",
            "os": "some",
            "url_b": "",
            "url_a": "",
            "software": "",
        }
        query_return = {
            "jsonrpc":
            "2.0",
            "result": [{
                "hostid":
                "10258",
                "proxy_hostid":
                "0",
                "host":
                "master",
                "status":
                "0",
                "disable_until":
                "1517766661",
                "error": ("Get value from agent failed: cannot connect to"
                          " [[10.0.2.15]:10050]: [111] Connection refused"),
                "available":
                "2",
                "errors_from":
                "1516087871",
                "lastaccess":
                "0",
                "ipmi_authtype":
                "-1",
                "ipmi_privilege":
                "2",
                "ipmi_username":
                "",
                "ipmi_password":
                "",
                "ipmi_disable_until":
                "0",
                "ipmi_available":
                "0",
                "snmp_disable_until":
                "0",
                "snmp_available":
                "0",
                "maintenanceid":
                "0",
                "maintenance_status":
                "0",
                "maintenance_type":
                "0",
                "maintenance_from":
                "0",
                "ipmi_errors_from":
                "0",
                "snmp_errors_from":
                "0",
                "ipmi_error":
                "",
                "snmp_error":
                "",
                "jmx_disable_until":
                "0",
                "jmx_available":
                "0",
                "jmx_errors_from":
                "0",
                "jmx_error":
                "",
                "name":
                "master",
                "flags":
                "0",
                "templateid":
                "0",
                "description":
                "",
                "tls_connect":
                "1",
                "tls_accept":
                "1",
                "tls_issuer":
                "",
                "tls_subject":
                "",
                "tls_psk_identity":
                "",
                "tls_psk":
                "",
                "inventory": {
                    "hostid": "10258",
                    "inventory_mode": "0",
                    "type": "",
                    "type_full": "",
                    "name": "",
                    "alias": "other thing",
                    "os": "some",
                    "os_full": "",
                    "os_short": "",
                    "serialno_a": "",
                    "serialno_b": "",
                    "tag": "",
                    "asset_tag": "",
                    "macaddress_a": "",
                    "macaddress_b": "",
                    "hardware": "",
                    "hardware_full": "",
                    "software": "",
                    "software_full": "",
                    "software_app_a": "",
                    "software_app_b": "",
                    "software_app_c": "",
                    "software_app_d": "",
                    "software_app_e": "",
                    "contact": "",
                    "location": "",
                    "location_lat": "",
                    "location_lon": "",
                    "notes": "",
                    "chassis": "",
                    "model": "",
                    "hw_arch": "",
                    "vendor": "",
                    "contract_number": "",
                    "installer_name": "",
                    "deployment_status": "",
                    "url_a": "",
                    "url_b": "",
                    "url_c": "",
                    "host_networks": "",
                    "host_netmask": "",
                    "host_router": "",
                    "oob_ip": "",
                    "oob_netmask": "",
                    "oob_router": "",
                    "date_hw_purchase": "",
                    "date_hw_install": "",
                    "date_hw_expiry": "",
                    "date_hw_decomm": "",
                    "site_address_a": "",
                    "site_address_b": "",
                    "site_address_c": "",
                    "site_city": "",
                    "site_state": "",
                    "site_country": "",
                    "site_zip": "",
                    "site_rack": "",
                    "site_notes": "",
                    "poc_1_name": "",
                    "poc_1_email": "",
                    "poc_1_phone_a": "",
                    "poc_1_phone_b": "",
                    "poc_1_cell": "",
                    "poc_1_screen": "",
                    "poc_1_notes": "",
                    "poc_2_name": "",
                    "poc_2_email": "",
                    "poc_2_phone_a": "",
                    "poc_2_phone_b": "",
                    "poc_2_cell": "",
                    "poc_2_screen": "",
                    "poc_2_notes": "",
                },
            }],
            "id":
            1,
        }

        with patch.object(zabbix, "_query", return_value=query_return):
            with patch.object(zabbix, "_login", return_value=CONN_ARGS):
                self.assertEqual(
                    zabbix.host_inventory_get("12345", **CONN_ARGS),
                    module_return)