Support Questions

Find answers, ask questions, and share your expertise

how to generate tag number by API

avatar

we want to post the new config to ambari

but we need uniq tag number that not exist in ambari

how to generate new tag number by API or other approach , so we can put it after "tag" ? as - 237432322

curl -u admin:admin -H "X-Requested-By: ambari" -X PUT -d '[
  {
    "Clusters": {
      "desired_config": [
        {
          "type": "kafka-env",
          "tag": "237432322",
          "properties": {
Michael-Bronson
1 ACCEPTED SOLUTION

avatar

@Michael Bronson

You can use the current epoch timestamp as tag.

configs.py internally uses the same.

In python: "version"+str(int(time.time() * 1000000)) tag will be something like : "version1527441356254688"

View solution in original post

5 REPLIES 5

avatar

@Michael Bronson

You can use the current epoch timestamp as tag.

configs.py internally uses the same.

In python: "version"+str(int(time.time() * 1000000)) tag will be something like : "version1527441356254688"

avatar

can you please give real example ?

Michael-Bronson

avatar
curl -u admin:admin -H 'X-Requested-By:admin' -X PUT 'http://localhost:8080/api/v1/clusters/cc' -d '{
  "Clusters": {
    "desired_config": {
      "type": "core-site",
      "tag": "version1527441356254688",
      "properties": {
        "security.admin.operations.protocol.acl" : "hadoop",
        "security.client.datanode.protocol.acl" : "*",
        "security.client.protocol.acl" : "*",
        "security.datanode.protocol.acl" : "*",
        "security.inter.datanode.protocol.acl" : "*",
        "security.inter.tracker.protocol.acl" : "*",
        "security.job.client.protocol.acl" : "*",
        "security.job.task.protocol.acl" : "*",
        "security.namenode.protocol.acl" : "*",
        "security.refresh.policy.protocol.acl" : "hadoop",
        "security.refresh.usertogroups.mappings.protocol.acl" : "hadoop"
      }
    }
  }
}'

avatar

( I accept your anser but we have aproblem ) , regarding the - version"+str(int(time.time() * 1000000)) , what in case its return number that already exists as version ( in spite this is very very rare ? )

Michael-Bronson

avatar

@Michael Bronson, It is highly unlikely that you will get the same version number when using epoch timestamp, The number changes every millisecond. So each time you execute "version"+str(int(time.time() * 1000000)) you will get a new unique number.