How to run Openstack-Swift java api? - openstack

I try to run Openstack-Swift java sdk sample.
I have swift and keystone project to use swift only.
I found this project : https://github.com/woorea/openstack-java-sdk
But, I don't know how to run this project in Window Eclipse.
Should I build all project(nova, etc..) in maven?
Do you know how to run this project or website that post run-way in regular sequence?

#stream
I have not tried Woorea but i know a lot many developers are using Jclouds, the link http://developer.rackspace.com/#home-sdks has well documented guide with example how to use the Java SDK.
Hope it helps.

looks like you can build SWIFT independently (part of woorea peoject)
as it states in the readme file here:
(com.woorea swift-client 3.0.0-SNAPSHOT)
https://github.com/woorea/openstack-java-sdk
the Maven artifact ID should be:
openstack-java-sdk
Here is a nice toturial that can be of hand:
https://github.com/woorea/openstack-java-sdk/wiki/Swift-Tutorial
it has the example for the java api for using SWIFT,
for example, this code snippet (more details in the link):
Properties properties = System.getProperties();
properties.put("verbose", "true");
properties.put("auth.credentials", "passwordCredentials");
properties.put("auth.username", "demo");
properties.put("auth.password", "secret0");
properties.put("auth.tenantName", "demo");
properties.put("identity.endpoint.publicURL","http://192.168.1.43:5000/v2.0");
OpenStackClient openstack = OpenStackClient.authenticate(properties);
AccountResource account = openstack.getStorageEndpoint();
account.container("hellocontainer").put();
account.container("hellocontainer").object("dir1").put();
account.container("hellocontainer").object("test1")
.put(new File("pom.xml"), new SwiftStorageObjectProperties() {{
setContentType("application/xml");
getCustomProperties().putAll(new HashMap<String, String>() {{
put("customkey.1", "customvalue.1");
}});
}});
List<SwiftStorageObject> objects = account.container("hellocontainer").get();
just keep in mind that when using openstack's API you will most likely need to authenticate (get tokens etc..) so that you will need the Keystone lib as well
www.programcreek.com/java-api-examples/index.php?api=com.woorea.openstack.keystone.Keystone
hope this helps.

Related

How do I add an Apps Script Library to AppMaker?

I created this script to determine if the Session.getScriptTimeZone() would draw the time zone from the library file rather than AppMaker. Here's the script:
function getFormattedDateString(dt,format){
var format=format||"E MMM dd, yyyy HH:mm";
var dt=dt||new Date();
return Utilities.formatDate(new Date(dt), Session.getScriptTimeZone(), format);
}
I tested it in another script with the following code:
function test(){
Logger.log(AMSLib.getFormattedDateString(new Date()));
}
I went into AppMaker and this dialog:
I've tried the Script ID from here:
I've also tried several deployment ID's from the publish from Manifest dialog and I keep getting the same answer:
I've also tried the Project Key which is used with other apps scripts to load libraries.
I don't know what to try next.
First things first, you need to publish your Apps Script app, after that it'll be assigned Script ID(by the way it can also be found in the published app URL). Once you have Script ID, you can specify it in App Maker and select library version you want to use:
To access library's functions you need to use name specified in the object setting:
// Server side library call
var result = MyLibraryName.doSomeCoolStuff();
App Maker should be smart enough and pickup all library's public functions for autocomplete.
Learn more:
https://developers.google.com/apps-script/guides/libraries
https://developers.google.com/appmaker/scripting/libraries
That's really odd to not have a script key there. You might make a copy of your script, something might be corrupted. You can also get the key from the URL ex: https://script.google.com/a/ignitesynergy.com/d/1oHnk_xl76KagGS4g7O2pC1MM4R3iZR8-7FlmzKXxRDtO1o5nDU2/edit
Remember to File-> Manage Versions and create a version. You also need to set the sharing to public.

spring boot/spring web app embedded version number

