Skip to content
This repository has been archived by the owner on Jan 9, 2019. It is now read-only.

rerun module

ahonor edited this page Aug 17, 2012 · 29 revisions

The "yana" rerun module acts as a basic client to the Yana server and provides a set of commands allowing users to create and manipulate Nodes.

For the most part, the commands are simple wrappers around the Yana API. You can find the module source here.

Command summary

  • import: import yana model - Reads a model definition.
  • node: manipulate a node - Provides actions for getting information about a node, creating and deleting them.
  • nodes: list nodes - Lists all nodes or limit results by node name or type.
  • type: manipulate a node type - Provides actions for listing, creating or deleting a node type.
  • types: list the node types - Lists all the types.

To list all commands and their options use rerun's command listing feature:

$ rerun yana

Configuration

The yana module uses a configuration file that contains data about how to connect to the yana server.

Data:

  • YANA_URL: URL to the Yana server
  • YANA_USER: Login name
  • YANA_PASSWORD: Password

Example data:

$ cat ~/.yanarc 
YANA_URL=http://localhost:8080
YANA_USER=admin
YANA_PASSWORD=admin

By default, the yana module looks for a file called $HOME/.yanarc but this can be overridden using the "--cfg" option.

Global Options

Global options exist for many of the yana commands.

-C|--cfg

Specify a configuration file via command line option:

rerun yana: <command> -C|--cfg <$HOME/.yanarc>

Example:

rerun yana:nodes --cfg $HOME/.yanarc

-F|--format

Specify a format option:

rerun yana: <command> -F|--format <>

Example:

rerun yana:nodes --format '${NAME}:${TYPE}'

See the command's usage statement for the default format string.

Command usage

The following sections provide usage summary and examples for each command.

Import

Import a model from a file. See the XML definition format here: https://github.com/dtolabs/yana2/blob/master/docs/yana.xsd

Usage:

rerun yana:import --file <>

Example:

$ rerun yana:import --file yana_import2.xml

Nodes

List the nodes

Lists all Nodes defined in the model. The --type <> option allows a sub filtering of nodes by their NodeType.

rerun yana:nodes [--type <>]

Example

List all the nodes:

$ rerun yana:nodes
1:ubuntu:Node:tomcat,simpleapp,qa:The ubuntu server
2:tomcat:Service:QA:The tomcat service
3:qa:Site:QA:The QA site
4:apache-tomcat-5.5.31:Package:tomcat:the tomcat container
5:simple-1.0.0.war:Package:tomcat:the simple webapp

List just the nodes of type, Package:

$ rerun yana:nodes --type Package
4:apache-tomcat-5.5.31:Package:tomcat:the tomcat container
5:simple-1.0.0.war:Package:tomcat:the simple webapp

Node

Manipulate a node.

Actions:

The node command provides a set of actions via the --action <> option.

  • create: Create a new node
  • delete: Delete the node
  • get: Get node info (default)

Get node info

The get action prints node info. Since the default action is "get", the --action option is left out in the examples.

Usage:

rerun yana:node --id <id>

Example:

$ rerun yana:node --id 1
name:ubuntu
type:Node
description:The ubuntu server
tags:tomcat,simpleapp,qa
appname:simpleapp
arch:i386
basedir:/tmp/demo/tomcat
environment:qa
hostname:ubuntu
osFamily:unix
osName:Linux
osVersion:2.6.32-28-generic
port:18080
service:tomcat
username:alexh

Create a node

Usage:

rerun yana:node --action create --typeid <> --name <> --tags <> --description <> --attributes <> --status <>

Example:

$ rerun yana:node --action create \
--typeid 4 --name fooboo --tags tagA \
--description 'my foo boo' \
--attributes "startuprank:1"

Output:

7:fooboo:Site

To create a node that has more than one attribute, separate the attribute/value pairs with a comma.

$ rerun yana:node --action create \
--typeid 3 --name my_service --tags tagA \
--description 'my service instance' \
--attributes "basedir:/usr/myservice,port:8088,startuprank:1"

Attributes are defined by NodeType. To see the list of attributes for a given type use the yana:type command below.

Delete a node

Usage:

rerun yana:node --action delete --id <>

Example:

$ rerun yana:node --action delete --id 7

Types

List the types.

Usage:

rerun yana:types

Example:

$ rerun yana:types
1:Node:An application host
2:Package:A software package
3:Service:A software service
4:Site:A service site

Type

Manipulate a type.

Actions:

The node command provides a set of actions via the --action <> option.

  • create: Create a type
  • get: Get type info (default)
  • delete: Delete a type

Get type info

Print information about the type specified by its ID.

Usage:

rerun yana:type --id <>

Example:

$ rerun yana:type --id 1
name:Node
description:An application host
id:1
attributes:hostname,arch,osFamily,osName,osVersion,username,port,basedir,appname,service,environment
relationships:environment,service

The --type <> option is an alternative means to specify a type using its name:

$ rerun yana:type --type Service
name:Service
description:A software service
id:3
attributes:basedir,startuprank,controller,port
relationships:service,package

Delete the type

Usage:

rerun yana:type --action delete --id <>

Example:

$ rerun yana:type --action delete --id 5