Added Dynamic IP creation by using API method /addresses/first_free/{id}

Added Dynamic IP creation by using API method /addresses/first_free/{subnetId}/
HI @lord-kyron , I've prepared new resource that will use phpIPAM API method /addresses/first_free/{subnetId}/
This method don't need execute data source to get new IP address, phpIPAM do it automatically.
This pull request has dependency from https://github.com/paybyphone/phpipam-sdk-go
This pull request can be applied only when this commit will be approved https://github.com/paybyphone/phpipam-sdk-go/pull/6
If you have paybyphone contacts, will be great if he could check pull request.
P.S. phpIPAM has bug, related to dynamic IP creation - https://github.com/phpipam/phpipam/issues/2960

Thank you @pavel-z1 !
As far as I understand in order this to work both this pull request and the one in @paybyphone repo should be merged?
Unfortunately I don't have any contacts of him, but will try to track him down.
However, in the mean time - did you had any chance to look at the "count" feature? Maybe I can contact him at once regarding both (if you have any more commits about this too for his repo) ?

Hi @lord-kyron ,
Yes, this will work when both PR will be merged:
https://github.com/lord-kyron/terraform-provider-phpipam/pull/7
https://github.com/paybyphone/phpipam-sdk-go/pull/6
Regarding count.
This feature already support terraform count method.
To the README I've added example of count usage:
data "phpipam_subnet" "subnet" {
  subnet_address = "<IP_ADDRESS>"
  subnet_mask    = 24
}

// Reserve the address. Note that we use ignore_changes here to ensure that we
// don't end up re-allocating this address on future Terraform runs.
resource "phpipam_first_free_address" {
  count = 3

  subnet_id   = data.phpipam_subnet.subnet.subnet_id
  hostname    = "tf-test-host.example.internal"
  description = "Managed by Terraform"

  lifecycle {
    ignore_changes = [
      subnet_id,
    ]
  }
}

We have only one problem here. This is phpIPAM bug - https://github.com/phpipam/phpipam/issues/2960
Will will wait when phpIPAM will fix this bug to user dynamic IP creation in Terraform multithreading mode.

@pavel-z1 - will it be easier to fork the paybyphone/phpipam-sdk-go repo, make the changes and then change the paths in the current code to lead to the new modified repo and re-build the provider then?
I tried contacting the only contributor of the repo trough the only channel I found he is active - twitter, but with no success yet.
Please, share your toughs!

@lord-kyron  Agree with you.
I will create Pull request with updated paths shortly.

@pavel-z1 - great. Fork the repo, update it and then make a new pull request here and I will merge it.
I will then try to build it and if it works I will upload new release.
Does your changes need specific version of golang to be compiled with?

Hi @lord-kyron
I've used GO version 13 to build provider.

@pavel-z1 - I know you forked paybyphone repo, but did you applied the changes from your initial request to the code there?

Hi @lord-kyron
Yes, I've added CreateFirstFreeAddress to my repository https://github.com/pavel-z1/phpipam-sdk-go/commit/50fba1e0dd19db95bab636fd77b1f5e31162ccb1
Also, we have great news regarding bug https://github.com/phpipam/phpipam/issues/2960
It already fixed, and available in this branch:
git clone -b mysql_locking --recursive https://github.com/phpipam/phpipam.git phpipam-locking
So, we already can use dynamic IP provisioning.
To build terraform provider need only execute:
go install
go build

I've build the provider with latest terraform 0.12.23 and with latest released go lang 1.14 successfully.
However, when I try to use your implementation with the following config:
`data "phpipam_subnet" "subnet" {
subnet_address = "<IP_ADDRESS>"
subnet_mask    = 24
}
resource "phpipam_first_free_address" "new_ip" {
count = 2
subnet_id   = data.phpipam_subnet.subnet.subnet_id
hostname    = "tf-test-host%d.test.internal"
description = "Managed by Terraform"
lifecycle {
ignore_changes = [
subnet_id,
]
}
}
I am getting the following error:Refreshing Terraform state in-memory prior to plan...
The refreshed state will be used to calculate this plan, but will not be
persisted to local or remote state storage.
data.phpipam_subnet.subnet: Refreshing state...
phpipam_address.new_ip[2]: Refreshing state... [id=61728]
Error: Error from API (404): Invalid Id`
Can you suggest - is this cause because I am using PHPipam 1.14 (not the patched mysql_locking branch) version, or it is something wrong with the provider function?

