Code Monkey home page Code Monkey logo

phpipam-for-vra8's Introduction

phpIPAM Integration for vRealize Automation 8.x

This integration allows vRealize Automation 8.x to use phpIPAM for assigning static IP addresses to provisioned virtual machines. Built against vRA 8.2.0.12946 and phpIPAM 1.5.

Details on how I built this (as well as notes on how I configured phpIPAM to work correctly with this plugin) can be found here: https://virtuallypotato.com/integrating-phpipam-with-vrealize-automation-8

Prerequisites

  • phpIPAM 1.5 must be installed, configured, and available over HTTPS
  • Subnets must be defined in phpIPAM.
  • (Optional) A Custom Field defined to identify subnets which should be available to vRA.
    • Note: I previously used the built-in isPool field, but this is not ideal with versions of phpIPAM 1.5 since a change on April 4, 2022 which made the subnet and broadcast addresses (x.x.x.0 and x.x.x.255) assignable on networks with this field set. Use a Custom Field instead.
  • A trusted SSL certificate is not required; vRA will prompt to confirm the certificate when the connection is initially validated.

Usage

From the phpIPAM web interface:

  1. Administration > phpIPAM Settings > Feature Settings and enable the API option.
  2. Administration > phpIPAM Settings > Users and create a new user to be used by vRA.
  3. Administration > phpIPAM Settings > API and create a new API key with Read/Write permissions and SSL with User Token security. Make a note of the selected App ID field (not the auto-generated App Code).

In vRealize Automation:

  1. Go to Cloud Assembly > Infrastructure > Integrations and Add Integration.
  2. Select the IPAM integration type.
  3. Give it a name, then click Manage IPAM Providers > Import Provider Package.
  4. Upload phpIPAM.zip (get it here).
  5. Back at the New Integration page, click the Provider dropdown and select phpIPAM.
  6. Enter the API App ID, Username, Password, and Hostname of the phpIPAM server (fully-qualified name or IP address).
  7. (Optional) Configure the subnet filter.
  8. Click Validate to verify the information. It may take a minute or two for the validation to complete.
  9. Once validated, click Add.

You can then learn how to utilize the new IPAM integration here

See VMware's IPAM SDK README for information on how to adapt the code if needed.

phpipam-for-vra8's People

Contributors

dependabot[bot] avatar jbowdre avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

phpipam-for-vra8's Issues

Missing Gateway

Attempting to sync IPAM with vRA while some subnets have no gateway results in an error:

[2021-12-14 14:34:59,806] [INFO] - Querying for auth credentials
[2021-12-14 14:34:59,839] [INFO] - Credentials obtained successfully!
[2021-12-14 14:35:00,169] [INFO] - Found subnet: 0.0.0.0/28 - XYZ.
[2021-12-14 14:35:00,263] [INFO] - Found subnet: 0.0.0.0/27 - XYZ.
[2021-12-14 14:35:00,368] [INFO] - Found subnet: 0.0.0.0/23 - XYZ.
[2021-12-14 14:35:00,473] [INFO] - Found subnet: 0.0.0.0/24 - XYZ.
Traceback (most recent call last):
  File "abx_wrapper.py", line 325, in main
    response = exec_function(wrapperCtx, request, f)
  File "abx_wrapper.py", line 223, in exec_function
    funcResult = handle(ctx, req)
  File "/function/source.py", line 42, in handler
    return ipam.get_ip_ranges()
  File "/function/vra_ipam_utils/ipam.py", line 64, in get_ip_ranges
    result = self.do_get_ip_ranges(auth_credentials, cert)
  File "/function/source.py", line 88, in do_get_ip_ranges
    gateway = gw_req.json()['data'][0]['ip']
KeyError: 'data'

It seems that it will still return 200 since the request was valid, but with no data. For get_ip_ranges/source.py I suggest
if gw_req.status_code == 200 and not "data" in gw_req.json():

Additionally, it would be nice to be able to specify the filter_by rule. Currently it's forced as filter_by=isPool&filter_value=1 but, since I believe you can add custom values to the vRA integration page, you could add filter_by and filter_value fields. Then instead of having these subnets be the only 'pools' in phpIPAM, I could create a custom field called vRA as a boolean, and simply filter for that. ?filter_by=custom_vRA&filter_value=1

Set MAC address , VLAN, Hostname using ABX or vRO in 8.6.2 version

Hello,

I have Django based program to talk to IPAM to get IP,Hostname, MAC, VLAN etc. This Django also talk to AD, internal costing tool as well. I am looking for an option to update MAC, Hostname, IP , Mac address type in new version of vRA7vRO. Found your website so promising and thought of asking here.

As of now I am using vRO(7.5) workflow to update properties of VM using payload. Code shared below.

