Esempio n. 1
0
 def test_get_network_profiles_by_type(self):
     test_profiles = [{'name': 'test_profile1',
                       'segment_type': p_const.TYPE_VLAN},
                      {'name': 'test_profile2',
                       'segment_type': p_const.TYPE_VXLAN}]
     for p in test_profiles:
         n1kv_db.add_network_profile(p['name'], p['segment_type'])
     profile = n1kv_db.get_network_profile_by_type(p_const.TYPE_VLAN)
     self.assertEqual(test_profiles[0]['name'], profile['name'])
     self.assertEqual(test_profiles[0]['segment_type'],
                      profile['segment_type'])
 def test_get_network_profiles_by_type(self):
     test_profiles = [{
         'name': 'test_profile1',
         'segment_type': p_const.TYPE_VLAN
     }, {
         'name': 'test_profile2',
         'segment_type': p_const.TYPE_VXLAN
     }]
     for p in test_profiles:
         n1kv_db.add_network_profile(p['name'], p['segment_type'])
     profile = n1kv_db.get_network_profile_by_type(p_const.TYPE_VLAN)
     self.assertEqual(test_profiles[0]['name'], profile['name'])
     self.assertEqual(test_profiles[0]['segment_type'],
                      profile['segment_type'])
def _create_test_network_profile_if_not_there(session,
                                              profile=TEST_NETWORK_PROFILE):
    try:
        _profile = session.query(
            n1kv_models.NetworkProfile).filter_by(name=profile['name']).one()
    except s_exc.NoResultFound:
        _profile = n1kv_db.add_network_profile(profile['name'],
                                               profile['segment_type'])
    return _profile
Esempio n. 4
0
def _create_test_network_profile_if_not_there(session,
                                              profile=TEST_NETWORK_PROFILE):
    try:
        _profile = session.query(n1kv_models.NetworkProfile).filter_by(
            name=profile['name']).one()
    except s_exc.NoResultFound:
        _profile = n1kv_db.add_network_profile(profile['name'],
                                          profile['segment_type'])
    return _profile
 def test_create_network_profile(self):
     _db_profile = n1kv_db.add_network_profile(TEST_NETWORK_PROFILE['name'],
                                               p_const.TYPE_VLAN)
     self.assertIsNotNone(_db_profile)
     db_profile = (self.session.query(n1kv_models.NetworkProfile).filter_by(
         name=TEST_NETWORK_PROFILE['name']).one())
     self.assertIsNotNone(db_profile)
     self.assertEqual(_db_profile.id, db_profile.id)
     self.assertEqual(_db_profile.name, db_profile.name)
     self.assertEqual(_db_profile.segment_type, db_profile.segment_type)
 def test_remove_network_profile(self):
     _db_profile = n1kv_db.add_network_profile(TEST_NETWORK_PROFILE['name'],
                                               p_const.TYPE_VLAN)
     db_profile = n1kv_db.get_network_profile_by_type(p_const.TYPE_VLAN)
     self.assertIsNotNone(db_profile)
     self.assertEqual(_db_profile.id, db_profile.id)
     n1kv_db.remove_network_profile(_db_profile.id)
     self.assertRaises(c_exc.NetworkProfileNotFound,
                       n1kv_db.get_network_profile_by_type,
                       p_const.TYPE_VLAN)
Esempio n. 7
0
 def test_create_network_profile(self):
     _db_profile = n1kv_db.add_network_profile(TEST_NETWORK_PROFILE['name'],
                                          p_const.TYPE_VLAN)
     self.assertIsNotNone(_db_profile)
     db_profile = (self.session.query(n1kv_models.NetworkProfile).
                   filter_by(name=TEST_NETWORK_PROFILE['name']).one())
     self.assertIsNotNone(db_profile)
     self.assertEqual(_db_profile.id, db_profile.id)
     self.assertEqual(_db_profile.name, db_profile.name)
     self.assertEqual(_db_profile.segment_type, db_profile.segment_type)
Esempio n. 8
0
 def test_remove_network_profile(self):
     _db_profile = n1kv_db.add_network_profile(TEST_NETWORK_PROFILE['name'],
                                          p_const.TYPE_VLAN)
     db_profile = n1kv_db.get_network_profile_by_type(
                                         p_const.TYPE_VLAN)
     self.assertIsNotNone(db_profile)
     self.assertEqual(_db_profile.id, db_profile.id)
     n1kv_db.remove_network_profile(_db_profile.id)
     self.assertRaises(c_exc.NetworkProfileNotFound,
                       n1kv_db.get_network_profile_by_type,
                       p_const.TYPE_VLAN)
Esempio n. 9
0
 def _ensure_network_profiles_created_on_vsm(self, db_session=None):
     # Try to create logical networks and network profiles on the VSM if
     # they don't exist already.
     for netp_type in [p_const.TYPE_VLAN, p_const.TYPE_VXLAN]:
         try:
             netp = n1kv_db.get_network_profile_by_type(netp_type)
         except n1kv_exc.NetworkProfileNotFound:
             # Create a network profile in Neutron DB
             netp = n1kv_db.add_network_profile(self.netp_name[netp_type],
                                                netp_type, db_session)
             try:
                 # Create a network profile of type VLAN on the VSM
                 self.n1kvclient.create_network_segment_pool(netp)
             # Catch any exception here and cleanup if so
             except (n1kv_exc.VSMConnectionFailed, n1kv_exc.VSMError):
                 with excutils.save_and_reraise_exception():
                     n1kv_db.remove_network_profile(netp.id, db_session)
 def _ensure_network_profiles_created_on_vsm(self, db_session=None):
     # Try to create logical networks and network profiles on the VSM if
     # they don't exist already.
     for netp_type in [p_const.TYPE_VLAN, p_const.TYPE_VXLAN]:
         try:
             netp = n1kv_db.get_network_profile_by_type(netp_type)
         except n1kv_exc.NetworkProfileNotFound:
             # Create a network profile in Neutron DB
             netp = n1kv_db.add_network_profile(self.netp_name[netp_type],
                                                netp_type,
                                                db_session)
             try:
                 # Create a network profile of type VLAN on the VSM
                 self.n1kvclient.create_network_segment_pool(netp)
             # Catch any exception here and cleanup if so
             except (n1kv_exc.VSMConnectionFailed, n1kv_exc.VSMError):
                 with excutils.save_and_reraise_exception():
                     n1kv_db.remove_network_profile(netp.id, db_session)