@lord-kyron I've perform testing plugin only with phpIPAM latest versions 1.4 and 1.5 (git clone -b mysql_locking --recursive https://github.com/phpipam/phpipam.git phpipam-locking)
On all current phpIPAM releases (<1.5) exists bug with multithreading. Try to use terraform with limit to one thread:
terraform apply -parallelism=1```

On current development branch issue with multithread was fixed.
Tested phpIPAM on branch phpipam-locking
Able to use terraform without `-parallelism=1` for many IPs.

I've tried with parallelism=1 and still getting:
phpipam_first_free_address.new_ip[1]: Creating...
phpipam_first_free_address.new_ip[0]: Creating...

Error: Non-API error (404 Not Found): {"code":404,"success":0,"message":"Invalid URL"}

  on main.tf line 13, in resource "phpipam_first_free_address" "new_ip":
  13: resource "phpipam_first_free_address" "new_ip" {

Error: Non-API error (404 Not Found): {"code":404,"success":0,"message":"Invalid URL"}

  on main.tf line 13, in resource "phpipam_first_free_address" "new_ip":
  13: resource "phpipam_first_free_address" "new_ip" {

It seems to me something else, like the URL that the new resource type constructs from what I am giving as parameters is somehow wrong and it does not exist.

Yes, @pavel-z1 indeed it seems that it tries to hit some wrong URL.
For example I've tried to access wrong URL from the browser and IPAM is returning the same error to me, when I do:

The question is - I am giving the right components for the provider to connect obviously as it is connecting and planing the right way. Maybe the new resource is not compiling the URL needed to access the IPAM as it should be or it is another problem?

@lord-kyron  Seems you try use terraform provider with app_id that is not configured in phpIPAM.
This is example from my configuration.
Terraform:
provider "phpipam" {
app_id   = "terraform"
endpoint = "http://ip_address/api"
password = "pass"
username = "admi user"
}
phpIPAM:
https://monosnap.com/file/5Jp96ZlqigjojpWX9Sg5q1IbrofyhT
app_id in terraform configuration should be the same as configured in phpIPAM.
Can you please recheck phpIPAM API configuration and terraform provider params?

@pavel-z1
my phpipam app_id is "myapp"
I am already using it with Ansible and was using it with the older version of the provider.
Also, interesting is that when I enter the same address in the browser - I am going to the right place, but when I use it in the provider, I am getting 404

@pavel-z1 - here is the full debug log from terraform when planning and then applying the changes that I am describing. Hope it can help to debug this:
terraform apply -parallelism=1
2020/03/12 14:58:47 [WARN] Log levels other than TRACE are currently unreliable, and are supported only for backward compatibility.
  Use TF_LOG=TRACE to see Terraform's internal logs.
  ----
2020/03/12 14:58:47 [INFO] Terraform version: 0.12.23
2020/03/12 14:58:47 [INFO] Go runtime version: go1.12.13
2020/03/12 14:58:47 [INFO] CLI args: []string{"/opt/terraform/terraform", "apply", "-parallelism=1"}
2020/03/12 14:58:47 [DEBUG] Attempting to open CLI config file: /home/.terraformrc
2020/03/12 14:58:47 [DEBUG] File doesn't exist, but doesn't need to. Ignoring.
2020/03/12 14:58:47 [DEBUG] checking for credentials in "/home/.terraform.d/plugins"
2020/03/12 14:58:47 [INFO] CLI command args: []string{"apply", "-parallelism=1"}
2020/03/12 14:58:47 [WARN] Log levels other than TRACE are currently unreliable, and are supported only for backward compatibility.
  Use TF_LOG=TRACE to see Terraform's internal logs.
  ----
2020/03/12 14:58:47 [DEBUG] New state was assigned lineage "bf6f3f19-a3d7-f838-35df-5c08a8e0oj41"
2020/03/12 14:58:47 [DEBUG] checking for provider in "."
2020/03/12 14:58:47 [DEBUG] checking for provider in "/opt/terraform"
2020/03/12 14:58:47 [DEBUG] checking for provider in ".terraform/plugins/linux_amd64"
2020/03/12 14:58:47 [DEBUG] checking for provider in "/home/.terraform.d/plugins"
2020/03/12 14:58:47 [WARN] found legacy provider "terraform-provider-phpipam"
2020/03/12 14:58:47 [DEBUG] found valid plugin: "phpipam", "0.0.0", "/home/.terraform.d/plugins/terraform-provider-phpipam"
2020/03/12 14:58:47 [DEBUG] checking for provisioner in "."
2020/03/12 14:58:47 [DEBUG] checking for provisioner in "/opt/terraform"
2020/03/12 14:58:47 [DEBUG] checking for provisioner in ".terraform/plugins/linux_amd64"
2020/03/12 14:58:47 [DEBUG] checking for provisioner in "/home/.terraform.d/plugins"
2020/03/12 14:58:47 [INFO] backend/local: starting Apply operation
2020-03-12T14:58:47.618Z [INFO]  plugin: configuring client automatic mTLS
2020-03-12T14:58:47.650Z [DEBUG] plugin: starting plugin: path=/home/.terraform.d/plugins/terraform-provider-phpipam args=[/home/.terraform.d/plugins/terraform-provider-phpipam]
2020-03-12T14:58:47.650Z [DEBUG] plugin: plugin started: path=/home/.terraform.d/plugins/terraform-provider-phpipam pid=130650
2020-03-12T14:58:47.650Z [DEBUG] plugin: waiting for RPC address: path=/home/.terraform.d/plugins/terraform-provider-phpipam
2020-03-12T14:58:47.659Z [INFO]  plugin.terraform-provider-phpipam: configuring server automatic mTLS: timestamp=2020-03-12T14:58:47.659Z
2020-03-12T14:58:47.691Z [DEBUG] plugin: using plugin: version=5
2020-03-12T14:58:47.691Z [DEBUG] plugin.terraform-provider-phpipam: plugin address: address=/tmp/plugin861585933 network=unix timestamp=2020-03-12T14:58:47.691Z
2020-03-12T14:58:47.764Z [DEBUG] plugin: plugin process exited: path=/home/.terraform.d/plugins/terraform-provider-phpipam pid=130650
2020-03-12T14:58:47.764Z [DEBUG] plugin: plugin exited
2020/03/12 14:58:47 [INFO] terraform: building graph: GraphTypeValidate
2020/03/12 14:58:47 [DEBUG] ProviderTransformer: "phpipam_first_free_address.new_ip" (*terraform.NodeValidatableResource) needs provider.phpipam
2020/03/12 14:58:47 [DEBUG] ProviderTransformer: "data.phpipam_subnet.subnet" (*terraform.NodeValidatableResource) needs provider.phpipam
2020/03/12 14:58:47 [DEBUG] ReferenceTransformer: "phpipam_first_free_address.new_ip" references: [data.phpipam_subnet.subnet]
2020/03/12 14:58:47 [DEBUG] ReferenceTransformer: "data.phpipam_subnet.subnet" references: []
2020/03/12 14:58:47 [DEBUG] ReferenceTransformer: "provider.phpipam" references: []
2020/03/12 14:58:47 [DEBUG] Starting graph walk: walkValidate
2020-03-12T14:58:47.766Z [INFO]  plugin: configuring client automatic mTLS
2020-03-12T14:58:47.797Z [DEBUG] plugin: starting plugin: path=/home/.terraform.d/plugins/terraform-provider-phpipam args=[/home/.terraform.d/plugins/terraform-provider-phpipam]
2020-03-12T14:58:47.799Z [DEBUG] plugin: plugin started: path=/home/.terraform.d/plugins/terraform-provider-phpipam pid=130662
2020-03-12T14:58:47.799Z [DEBUG] plugin: waiting for RPC address: path=/home/.terraform.d/plugins/terraform-provider-phpipam
2020-03-12T14:58:47.806Z [INFO]  plugin.terraform-provider-phpipam: configuring server automatic mTLS: timestamp=2020-03-12T14:58:47.806Z
2020-03-12T14:58:47.840Z [DEBUG] plugin.terraform-provider-phpipam: plugin address: address=/tmp/plugin114287294 network=unix timestamp=2020-03-12T14:58:47.840Z
2020-03-12T14:58:47.840Z [DEBUG] plugin: using plugin: version=5
2020-03-12T14:58:47.912Z [DEBUG] plugin: plugin process exited: path=/home/.terraform.d/plugins/terraform-provider-phpipam pid=130662
2020-03-12T14:58:47.912Z [DEBUG] plugin: plugin exited
2020/03/12 14:58:47 [INFO] backend/local: apply calling Refresh
2020/03/12 14:58:47 [INFO] terraform: building graph: GraphTypeRefresh
2020/03/12 14:58:47 [DEBUG] ProviderTransformer: "data.phpipam_subnet.subnet" (*terraform.NodeRefreshableDataResource) needs provider.phpipam
2020/03/12 14:58:47 [DEBUG] ReferenceTransformer: "data.phpipam_subnet.subnet" references: []
2020/03/12 14:58:47 [DEBUG] ReferenceTransformer: "provider.phpipam" references: []
2020/03/12 14:58:47 [DEBUG] Starting graph walk: walkRefresh
2020-03-12T14:58:47.914Z [INFO]  plugin: configuring client automatic mTLS
2020-03-12T14:58:47.944Z [DEBUG] plugin: starting plugin: path=/home/.terraform.d/plugins/terraform-provider-phpipam args=[/home/.terraform.d/plugins/terraform-provider-phpipam]
2020-03-12T14:58:47.944Z [DEBUG] plugin: plugin started: path=/home/.terraform.d/plugins/terraform-provider-phpipam pid=130673
2020-03-12T14:58:47.945Z [DEBUG] plugin: waiting for RPC address: path=/home/.terraform.d/plugins/terraform-provider-phpipam
2020-03-12T14:58:47.953Z [INFO]  plugin.terraform-provider-phpipam: configuring server automatic mTLS: timestamp=2020-03-12T14:58:47.953Z
2020-03-12T14:58:47.987Z [DEBUG] plugin.terraform-provider-phpipam: plugin address: address=/tmp/plugin379691844 network=unix timestamp=2020-03-12T14:58:47.987Z
2020-03-12T14:58:47.987Z [DEBUG] plugin: using plugin: version=5
2020-03-12T14:58:48.056Z [DEBUG] plugin.terraform-provider-phpipam: 2020/03/12 14:58:48 [DEBUG] Initializing PHPIPAM controllers
2020-03-12T14:58:48.056Z [DEBUG] plugin.terraform-provider-phpipam: 2020/03/12 14:58:48 Request Body Debug ................... {}
2020-03-12T14:58:48.217Z [DEBUG] plugin.terraform-provider-phpipam: 2020/03/12 14:58:48 Response Body Debug ................... {"code":200,"success":true,"data":{"token":"L3HU51DFkjkl0asd98as890","expires":"2020-03-12 20:57:14"},"time":0.057}
2020-03-12T14:58:48.217Z [DEBUG] plugin.terraform-provider-phpipam: 2020/03/12 14:58:48 Request Body Debug ................... {}
2020-03-12T14:58:48.274Z [DEBUG] plugin.terraform-provider-phpipam: 2020/03/12 14:58:48 Response Body Debug ................... {"code":200,"success":true,"data":[{"id":"3","name":"Crown","description":"ip address","masterSection":"0","permissions":"{\"2\":\"2\",\"3\":\"3\",\"6\":\"3\",\"7\":\"1\"}","strictMode":"1","subnetOrdering":"default","order":null,"editDate":"2020-01-06 13:14:19","showVLAN":"1","showVRF":"0","DNS":null,"showSupernetOnly":"0","links":[{"rel":"self","href":"\/api\/myapp\/sections\/3\/"}],"custom_fields":null}],"time":0.002}
2020/03/12 14:58:48 [DEBUG] Resource state not found for node "data.phpipam_subnet.subnet", instance data.phpipam_subnet.subnet
2020/03/12 14:58:48 [DEBUG] ReferenceTransformer: "data.phpipam_subnet.subnet" references: []
data.phpipam_subnet.subnet: Refreshing state...
2020-03-12T14:58:48.277Z [DEBUG] plugin.terraform-provider-phpipam: 2020/03/12 14:58:48 Request Body Debug ................... {}
2020-03-12T14:58:48.337Z [DEBUG] plugin.terraform-provider-phpipam: 2020/03/12 14:58:48 Response Body Debug ................... {"code":200,"success":true,"data":[{"id":"1780","subnet":"<IP_ADDRESS>","mask":"24","sectionId":"3","description":"Shared","firewallAddressObject":null,"vrfId":"0","masterSubnetId":"1629","allowRequests":"0","vlanId":"13","showName":"1","device":"0","permissions":"{\"2\":\"2\",\"7\":\"1\"}","pingSubnet":"0","discoverSubnet":"0","DNSrecursive":"0","DNSrecords":"0","nameserverId":"0","scanAgent":"0","isFolder":"0","isFull":"0","tag":"2","editDate":"2020-01-06 13:10:06","linked_subnet":null,"lastScan":null,"lastDiscovery":null,"resolveDNS":"0","threshold":"0","location":"0","custom_AS-New":null,"customer_id":null,"links":[{"rel":"self","href":"\/api\/myapp\/subnets\/1780\/"}],"custom_fields":{"custom_Site":"NL-AMS-DR","custom_AS":"AS 65506 - NL DR"}}],"time":0.006}
2020-03-12T14:58:48.340Z [DEBUG] plugin: plugin process exited: path=/home/.terraform.d/plugins/terraform-provider-phpipam pid=130673
2020-03-12T14:58:48.340Z [DEBUG] plugin: plugin exited
2020/03/12 14:58:48 [INFO] backend/local: apply calling Plan
2020/03/12 14:58:48 [INFO] terraform: building graph: GraphTypePlan
2020/03/12 14:58:48 [DEBUG] ProviderTransformer: "phpipam_first_free_address.new_ip" (*terraform.NodePlannableResource) needs provider.phpipam
2020/03/12 14:58:48 [DEBUG] ProviderTransformer: "data.phpipam_subnet.subnet" (*terraform.NodePlannableResource) needs provider.phpipam
2020/03/12 14:58:48 [DEBUG] ReferenceTransformer: "provider.phpipam" references: []
2020/03/12 14:58:48 [DEBUG] ReferenceTransformer: "phpipam_first_free_address.new_ip" references: [data.phpipam_subnet.subnet]
2020/03/12 14:58:48 [DEBUG] ReferenceTransformer: "data.phpipam_subnet.subnet" references: []
2020/03/12 14:58:48 [DEBUG] Starting graph walk: walkPlan
2020-03-12T14:58:48.343Z [INFO]  plugin: configuring client automatic mTLS
2020-03-12T14:58:48.375Z [DEBUG] plugin: starting plugin: path=/home/.terraform.d/plugins/terraform-provider-phpipam args=[/home/.terraform.d/plugins/terraform-provider-phpipam]
2020-03-12T14:58:48.375Z [DEBUG] plugin: plugin started: path=/home/.terraform.d/plugins/terraform-provider-phpipam pid=130682
2020-03-12T14:58:48.375Z [DEBUG] plugin: waiting for RPC address: path=/home/.terraform.d/plugins/terraform-provider-phpipam
2020-03-12T14:58:48.384Z [INFO]  plugin.terraform-provider-phpipam: configuring server automatic mTLS: timestamp=2020-03-12T14:58:48.384Z
2020-03-12T14:58:48.416Z [DEBUG] plugin: using plugin: version=5
2020-03-12T14:58:48.416Z [DEBUG] plugin.terraform-provider-phpipam: plugin address: address=/tmp/plugin142951034 network=unix timestamp=2020-03-12T14:58:48.416Z
2020-03-12T14:58:48.484Z [DEBUG] plugin.terraform-provider-phpipam: 2020/03/12 14:58:48 [DEBUG] Initializing PHPIPAM controllers
2020-03-12T14:58:48.484Z [DEBUG] plugin.terraform-provider-phpipam: 2020/03/12 14:58:48 Request Body Debug ................... {}
2020-03-12T14:58:48.598Z [DEBUG] plugin.terraform-provider-phpipam: 2020/03/12 14:58:48 Response Body Debug ................... {"code":200,"success":true,"data":{"token":"L3HU51DFkjkl0asd98as890","expires":"2020-03-12 20:57:14"},"time":0.011}
2020-03-12T14:58:48.598Z [DEBUG] plugin.terraform-provider-phpipam: 2020/03/12 14:58:48 Request Body Debug ................... {}
2020-03-12T14:58:48.654Z [DEBUG] plugin.terraform-provider-phpipam: 2020/03/12 14:58:48 Response Body Debug ................... {"code":200,"success":true,"data":[{"id":"3","name":"Crown","description":"ip address","masterSection":"0","permissions":"{\"2\":\"2\",\"3\":\"3\",\"6\":\"3\",\"7\":\"1\"}","strictMode":"1","subnetOrdering":"default","order":null,"editDate":"2020-01-06 13:14:19","showVLAN":"1","showVRF":"0","DNS":null,"showSupernetOnly":"0","links":[{"rel":"self","href":"\/api\/myapp\/sections\/3\/"}],"custom_fields":null}],"time":0.002}
2020/03/12 14:58:48 [DEBUG] ReferenceTransformer: "data.phpipam_subnet.subnet" references: []
2020/03/12 14:58:48 [DEBUG] Resource instance state not found for node "phpipam_first_free_address.new_ip[0]", instance phpipam_first_free_address.new_ip[0]
2020/03/12 14:58:48 [DEBUG] Resource instance state not found for node "phpipam_first_free_address.new_ip[1]", instance phpipam_first_free_address.new_ip[1]
2020/03/12 14:58:48 [DEBUG] ReferenceTransformer: "phpipam_first_free_address.new_ip[0]" references: []
2020/03/12 14:58:48 [DEBUG] ReferenceTransformer: "phpipam_first_free_address.new_ip[1]" references: []
2020-03-12T14:58:48.662Z [DEBUG] plugin: plugin process exited: path=/home/.terraform.d/plugins/terraform-provider-phpipam pid=130682
2020-03-12T14:58:48.662Z [DEBUG] plugin: plugin exited

An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # phpipam_first_free_address.new_ip[0] will be created
  + resource "phpipam_first_free_address" "new_ip" {
      + address_id        = (known after apply)
2020/03/12 14:58:48 [DEBUG] command: asking for input: "Do you want to perform these actions?"
      + description       = "Managed by Terraform"
      + device_id         = (known after apply)
      + edit_date         = (known after apply)
      + exclude_ping      = (known after apply)
      + hostname          = "tf-test-host.test.internal"
      + id                = (known after apply)
      + ip_address        = (known after apply)
      + is_gateway        = (known after apply)
      + last_seen         = (known after apply)
      + mac_address       = (known after apply)
      + note              = (known after apply)
      + owner             = (known after apply)
      + ptr_record_id     = (known after apply)
      + skip_ptr_record   = (known after apply)
      + state_tag_id      = (known after apply)
      + subnet_id         = 1780
      + switch_port_label = (known after apply)
    }

  # phpipam_first_free_address.new_ip[1] will be created
  + resource "phpipam_first_free_address" "new_ip" {
      + address_id        = (known after apply)
      + description       = "Managed by Terraform"
      + device_id         = (known after apply)
      + edit_date         = (known after apply)
      + exclude_ping      = (known after apply)
      + hostname          = "tf-test-host.test.internal"
      + id                = (known after apply)
      + ip_address        = (known after apply)
      + is_gateway        = (known after apply)
      + last_seen         = (known after apply)
      + mac_address       = (known after apply)
      + note              = (known after apply)
      + owner             = (known after apply)
      + ptr_record_id     = (known after apply)
      + skip_ptr_record   = (known after apply)
      + state_tag_id      = (known after apply)
      + subnet_id         = 1780
      + switch_port_label = (known after apply)
    }

Plan: 2 to add, 0 to change, 0 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes
2020/03/12 14:58:56 [INFO] backend/local: apply calling Apply
2020/03/12 14:58:56 [INFO] terraform: building graph: GraphTypeApply
2020/03/12 14:58:56 [DEBUG] Resource state not found for node "phpipam_first_free_address.new_ip[1]", instance phpipam_first_free_address.new_ip[1]
2020/03/12 14:58:56 [DEBUG] Resource state not found for node "phpipam_first_free_address.new_ip[0]", instance phpipam_first_free_address.new_ip[0]
2020/03/12 14:58:56 [DEBUG] ProviderTransformer: "data.phpipam_subnet.subnet (prepare state)" (*terraform.NodeApplyableResource) needs provider.phpipam
2020/03/12 14:58:56 [DEBUG] ProviderTransformer: "phpipam_first_free_address.new_ip[1]" (*terraform.NodeApplyableResourceInstance) needs provider.phpipam
2020/03/12 14:58:56 [DEBUG] ProviderTransformer: "phpipam_first_free_address.new_ip[0]" (*terraform.NodeApplyableResourceInstance) needs provider.phpipam
2020/03/12 14:58:56 [DEBUG] ProviderTransformer: "phpipam_first_free_address.new_ip (prepare state)" (*terraform.NodeApplyableResource) needs provider.phpipam
2020/03/12 14:58:56 [DEBUG] ReferenceTransformer: "phpipam_first_free_address.new_ip (prepare state)" references: []
2020/03/12 14:58:56 [DEBUG] ReferenceTransformer: "data.phpipam_subnet.subnet (prepare state)" references: []
2020/03/12 14:58:56 [DEBUG] ReferenceTransformer: "phpipam_first_free_address.new_ip[1]" references: [data.phpipam_subnet.subnet (prepare state)]
2020/03/12 14:58:56 [DEBUG] ReferenceTransformer: "phpipam_first_free_address.new_ip[0]" references: [data.phpipam_subnet.subnet (prepare state)]
2020/03/12 14:58:56 [DEBUG] ReferenceTransformer: "provider.phpipam" references: []
2020/03/12 14:58:56 [DEBUG] Starting graph walk: walkApply

2020-03-12T14:58:56.392Z [INFO]  plugin: configuring client automatic mTLS
2020-03-12T14:58:56.427Z [DEBUG] plugin: starting plugin: path=/home/.terraform.d/plugins/terraform-provider-phpipam args=[/home/.terraform.d/plugins/terraform-provider-phpipam]
2020-03-12T14:58:56.428Z [DEBUG] plugin: plugin started: path=/home/.terraform.d/plugins/terraform-provider-phpipam pid=130696
2020-03-12T14:58:56.428Z [DEBUG] plugin: waiting for RPC address: path=/home/.terraform.d/plugins/terraform-provider-phpipam
2020-03-12T14:58:56.437Z [INFO]  plugin.terraform-provider-phpipam: configuring server automatic mTLS: timestamp=2020-03-12T14:58:56.436Z
2020-03-12T14:58:56.469Z [DEBUG] plugin.terraform-provider-phpipam: plugin address: address=/tmp/plugin255522334 network=unix timestamp=2020-03-12T14:58:56.469Z
2020-03-12T14:58:56.470Z [DEBUG] plugin: using plugin: version=5
2020-03-12T14:58:56.541Z [DEBUG] plugin.terraform-provider-phpipam: 2020/03/12 14:58:56 [DEBUG] Initializing PHPIPAM controllers
2020-03-12T14:58:56.541Z [DEBUG] plugin.terraform-provider-phpipam: 2020/03/12 14:58:56 Request Body Debug ................... {}
2020-03-12T14:58:56.793Z [DEBUG] plugin.terraform-provider-phpipam: 2020/03/12 14:58:56 Response Body Debug ................... {"code":200,"success":true,"data":{"token":"L3HU51DFkjkl0asd98as890","expires":"2020-03-12 20:57:22"},"time":0.138}
2020-03-12T14:58:56.793Z [DEBUG] plugin.terraform-provider-phpipam: 2020/03/12 14:58:56 Request Body Debug ................... {}
2020-03-12T14:58:56.867Z [DEBUG] plugin.terraform-provider-phpipam: 2020/03/12 14:58:56 Response Body Debug ................... {"code":200,"success":true,"data":[{"id":"3","name":"Crown","description":"ip address","masterSection":"0","permissions":"{\"2\":\"2\",\"3\":\"3\",\"6\":\"3\",\"7\":\"1\"}","strictMode":"1","subnetOrdering":"default","order":null,"editDate":"2020-01-06 13:14:19","showVLAN":"1","showVRF":"0","DNS":null,"showSupernetOnly":"0","links":[{"rel":"self","href":"\/api\/myapp\/sections\/3\/"}],"custom_fields":null}],"time":0.002}
phpipam_first_free_address.new_ip[1]: Creating...
2020/03/12 14:58:56 [DEBUG] phpipam_first_free_address.new_ip[1]: applying the planned Create change
2020-03-12T14:58:56.871Z [DEBUG] plugin.terraform-provider-phpipam: 2020/03/12 14:58:56 Request Body Debug ................... {"description":"Managed by Terraform","hostname":"tf-test-host.test.internal"}
2020-03-12T14:58:56.922Z [DEBUG] plugin.terraform-provider-phpipam: 2020/03/12 14:58:56 Response Body Debug ................... {"code":404,"success":0,"message":"Invalid URL"}
2020/03/12 14:58:56 [DEBUG] phpipam_first_free_address.new_ip[1]: apply errored, but we're indicating that via the Error pointer rather than returning it: Non-API error (404 Not Found): {"code":404,"success":0,"message":"Invalid URL"}
2020/03/12 14:58:56 [ERROR] <root>: eval: *terraform.EvalApplyPost, err: Non-API error (404 Not Found): {"code":404,"success":0,"message":"Invalid URL"}
2020/03/12 14:58:56 [ERROR] <root>: eval: *terraform.EvalSequence, err: Non-API error (404 Not Found): {"code":404,"success":0,"message":"Invalid URL"}
phpipam_first_free_address.new_ip[0]: Creating...
2020/03/12 14:58:56 [DEBUG] phpipam_first_free_address.new_ip[0]: applying the planned Create change
2020-03-12T14:58:56.925Z [DEBUG] plugin.terraform-provider-phpipam: 2020/03/12 14:58:56 Request Body Debug ................... {"description":"Managed by Terraform","hostname":"tf-test-host.test.internal"}
2020-03-12T14:58:56.975Z [DEBUG] plugin.terraform-provider-phpipam: 2020/03/12 14:58:56 Response Body Debug ................... {"code":404,"success":0,"message":"Invalid URL"}
2020/03/12 14:58:56 [DEBUG] phpipam_first_free_address.new_ip[0]: apply errored, but we're indicating that via the Error pointer rather than returning it: Non-API error (404 Not Found): {"code":404,"success":0,"message":"Invalid URL"}
2020/03/12 14:58:56 [ERROR] <root>: eval: *terraform.EvalApplyPost, err: Non-API error (404 Not Found): {"code":404,"success":0,"message":"Invalid URL"}
2020/03/12 14:58:56 [ERROR] <root>: eval: *terraform.EvalSequence, err: Non-API error (404 Not Found): {"code":404,"success":0,"message":"Invalid URL"}

Error: Non-API error (404 Not Found): {"code":404,"success":0,"message":"Invalid URL"}

  on main.tf line 13, in resource "phpipam_first_free_address" "new_ip":
  13: resource "phpipam_first_free_address" "new_ip" {

Error: Non-API error (404 Not Found): {"code":404,"success":0,"message":"Invalid URL"}

  on main.tf line 13, in resource "phpipam_first_free_address" "new_ip":
  13: resource "phpipam_first_free_address" "new_ip" {

2020-03-12T14:58:56.982Z [DEBUG] plugin: plugin process exited: path=/home/.terraform.d/plugins/terraform-provider-phpipam pid=130696
2020-03-12T14:58:56.982Z [DEBUG] plugin: plugin exited

@lord-kyron based on debug, seems used different app_id in phpIPAM and terraform provider.
Can you please send screenshot of phpIPAM API configuration page and you terraform provider credential configuration(without login/pass)?

@pavel-z1 - as you requested
Screenshot from ipam app_id:

Terraform provider config:
provider "phpipam" {
  app_id   = "myapp"
  endpoint = "http://<IP_ADDRESS>/api/"
  password = "PASSWORD"
  username = "USERNAME"
}

data "phpipam_subnet" "subnet" {
  subnet_address = "<IP_ADDRESS>"
  subnet_mask    = 24
}

resource "phpipam_first_free_address" "new_ip" {
  count = 2

  subnet_id   = data.phpipam_subnet.subnet.subnet_id
  hostname    = "tf-test-host-%d"
  description = "Managed by Terraform"

  lifecycle {
    ignore_changes = [
      subnet_id,
    ]
  }
}

Hi @lord-kyron
I've added debug of Request URL to the phpipam-sdk-go - https://github.com/pavel-z1/phpipam-sdk-go/commit/a1ff3ad17e47f3892a955b5191d9bdceb7875263
Now we will see Request Url and Request Body data. This will help us to debug phpIPAM.
Example of debug results:
2020-03-13T08:06:03.163+0100 [DEBUG] plugin.terraform-provider-phpipam: 2020/03/13 08:06:03 Request URL Debug ...................Method: GET, UR: http://<IP_ADDRESS>/api/terraform/sections/
2020-03-13T08:06:03.203+0100 [DEBUG] plugin.terraform-provider-phpipam: 2020/03/13 08:06:03 Response Body Debug ................... {"code":200,"success":true,"data":[{"id":"2","name":"IPv6","description":"Section for IPv6 addresses","masterSection":"0","permissions":"{\"3\":\"1\",\"2\":\"2\"}","strictMode":"1","subnetOrdering":null,"order":null,"editDate":null,"showSubnet":"1","showVLAN":"0","showVRF":"0","showSupernetOnly":"0","DNS":null},{"id":"1","name":"Rotterdam DC02","description":"Section for customers","masterSection":"0","permissions":"{\"2\":\"2\",\"3\":\"1\"}","strictMode":"1","subnetOrdering":"default","order":null,"editDate":"2020-03-12 10:56:24","showSubnet":"1","showVLAN":"0","showVRF":"0","showSupernetOnly":"0","DNS":null}],"time":0.004}
phpipam_first_free_address.new_ip[0]: Creating...
2020/03/13 08:06:03 [DEBUG] phpipam_first_free_address.new_ip[0]: applying the planned Create change
2020-03-13T08:06:03.208+0100 [DEBUG] plugin.terraform-provider-phpipam: 2020/03/13 08:06:03 Request Body Debug ................... {"description":"Managed by Terraform","hostname":"tf-test-host%d.test.internal"}
2020-03-13T08:06:03.208+0100 [DEBUG] plugin.terraform-provider-phpipam: 2020/03/13 08:06:03 Request URL Debug ...................Method: POST, UR: http://<IP_ADDRESS>/api/terraform/addresses/first_free/8
2020-03-13T08:06:03.264+0100 [DEBUG] plugin.terraform-provider-phpipam: 2020/03/13 08:06:03 Response Body Debug ................... {"code":201,"success":true,"message":"Address created","id":"41","data":"<IP_ADDRESS>","time":0.019}
2020-03-13T08:06:03.264+0100 [DEBUG] plugin.terraform-provider-phpipam: 2020/03/13 08:06:03 [DEBUG] Start Reading IP Address ..............
2020-03-13T08:06:03.264+0100 [DEBUG] plugin.terraform-provider-phpipam: 2020/03/13 08:06:03 Request Body Debug ................... {}
2020-03-13T08:06:03.265+0100 [DEBUG] plugin.terraform-provider-phpipam: 2020/03/13 08:06:03 Request URL Debug ...................Method: GET, UR: http://<IP_ADDRESS>/api/terraform/addresses/search/<IP_ADDRESS>/
2020-03-13T08:06:03.308+0100 [DEBUG] plugin.terraform-provider-phpipam: 2020/03/13 08:06:03 Response Body Debug ................... {"code":200,"success":true,"data":[{"id":"41","subnetId":"8","ip":"<IP_ADDRESS>","is_gateway":"0","description":"Managed by Terraform","hostname":"tf-test-host%d.test.internal","mac":null,"owner":null,"tag":"2","deviceId":null,"location":null,"port":null,"note":null,"lastSeen":"1970-01-01 00:00:01","excludePing":"0","PTRignore":"0","PTR":"0","firewallAddressObject":null,"editDate":null,"customer_id":null}],"time":0.007}
phpipam_first_free_address.new_ip[0]: Creation complete after 0s [id=41]
phpipam_first_free_address.new_ip[1]: Creating...
2020/03/13 08:06:03 [DEBUG] phpipam_first_free_address.new_ip[1]: applying the planned Create change
2020-03-13T08:06:03.322+0100 [DEBUG] plugin.terraform-provider-phpipam: 2020/03/13 08:06:03 Request Body Debug ................... {"description":"Managed by Terraform","hostname":"tf-test-host%d.test.internal"}
2020-03-13T08:06:03.322+0100 [DEBUG] plugin.terraform-provider-phpipam: 2020/03/13 08:06:03 Request URL Debug ...................Method: POST, UR: http://<IP_ADDRESS>/api/terraform/addresses/first_free/8
2020-03-13T08:06:03.374+0100 [DEBUG] plugin.terraform-provider-phpipam: 2020/03/13 08:06:03 Response Body Debug ................... {"code":201,"success":true,"message":"Address created","id":"42","data":"<IP_ADDRESS>","time":0.017}
2020-03-13T08:06:03.374+0100 [DEBUG] plugin.terraform-provider-phpipam: 2020/03/13 08:06:03 [DEBUG] Start Reading IP Address ..............
2020-03-13T08:06:03.374+0100 [DEBUG] plugin.terraform-provider-phpipam: 2020/03/13 08:06:03 Request Body Debug ................... {}
2020-03-13T08:06:03.374+0100 [DEBUG] plugin.terraform-provider-phpipam: 2020/03/13 08:06:03 Request URL Debug ...................Method: GET, UR: http://<IP_ADDRESS>/api/terraform/addresses/search/<IP_ADDRESS>/
2020-03-13T08:06:03.417+0100 [DEBUG] plugin.terraform-provider-phpipam: 2020/03/13 08:06:03 Response Body Debug ................... {"code":200,"success":true,"data":[{"id":"42","subnetId":"8","ip":"<IP_ADDRESS>","is_gateway":"0","description":"Managed by Terraform","hostname":"tf-test-host%d.test.internal","mac":null,"owner":null,"tag":"2","deviceId":null,"location":null,"port":null,"note":null,"lastSeen":"1970-01-01 00:00:01","excludePing":"0","PTRignore":"0","PTR":"0","firewallAddressObject":null,"editDate":null,"customer_id":null}],"time":0.006}

Please rebuild your terraform-provider-phpipam and execute terraform again:
terraform apply -parallelism=1

Send please results of terraform debug.

@pavel-z1
phpipam_first_free_address.new_ip[0]: Creating...
2020/03/13 08:14:17 [DEBUG] phpipam_first_free_address.new_ip[0]: applying the planned Create change
2020-03-13T08:14:17.287Z [DEBUG] plugin.terraform-provider-phpipam: 2020/03/13 08:14:17 Request Body Debug ................... {"description":"Managed by Terraform","hostname":"tf-test-host"}
2020-03-13T08:14:17.287Z [DEBUG] plugin.terraform-provider-phpipam: 2020/03/13 08:14:17 Request URL Debug ...................Method: POST, UR: http://<IP_ADDRESS>/api/myapp/addresses/first_free/1780
2020-03-13T08:14:17.337Z [DEBUG] plugin.terraform-provider-phpipam: 2020/03/13 08:14:17 Response Body Debug ................... {"code":404,"success":0,"message":"Invalid URL"}
2020/03/13 08:14:17 [DEBUG] phpipam_first_free_address.new_ip[0]: apply errored, but we're indicating that via the Error pointer rather than returning it: Non-API error (404 Not Found): {"code":404,"success":0,"message":"Invalid URL"}
2020/03/13 08:14:17 [ERROR] <root>: eval: *terraform.EvalApplyPost, err: Non-API error (404 Not Found): {"code":404,"success":0,"message":"Invalid URL"}
2020/03/13 08:14:17 [ERROR] <root>: eval: *terraform.EvalSequence, err: Non-API error (404 Not Found): {"code":404,"success":0,"message":"Invalid URL"}
phpipam_first_free_address.new_ip[1]: Creating...
2020/03/13 08:14:17 [DEBUG] phpipam_first_free_address.new_ip[1]: applying the planned Create change
2020-03-13T08:14:17.342Z [DEBUG] plugin.terraform-provider-phpipam: 2020/03/13 08:14:17 Request Body Debug ................... {"description":"Managed by Terraform","hostname":"tf-test-host"}
2020-03-13T08:14:17.342Z [DEBUG] plugin.terraform-provider-phpipam: 2020/03/13 08:14:17 Request URL Debug ...................Method: POST, UR: http://<IP_ADDRESS>/api/myapp/addresses/first_free/1780
2020-03-13T08:14:17.393Z [DEBUG] plugin.terraform-provider-phpipam: 2020/03/13 08:14:17 Response Body Debug ................... {"code":404,"success":0,"message":"Invalid URL"}
2020/03/13 08:14:17 [DEBUG] phpipam_first_free_address.new_ip[1]: apply errored, but we're indicating that via the Error pointer rather than returning it: Non-API error (404 Not Found): {"code":404,"success":0,"message":"Invalid URL"}
2020/03/13 08:14:17 [ERROR] <root>: eval: *terraform.EvalApplyPost, err: Non-API error (404 Not Found): {"code":404,"success":0,"message":"Invalid URL"}
2020/03/13 08:14:17 [ERROR] <root>: eval: *terraform.EvalSequence, err: Non-API error (404 Not Found): {"code":404,"success":0,"message":"Invalid URL"}

Error: Non-API error (404 Not Found): {"code":404,"success":0,"message":"Invalid URL"}

  on main.tf line 13, in resource "phpipam_first_free_address" "new_ip":
  13: resource "phpipam_first_free_address" "new_ip" {

Error: Non-API error (404 Not Found): {"code":404,"success":0,"message":"Invalid URL"}

  on main.tf line 13, in resource "phpipam_first_free_address" "new_ip":
  13: resource "phpipam_first_free_address" "new_ip" {

2020-03-13T08:14:17.399Z [DEBUG] plugin: plugin process exited: path=/home/ansible/.terraform.d/plugins/terraform-provider-phpipam pid=156574
2020-03-13T08:14:17.399Z [DEBUG] plugin: plugin exited

Aaah @pavel-z1 - I think I found the problem.
When I try to access the same address like this: http://<IP_ADDRESS>/api/myapp/addresses/first_free/1780 - it returns me 404, but when I add "/" on the end like this:
http://<IP_ADDRESS>/api/myapp/addresses/first_free/1780/ - then it seems to be working!
I am working on phpIPAM IP address management [v1.4]

@lord-kyron , thank you for information.
Fix was added https://github.com/pavel-z1/phpipam-sdk-go/commit/d0ff3300814c6a264161e5555c0554fd3247c270
Try to rebuild provider now.

@lord-kyron Done
https://github.com/lord-kyron/terraform-provider-phpipam/commit/f75f482798953e710bb2bb2adbeade07d0619d34

Wonderful! Thank you very much for all your work!
Hope you will continue to contribute to this project!
I've added new major release of the provider v1.0 because it now supports this crucial functionality!
Thanks once again!

Thank you too for help with testing and new release.

@pavel-z1 - I have some terraform difficulty, that I am trying to get over but I cannot understand if and how it can be done. I was wondering if you have some knowledge / experience about it - I am trying to use two providers this terraform-phpipam-rpovider and vsphere provider together and in one single build to reserve IPs in IPAM with the first module, then expose them to the second provider and use then in the vsphere provider build. Can you help me somehow with that?
Thank you!

Hi @lord-kyron
On this page terraform well described case that you need - https://www.terraform.io/docs/modules/composition.html
  source = "modules/azurerm-k8s-cluster"

  # (Azure-specific configuration arguments)
}

module "monitoring_tools" {
  source = "modules/monitoring_tools"

  cluster_hostname = module.k8s_cluster.hostname
}

Hostname from module k8s_cluster is used in the module monitoring_tools
In you case you need define two modules in one place. In the second (vsphere) use ip resource from second module.
For example:
module.module1.phpipam_address.ip_address

@pavel-z1 - thank you@ I've successfully created several modules and they are working like charm! Thank you so much!

@pavel-z1 - do you know how can I (even IF it can be done) use the data to check if ip adress is already existing in IP (by hostname for example) and reserve the next free IP address from the subnet, only if an address with the same hostname is not already present?
I've tried to get data for the address_search for the subnet and the resource to depends_on this data, but it created the IP anyway even if it was existing.

Hi @lord-kyron ,
In you case, better to use datasource - phpipam_addresses
You can use parameter hostname to search ip with hostname.
Example from ReadMe:
The phpipam_addresses Data Source
The phpipam_addresses data source allows you to search for IP addresses, much in the same way as you can in the single-form phpipam_address data source. However, multiple addresses are returned from this data source as a single list of address IDs as they are found in the PHPIPAM database. You can then use the single-form phpipam_address data source to extract the IP data for each matched address in the database.
Example:
⚠ NOTE: The below example requires Terraform v0.12.0 or later!
data "phpipam_addresses" "address_search" {
  subnet_id = 3

  custom_field_filter {
    CustomTestAddresses = ".*terraform.*"
  }
}

data "phpipam_address" "addresses" {
  count      = length(data.phpipam_addresses.address_search.address_ids)
  address_id = element(data.phpipam_addresses.address_search.address_ids, count.index)
}

output "ip_addresses" {
  value = [data.phpipam_address.addresses.*.ip_address]
}

Argument Reference
The data source takes the following parameters:
subnet_id (Required) - The ID of the subnet that the address resides in. This is required to search on the description or hostname fields.
One of the following fields is required alongside subnet_id:
description - The description of the IP address. subnet_id is required when using this field.
hostname - The host name of the IP address. subnet_id is required when using this field.
custom_field_filter - A map of custom fields to search for. The filter values are regular expressions that follow the RE2 syntax for which you can find documentation here. All fields need to match for the match to succeed.
⚠ NOTE: An empty or unspecified custom_field_filter value is the equivalent to a regular expression that matches everything, and hence will return all addresses that contain the referenced custom field key!

Hi everyone,
I'm facing the same problem trying to automate with terraform. I agree that php-ipam has to add this improvement. @lord-kyron first of all thanks for provider v1 (including count feature). Regarding to:
...you must apply this fix<EMAIL_ADDRESS>it only applies to v1.4. I tried to patch v1.3 but it has Mysql PDO problems.
For people that need a workaround (beeing at v1.3 and can't upgrade to 1.4), can be accomplished by phpipam_addresses:

First, you have to add a description (for example: DESCRIPTION_TO_SEARCH) to all IPs you want to get. (I know...it's a workaround). Feel free to change this attribute. Is a conditional to get "free" ips that are already "assigned".

Create a file called phpipam-login.sh with this content (maybe you can use token from phpipam provider):

#!/bin/bash
TOKEN=$(curl -sS -X POST --user <user>:<password> -H 'Content-type: application/json' https://<server-ipam>/api/<clientid>/user/ | jq -r '.data.token')
echo -n "{\"token\":\"${TOKEN}\"}

Then add this to you tf file (change count parameter as many IPs you want to reserve. You can add more attributes to PATCH  curl command):

data "phpipam_addresses" "address_search" {
  subnet_id = data.phpipam_subnet.subnet.subnet_id
  description = "DESCRIPTION_TO_SEARCH"
}

data "phpipam_address" "addresses" {
  count      = "${length(data.phpipam_addresses.address_search.address_ids)}"
  address_id = "${element(data.phpipam_addresses.address_search.address_ids, count.index)}"
}

data "external" "phpipam_login" {
  program = ["bash", "${path.module}/phpipam-login.sh"]
}

# Change description and other attributes of each IP (description has to be changed!)
# Add to --data as many attributes you want to change for "reserve"
resource "null_resource" "phpipam_assignip" {
  count = 3
  provisioner "local-exec" {
    command = "curl -sS -X PATCH --data '{\"description\":\"Assigned!\"}' -H 'Content-type: application/json' -H 'token: ${data.external.phpipam_login.result["token"]}' https://<server-ipam>/api/<client-id>/addresses/${data.phpipam_address.addresses[count.index].id}/"
  }
}

Obviusly, It's not a solution... but if anyone needs something fast... may help

Hi there,
I'm facing same issue.
This is what terraform creates when using multiple provisioning:
Terraform will perform the following actions:

  # phpipam_address.address[0] will be created
  + resource "phpipam_address" "address" {
      + address_id           = (known after apply)
      + description          = "Managed by Terraform"
      + device_id            = (known after apply)
      + edit_date            = (known after apply)
      + exclude_ping         = (known after apply)
      + hostname             = "transacional-core-1.mydomain.comr"
      + id                   = (known after apply)
      + ip_address           = "<IP_ADDRESS>"
      + is_gateway           = (known after apply)
      + last_seen            = (known after apply)
      + mac_address          = (known after apply)
      + note                 = (known after apply)
      + owner                = (known after apply)
      + ptr_record_id        = (known after apply)
      + remove_dns_on_delete = true
      + skip_ptr_record      = (known after apply)
      + state_tag_id         = (known after apply)
      + subnet_id            = 63
      + switch_port_label    = (known after apply)
    }

  # phpipam_address.address[1] will be created
  + resource "phpipam_address" "address" {
      + address_id           = (known after apply)
      + description          = "Managed by Terraform"
      + device_id            = (known after apply)
      + edit_date            = (known after apply)
      + exclude_ping         = (known after apply)
      + hostname             = "transacional-core-2.mydomain.comr"
      + id                   = (known after apply)
      + ip_address           = "<IP_ADDRESS>"
      + is_gateway           = (known after apply)
      + last_seen            = (known after apply)
      + mac_address          = (known after apply)
      + note                 = (known after apply)
      + owner                = (known after apply)
      + ptr_record_id        = (known after apply)
      + remove_dns_on_delete = true
      + skip_ptr_record      = (known after apply)
      + state_tag_id         = (known after apply)
      + subnet_id            = 63
      + switch_port_label    = (known after apply)
    }

  # phpipam_address.address[2] will be created
  + resource "phpipam_address" "address" {
      + address_id           = (known after apply)
      + description          = "Managed by Terraform"
      + device_id            = (known after apply)
      + edit_date            = (known after apply)
      + exclude_ping         = (known after apply)
      + hostname             = "transacional-core-3.mydomain.comr"
      + id                   = (known after apply)
      + ip_address           = "<IP_ADDRESS>"
      + is_gateway           = (known after apply)
      + last_seen            = (known after apply)
      + mac_address          = (known after apply)
      + note                 = (known after apply)
      + owner                = (known after apply)
      + ptr_record_id        = (known after apply)
      + remove_dns_on_delete = true
      + skip_ptr_record      = (known after apply)
      + state_tag_id         = (known after apply)
      + subnet_id            = 63
      + switch_port_label    = (known after apply)
    }

Then when creating:
vsphere_folder.folder: Creating...
phpipam_address.address[1]: Creating...
phpipam_address.address[1]: Creation complete after 1s [id=6566]
phpipam_address.address[0]: Creating...
phpipam_address.address[2]: Creating...

Error: Error from API (409): IP address already exists

  on main.tf line 15, in resource "phpipam_address" "address":
  15: resource "phpipam_address" "address" {

Error: Error from API (409): IP address already exists

  on main.tf line 15, in resource "phpipam_address" "address":
  15: resource "phpipam_address" "address" {

Error: error creating folder: ServerFaultCode: The name 'TRANSACIONAL-CORE' already exists.

  on main.tf line 60, in resource "vsphere_folder" "folder":
  60: resource "vsphere_folder" "folder" {

My resource config:
resource "phpipam_address" "address" {
  count       = var.vm_count
  subnet_id   = data.phpipam_subnet.subnet.subnet_id
  ip_address  = data.phpipam_first_free_address.next_address.ip_address
  hostname    = "transacional-core-${count.index+1}.mydomain.com"
  description = "Managed by Terraform"

  lifecycle {
    ignore_changes = [
      subnet_id
    ]
  }
}

And my vsphere resource:
resource "vsphere_virtual_machine" "cloned_virtual_machine" {
  count            = var.vm_count
  name             = "${var.vsphere_virtual_machine_name} ${count.index+1}"
  resource_pool_id = data.vsphere_resource_pool.pool.id
  datastore_id     = data.vsphere_datastore.datastore.id
  folder           = var.vsphere_folder
  depends_on  = [phpipam_address.address]

  num_cpus = 1
  memory   = 2048

  guest_id = data.vsphere_virtual_machine.template.guest_id

  scsi_type = data.vsphere_virtual_machine.template.scsi_type

  network_interface {
    network_id   = data.vsphere_network.network.id
    adapter_type = data.vsphere_virtual_machine.template.network_interface_types[0]
  }

  disk {
    label = "disk0"
    size = data.vsphere_virtual_machine.template.disks.0.size
  }

  clone {
    template_uuid = data.vsphere_virtual_machine.template.id
    customize {
      linux_options {
        host_name = "${var.vsphere_virtual_machine_name} ${count.index+1}"
        domain = "mydomain.com"
      }

      network_interface {
        ipv4_address = data.phpipam_first_free_address.next_address.ip_address
        ipv4_netmask = 24
      }

      dns_suffix_list = ["mydomain.com"]
      dns_server_list = ["<IP_ADDRESS>"]
      ipv4_gateway = "<IP_ADDRESS>"
    }
  }
}

Am I missing something here?
Best regards,
Rafael


Detach and remove migration disk

Hello @wmarquardt! Thanks for opening this PR.


Prevent race in iptables across different tools in the host

Description
When deploying multiple VMs on a host with multiple actions per host enabled the following lock in xtables is observed:
Wed Aug 28 17:04:45 2019 [Z0][VMM][I]: Command execution fail: cat << EOT | /var/tmp/one/vnm/802.1Q/post 'one-284'
Wed Aug 28 17:04:45 2019 [Z0][VMM][I]: Another app is currently holding the xtables lock. Perhaps you want to use the -w option?
Wed Aug 28 17:04:45 2019 [Z0][VMM][E]: post: Command Error: sudo iptables -I opennebula -m physdev --physdev-in one-284-0 --physdev-is-bridged -j one-284-0-o
Wed Aug 28 17:04:45 2019 [Z0][VMM][E]: post: ["/var/tmp/one/vnm/command.rb:64:in `block in run!'", "/var/tmp/one/vnm/command.rb:59:in `each'", "/var/tmp/one/vnm/command.rb:59:in `run!'", "/var/tmp/one/vnm/security_groups_iptables.rb:519:in `nic_pre'", "/var/tmp/one/vnm/sg_driver.rb:92:in `block in activate'", "/var/tmp/one/vnm/vnm_driver.rb:79:in `call'", "/var/tmp/one/vnm/vnm_driver.rb:79:in `block in process'", "/var/tmp/one/vnm/vm.rb:73:in `call'", "/var/tmp/one/vnm/vm.rb:73:in `block in each_nic'", "/var/tmp/one/vnm/vm.rb:72:in `each'", "/var/tmp/one/vnm/vm.rb:72:in `each_nic'", "/var/tmp/one/vnm/vnm_driver.rb:82:in `process'", "/var/tmp/one/vnm/sg_driver.rb:84:in `activate'", "/var/tmp/one/vnm/802.1Q/post:32:in `<main>'"]

