Create a frontend website for Horizon OpenStack - node.js

I have setup a private cloud which has 2 computes and the back end is working successfully. OpenStack and Horizon is used to create and manage instances.
Basically, Horizon would be used on an administrator level and not by the user. So for the user to enter inputs like RAM, Disk Storage, Image etc, i want to create a frontend (ReactJS, NodeJS) website though which they can provide the details for VM creation.
The flow would be:
User provides all details through an HTML form.
Those details go to the Administrator sitting who will check the details and then approve the request.
Once the request is approved, VM is created and user can manage the VM.
I want to achieve somewhat like the above.
The goal is to not allow access for the user to create, manage VM instances through horizon.
Any help ?
EDITS
The flow should be the following :
Login to the front end user dashboard.
Allow user to create a flavor by accepting the values.
Store the values into MySQL DB.
Admin would get the request inn his login. An 'Accept' and 'Decline' button would be there on each flavor entry. If admin accepts, using shelljs the openstack flavor creation command is run and the output is saved in db.
The user could get the accepted flavor on his side.
The user would create a VM instance by selecting the flavor which he recieved above.
Using openstack create server command, the VM would be created and a token url would be generated which will be displayed to the user.
8.When user clicks on the url, VM is launched.
So the above is the goal to be achieved using React, NodeJS and MySQL.
The difficult parts would be:-
Running the openstack cli commands using shelljs
Generating a token url.
I hope there might be a way to do this.
Thanks

Not sure how to help you on this. Some ideas:
You will need a python backend unless you want your backend to talk to the OpenStack REST API directly. Similarly to Horizon, using the Django Python web framework will save you some time with using the python client APIs
Then you can build a frontend app with ReactJS and BackboneJS. Since ReactJS itself will not let you communicate with the HTTP Response generated by your backend. Also, you should look into Redux to deal with the data flow.
Here is an open source project which does what you want mostly: https://github.com/cyverse/atmosphere/
HTH

Related

Problems accessing azure data explorer free cluster

I am trying use https://dataexplorer.azure.com/freecluster. I have succefully logged in with my personal email id and created a table. I am able to query data run basic commands..etc. Then i was trying to create a java app to query to my data base. So i navigated to this link https://dataexplorer.azure.com/oneclick, and created a java application downloaded it. When i run this sample program it prompts for login but when i give the email id it shows this error. May i know what is going wrong here?
NB: I have used the same personal account which i used to login and query to ADX via web UI.

webapp only, Track activity(last signin time) of a user of a Cognito userpool

In our webapp (no mobile app), we use cognito userpools for authentication.
There is a use case to track the user login activity so that we will want to send this details to an existing power BI tool. A backend cron job(perhaps a lambda) is expected to fetch user login activity, transform the data and feed BI tool.
I've come across amazon pinpoint and it seems to be a good fit. I've followed the instructions given in https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-user-pools-pinpoint-integration.html to configure cognito userpool to send data to pinpoint, but I could not see any metrics in pinpoint console. I'm not sure what went wrong. Beside to this, I'm not sure whether I can query pinpoint to fetch activity of a given user, this is required because this data will be fed to power BI to generate some custom metrics.
Further googling has taken me to web app analytics setting. Based on this it seems I'll have to write some code on my backend side. Beside to that it talks about identity pool, which is additional. Things started confusing me and turning to complex setup.
It seems I'm missing something, could someone share some light?
Note: backend is nodejs/typescript

Azure Web App Service / Rest API - How to upload a website page

I have a web app service on azure that is hosting a RESTful api which deals with my MySQL database. I am wondering if its possible to somehow (either manually, or otherwise) upload a page to this app service as well. For instance, i have my URL from azure, and my API lives under /api
I was wondering if i can create a php/html page or something that I can upload to /meetingConfirm
so i can do something like /meetingConfirm?id=hash
And have a page which i can send email links to encoded for each meeting, to allow people to respond to invites. It would be a simple page that just updates a value via the API and then displays a confirmation.
For this, you don't need a separate page to be uploaded for each user. You can just add a multi-threading Id generator code and save the last used Id in your DB for future requests.
I am referring to a solution like this(as I am not sure about your tech stack, sharing python approach): How do you generate random unique identifiers in a multi process and multi thread environment?

Accessing Google Sheets & Google's non-Cloud Platform APIs from Google App Engine - NodeJS Flexible Environment

