Blame view

slapos/README.console.rst 2.82 KB
Łukasz Nowak committed
1
console
Cédric de Saint Martin committed
2
-------
Cédric de Saint Martin committed
3 4 5 6

The slapconsole tool allows to interact with a SlapOS Master throught the SLAP
library.

Cédric de Saint Martin committed
7
For more information about SlapOS or slapconsole usages, please go to
Cédric de Saint Martin committed
8
http://community.slapos.org.
Cédric de Saint Martin committed
9 10 11 12 13 14

The slapconsole tool is only a bare Python console with several global variables
defined and initialized.


Initialization and configuration file
Cédric de Saint Martin committed
15 16
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Cédric de Saint Martin committed
17 18 19 20 21 22
Slapconsole allows to automatically connect to a Master using URL and SSL
certificate from given slapos.cfg.
Certificate has to be *USER* certificate, manually obtained from SlapOS master
web interface.

Slapconsole tools reads the given slapos.cfg configuration file and use the
Cédric de Saint Martin committed
23 24
following informations :

Cédric de Saint Martin committed
25 26 27 28 29 30 31
 * Master URL is read from [slapos] in the "master_url" parameter.
 * SSL Certificate is read from [slapconsole] in the "cert_file" parameter.
 * SSL Key is read from [slapconsole] in the "key_file" parameter.

See slapos.cfg.example for examples.


32 33
Global functions/variables
~~~~~~~~~~~~~~~~~~~~~~~~~~
Cédric de Saint Martin committed
34

35
 * "request()" is a shorthand for slap.registerOpenOrder().request() allowing
Cédric de Saint Martin committed
36
   to request instances.
37
 * "supply()" is a shorthand for slap.registerSupply().supply() allowing to
Cédric de Saint Martin committed
38 39 40 41 42
   request software installation.

For more information about those methods, please read the SLAP library
documentation.

43 44 45 46
 * "product" is an instance of slap.SoftwareProductCollection whose only goal is to retrieve
   the URL of the best Software Release of a given Software Product as attribute.
   for each attribute call, it will retrieve from the SlapOS Master the best
   available Software Release URL and return it.
Cédric de Saint Martin committed
47

48
   This allows to request instances in a few words, i.e::
Cédric de Saint Martin committed
49

Gabriel Monnerat committed
50
      request("http://www.url.com/path/to/current/best/known/kvm/software.cfg", "mykvm")
Cédric de Saint Martin committed
51

52
   can be simplified into ::
Cédric de Saint Martin committed
53

Gabriel Monnerat committed
54
     request(product.kvm, "mykvm")
Cédric de Saint Martin committed
55

56
 * "slap" is an instance of the SLAP library. It is only used for advanced usages.
Jérome Perrin committed
57
   "slap" instance is obtained by doing ::
Cédric de Saint Martin committed
58
    
Jérome Perrin committed
59 60 61 62
    slap = slapos.slap.slap()
    slap.initializeConnection(config.master_url,
      key_file=config.key_file, cert_file=config.cert_file)

Cédric de Saint Martin committed
63 64

Examples
Cédric de Saint Martin committed
65 66 67
~~~~~~~~

::
Jérome Perrin committed
68
  
Cédric de Saint Martin committed
69
  >>> # Request instance
70
  >>> request(product.kvm, "myuniquekvm")
Jérome Perrin committed
71
  
Cédric de Saint Martin committed
72
  >>> # Request instance on specific computer
73
  >>> request(product.kvm, "myotheruniquekvm",
Cédric de Saint Martin committed
74 75 76
    filter_kw={ "computer_guid": "COMP-12345" })
  
  >>> # Request instance, specifying parameters (here nbd_ip and nbd_port)
77
  >>> request(product.kvm, "mythirduniquekvm",
Cédric de Saint Martin committed
78
    partition_parameter_kw={"nbd_ip":"2a01:e35:2e27:460:e2cb:4eff:fed9:48dc",
Cédric de Saint Martin committed
79
    "nbd_port":"1024"})
Jérome Perrin committed
80
  
Cédric de Saint Martin committed
81
  >>> # Request software installation on owned computer
82
  >>> supply(product.kvm, "mycomputer")
Jérome Perrin committed
83
  
Cédric de Saint Martin committed
84
  >>> # Fetch existing instance status
85
  >>> request(product.kvm, "myuniquekvm").getState()
Jérome Perrin committed
86
  
Marco Mariani committed
87
  >>> # Fetch instance information on already launched instance
88
  >>> request(product.kvm, "myuniquekvm").getConnectionParameter("url")