To Reproduce

Enable multiple actions per host
instantiate several VMs with several NICs enabled
monitor the VM's logs for the above error message

Expected behavior
The VM's should be deployed successfully
Details

Affected Component: [Network]
Hypervisor: [KVM]
Version: [5.8.4]

Additional context
The suggested resolution by adding a timeout to the iptables works. A pull request is pending.

Progress Status

[ ] Branch created
[ ] Code committed to development branch
[ ] Testing - QA
[ ] Documentation
[ ] Release notes - resolved issues, compatibility, known issues
[ ] Code committed to upstream release/hotfix branches
[ ] Documentation committed to upstream release/hotfix branches

This was supposed to be addressed by the locking mechanism of the drivers. In particular the sg_driver has the locking enabled:
https://github.com/OpenNebula/one/blob/master/src/vnm_mad/remotes/lib/sg_driver.rb#L45
and iptables commands should be executed through the flock facilites see: https://github.com/OpenNebula/one/blob/master/src/vnm_mad/remotes/lib/vnm_driver.rb#L58

Are all VMs using the same network? If not, are the networks using different drivers o modes?

Well it happened when only 3 VMs were instantiated simultaneously on the same host and with the sg_driver and same VM Template...
Will try to reproduce it tomorrow with some more logging (any hints what to look for are welcome)

