def _create_netconf_creds(self, context, body, protocol):
     """Create a new NETCONF Credential."""
     access_parameters = body.pop(protocol)
     netconf_cred_dict = self._create_netconf_cred_dict()
     for key, value in access_parameters.iteritems():
         body[key] = value
     body['protocol_type'] = protocol
     netconf_cred = self._update_dict(body, netconf_cred_dict)
     db_netconf_cred = db.add_bnp_netconf_cred(context, netconf_cred)
     return db_netconf_cred
 def _create_netconf_creds(self, context, body, protocol):
     """Create a new NETCONF Credential."""
     access_parameters = body.pop(protocol)
     netconf_cred_dict = self._create_netconf_cred_dict()
     for key, value in access_parameters.iteritems():
         body[key] = value
     body['protocol_type'] = protocol
     netconf_cred = self._update_dict(body, netconf_cred_dict)
     db_netconf_cred = db.add_bnp_netconf_cred(context, netconf_cred)
     return db_netconf_cred
 def _create_netconf_creds(self, context, body, protocol):
     """Create a new NETCONF Credential."""
     name = body.get('name')
     netconf_cred = db.get_netconf_cred_by_name(context,
                                                name)
     if netconf_cred:
         raise webob.exc.HTTPConflict(
             _("NETCONF Credential with %s name already present") %
             name)
     access_parameters = body.pop(protocol)
     netconf_cred_dict = self._create_netconf_cred_dict()
     for key, value in access_parameters.iteritems():
         body[key] = value
     body['proto_type'] = protocol
     netconf_cred = self._update_dict(body, netconf_cred_dict)
     db_netconf_cred = db.add_bnp_netconf_cred(context, netconf_cred)
     return db_netconf_cred
 def test_get_netconf_cred_by_id(self):
     """Test get_netconf_cred_by_id method."""
     netconf_cred_dict = self._get_netconf_cred_dict()
     retval = [db.add_bnp_netconf_cred(self.ctx, netconf_cred_dict)]
     cred_val = db.get_netconf_cred_by_id(self.ctx, retval[0]['id'])
     self.assertEqual(retval[0], cred_val)
 def test_get_netconf_cred_by_name(self):
     """Test get_netconf_cred_by_name method."""
     netconf_cred_dict = self._get_netconf_cred_dict()
     retval = [db.add_bnp_netconf_cred(self.ctx, netconf_cred_dict)]
     cred_val = db.get_netconf_cred_by_name(self.ctx, 'CRED1')
     self.assertEqual(retval, cred_val)
 def test_add_bnp_netconf_cred(self):
     """Test test_add_bnp_netconf_cred method."""
     netconf_cred_dict = self._get_netconf_cred_dict()
     db.add_bnp_netconf_cred(self.ctx, netconf_cred_dict)
     count = self.ctx.session.query(models.BNPNETCONFCredential).count()
     self.assertEqual(1, count)