softlayer / softlayer.github.io

A collection of SoftLayer API examples in a variety of languages
https://softlayer.github.io
13 stars 18 forks source link

not able to get fortigate device information like serial number #121

Closed sdputurn closed 4 years ago

sdputurn commented 6 years ago

Hi team, we are using Softlayer for our infrastructure. to record Configuration Items CI inventory for servers in SL. we need device information. i am not able to get device information for fortigate devices.

I have tried below:

  1. SoftLayer_Account::getHardware this give me vyatta servers but not fortigate)
  2. firewall manager (FirewallManager) but this gives me only the vlans infromation

Could you please help me where can i get the fortigate devices information such as model, manufacturer, serial number, mac address.(i used to get these details for vyatta firewalls using python apis)

allmightyspiff commented 6 years ago

Example for getting serial number for fortigate

FernandoOjeda commented 6 years ago

Using the softlayer api you can only get a general information of the Firewall (fortigate) as vlan, router, subnets, where the firewall was added and the credentials to access to the fortigate server such as username, password and Management ip, as shown in the control portal.

In order to obtain data such as serial, model, manufacturer, etc., you have to enter to the "fortigate" server with the credentials mentioned above provided by the softlayer api or the portal control.

You can use this python example to obtain the credentials and the ip management of the fortigate and you will be able to enter to the server as in the image below.

"""
GetObject Network_Vlan_Firewall
getObject returns a SoftLayer_Network_Vlan_Firewall object. You can only get objects for vlans attached to your account
that have a network firewall enabled.

Important manual pages:
https://softlayer.github.io/reference/services/SoftLayer_Network_Vlan_Firewall/getObject/
https://softlayer.github.io/reference/datatypes/SoftLayer_Network_Vlan_Firewall/

License: http://sldn.softlayer.com/article/License
Author: SoftLayer Technologies, Inc. <sldn@softlayer.com>
"""
import SoftLayer

# For nice debug output:
from pprint import pprint as pp

# Your SoftLayer API username and key.
API_USERNAME = 'set me'

# Generate one at https://control.softlayer.com/account/users
API_KEY = 'set me'

firewallId = 11111

objectMask = 'mask[billingItem,customerManagedFlag,fullyQualifiedDomainName,managementCredentials,networkVlan[id,' \
             'firewallInterfaces,primaryRouter[hostname,id],vlanNumber],primaryIpAddress, bypassRequestStatus]'

client = SoftLayer.create_client_from_env(
    username=API_USERNAME,
    api_key=API_KEY
)

try:

    orderStatus = client['SoftLayer_Network_Vlan_Firewall'].getObject(mask = objectMask, id = firewallId)
    print(orderStatus)

except SoftLayer.SoftLayerAPIError as e:
    pp('Unable to get the firewall information faultCode=%s, faultString=%s'
       % (e.faultCode, e.faultString))

You will get a response like this example:

{ "primaryIpAddress": "11.111.111.111", "billingItem": { "allowCancellationFlag": 1, "categoryCode": "vlan_firewall", "description": "FortiGate Security Appliance", "id":11111 }, "managementCredentials": { "createDate": "2018-07-31T15:16:23-06:00", "id": 2222222, "modifyDate": "2018-07-31T15:16:23-06:00", "password": "password12345", "port": 23, "softwareId": 1111111, "username": "SL45454" }

Use the "primaryIpAddress" as the url and the credential username and password to login to the fortigate server.

fortigate