Hello Anton, when reproducing, pls check the locking code in /var/lib/one/remotes/vnm/vnm_driver.rb, if it's using (proper) locks:
        def lock
            if @locking
                driver_name = self.class.name.downcase
                @locking_file = File.open("/tmp/onevnm-#{driver_name}-lock","w")
                @locking_file.flock(File::LOCK_EX)
            end
        end

Also, I would try to experimentally change it to use a single hard coded driver independent lock name:
                @locking_file = File.open("/tmp/onevnm-ALL-lock","w")

Probably SG and VLAN drivers are competing for same resources, but using different lock names.

Hi All.
Managed to reproduce, but the issue is not in the OpenNebula's control. The locking is fine - there are no issues observed.
The xtables locking issue is caused by an external iptables call. In my case there was a 1 second poll of iptables started on same host by a colleague to monitor the iptables counters watch -n1 'iptables -nvx -L' that was racing with the VN MAD.
So I think it is better to have the iptables lock enabled because opennebula could not relay that it is the only service using iptables on the host. It could race with fail2ban or any other service/tool that could use iptables...
The proposed patch will protect OpenNebula for these racing issues. With the patch applied the iptables polling was failing from time to time, not the OpenNebula's vn mad. (And yes the "other" service could fail too, but it is "their" job to handle the case and wait for the xtables lock too...)

