Error Status of the Server created with OpenStack Compute Api - api

POST request for creating the OpenStack instance
curl -g -i -X POST http://Controller_ip:8774/v2/tenant_id/servers -H "User-Agent: python-novaclient" -H "Content-Type: application/json" -H "Accept: application/json" -H "X-Auth-Token: token_id" -d '{"server": {"name": "viki_test_instance", "imageRef": "image_id", "flavorRef": "1", "max_count": 1, "min_count": 1, "networks": [{"uuid": "public interface"}], "security_groups": [{"name": "default"}]}}'
Response to the Request
HTTP/1.1 202 Accepted
Content-Length: 438
Location: http://Controlle-ip:8774/v2/tenant-id/servers/image-id
Content-Type: application/json X-Compute-Request-Id:
req-92a46827-1200-4084-bc4e-7c74a9d6f671 Date: Tue, 27 Dec 2016
06:19:10 GMT
{"server": {"security_groups": [{"name": "default"}],
"OS-DCF:diskConfig": "MANUAL", "id": "image-id", "links": [{"href":
"http://controller-ip:8774/v2/tenant-id/servers/image-id", "rel":
"self"}, {"href":
"http://Controller-ip:8774/tenant-id/servers/image-id", "rel":
"bookmark"}], "adminPass": "8vCSQzmf6uwu"}}
Results:
The instance got created with the particular name of the OpenStack tenant and also was listed in the openstack server list command
Problem:
The status of the instance is showing ERROR
I am able to create the instance via openstack server create command and horizon dashboard.
openstack server create --image Ubuntu-14.04-Trusty --flavor m1.small --nic net-id=214a5016-c2e1-47e2-aec3-fcdcdec9e939 viki_test_instance1
nova-api.log shows,
The first log shows to upgrade the glance version but I doubt that is a solution as my other services such the openstack cli and horizon dashboard are able to create the instance.
Need help in debugging this issue.

#dvigneshwer: Thanks for the hint. It did work for me. In my case I am not sure how but the image created with cirros was wrong. I downloaded a new image and then added this image to glance, then created my server and it did work.
+--------------------------------------+--------------------------+--------+
| ID | Name | Status |
+--------------------------------------+--------------------------+--------+
| af6bf068-0997-4711-bf49-5ba44e986d9d | cirros | active |
| dcad76ef-210e-4cee-b4f0-139c0f1cd1f7 | cirros-0.3.5-x86_64-disk | active |<-- Some issue with this Image. So deleted this.
+--------------------------------------+--------------------------+--------+

Related

How to automate BrowserStack screenshot API on my localhost?

I tried to go through their Screenshots API & Local testing but got lost in between..
All I want is to test my front-end style guide (language agnostic), can someone direct me to a good direction please?
Generating screenshots for internal URL via Screenshots API is a two-step process:
a) Setup Local Testing using the BrowserStack Local binary. The command is as follows:
./BrowserStackLocal --key KEY
More details on Local Testing is available here.
b) Add the parameter "local" = true in your Rest API. For more information, refer.
Example for generating a screenshot for localhost on Windows 7-IE 8:
"UserName:KEY" -H "Content-Type: application/json" -H "Accept: application/json" -d '{"browsers": [{"os": "Windows", "os_version": "7", "browser_version": "8.0", "browser": "ie"}], "url": "http://localhost", "local": "true"}' https://www.browserstack.com/screenshots
Note: The access key for your account can be acquired from here.

Docker Hub API v2 token authentication issue

