Recover Vsphere VMs by folder with postman request? - request

I try to recover each VM by folder by using request from postman.
With this request, I'm able to list each folder in my vsphere :
GET https://SERVER/rest/vcenter/folder
With this second command, I'm able to list each VM in my vpshere :
GET https://SERVER/rest/vcenter/vm
I want to know if there is a way to get a folder and each VMS inside it ?
Something like :
GET https://SERVER/rest/vcenter/folder/my_folder
With an output like :
"value": [
{
"folder": "XXX",
"VMs" : {
VM1
VM2
...
Or someting like that ?
Thanks a lot !

http://vmware.github.io/vsphere-automation-sdk-rest/6.5/operations/com/vmware/vcenter/folder.list-operation.html
&filter.parent_folders.1=obj-103
it supports query parameter parent_folders , so the url will be like
GET https://SERVER/rest/vcenter/folder?filters.filter.parent_folders.1=obj-103
Even VM supports the filter called folder:
http://vmware.github.io/vsphere-automation-sdk-rest/6.5/operations/com/vmware/vcenter/vm.list-operation.html

Related

Extension manifest content scripts matches local files

I would like to know if it is possible to add a content script file to a local extension file named for example "test.html", I tried the following but I can not get it to work :
"content_scripts": [
{
"matches": ["popup/test.html"],
"all_frames":true,
"js": ["js/content_script_test.js"]
}
]
I am trying to do this because I would like to be able to use Message Passing from my background script.
You don't need a content script for this, APIs like browser.runtime.sendMessage() and browser.runtime.onMessage.addListener() are available in extension pages, including popups.

Delete and Rename events in google drive

I am working on a feature for our webapp where we create google drive files from our server
Drive service = getServiceForLoginUser();
com.google.api.services.drive.model.File fileMetadata = new com.google.api.services.drive.model.File();
fileMetadata.setTitle(getDefaultName());
fileMetadata.setMimeType(APPLICATION_VND_GOOGLE_APPS_DRIVE_SDK);
com.google.api.services.drive.model.File.Thumbnail thumbnail = buildThumbnail(driveType);
fileMetadata.setThumbnail(thumbnail);
com.google.api.services.drive.model.File googleFile = service.files().insert(fileMetadata)
.setFields("id")
.execute();
I have configured Drive UI Integration to trigger New and Open URL flows from google drive.I have also published a chrome app with following manifest.
"name" : "classflowtest",
"version" : "3.5",
"manifest_version" : 2,
"icons": {
"128": "icon_128.png"
},
"description" : "description_text",
"container" : "GOOGLE_DRIVE",
"api_console_project_id" : "146081768739",
"gdrive_mime_types": {
"http://drive.google.com/intents/opendrivedoc": [
{
"type": ["image/png", "image/jpeg", "image/gif", "html","application/vnd.google.drive.ext-type.png",
"application/vnd.google.drive.ext-type.jpg","application/vnd.google.drive.ext-type.gif","application/vnd.google.drive.ext-type.html"],
"href": "https://mywebappurl",
"title" : "Open",
"disposition" : "window"
}
]
},
"app" : {
"launch" : {
"web_url" : "mywebappurl"
}
}
So now I can trigger New and Open flows in drive successfully. In New flow I create first a resource in our db and then I create a file in google drive from my application server. So every entry I create in google drive has a representation in our db as well. My issue is now if I rename or delete the file in google drive how do I get those events so that I can make the necessary changes in our DB ?
Check the Changes: list if it can help you. It will lists all the changes in your drive. But is is difficult to filter the results. To get the deleted files, you must specify the includeRemoved parameter to true. So it is easier to get the files if you know its fileID before you rename or delete it.
I found in this SO question that someone use Apps Activity API to solve this problem.
For more information, check this thread.

How to generate ready-for-web-server source?

I'm trying to find a way to generate (with generate.py source-all) application code that is ready for running from web server (eg. Tomcat).
The only thing that prevents me from doing this is the fact that myapp.js contains filesystem URIs in libinfo object:
var libinfo = {
"__out__":{"sourceUri":"script"},
"myapp":{"resourceUri":"../source/resource","sourceUri":"../source/class"},
"qx":{
"resourceUri":"file:///C:/dev/qooxdoo-5.0.1-sdk/framework/source/resource",
"sourceUri":"file:///C:/dev/qooxdoo-5.0.1-sdk/framework/source/class",
"sourceViewUri":"https://github.com/qooxdoo/qooxdoo/blob/%{qxGitBranch}/framework/source/class/%{classFilePath}#L%{lineNumber}"
}
};
When I manually change resourceUri & sourceUri from
file:///C:/dev/qooxdoo-5.0.1-sdk/framework/source/...
to
/myapp/qooxdoo-5.0.1-sdk/framework/source/...
application page successfully loads in the browser with all the dependencies (generated sources are already in document root, and "qooxdoo-5.0.1-sdk" framework content loads due to the mapping /myapp/qooxdoo-5.0.1-sdk => C:\Dev\qooxdoo-5.0.1-sdk set up on the server).
Is there a way to tell generate.py that my SDK framework files should be accessed through an URL (/myapp/qooxdoo-5.0.1-sdk/...) instead of filesystem URI?
(I can see there are a number of "compile-options" that can be specified in config.json (qooxdoo Documentation Release 5.1: chapter 11.3.3 - Generator Config Keys), but looks like none of them solves the problem)
In your config.json you will have a "jobs" section containing a "libraries" section, containing a "library" array - your application is a library, as is Qooxdoo, as is any contribs so it will look something like this:
"jobs" : {
"libraries" : {
"=library" : [ {
"manifest" : "${QOOXDOO_PATH}/framework/Manifest.json"
}, {
"manifest" : "Manifest.json"
}
},
Each "library" object can have a "uri" property, so for your example you probably want something like this:
"jobs" : {
"libraries" : {
"=library" : [ {
"manifest" : "${QOOXDOO_PATH}/framework/Manifest.json",
"uri" : "/some/other/uri/qooxdoo-5.0.1-sdk"
}, {
"manifest" : "Manifest.json"
}
},
and then on your web server, either position the qooxdoo-5.0.1-sdk directory appropriately or create a mapping to it.

Laravel returning a 404 on an image

This should be fairly simple though it is completely stumping me.
I have a backend Laravel installation running on localhost:8000
I have a front end Angular app running on localhost:9001.
I have some 'static' images I have included in my seed data (eg.
'1', 'user.png'), these images are being rendered perfectly in my front end (they are also served from the exact place my image uploads are going).
The URL I am currently serving images from is http://localhost:8000/images/{filename}
I can upload images from the front to the back end and they appear in the DB and the image is being put in the filesystem, I'm populating the correct URL in my front end (as evidenced by the previous URL).
My uploaded images are not being shown.
In my logs I am getting:
[2015-01-20 18:13:49] local.ERROR: NotFoundHttpException Route: http://localhost:8000/images/j249ae747ce28c317e02f1fb6d0a10c3.jpg [] []
[2015-01-20 18:13:49] local.ERROR: exception 'Symfony\Component\HttpKernel\Exception\NotFoundHttpException'
I tried a method in my routes file, but couldnt see why, when I am already serving some images already?
I have also set all permissions to 755 on my /images folder.
Any ideas?
I'm not sure I follow every bit of multi-system interaction you have going on, but I'd drop back to first HTTP principles.
Try accessing the image URL directly.
http://localhost:8000/images/j249ae747ce28c317e02f1fb6d0a10c3.jpg
If the error in your browser (or your logs, if you're not developing with debug set to true) is
local.ERROR: NotFoundHttpException Route: http://localhost:8000/images/j249ae747ce28c317e02f1fb6d0a10c3.jpg
This means your web server couldn't find a file at images/j249ae747ce28c317e02f1fb6d0a10c3.jpg, and handed the request to Laravel. This means you need to figure out why your webserver can't see the file.
Assuming you're serving index.php from the public folder
Do you have a public/images/j249ae747ce28c317e02f1fb6d0a10c3.jpg file?
Are you sure? Copy and paste the path into terminal and to a ls public/images/j249ae747ce28c317e02f1fb6d0a10c3.jpg to make sure your brain isn't missing some subtle case issue
Are any errors showing up in your web server's logs (not Laravel's)
Can you create a text/html file in the images folder and serve it? If not, then you may not be pointing your web server at the folder you think you are.
Something like
http://localhost:8000/images/test.txt
http://localhost:8000/images/test.html
Some first principles debugging like that should point you in the right direction.
rm public/storage
php artisan optimize:clear
php artisan storage:link
This worked for me.
The problem is you haven't generated a url for your uploaded image
Try accessing your url like this
http://localhost:8000/storage/images/j249ae747ce28c317e02f1fb6d0a10c3.jpg
To generate the above url
Add this method \Storage::disk('public')->url(); method in your controller.This method accesses the public disk array which is found in Config\filesystems.php and it generates a url in the following format
http://localhost:8000/storage/images/j249ae747ce28c317e02f1fb6d0a10c3.jpg
For example the method below stores the image in the image folder and generates the url of the image path.
public function uploadImage(Request $request)
{
$request->validate(['image'=>'file|image|max:5000']);
$imageProfile = new ImageProfile();
if($request->hasFile('image') && $request->file('image')->isValid())
{
$image = $request->file('image')->store('images');
$imageProfile->image_profile_url = \Storage::disk('public')->url($image);
$imageProfile->save()
}
return response()->json($imageProfile,200);
}
The code returns a Json response below
{
"id": 13,
"image_profile_url ": "http://127.0.0.1:8000/storage/images/cxlogqdI8aodERsmw74nmEx7BkxkWrnyJLMH7sFj.jpeg",
"updated_at": "2020-01-13 16:27:37",
"created_at": "2020-01-13 16:27:37",
}
Try to copy the url and test it in postman.
Visit the link to learn more about Laravel file storage
Laravel File Storage
Hope it helps.
laravel 8
Controler function
public function store(Request $request)
{
$this->validate($request, [
'site_title' => 'required',
'logo_image' => 'required|image|mimes:jpeg,png,jpg,gif,svg|max:2048',
]);
$input['logo_image'] = time().'.'.$request->logo_image->getClientOriginalExtension();
$request->logo_image->move(public_path('images'), $input['logo_image']);
$input['site_title'] = $request->site_title;
//dd($input);
Site_settings::create($input);
return back()->with('success','Image Uploaded successfully.');
}
blade view
<td>
<img src="{{ url('/images/').'/'.$site_settings->logo_image ?? '' }}" alt="" width="250px" height="auto">
</td>

How to use JSON without json file?

I need to use dynamically JSON with data.TreeStore.
With this component, there is proxy "config", it need a path to JSON file.
My problem is, i can't write Json file in my application.
I would know, if i can generated JSON dynamically and pass it to url config into proxy?
For example :
Var trStore = Ext.create('Ext.Data.TreeStore',{
... // config
proxy {
type : 'ajax',
url : { id : 'id0', task :'task0', value : 'val0', ..... }
}
});
My URL is not a file url but is JSON generated with my own method !
How to build JSON for use it with TreeStore and without make file !?
I hope you understand my problem :)
Thanks a lot to help !
Your example looks like you want to pass static "inline data" to the TreeStore.
As far as I can see this is not possible with a bare TreeStore, since it does not have a data config option as the "normal" Store has. However, it is possible with a Treepanel.
You can pass your inline data to the TreeStore using the root config option of the Treepanel (not the TreeStore). It works in a very similar manner as the data config option of a "normal" Store:
Ext.create('Ext.tree.Panel', {
root: { id : 'id0', task :'task0', value : 'val0', children: [...], ... }
// ...
});
There are two caveats related to this:
The beta3 docs say root is boolean, that's wrong.
Because of a bug in beta3 you cannot use this together with rootVisible: false.
Remember that a "json file" is really just a text string, so you can generate that with PHP or your preferred server software.
For the url in the proxy, simply put in the url you use to run that function. Eg in my web app I have http://example.org/controller/getTree?output=json
This runs the getTree() function on my controller, and the function knows to return json.

Resources