Skip to content
Permalink
Browse files

forgot to include globalIdentifier in the API results mask

  • Loading branch information...
eightnoneone committed Jan 11, 2019
1 parent 1dd7c6c commit a8d31edf94123b44c6becdd9a9d9d54f890aa226
Showing with 1 addition and 1 deletion.
  1. +1 −1 Dynamic Folder/IBM/Softlayer/Softlayer Servers (Python).rdfe
@@ -16,7 +16,7 @@
"ScriptInterpreter": "python",
"DynamicCredentialScriptInterpreter": "json",
"DynamicCredentialScript": "{\n\t\"Username\": \"user\",\n\t\"Password\": \"pass\"\n}",
"Script": "import SoftLayer\nimport json\n\n\ndef get_instances(datacenter = \"\"):\n\n client = SoftLayer.Client()\n mgr = SoftLayer.VSManager(client)\n\n connections = [ ]\n\n object_mask = \"mask[hostname,operatingSystemReferenceCode,primaryBackendIpAddress]\"\n for instance in mgr.list_instances(datacenter=datacenter, mask=object_mask):\n\n instance_id = instance.get(\"globalIdentifier\", \"\")\n is_windows = instance.get(\"operatingSystemReferenceCode\").partition('_')[0] == \"WIN\"\n\n\n# public_ip_address = instance.get(\"PublicIpAddress\", \"\")\n# public_hostname = instance.get(\"PublicDnsName\", \"\")\n\n private_ip_address = instance.get(\"primaryBackendIpAddress\", \"\")\n private_hostname = instance.get(\"hostname\", \"\")\n name = private_hostname\n\n# Fetching tags on each vs is very time consuming. \n# tags = details.get(\"tagReferences\")\n# tagstring = [ ]\n# for tag in tags:\n# tagstring.append(tag['tag'].get('name'))\n# notes = ' '.join(tagstring)\n \n\n computer_name = private_ip_address\n\n if computer_name == \"\":\n computer_name = public_ip_address\n\n connection = { }\n\n if not is_windows:\n connection[\"Type\"] = \"TerminalConnection\"\n connection[\"TerminalConnectionType\"] = \"SSH\"\n connection['CredentialsFromParent'] = True\n else:\n connection[\"Type\"] = \"RemoteDesktopConnection\"\n connection['CredentialName'] = \"AD_Crendentials\"\n\n connection[\"ID\"] = instance_id\n connection[\"Name\"] = name\n connection[\"ComputerName\"] = computer_name\n# connection['Notes'] = notes\n \n\n connections.append(connection)\n\n store = {\n \"Objects\": connections\n }\n\n store_json = json.dumps(store, indent=2)\n\n return store_json\n\nprint(get_instances(\"$CustomProperty.Datacenter$\"))"
"Script": "import SoftLayer\nimport json\n\n\ndef get_instances(datacenter = \"\"):\n\n client = SoftLayer.Client()\n mgr = SoftLayer.VSManager(client)\n\n connections = [ ]\n\n object_mask = \"mask[globalIdentifier,hostname,operatingSystemReferenceCode,primaryBackendIpAddress]\"\n for instance in mgr.list_instances(datacenter=datacenter, mask=object_mask):\n\n instance_id = instance.get(\"globalIdentifier\", \"\")\n is_windows = instance.get(\"operatingSystemReferenceCode\").partition('_')[0] == \"WIN\"\n\n\n# public_ip_address = instance.get(\"PublicIpAddress\", \"\")\n# public_hostname = instance.get(\"PublicDnsName\", \"\")\n\n private_ip_address = instance.get(\"primaryBackendIpAddress\", \"\")\n private_hostname = instance.get(\"hostname\", \"\")\n name = private_hostname\n\n# Fetching tags on each vs is very time consuming. \n# tags = details.get(\"tagReferences\")\n# tagstring = [ ]\n# for tag in tags:\n# tagstring.append(tag['tag'].get('name'))\n# notes = ' '.join(tagstring)\n \n\n computer_name = private_ip_address\n\n if computer_name == \"\":\n computer_name = public_ip_address\n\n connection = { }\n\n if not is_windows:\n connection[\"Type\"] = \"TerminalConnection\"\n connection[\"TerminalConnectionType\"] = \"SSH\"\n connection['CredentialsFromParent'] = True\n else:\n connection[\"Type\"] = \"RemoteDesktopConnection\"\n connection['CredentialName'] = \"AD_Crendentials\"\n\n connection[\"ID\"] = instance_id\n connection[\"Name\"] = name\n connection[\"ComputerName\"] = computer_name\n# connection['Notes'] = notes\n \n\n connections.append(connection)\n\n store = {\n \"Objects\": connections\n }\n\n store_json = json.dumps(store, indent=2)\n\n return store_json\n\nprint(get_instances(\"$CustomProperty.Datacenter$\"))"
}
]
}

0 comments on commit a8d31ed

Please sign in to comment.
You can’t perform that action at this time.