Ejemplo n.º 1
0
def compute_joined(rid=None):
    # NOTE(james-page) in MAAS environments the actual hostname is a CNAME
    # record so won't get scanned based on private-address which is an IP
    # add the hostname configured locally to the relation.
    settings = {
        'hostname': gethostname()
    }
    if config('prefer-ipv6'):
        settings = {'private-address': get_ipv6_addr()[0]}
    if migration_enabled():
        auth_type = config('migration-auth-type')
        settings['migration_auth_type'] = auth_type
        if auth_type == 'ssh':
            settings['ssh_public_key'] = public_ssh_key()
        relation_set(relation_id=rid, **settings)
    if config('enable-resize'):
        settings['nova_ssh_public_key'] = public_ssh_key(user='******')
        relation_set(relation_id=rid, **settings)
def compute_joined(rid=None):
    if not migration_enabled():
        return
    auth_type = config('migration-auth-type')
    settings = {
        'migration_auth_type': auth_type
    }
    if auth_type == 'ssh':
        settings['ssh_public_key'] = public_ssh_key()
    relation_set(relation_id=rid, **settings)
def compute_joined(rid=None):
    # NOTE(james-page) in MAAS environments the actual hostname is a CNAME
    # record so won't get scanned based on private-address which is an IP
    # add the hostname configured locally to the relation.
    settings = {
        'hostname':
        gethostname(),
        'private-address':
        get_relation_ip('migration',
                        cidr_network=config('libvirt-migration-network')),
    }

    if migration_enabled():
        auth_type = config('migration-auth-type')
        settings['migration_auth_type'] = auth_type
        if auth_type == 'ssh':
            settings['ssh_public_key'] = public_ssh_key()
        relation_set(relation_id=rid, **settings)
    if config('enable-resize'):
        settings['nova_ssh_public_key'] = public_ssh_key(user='******')
        relation_set(relation_id=rid, **settings)
 def test_public_ssh_key(self, getpwnam):
     getpwnam.return_value = self.fake_user('foo')
     with patch_open() as (_open, _file):
         _file.read.return_value = 'mypubkey'
         result = utils.public_ssh_key('foo')
     self.assertEqual(result, 'mypubkey')
 def test_public_ssh_key_not_found(self, getpwnam, _open):
     _open.side_effect = Exception
     getpwnam.return_value = self.fake_user('foo')
     self.assertEqual(None, utils.public_ssh_key())
 def test_public_ssh_key(self, getpwnam):
     getpwnam.return_value = self.fake_user('foo')
     with patch_open() as (_open, _file):
         _file.read.return_value = 'mypubkey'
         result = utils.public_ssh_key('foo')
     self.assertEqual(result, 'mypubkey')
 def test_public_ssh_key_not_found(self, getpwnam, _open):
     _open.side_effect = Exception
     getpwnam.return_value = self.fake_user('foo')
     self.assertEqual(None, utils.public_ssh_key())