Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
951829c
Initial commit
johnelse Mar 4, 2013
333d600
Remove the almost-redundant inventory_globs.ml
johnelse Mar 5, 2013
a6ed115
Update OASIS
johnelse Mar 5, 2013
d27dc1e
Add README.md
johnelse Mar 5, 2013
39f70ec
Remove dependency on FHS
Mar 21, 2013
6492ba8
Remove dependency on uuid library
Mar 21, 2013
d701513
Remove dependence on log library
Mar 21, 2013
273a1f3
Use obuild rather than oasis
Mar 21, 2013
4da99f1
Introduce a configure script
May 16, 2013
086f3c1
Add standard files.
Jun 5, 2013
55ec27b
Merge pull request #1 from djs55/first-release
djs55 Jun 5, 2013
de8f4d9
Add Dave to maintainers file.
Jul 24, 2013
29f4382
Switch to a compiled configure script
Sep 10, 2013
40d32f1
'make' by itself should build the library, not the configure program
Sep 10, 2013
c6d25f3
s/Stringext/Xstringext/
jonludlam May 7, 2014
2f79954
Merge pull request #2 from jonludlam/great_stringext_rename
May 12, 2014
13735de
Add configurable idle timeout to stunnel
akshayramani May 22, 2014
0200f5a
Merge pull request #3 from akshayramani/SCTX-1665.f
thomassa May 30, 2014
b63b038
Oasisify. Ossify? No, that's not quite right...
jonludlam Jun 3, 2014
ab85988
Remove obuild file
jonludlam Jun 3, 2014
2d08cdd
Merge pull request #4 from jonludlam/oasisify
Jun 4, 2014
5659c00
Fix up the oasis specification to include the autogenerated ml file
jonludlam Jun 4, 2014
d0ac097
Merge pull request #5 from jonludlam/fix-oasis
Jun 4, 2014
75d3fc6
CP-12512 New key _stunnel_legacy "STUNNEL_LEGACY"
thomassa Jul 2, 2015
a63afc2
Merge pull request #6 from thomassa/sslinventory
euanh Jul 8, 2015
e1992e5
Use packed Stdext
jonludlam May 20, 2016
27c37e2
Add opam, and remove autogenerated stuff
jonludlam Jun 22, 2016
82e61f9
Merge pull request #7 from jonludlam/smapiv3
johnelse Jun 22, 2016
647ae5e
s/1.0.0/1.0.1/ - 1.0.0 had already been released
jonludlam Jun 22, 2016
f817297
Merge pull request #8 from jonludlam/version-mixup
johnelse Jun 22, 2016
f57843a
Add Make rule for setup.ml
johnelse Jun 28, 2016
aea3ebf
Add .travis.yml
johnelse Jul 5, 2016
fab265e
Merge pull request #9 from johnelse/fix-makefile
johnelse Jul 5, 2016
2e7192e
git: Add metadata to the result of `git archive`
euanh Nov 7, 2016
300b49a
Bump version to 1.0.2
lindig Feb 3, 2017
aa6f8dc
Merge pull request #10 from lindig/master
mseri Feb 3, 2017
7745680
Sync opam file with xs-opam
gaborigloi Jun 9, 2017
cecd1f6
Merge pull request #11 from gaborigloi/sync_opam
mseri Jun 9, 2017
c1650dd
CA-276606: Ported build from _oasis to jbuilder.
Dec 13, 2017
ff95604
Replace xapi-stdext with xapi-stdext-subpackages and astring.
Dec 14, 2017
fc0653a
Reindentation and file mode change.
Dec 14, 2017
ed9ceb2
Merge pull request #12 from kc284/master
mseri Dec 14, 2017
28a120f
inventory: preserve old ~limit:2 semantic
Jan 9, 2018
6c2270c
Merge pull request #13 from mseri/master
mseri Jan 9, 2018
200c85d
Ported build to dune and deprecated the old package xcp-inventory.
Nov 22, 2018
98f2dc9
Removed conflict between xcp-inventory and xapi-inventory.
Nov 28, 2018
5403f31
Merge pull request #15 from kc284/master
lindig Dec 3, 2018
075e03f
maintenance: fix travis
Mar 2, 2020
a2ae295
maintenance: use dune instead of jbuilder
Mar 2, 2020
be8eea8
maintenance: change default filename to /etc/xensource-inventory
Mar 2, 2020
94c30ea
Merge pull request #16 from lippirk/master
Mar 5, 2020
623348b
maintenance: clean up opam metadata
psafont Jul 28, 2021
82313e8
Merge pull request #17 from xapi-project/nourl
Jul 28, 2021
b913ef4
Add license to opam metadata
psafont Feb 17, 2022
ef3a1f2
Merge pull request #18 from psafont/license
psafont Feb 18, 2022
5a86e84
maintenance: Decrease direct usages of Threadext
psafont Mar 30, 2022
cf2953c
Merge pull request #19 from xapi-project/threading
robhoes Apr 5, 2022
7461b57
maintenance: prepare for release
psafont Jun 17, 2022
26e78d6
Merge pull request #20 from psafont/release
psafont Jun 17, 2022
ac3055c
Add 'ocaml/libs/xapi-inventory/' from commit '26e78d63c9462d86bc79865…
edwintorok Jan 22, 2024
87360d5
[maintenance]: make format
edwintorok Jan 22, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ install: build doc sdk doc-json
gzip http-lib pciutil sexpr stunnel uuid xml-light2 zstd xapi-compression safe-resources \
message-switch message-switch-async message-switch-cli message-switch-core message-switch-lwt \
message-switch-unix xapi-idl forkexec xapi-forkexecd xapi-storage xapi-storage-script xapi-storage-cli \
xapi-nbd varstored-guard xapi-log xapi-open-uri xapi-tracing xapi-expiry-alerts cohttp-posix
xapi-nbd varstored-guard xapi-log xapi-open-uri xapi-tracing xapi-expiry-alerts cohttp-posix xapi-inventory
# docs
mkdir -p $(DESTDIR)$(DOCDIR)
cp -r $(XAPIDOC)/jekyll $(DESTDIR)$(DOCDIR)
Expand All @@ -264,7 +264,7 @@ uninstall:
gzip http-lib pciutil sexpr stunnel uuid xml-light2 zstd xapi-compression safe-resources \
message-switch message-switch-async message-switch-cli message-switch-core message-switch-lwt \
message-switch-unix xapi-idl forkexec xapi-forkexecd xapi-storage xapi-storage-script xapi-log \
xapi-open-uri xapi-tracing xapi-expiry-alerts cohttp-posix
xapi-open-uri xapi-tracing xapi-expiry-alerts cohttp-posix xapi-inventory

