~ibm-charms/charms/trusty/nova-compute-power/trunk

« back to all changes in this revision

Viewing changes to hooks/nova_compute_hooks.py

  • Committer: James Page
  • Date: 2014-01-24 15:21:15 UTC
  • mfrom: (51.2.7 nova-compute)
  • Revision ID: james.page@canonical.com-20140124152115-wh94p063fxc699th
[james-page] Add support for optional resize support
[r,gandelman-a]

Show diffs side-by-side

added added

removed removed

Lines of Context:
48
48
    register_configs,
49
49
    NOVA_CONF,
50
50
    QUANTUM_CONF, NEUTRON_CONF,
51
 
    ceph_config_file, CEPH_SECRET
 
51
    ceph_config_file, CEPH_SECRET,
 
52
    enable_shell, disable_shell
52
53
)
53
54
 
54
55
from nova_compute_context import CEPH_SECRET_UUID
75
76
        # Check-in with nova-c-c and register new ssh key, if it has just been
76
77
        # generated.
77
78
        initialize_ssh_keys()
78
 
        [compute_joined(rid) for rid in relation_ids('cloud-compute')]
 
79
 
 
80
    if config('enable-resize') is True:
 
81
        enable_shell(user='nova')
 
82
        initialize_ssh_keys(user='nova')
 
83
    else:
 
84
        disable_shell(user='nova')
 
85
 
 
86
    [compute_joined(rid) for rid in relation_ids('cloud-compute')]
79
87
 
80
88
    CONFIGS.write_all()
81
89
 
140
148
 
141
149
@hooks.hook('cloud-compute-relation-joined')
142
150
def compute_joined(rid=None):
143
 
    if not migration_enabled():
144
 
        return
145
 
    auth_type = config('migration-auth-type')
146
 
    settings = {
147
 
        'migration_auth_type': auth_type
148
 
    }
149
 
    if auth_type == 'ssh':
150
 
        settings['ssh_public_key'] = public_ssh_key()
151
 
    relation_set(relation_id=rid, **settings)
 
151
    if migration_enabled():
 
152
        auth_type = config('migration-auth-type')
 
153
        settings = {
 
154
            'migration_auth_type': auth_type
 
155
        }
 
156
        if auth_type == 'ssh':
 
157
            settings['ssh_public_key'] = public_ssh_key()
 
158
        relation_set(relation_id=rid, **settings)
 
159
    if config('enable-resize'):
 
160
        settings = {
 
161
            'nova_ssh_public_key': public_ssh_key(user='nova')
 
162
        }
 
163
        relation_set(relation_id=rid, **settings)
152
164
 
153
165
 
154
166
@hooks.hook('cloud-compute-relation-changed')
158
170
    # config advertised from controller.
159
171
    CONFIGS.write_all()
160
172
    import_authorized_keys()
 
173
    import_authorized_keys(user='nova', prefix='nova')
161
174
    import_keystone_ca_cert()
162
175
    if (network_manager() in ['quantum', 'neutron']
163
176
            and neutron_plugin() == 'ovs'):