Currently, I'm working on a very light version of Docker containers orchestrator and I have to be able to get image digest from public Docker Hub registry. I want to use Docker Registry API v2 for this purposes.
I'm trying to get authorization token using following API call:
curl https://auth.docker.io/token?service=index.docker.io&scope=repository:alpine:pull
... and I get a response like following:
{"token":"eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCIsIng1YyI6WyJNSUlDTHpDQ0FkU2dBd0lCQWdJQkFEQUtCZ2dxaGtqT1BRUURBakJHTVVRd1FnWURWUVFERXp0Uk5Gb3pPa2RYTjBrNldGUlFSRHBJVFRSUk9rOVVWRmc2TmtGRlF6cFNUVE5ET2tGU01rTTZUMFkzTnpwQ1ZrVkJPa2xHUlVrNlExazFTekFlRncweE5qQTFNekV5TXpVNE5UZGFGdzB4TnpBMU16RXlNelU0TlRkYU1FWXhSREJDQmdOVkJBTVRPMUV6UzFRNlFqSkpNenBhUjFoT09qSlhXRTA2UTBWWFF6cFVNMHhPT2tvMlYxWTZNbGsyVHpwWlFWbEpPbGhQVTBRNlZFUlJTVG8wVWtwRE1Ga3dFd1lIS29aSXpqMENBUVlJS29aSXpqMERBUWNEUWdBRVo0NkVLV3VKSXhxOThuUC9GWEU3U3VyOXlkZ3c3K2FkcndxeGlxN004VHFUa0N0dzBQZm1SS2VLdExwaXNTRFU4LzZseWZ3QUFwZWh6SHdtWmxZR2dxT0JzakNCcnpBT0JnTlZIUThCQWY4RUJBTUNCNEF3RHdZRFZSMGxCQWd3QmdZRVZSMGxBREJFQmdOVkhRNEVQUVE3VVROTFZEcENNa2t6T2xwSFdFNDZNbGRZVFRwRFJWZERPbFF6VEU0NlNqWlhWam95V1RaUE9sbEJXVWs2V0U5VFJEcFVSRkZKT2pSU1NrTXdSZ1lEVlIwakJEOHdQWUE3VVRSYU16cEhWemRKT2xoVVVFUTZTRTAwVVRwUFZGUllPalpCUlVNNlVrMHpRenBCVWpKRE9rOUdOemM2UWxaRlFUcEpSa1ZKT2tOWk5Vc3dDZ1lJS29aSXpqMEVBd0lEU1FBd1JnSWhBTzYxSWloN1FUcHNTMFFIYUNwTDFZTWNMMnZXZlNydlhHbHpSRDEwN2NRUEFpRUFtZXduelNYRHplRGxqcDc4T1NsTFFzbnROYWM5eHRyYW0xU0kxY0ZXQ2tJPSJdfQ.eyJhY2Nlc3MiOltdLCJhdWQiOiJpbmRleC5kb2NrZXIuaW8iLCJleHAiOjE0NzQ1NDcyODMsImlhdCI6MTQ3NDU0Njk4MywiaXNzIjoiYXV0aC5kb2NrZXIuaW8iLCJqdGkiOiIzVTdCazF4dm9CLVA0MGJWVF9JSiIsIm5iZiI6MTQ3NDU0Njk4Mywic3ViIjoiIn0.516fS692WGHNi5Sc44iB8OFSLairrM6n1zNvVo5KXAxlsxsP4rE7VDmW5d0YqvTYeKfZAYIi9yEptx4xJlQ6DA"}
It seems that everything is okay and I'm trying to use obtained token for my next API call:
curl -i -H "Authorization: Bearer eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCIsIng1YyI6WyJNSUlDTHpDQ0FkU2dBd0lCQWdJQkFEQUtCZ2dxaGtqT1BRUURBakJHTVVRd1FnWURWUVFERXp0Uk5Gb3pPa2RYTjBrNldGUlFSRHBJVFRSUk9rOVVWRmc2TmtGRlF6cFNUVE5ET2tGU01rTTZUMFkzTnpwQ1ZrVkJPa2xHUlVrN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M6n1zNvVo5KXAxlsxsP4rE7VDmW5d0YqvTYeKfZAYIi9yEptx4xJlQ6DA" https://index.docker.io/v2/alpine/manifests/latest
... and here what I've got:
HTTP/1.1 401 Unauthorized
Content-Type: application/json; charset=utf-8
Docker-Distribution-Api-Version: registry/2.0
Www-Authenticate: Bearer realm="https://auth.docker.io/token",service="registry.docker.io",scope="repository:alpine:pull",error="invalid_token"
Date: Thu, 22 Sep 2016 12:27:54 GMT
Content-Length: 138
Strict-Transport-Security: max-age=31536000
{"errors":[{"code":"UNAUTHORIZED","message":"authentication required","detail":[{"Type":"repository","Name":"alpine","Action":"pull"}]}]}
Does anybody have ideas why token aouthentication fails for such simple flow?
The response in the Www-Authenticate header is trying to tell you what you need, although it could be more helpful.
First thing: the service you want is registry.docker.io.
Second thing: the repository name in the scope is incomplete. Official repositories only have a single-part name like alpine for the CLI, but in the registry it's properly called library/alpine.
So your token request should be:
curl "https://auth.docker.io/token?service=registry.docker.io&scope=repository:library/alpine:pull"
And then your image request is:
curl --header "Authorization: Bearer eyJh..." https://index.docker.io/v2/library/alpine/manifests/latest
And then you'll get the response.

