GithubHelp home page GithubHelp logo

pombredanne / libcrange Goto Github PK

View Code? Open in Web Editor NEW

This project forked from square/libcrange

0.0 1.0 0.0 686 KB

The libcrange cluster metadata library.

License: BSD 3-Clause "New" or "Revised" License

libcrange's Introduction

libcrange

A library for parsing and generating range expressions.

Description

A library for parsing and generating range expressions. libcrange for modules to add symbolic name lookup features as well as functions to retreive additional data.

##Requirements

Red Hat / Scientific / CentOS

  • apr apr-devel flex pcre pcre-devel sqlite sqlite-devel libyaml libyaml-devel perl-YAML-Syck perl perl-core perl-devel perl-libs python-devel

Ubuntu / Debian

  • libapr1 libapr1-dev flex libpcre3 libpcre3-dev sqlite3 libsqlite3-dev libsqlite3-0 libyaml-0-2 libyaml-dev libyaml-syck-perl perl-base libperl5.14 libperl-dev

Range Syntax

Simple ranges:

  • node1,node2,node3,node4 == node1..node4 == node1..4
  • node1000..1099 == node1000..99 # auto pads digits to the end of the range
  • 1..100 # numeric only ranges
  • foo1-2.domain.com == foo1.domain.com-foo2.domain.com # domain support
  • 209.131.40.1-209.131.40.255 == 209.131.40.1-255 # IP ranges

Clusters:

A cluster is a way to store node membership into groups. Depending on your backend module how this is stored may vary. In the case of the YAML module, a cluster is defined by the membership of the CLUSTER key

  • %cluster101 == nodes defined in /var/range/cluster101.yaml - Default key CLUSTER
  • %cluster101:ALL or %cluster101:FOO == nodes defined in a specific key of ks301/nodes.cf
  • %%all == assuming %all is a lust of clusters, the additional % will expand the list of clusters to node list that is their membership
  • *node == returns the cluster(s) that node is a member of

Operatons:

  • range1,range2 == union
  • range1,-range2 == set difference
  • range1,&range2 == intersection
  • ^range1 == admins for the nodes in range1
  • range1,-(range2,range3) == () can be used for grouping
  • range1,&/regex/ # all nodes in range1 that match regex
  • range1,-/regex/ # all nodes in range1 that do not match regex

Advanced ranges:

  • foo{1,3,5} == foo1,foo3,foo5
  • %cluster30{1,3} == %cluster301,%cluster303
  • %cluster301-7 == nodes in clusters cluster301 to cluster307
  • %all:KEYS == all defined sections in cluster all
  • %{%all} == expands all clusters in %all
  • %all:dc1,-({f,k}s301-7) == names for clusters in dc1 except ks301-7,fs301-7
  • %all:dc1,-|ks| == clusters in dc1, except those matching ks

Functions:

libcrange modules can define certain functions to look up data about hosts or clusters The yaml module for instance implements some of the following functions.

  • has(KEY;value) - looks for a cluster that has a key with some certain value
  • allclusters() - returns a range of all clusters
    • and get_clusters(node) - return the first cluster a node is a member of
  • clusters(node) - return all clusters a node is a member of
  • has(ENVIRONMENT; production) would return any clusters with the a key called ENVIRONMENT set to production
  • mem(CLUSTER; foo.example.com) => which keys under CLUSTER is foo.example.com a member of

Other functions can be added via modules that provide useful insight into your environment

  • vlan(host) - return vlan for this host
  • dc(host) - return datacenter for this host
  • drac(host) - might do an API call on backend to central host db to look up a drac IP for a host

libcrange's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.