Says: vRA>Subscriptions>vRO>API Calls to Django> Get below values

virtualMachineAddOrUpdateProperties = new Properties ();
virtualMachineAddOrUpdateProperties.put('Name', hostname);
virtualMachineAddOrUpdateProperties.put('VirtualMachine.Network0.MacAddressType', 'static');
virtualMachineAddOrUpdateProperties.put('VirtualMachine.Network0.MacAddress', mac);
virtualMachineAddOrUpdateProperties.put('VirtualMachine.Network0.Name', "VLAN"+vlan);

And I have couple of API calls to Django program to get above values. How do I implement same in vRA7vRO 8.6.2

Is there any way to use your repo to build my Django application as IPAM ? Please guide

phpIPAM_GetIPRanges

Hello @jbowdre
I am trying to integrating your plugin into my vra 8.5 and show me an error: Execution of action phpIPAM_GetIPRanges failed on provider side: 'data'

Logs:
[2021-10-04 18:33:40,623] [INFO] - Querying for auth credentials
[2021-10-04 18:33:40,659] [INFO] - Credentials obtained successfully!
Traceback (most recent call last):
File "abx_wrapper.py", line 325, in main
response = exec_function(wrapperCtx, request, f)
File "abx_wrapper.py", line 223, in exec_function
funcResult = handle(ctx, req)
File "/function/source.py", line 42, in handler
return ipam.get_ip_ranges()
File "/function/vra_ipam_utils/ipam.py", line 64, in get_ip_ranges
result = self.do_get_ip_ranges(auth_credentials, cert)
File "/function/source.py", line 68, in do_get_ip_ranges
subnets = subnets.json()['data']
KeyError: 'data'

i dont know if this error is because some configuration on phpIPAM or the version of my vRA.

If you can help, i really appreciate that.

Regards,

vRA 8.6: "IP ALLOCATE failed: 'owner'"

Attempting to allocate an IP address on a newly-upgraded vRA 8.6 instance fails:

[2021-10-19 18:35:05,164] [INFO] - Querying for auth credentials
[2021-10-19 18:35:05,201] [INFO] - Credentials obtained successfully!
[2021-10-19 18:35:05,218] [INFO] - Allocating from range 9
[2021-10-19 18:35:05,218] [ERROR] - Failed to allocate from range 9: 'owner'
[2021-10-19 18:35:05,218] [ERROR] - No more ranges. Raising last error
Traceback (most recent call last):
  File "abx_wrapper.py", line 325, in main
    response = exec_function(wrapperCtx, request, f)
  File "abx_wrapper.py", line 223, in exec_function
    funcResult = handle(ctx, req)
  File "/function/source.py", line 81, in handler
    return ipam.allocate_ip()
  File "/function/vra_ipam_utils/ipam.py", line 91, in allocate_ip
    result = self.do_allocate_ip(auth_credentials, cert)
  File "/function/source.py", line 119, in do_allocate_ip
    raise e
  File "/function/source.py", line 112, in do_allocate_ip
    allocation_result.append(allocate(resource, allocation, self.context, self.inputs["endpoint"], bundle))
  File "/function/source.py", line 139, in allocate
    raise last_error
  File "/function/source.py", line 133, in allocate
    return allocate_in_range(range_id, resource, allocation, context, endpoint, bundle)
  File "/function/source.py", line 145, in allocate_in_range
    owner = resource['owner']
KeyError: 'owner'

Inputs from 8.6:

"resourceInfo": {
    "id": "/resources/compute/71dd540f-bcab-4cf0-bbba-37e8463aee35",
    "name": "BOW-TTST-XXX029",
    "type": "VM",
    "orgId": "6b583ecf-9349-4b78-803c-c728f9d46751",
    "properties": { ... },
    "blueprintId": "757d9712-7a34-47d6-ac63-dee01818dfd1",
    "deploymentId": "e350330d-6332-4351-988f-a7541f74bf3a"
  }

Inputs from 8.5:

"resourceInfo": {
    "id": "/resources/compute/dc395c3c-5e29-4d5c-b037-28c10bf79085",
    "name": "BOW-TTST-XXX024",
    "type": "VM",
    "orgId": "6b583ecf-9349-4b78-803c-c728f9d46751",
    "owner": "john",
    "projectId": "a02fe1ff-e152-47f9-811e-103af9fcf63c",
    "properties": { ... },
    "blueprintId": "757d9712-7a34-47d6-ac63-dee01818dfd1",
    "deploymentId": "0f854008-a4d6-4d76-8e9f-250d99493910"
  }

It looks like the resourceInfo Properties no longer includes the owner string to designate the requester of the deployment. I'll work on a way to compensate for this change.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.