Ubuntu Pastebin

Paste from smoser at Wed, 4 May 2016 17:47:13 +0000

Download as text
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
- datasources can be laid down into /var/lib/cloudinit/datasources/
  if entry is a directory, it must have __init__.py and is loaded as a module
  if entry is a file, it must end in .py and it will be loaded
- datasource providers must define get_datasources.
   get_datasources should return
   a list of dictionaries
     {'version': 2, 'priority': X, class: class}

 - classes are loaded in priority order their search(mode='local') is called.
   Short circuit on first found.
   ultimately could declare in the return a list of "resources" (/dev/ttyS0)
   that the datasource would need exclusive access to and then you could
   call some in parallel.

 - if there is a previously booted instance data (/var/lib/cloud/instance/obj.pkl)
   then load it and call quick_check to see if it is still relevant
   (on openstack that checks the dmi product id versus the stored instance-id)

 - if did not reload from cache, then search(local) on each
   if a True is found in search(local) then short circuit:
   if class.dsmode == local:
      then user data will be consumed and init_modules run
   module is pickled to /var/lib/cloud/instance/obj.pkl

 - if did not find in search(local) then search(network-probe)
   this allows some datasources to go looking
   
 - if not found in search(network-probe)
   generate fallback networking
   come back up after fallback networking and call search(network)



Version 2 Datasources
  def __init__(self, sys_cfg, distro, paths)
    sys_cfg : system config (loaded /etc/cloud.cfg.d)
    distr: the current cloudinit.distro 
    paths: paths paths object for finding defined paths

 def search(mode=('local', 'network-probe' or 'network'))
    return True if this is the right datasource (you've found data)
    raise UnNeccesaryDatasource if no more 'search' are necessary here
       (definitively found this is *not* the right datasource)
    return False if further searching should be done.

    local-only: only search 'local' datasources
    network-probe: you can muck with networking to further look
       ie, you could bring up an ipv4 link local and try http://169.254.169.254/
    network: network is configured, you can read data from network sources

 @property
 def dsmode()
     return local or network
        defines when the init_modules should be invoked
        should be 'network' in almost any case unless the user
        provided data or config indicates should be a local


Questions:
   is statedir usefuL?
         statedir: place to store state (/var/lib/cloud/instances/)
                   the intent of this is for a datasource that searches
                   locally can pick back up in network search.
                   for example NoCloud or ConfigDrive would find a disk
                   and thus know that it is the applicable datasource
                   but would not
Download as text