curl can't list tenants servers

I'm trying to list some info API style :) and what i have done till now is the following:
Using "curl" i can get the token out, with the token i can list the tenants, but after that i can't list the servers and other information. From the conductore if i execute the "nova --debug list --all-tenants" i get the results and get the commands that are executed with curl. So when im trying this from outside i get an error "404" The resource could not be found.
curl -i 'http://x.x.x.x:8774/v2/tenants/' -X GET -H "X-Auth-Token: <Token_ID>" -H "X-Auth-Project-Id: admin" -H "User-Agent: python-novaclient" -H "Accept: application/json"
And with the following command i don't get errors but i get some strange results:
curl -i 'http://x.x.x.x:8774/v2.0/<Tenant_ID>/servers' -X ET -H "X-Auth-Token: <Token_ID>" -H "X-Auth-Project-Id: <Tenant_ID>" -H "User-Agent: python-novaclient" -H "Accept: application/json"
and the output is:
HTTP/1.1 300 Multiple Choices
Content-Type: application/json
Content-Length: 357 Date: Sun, 03 Apr
2016 21:59:48 GMT Connection: close
{"choices": [{"status": "CURRENT",
"media-types": [{"base":
"application/xml", "type":
"application/vnd.openstack.compute+xml;version=2"},
{"base": "application/json", "type":
"application/vnd.openstack.compute+json;version=2"}],
"id": "v2.0", "links": [{"href":
"http://x.x.x.x:8774/v2/v2.0/<Tenant_ID>/servers",
"rel": "self"}]}]}
So my question is what is wrong here, i get output for tokens and listing tenants but i can't get output for listing servers ??
Thanks in advanced !
I tried to find what is wrong with your curl - made requests to my host, but the answer is in the surface-response, obviously :)
You are trying to connect to nova service with version 2.0, but you have endpoint only with version=2 by default, so version must be 2.
Go to http://x.x.x.x/horizon/project/access_and_security/
and check the "API Access" tab, there are endpoints look to the compute one and use it to connect to service.
For example my compute service have endpoint:
Compute http://controller:8774/v2/004e4c0366b74300b875adfd2c1bca4c
Take them to connect to services by curl.

Kong responds 404 when accessed vi Postman

