vCloudDirector API can`t change instantiation params for vApp - vcloud-director-rest-api

Currently I was stopped by problem that I need to change my instantiation params programmatically to have possibility to run instances with different CPU number and Memory size.
I found out that I need to use InstantiateVAppTemplateParamsType (link below)
https://code.vmware.com/apis/442/vcloud-director/doc/doc/types/InstantiateVAppTemplateParamsType.html
I found out how to start VApp with this parameters WITHOUT customization by simplifying params to:
<?xml version="1.0" encoding="UTF-8"?>
<InstantiateVAppTemplateParams
xmlns="http://www.vmware.com/vcloud/v1.5"
name="$TEMPLATE_NAME"
deploy="true"
powerOn="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1">
<Description>$TEMPLATE_DESCRIPTION</Description>
<Source
href="$SOURCE_TEMPLATE" />
</InstantiateVAppTemplateParams>
Now I'm frustrated because I can't build parameters for API to consume it and create vApp with customized VM.
I found information about InstantiationParamsType (link below)
https://code.vmware.com/apis/442/vcloud-director/doc/doc/types/InstantiationParamsType.html
But I can`t build them properly to retrieve normal response instead of BAD_REQUEST.
Thanks in advance.
P.S. I`m using vCloudDirector API 9.5

Ok, issue was that I coppied VirtualHardwareSection from VMWare API guide which was in PDF, which broke my encoding.
After that I found guide for service providers (link below)
https://code.vmware.com/docs/6899/vcloud-api-programming-guide-for-service-providers/doc/GUID-BF9B790D-512E-4EA1-99E8-6826D4B8E6DC.html
And after taking xml-snippet from there everything worked as was expected from documentation.

Related

How to access a server file from PyScript?

I have a PyScript running on the home.html page of a website, and within the script I'd like to read some information from a file stored in same directory as the home.html page but I always get error "Host is unreachable".
I expect to be able to read information from a file stored in same directory as my home.html page containing the script.
I am trying the following:
url='<my file full URL here>'
req = urllib.request.Request(url=url)
response = urllib.request.urlopen(req,timeout=120)
data=response.read().decode('utf-8')
PyScript doesn't play well (actually, doesn't play at all) with most existing Python libraries that handle HTTP requests (requests, httpx, urllib). Take a look at the PyScript documentation on HTTP requests here for guidance. It's a great walk-through on making HTTP requests in PyScript using pyfetch, a Python wrapper of the JavaScript fetch api.
One quick warning about the documentation. Like PyScript itself, the documentation is a work in progress. In the link above, there's a reference to the py-env tag. That has been deprecated and it doesn't look like they've updated that part of the documentation. The functions of the py-env tag have been subsumed in the py-config tag. More on that here.
UPDATE:
As a framework under development, PyScript is going to be a moving target for a while. Specific to your case, the documentation on http-requests (How to make HTTP requests using PyScript) was actually updated just this morning (11/8/2022). I'll refer you to that page for the code. One very important note, however. The code examples are written as though they are being run in an updated local development environment. When you point to the remote PyScript version to use, it matters which one you select. Your code points to <link rel="stylesheet" href="https://pyscript.net/latest/pyscript.css" />
, which is perfectly reasonable -- it is, after all, the suggested release. The code example in the documentation, however, will not work with 'latest'. It will, however, work with 'unstable' (<link rel="stylesheet" href="https://pyscript.net/unstable/pyscript.css" />). When running this code using the 'unstable' release, it also appears that you have to run it in a live server. The point is workable solutions are going to be hit and miss for a while. What works today may not work next week.

GAE not loading properties file

I have created an app-engine app where in I am loading properties files using Spring based configuration and using it in as "${app.id}". When I run my app, all properties are getting loaded properly and my program works like charm but when I deploy the same application in Google App-Engine, I noticed that properties are not getting loaded and am getting null pointer exception. Does anyone has any pointer for this issue. I have googled a lot but not getting any correct solutions. Thanks !!
Use the following in your applicationContext.xml
<context:property-placeholder location="classpath:/test.properties" />

What is the best way to update an angular application?

Our team is constantly working on an angular application, and every week or 2 we update it with new features or correct some bugs that came out.
We are using a C# backend with webservices.
QUESTION: When we update the application on the server, we sometimes (this doesn't happen all the time) get the problem that user is still seeing the old HTML and functionalities. What is the way to solve this?
I didn't find this on google, maybe I'm not looking for the right terms,
any help is appreciated.
Users have to clear their cache to get the new version of the application.
What you are seeing are cached copies of the JS files (possibly HTML partials too).
When the browser parses the HTML page, it makes the request for getting the JS resource and looks at various information before deciding to retrieve either the cached copy (if any) or whether to query the server again.
You can find some extra details on the Google fundamentals on HTTP caching
A solution I have been adopting myself is to set the cache headers to cache the file for a very long period, and then use tools in the build to version the file either on the filename or with a request parameter.
I have used grunt-cache-breaker and found it to serve well for this purpose. I know there is a gulp equivalent too
The most common way to make sure cached versions of your javascript aren't used is adding the version as a parameter in the reference to the script like so:
<script src="/app.js?v=v1.0"></script>

Thinktecture IdentityServer V3 - Data is not binding and resources are not loading

I've recently created an Web API that I'd like secured by Thinktecture's IdentityServer V3. I imported the package from nuget, and was able to hit the token endpoints to create a token. However, I noticed that the bootstrap css would not load on IS's main page:
This is how it appears i.imgur.com/DftMQ7C.png vs https:/demo.getidentityserver.com
It didn't bother me until I started using the views (and not just the endpoints) where my pages would print the variable names and function incorrectly with the resources not loading properly. Like so.
Of course, I can not log in since it redirects me the literal "loginUrl" page. I've tried reverting to the previous version 1.2.1, but I still have the same issue. Alternatively, I've looked at samples and those don't have the same issue at all, so I'm wondering if there's a config in my API project that may be causing this.
Has anyone encountered this problem or know of a potential fix?
Be sure to read through the documentation thoroughly, guys. Lesson learned. I just needed to add RAMMFAR to my web.config "otherwise some of the embedded assets will not be loaded correctly by IIS"
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
</system.webServer>

Loading Facelets templates from database

In my application (CMS for internal purposes) I'm facing the problem how to serve pages stored in the database with dynamic URL (e.g. http://example.com/page3) using the JSF. Generally, let's say I want to grab the page content from the database, put it inside jsf file and serve it as /page3. Is there any way how to obtain the request URL from JSF, search the database for the article (instead of searching *xhtml in the WAR), build dynamically the JSF XHML file and return it to JSF as InputStream for example? I've found this answed by Thomas Maerz, but it failed with
Unable to create a new instance of 'com.test.CustomResourceResolver': java.lang.InstantiationException: com.test.CustomResourceResolver
on my glassfish v4 (Mojarra 2.2), and I also found that ResourceResolver is deprecated in JSF2.2.
I've googled a lot, but this seems to be not very common/documented part of JSF.
Thank you for any help.
I did not understand fully the problem, but for url change you can use prettyfaces, for dynamic forms you can use primefaces ext and I am not suggest keep form in the database, if I know your target I can suggest more useful answer.

Resources