def test_install_params_w_bmc(self): self.maxDiff = None bmcsetup = luna.BMCSetup( name='bmcsetup1', mongo_db=self.db, create=True, ) self.install_expected_dict['interfaces'].pop('BOOTIF') self.group.bmcsetup(bmcsetup.name) self.install_expected_dict['bmcsetup'] = { 'netchannel': 1, 'mgmtchannel': 1, 'userid': 3, 'user': '******', 'password': '******' } self.node = luna.Node( name=self.node.name, mongo_db=self.db, ) self.assertEqual( self.node.install_params, self.install_expected_dict, )
def luna_bmcsetup_absent(data): name = data['name'] try: bmcsetup = luna.BMCSetup(name=name) except RuntimeError: return False, False, name return not bmcsetup.delete(), True, name
def setUp(self): self.bind = create_datastore('mim:///luna') self.db = self.bind.db.luna self.path = '/tmp/luna' if not os.path.exists(self.path): os.makedirs(self.path) cluster = luna.Cluster(mongo_db=self.db, create=True, path=self.path, user=getpass.getuser()) self.bmc = luna.BMCSetup(name='testbmc', mongo_db=self.db, create=True)
def setUp(self): print self.sandbox = Sandbox() self.db = self.sandbox.db self.path = self.sandbox.path cluster = luna.Cluster(mongo_db=self.db, create=True, path=self.path, user=getpass.getuser()) self.bmc = luna.BMCSetup(name='testbmc', mongo_db=self.db, create=True)
def test_read_bmcsetup(self): bmc = luna.BMCSetup(name='testbmc', mongo_db=self.db) doc = self.db['bmcsetup'].find_one({'_id': bmc._id}) expected = { 'userid': 3, 'user': '******', 'password': '******', 'netchannel': 1, 'mgmtchannel': 1 } for attr in expected: self.assertEqual(doc[attr], expected[attr])
def luna_bmcsetup_present(data): data.pop('state') name = data.pop('name') changed = False ret = True try: bmcsetup = luna.BMCSetup(name=name) except RuntimeError: args = {} for key in data: if data[key] is not None: args[key] = data[key] args['name'] = name args['create'] = True bmcsetup = luna.BMCSetup(**args) changed = True for key in data: if data[key] is not None and bmcsetup.get(key) != data[key]: changed = True ret &= bmcsetup.set(key, data[key]) return not ret, changed, str(bmcsetup)
def test_create_bmcsetup_with_defaults(self): bmc = luna.BMCSetup(name='testbmc', mongo_db=self.db, create=True) doc = self.db['bmcsetup'].find_one({'_id': bmc._id}) expected = { 'userid': 3, 'user': '******', 'password': '******', 'netchannel': 1, 'mgmtchannel': 1, 'comment': '' } for attr in expected: self.assertEqual(doc[attr], expected[attr])
def test_install_params_w_bmconfig_wo_net(self): # add bmcconfig bmc = luna.BMCSetup(name="testbmc", mongo_db=self.db, create=True) self.group.bmcsetup(bmc.name) self.install_expected_dict['bmcsetup'] = { 'mgmtchannel': 1, 'netchannel': 1, 'password': '******', 'user': '******', 'userid': 3, } self.assertEqual(self.group.install_params, self.install_expected_dict)
create=True, NETWORK='192.168.1.0', PREFIX=24, NETMASK='255.255.255.0') ifcfg2 = luna.IfCfg(name='internal2', create=True, NETWORK='192.168.2.0', PREFIX=24, NETMASK='255.255.255.0') ifcfg3 = luna.IfCfg(name='internal3', create=True, NETWORK='192.168.3.0', PREFIX=24, NETMASK='255.255.255.0') ipmi = luna.IfCfg(name='ipmi', create=True, NETWORK='10.10.0.0', PREFIX=16) bmc = luna.BMCSetup(name='base', create=True) osimage = luna.OsImage(create=True, name='compute1', path='/os/compute-image', kernver='3.10.0-327.3.1.el7.x86_64') osimage = luna.OsImage(create=True, name='compute2', path='/os/compute-image-2', kernver='3.10.0-327.3.1.el7.x86_64') group = luna.Group(create=True, name='compute-group', bmcsetup='base', bmcnetwork='ipmi', osimage='compute1', interfaces={ 'eth0': 'internal1',
def setUp( self, mock_rpm_addmacro, mock_rpm_transactionset, ): print packages = [ { 'VERSION': '3.10', 'RELEASE': '999-el0', 'ARCH': 'x86_64' }, ] mock_rpm_transactionset.return_value.dbMatch.return_value = packages self.sandbox = Sandbox() self.db = self.sandbox.db self.path = self.sandbox.path self.cluster = luna.Cluster(mongo_db=self.db, create=True, path=self.path, user=getpass.getuser()) self.cluster.set("frontend_address", "127.0.0.1") self.osimage = luna.OsImage(name='testosimage', path=self.path, mongo_db=self.db, create=True) self.bmcsetup = luna.BMCSetup(name='bmcsetup', mongo_db=self.db, create=True) self.net1 = luna.Network(name='cluster', NETWORK='10.11.0.0', PREFIX=16, mongo_db=self.db, create=True) self.net2 = luna.Network(name='external', NETWORK='10.12.0.0', PREFIX=16, mongo_db=self.db, create=True) self.net3 = luna.Network(name='ib', NETWORK='10.13.0.0', PREFIX=16, mongo_db=self.db, create=True) self.prescript = 'pre' self.postscript = 'post' self.partscript = 'part' self.nics = {'BOOTIF': 'PARM=1', 'eth1': 'PARM=2', 'ib0': 'PARM=3'} self.group = luna.Group(name='compute', osimage=self.osimage.name, mongo_db=self.db, interfaces=['BOOTIF'], create=True) # mocking osimage boot stuff with mock.patch('os.path'), \ mock.patch('shutil.copy'), \ mock.patch('os.remove'), \ mock.patch('os.chown'), \ mock.patch('os.chmod'), \ mock.patch('subprocess.Popen') as mock_subprocess_popen, \ mock.patch('os.open'), \ mock.patch('os.chroot'), \ mock.patch('os.fchdir'), \ mock.patch('os.close'), \ mock.patch('os.chdir'), \ mock.patch('shutil.move'), \ mock.patch('libtorrent.add_files'), \ mock.patch('libtorrent.set_piece_hashes'): (mock_subprocess_popen.return_value.stderr.readline.return_value ) = '' self.osimage.copy_boot() self.osimage.create_tarball() self.osimage.create_torrent() group_json = self.db['group'].find_one({'_id': self.group._id}) osimage_json = self.db['osimage'].find_one({'_id': self.osimage._id}) self.install_expected_dict = { 'torrent_if': '', 'partscript': group_json['partscript'], 'tarball': osimage_json['tarball'] + '.tgz', 'bmcsetup': {}, 'interfaces': { 'BOOTIF': { 'options': '', '4': { 'ip': '', 'netmask': '', 'prefix': '', }, '6': { 'ip': '', 'netmask': '', 'prefix': '', } } }, 'prescript': '', 'domain': '', 'postscript': group_json['postscript'], 'kernopts': '', 'kernver': '3.10-999-el0.x86_64', 'torrent': osimage_json['torrent'] + '.torrent' }
def setUp( self, mock_rpm_addmacro, mock_rpm_transactionset, ): print packages = [ { 'VERSION': '3.10', 'RELEASE': '999-el0', 'ARCH': 'x86_64' }, ] mock_rpm_transactionset.return_value.dbMatch.return_value = packages self.sandbox = Sandbox() self.db = self.sandbox.db self.path = self.sandbox.path #osimage_path = self.sandbox.create_osimage() self.cluster = luna.Cluster(mongo_db=self.db, create=True, path=self.path, user=getpass.getuser()) self.cluster.set("frontend_address", "127.0.0.1") self.osimage = luna.OsImage(name='testosimage', path=self.path, mongo_db=self.db, create=True) self.bmcsetup = luna.BMCSetup(name='bmcsetup', mongo_db=self.db, create=True) self.net1 = luna.Network(name='cluster', NETWORK='10.11.0.0', PREFIX=16, mongo_db=self.db, create=True) self.net2 = luna.Network(name='external', NETWORK='10.12.0.0', PREFIX=16, mongo_db=self.db, create=True) self.net3 = luna.Network(name='ib', NETWORK='10.13.0.0', PREFIX=16, mongo_db=self.db, create=True) self.net6 = luna.Network(name='net6', NETWORK='fe80::', PREFIX=64, mongo_db=self.db, create=True, version=6) self.prescript = 'pre' self.postscript = 'post' self.partscript = 'part' self.nics = {'eth0': 'PARM=1', 'eth1': 'PARM=2', 'ib0': 'PARM=3'} self.group = luna.Group(name='compute', osimage=self.osimage.name, mongo_db=self.db, interfaces=['eth0'], create=True)
def test_creation_group(self): bmcsetup = luna.BMCSetup(name='bmcsetup', mongo_db=self.db, create=True) net = luna.Network(name='cluster', NETWORK='10.11.0.0', PREFIX=16, mongo_db=self.db, create=True) nics = ['eth0', 'eth1'] group = luna.Group(name='testgroup2', osimage=self.osimage.name, bmcsetup=bmcsetup.name, mongo_db=self.db, interfaces=nics, domain=net.name, torrent_if=nics[1], create=True) doc = self.db['group'].find_one({'_id': group._id}) expected = { 'torrent_if': nics[1], 'partscript': 'mount -t tmpfs tmpfs /sysroot', 'postscript': ('cat << EOF >> /sysroot/etc/fstab\n' + 'tmpfs / tmpfs defaults 0 0\n' + 'EOF'), 'name': 'testgroup2', 'bmcsetup': bmcsetup.DBRef, 'domain': net.DBRef, '_use_': { 'cluster': { str(self.cluster._id): 1 }, 'osimage': { str(self.osimage._id): 1 }, 'network': { str(net._id): 1, }, 'bmcsetup': { str(bmcsetup._id): 1 }, }, 'osimage': self.osimage.DBRef, 'comment': '', } for attr in expected: self.assertEqual(doc[attr], expected[attr]) # check interfaces if_dict = doc['interfaces'] self.assertEqual(len(if_dict), len(nics)) for uuid in if_dict: self.assertIn(if_dict[uuid]['name'], nics) self.assertEqual(if_dict[uuid]['params'], '') self.assertEqual(if_dict[uuid]['network'], {'4': None, '6': None}) nics.remove(if_dict[uuid]['name'])