{"action":"created","comment":{"url":"https://api.github.com/repos/sl1pm4t/terraform-provider-lxd/pulls/comments/127619262","pull_request_review_id":50222706,"id":127619262,"diff_hunk":"@@ -203,40 +210,84 @@ func resourceLxdContainerCreate(d *schema.ResourceData, meta interface{}) error\n \t\tprofiles = append(profiles, \"default\")\n \t}\n \n-\t// client.Init = (name string, imgremote string, image string, profiles *[]string, config map[string]string, devices shared.Devices, ephem bool)\n-\tvar resp *api.Response\n-\tif resp, err = client.Init(name, remote, image, &profiles, config, devices, ephem); err != nil {\n-\t\treturn err\n+\t// build API request\n+\tcreateReq := api.ContainersPost{}\n+\tcreateReq.Name = name\n+\tcreateReq.Profiles = profiles\n+\tcreateReq.Config = config\n+\tcreateReq.Devices = devices\n+\tcreateReq.Ephemeral = ephem\n+\n+\t// Gather info about source image\n+\t//\n+\t// Optimisation for simplestreams\n+\tvar imgInfo *api.Image\n+\tif conn, _ := imgServer.GetConnectionInfo(); conn.Protocol == \"simplestreams\" {\n+\t\timgInfo = &api.Image{}\n+\t\timgInfo.Fingerprint = image\n+\t\timgInfo.Public = true\n+\t\tcreateReq.Source.Alias = image\n+\t} else {\n+\t\t// Attempt to resolve an image alias\n+\t\talias, _, err := imgServer.GetImageAlias(image)\n+\t\tif err == nil {\n+\t\t\tcreateReq.Source.Alias = image\n+\t\t\timage = alias.Target\n+\t\t}\n+\n+\t\t// Get the image info\n+\t\timgInfo, _, err = imgServer.GetImage(image)\n+\t\tif err != nil {\n+\t\t\treturn fmt.Errorf(\"could not get image info: %v\", err)\n+\t\t}\n \t}\n \n-\t// Wait for the LXC container to be created\n-\terr = client.WaitForSuccess(resp.Operation)\n+\t// Create container. It will not be running after this operation\n+\top1, err := client.CreateContainerFromImage(imgServer, *imgInfo, createReq)\n \tif err != nil {\n \t\treturn err\n \t}\n \n+\t// Wait for the container to be created\n+\terr = op1.Wait()\n+\tif err != nil {\n+\t\treturn fmt.Errorf(\"failed to create container (%s): %s\", name, err)\n+\t}\n+\n+\t// Container has been created, store ID\n+\td.SetId(name)\n+\n \t// Start container\n-\t_, err = client.Action(name, shared.Start, -1, false, false)\n+\tstartReq := api.ContainerStatePut{\n+\t\tAction:  \"start\",\n+\t\tTimeout: UpdateTimeout,\n+\t\tForce:   false,\n+\t}\n+\top2, err := client.UpdateContainerState(name, startReq, \"\")\n \tif err != nil {\n \t\t// Container has been created, but daemon rejected start request\n-\t\treturn err\n+\t\treturn fmt.Errorf(\"LXD server rejected request to start container (%s): %s\", name, err)\n \t}\n \n-\t// Wait until the container is in a Running state\n+\tif err = op2.Wait(); err != nil {\n+\t\treturn fmt.Errorf(\"failed to start container (%s): %s\", name, err)\n+\t}\n+\n+\t// Even though op.Wait has completed,\n+\t// wait until we can see the container is running via a new API call.\n+\t// At a minimum, this adds some padding between API calls.\n \tstateConf := &resource.StateChangeConf{\n \t\tTarget:     []string{\"Running\"},\n \t\tRefresh:    resourceLxdContainerRefresh(client, name),\n \t\tTimeout:    3 * time.Minute,\n-\t\tDelay:      refreshInterval,\n+\t\tDelay:      3 * time.Second,","path":"lxd/resource_lxd_container.go","position":124,"original_position":124,"commit_id":"ebe1cc422b0fcd82e951d05742b409801e9f9bdb","original_commit_id":"ebe1cc422b0fcd82e951d05742b409801e9f9bdb","user":{"login":"jtopjian","id":46959,"avatar_url":"https://avatars4.githubusercontent.com/u/46959?v=4","gravatar_id":"","url":"https://api.github.com/users/jtopjian","html_url":"https://github.com/jtopjian","followers_url":"https://api.github.com/users/jtopjian/followers","following_url":"https://api.github.com/users/jtopjian/following{/other_user}","gists_url":"https://api.github.com/users/jtopjian/gists{/gist_id}","starred_url":"https://api.github.com/users/jtopjian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jtopjian/subscriptions","organizations_url":"https://api.github.com/users/jtopjian/orgs","repos_url":"https://api.github.com/users/jtopjian/repos","events_url":"https://api.github.com/users/jtopjian/events{/privacy}","received_events_url":"https://api.github.com/users/jtopjian/received_events","type":"User","site_admin":false},"body":"Yeah, let's add the `refreshInterval` back here.","created_at":"2017-07-16T22:59:22Z","updated_at":"2017-07-16T22:59:22Z","html_url":"https://github.com/sl1pm4t/terraform-provider-lxd/pull/71#discussion_r127619262","pull_request_url":"https://api.github.com/repos/sl1pm4t/terraform-provider-lxd/pulls/71","_links":{"self":{"href":"https://api.github.com/repos/sl1pm4t/terraform-provider-lxd/pulls/comments/127619262"},"html":{"href":"https://github.com/sl1pm4t/terraform-provider-lxd/pull/71#discussion_r127619262"},"pull_request":{"href":"https://api.github.com/repos/sl1pm4t/terraform-provider-lxd/pulls/71"}}},"pull_request":{"url":"https://api.github.com/repos/sl1pm4t/terraform-provider-lxd/pulls/71","id":128771079,"html_url":"https://github.com/sl1pm4t/terraform-provider-lxd/pull/71","diff_url":"https://github.com/sl1pm4t/terraform-provider-lxd/pull/71.diff","patch_url":"https://github.com/sl1pm4t/terraform-provider-lxd/pull/71.patch","issue_url":"https://api.github.com/repos/sl1pm4t/terraform-provider-lxd/issues/71","number":71,"state":"open","locked":false,"title":"[WIP] Port provider to new LXD client","user":{"login":"sl1pm4t","id":8053182,"avatar_url":"https://avatars7.githubusercontent.com/u/8053182?v=4","gravatar_id":"","url":"https://api.github.com/users/sl1pm4t","html_url":"https://github.com/sl1pm4t","followers_url":"https://api.github.com/users/sl1pm4t/followers","following_url":"https://api.github.com/users/sl1pm4t/following{/other_user}","gists_url":"https://api.github.com/users/sl1pm4t/gists{/gist_id}","starred_url":"https://api.github.com/users/sl1pm4t/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sl1pm4t/subscriptions","organizations_url":"https://api.github.com/users/sl1pm4t/orgs","repos_url":"https://api.github.com/users/sl1pm4t/repos","events_url":"https://api.github.com/users/sl1pm4t/events{/privacy}","received_events_url":"https://api.github.com/users/sl1pm4t/received_events","type":"User","site_admin":false},"body":"Fixes #70 \r\n\r\n","created_at":"2017-07-04T10:18:23Z","updated_at":"2017-07-16T22:59:22Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8fd6cca805bf93960c4ecc3d24e5fdb5a2d24f70","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/sl1pm4t/terraform-provider-lxd/pulls/71/commits","review_comments_url":"https://api.github.com/repos/sl1pm4t/terraform-provider-lxd/pulls/71/comments","review_comment_url":"https://api.github.com/repos/sl1pm4t/terraform-provider-lxd/pulls/comments{/number}","comments_url":"https://api.github.com/repos/sl1pm4t/terraform-provider-lxd/issues/71/comments","statuses_url":"https://api.github.com/repos/sl1pm4t/terraform-provider-lxd/statuses/ebe1cc422b0fcd82e951d05742b409801e9f9bdb","head":{"label":"sl1pm4t:new-lxd-client","ref":"new-lxd-client","sha":"ebe1cc422b0fcd82e951d05742b409801e9f9bdb","user":{"login":"sl1pm4t","id":8053182,"avatar_url":"https://avatars7.githubusercontent.com/u/8053182?v=4","gravatar_id":"","url":"https://api.github.com/users/sl1pm4t","html_url":"https://github.com/sl1pm4t","followers_url":"https://api.github.com/users/sl1pm4t/followers","following_url":"https://api.github.com/users/sl1pm4t/following{/other_user}","gists_url":"https://api.github.com/users/sl1pm4t/gists{/gist_id}","starred_url":"https://api.github.com/users/sl1pm4t/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sl1pm4t/subscriptions","organizations_url":"https://api.github.com/users/sl1pm4t/orgs","repos_url":"https://api.github.com/users/sl1pm4t/repos","events_url":"https://api.github.com/users/sl1pm4t/events{/privacy}","received_events_url":"https://api.github.com/users/sl1pm4t/received_events","type":"User","site_admin":false},"repo":{"id":47083172,"name":"terraform-provider-lxd","full_name":"sl1pm4t/terraform-provider-lxd","owner":{"login":"sl1pm4t","id":8053182,"avatar_url":"https://avatars7.githubusercontent.com/u/8053182?v=4","gravatar_id":"","url":"https://api.github.com/users/sl1pm4t","html_url":"https://github.com/sl1pm4t","followers_url":"https://api.github.com/users/sl1pm4t/followers","following_url":"https://api.github.com/users/sl1pm4t/following{/other_user}","gists_url":"https://api.github.com/users/sl1pm4t/gists{/gist_id}","starred_url":"https://api.github.com/users/sl1pm4t/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sl1pm4t/subscriptions","organizations_url":"https://api.github.com/users/sl1pm4t/orgs","repos_url":"https://api.github.com/users/sl1pm4t/repos","events_url":"https://api.github.com/users/sl1pm4t/events{/privacy}","received_events_url":"https://api.github.com/users/sl1pm4t/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/sl1pm4t/terraform-provider-lxd","description":"LXD Resource provider for Terraform","fork":false,"url":"https://api.github.com/repos/sl1pm4t/terraform-provider-lxd","forks_url":"https://api.github.com/repos/sl1pm4t/terraform-provider-lxd/forks","keys_url":"https://api.github.com/repos/sl1pm4t/terraform-provider-lxd/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sl1pm4t/terraform-provider-lxd/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sl1pm4t/terraform-provider-lxd/teams","hooks_url":"https://api.github.com/repos/sl1pm4t/terraform-provider-lxd/hooks","issue_events_url":"https://api.github.com/repos/sl1pm4t/terraform-provider-lxd/issues/events{/number}","events_url":"https://api.github.com/repos/sl1pm4t/terraform-provider-lxd/events","assignees_url":"https://api.github.com/repos/sl1pm4t/terraform-provider-lxd/assignees{/user}","branches_url":"https://api.github.com/repos/sl1pm4t/terraform-provider-lxd/branches{/branch}","tags_url":"https://api.github.com/repos/sl1pm4t/terraform-provider-lxd/tags","blobs_url":"https://api.github.com/repos/sl1pm4t/terraform-provider-lxd/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sl1pm4t/terraform-provider-lxd/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sl1pm4t/terraform-provider-lxd/git/refs{/sha}","trees_url":"https://api.github.com/repos/sl1pm4t/terraform-provider-lxd/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sl1pm4t/terraform-provider-lxd/statuses/{sha}","languages_url":"https://api.github.com/repos/sl1pm4t/terraform-provider-lxd/languages","stargazers_url":"https://api.github.com/repos/sl1pm4t/terraform-provider-lxd/stargazers","contributors_url":"https://api.github.com/repos/sl1pm4t/terraform-provider-lxd/contributors","subscribers_url":"https://api.github.com/repos/sl1pm4t/terraform-provider-lxd/subscribers","subscription_url":"https://api.github.com/repos/sl1pm4t/terraform-provider-lxd/subscription","commits_url":"https://api.github.com/repos/sl1pm4t/terraform-provider-lxd/commits{/sha}","git_commits_url":"https://api.github.com/repos/sl1pm4t/terraform-provider-lxd/git/commits{/sha}","comments_url":"https://api.github.com/repos/sl1pm4t/terraform-provider-lxd/comments{/number}","issue_comment_url":"https://api.github.com/repos/sl1pm4t/terraform-provider-lxd/issues/comments{/number}","contents_url":"https://api.github.com/repos/sl1pm4t/terraform-provider-lxd/contents/{+path}","compare_url":"https://api.github.com/repos/sl1pm4t/terraform-provider-lxd/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sl1pm4t/terraform-provider-lxd/merges","archive_url":"https://api.github.com/repos/sl1pm4t/terraform-provider-lxd/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sl1pm4t/terraform-provider-lxd/downloads","issues_url":"https://api.github.com/repos/sl1pm4t/terraform-provider-lxd/issues{/number}","pulls_url":"https://api.github.com/repos/sl1pm4t/terraform-provider-lxd/pulls{/number}","milestones_url":"https://api.github.com/repos/sl1pm4t/terraform-provider-lxd/milestones{/number}","notifications_url":"https://api.github.com/repos/sl1pm4t/terraform-provider-lxd/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sl1pm4t/terraform-provider-lxd/labels{/name}","releases_url":"https://api.github.com/repos/sl1pm4t/terraform-provider-lxd/releases{/id}","deployments_url":"https://api.github.com/repos/sl1pm4t/terraform-provider-lxd/deployments","created_at":"2015-11-29T22:34:42Z","updated_at":"2017-06-25T09:53:41Z","pushed_at":"2017-07-16T21:44:03Z","git_url":"git://github.com/sl1pm4t/terraform-provider-lxd.git","ssh_url":"git@github.com:sl1pm4t/terraform-provider-lxd.git","clone_url":"https://github.com/sl1pm4t/terraform-provider-lxd.git","svn_url":"https://github.com/sl1pm4t/terraform-provider-lxd","homepage":null,"size":5040,"stargazers_count":32,"watchers_count":32,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":12,"mirror_url":null,"open_issues_count":10,"forks":12,"open_issues":10,"watchers":32,"default_branch":"master"}},"base":{"label":"sl1pm4t:master","ref":"master","sha":"4cb0e2f0f4b88b7953a7885bf1c35c20299a44f4","user":{"login":"sl1pm4t","id":8053182,"avatar_url":"https://avatars7.githubusercontent.com/u/8053182?v=4","gravatar_id":"","url":"https://api.github.com/users/sl1pm4t","html_url":"https://github.com/sl1pm4t","followers_url":"https://api.github.com/users/sl1pm4t/followers","following_url":"https://api.github.com/users/sl1pm4t/following{/other_user}","gists_url":"https://api.github.com/users/sl1pm4t/gists{/gist_id}","starred_url":"https://api.github.com/users/sl1pm4t/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sl1pm4t/subscriptions","organizations_url":"https://api.github.com/users/sl1pm4t/orgs","repos_url":"https://api.github.com/users/sl1pm4t/repos","events_url":"https://api.github.com/users/sl1pm4t/events{/privacy}","received_events_url":"https://api.github.com/users/sl1pm4t/received_events","type":"User","site_admin":false},"repo":{"id":47083172,"name":"terraform-provider-lxd","full_name":"sl1pm4t/terraform-provider-lxd","owner":{"login":"sl1pm4t","id":8053182,"avatar_url":"https://avatars7.githubusercontent.com/u/8053182?v=4","gravatar_id":"","url":"https://api.github.com/users/sl1pm4t","html_url":"https://github.com/sl1pm4t","followers_url":"https://api.github.com/users/sl1pm4t/followers","following_url":"https://api.github.com/users/sl1pm4t/following{/other_user}","gists_url":"https://api.github.com/users/sl1pm4t/gists{/gist_id}","starred_url":"https://api.github.com/users/sl1pm4t/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sl1pm4t/subscriptions","organizations_url":"https://api.github.com/users/sl1pm4t/orgs","repos_url":"https://api.github.com/users/sl1pm4t/repos","events_url":"https://api.github.com/users/sl1pm4t/events{/privacy}","received_events_url":"https://api.github.com/users/sl1pm4t/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/sl1pm4t/terraform-provider-lxd","description":"LXD Resource provider for Terraform","fork":false,"url":"https://api.github.com/repos/sl1pm4t/terraform-provider-lxd","forks_url":"https://api.github.com/repos/sl1pm4t/terraform-provider-lxd/forks","keys_url":"https://api.github.com/repos/sl1pm4t/terraform-provider-lxd/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sl1pm4t/terraform-provider-lxd/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sl1pm4t/terraform-provider-lxd/teams","hooks_url":"https://api.github.com/repos/sl1pm4t/terraform-provider-lxd/hooks","issue_events_url":"https://api.github.com/repos/sl1pm4t/terraform-provider-lxd/issues/events{/number}","events_url":"https://api.github.com/repos/sl1pm4t/terraform-provider-lxd/events","assignees_url":"https://api.github.com/repos/sl1pm4t/terraform-provider-lxd/assignees{/user}","branches_url":"https://api.github.com/repos/sl1pm4t/terraform-provider-lxd/branches{/branch}","tags_url":"https://api.github.com/repos/sl1pm4t/terraform-provider-lxd/tags","blobs_url":"https://api.github.com/repos/sl1pm4t/terraform-provider-lxd/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sl1pm4t/terraform-provider-lxd/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sl1pm4t/terraform-provider-lxd/git/refs{/sha}","trees_url":"https://api.github.com/repos/sl1pm4t/terraform-provider-lxd/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sl1pm4t/terraform-provider-lxd/statuses/{sha}","languages_url":"https://api.github.com/repos/sl1pm4t/terraform-provider-lxd/languages","stargazers_url":"https://api.github.com/repos/sl1pm4t/terraform-provider-lxd/stargazers","contributors_url":"https://api.github.com/repos/sl1pm4t/terraform-provider-lxd/contributors","subscribers_url":"https://api.github.com/repos/sl1pm4t/terraform-provider-lxd/subscribers","subscription_url":"https://api.github.com/repos/sl1pm4t/terraform-provider-lxd/subscription","commits_url":"https://api.github.com/repos/sl1pm4t/terraform-provider-lxd/commits{/sha}","git_commits_url":"https://api.github.com/repos/sl1pm4t/terraform-provider-lxd/git/commits{/sha}","comments_url":"https://api.github.com/repos/sl1pm4t/terraform-provider-lxd/comments{/number}","issue_comment_url":"https://api.github.com/repos/sl1pm4t/terraform-provider-lxd/issues/comments{/number}","contents_url":"https://api.github.com/repos/sl1pm4t/terraform-provider-lxd/contents/{+path}","compare_url":"https://api.github.com/repos/sl1pm4t/terraform-provider-lxd/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sl1pm4t/terraform-provider-lxd/merges","archive_url":"https://api.github.com/repos/sl1pm4t/terraform-provider-lxd/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sl1pm4t/terraform-provider-lxd/downloads","issues_url":"https://api.github.com/repos/sl1pm4t/terraform-provider-lxd/issues{/number}","pulls_url":"https://api.github.com/repos/sl1pm4t/terraform-provider-lxd/pulls{/number}","milestones_url":"https://api.github.com/repos/sl1pm4t/terraform-provider-lxd/milestones{/number}","notifications_url":"https://api.github.com/repos/sl1pm4t/terraform-provider-lxd/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sl1pm4t/terraform-provider-lxd/labels{/name}","releases_url":"https://api.github.com/repos/sl1pm4t/terraform-provider-lxd/releases{/id}","deployments_url":"https://api.github.com/repos/sl1pm4t/terraform-provider-lxd/deployments","created_at":"2015-11-29T22:34:42Z","updated_at":"2017-06-25T09:53:41Z","pushed_at":"2017-07-16T21:44:03Z","git_url":"git://github.com/sl1pm4t/terraform-provider-lxd.git","ssh_url":"git@github.com:sl1pm4t/terraform-provider-lxd.git","clone_url":"https://github.com/sl1pm4t/terraform-provider-lxd.git","svn_url":"https://github.com/sl1pm4t/terraform-provider-lxd","homepage":null,"size":5040,"stargazers_count":32,"watchers_count":32,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":12,"mirror_url":null,"open_issues_count":10,"forks":12,"open_issues":10,"watchers":32,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/sl1pm4t/terraform-provider-lxd/pulls/71"},"html":{"href":"https://github.com/sl1pm4t/terraform-provider-lxd/pull/71"},"issue":{"href":"https://api.github.com/repos/sl1pm4t/terraform-provider-lxd/issues/71"},"comments":{"href":"https://api.github.com/repos/sl1pm4t/terraform-provider-lxd/issues/71/comments"},"review_comments":{"href":"https://api.github.com/repos/sl1pm4t/terraform-provider-lxd/pulls/71/comments"},"review_comment":{"href":"https://api.github.com/repos/sl1pm4t/terraform-provider-lxd/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/sl1pm4t/terraform-provider-lxd/pulls/71/commits"},"statuses":{"href":"https://api.github.com/repos/sl1pm4t/terraform-provider-lxd/statuses/ebe1cc422b0fcd82e951d05742b409801e9f9bdb"}}}}
{"actor":{"display_login":"jtopjian"}}