README.console.rst 2.82 KB
Newer Older
1
console
Cédric de Saint Martin's avatar
Cédric de Saint Martin committed
2
-------
3 4 5 6

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

Cédric de Saint Martin's avatar
Cédric de Saint Martin committed
7
For more information about SlapOS or slapconsole usages, please go to
Cédric de Saint Martin's avatar
Cédric de Saint Martin committed
8
http://community.slapos.org.
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's avatar
Cédric de Saint Martin committed
15 16
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

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's avatar
Cédric de Saint Martin committed
23 24
following informations :

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's avatar
Cédric de Saint Martin committed
34

35
 * "request()" is a shorthand for slap.registerOpenOrder().request() allowing
36
   to request instances.
37
 * "supply()" is a shorthand for slap.registerSupply().supply() allowing to
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.
47

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

50
      request("http://www.url.com/path/to/current/best/known/kvm/software.cfg", "mykvm")
51

52
   can be simplified into ::
53

54
     request(product.kvm, "mykvm")
Cédric de Saint Martin's avatar
Cédric de Saint Martin committed
55

56
 * "slap" is an instance of the SLAP library. It is only used for advanced usages.
57
   "slap" instance is obtained by doing ::
58
    
59 60 61 62
    slap = slapos.slap.slap()
    slap.initializeConnection(config.master_url,
      key_file=config.key_file, cert_file=config.cert_file)

63 64

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

::
68
  
69
  >>> # Request instance
70
  >>> request(product.kvm, "myuniquekvm")
71
  
72
  >>> # Request instance on specific computer
73
  >>> request(product.kvm, "myotheruniquekvm",
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's avatar
Cédric de Saint Martin committed
78
    partition_parameter_kw={"nbd_ip":"2a01:e35:2e27:460:e2cb:4eff:fed9:48dc",
79
    "nbd_port":"1024"})
80
  
81
  >>> # Request software installation on owned computer
82
  >>> supply(product.kvm, "mycomputer")
83
  
84
  >>> # Fetch existing instance status
85
  >>> request(product.kvm, "myuniquekvm").getState()
86
  
Marco Mariani's avatar
Marco Mariani committed
87
  >>> # Fetch instance information on already launched instance
88
  >>> request(product.kvm, "myuniquekvm").getConnectionParameter("url")