Reset server(VM) status to ACTIVE using REST API Nova - openstack-nova

When Server(VM) status is in ERROR How to reset the status back to Active using REST API (Nova).
CLI For .e.g nova reset-state --active vm

From the openstack nova API documentation https://developer.openstack.org/api-ref/compute/
To reset the status of VM using API: https://developer.openstack.org/api-ref/compute/#reset-server-state-os-resetstate-action
/servers/{server_id}/action - Reset Server State (os-resetState Action)
Request body:
{
"os-resetState": {
"state": "active"
} }
Response:
If successful, this method does not return content in the response
body.

Related

Accessing user token in IBM Cloud Functions serverless app secured with OAuth user authentication

I am creating a serverless app using IBM Cloud Functions. My Cloud Functions API is secured with OAuth user authentication using an IBM Cloud App ID service. When a user logs into my app, an access token is generated by this service. I want to extract user data from that access token so that I can customize the user experience.
How do I access that token from within a Cloud Functions action that is coded for Node.js 10?
Example
The openwhisk webaction doc
https://github.com/apache/openwhisk/blob/master/docs/webactions.md
states that the following code
function main(params) {
return { response: params };
}
generates the following response
{
"response": {
"__ow_method": "get",
"__ow_headers": {
"accept": "*/*",
"connection": "close",
"host": "172.17.0.1",
"user-agent": "curl/7.43.0"
},
"__ow_path": ""
}
}
From that data I should be able to get HTTP request details. Specifically, I should be able to get the Authorization header value off the "__ow_headers" property of the action argument (params).
However, the same code inside an IBM Cloud Functions web action generates nothing. Nothing exists on the params object.

AWS Lambda python function giving json headers in the output

I am trying to invoke lambda service. When I hit the Get method(under Api gateway->stages->GET) invoke Url I see json headers and status code also. But in the acloud guru lecture video, I see just the body. Can anyone please tell what am I missing here.
Here is my python function:
def lambda_handler(event, context):
print("In lambda handler")
resp = {
"statusCode": 200,
"headers": {
"Access-Control-Allow-Origin": "*",
},
"body": "myName"
}
return resp
Actual Output:
{"statusCode": 200, "headers": {"Access-Control-Allow-Origin": "*"}, "body": "myName"}
Expected output:
myName
here you have used lambda proxy integration and did not enable it in API gateway level.
You can enable it under Integration request, see the image below
There are 2 types of API Gateway and Lambda integration
Proxy Integration - Request to API gateway is directly forwarded to lambda and response is sent from lambda. we have to create the response body with appropriate status code and headers inside the lambda in this integration
Lambda Integration - request can be modified before sending to lambda and response can be modified from lambda response in API gateway level using mapping templates
This blog post gives more details about the 2 integrations
https://medium.com/#lakshmanLD/lambda-proxy-vs-lambda-integration-in-aws-api-gateway-3a9397af0e6d

Trigger a cloud build pipeline using Cloud Function

I'm trying to create a cloud function listening to cloudbuilds topic and making an API call to trigger the build. I think I'm missing something in my index.js file (I'm new to Node.js). Can you provide a sample example of a Cloud Function making an API call to the Cloud Build API?
Here is my function:
const request = require('request')
const accessToken = '$(gcloud config config-helper --format='value(credential.access_token)')';
request({
url: 'https://cloudbuild.googleapis.com/v1/projects/[PROJECT_ID]/builds',
auth: {
'bearer': accessToken
},
method: 'POST',
json: {"steps": [{"name":"gcr.io/cloud-builders/gsutil", "args": ['cp','gs://adolfo-test-cloudbuilds/cloudbuild.yaml', 'gs://adolfo-test_cloudbuild/cloudbuild.yaml']}]},
},
module.exports.build = (err, res) => {
console.log(res.body);
});
I was executing the command gcloud config config-helper --format='value(credential.access_token)', copying the token, and putting it as a value to the variable accessToken. But this didn't work for me.
Here is the error: { error: { code: 403, message: 'The caller does not have permission', status: 'PERMISSION_DENIED' } }
I had the same exact problem and I have solved it by writing a small package, you can use it or read the source code.
https://github.com/MatteoGioioso/google-cloud-build-trigger
With this package you can run a pre-configured trigger from cloud build.
You can also extend to call other cloud build API endpoints.
As my understanding cloud build API requires either OAuth2 or a service account. Make sure you gave the right permission to cloud build in the gcp console under IAM. After that you should be able to download the service-account.json file.

How can I trigger a Google Apps Script function from the Google API PHP Client with the authentication I have set already?

I'm struggling to trigger a Google Apps Script Function which builds many dropdowns of a Google Spreadsheet.
I need this data to be updated daily on this Google Spreadsheet so I must call the function.
Seems like I'm required to have a client-side authentication which I'm reluctant to force it to happen.
I have set already the Google API PHP Client which does batch updates, get requests and control users and its roles.
Here's how the code looks like:
public function updateTemplate ()
{
$client = $this->getClient();
$service = new Google_Service_Script($client);
$scriptId = $this->gScriptId;
// Create an execution request object.
$request = new Google_Service_Script_ExecutionRequest();
$request->setFunction('SetUpNewSpreadsheet');
try {
// Make the API request.
$response = $service->scripts->run($scriptId, $request);
echo "here<pre>";
print_r($response);
exit;
I'm getting the following response error:
Caught exception: {
"error": {
"code": 401,
"message": "Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.",
"errors": [ {
"message": "Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.",
"domain": "global",
"reason": "unauthorized"
} ]
, "status": "UNAUTHENTICATED"
}
}
I've checked the message errors and docs already. I'm wondering if maybe I'm missing something or if I can find a way to execute that request without forcing a client-side login?
Has anyone been through it?

How to get the JSON response from the Greenhopper REST API in Gadget?

I am not able to get the response from the GreenHopper REST API for the url http://:2990/jira/rest/greenhopper/1.0/sprints/1 through my Gadget application.
I able to get the following output when I try it from Browser, Below is the Output.
{"sprints":[{"id":1,"name":"Sprint 1","closed":false}],"rapidViewId":1}
My Code snippet to retrive the sprint details in Gadget is :
args: {
key: "sprints",
ajaxOptions: function () {
return {
url: "/rest/greenhopper/1.0/sprints/1",
};
}
}
Can anybody sugget me how to get the JSON Response from greenhopper REST API for a JIRA dashboard.
I am getting following Exception in Server:
[talledLocalContainer] at java.lang.Thread.run(Thread.java:662)
[talledLocalContainer] 2013-04-25 15:26:58,985 http-2990-11 ERROR admin 926x5323x1 dggnll 172.27.186.82 /rest/greenhopper/1.0/sprints/1
[common.error.jersey.ThrowableExceptionMapper] Uncaught exception thrown by REST service
[talledLocalContainer] javax.ws.rs.WebApplicationException
[talledLocalContainer] at com.sun.jersey.server.impl.uri.rules.TerminatingRule.accept(TerminatingRule.java:66)
[talledLocalContainer] at com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:108)
That's the right URL so maybe the sprint doesn't exist or you don't have permission to view it? Also, try using the Developer Workbox add-on and the REST API browser to test these kind of methods.