OK THANKS @atodorov-storpool  for the information

Just for reference, libvirt is using the *tables locking (if available)

We have added the wait lock for the iptables commands. ip_unpriv is needed by some drivers so it is kept in commands


Add the Aitchison distance

The Aitchison distance is a euclidedian metric to measure distances between compositions. I added the math developed in issue #4480, and hopefully the necessary codes for cdist and pdist. I haven't run the unit test, as I'm not used to code development.

Thanks @essicolo.
The test errors are real:
ERROR: Failure: AttributeError ('module' object has no attribute 'cdist_aitchison_wrap')

I'll have a quick look if I can spot an error, but I'd recommend trying to build and run tests locally. If you're on Linux or OS X then it should not be too difficult, this is the recommended way to build and run tests: https://docs.scipy.org/doc/numpy-dev/dev/development_environment.html#recommended-development-setup

This PR needs a rebase as well, a cleanup of the code in distance.py was just merged.

Ah, the test errors are because you didn't add any C code to spatial/src/distance_wrap.c. Have a look at what's done there for other distance metrics.

Since Aitchison distance is just the Euclidean distance of the clr (center-log ratio) transformed data points, do you need a separate C-level function? Doing the transformations on a per-vector basis will be slower than precomputing them.  Unless memory is a concern? This is somewhat similar to how cosine cdist is currently implemented.

@dezmondgoff you are right. I'm closing this one.


Adding CA rbac info

Same as in the non preview page, we had to add new RBAC to control access to CA data as a response to an MSRC security issue

@besiler : Thanks for your contribution! The author(s) have been notified to review your proposed change.

@markusvi
Can you review the proposed changes? IMPORTANT: When the changes are ready for publication, add a #sign-off comment to signal that the PR is ready for the review team to merge.
#label:"aq-pr-triaged"

@shlipsey3 can you add this on your side since it's so stale? Then we can just close this one.

reassign:shlipsey3

#reassign:@shlipsey3

For whoever picks this up - I'm about to sign off, but this is a stale PR so was started before I was added to this content group. Please let me know if there's anything needed to resolve the changes.

#sign-off

#please-close


Greet Check

Congratulations, @rahulgavhar! 🎉 Thank you for creating your issue for "Your Repo Name". Your contribution is greatly appreciated and we look forward to working with you to resolve the issue. Keep up the great work! Should you have any queries or require guidance, do not hesitate to ask.

Greet Token & Secret Working!


Error With Max Lvl Range

I am trying to setup where my tiers can only go so high or so low with levels I have my legendary set up at max = 5 and min = 3 but when I get a book in game it ends up giving me a lvl 1 enchant???

