{"action":"created","comment":{"url":"https://api.github.com/repos/saltstack/salt/pulls/comments/32371085","id":32371085,"diff_hunk":"@@ -281,3 +163,367 @@ def create(vm_):\n     )\n \n     return ret\n+\n+\n+def list_nodes(full=False, call=None):\n+    '''\n+    List of nodes, keeping only a brief listing\n+\n+    CLI Example:\n+\n+    .. code-block:: bash\n+\n+        salt-cloud -Q\n+    '''\n+    if call == 'action':\n+        raise SaltCloudSystemExit(\n+            'The list_nodes function must be called with -f or --function.'\n+        )\n+\n+    ret = {}\n+    nodes = list_nodes_full('function')\n+    if full:\n+        return nodes\n+\n+    for node in nodes:\n+        ret[node] = {}\n+        for item in ('id', 'image', 'size', 'public_ips', 'private_ips', 'state'):\n+            ret[node][item] = nodes[node][item]\n+\n+    return ret\n+\n+\n+def list_nodes_full(call=None):\n+    '''\n+    List nodes, with all available information\n+\n+    CLI Example:\n+\n+    .. code-block:: bash\n+\n+        salt-cloud -F\n+    '''\n+    response = _query('grid', 'server/list')\n+\n+    ret = {}\n+    for item in response['list']:\n+        name = item['name']\n+        ret[name] = item\n+\n+        ret[name]['image_info'] = item['image']\n+        ret[name]['image'] = item['image']['friendlyName']\n+        ret[name]['size'] = item['ram']['name']\n+        ret[name]['public_ips'] = [item['ip']['ip']]\n+        ret[name]['private_ips'] = []\n+        ret[name]['state_info'] = item['state']\n+        if 'active' in item['state']['description']:\n+            ret[name]['state'] = 'RUNNING'\n+\n+    return ret\n+\n+\n+def list_nodes_select(call=None):\n+    '''\n+    Return a list of the VMs that are on the provider, with select fields\n+\n+    CLI Example:\n+\n+    .. code-block:: bash\n+\n+        salt-cloud -S\n+    '''\n+    return salt.utils.cloud.list_nodes_select(\n+        list_nodes_full('function'), __opts__['query.selection'], call,\n+    )\n+\n+\n+def avail_locations():\n+    '''\n+    Available locations\n+    '''\n+    response = list_common_lookups(kwargs={'lookup': 'ip.datacenter'})\n+\n+    ret = {}\n+    for item in response['list']:\n+        name = item['name']\n+        ret[name] = item\n+\n+    return ret\n+\n+\n+def avail_sizes():\n+    '''\n+    Available sizes\n+    '''\n+    response = list_common_lookups(kwargs={'lookup': 'server.ram'})\n+\n+    ret = {}\n+    for item in response['list']:\n+        name = item['name']\n+        ret[name] = item\n+\n+    return ret\n+\n+\n+def avail_images():\n+    '''\n+    Available images\n+    '''\n+    response = _query('grid', 'image/list')\n+\n+    ret = {}\n+    for item in response['list']:\n+        name = item['friendlyName']\n+        ret[name] = item\n+\n+    return ret\n+\n+\n+def list_passwords(kwargs=None, call=None):\n+    '''\n+    Available images\n+    '''\n+    response = _query('support', 'password/list')\n+\n+    ret = {}\n+    for item in response['list']:\n+        server = item['server']['name']\n+        if server not in ret:\n+            ret[server] = []\n+        ret[server].append(item)\n+\n+    return ret\n+\n+\n+def list_public_ips(kwargs=None, call=None):\n+    '''\n+    List all available public IPs.\n+\n+    CLI Example:\n+    .. code-block:: bash\n+\n+        salt-cloud -f list_public_ips <provider>\n+\n+    To list unavailable (assigned) IPs, use:\n+\n+    CLI Example:\n+    .. code-block:: bash\n+\n+        salt-cloud -f list_public_ips <provider> state=assigned\n+    '''\n+    if kwargs is None:\n+        kwargs = {}\n+\n+    args = {}\n+    if 'state' in kwargs:\n+        if kwargs['state'] == 'assigned':\n+            args['ip.state'] = 'Assigned'\n+        else:\n+            args['ip.state'] = 'Unassigned'\n+    else:\n+        args['ip.state'] = 'Unassigned'\n+\n+    args['ip.type'] = 'Public'\n+\n+    response = _query('grid', 'ip/list', args=args)\n+\n+    ret = {}\n+    for item in response['list']:\n+        name = item['ip']\n+        ret[name] = item\n+\n+    return ret\n+\n+\n+def list_common_lookups(kwargs=None, call=None):\n+    '''\n+    List common lookups for a particular type of item\n+    '''\n+    if kwargs is None:\n+        kwargs = {}\n+\n+    args = {}\n+    if 'lookup' in kwargs:\n+        args['lookup'] = kwargs['lookup']\n+\n+    response = _query('common', 'lookup/list', args=args)\n+\n+    return response\n+\n+\n+def destroy(name, call=None):\n+    '''\n+    Destroy a machine by name\n+\n+    CLI Example:\n+\n+    .. code-block:: bash\n+\n+        salt-cloud -d vm_name\n+\n+    '''\n+    if call == 'function':\n+        raise SaltCloudSystemExit(\n+            'The destroy action must be called with -d, --destroy, '\n+            '-a or --action.'\n+        )\n+\n+    salt.utils.cloud.fire_event(\n+        'event',\n+        'destroying instance',\n+        'salt/cloud/{0}/destroying'.format(name),\n+        {'name': name},\n+        transport=__opts__['transport']\n+    )\n+\n+    response = _query('grid', 'server/delete', args={'name': name})\n+\n+    salt.utils.cloud.fire_event(\n+        'event',\n+        'destroyed instance',\n+        'salt/cloud/{0}/destroyed'.format(name),\n+        {'name': name},\n+        transport=__opts__['transport']\n+    )\n+\n+    if __opts__.get('update_cachedir', False) is True:\n+        salt.utils.cloud.delete_minion_cachedir(name, __active_provider_name__.split(':')[0], __opts__)\n+\n+    return response\n+\n+\n+def reboot(name, call=None):\n+    '''\n+    Reboot a machine by name\n+\n+    CLI Example:\n+\n+    .. code-block:: bash\n+\n+        salt-cloud -a reboot vm_name\n+    '''\n+    return _query('grid', 'server/power', args={'name': name, 'power': 'restart'})\n+\n+\n+def stop(name, call=None):\n+    '''\n+    Stop a machine by name\n+\n+    CLI Example:\n+\n+    .. code-block:: bash\n+\n+        salt-cloud -a stop vm_name\n+    '''\n+    return _query('grid', 'server/power', args={'name': name, 'power': 'stop'})\n+\n+\n+def start(name, call=None):\n+    '''\n+    Start a machine by name\n+\n+    CLI Example:\n+\n+    .. code-block:: bash\n+\n+        salt-cloud -a start vm_name\n+    '''\n+    return _query('grid', 'server/power', args={'name': name, 'power': 'start'})\n+\n+\n+def show_instance(name, call=None):\n+    '''\n+    Start a machine by name\n+\n+    CLI Example:\n+\n+    .. code-block:: bash\n+\n+        salt-cloud -a start vm_name","path":"salt/cloud/clouds/gogrid.py","position":572,"original_position":572,"commit_id":"bbb76bf048c5688cfe4579a0be54d732d3d8c51e","original_commit_id":"bbb76bf048c5688cfe4579a0be54d732d3d8c51e","user":{"login":"rallytime","id":6547906,"avatar_url":"https://avatars.githubusercontent.com/u/6547906?v=3","gravatar_id":"","url":"https://api.github.com/users/rallytime","html_url":"https://github.com/rallytime","followers_url":"https://api.github.com/users/rallytime/followers","following_url":"https://api.github.com/users/rallytime/following{/other_user}","gists_url":"https://api.github.com/users/rallytime/gists{/gist_id}","starred_url":"https://api.github.com/users/rallytime/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rallytime/subscriptions","organizations_url":"https://api.github.com/users/rallytime/orgs","repos_url":"https://api.github.com/users/rallytime/repos","events_url":"https://api.github.com/users/rallytime/events{/privacy}","received_events_url":"https://api.github.com/users/rallytime/received_events","type":"User","site_admin":false},"body":"I think this code block example isn't quite right.","created_at":"2015-06-13T14:51:55Z","updated_at":"2015-06-13T14:51:55Z","html_url":"https://github.com/saltstack/salt/pull/24634#discussion_r32371085","pull_request_url":"https://api.github.com/repos/saltstack/salt/pulls/24634","_links":{"self":{"href":"https://api.github.com/repos/saltstack/salt/pulls/comments/32371085"},"html":{"href":"https://github.com/saltstack/salt/pull/24634#discussion_r32371085"},"pull_request":{"href":"https://api.github.com/repos/saltstack/salt/pulls/24634"}}},"pull_request":{"url":"https://api.github.com/repos/saltstack/salt/pulls/24634","id":37590066,"html_url":"https://github.com/saltstack/salt/pull/24634","diff_url":"https://github.com/saltstack/salt/pull/24634.diff","patch_url":"https://github.com/saltstack/salt/pull/24634.patch","issue_url":"https://api.github.com/repos/saltstack/salt/issues/24634","number":24634,"state":"open","locked":false,"title":"Move GoGrid to a direct REST driver","user":{"login":"techhat","id":287147,"avatar_url":"https://avatars.githubusercontent.com/u/287147?v=3","gravatar_id":"","url":"https://api.github.com/users/techhat","html_url":"https://github.com/techhat","followers_url":"https://api.github.com/users/techhat/followers","following_url":"https://api.github.com/users/techhat/following{/other_user}","gists_url":"https://api.github.com/users/techhat/gists{/gist_id}","starred_url":"https://api.github.com/users/techhat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/techhat/subscriptions","organizations_url":"https://api.github.com/users/techhat/orgs","repos_url":"https://api.github.com/users/techhat/repos","events_url":"https://api.github.com/users/techhat/events{/privacy}","received_events_url":"https://api.github.com/users/techhat/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-06-12T18:16:05Z","updated_at":"2015-06-13T14:51:55Z","closed_at":null,"merged_at":null,"merge_commit_sha":"79e726236b6cb75ed26a255ce61f29a47999a00b","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/saltstack/salt/pulls/24634/commits","review_comments_url":"https://api.github.com/repos/saltstack/salt/pulls/24634/comments","review_comment_url":"https://api.github.com/repos/saltstack/salt/pulls/comments{/number}","comments_url":"https://api.github.com/repos/saltstack/salt/issues/24634/comments","statuses_url":"https://api.github.com/repos/saltstack/salt/statuses/bbb76bf048c5688cfe4579a0be54d732d3d8c51e","head":{"label":"techhat:gogrid","ref":"gogrid","sha":"bbb76bf048c5688cfe4579a0be54d732d3d8c51e","user":{"login":"techhat","id":287147,"avatar_url":"https://avatars.githubusercontent.com/u/287147?v=3","gravatar_id":"","url":"https://api.github.com/users/techhat","html_url":"https://github.com/techhat","followers_url":"https://api.github.com/users/techhat/followers","following_url":"https://api.github.com/users/techhat/following{/other_user}","gists_url":"https://api.github.com/users/techhat/gists{/gist_id}","starred_url":"https://api.github.com/users/techhat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/techhat/subscriptions","organizations_url":"https://api.github.com/users/techhat/orgs","repos_url":"https://api.github.com/users/techhat/repos","events_url":"https://api.github.com/users/techhat/events{/privacy}","received_events_url":"https://api.github.com/users/techhat/received_events","type":"User","site_admin":false},"repo":{"id":2743096,"name":"salt","full_name":"techhat/salt","owner":{"login":"techhat","id":287147,"avatar_url":"https://avatars.githubusercontent.com/u/287147?v=3","gravatar_id":"","url":"https://api.github.com/users/techhat","html_url":"https://github.com/techhat","followers_url":"https://api.github.com/users/techhat/followers","following_url":"https://api.github.com/users/techhat/following{/other_user}","gists_url":"https://api.github.com/users/techhat/gists{/gist_id}","starred_url":"https://api.github.com/users/techhat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/techhat/subscriptions","organizations_url":"https://api.github.com/users/techhat/orgs","repos_url":"https://api.github.com/users/techhat/repos","events_url":"https://api.github.com/users/techhat/events{/privacy}","received_events_url":"https://api.github.com/users/techhat/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/techhat/salt","description":"Central system and configuration manager ","fork":true,"url":"https://api.github.com/repos/techhat/salt","forks_url":"https://api.github.com/repos/techhat/salt/forks","keys_url":"https://api.github.com/repos/techhat/salt/keys{/key_id}","collaborators_url":"https://api.github.com/repos/techhat/salt/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/techhat/salt/teams","hooks_url":"https://api.github.com/repos/techhat/salt/hooks","issue_events_url":"https://api.github.com/repos/techhat/salt/issues/events{/number}","events_url":"https://api.github.com/repos/techhat/salt/events","assignees_url":"https://api.github.com/repos/techhat/salt/assignees{/user}","branches_url":"https://api.github.com/repos/techhat/salt/branches{/branch}","tags_url":"https://api.github.com/repos/techhat/salt/tags","blobs_url":"https://api.github.com/repos/techhat/salt/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/techhat/salt/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/techhat/salt/git/refs{/sha}","trees_url":"https://api.github.com/repos/techhat/salt/git/trees{/sha}","statuses_url":"https://api.github.com/repos/techhat/salt/statuses/{sha}","languages_url":"https://api.github.com/repos/techhat/salt/languages","stargazers_url":"https://api.github.com/repos/techhat/salt/stargazers","contributors_url":"https://api.github.com/repos/techhat/salt/contributors","subscribers_url":"https://api.github.com/repos/techhat/salt/subscribers","subscription_url":"https://api.github.com/repos/techhat/salt/subscription","commits_url":"https://api.github.com/repos/techhat/salt/commits{/sha}","git_commits_url":"https://api.github.com/repos/techhat/salt/git/commits{/sha}","comments_url":"https://api.github.com/repos/techhat/salt/comments{/number}","issue_comment_url":"https://api.github.com/repos/techhat/salt/issues/comments{/number}","contents_url":"https://api.github.com/repos/techhat/salt/contents/{+path}","compare_url":"https://api.github.com/repos/techhat/salt/compare/{base}...{head}","merges_url":"https://api.github.com/repos/techhat/salt/merges","archive_url":"https://api.github.com/repos/techhat/salt/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/techhat/salt/downloads","issues_url":"https://api.github.com/repos/techhat/salt/issues{/number}","pulls_url":"https://api.github.com/repos/techhat/salt/pulls{/number}","milestones_url":"https://api.github.com/repos/techhat/salt/milestones{/number}","notifications_url":"https://api.github.com/repos/techhat/salt/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/techhat/salt/labels{/name}","releases_url":"https://api.github.com/repos/techhat/salt/releases{/id}","created_at":"2011-11-09T17:21:46Z","updated_at":"2015-03-03T14:53:12Z","pushed_at":"2015-06-13T05:04:38Z","git_url":"git://github.com/techhat/salt.git","ssh_url":"git@github.com:techhat/salt.git","clone_url":"https://github.com/techhat/salt.git","svn_url":"https://github.com/techhat/salt","homepage":"saltstack.org","size":105203,"stargazers_count":1,"watchers_count":1,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":1,"default_branch":"develop"}},"base":{"label":"saltstack:develop","ref":"develop","sha":"95dc331da83948a62249b6dcf451f6429d521028","user":{"login":"saltstack","id":1147473,"avatar_url":"https://avatars.githubusercontent.com/u/1147473?v=3","gravatar_id":"","url":"https://api.github.com/users/saltstack","html_url":"https://github.com/saltstack","followers_url":"https://api.github.com/users/saltstack/followers","following_url":"https://api.github.com/users/saltstack/following{/other_user}","gists_url":"https://api.github.com/users/saltstack/gists{/gist_id}","starred_url":"https://api.github.com/users/saltstack/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/saltstack/subscriptions","organizations_url":"https://api.github.com/users/saltstack/orgs","repos_url":"https://api.github.com/users/saltstack/repos","events_url":"https://api.github.com/users/saltstack/events{/privacy}","received_events_url":"https://api.github.com/users/saltstack/received_events","type":"Organization","site_admin":false},"repo":{"id":1390248,"name":"salt","full_name":"saltstack/salt","owner":{"login":"saltstack","id":1147473,"avatar_url":"https://avatars.githubusercontent.com/u/1147473?v=3","gravatar_id":"","url":"https://api.github.com/users/saltstack","html_url":"https://github.com/saltstack","followers_url":"https://api.github.com/users/saltstack/followers","following_url":"https://api.github.com/users/saltstack/following{/other_user}","gists_url":"https://api.github.com/users/saltstack/gists{/gist_id}","starred_url":"https://api.github.com/users/saltstack/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/saltstack/subscriptions","organizations_url":"https://api.github.com/users/saltstack/orgs","repos_url":"https://api.github.com/users/saltstack/repos","events_url":"https://api.github.com/users/saltstack/events{/privacy}","received_events_url":"https://api.github.com/users/saltstack/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/saltstack/salt","description":"Infrastructure automation and management system","fork":false,"url":"https://api.github.com/repos/saltstack/salt","forks_url":"https://api.github.com/repos/saltstack/salt/forks","keys_url":"https://api.github.com/repos/saltstack/salt/keys{/key_id}","collaborators_url":"https://api.github.com/repos/saltstack/salt/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/saltstack/salt/teams","hooks_url":"https://api.github.com/repos/saltstack/salt/hooks","issue_events_url":"https://api.github.com/repos/saltstack/salt/issues/events{/number}","events_url":"https://api.github.com/repos/saltstack/salt/events","assignees_url":"https://api.github.com/repos/saltstack/salt/assignees{/user}","branches_url":"https://api.github.com/repos/saltstack/salt/branches{/branch}","tags_url":"https://api.github.com/repos/saltstack/salt/tags","blobs_url":"https://api.github.com/repos/saltstack/salt/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/saltstack/salt/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/saltstack/salt/git/refs{/sha}","trees_url":"https://api.github.com/repos/saltstack/salt/git/trees{/sha}","statuses_url":"https://api.github.com/repos/saltstack/salt/statuses/{sha}","languages_url":"https://api.github.com/repos/saltstack/salt/languages","stargazers_url":"https://api.github.com/repos/saltstack/salt/stargazers","contributors_url":"https://api.github.com/repos/saltstack/salt/contributors","subscribers_url":"https://api.github.com/repos/saltstack/salt/subscribers","subscription_url":"https://api.github.com/repos/saltstack/salt/subscription","commits_url":"https://api.github.com/repos/saltstack/salt/commits{/sha}","git_commits_url":"https://api.github.com/repos/saltstack/salt/git/commits{/sha}","comments_url":"https://api.github.com/repos/saltstack/salt/comments{/number}","issue_comment_url":"https://api.github.com/repos/saltstack/salt/issues/comments{/number}","contents_url":"https://api.github.com/repos/saltstack/salt/contents/{+path}","compare_url":"https://api.github.com/repos/saltstack/salt/compare/{base}...{head}","merges_url":"https://api.github.com/repos/saltstack/salt/merges","archive_url":"https://api.github.com/repos/saltstack/salt/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/saltstack/salt/downloads","issues_url":"https://api.github.com/repos/saltstack/salt/issues{/number}","pulls_url":"https://api.github.com/repos/saltstack/salt/pulls{/number}","milestones_url":"https://api.github.com/repos/saltstack/salt/milestones{/number}","notifications_url":"https://api.github.com/repos/saltstack/salt/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/saltstack/salt/labels{/name}","releases_url":"https://api.github.com/repos/saltstack/salt/releases{/id}","created_at":"2011-02-20T20:16:56Z","updated_at":"2015-06-13T12:07:33Z","pushed_at":"2015-06-13T14:51:21Z","git_url":"git://github.com/saltstack/salt.git","ssh_url":"git@github.com:saltstack/salt.git","clone_url":"https://github.com/saltstack/salt.git","svn_url":"https://github.com/saltstack/salt","homepage":"saltstack.com","size":224947,"stargazers_count":5282,"watchers_count":5282,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2229,"mirror_url":null,"open_issues_count":2720,"forks":2229,"open_issues":2720,"watchers":5282,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/saltstack/salt/pulls/24634"},"html":{"href":"https://github.com/saltstack/salt/pull/24634"},"issue":{"href":"https://api.github.com/repos/saltstack/salt/issues/24634"},"comments":{"href":"https://api.github.com/repos/saltstack/salt/issues/24634/comments"},"review_comments":{"href":"https://api.github.com/repos/saltstack/salt/pulls/24634/comments"},"review_comment":{"href":"https://api.github.com/repos/saltstack/salt/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/saltstack/salt/pulls/24634/commits"},"statuses":{"href":"https://api.github.com/repos/saltstack/salt/statuses/bbb76bf048c5688cfe4579a0be54d732d3d8c51e"}}}}