Adds a connection between server and device
struct
addDeviceConnection
(struct $p)
-
struct
$p: Associative array with the following fields:
- host: MAC-address
- devid: Device ID
- portid: Port ID
- description: Optional port description
For iSCSI: - conn_user: username
- conn_password: password
- data1: initiator name
- data2: reserved
- data3: reserved
Adds a host to the system
struct
addHost
(struct $p)
-
struct
$p: Associative array with the following fields:
- mac: MAC-address
- subnet: Network address of subnet (must already exist in database)
- ip: IP-address
- numips: number of IPs (e.g. 1). All IPs must be sequential from "ip"
- add_ips: OPTIONAL: space seperated string with additional IP-addresses that are not sequential.
- ipmi_ip: IP-address of IPMI card
- ipmi_user: IPMI username
- ipmi_password: IPMI password
- ipmi_type: IPMI type. v1, v2, v2nokvm or AMT
- hostname: hostname
- arch: optional architecture
- description: description
- pool: id of pool
Adds an IP-reservation to the system
struct
addReservation
(struct $p)
-
struct
$p: Associative array with the following fields:
- subnet: Network address of subnet (must already exist in database)
- ip: IP-address
- numips: number of IPs (e.g. 1). All IPs must be sequential from "ip"
- add_ips: OPTIONAL: space seperated string with additional IP-addresses that are not sequential.
- hostname: hostname
- description: description
Adds a subnet to the system
struct
addSubnet
(struct $p)
-
struct
$p: associative array with the following elements:
- subnet: network address of subnet (e.g. 10.0.0.0)
- netmask: netmask (e.g. 255.255.255.0)
- gateway: IP-address of gateway
- vlan: Optional VLAN ID. Currently only used for matching IPv4 to IPv6 subnets
- description: Description
Adds an IPv6 subnet to the system
struct
addSubnet6
(struct $p)
-
struct
$p: associative array with the following elements:
- subnet: network address of subnet (e.g. 1:2:3:4::)
- cidr: cidr (e.g. 64)
- gateway: IPv6-address of gateway
- vlan: Optional VLAN ID. Currently only used for matching IPv4 to IPv6 subnets
- description: Description
Adds a VPS to the system
struct
addVM
(struct $p)
-
struct
$p: Associative array with the following fields:
- subnet: Network address of subnet (must already exist in database)
- ip: IP-address
- numips: number of IPs (e.g. 1). All IPs must be sequential from "ip"
- add_ips: OPTIONAL: space seperated string with additional IP-addresses that are not sequential.
- hostname: hostname
- description: description
- module: hypervisor device module ID
- memory: amount of memory in MB
- disk: amount of disk in MB
- diskstore: OPTIONAL name of disk store
- network: OPTIONAL name of network to hook up to
Checks if an IP-address is already in use using ARP-ping
Only works for hosts that are in the same VLAN as the NOC-PS server.
string|boolean
arpPing
(string $ip)
Cancels the provisioning of a server
void
cancelProvisioning
(string $mac)
Physical/virtual CD -> ISO
void
copyCD
(string $filename)
-
string
$filename: ISO filename to create
Deletes a device
void
deleteDevice
(string $id)
Deletes a connection between server and device
void
deleteDeviceConnection
(string $server, int $devid, string $portid)
-
string
$server: MAC-address
-
int
$devid: Device ID
-
string
$portid: Port ID
void
deleteHost
(string|array $mac)
-
string|array
$mac: MAC-address
Delete ISO file
void
deleteISO
(string $filename)
-
string
$filename: Filename
Deletes a nic
void
deleteNic
(string $host, string $index)
-
string
$host: Host
-
string
$index:
Index
Note we currently do not support deleting adapter #0
void
deletePool
(string|array $id)
-
string|array
$id: ID of pool
Delete profile Also deletes cached files if it is the only profile using that cache folder
Throws exception if hosts being provisioned are still depending on it
void
deleteProfile
(int $id)
-
int
$id: Numeric ID of profile
Delete profile add-on
void
deleteProfileAddon
(string $tag, string $name)
-
string
$tag: Tag
-
string
$name: Name
Deletes a subnet
Throws an exception if the subnet cannot be deleted, for example: when there are still hosts associated with it.
void
deleteSubnet
(string|array $subnet)
-
string|array
$subnet: Network address of subnet
Deletes an IPv6 subnet
Throws an exception if the subnet cannot be deleted, for example: when there are still hosts associated with it. Note: IPv6 subnet must be written exactly the same as in NOC-PS database (e.g. compact 0001:0000 to 1::)
void
deleteSubnet6
(string|array $subnet)
-
string|array
$subnet: Network address of subnet
Delete a webinterace user
Throws an exception if it is the last admin left
void
deleteUser
(string $username)
-
string
$username: Username
Delete VM including storage
void
deleteVM
(string|array $mac)
-
string|array
$mac: MAC-address
Removes downloaded files of profile
void
emptyCacheOfProfile
(int $profile)
-
int
$profile: Numeric profile ID
Exports host and subnet information
Format is .zip file containing 2 .csv files
base64
exportData
()
Check if there is a new NOC-PS update, and return information
string
fetchUpdateInfo
()
Generates a bandwidth graph
base64
generateBandwidthGraph
(struct $p)
-
struct
$p: Associative array with following parameters:
- host: MAC-address of server
- device: Device number (only if host is not specified)
- port: number of port
- start: Start of graph period requested
- end: End of graph period requested
Retrieves information about the available bandwidth data of a host
struct
getAvailableBandwidthData
(string $host)
-
string
$host: MAC-address of server
void
getAvailableData
(struct $p)
-
struct
$p: associated struct, parameters:
- host MAC-address of server
- type net or power
Retrieves available disk space
int
getAvailableSpace
()
Retrieves numerical bandwidth information
struct
getBandwidthData
(struct $p)
-
struct
$p: Associative array with following parameters:
- host: MAC-address of server
- port: number of port
- start: Start of period requested
- end: End of period requested
Retrieves bandwidth data from all hosts
struct
getBandwidthDataOfAllHosts
(int $start, int $end)
-
int
$start: Start of period requested
-
int
$end: End of period requested
Retrieves a list of device connections by host
struct
getConnectionsByHost
(string $mac)
-
string
$mac: MAC-address of host
Get console URL
string
getConsoleURL
(string $mac, string $ipmi_password, string|bool $restrict_ip)
-
string
$mac: MAC-address of server
-
string
$ipmi_password: IPMI password (if applicable). Leave blank to use stored password.
-
string|bool
$restrict_ip: Optional: IP-address of client to restrict access to
Retrieves statistics from all hosts
void
getDataOfAllHosts
(struct $p)
-
struct
$p: p Associate array with the following fields:
- start: start time
- end: end time
- type: type of data. "net" for data traffic stats, "power" for power statistics
Get a list of datastores available at a certain hypervisor
struct
getDatastores
(int $devid)
-
int
$devid: Hypervisor device ID
Get default settings
struct
getDefaults
()
Retrieve a list of devices
struct
getDevices
(int $start, int $limit)
-
int
$start: offset of first record (first = 0)
-
int
$limit: maximum number of results
Retrieves the list of device types supported
e.g.: apcpdu, switch, iscsi, webresetter, xenserver, vmware
struct
getDeviceTypes
()
Get a list of inactive profiles
struct
getDisabledProfileNames
(int $start, int $limit)
-
int
$start: offset of first record (first = 0)
-
int
$limit: maximum number of results
Get the first available IP-address that is not already in use in a subnet
string
getFirstAvailableIP
(string $subnet)
-
string
$subnet: Network address of subnet
Retrieve all host information from a specific host
struct
getHost
(string $mac)
Retrieve all host information for a specific subnet
struct
getHosts
(string $subnet, int $start, int $limit)
-
string
$subnet: network address of subnet
-
int
$start: offset of first record (first = 0)
-
int
$limit: maximum number of results
Get list of ISO files on server
struct
getISOs
(int $start, int $limit)
-
int
$start: offset of first record (first = 0)
-
int
$limit: maximum number of results
Retrieves license information
string
getLicenseInfo
()
Get locale settings
struct
getLocale
()
Get a list of networks available at a certain hypervisor
struct
getNetworks
(int $devid)
-
int
$devid: Hypervisor device ID
Retrieves a list of pools
struct
getPools
()
Get all information from profile
struct
getProfile
(int $id)
Get all information from profile add-on
struct
getProfileAddon
(string $tag, string $name)
-
string
$tag: tag
-
string
$name: name
Get a list of add-ons
struct
getProfileAddonNames
(int $start, int $limit)
-
int
$start: offset of first record (first = 0)
-
int
$limit: maximum number of results
Get profile number by name
int
getProfileByName
(string $name, [string $arch = 'amd64'])
-
string
$name: Friendly name of profile
-
string
$arch: Architecture ("amd64" for 64-bit, "x86" for 32-bit)
Get a list of profiles
struct
getProfileNames
(int $start, int $limit)
-
int
$start: offset of first record (first = 0)
-
int
$limit: maximum number of results
Retrieve the provisioning status
struct
getProvisioningStatus
(int $start, int $limit)
-
int
$start: offset of first record (first = 0)
-
int
$limit: maximum number of results
Retrieve the provisioning status of a single server
struct
getProvisioningStatusByServer
(string $server)
-
string
$server: MAC-address of server
Get server (MAC-address) by IP-address
string
getServerByIP
(string $ip)
Retrieve all subnet information
returns
getSubnets
(int $start, int $limit)
-
int
$start: offset of first record (first = 0)
-
int
$limit: maximum number of results
Retrieve all subnet information
returns
getSubnets6
(int $start, int $limit)
-
int
$start: offset of first record (first = 0)
-
int
$limit: maximum number of results
Retrieve a list of hosts that requested a DHCP lease recently.
The list is sorted on newest first.
struct
getUnknownHosts
(int $start, int $limit)
-
int
$start: offset of first record (first = 0)
-
int
$limit: maximum number of results
Get ports from device, that are not assigned to other servers yet
struct
getUnusedDevicePorts
(int $devid)
Retrieve a list of webinterface usernames
struct
getUsernames
(int $start, int $limit)
-
int
$start: offset of first record (first = 0)
-
int
$limit: maximum number of results
Retrieve version information
string
getVersion
()
Update NOC-PS to newest version
void
installUpdate
()
Check if an IP-address is already in use by another server (according to the database)
boolean
IPinUse
(string $ip)
-
string
$ip: IP-address to check
Check if an IP-address is in use by device
boolean
IPinUseByDevice
(string $ip)
-
string
$ip: IP-address to check
Check if an IP-address is already in use BY ANOTHER SERVER then the one specified
boolean
IPinUseByOtherServer
(string $ip, string $server)
-
string
$ip
-
string
$server: MAC-address of server
Send an IPMI command to server (depreciated, use IPMIcommandEx or submitIPMI instead)
string
IPMIcommand
(string $ip, string $user, string $password, string $cmd)
-
string
$ip: IP-address of IPMI card
-
string
$user: IPMI username
-
string
$password: IPMI password
-
string
$cmd: Raw IPMI command
Send an IPMI command to server
To be able to use IPMI password stored in database: use submitIPMI() instead
string
IPMIcommandEx
(string $ip, string $type, string $user, string $password, string $cmd)
-
string
$ip: IP-address of IPMI card
-
string
$type: IPMI version/type. "v1", "v2", "v2nokvm" or "AMT"
-
string
$user: IPMI username
-
string
$password: IPMI password
-
string
$cmd: Raw IPMI command
Returns the days left before the license expires If less than 15, the license server is contacted to see if user bought a new one
int
licenseDaysLeft
()
Retrieves information about the hosts secondary network interfaces
struct
listHostNics
(string $host)
Wait for event
This can be used to wait for updates on the provisioning status
int
longPoll
(int $num, int $timeout)
-
int
$num: last event received
-
int
$timeout: timeout in seconds
Performs an ICMP echo request
boolean
ping
(string $ip)
Grab a single server from the specificied pool and move it to a new pool Atomic operation (database table locked during operation)
string|boolean
popFromPool
(int $pool, int $moveToPool)
-
int
$pool: Old pool ID
-
int
$moveToPool: New pool ID
Controls the power of a server
string
powercontrol
(string $mac, string $action, string $ipmipassword, string $method)
-
string
$mac: MAC-address of server
-
string
$action: on/off/status/reset/cycle/ctrlaltdel/supportedactions
-
string
$ipmipassword: IPMI password (only required when password is not stored in db)
-
string
$method: apcpdu, webresetter, ipmi or auto
Provisions a server
The server must already be in the system. If it is not, add it with AddHost
struct
provisionHost
(struct $p)
-
struct
$p:
Associative array with the following fields:
- mac: MAC-address
- hostname: New hostname of server
- rootpassword, rootpassword2: Root password (twice)
- adminuser: Username of optional user
- userpassword, userpassword2: Password of optional user (twice)
- rebootmethod: ipmi, apcpdu, webresetter, auto, or empty for manual
- ipmipassword: IPMI password to set boot method and reboot (optional)
- profile: Profile ID number
Optional, overriding profile defaults:- disklayout: Disk layout in profile specific format
- packages: List of packages
- pre_installation: Pre-installation script (not supported by every profile)
- post_installation: Post-installation script (usually executed at the end of the installation, before reboot)
- firstboot: First boot script (executed after installation, after reboot)
- timezone: Server's timezone
- language: Language pack to install
-OR-- disk_addon: Reference to disk layout tag/name (e.g. "kickstart:raid1")
- packages_addon: Reference to package list tag/name (e.g. "ubuntu:lamp")
- extra_addon1 ... extra_addon10: Extra settings. Usually post-installation scripts. Maximum of 10 items.
Optional for integration with 3rd party software:- callback: URL to be called when provisioning is finished. The MAC addresses of the host will be appended to the URL as GET parameter.
Caveats:- Do not override both the profile defaults and use add-ons at the same time.
- You should NOT set parameters to empty, if you do not want to use them.
e.g. setting "packages" to "", will result in 0 packages being installed
If that is not your intention, and you would like to install the default packages listed in the profile,
you should leave out the parameter completely, instead of setting it to empty.
Rename ISO file
void
renameISO
(string $oldname, string $newname)
-
string
$oldname: Current filename
-
string
$newname: New filename
Search hosts
struct
searchHosts
(struct $p)
-
struct
$p: containing:
- subnet OR device OR pool OR rack OR query
Set default settings
struct
setDefaults
( $p, struct $d)
Update locale settings
struct
setLocale
(struct $d)
Active/Deactivate profile
void
setProfileEnabled
(int $profileid, bool $enabled)
-
int
$profileid
-
bool
$enabled
Splits a subnet into smaller ones
The subnet must be empty, it may not have any hosts associated with it.
void
splitSubnet
(struct $p)
-
struct
$p: associative array with the following elements: *
- subnet: Network address of subnet
- cidr: CIDR of new subnet (e.g. "30" to split into \30 subnets)
- gateway: "first" to indicate the gateway is the first usable IP of subnet, "last" for last IP, or "none"
Splits an IPv6 subnet into smaller ones
The subnet must be empty, it may not have any hosts associated with it. Implementation limitation: currently can only split subnet CIDRs dividable by 8 into 256 subnets
void
splitSubnet6
(struct $p)
-
struct
$p: associative array with the following elements: *
- subnet: Network address of subnet
- cidr: CIDR of new subnet (e.g. "30" to split into \30 subnets)
- gateway: "first" to indicate the gateway is the first usable IP of subnet, "last" for last IP, or "none"
Start KVM/QEMU environment
struct
startVKVM
(struct $p)
-
struct
$p: Associative array with the following fields:
- rootpassword: VNC password (8 characters max)
- iso: optional filename of ISO file
- storage: optional storage mode (ide, scsi, virtio)
- network: optional networking mode (none, user)
Add or update a device like an Ethernet or power switch
struct
submitDevice
(struct $p)
-
struct
$p: Associative array of the following fields:
- id (only required when updating)
- ip
- name
- type
- username (optional)
- password (or SNMP community name)
Send an IPMI command to server (array version)
struct
submitIPMI
(struct $d)
-
struct
$d: associative array with fields:
- ip
- username
- password (if not in database)
- ipmi_type (v1, v2 or AMT)
- cmd
Add or update NIC
struct
submitNic
(struct $p)
-
struct
$p: Associative array with the following fields:
- host
- index
- mac
- model
- subnet
- ip
- add_ips
- ext_if
- antispoof
Add or update a pool
struct
submitPool
(struct $p)
-
struct
$p: Associate array with the following fields:
- id: pool id number (only if updating a pool)
- name: name of pool
- description: description
Add or update profile
struct
submitProfile
(struct $p)
-
struct
$p: Associative array
Add or update add-on
struct
submitProfileAddon
(struct $p)
-
struct
$p: Associative array
Add or update webinterface user
struct
submitUser
(struct $p)
-
struct
$p: Associative array of the following fields:
- username: Username
- password, password2: Password (twice)
- restrict_ip: IP restriction
- current_username: current username (only when updating an existing user)
Updates host information You must update all fields at once. MAC address and subnet cannot be changed.
struct
updateHost
(struct $p)
-
struct
$p: Associative array with the following fields:
- mac: MAC-address
- ip: IP-address
- add_ips: OPTIONAL: space seperated string with additional IP-addresses that are not sequential
- subnet: OPTIONAL: network IP-address of new subnet
- ipmi_ip: IP-address of IPMI card
- ipmi_user: IPMI username
- ipmi_password: IPMI password
- ipmi_noverify: if set, do not verify IPMI password. Default is to connect to the IPMI unit and verify password upon calling updateHost()
- ipmi_type: v1, v2, v2nokvm or AMT
- hostname: hostname
- dhcp: boolean, true if we act as permanent DHCP server for this host
- pool: pool id number
- subnet6: IPv6 subnet
- add_ips6: Space seperated string with IPv6 address(es). All must be within the subnet specified by subnet6
Updates a subnet NOTE: subnet and netmask values CANNOT be changed, only gateway and description
struct
updateSubnet
(struct $p)
-
struct
$p: associative array with the following elements:
- subnet: network address of subnet (e.g. 10.0.0.0)
- gateway: IP-address of gateway
- description: Description
- vlan: Optional VLAN ID
Updates an IPv6 subnet NOTE: subnet and cidr values CANNOT be changed, only gateway, vlan and description
struct
updateSubnet6
(struct $p)
-
struct
$p: associative array with the following elements:
- subnet: network address of IPv6 subnet
- gateway: IP-address of gateway
- description: Description
- vlan: Optional VLAN ID