Beispiel #1
0
 def sample_obj(self):
     from hil.ext.obm.ipmi import Ipmi
     return Node(label='node-99',
                 obm=Ipmi(type=Ipmi.api_name,
                          host="ipmihost",
                          user="******",
                          password="******"))
Beispiel #2
0
def test_obmd_migrate(tmpdir):
    """The test proper.

    Create some nodes, run the script, and verify that it has done the right
    thing.
    """
    from hil.ext.obm.ipmi import Ipmi

    # Add some objects to the hil database:
    with app.app_context():
        for i in range(4):
            node = model.Node(label='node-%d' % i,
                              obm=Ipmi(user='******',
                                       host='10.0.0.%d' % (100 + i),
                                       password='******'))
            model.db.session.add(node)
        model.db.session.commit()

    check_call([
        'hil-admin', 'migrate-ipmi-info',
        '--obmd-base-url', OBMD_BASE_URL,
        '--obmd-admin-token', ADMIN_TOKEN,
    ])

    with app.app_context():
        for node in model.Node.query.all():

            # Check that the db info was updated correctly:
            assert node.obmd_admin_token == ADMIN_TOKEN, (
                "Node %s{label}'s admin token was incorrect: %s{token}"
                .format(
                    label=node.label,
                    token=node.obmd_admin_token,
                )
            )
            assert node.obmd_uri == OBMD_BASE_URL + '/node/' + node.label, (
                "Node %s{label}'s obmd_uri was incorrect: %s{uri}"
                .format(
                    label=node.label,
                    uri=node.obmd_uri,
                )
            )

            # Make sure obmd thinks the nodes are there; if so it should be
            # possible to get a token:
            sess = requests.Session()
            sess.auth = ('admin', ADMIN_TOKEN)
            resp = sess.post(node.obmd_uri + '/token')
            assert resp.ok, (
                "Failure getting token for node %s{label} from obmd; "
                "response: %s{resp}".format(
                    label=node.label,
                    resp=resp,
                )
            )
Beispiel #3
0
 def sample_obj(self):
     from hil.ext.obm.ipmi import Ipmi
     nic = Nic(
         Node(label='node-99',
              obm=Ipmi(type=Ipmi.api_name,
                       host="ipmihost",
                       user="******",
                       password="******")), 'ipmi', '00:11:22:33:44:55')
     project = Project('anvil-nextgen')
     network = Network(project, [project], True, '102', 'hammernet')
     return NetworkingAction(nic=nic, new_network=network, channel='null')
Beispiel #4
0
 def nic(self):
     """Create a Nic object (and associated Node) to work with."""
     from hil.ext.obm.ipmi import Ipmi
     return model.Nic(
         model.Node(
             label='node-99',
             obm=Ipmi(
                 type="http://schema.massopencloud.org/haas/v0/obm/ipmi",
                 host="ipmihost",
                 user="******",
                 password="******")), 'ipmi', '00:11:22:33:44:55')
Beispiel #5
0
def create_bigint_db():
    """Create database objects used in 'after-PK-bigint.sql'"""
    from hil.ext.switches.n3000 import DellN3000
    from hil.ext.switches.dell import PowerConnect55xx
    from hil.ext.switches.brocade import Brocade
    from hil.ext.switches.nexus import Nexus
    from hil.ext.switches.mock import MockSwitch
    from hil.ext.obm.ipmi import Ipmi
    from hil.ext.obm.mock import MockObm
    from hil.ext.auth.database import User
    from hil.ext.auth import database as dbauth
    with app.app_context():
        db.session.add(
            DellN3000(label='sw-n3000',
                      hostname='host',
                      username='******',
                      password='******',
                      dummy_vlan='5',
                      type=DellN3000.api_name))
        dell1 = PowerConnect55xx(label='sw-dell',
                                 hostname='host',
                                 username='******',
                                 password='******',
                                 type=PowerConnect55xx.api_name)
        db.session.add(dell1)
        db.session.add(
            Nexus(label='sw-nexus',
                  hostname='host',
                  username='******',
                  password='******',
                  dummy_vlan='5',
                  type=Nexus.api_name))
        db.session.add(
            Brocade(label='sw-brocade',
                    hostname='host',
                    username='******',
                    password='******',
                    interface_type='4',
                    type=Brocade.api_name))
        db.session.add(
            MockSwitch(label='sw0',
                       hostname='host',
                       username='******',
                       password='******',
                       type=MockSwitch.api_name))
        proj = model.Project(label='runway')
        db.session.add(proj)
        headnode1 = model.Headnode(label='runway_headnode',
                                   project=proj,
                                   base_img='image1')
        db.session.add(headnode1)
        db.session.add(model.Hnic(label='hnic1', headnode=headnode1))
        ipmi = Ipmi(host='host', user='******', password='******')
        db.session.add(ipmi)
        mock_obm = MockObm(host='host', user='******', password='******')
        db.session.add(mock_obm)
        node1 = model.Node(label='node-1', obm=ipmi)
        db.session.add(node1)

        db.session.add(
            model.Metadata(label='meta',
                           value="it is a true value",
                           node=node1))
        network1 = model.Network(owner=None,
                                 access=[proj],
                                 allocated=False,
                                 network_id="networking network",
                                 label='hil wireless')
        db.session.add(network1)
        nic1 = model.Nic(node=node1, label='pxe', mac_addr='ff:ff:ff:ff:ff:fe')
        model.Port(label='A fine port', switch=dell1)
        db.session.add(nic1)
        db.session.add(
            model.NetworkAttachment(nic=nic1, network_id=1,
                                    channel='vlan/100'))
        db.session.add(
            model.NetworkingAction(type='modify_port',
                                   nic=nic1,
                                   new_network=network1,
                                   channel='vlan/100'))
        jim = User(label='jim', password='******', is_admin=True)
        db.session.add(jim)

        local.auth = dbauth.User.query.filter_by(label='jim').one()

        dbauth.user_add_project('jim', 'runway')

        db.session.commit()

        # Original password is "pass"
        db.session.query(User).get(1).hashed_password = \
            ('$6$rounds=656000$iTyrApYTUhMx4b4g$YcaMExV'
             'YtS0ut2yXWrT64OggFpE4lLg12QsAuyMA3YKX6Czth'
             'XeisA47dJZW9GwU2q2CTIVrsbpxAVT64Pih2/')
        db.session.commit()