Pastebin your config.yml and enchantments.yml files. Also, tell me what enchantment it is you got when this happened.


Fix no user listed in org teams page

https://github.com/go-gitea/gitea/pull/22294 introduced this bug.
Before:

After:

The avatar function needs a default case to catch incorrect argument, panic or error log will helper developers in the future to catch low-level mistakes as early as possible.


LLAMA3 - Anyone Ran this experiment with llama3 ?

We are currently occupied with other projects and would greatly appreciate community contributions for benchmarking LLaMA-3.


object mints with only secondary unit quantities defined fail

A contract change will be necessary to allow mints that only have secondary units defined. This is useful when minting objects directly into a group of secondary holder addresses.  The contract is currently expecting and only verifies primary unit objects.  if none are found the object mint is considered invalid and is rejected.
Primary units are units held by the object address itself.
Secondary units are units held by an address other then the object address.

just verified this does work... it was actually a user error that caused the problem.


feat(polar): allow setting angleAxis.endAngle

Brief Information
This pull request is in the type of:

[ ] bug fixing
[x] new feature
[ ] others

What does this PR do?

Allow setting an endAngle alongside startAngle on a polar coordinate system.
Fixed issues

Details
Before: What was the problem?

After: How does it behave after the fixing?

Document Info
One of the following should be checked.

[x] This PR doesn't relate to document changes
[x] The document should be updated later
[ ] The document changes have been made in apache/echarts-doc#xxx

Misc
ZRender Changes

[ ] This PR depends on ZRender changes (ecomfe/zrender#xxx).

Related test cases or examples to use the new APIs
N.A.
Others
Merging options

[ ] Please squash the commits into a single one when merging.

Other information

Link to a working example here

Your suggestion indeed fixes the regression :)

@yassilah Thanks for this useful PR!

hey @Ovilia i want to join slack channel of apache so how can i


fixes for loadings-plot

@waxlamp first, forgive my meddling.  I did this because I wanted to get into the weeds a bit with your code and understand it, and this was the best way for me to do that.
If you'd like to simply read over it then make whatever changes you decide to keep by hand on your own branch, that won't bother me at all.
This branch consists of a refactor of the axisPlot mixin and a small fix for VisPca because the axes didn't update when scaling changed, so they'd get initialized once then not update.
There's also a container overflow fix (which only helps on Chrome, flexbox heights work slightly different on Firefox and I can't figure out the search terms to find any discussion of the problem).
axisPlot bits.
First, I really liked the mixin here -- I think it was a good place to use one.
The main issues I wanted to address were:

that the mixin was creating properties on the instance in a non-reactive way and from within a method where it isn't obvious that the mixin owns those properties.
that the properties it was creating were deterministic of the props, and could be factored into computed props.
that the mixin was creating data properties that the parent would then use, the timings of which were hard to understand.  (e.g. I have to call axisPlot and then my component will have some new properties like svg.

I'm still learning mixins, but so far I've had a good experience with treating them like abstract base classes (minus the abstract methods bits).  I try to make my mixins attachable to any component:  they don't rely on any data or methods to be present on the components they modify.   In this case, a mixin can't use $refs.svg because mixins can't change/own templates.
PTAL and let me know what you think!

BTW;

        loadings: {
          data: null,
          valid: false,
        },

neeeded on store/index.js line 99.

My changes/additions are ready for review. Thanks again @subdavis.

LGTM @waxlamp !


Invalid Python code in class-inheritance-example

The lines
class Animal:
def jump:
print "I am jumping"
are invalid, because the self parameter is missing the definition of method "jump" and the print-statement requires parentheses in Python 3
correct code:
class Animal:
def jump(self):
print("I am jumping")

Thanks!

@jecki, your patch replaced some spaces with tabs. Now we have a mixed-indentation code, which is a Python Worst Practice - can you fix that? (I could fix that myself, but I'd have to pull the repo first.)

sure! just done that.

Show me the commit and I'll review and merge :-)


Can containable item be contained by many content item?

Here is the sample requriement: I got many classes under Class content type and many students under Student content type. One student can book some of classes.
Here is what I done and the problem I am encountering: I set the Class content type is containable and Student content type has Container part. But one class only can be contained by one student. Once the same class is booked by many students. It only appear under the list of the student who is the last one to operate the book action.
Here is what I expect to: One class can be contained by many students.
Any clue to find the path?
Thanks

This can't be done with Containable, you should use Taxonomies instead. Classes is a taxonomy, each class is a Term, and you create a Taxonomy field in the Student type. You can also add custom fields to the Class terms.


Admin Menu Collapses etc.

The admin menu (multi level) collapses when you click anywhere on the page.
It should only collapse on page refresh or when you click the main menu item again, or click another menu item.
When you click a menu item and then click another menu item the first menu item clicked does not collapse.
This is one of the worst JS menus I have seen!

related https://github.com/dmstr/yii2-adminlte-asset/issues/23
@osCMattiFinn Any ideas about implementing this feature, eg. with cookies?

I keep the menu open where it should be using Javascript.
I would like to see a solution for this issue:  The admin menu (multi level) collapses when you click anywhere on the page.

hmmm, maybe you should think about the sidebars extension - doesn't collapse by clicking somewhere else...

I Googled "Phundament sidebars extension" and found nada.  Where is this to be found?

http://plugins.adchsm.me/slidebars/

fixed by https://github.com/dmstr/yii2-adminlte-asset/issues/63


[docs] Update list of packages

Need to do more tests to make doc more clean.

@azhogov

Versions specified
Issue created: https://github.com/intel/compute-runtime/issues/46
Oleg asked :)


Unicode Errors (System specific)

Actual Behavior
Traceback (most recent call last):
File "pokecli.py", line 347, in
main()
File "pokecli.py", line 340, in main
bot.run()
File "OpenPoGoBot/pokemongo_bot/init.py", line 92, in run
self.navigator.navigate(map_cells)
File "OpenPoGoBot/pokemongo_bot/navigation/fort_navigator.py", line 40, in navigate
logger.log("[#] Walking towards PokeStop "{}" ({} away)".format(fort_name, format_dist(dist, unit)))
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe2' in position 24: ordinal not in range(128)
Other Information
OS: debian
Git Commit: 7df83ac094901222febaf5c34620e86b3dd34ffa

For non-unicode fort name, we need either use u'{}' or add an import in the source of affected files:
from future import unicode_literals
This make the format function works well for me (I am in Hong Kong)
Source:
http://stackoverflow.com/questions/3235386/python-using-format-on-a-unicode-escaped-string

The same problem
[2016-08-02 09:47:44] [x] Starting PokemonGo Bot....
Traceback (most recent call last):
File "pokecli.py", line 347, in
main()
File "pokecli.py", line 340, in main
bot.run()
File "/home/poke/pokemongo_bot/init.py", line 91, in run
self.work_on_cells(map_cells)
File "/home/poke/pokemongo_bot/init.py", line 98, in work_on_cells
self.fire("pokestops_found", pokestops=cell.pokestops)
File "/home/poke/pokemongo_bot/init.py", line 85, in fire
manager.fire_with_context(event, self, *args, **kwargs)
File "/home/poke/pokemongo_bot/event_manager.py", line 107, in fire_with_context
return self.fire(event_name, *args, **kwargs)
File "/home/poke/pokemongo_bot/event_manager.py", line 101, in fire
return self.events[event_name].fire(*args, **kwargs)
File "/home/poke/pokemongo_bot/event_manager.py", line 64, in fire
return_dict = listener(**listener_args)
File "./plugins/spin_pokestop/init.py", line 45, in visit_near_pokestops
manager.fire_with_context('pokestop_arrived', bot, pokestop=pokestop)
File "/home/poke/pokemongo_bot/event_manager.py", line 107, in fire_with_context
return self.fire(event_name, *args, **kwargs)
File "/home/poke/pokemongo_bot/event_manager.py", line 101, in fire
return self.events[event_name].fire(*args, **kwargs)
File "/home/poke/pokemongo_bot/event_manager.py", line 64, in fire
return_dict = listener(**listener_args)
File "./plugins/spin_pokestop/init.py", line 72, in spin_pokestop
format_dist(dist, bot.config.distance_unit)), color="yellow")
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-11: ordinal not in range(128)

please test https://github.com/OpenPoGo/OpenPoGoBot/pull/159

Adding "from future import unicode_literals" seems a good workaround.

@lazyfai I will test that when I get home.

please test https://github.com/OpenPoGo/OpenPoGoBot/pull/177

Got one pokestop which break bot all the time, with #177 working without any problems.

I get a travis CI build error. not sure about it.

@Gnacik i think ec5b155d6d10047a5d06a9394012fc3017d5787f was working fine...could you verify this with your "one pokestop which break bot all the time" ?

After ec5b155 i've got crash every time when i go to that pokestop, it have some italian chars.
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe1' in position 3: ordinal not in range(128)

with #177 problem disappear.

okay
yes, #177 will fix it

@Reaver01  hellow ，i have another problem. i want to use proxy then have one error. May you help me .
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='android.clients.google.com', port=443): Max retries exceeded with url: /auth (Caused by NewConnectionError('<requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x7f1751b7e090>: Failed to establish a new connection: [Errno 111] Connection refused',))

@GucciChen it has nothing to do with our bot or even this ticket here...


Change "licenses" to "license" in sample datapackage

