Packer: Sample file for Openstack - openstack

Can someone please provide me with a sample file for Packer creating OS image? I have this one:
{
"builders": [{
"type": "openstack",
"ssh_username": "ubuntu",
"tenant_name": "mytenant",
"flavor": "m1.tiny",
"identity_endpoint": "http://1.2.3.4:5000/",
"availability_zone": "az1",
"source_image": "Ubuntu 16.04 With Proxy",
"image_name": "Ubuntu 16.04 With Proxy and Python"
}],
"provisioners": [
{
"type": "shell",
"script": "python.sh"
}
]
}
but OS always returns:
==> openstack: Error launching source server: Invalid request due to incorrect syntax or missing required parameters.
I have no idea what I am missing.
Of course i have correct OS_ env values preset for my Nova API.

You have to use source_image_name or use the ID to reference the image
From the docs:
source_image (string) - The ID or full URL to the base image to use. This is the image that will be used to launch a new server and provision it. Unless you specify completely custom SSH settings, the source image must have cloud-init installed so that the keypair gets assigned properly.
source_image_name (string) - The name of the base image to use. This is an alternative way of providing source_image and only either of them can be specified.
See source_image

Related

how to boot from iso in openstack horizon

I'm trying to use horzon web page to build an instance from an ISO image, but it appears to show no disk in centos install configuration. while i choose to create new volume.
the general flow like below:
The test openstack invironment is built with devstack on the latest branch. I upload with a centos iso downloaded from http://mirrors.163.com/centos/7.6.1810/isos/x86_64/, i followed the original workflow provided by horizon. But it seems failed.
webpage send follow data to horizon server
{
"availability_zone":"nova",
"config_drive":false,
"user_data":"",
"disk_config":"AUTO",
"instance_count":1,
"name":"vm_boot_from_iso",
"scheduler_hints":{
},
"security_groups":[
"09f6bebe-3015-438d-8b4c-2d10b5d5998b"
],
"create_volume_default":true,
"hide_create_volume":false,
"source_id":null,
"block_device_mapping_v2":[
{
"source_type":"image",
"destination_type":"volume",
"delete_on_termination":true,
"uuid":"0e49cc7a-593c-4a62-a05f-bdef63157d22",
"boot_index":"0",
"volume_size":10
}
],
"flavor_id":"d2",
"nics":[
{
"net-id":"f9796914-00b5-4dfe-a7fa-4b2c1641d037",
"v4-fixed-ip":""
}
],
"key_name":null
}
I was expecting through the installation i could find the disk provided by the workflow.

How can I use mesos-execute to run a jar

I have set up my mesos cluser correctly with one master and two slaves. What I am trying to do is use the mesos-execute framework to run jar files on the cluster. I can use it to run simple commands like:
mesos-execute --master=mesosr:5050 --name="simple-test" --command=echo "hello"
Which will run as expected. However if I try to replace that echo "hello" command with something like "java -jar helloWorld.jar" it won't work.
I managed to identify the problem, but I don't know how to fix it. The issue is that the command doesn't run from the home directory, it runs from something similar to this
/var/lib/mesos/slaves/3f5439b1-7fab-45d6-876e-7e75b7c15fc9-S0/frameworks/3f5439b1-7fab-45d6-876e-7e75b7c15fc9-0043/executors/java-test/runs/7c20baff-080f-48ee-95fc-3662c388744b
I got that path by running "pwd" as a command on mesos-execute.
Now, my question is how do I get out from there? cd doesn't work.
Is there any way for me to get to the home folder or to a special folder where I can put my jars to make them accessible to mesos-execute?
The use case for this application is that there will be a lot of small jar files that will have to be run on the cluster. They don't have to stay alive, so I am not using anything like Marathon for these jars.
Thank you.
From mesos-execute -h
--task_group=VALUE The value could be a JSON-formatted string of TaskGroupInfo or a file path containing the JSON-formatted TaskGroupInfo. Path must be of the form file:///path/to/file or /path/to/file. See the TaskGroupInfo message in mesos.proto for the expected format. NOTE: agent_id need not to be set.
Example:
{
"tasks":
[
{
"name": "Name of the task",
"task_id": {"value" : "Id of the task"},
"agent_id": {"value" : ""},
"resources": [{
"name": "cpus",
"type": "SCALAR",
"scalar": {
"value": 0.1
}
},
{
"name": "mem",
"type": "SCALAR",
"scalar": {
"value": 32
}
}],
"command": {
"value": "sleep 1000"
}
}
]
}
What interest you most is command part. There you can define your task with all files it need to download to run correctly. All possible configuration options for command are specified in CommandInfo.
Ok, so I figured out how to do it.
I was going about it all wrong, perhaps not the best idea to tackle a new thing at the end of a workday.
What I was trying to do was change directory to the home directory as part of the mesos-execute command. This is not allowed. The way to run a jar that is located in the home directory is to specify the path of the jar in the java -jar command. So the final command, that works, looks like this:
mesos-execute --master=mesosr:5050 --name="simple-test" --command="java -jar /home/user/jarFile.jar"
This works, and the jar is executed on the cluster.