What are the strategies to embed a unique version number in a Spring application?
I've got an app using Spring Boot and Spring Web.
Its matured enough that I want to version it and see it displayed on screen at run time.
I believe what you are looking for is generating this version number during build time (Usually by build tools like Ant, Maven or Gradle) as part of their build task chain.
I believe a quite common approach is to either put the version number into the Manifest.mf of the produced JAR and then read it, or create a file that is part of the produced JAR that can be read by your application.
Another solution would be just using Spring Boot's banner customization options described here: http://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-spring-application.html#boot-features-banner
However, this will only allow you to change spring-boot banner.
I also believe that Spring Boot exposes product version that is set in Manifest.MF of your application. To achieve this you will need to make sure Implementation-Version attribute of the manifest is set.
Custom solution for access anywhere in the code
Lets assume you would like to have a version.properties file in your src/main/resources that contains your version information. It will contain placeholders instead of actual values so that these placeholders can be expanded during build time.
version=${prodVersion}
build=${prodBuild}
timestamp=${buildTimestamp}
Now that you have a file like this you need to fill it with actual data. I use Gradle so there I would make sure that processResources task which is automatically running for builds is expanding resources. Something like this should do the trick in the build.gradle file for Git-based code:
import org.codehaus.groovy.runtime.*
import org.eclipse.jgit.api.*
def getGitBranchCommit() {
try {
def git = Git.open(project.file(project.getRootProject().getProjectDir()));
def repo = git.getRepository();
def id = repo.resolve(repo.getFullBranch());
return id.abbreviate(7).name()
} catch (IOException ex) {
return "UNKNOWN"
}
}
processResources {
filesMatching("**/version.properties") {
expand (
"prodVersion": version,
"prodBuild": getGitBranchCommit(),
"buildTimestamp": DateGroovyMethods.format(new Date(), 'yyyy-MM-dd HH:mm')
)
}
}
processResources.outputs.upToDateWhen{ false }
In the code about the following is happening:
We defined a function that can take a build number out of the VCS
(in this case Git). The commit hash is limited to 7 characters.
We configure the processResources task to process
version.properties file and fill it with our variables.
prodVersion is taken from Gradle project version. It's usually set
as version in gradle.properties file (part of the general build
setup).
As a last step we ensure that it's always updated (Gradle
has some mechanics to detect if files ened to be processed
Considering you are on SVN, you will need to have a getSvnBranchCommit() method instead. You could for instance use SVNKit or similar for this.
The last thing that is missing now is reading of the file for use in your application.
This could be achieved by simply reading a classpath resource and parsing it into java.util.Properties. You could take it one step further and for instance create accessor methods specifically for each field, e.g getVersion(), getBuild(), etc.
Hope this helps a bit (even though may not be 100% applicable straight off)
Maven can be used to track the version number, e.g.:
<!-- pom.xml -->
<version>2.0.3</version>
Spring Boot can refer to the version, and expose it via REST using Actuator:
# application.properties
endpoints.info.enabled=true
info.app.version=#project.version#
Then use Ajax to render the version in the browser, for example using Polymer iron-ajax:
<!-- about-page.html -->
<iron-ajax auto url="/info" last-response="{{info}}"></iron-ajax>
Application version is: [[info.app.version]]
This will then show in the browser as:
Application version is: 2.0.3
I'm sure you've probably figured something out since this is an older question, but here's what I just did and it looks good. (Getting it into the banner requires you to duplicate a lot).
I'd recommend switching to git (it's a great SVN client too), and then using this in your build.gradle:
// https://github.com/n0mer/gradle-git-properties
plugins {
id "com.gorylenko.gradle-git-properties" version "1.4.17"
}
// http://docs.spring.io/spring-boot/docs/current/reference/html/deployment-install.html
springBoot {
buildInfo() // create META-INF/build-info.properties
}
bootRun.dependsOn = [assemble]
And this in your SpringBoot application:
#Resource
GitProperties props;
#Resource
BuildProperties props2;
Or this way to expose those properties into the standard spring environment:
#SpringBootApplication
#PropertySources({
#PropertySource("classpath:git.properties"),
#PropertySource("classpath:META-INF/build-info.properties")
})
public class MySpringBootApplication {
and then referencing the individual properties as needed.
#Value("${git.branch}")
String gitBranch;
#Value("${build.time}")
String buildTime;

Active Model Serializer not render my models

I am trying to integrate Active Model Serializer to render JSON elements with relations.
I follow the documentation on this address: http://rubydoc.info/gems/active_model_serializers
I am not sure if I am doing something wrong but it looks like serializers are not working. Do I need to make more steps?
I install the gem, generate the serializer and add relation.
Can you guide me, please??
My project is in this repo:
https://github.com/dwdsolutions/argo
Best Regards
You're using the 0.9.0 version. Try to change it to 0.8.0
Alex is right, I tried using v0.9.0 earlier and was unable to get it working per the existing documentation.
The main github repo does state to use v0.8.0 if you are familiar with the gem (https://github.com/rails-api/active_model_serializers/tree/master#maintenance-please-read). At any rate, once you get it working, you shouldn't need to manually specify your serializers since they're named properly compared to your models and controllers.
i.e. you can remove the trailing option of this line:
render json: #travel, serializer: TravelSerializer
And make it just:
render json: #travel

Adding TAG to EMR Cluster

I am launching emr cluster using Java API but not able to associate a tag to it. Pl can you help me on this.
Using EMR CLI, it is very easy as below but I have to do this using my Java code
./elastic-mapreduce --create --alive --tag tagKey=stackOverflow
If you need more details on this, pl let me know..
Thanks in advance.
Regards,
Vineet
In earlier versions of EMR Java SDK there wasn't a way to add tags(not a direct one for sure) to add tags, but in newer versions of the Java SDK for EMR, there is a method named addTags(Collection<Tag> tags), using which you can add tags to the resources(EC2) being launched as part of the EMR cluster.
You would use it as follows:
AWSCredentials credentials = new BasicAWSCredentials(accessKey, secretKey);
AmazonElasticMapReduce emr = new AmazonElasticMapReduceClient(credentials);
List<Tag> tags = new ArrayList<Tag>();
Tag stackOverflowTag = new Tag();
stackOverflowTag.setKey("stackOverflow");
tags.add(stackOverflowTag);
AddTagsRequest addTagsRequest = new AddTagsRequest();
addTagsRequest.setTags(tags);
emr.addTags(addTagsRequest);
StepFactory stepFactory = new StepFactory();
// set up the cluster to launch and add steps
RunJobFlowResult result = emr.runJobFlow(request);
Use com.amazonaws.services.elasticmapreduce.model.Tag class in order to create tags, as there are many Tag classes present in the SDK, and for a moment I had imported the wrong one as well.
Read the doc here.

How to enable route security when using AngularFire with Angular ui-router?

Is it possible to use theAngularFire routeSecurity module with angular UI-ROUTER instead of the standard ng-route provider? Is there a version of routeSecurity that would work with ui-router?
#mattvv Gave me this gist while I was talking on him in the angular irc channel. So essentially you would just need to replace the routesecurity.js file in angularfire directory assuming that you used yeoman to scaffold your application.
A neat thing to do is just to create another file named routesecurity-ui-router.js instead of replacing the content of the routesecurity.js.
So to give a little bit of information about the gist, basically mattvv just modified the routes term and use state instead.

Resources