Licenses was dropped in favor of license on version 1.0.0-beta.14 (issue #214), but there the datapackage's JSON example was still using licenses. This PR fixes that.

thanks


ENH: In-memory dictionary transformation

Is your Feature Request Related to a Problem?
I would like to pass an in-memory JSON dictionary for my conversion, instead of reading it from a source file. At the moment I have to save intermediate JSON results just for morph-kgc to re-read them again.
Describe the Solution you'd Like
A way to pass in a source which is in-memory, instead of written in a file
Describe Alternatives you've Considered
At the moment I have to do some processing, save an intermediate JSON file and update the paths in the config file so morph-kgc reads it

This issue can be closed now, with the in-memory extension being added (see Examples -> dict)

Thanks @TheRazorace


MaxListenersExceededWarning

I get this in my log:
2023-02-05 11:36:27.270  INFO  Eufy Security server listening on host <IP_ADDRESS>, port 3000  (node:10) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 station talkback start listeners added to [EufySecurity]. Use emitter.setMaxListeners() to increase limit (Use node --trace-warnings ...to show where the warning was created) (node:10) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 station talkback stop listeners added to [EufySecurity]. Use emitter.setMaxListeners() to increase limit 2023-02-05 11:36:37.639  INFO  Connected to station T8010P2322412672 on host <IP_ADDRESS> and port 22457  2023-02-05 11:36:41.479  INFO  Push notification connection successfully established  2023-02-05 11:37:41.100  INFO  Disconnected from station T8010P2322412672
The emitter.setMaxListeners seems to be to low. Can I put this in Eufy Security Add-on yaml file?
If yes? Can you give me an example?
One minor point, My host and port are displayed incorrectly. It should be localhost and port 3200

Eufy Security Add-on
Current version: 1.3.0

Versie
core-2023.2.2

Type installatie
Home Assistant OS

Ontwikkeling
false

Supervisor
true

Docker
true

Gebruiker
root

Virtuele omgeving
false

Python-versie
3.10.7

Besturingssysteem
Linux

Versie van het besturingssysteem
5.15.90

CPU-architectuur
aarch64

Tijdzone
Europe/Amsterdam

Configuratiemap
/config

I am experiencing the same issue and started a discussion which has not been answered.
https://github.com/fuatakgun/eufy_security/discussions/698#discussion-4772934


ISPN-14727 Degrade client intelligence to basic if connection returns…

… "no route to host"
https://issues.redhat.com/browse/ISPN-14727

Does this mean we don't need to set up the client intelligence to BASIC explicitly to work with docker for mac for example?

It means exactly that

Integrated into main, thanks @jabolina !


Adds type annotations for apistar/docs.py functions.

Let me know what you think! I was looking at issue #87 as a good starter task and the file I chose seemed to be a good place to start

Looks good! 👍


Milestone PR for version 1.1.0

This is a milestone PR for version 1.1.0
Keep in mind, it's not ready to use branch. It's a development prototype that will accumulate more stuff over the time.
I strongly discourage against using this branch.

[x] Patch of 1.0.1 was applied


HPM proxy sockjs got Connection closed before receiving a handshake response

Expected behavior
Now I'm writing a quotation system . Back end is spring-boot and front is Vue.
I use sockjs-client and stompjs to communicate with backend tomcat server
What I want is to prxoy
ws://localhost:9528/jcs/websocket to ws://localhost:8088/jcs/websocket,
also all the http request with prefix /jcs
http://<IP_ADDRESS>:9528/jcs/websocket/info to  http://<IP_ADDRESS>:8088/jcs/websocket/info
Actual behavior
It seems I can't achieve this with config below. Am I missing anything?
Setup

http-proxy-middleware: 0.17.4
server: express +4.15.3
"sockjs-client": "^1.1.4",
"stompjs": "^2.3.3",

proxy middleware configuration
'/jcs' : {
target : 'http://<IP_ADDRESS>:8088',
changeOrigin: true,
pathRewrite: {
'^/jcs' : '/jcs'
},
ws: true
}
js code to open websocket connection
let socket = new sockjs('jcs/websocket'); // it will fail here
let stompClient = stomp.over(socket);
If I didn't use proxy it works fine. There would be two request in browser network:
Request URL:http://localhost:8080/jcs/test-info/info?t=1519957548721 Request Method:GET Status Code:200  Remote Address:[::1]:8080 Referrer Policy:no-referrer-when-downgrade
Request URL:ws://localhost:8080/jcs/test-info/327/ytsc34dk/websocket Request Method:GET Status Code:101
If I user proxy , the first one would return 200 since it proxy to 8088 correctly:
Request URL:http://<IP_ADDRESS>:9528/jcs/websocket/info?t=1519959085127 Request Method:GET Status Code:200 OK Remote Address:<IP_ADDRESS>:9528 Referrer Policy:no-referrer-when-downgrade
the second one will not return 101:
Request URL:ws://<IP_ADDRESS>:9528/jcs/websocket/204/drp3cmqo/websocket
and I will get this error in console:
WebSocket connection to 'ws://<IP_ADDRESS>:9528/jcs/websocket/204/drp3cmqo/websocket' failed: Connection closed before receiving a handshake response
Please help me out, it takes me almost a whole day with no luck :(

Fixed by setAllowedOrigins in the javaside

goodjob


Error with annotate_ws.py

Hi!
I was using annotate_ws.py to annotate custom questions. I ran annotate_ws.py on google cloud platform. However, I got this error:
python3 annotate_ws.py --split past,present annotating /home/Enzo/sqlova-shallow-layer/past.jsonl loading tables 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 2716/2716 [00:00<00:00, 17256.43it/s] loading examples   0%|                                                                                | 0/1690 [00:00<?, ?it/s]Starting server with command: java -Xmx5G -cp /home/Enzo/sqlova-shallow-layer/stanford-corenlp-4.0.0/* edu.stanford.nlp.pipeline.StanfordCoreNLPServer -port 9000 -timeout 60000 -threads 5 -maxCharLength 100000 -quiet True -serverProperties corenlp_server-6f9bf1976d784f04.props -preload tokenize,ssplit,pos,lemma,ner,depparse   0%|                                                                                | 0/1690 [00:40<?, ?it/s] Traceback (most recent call last):   File "annotate_ws.py", line 190, in <module>     a = annotate_example_ws(d, tables[d['table_id']])   File "annotate_ws.py", line 107, in annotate_example_ws     _nlu_ann = annotate(example['question'])   File "annotate_ws.py", line 24, in annotate     for s in client.annotate(sentence): TypeError: 'Document' object is not iterable
Could you tell me why this happened? Thank you in advance!

I am facing same issue. Did you get any solution to this problem?

@Daljeetka Not yet...

When running annotate_wa.py, i got an error: ModuleNotFoundError: No module named 'stanza.nlp'. But i has installed stanza. Which package else should I install?

i know. Change line 8 to from stanza.server import CoreNLPClient. Now i am facing the same issue TypeError: 'Document' object is not iterable too..

Try this:
import stanza
nlp = stanza.Pipeline('en')

def annotate(sentence, lower=True, nlp=nlp):
    """
    Input: Question
    Output: Tokenized input question
    {
        'gloss': original question,
        'words': list of tokens,
        'after': " " for tokens through last 2; last 2 tokens = ""
    }
    """
    doc = nlp(sentence)

    words, gloss, after = [], [], []
    for sentence in doc.sentences:
        for token in sentence.tokens:
            word, originalText = token.text, token.text
            after_ = " "

            words.append(word)
            gloss.append(originalText)
            after.append(after_)
        after[-2:] = ["", ""]
    if lower:
        words = [w.lower() for w in words]
    return {
        'gloss': gloss,
        'words': words,
        'after': after,
        }

In case of latest stanza I have to make hese changes to work (check lines with ###), started the coreNLP server outside
#!/usr/bin/env python3
from argparse import ArgumentDefaultsHelpFormatter, ArgumentParser
from asyncio import start_server
import os
import records
import ujson as json
from stanza.server.client import CoreNLPClient ###
from tqdm import tqdm
import copy
from lib.common import count_lines, detokenize
from lib.query import Query
import stanza.server as corenlp ###
client = None
if client is None:
client = CoreNLPClient(annotators='tokenize,ssplit,pos,lemma,ner,depparse',
start_server=corenlp.StartServer.DONT_START) ###
words, gloss, after = [], [], []
objs = client.annotate(sentence) ###
for s in objs.sentence: ###
for t in s.token: ###
words.append(t.word)
gloss.append(t.originalText)
after.append(t.after)

Yes, the code by @dsivakumar seems to be correct. The return value of client.annotate(sentence) is not an actual Document object, no matter what the error message says. It's something called a Protobuf, as explained (sort of) here. These objects' fields are named in the singular (sentence, token) even though they refer to iterables of multiple sentences and tokens.


Translational.support

Reported by AHaumer on 19 Nov 2007 09:28 UTC
All elements with Translational.support are wrong or at least misleading;
consider friction: fine that the friction force appears at the support,
but the relative velocity which defines friction force is NOT the absolute velocity of the shaft BUT the relative velocity of the shaft against the support! We may discuss the sources (like position, whether we want to define an absolute position or the position against support - which would be much easier to understand!)
Rotational (in MSL 2.2.1, 2.2.2 and 3.0) has the same defect.

Migrated-From: https://trac.modelica.org/Modelica/ticket/19

Comment by AHaumer on 19 Nov 2007 10:04 UTC
The elements are ok since they extend from PartialGear which defines the relative distances against support in the right way.
Also the SpeedDependent sources are ok since the relative velocity against support is defined in PartialSpeedDependentSource.
We should discuss the other sources (e.g. whether position, velocity or acceleration should be defined absolute or relative against the support).

Modified by dietmarw on 19 Nov 2007 10:45 UTC

Comment by AHaumer on 19 Nov 2007 11:12 UTC
Could be a good idea to let the user choose whether to define position / velocity / acceleration absolute (like now) or relative to support.

Modified by AHaumer on 19 Nov 2007 11:13 UTC

Comment by AHaumer on 19 Nov 2007 16:39 UTC
fixed by 8320a6d169ad1252c3544049915d67e50f7b6c54, 2155a00f301938975b4a366b0313cf75efe3b167
defined the movement of the flange relative to support
(Position, Speed, Accelerate, Move)


Validate that there is at least one objective/creator/mutator/deletor when making islands

Is your feature request related to a problem? Please describe.
Islands require at least one objective/creator/mutator/deletor, but currently that isn't validated and will result in weird errors.
Describe the solution you'd like
There should be checks in EvvoIsland that ensure all the provided collections are not empty.
Describe alternatives you've considered
We can use a non-empty list to force this at compile time, but there isn't a non-empty vector type.

http://blog.rafaelferreira.net/2008/07/type-safe-builder-pattern-in-scala.html will help here. We can also make it illegal to create islands without a builder, by making the EvvoIsland component private to the package/file, while requiring builders as constructor arguments for Local and Remote islands/managers.


bug(datepicker): Range picker fails when the adapter uses classes that can't be converted to primitives

Is this a regression?

[ ] Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was
No response
Description
When using a custom DateAdapter for a date class that doesn't support conversion to primitives (js-joda), that I like because it avoids too many errors. It fails when a date is selected on the date range picker, with the following error:
Uncaught TypeError: A conversion from Temporal to a number is not allowed. To compare use the methods .equals(), .compareTo(), .isBefore() or one that is more suitable to your use case.
This happen because  the code is using cell.rawValue at the following line:
https://github.com/angular/components/blob/1da7f15ff66ce30ad9888d56760bb149c960d2a6/src/material/datepicker/calendar-body.ts#LL515C40-L515C48
I think it should be using cell.compareValue instead.
A workaround can be made monkey patching MatCalendarBody (remember to use your date class check if not using js-joda)
import { MatCalendarBody } from '@angular/material/datepicker';

const originalIsInRange = MatCalendarBody.prototype._isInRange;
MatCalendarBody.prototype._isInRange = function(value: number) {
  const badValue = value as any;
  if (badValue instanceof LocalDate) {
    value = new Date(badValue.year(), badValue.monthValue(), badValue.dayOfMonth()).getTime();
  }
  return originalIsInRange.call(this, value);
};

Reproduction
I am pointing to the exact source line with the problem
Expected Behavior
Using a custom DateAdapter for js-joda should work. The date range picker should not give an error with clicked.
Actual Behavior
An exception when a date is clicked and the date class using by the DateAdapter doesn't support conversion to primitives.
Environment
Angular CLI: 16.0.3
Node: 18.16.0
Package Manager: npm 9.5.1
OS: linux x64
Angular: 16.0.3
... animations, cli, common, compiler, compiler-cli, core, forms
... language-service, localize, platform-browser
... platform-browser-dynamic, router
Package                         Version
@angular-devkit/architect       0.1600.3
@angular-devkit/build-angular   16.0.3
@angular-devkit/core            16.0.3
@angular-devkit/schematics      16.0.3
@angular/cdk                    16.0.2
@angular/material               16.0.2
@schematics/angular             16.0.3
ng-packagr                      16.0.1
rxjs                            7.8.1
typescript                      5.0.4

Hello,
Thank you for investigating this.
@crisbeto is there a specific reason why we are comparing values with <=/>= rather than through the date adapter API? Is it done that way for performance reasons. Is looks to me like doing this with the date adapter API (compareDate) could be more robust.
-Zach

I nearly forgot about this. Can this be fixed with the change we propose here or it must wait for the review about the need of this kind of comparison asked by @zarend?

This looks fixed on the main and 17.0.x branch
https://github.com/angular/components/blob/main/src/material/datepicker/calendar-body.ts#L518
https://github.com/angular/components/blob/17.0.x/src/material/datepicker/calendar-body.ts#L518
Not on 17.0.0, but it should be on a next fix release I think.
https://github.com/angular/components/blob/17.0.0/src/material/datepicker/calendar-body.ts#L515


ScrollViewer blocks the focus visual of contents

Describe the bug
ScrollViewer is clipping the focus visual of content.
Steps to reproduce the bug
In a sample WinUI UWP app add the following XAML element.
<ScrollViewer>
    <StackPanel>
        <ComboBox />
        <ComboBox />
        <ComboBox />
    </StackPanel>
</ScrollViewer>

Expected behavior

Screenshots
Actual Behavior:

Expected Behavior

NuGet package version
No response
Windows app type

[X] UWP
[ ] Win32

Device form factor
Desktop
Windows version
Insider Build (xxxxx)
Additional context
No response

I don't reproduce this issue.  @zhit-microsoft could you provide more info?

@StephenLPeters, what information do you need?

The build of windows you are using, the version of winui you are using. any repro steps that you are doing beyond launch the app and hit tab.


Fixing serac CI on Gitlab: back to the basics [fix/ci]

Intro
I have fixed Serac CI on LC Gitlab.
My mistake was to try to use the same pipeline template I use for other projects, while I could have kept things simple.
I simplified the pipeline, which means less optimization (produces more data, is longer to run), but better robustness.
What
The result is a 3-stage pipeline, allocation/run/release. (I kept the "single allocation" optimization)
The run phase consists in three streps (in one job) aiming at reproducing the development workflow:

install dependencies and generate the host-config file (uberenv)
build with classic cmake commands (not using uberenv)
test

This is done for 3 compilers<EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS>on quartz only and could (should?) be extended to lassen (just tell be what you want).
Comments
The pipeline still fails, because some tests fails when built with<EMAIL_ADDRESS>Someone more into the project should give a look at this...
TODO

I found a way to control the collapse of logs by sections in GitLab, I will test it. It would make the all-in-one job log easier to read.
I want to update Uberenv. (not necessarily in this PR)
Add other targets (more recent clang? lassen?)

LGTM

(Last comment is a sign-off for Gitlab)

This looks great!! Thank you for your work!

This is done for 3 compilers<EMAIL_ADDRESS><EMAIL_ADDRESS><EMAIL_ADDRESS>on quartz only and could (should?) be extended to lassen (just tell be what you want).

Eventually we should add lassen, but the core code isn't GPU-ized yet. It can wait for now.

The pipeline still fails, because some tests fails when built with<EMAIL_ADDRESS>
Yep, this is a known issue. This recently merged PR should fix a bunch of it, and I have a new branch that should fix the rest.

Then I merge it, rather than adding non mandatory changes.


instructions

hey mate i just built the executable but cant figure out how to use it. would've thought i would just have to drag the json file onto the exe but no luck. sorry to bother

Did you get it working?

you need to execute it on cmd for example: blurlconverter.exe sparktrackname.blurl sparktrackname.blurl
you need to input the spark track blurl 2 times and it will work

blurlconverter.exe? I have programs in the go lang but no executables

Asks for my available playlist, and when I put it in, it says "Error getting playlist metadata: EOF"

Got it to work, thanks!


Publish docker image

I've created a PR (#146) with a Dockerfile that builds pimd/pimctl and packages them in a debian:stretch image.  Can this be published to https://hub.docker.com/u/troglobit

This Dockerfile let me build the latest tag (2.3.2), as well:
FROM debian:stretch

COPY . /root/pimd
WORKDIR /root/pimd
RUN apt-get update && apt-get install -y build-essential automake git
RUN ./configure --prefix=/usr
RUN make

FROM debian:stretch
COPY --from=0 /root/pimd/pimd /usr/sbin/

CMD [ "/usr/sbin/pimd", "--foreground" ]

Cool, thanks man!
Any particular reason you chose debian and not alpine?

Switched to alpine.  Here's an updated Dockerfile to manually build version 2.3.2:
FROM alpine:3.9

COPY . /root/pimd
WORKDIR /root/pimd
RUN apk add --update build-base automake autoconf linux-headers git
RUN ./configure --prefix=/usr --sysconfdir=/etc
RUN make

FROM alpine:3.9
COPY --from=0 /root/pimd/pimd /usr/sbin/
COPY --from=0 /root/pimd/pimd.conf /etc

CMD [ "/usr/sbin/pimd", "--foreground" ]

Neat, thank you!  I guess you want both the 2.3.2 and latest master on dockerhub, right?

Yeah, both would be good.  It's up to you if you want :latest to mean latest commit or latest tag (I've seen both in the docker world), but I don't see a tag anywhere for the 3.0-beta1 version.

I've seen some places use :latest for latest-tag, and either :master or :snapshot for latest-commit.

Ah, overloaded term of course ... snapshot is perhaps the best then.
(We currently don't tag intermediate versions like beta or RC in this project.)

Pushed.  Hopefully it works to your liking.  I had to modify the (above) Dockerfile for v2.3.2 quite heavily since we didn't have autoconf-based configure script back then, and we also used GIT submodules for some BSD replacement functions.

Thanks! Since :2.3.2 is the latest tag, can you push that to :latest as well so docker pull troglobit/pimd works properly?
$ docker pull troglobit/pimd
Using default tag: latest
Error response from daemon: manifest for troglobit/pimd:latest not found

Sure, fixed.


bump containerd version to v1.5.1

What this PR does / why we need it:
This PR bumps the containerd version to v1.5.1
Additional context
Link to the new release: https://github.com/containerd/containerd/releases/tag/v1.5.1
Signed-off-by: Priyanka Saggu<EMAIL_ADDRESS>

cc: @dims


Dynamic options for select/multiselect filter

Is there any way to fill in options for select/multiselect filter dynamically - specifically, I'd just want distinct on all column values, e.g. just composing values externally and passing over as filter options. Couldn't figure out a way to do that.

Figured it out :)
const Table = ({rows}) => {
    const columns = (rows) => {
        return [
                {text: 'State',
                dataField: 'state',
                sort: true,
                filter: multiSelectFilter({
                    options: composeSelectOptions(rows)
                })
            }]
        }
...
}


[Feature Request] Add option to share PDF after scanning

Hi,
first of all thank you for this project. It's amazing!
I just started out with using Paperless for all my paper documents. I use your lovely app to scan the documents and then upload it to Paperless.
Currently the workflow is:

Scan document
Export (= save) the PDF to Downloads
Open file manager
Upload scanned PDF via file manager to Paperless

So the option to export to another application would save quite a bit of work.
Also it might be useful to allow the user where to save the exported PDF.
Thank you for considering this feature :)

@graves501 thanks a lot for the kind words. I didn't had share for pdf because the open would open in a PDF viewer where you could share.
but I see that in your workflow it would be better to share directly so I LL add it.
I use paperless too. I wanted to add sync feature to paperless (NGC) but their API dont support what I want (syncing already existing document when I add pages) and they dont seem really open to changes :(

@farfromrefug
Thank you so much for considering!
I guess adding a "Share PDF" functionality will be useful for other people as well. And it adds some consistency to the UX since the user can share the JPG/photo at the moment, but not the PDF version of the scan :thinking:
That's interesting, can you send me a link to your proposal/Github issue? I'm just curious how the interaction went :thinking:
Have a nice day :)

@graves501 i added it in latest version ;)

@farfromrefug That's awesome, thank you so much! I tried it out and tried to share/send the PDF to "Paperless Mobile" but it doesn't seem like it's listed.
So I don't know why my phone (Pixel 7 Pro, Android 14, GrapheneOS) doesn't list Paperless Mobile in this context, because it does show up when I share it from e.g. the file explorer 🤔 Any ideas?

@graves501 i got an idea. will try

@graves501 new version up. I tested it with paperless and it worked

@farfromrefug Awesome! Can confirm, with version v1.2.24 it's working! Thank you so much, makes life easier :)
I think this issue can be closed now :)


"Test" button works, but nothing happens when i try to connect

System data:
OS: Windows 10 x64 Pro
InfluxDB OS: Debian 11.x most current version on 2022-06-28
InfluxDB Version: 2.x, most current version on 2022-06-28
When i select a connection entry, that was successfully tested with "Test" button before, nothing happens. Why?

When i click "Test" button in connection settings:

solved


Blameable and timestampable with loggable

Hi,
I need to save in the log the date and user alteration, how i can do this?
If i put the 'versioned' annotation on the field 'alteration_data' it's ok, but if i revert to a previous version the previous  'alteration_data' returns.
how i can work with this problem?

Hello, and thank you for your contribution.
In the interest of spring cleaning and package modernization, I'm going through and closing old issues and pull requests that have had no recent activity, do not have associated tests, or have failing tests.
If you are still experiencing this issue or wish to contribute an up-to-date pull request, please create a new issue.
Thank you!


Docs: Add new alpha libraries to README

Move reference links closer to point of use, and sort for ease of comparison to match lists.
Normalize PyPI URLs.

Note that asset and oslogin don't have PyPI releases, so I didn't add them (they also don't have cloud.google.com links that I can find).


use capture-require

Well, this doesn't work, but I am a bit stumped as to why.
It no longer distinguishes between default and wrapped (it just uses the wrapping function to wrap the current top of require.extensions['.js']). This also means it never calls addFile, but addFile isn't really necessary. The default require.extensions['.js'] should be forwarding you the content anyway.
@novemberborn - can you take a look and give me a guess as to why those tests are failing (like what information nyc isn't collecting correctly). I've spent quite a bit of time groking the wrapRequire section of the nyc codebase, but haven't really dived deep anywhere else.
I will keep trying, just hoping for another set of eyeballs.

@jamestalmage we'll get it to work, I'm really happy with how much logic this will trim out of the core library -- nyc's strength is in it's subprocess handling, I love the idea of splitting more and more logic into other modules.
Complete aside but, I wonder if it's worth pulling the source-map-remapping logic into its own module.... it is pretty domain specific, since it assumes an Istanbul coverage output.

@jamestalmage I'm not quite sure. It may be to do with https://github.com/bcoe/nyc/issues/79, or that the tests tend to reload index.js after clearing it from the require cache.

Complete aside but, I wonder if it's worth pulling the source-map-remapping logic into its own module.... it is pretty domain specific, since it assumes an Istanbul coverage output.

Modularize all the things. :+1:

I think part of the problem might be that the old .wrap() just blew away whatever was existing on require.extensions['.js']. That meant repeated calls to .wrap() did not have side effects. In an attempt to be more generalized capture-require actually looks at Object.getOwnPropertyDescriptor and will forward through future added extensions to the previous getter/setter pair. Since nyc installs its hook multiple times in the test, this ends up meaning the coverage transform gets applied multiple times (once for the hook installed in this test, and once for every previous test).
All speculation on my part at this point. But if it turns out to be true, then we actually only have a problem in the tests, since nyc won't invoke capture-require multiple times IRL.
Not sure on the best strategy for solving that.

Not sure on the best strategy for solving that.

Let's see if we can tackle #80.

@jamestalmage any headway on this bug?

closed via #90


Running pytest leads to "... is already defined for this MetaData instance"

I am currently working on a class that provides Authentication functionality. The class itself depends on a UserRepository, that basically just wraps db.session. The code kind of looks like this:
AuthenticationService
Please note the type hint in the class constructor.
from repository.user import UserRepository

class UnauthorizedException(Exception):
    pass

class AuthenticationService:
    def __init__(self, user_repository: UserRepository):
        self.user_repository = user_repository

    def authenticate(self, username, password):
        user = self.user_repository.find_by_username(username)
        if not user:
            raise UnauthorizedException("Invalid credentials.")

User Model
from werkzeug.security import generate_password_hash
from extensions import db

class User(db.Model):

    id = db.Column(db.Integer, primary_key=True)
    first_name = db.Column(db.String(80), nullable=False)
    last_name = db.Column(db.String(80), nullable=False)
    username = db.Column(db.String(80), unique=True, nullable=False)
    email = db.Column(db.String(80), unique=True, nullable=False)
    password = db.Column(db.String(120), nullable=False)
    active = db.Column(db.Boolean, server_default=db.true(), default=True, nullable=False)

    def set_password(self, password):
        self.password = generate_password_hash(password)

User Repository
from repository.abstract import AbstractRepository
from model.user import User

class UserRepository(AbstractRepository):
    def __init__(self, session):
        super().__init__(session, User)

    def find_by_username(self, username):
        return self._session.query(self.entity_type).filter_by(username=username).first()

Additionally, I wrote a simple test for the AuthenticationService
from service.authentication import AuthenticationService, UnauthorizedException
import pytest

def test_authorize_when_given_unknown_username_throws_exception(mocker):
    user_repo_mock = mocker.MagicMock()
    user_repo_mock.find_by_username.return_value = None

    auth_service = AuthenticationService(user_repo_mock)

    with pytest.raises(UnauthorizedException):
        auth_service.authenticate("some_random_username", "some_password")

When running this using pytest, I get the following error message:
sqlalchemy.exc.InvalidRequestError: Table 'user' is already defined for this MetaData instance.  Specify 'extend_existing=True' to redefine options and columns on an existing Table object.
When removing the type hint (and thus the import) from the AuthenticationService, this error disappears. It also doesn't even come up when I use the native SQLAlchemy declarative base in the User model. Even though the error message seems to be a SQLAlchemy native, this kind of makes me feel like the reason for this is somewhere in Flask-SQLAlchemy when used with pytest.
I'm using Flask-SQLAlchemy 2.3.2, SQLAlchemy 1.2.6 and pytest 3.5.0

Hi, chrismeh.
I had a similar problem recently, but it occurs because the database I was using had that name registered. I solved it when I changed its name to something like user_account for example. Which database are you using.

Hi leandrocosta26,
sorry for not getting back to you earlier. Unfortunately, just changing the table name to something else than user didn't help. I just updated to Python 3.6 yesterday (been using 3.5 for a while now) and I can't seem to reproduce this error anymore. I will investigate into this more though.