How to use complex-number of kairosdb from REST

I am checking if I can use kairosdb for my project. I was checking out the REST api's and I have a use case where I need to save both my device state and status (state tells if device is on or off and status tells if my device is occupied or empty)
kairosdb version: 1.1.1
I came across this link https://kairosdb.github.io/docs/build/html/restapi/AddDataPoints.html
but when I try to post data from REST client I am getting the error 400 BAD Request error. The error is
{"errors":["Unregistered data point type 'complex-number'"]}
My request I am posting is ,
{
"name": "device_data",
"type": "complex-number",
"datapoints": [
[
1470897496,
{
"state": 0,
"status": "empty"
}
]
],
"tags": {
"device_id": "abc123"
}
}
In tried doing the same in Java as specified in https://kairosdb.github.io/docs/build/html/kairosdevelopment/CustomData.html
I get the same error i
Please let me know how to use complex-numbers or custom data types from REST
Recently, I figured out how to use this.
Using the example from the official document of KairosDB.
create 2 files called ComplexDataPoint.java and ComplexDataPointFactory.java and then paste the code provided by the tutorial on the doc: https://kairosdb.github.io/docs/build/html/kairosdevelopment/CustomData.html#example-for-creating-custom-types
download the KairosDB source, then extract the .zip file.
paste the 2 files in /KAIROSDB_DOWNLOADED_SOURCE/src/main/java/org/kairosdb/core/datapoints/
configure the CoreModule.java at /KAIROSDB_DOWNLOADED_SOURCE/src/main/java/org/kairosdb/core/, add the following line in the function protected void configure():
bind(ComplexDataPointFactory.class).in(Singleton.class);
open terminal, cd to KAIROSDB_DOWNLOADED_SOURCE/, then follow the instruction in the file how_to_build.txt
when complete, it will create a folder called build, the compiled kairosdb jar file is located in KAIROSDB_DOWNLOADED_SOURCE/build/jar
in your kairosdb installation folder, backup the kairosdb-X.X.X.jar file in YOUR_KAIROSDB_INSTALLATION/lib
mv kairosdb-X.X.X.jar kairosdb-X.X.X.jar.backup
mv the newly compiled jar file to YOUR_KAIROSDB_INSTALLATION/lib
modify the configuration file by adding the following line:
kairosdb.datapoints.factory.complex=org.kairosdb.core.datapoints.ComplexDataPointFactory
restart your kairosdb
For your query, since the registered name is kairosdb.datapoints.factory.complex, replace complex-number with complex in your query string.
Hope this will help you! I am now having a problem to plot the complex data. I am still figuring out...

retrieve artifact with maven timestamp from artifactory