compile_flags.txt: Makefile
(ocamlc -config-var ocamlc_cflags;\
Expand Down
2 changes: 2 additions & 0 deletions ocaml/libs/xapi-inventory/.gitarchive-info
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Changeset: $Format:%H$
Commit date: $Format:%cD$
1 change: 1 addition & 0 deletions ocaml/libs/xapi-inventory/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.gitarchive-info export-subst
7 changes: 7 additions & 0 deletions ocaml/libs/xapi-inventory/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
_build/
*.install
.merlin

*.orig
*.rej
xcp_inventory_config.ml
12 changes: 12 additions & 0 deletions ocaml/libs/xapi-inventory/.travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
language: c
service: docker
install:
- wget https://raw.githubusercontent.com/ocaml/ocaml-ci-scripts/master/.travis-docker.sh
- wget https://raw.githubusercontent.com/xapi-project/xs-opam/master/tools/xs-opam-ci.env
- source xs-opam-ci.env
script: bash -ex .travis-docker.sh
env:
global:
- PACKAGE=xapi-inventory
jobs:
- PINS="xapi-inventory:."
36 changes: 36 additions & 0 deletions ocaml/libs/xapi-inventory/ChangeLog
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
## v1.2.3 (17 Jun 2022):
* maintenance: Decrease direct usages of Threadext
* Add license to opam metadata

## v1.2.2 (28 Jul 2021):
* maintenance: clean up opam metadata
* maintenance: change default filename to /etc/xensource-inventory
* maintenance: use dune instead of jbuilder
* maintenance: fix travis

## v1.2.1 (3 Dec 2018):
- Removed conflict between xcp-inventory and xapi-inventory.
- Ported build to dune and deprecated the old package xcp-inventory.

## v1.2.0 (9 Jan 2018):
* inventory: preserve old ~limit:2 semantic

## v1.1.0 (14 Dec 2017):
* Reindentation and file mode change.
* Replace xapi-stdext with xapi-stdext-subpackages and astring.
* CA-276606: Ported build from _oasis to jbuilder.
* Sync opam file with xs-opam

## v1.0.2 (03 Febr 2017):
* fix Makfile to make installation via Opam work
* add Git meta data files .gitarchive-info and .gitattributes

## v1.0.1 (22 Jun 2016):
* Update to Stdext 2.0.0

## v0.9.1 (3 Jun 2014):
* second public release
* Update to cohttp-0.11.2 interface

## v0.9.0 (5 Jun 2013):
* first public release
6 changes: 6 additions & 0 deletions ocaml/libs/xapi-inventory/INSTALL
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
The easiest way to install this package is via opam:

opam init
opam remote add xen-org git://github.com/xen-org/opam-repo-dev
opam install xcp-inventory

521 changes: 521 additions & 0 deletions ocaml/libs/xapi-inventory/LICENSE

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions ocaml/libs/xapi-inventory/MAINTAINERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
How to submit changes to this project
=====================================

Please submit changes as pull requests to the repository on github.
Please ensure that all changes have descriptive commit comments and
include a Signed-off-by: line.

Maintainers list
----------------

* Jonathan Ludlam <jonathan.ludlam@eu.citrix.com>
* Dave Scott <david.scott@eu.citrix.com>

4 changes: 4 additions & 0 deletions ocaml/libs/xapi-inventory/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# The XCP inventory library

Maintains a database of key-value pairs at a specific location in the
filesystem.
12 changes: 12 additions & 0 deletions ocaml/libs/xapi-inventory/lib/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
(library
(name inventory)
(public_name xapi-inventory)
(wrapped false)
(libraries
uuidm
astring
xapi-stdext-unix
xapi-stdext-threads
threads
)
)
147 changes: 147 additions & 0 deletions ocaml/libs/xapi-inventory/lib/inventory.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
(*
* Copyright (C) 2006-2010 Citrix Systems Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation; version 2.1 only. with the special
* exception on linking described in file LICENSE.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*)
(* Code to parse the XenSource inventory file *)

open Xapi_stdext_unix
module M = Xapi_stdext_threads.Threadext.Mutex

let inventory_filename = ref "/etc/xensource-inventory"

(* Keys which must exist: *)
let _installation_uuid = "INSTALLATION_UUID"

let _control_domain_uuid = "CONTROL_DOMAIN_UUID"

let _management_interface = "MANAGEMENT_INTERFACE"

let _management_address_type = "MANAGEMENT_ADDRESS_TYPE"

let _build_number = "BUILD_NUMBER"

(* Optional keys: *)
let _current_interfaces = "CURRENT_INTERFACES"

let _oem_manufacturer = "OEM_MANUFACTURER"

let _oem_model = "OEM_MODEL"

let _oem_build_number = "OEM_BUILD_NUMBER"

let _machine_serial_number = "MACHINE_SERIAL_NUMBER"

let _machine_serial_name = "MACHINE_SERIAL_NAME"

let _stunnel_idle_timeout = "STUNNEL_IDLE_TIMEOUT"

let _stunnel_legacy = "STUNNEL_LEGACY"

let loaded_inventory = ref false

let inventory = Hashtbl.create 10

let inventory_m = Mutex.create ()

(* Compute the minimum necessary inventory file contents *)
let minimum_default_entries () =
let host_uuid = Uuidm.to_string (Uuidm.create `V4) in
let dom0_uuid = Uuidm.to_string (Uuidm.create `V4) in
[
(_installation_uuid, host_uuid)
; (_control_domain_uuid, dom0_uuid)
; (_management_interface, "")
; (_management_address_type, "IPv4")
; (_build_number, "0")
]

(* trim any quotes off the ends *)
let strip_quotes v =
if String.length v >= 2 && v.[0] = '\'' && v.[String.length v - 1] = '\'' then
String.sub v 1 (String.length v - 2)
else
v

let parse_inventory_entry line =
match Astring.String.cut ~sep:"=" line with
| Some (k, v) ->
(* trim whitespace *)
Some (k, v |> strip_quotes |> String.trim)
| None ->
None

let string_of_table h =
let lines =
List.fold_left
(fun acc (k, v) -> Printf.sprintf "%s='%s'\n" k v :: acc)
[] h
in
String.concat "" lines

let read_inventory_contents () =
if not (Sys.file_exists !inventory_filename) then
Unixext.write_string_to_file !inventory_filename
(string_of_table (minimum_default_entries ())) ;
(* Perhaps we should blank the old inventory before we read the new one?
What is the desired behaviour? *)
Unixext.file_lines_iter
(fun line ->
match parse_inventory_entry line with
| Some (k, v) ->
Hashtbl.add inventory k v
| None ->
()
)
!inventory_filename ;
loaded_inventory := true

let read_inventory () = M.execute inventory_m read_inventory_contents

let reread_inventory () =
M.execute inventory_m (fun () ->
Hashtbl.clear inventory ; read_inventory_contents ()
)

exception Missing_inventory_key of string

let lookup ?default key =
M.execute inventory_m (fun () ->
if not !loaded_inventory then read_inventory_contents () ;
if Hashtbl.mem inventory key then
Hashtbl.find inventory key
else
match default with
| None ->
raise (Missing_inventory_key key)
| Some v ->
v
)

let flush_to_disk_locked () =
let h = Hashtbl.fold (fun k v acc -> (k, v) :: acc) inventory [] in
Unixext.write_string_to_file !inventory_filename (string_of_table h)

let update key value =
M.execute inventory_m (fun () ->
Hashtbl.clear inventory ;
read_inventory_contents () ;
Hashtbl.replace inventory key value ;
flush_to_disk_locked ()
)

let remove key =
M.execute inventory_m (fun () ->
Hashtbl.clear inventory ;
read_inventory_contents () ;
Hashtbl.remove inventory key ;
flush_to_disk_locked ()
)
2 changes: 1 addition & 1 deletion quality-gate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ verify-cert () {
}

mli-files () {
N=519
N=520
# do not count ml files from the tests in ocaml/{tests/perftest/quicktest}
MLIS=$(git ls-files -- '**/*.mli' | grep -vE "ocaml/tests|ocaml/perftest|ocaml/quicktest" | xargs -I {} sh -c "echo {} | cut -f 1 -d '.'" \;)
MLS=$(git ls-files -- '**/*.ml' | grep -vE "ocaml/tests|ocaml/perftest|ocaml/quicktest" | xargs -I {} sh -c "echo {} | cut -f 1 -d '.'" \;)
Expand Down
28 changes: 28 additions & 0 deletions xapi-inventory.opam
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
opam-version: "2.0"
name: "xapi-inventory"
maintainer: "xen-api@lists.xen.org"
authors: "xen-api@lists.xen.org"
homepage: "https://github.com/xapi-project/xcp-inventory"
bug-reports: "https://github.com/xapi-project/xcp-inventory/issues"
dev-repo: "git+http://github.com/xapi-project/xcp-inventory.git"
license: "LGPL-2.1-only WITH OCaml-LGPL-linking-exception"
tags: [ "org:xapi-project" ]
build: [
["dune" "build" "-p" name "-j" jobs]
["dune" "runtest" "-p" name "-j" jobs] {with-test}
]
depends: [
"ocaml"
"ocamlfind" {build}
"dune" {build}
"base-threads"
"astring"
"xapi-stdext-unix"
"xapi-stdext-threads"
"cmdliner"
"uuidm"
]
synopsis: "Library for accessing the xapi toolstack inventory file"
description: """
The inventory file provides global host identify information
needed by multiple services."""