Wiki

Clone wiki

occam-web / Beginners-Guide / 1.Creating-a-Simple-OCCAM-Object

PREVIOUS: A Dummy Program

Creating a new object using OCCAM CLI

OCCAM provides a command line interface (CLI) to create, commit, and pull objects. In this tutorial, we will create a simple object that can contains executable code that needs to be built, and can then be executed.

In order to create a new object, OCCAM provides the new command:

$ occam new <type> <name>

This command takes as input the object type and name, creates the object folder in the current directory, and pulls the object into OCCAM. The directory is created containing a GIT repository, and the object description file (object.json), that contains the object description.

Create a simple simulator

Create a simulator named ExampleSim by running the following command:

$ cd ~/occam_workspace
$ occam new simulator ExampleSim
$ cd ~/occam_workspace/simulator-ExampleSim
$ occam commit

This command will create the following directory tree:

simulator-ExampleSim
├── .git
├── .gitignore
└── object.json

Where the contents of the object description file (object.json) are 1:

{
  "type": "simulator",
  "id": "95fdb476-8984-11e6-8e21-1c1b0d0a9044",
  "name": "ExampleSim"
}

You can also check your local OCCAM instance for the new object. For that purpose, open the OCCAM web interface, and on the top right corner search for the object name.

Adding files to the object

In order to make the object useful we need to be able to add files. And since an OCCAM objects uses a GIT repository to manage its contents, adding file to an object is simply adding the files to the GIT repository.

Now, lets wrap our dummy program within our ExampleSim object.

Note: From this point onward, we assume you are working within the simulator-ExampleSim folder, unless explicitly stated otherwise.

Add the dummy program to the GIT repository

Note: Basic GIT knowledge is advised, but not required. (Check this link for a book about GIT.)

Copy the dummy program into our object folder.

$ cp -R ~/occam_workspace/dummy_program ~/occam_workspace/simulator-ExampleSim/.

Now, commit the program files into the GIT repository.

$ git add dummy_program
$ git commit -m "Added a dummy_program"

Note: If you get an error from GIT, follow the instructions on the error to let GIT know who you are.
For example:
  git config --global user.email "my_mail@wherever.com"
  git config --global user.name "My Name"

Commit the new object revision into OCCAM

Once the object has been modified, it is time to commit the new version of the object to OCCAM:

$ occam commit
You can check the OCCAM web page for the new version.

NEXT: Adding a Configuration Schema


  1. Note that the id is automatically generated and must not be changed. 

Updated