Is there a way to retrieve an artifact with the maven timestamp as it was originally uploaded by maven?
from jenkins logs:
Uploading: http://artifactory.foo/artifactory/libs-snapshot-local/com/foo/foo-web-service/1.16.0-SNAPSHOT/foo-web-service-1.16.0-20160504.182015-2.tar.gz
Results from artifactory REST api:
$ curl -X GET 'http://artifactory.foo/artifactory/api/search/gavc?g=com.foo&a=foo-web-service&v=1.16.0-SNAPSHOT&c=*&repos=libs-snapshot-local'
{
"results" : [ {
"uri" : "http://artifactory.foo/artifactory/api/storage/libs-snapshot-local/com/foo/foo-web-service/1.16.0-SNAPSHOT/foo-web-service-1.16.0-SNAPSHOT-sources.jar"
}, {
"uri" : "http://artifactory.foo/artifactory/api/storage/libs-snapshot-local/com/foo/foo-web-service/1.16.0-SNAPSHOT/foo-web-service-1.16.0-SNAPSHOT.pom"
}, {
"uri" : "http://artifactory.foo/artifactory/api/storage/libs-snapshot-local/com/foo/foo-web-service/1.16.0-SNAPSHOT/foo-web-service-1.16.0-SNAPSHOT.tar.gz"
}, {
"uri" : "http://artifactory.foo/artifactory/api/storage/libs-snapshot-local/com/foo/foo-web-service/1.16.0-SNAPSHOT/foo-web-service-1.16.0-SNAPSHOT.war"
} ]
}
I'd like to get the the same name as it was uploaded to via a wget or equivalent...
What I want to acheive:
jenkins uploads foo-web-service-1.16.0-20160504.182015-2.tar.gz to libs-snapshot-local
query REST api to get latest artifact link that includes the timestamps in the name with parameters a=foo-web-service&version=1.16.0&...
wget $artifact_link_with_timestamp
What I currently acheive that does not satisfy my need:
jenkins uploads foo-web-service-1.16.0-20160504.182015-2.tar.gz to libs-snapshot-local
query REST api via gavc search with parameters a=foo-web-service&version=1.16.0&...
wget $artifact_link
Conclusion as stated in the accepted answer, the problem was in the artifactory config itself. To achieve what I wanted, I needed the snapshots to be unique.
As long as your repository is configured to use unique snapshots (or to use client snapshot policy and you use Maven 3 and up), you can always use the Maven timestamp as a version. Replacing it with -SNAPSHOT is a "runtime" trick to make the resolution easier.
If your repository is configured to use non-unique snapshots, the files are actually stored with -SNAPSHOT instead of version and override previous snapshots (don't do that).

Meteor app doesn't appear in browser after deployment with mup

I'm facing strange issue - I deployed my Meteor app with mup ( followed this instruction: https://www.vultr.com/docs/deploy-a-meteor-application-on-ubuntu ). Everything went successfully (see screenshot).
However the content doesn't appear when I try to access it via browser (I type IP-address).
As a server I use apache2 on Ubuntu 15.04, and mup.json as following:
{
// Server authentication info
"servers": [
{
"host": "IP_ADDRESS",
"username": "developer"
//"password": "password"
// or pem file (ssh based authentication)
//"pem": "~/.ssh/id_rsa"
}
],
// Install MongoDB in the server, does not destroy local MongoDB on future setup
"setupMongo": false,
// WARNING: Node.js is required! Only skip if you already have Node.js installed on server.
"setupNode": true,
// WARNING: If nodeVersion omitted will setup 0.10.36 by default. Do not use v, only version number.
"nodeVersion": "0.10.36",
// Install PhantomJS in the server
"setupPhantom": true,
// Show a progress bar during the upload of the bundle to the server.
// Might cause an error in some rare cases if set to true, for instance in Shippable CI
"enableUploadProgressBar": true,
// Application name (No spaces)
"appName": "meteor",
// Location of app (local directory)
"app": "~/app",
// Configure environment
"env": {
"PORT": 80,
"UPSTART_UID": "meteoruser",
"ROOT_URL": "http://IP_ADDRESS",//and I also tried http://localhost
//"MONGO_URL": "",
"METEOR_ENV": "production"
},
// Meteor Up checks if the app comes online just after the deployment
// before mup checks that, it will wait for no. of seconds configured below
"deployCheckWaitTime": 15
}
I would appreciate any help! Thanks in advance!
UPD: I made a better research and found a great tutorial - https://www.phusionpassenger.com/library/walkthroughs/deploy/meteor/ownserver/apache/oss/vivid/deploy_app.html . So, if anyone else curious about how to deploy Meteor app, please have a look :)

Resources