Thursday, February 15, 2018

VMWare, vRealize and Docker

here some statements about vRealize Automarion (VRA) https://blogs.vmware.com/management/2017/07/container-management-vrealize-automation.html

This is the homepage:
https://www.vmware.com/products/vrealize-automation.html

You can quickly open a free account and start an online lab (again, FREE) of vRealize Automation

Hands-on Lab manual is available here http://docs.hol.vmware.com/

I have done the "HOL-1821-01-CMP vRealize Automation 7 - Getting Started"

There is even a course "HOL-1830-02-CNA vSphere Integrated Containers - Getting Started" available at https://www.vmware.com/go/try-vic-hol


This PDF is about VIC containers https://www.vmware.com/content/dam/digitalmarketing/vmware/en/pdf/solutionbrief/vmware-vic-developer-sandbox-use-case.pdf

Monday, February 12, 2018

Oracle XE DB running as Docker Container, and a freaky Docker error

https://hub.docker.com/r/sath89/oracle-xe-11g/

docker run -d -p 8080:8080 -p 1521:1521 sath89/oracle-xe-11g


Error response from daemon: updating the store state of sandbox failed: failed to update store for object type *libnetwork.sbState: json: cannot unmarshal string into Go struct field sbState.ExtDNS of type libnetwork.extDNSEntry.

it seems that the only way to solve it is:

sudo rm -rf /var/lib/docker

then reboot

I did so and it worked (but of course I have lost all my images and containers).

Scary.

Friday, February 9, 2018

screen : how to run long running linux commands who survive also a VDI crash

https://www.rackaid.com/blog/linux-screen-tutorial-and-how-to/

example:

screen
CTRL-A c (create new window)
top
CTRL-A c (create new window)
ls
CTRL-A n (next window)
You are now back in “top”


Restart VDI

Login again

screen –r (reattach)



With screen you can also open several terminal sessions from the same login, and tab through them with CTRL-A n


Monday, February 5, 2018

Maven version sorting with Java 8

You can easily sort versions in Maven using org.apache.maven.artifact.versioning.ComparableVersion :

pom.xml:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>org.pierre</groupId>
  <artifactId>mavensort</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <dependencies>
   <dependency>
    <groupId>org.apache.maven</groupId>
    <artifactId>maven-artifact</artifactId>
    <version>3.5.2</version>
   </dependency>
  </dependencies>
</project>

package mavensort;

import org.apache.maven.artifact.versioning.ComparableVersion;

public class Artifact implements Comparable<Artifact> {
 int id;
 String version;
 public int getId() {
  return id;
 }
 public void setId(int id) {
  this.id = id;
 }
 public String getVersion() {
  return version;
 }
 public void setVersion(String version) {
  this.version = version;
 }
 public Artifact(int id, String version) {
  super();
  this.id = id;
  this.version = version;
 }

 public int compareTo(Artifact o) {
  
  ComparableVersion cv1 = new ComparableVersion(version);
  ComparableVersion cv2 = new ComparableVersion(o.getVersion());
  int compareTo = cv1.compareTo(cv2);
  System.out.println("compareTo " + version + " " + o.getVersion() + " " + compareTo);
  return compareTo;
 }
 

}


package mavensort;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.function.Supplier;
import java.util.stream.Collectors;

import org.apache.maven.artifact.versioning.ComparableVersion;
import org.junit.Test;

public class ArtifactTest {

 @Test
 public void testSort() {
  String version1 = "1.2";
  ComparableVersion cv1 = new ComparableVersion(version1);
  String version2 = "1.12";
  ComparableVersion cv2 = new ComparableVersion(version2);
  assert(cv1.compareTo(cv2) < 0);

 }
 
 @Test
 public void testSortCollection() {
  Artifact a1 = new Artifact(1, "1.2");
  Artifact a2 = new Artifact(2, "1.12");
  Artifact a3 = new Artifact(3, "0.12");
  List<Artifact> list = Arrays.asList(a1, a2, a3);
  Supplier<List<Artifact>> supplier = () -> new ArrayList<Artifact>();
  List<Artifact> sortedList = list.stream().sorted().collect(Collectors.toCollection(supplier));
  sortedList.forEach(item -> System.out.println(item.version));
  
 }

}


The use of streams and Supplier just to sort a collection is voodoistic. One can simply code this:

Collections.sort(list);
list.forEach(item -> System.out.println(item.version));


You can use also an external comparator:

@Test
 public void testSortCollectionExternalComparator() {
  Artifact a1 = new Artifact(1, "1.2");
  Artifact a2 = new Artifact(2, "1.12");
  Artifact a3 = new Artifact(3, "0.12");
  List<Artifact> list = Arrays.asList(a1, a2, a3);
  list.sort(new ArtifactComparator());
  list.forEach(item -> System.out.println(item.version));
  
 }


public class ArtifactComparator implements Comparator<Artifact> {

 @Override
 public int compare(Artifact o1, Artifact o2) {
  ComparableVersion cv1 = new ComparableVersion(o1.getVersion());
  ComparableVersion cv2 = new ComparableVersion(o2.getVersion());
  int compareTo = cv1.compareTo(cv2);
  System.out.println("C2 compareTo " + o1.getVersion() + " " + o2.getVersion() + " " + compareTo);
  return compareTo;
 }

}




The external dependency is not necessary, you can simply copy the class https://raw.githubusercontent.com/apache/maven/master/maven-artifact/src/main/java/org/apache/maven/artifact/versioning/ComparableVersion.java into your project, luckily it has no other dependencies to other classes in the same package

Ref: https://www.geeksforgeeks.org/collections-sort-java-examples/ for comparators



Friday, February 2, 2018

Kerberos

https://en.wikipedia.org/wiki/Kerberos_(protocol)

https://access.redhat.com/documentation/en-us/red_hat_jboss_enterprise_application_platform/7.0/html/how_to_set_up_sso_with_kerberos/sso_with_kerberos_deeper_dive




https://en.wikipedia.org/wiki/Generic_Security_Services_Application_Program_Interface



KDC = Key Distribution Center

TGT = Ticket-Getting Ticket

AS = Authorization Server

ST = Service Ticket

TGS = Ticket Granting Service

SPN = Service Principal Name

1) AS-REQ / AS-REP : user logs in, using key in keytab file he authenticates in AS/KDC. AS/KDC checks if user exists in its DB. User gets a TGT (time limited)
2) user


Kerberos uses a keytab file https://kb.iu.edu/d/aumh