오픈 스택의 Glance(https://docs.openstack.org/glance/latest/contributor/architecture.html)를 사용하면 운영체제 템플릿 이미지를 등록할 수 있다. 이미지 등록, 삭제, 변경등을 api를 통해 진행할 수 있다. 




Glance API 서버를 통해 controller를 지나 Registry Layer에서 Glance DB를 사용하는 구조이다. 



출처 : https://docs.openstack.org/glance/latest/contributor/architecture.html




이미지 포맷은 https://docs.openstack.org/image-guide/image-formats.html에서 볼 수 있듯이 다양하다.


많은 이미지와 컨테이너 타입을 지원하고 있다. 표로 설명하는 문서(https://platform9.com/support/supported-image-types-and-file-formats/)는 다음과 같다.


Format TypeDescriptionSupported By Platform9? Our Comments
raw/imgAn unstructured disk image format; if you have a file without an extension it is possibly a raw format.Yes (given .raw, .img, .dat, .bin extensions)Common extensions .raw, .img, .dat, .bin
qcow2Supported by the QEMU emulator that can expand dynamically and supports Copy-on-WriteYesMost common file format used with Linux/KVM
vmdkCommon disk format supported by many common virtual machine monitorsYes (for VMware vSphere hypervisor)VMDK format is commonly associated with VMware
vdiSupported by VirtualBox virtual machine monitor and the QEMU emulatorNot recommended(Will be recognized, but may or may not work depending on driver availability)VirtualBox image files in practice may or may not work with Linux/KVM hypervisor. You might run into compatibility issues due to missing required virtualization drivers)
isoAn archive format for the data contents of an optical disc, such as CD-ROMYes
akiAn Amazon kernel imageNoAmazon image types are not popularly used with Linux/KVM
ariAn Amazon ramdisk imageNoAmazon image types are not popularly used with Linux/KVM
amiAn Amazon machine imageNoAmazon image types are not popularly used with Linux/KVM
vhdThe VHD disk format, a common disk format used by virtual machine monitors from VMware, Xen, Microsoft, VirtualBox, and others
No
 Not a popular image format




우분투 OS이미지를 생성하는 방법(아마도 구 버전이겠지만.) 대충 이렇다.

(출처 : http://lollyrock.com/articles/glance-image-create/)


glance image-create --name 'Ubuntu 14.04 LTS' \ --container-format bare \ --disk-format qcow2 \ --is-public true \ --copy-from http://uec-images.ubuntu.com/releases/14.04/release/ubuntu-14.04-server-cloudimg-amd64-disk1.img +------------------+--------------------------------------+ | Property | Value | +------------------+--------------------------------------+ | checksum | None | | container_format | bare | | created_at | 2014-04-02T13:16:20 | | deleted | False | | deleted_at | None | | disk_format | qcow2 | | id | aa5ab6de-e461-4330-136e-fb149802bdc0 | | is_public | True | | min_disk | 0 | | min_ram | 0 | | name | Ubuntu 14.04 LTS Beta 1 | | owner | 9ab2f1a7ca521eee9c8de5a14567d377 | | protected | False | | size | 261095936 | | status | queued | | updated_at | 2014-04-02T13:16:20 | +------------------+--------------------------------------+



glance 슬라이드 자료.


OpenStack Glance from Deepti Ramakrishna


Posted by '김용환'
,


scalameter(https://scalameter.github.io/)는 마이크로 벤치마킹 기능을 가진 툴이다.  JVM warm up 또는 GC 의 영향을 받아 속도 체크가 좀 틀릴 수 있다. 이를 좀 막고 측정할 수 있는 라이브러리를 알게 되었다.


slideshare에 관련 자료가 잘 설명되어 있다. 


ScalaMeter 2014 from Aleksandar Prokopec







sbt 설정에 다음 라이브러리를 추가한다.

"com.storm-enroute" %% "scalameter-core" % "0.7"

(!!! 0.6에는 라이브러리가 많이 없으니 최신 버전을 활용하는 것이 좋다)



sbt console을 사용해서 scalameter를 임포트한다.



scala> import org.scalameter._




jvm warm up 관련해서 메모리 초기화로 인해서 결과 값이 달라지지 않게 하니 적당히 잘 나온다.



scala> withWarmer(new Warmer.Default) measure { (0 until 100000).toArray }

res28: Double = 0.688856


scala> withWarmer(new Warmer.Default) measure { (0 until 100000).toArray }

res29: Double = 0.689882


scala> withWarmer(new Warmer.Default) measure { (0 until 100000).toArray }

res30: Double = 0.684432


scala> withWarmer(new Warmer.Default) measure { (0 until 100000).toArray }

res31: Double = 0.681093


scala> withWarmer(new Warmer.Default) measure { (0 until 100000).toArray }

res32: Double = 0.678273


scala> withWarmer(new Warmer.Default) measure { (0 until 100000).toArray }

res33: Double = 0.671677


scala> withWarmer(new Warmer.Default) measure { (0 until 100000).toArray }

res34: Double = 0.695395







메모리 정보도 확인할 수 있다.


scala> withMeasurer(new Measurer.MemoryFootprint) measure { (0 until 100000).toArray }

res9: Double = 399.656


scala> withMeasurer(new Measurer.MemoryFootprint) measure { (0 until 100000).toArray }

res10: Double = 400.016


scala> withMeasurer(new Measurer.MemoryFootprint) measure { (0 until 100000).toArray }

res11: Double = 399.656


scala> withMeasurer(new Measurer.MemoryFootprint) measure { (0 until 100000).toArray }

res12: Double = 400.016


scala> withMeasurer(new Measurer.MemoryFootprint) measure { (0 until 100000).toArray }

res13: Double = 399.656


scala> withMeasurer(new Measurer.MemoryFootprint) measure { (0 until 100000).toArray }

res14: Double = 399.656


scala> withMeasurer(new Measurer.MemoryFootprint) measure { (0 until 100000).toArray }

res15: Double = 400.016


scala> withMeasurer(new Measurer.MemoryFootprint) measure { (0 until 100000).toArray }

res16: Double = 399.656


scala> withMeasurer(new Measurer.MemoryFootprint) measure { (0 until 100000).toArray }

res17: Double = 397.08


scala> withMeasurer(new Measurer.MemoryFootprint) measure { (0 until 100000).toArray }

res18: Double = 400.016


scala> withMeasurer(new Measurer.MemoryFootprint) measure { (0 until 100000).toArray }

res19: Double = 399.656


scala> withMeasurer(new Measurer.MemoryFootprint) measure { (0 until 100000).toArray }

res20: Double = 400.016


scala> withMeasurer(new Measurer.MemoryFootprint) measure { (0 until 100000).toArray }

res21: Double = 397.568




GC 정보는 다음과 같이 테스트할 수 있다. 


scala>  withMeasurer(new Measurer.GarbageCollectionCycles, Aggregator.median[Int]) measure { (0 until 9999000).toArray }

res5: org.scalameter.Quantity[Int] = 2 #


scala>  withMeasurer(new Measurer.GarbageCollectionCycles, Aggregator.median[Int]) measure { (0 until 9999000).toArray }

res6: org.scalameter.Quantity[Int] = 2 #


scala>  withMeasurer(new Measurer.GarbageCollectionCycles, Aggregator.median[Int]) measure { (0 until 9999000).toArray }

res7: org.scalameter.Quantity[Int] = 2 #


scala>  withMeasurer(new Measurer.GarbageCollectionCycles, Aggregator.median[Int]) measure { (0 until 9999000).toArray }

res8: org.scalameter.Quantity[Int] = 2 #




관련 소스는 다음과 같다.


https://github.com/scalameter/scalameter/blob/master/scalameter-core/src/main/scala/org/scalameter/Measurer.scala


Posted by '김용환'
,


스칼라 콘솔에서 테스트하고 싶은 예제 코드가 있을 때 실행 라인이 아닌 

전체 예제 코드를 실행하고 싶을 때 :paste를 사용하면 된다. 



스칼라 콘솔(REPL)을 실행한다.


scala> 



:paste를 입력하고 엔터를 입력한다.


scala> :paste

// Entering paste mode (ctrl-D to finish)



그리고 코드를 입력 한 후 Ctrl+D 키를 함께 누른다. 

그러면 결과가 실행된다.



scala> :paste

// Entering paste mode (ctrl-D to finish)


  def max(xs: List[Int]): Int = xs match {

    case List() => throw new java.util.NoSuchElementException

    case x :: Nil => x

    case _ => val t: Int = max(xs.tail); if (t > xs.head) t else xs.head

  }


  val m = max(List(3,2,1,100))

  print(m)


// Exiting paste mode, now interpreting.


m: Int = 100

Posted by '김용환'
,