I have set up an API and Kong. I have successfully installed Kong. In fact, i can access my APIs via curl on cli. However, when I use Postman, which I use all of the time, I get the response
{
"request_path": "/api/v1/",
"message": "API not found with these values",
"request_host": [
"192.168.33.13"
]
}
Ps. Im new to kong so please bear with me.
$ kong start
[INFO] Kong 0.7.0
[INFO] Using configuration: /etc/kong/kong.yml
[INFO] Setting working directory to /usr/local/kong
[INFO] database...........cassandra keyspace=kong ssl=verify=false enabled=false replication_factor=1 contact_points=127.0.0.1:9042 replication_strategy=SimpleStrategy timeout=5000 data_centers=
[INFO] dnsmasq............address=127.0.0.1:8053 dnsmasq=true port=8053
[INFO] serf ..............-profile=wan -rpc-addr=127.0.0.1:7373 -event-handler=member-join,member-leave,member-failed,member-update,member-reap,user:kong=/usr/local/kong/serf_event.sh -bind=0.0.0.0:7946 -node=precise64_0.0.0.0:7946 -log-level=err
[INFO] Trying to auto-join Kong nodes, please wait..
[WARN] Cannot auto-join the cluster because no nodes were found
[WARN] ulimit is currently set to "1024". For better performance set it to at least "4096" using "ulimit -n"
[INFO] nginx .............admin_api_listen=0.0.0.0:8001 proxy_listen=0.0.0.0:8000 proxy_listen_ssl=0.0.0.0:8443
[OK] Started
$ curl -i -X POST --url http://localhost:8001/apis/ --data 'name=geospatial' --data 'upstream_url=http://192.168.33.10/' --data 'request_host=192.168.33.10'
HTTP/1.1 201 Created
Date: Fri, 08 Apr 2016 14:38:22 GMT
Content-Type: application/json; charset=utf-8
Transfer-Encoding: chunked
Connection: keep-alive
Access-Control-Allow-Origin: *
Server: kong/0.7.0
{"upstream_url":"http:\/\/192.168.33.10\/","id":"240e6cc6-626f-4629-9551-0d341a57adba","name":"geospatial","created_at":1460126302000,"request_host":"192.168.33.10"}
When I curl the api...
$ curl -i -X GET -H "Host: 192.168.33.10" "http://192.168.33.13:8000/api/v1/"
HTTP/1.1 200 OK
Date: Fri, 08 Apr 2016 14:56:04 GMT
Content-Type: application/json
Content-Length: 70
Connection: keep-alive
Server: Werkzeug/0.11.4 Python/2.7.6
X-Kong-Upstream-Latency: 4
X-Kong-Proxy-Latency: 0
Via: kong/0.7.0
{"status": 200, "message": 200, "data": "Hello World!", "error": null}
How ever when I try to use Postman, I get a 404 status response.
with this body
{
"request_path": "/api/v1/",
"message": "API not found with these values",
"request_host": [
"192.168.33.13"
]
}
Am I missing something?
Disclaimer:
I am using Postman because I am lazy and because my clients will mostly be using Postman as well. So dont tell me to to use curl instead :)
Just encountered the same problem.
In order to send to Kong you need to add Host header, but Postman has some restricted headers that are blocked and Host is one of them.
You need to download Chrome Inspector to send the Host header.
For more details -
https://www.getpostman.com/docs/requests
You need to setup the header parameter named "Host" in order to Kong find your API.
You can see that your curl command have this parameter
-H "Host: 192.168.33.10"

Is there a sample code for using IBM Bluemix Container API?

I'm trying to create container in bluemix with API as it in http://ccsapi-doc.mybluemix.net In the document it mentions:
When using the API with the new model, the following HTTP headers shall be provided:
X-Auth-Token = Bluemix JWT Token
X-Auth-Project-Id = Space GUID
But I have no idea how to get or generate the Bluemix JWT Token. Can someone help me ?
You can get X-Auth-Token by cf oauth-token command. Then copy and paste rest of the part after bearer. And you also can get X-Auth-Project-Id by cf space --guid <space Name>. Please see below commands;
$ cf login -a api.<region>.bluemix.net -u <space name> -o <org name> -s <space name>
$ cf ic login
$ cf oauth-token
$ cf space <space-name> --guid (space name where the container exists)
Try expanding the Authentication section on that page and the "Get TLS Certificate" to show more info
When you enter the values and click "try it out" you will see additional output generated with token info.
This is an alternative Method:
You can retrieve X-Auth-Token and X-Auth-Project-Id with this command:
cf login
CF_TRACE=true cf ic login
Copy all output in a .txt file and search for X-Auth-Token and X-Auth-Project-Id
here there is a simple example:
curl -X GET --header "Accept: application/json" --header "X-Auth-Token: asdlkfajdfdkaldkjfskl239049283049jsdfjksl29304" --header "X-Auth-Project-Id: sdfadf-0090-43ef-22932-23434234" "https://containers-api.ng.bluemix.net/v3/containers/quota"
Response:
The output of API is like this:
{
"account_type": "TRIAL",
"country_code": "ITA",
"org_quota": {
"floating_ips_max": "2",
"floating_ips_space_default": "2",
"floating_ips_usage": 2,
"ram_max": "2048",
"ram_space_default": "2048",
"ram_usage": 2048,
"subnet_usage": -1,
"subnets_default": "5",
"subnets_max": 0
},
"space_quota": {
"floating_ips_max": 2,
"ram_max": 2048,
"subnets_max": -1
}