Does anyone here have experience running a NodeJS application on GAE flex environment?
I have a specific question about authenticating to non-cloud platform Google APIs (E.g. Google Drive, Google Sheets, etc and not Cloud Storage, etc).
I've been using Google's ADC and a following the method described here: https://github.com/google/google-api-nodejs-client#choosing-the-correct-credential-type-automatically
This worked for me previously - I was able to use ADC to authenticate with Cloud KMS & cloud storage.
But, I am unable to ship a a feature using the Google Sheets API (it writes data to a sheet based on user interaction, so that I can give this data super easily to the business team) as it runs locally with ADC and the service client keyfile that creates a JWT, but does not run in production.
As there aren't any concrete examples on this for NodeJS I ended up going down the rabbit hole of looking through the separate node docs to solve my issue.
In particular, the Sheets API states that I need to use OAuth 2, but these docs say it's better for me to stick with ADC:
- https://cloud.google.com/appengine/docs/flexible/nodejs/authorizing-apps#oauth_20_authorization
- https://developers.google.com/identity/protocols/OAuth2ServiceAccount
And why would it work with my local copy of my GAE service account's JWT, but not the Compute engine service account? I've added both appengine and compute engine service account emails to the spreadsheet with Write access, but it doesn't seem to work for the latter.
i keep running into the same error where my code works locally and I can append values to a sheet where my app engine email has access to write to, but in production, I continue to get the same error which says the app has insufficient permissions: `"The Sheets API returned an error: Error: A Forbidden error was returned while attempting to retrieve an access token for the Compute Engine built-in service account. This may be because the Compute Engine instance does not have the correct permission scopes specified. Request had insufficient authentication scopes."
So i've also done domain wide authority delegation, and done every single thing I about adding the right access can find.
My main question is, will I be able to continue using the method laid out in this code (https://github.com/google/google-api-nodejs-client#choosing-the-correct-credential-type-automatically), or should I be using OAuth2 as in this documentation (https://developers.google.com/identity/protocols/OAuth2ServiceAccount#authorizingrequests)? And if I need to use OAuth2, what's the point of even being on GAE if I can't even access Google's Sheets API without loading my own credentials in my env variables?
Am I doing something wrong?
I recently wrote NodeJS code that writes to a spreadsheet. It uses a service account and creates a JWT from a key file. My code runs as a Cloud Function, but perhaps it would give you ideas for how to solve your problem in GAE.
As mentioned by Martin, you can access Google Sheets via the Google Sheets API with the Node Client library. I'd follow that link for details.
Here's a summary:
Create a service account. Name it credentials.json.
Enable the Google Sheets API
Copy the email address found from step 1.
Share the Google Sheet with the email address.
Call the Google Sheets API, authorizing with the credentials created above.
Links:
Sheets API: https://developers.google.com/sheets
Node Client: https://github.com/googleapis/google-api-nodejs-client

Azure Easy API on Node.js 'No route registered for '/api/xxx'?

I'm having problems even running a simple Easy API method. I keep getting the response that says "No route registered for '/api/userInfo'".
I know that this location is correct because the I'm opening the App Service editor at https://XXXX/dev/wwwroot/api/userInfo.js
The file also has anonymous access, so there shouldn't be an authorization issue. I'm simply trying to hit the api method from a browser.
The code of this very simple method has been reduced to the following for debugging purposes
module.exports = {
"get":function(){
console.log('whooohooo');
}
};
Is there a setting I'm missing to enable the ability to call Easy API's? I've not been able to find any documentation that states that Easy APIs method must be explicitly enabled, nor can I find any settings related to enabling them.
Please note that I did not set up a Node.js project and deploy it to Azure. I am using an "out of the box" app service.
My end goal is to use an Easy API method go get an authenticated user's email and name, but my efforts have been reduced to confirming that I can call a method. Thanks in advance.
UPDATE:
I've created 3 different mobile App services with no luck and varying advantages.
App Service 1:
This Mobile Apps project is 10 months old and was created in the Azure portal. It has a routing line in the app.js file that suggest that the api route should be present, but doesn't work. I don't remember if i authorized the easy apis when i created it, but the fact that it has the following line suggests that I did
mobile.api.import('./api');
AppService 2:
This project was created in the MobileCenter using the Tables menu option for a Xamarin project. I then navigated to the Azure Portal and hooked up a SQL db to the table. I don't think I had the opt in to use Easy APIs, but the I was allowed to create an Easy API script, then edit it. Upon editing it, I realized that the project had no app.js file. Apparently web apps created via MobileCenter are created differently.
I picked this option because it allows you to use the "per-user" flag when setting up tables and doesn't require you to manually filter out data with a modification to the table's script. Apparently this is not an option if you don't set up an App Service via the MobileCenter??
App Service 3:
I created a brand new project within the portal and followed the the steps Aaron Chen laid out. I opted in, hooked up the table and modified the js file (I created a new one called 'testing'). I browsed to https://zzzzapitestzzzz1.scm.azurewebsites.net/api/testing
and got the dreaded no routes found error. Of course, the API method was created with anon access rights.
Basically, we can easily create an Easy API in the Azure portal.
Select your app service and click on Easy APIs in the MOBILE menu.
Enable Mobile extension for your app by clicking Need to configure Easy Tables/Easy APIs ...
Connect a database and then click Initialize App button.
After app initialized, you can add an API from Easy APIs blade.
Change the userInfo.js file to something like this:
Now, we can access the API with the endpoint http://<yourappname>.azurewebsites.net/api/userInfo.
For more info, please refer to this blog post.

Resources