]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
UCS inventore persistence and pep8/pylint fixes.
authorSumit Naiksatam <snaiksat@cisco.com>
Sun, 21 Aug 2011 03:37:51 +0000 (20:37 -0700)
committerSumit Naiksatam <snaiksat@cisco.com>
Sun, 21 Aug 2011 03:37:51 +0000 (20:37 -0700)
quantum/plugins/cisco/tests/unit/test_cisco_extension.py
quantum/plugins/cisco/ucs/cisco_ucs_inventory.py
quantum/plugins/cisco/ucs/cisco_ucs_plugin.py

index 36e8d52342a715ceb33d636df4e44ac54b841d9b..f69ac3df0cbb84a37473e6e46768465ef6eae2fb 100644 (file)
@@ -640,8 +640,7 @@ class CredentialExtensionTest(unittest.TestCase):
         self.test_credential_data = {'credential':
                                     {'credential_name': 'cred8',
                                     'user_name': 'newUser2',
-                                    'password': 'newPasswd1'
-                                    }}
+                                    'password': 'newPasswd1'}}
 
     def test_list_credentials(self):
         #Create Credential before listing
@@ -653,8 +652,7 @@ class CredentialExtensionTest(unittest.TestCase):
         req_body2 = json.dumps({'credential':
                                 {'credential_name': 'cred9',
                                 'user_name': 'newUser2',
-                                'password': 'newPasswd2'
-                                }})
+                                'password': 'newPasswd2'}})
         create_response2 = self.test_app.post(
                            self.credential_path, req_body2,
                            content_type=self.contenttype)
@@ -735,8 +733,7 @@ class CredentialExtensionTest(unittest.TestCase):
         rename_req_body = json.dumps({'credential':
                                       {'credential_name': 'cred3',
                                           'user_name': 'RenamedUser',
-                                          'password': 'Renamedpassword'
-                                      }})
+                                          'password': 'Renamedpassword'}})
         rename_path_temp = self.cred_second_path +\
                            resp_body['credentials']['credential']['id']
         rename_path = str(rename_path_temp)
@@ -767,8 +764,7 @@ class CredentialExtensionTest(unittest.TestCase):
         rename_req_body = json.dumps({'credential':
                                       {'credential_name': 'cred3',
                                           'user_name': 'RenamedUser',
-                                          'password': 'Renamedpassword'
-                                      }})
+                                          'password': 'Renamedpassword'}})
         rename_path_temp = self.cred_second_path + credential_id
         rename_path = str(rename_path_temp)
         rename_response = self.test_app.put(rename_path, rename_req_body,
index ae9aa49708ebcfe15708fbdf248209919c5e2760..f2dd3553e34f7ac35148e62927b24596e81eba73 100644 (file)
@@ -26,6 +26,7 @@ from quantum.plugins.cisco.common import cisco_constants as const
 from quantum.plugins.cisco.common import cisco_credentials as cred
 from quantum.plugins.cisco.common import cisco_exceptions as cexc
 from quantum.plugins.cisco.common import cisco_utils as cutil
+from quantum.plugins.cisco.db import ucs_db as udb
 from quantum.plugins.cisco.ucs \
         import cisco_ucs_inventory_configuration as conf
 from quantum.plugins.cisco.ucs import cisco_ucs_network_driver
@@ -115,7 +116,7 @@ class UCSInventory(object):
                     blade_list.append(blade_id)
                 chassis_dict[chassis_id] = blade_list
             self._inventory[ucsm_ip] = chassis_dict
-        
+
         self.build_inventory_state()
 
     def _get_host_name(self, ucsm_ip, chassis_id, blade_id):
@@ -132,6 +133,7 @@ class UCSInventory(object):
         unreserved_counter = 0
 
         for blade_intf in blade_intf_data.keys():
+            dist_name = blade_intf_data[blade_intf][const.BLADE_INTF_DN]
             if (blade_intf_data[blade_intf][const.BLADE_INTF_LINK_STATE] == \
                 const.BLADE_INTF_STATE_UNALLOCATED  or \
                 blade_intf_data[blade_intf][const.BLADE_INTF_LINK_STATE] == \
@@ -141,14 +143,25 @@ class UCSInventory(object):
                 blade_intf_data[blade_intf][const.BLADE_INTF_RESERVATION] = \
                         const.BLADE_INTF_UNRESERVED
                 unreserved_counter += 1
+                blade_intf_data[blade_intf][const.TENANTID] = None
+                blade_intf_data[blade_intf][const.PORTID] = None
+                blade_intf_data[blade_intf][const.PROFILE_ID] = None
+                blade_intf_data[blade_intf][const.INSTANCE_ID] = None
+                blade_intf_data[blade_intf][const.VIF_ID] = None
             else:
                 blade_intf_data[blade_intf][const.BLADE_INTF_RESERVATION] = \
                         const.BLADE_INTF_RESERVED
-            blade_intf_data[blade_intf][const.TENANTID] = None
-            blade_intf_data[blade_intf][const.PORTID] = None
-            blade_intf_data[blade_intf][const.PROFILE_ID] = None
-            blade_intf_data[blade_intf][const.INSTANCE_ID] = None
-            blade_intf_data[blade_intf][const.VIF_ID] = None
+                port_binding = udb.get_portbinding_dn(dist_name)
+                blade_intf_data[blade_intf][const.TENANTID] = \
+                        port_binding[const.TENANTID]
+                blade_intf_data[blade_intf][const.PORTID] = \
+                        port_binding[const.PORTID]
+                blade_intf_data[blade_intf][const.PROFILE_ID] = \
+                        port_binding[const.PORTPROFILENAME]
+                blade_intf_data[blade_intf][const.INSTANCE_ID] = \
+                        port_binding[const.INSTANCE_ID]
+                blade_intf_data[blade_intf][const.VIF_ID] = \
+                        port_binding[const.VIF_ID]
 
         blade_data = {const.BLADE_INTF_DATA: blade_intf_data,
                      const.BLADE_UNRESERVED_INTF_COUNT: unreserved_counter}
@@ -287,8 +300,8 @@ class UCSInventory(object):
                         const.BLADE_INTF_RESERVED
                 blade_intf_data[blade_intf][const.TENANTID] = tenant_id
                 blade_intf_data[blade_intf][const.PORTID] = port_id
-                blade_intf_data[blade_intf][const.PROFILE_ID] = \
-                        portprofile_name
+                #blade_intf_data[blade_intf][const.PROFILE_ID] = \
+                #        portprofile_name
                 blade_intf_data[blade_intf][const.INSTANCE_ID] = None
                 dev_eth_name = blade_intf_data[blade_intf] \
                         [const.BLADE_INTF_RHEL_DEVICE_NAME]
@@ -304,6 +317,11 @@ class UCSInventory(object):
                 reserved_nic_dict = {const.RESERVED_NIC_HOSTNAME: host_name,
                                    const.RESERVED_NIC_NAME: dev_eth_name,
                                    const.BLADE_INTF_DN: blade_intf}
+                port_binding = udb.add_portbinding(port_id, blade_intf, None,
+                                                   None, None, None)
+                udb.update_portbinding(port_id,
+                                       tenant_id=blade_intf_data[blade_intf]\
+                                       [const.TENANTID])
                 LOG.debug("Reserved blade interface: %s\n" % reserved_nic_dict)
                 return reserved_nic_dict
 
@@ -379,6 +397,10 @@ class UCSInventory(object):
                             host_name = self._get_host_name(ucsm_ip,
                                                             chassis_id,
                                                             blade_id)
+                            port_binding = udb.get_portbinding_dn(blade_intf)
+                            port_id = port_binding[const.PORTID]
+                            udb.update_portbinding(port_id,
+                                                   instance_id=instance_id)
                             return host_name
         return None
 
@@ -402,7 +424,10 @@ class UCSInventory(object):
                            [const.INSTANCE_ID] == instance_id:
                             blade_intf_data[blade_intf][const.VIF_ID] = \
                                     vif_id
-
+                            port_binding = udb.get_portbinding_dn(blade_intf)
+                            port_id = port_binding[const.PORTID]
+                            udb.update_portbinding(port_id,
+                                                   vif_id=vif_id)
                             return blade_intf_data[blade_intf]\
                                     [const.BLADE_INTF_RHEL_DEVICE_NAME]
         return None
index 023e4347fb6368152961dab190d28d92ec30489f..f3ecf72eff03c7897e6e78c224da630baf19a449 100644 (file)
@@ -172,11 +172,11 @@ class UCSVICPlugin(L2DevicePluginBase):
                                         blade_id, blade_data_dict,
                                         tenant_id, port_id,
                                         profile_name)
-        port_binding = udb.add_portbinding(port_id,
-                                           rsvd_nic_dict[const.BLADE_INTF_DN],
-                                           profile_name,
-                                           conf.DEFAULT_VLAN_NAME,
-                                           conf.DEFAULT_VLAN_ID, qos)
+        port_binding = udb.update_portbinding(port_id,
+                                       portprofile_name=profile_name,
+                                       vlan_name=conf.DEFAULT_VLAN_NAME,
+                                       vlan_id=conf.DEFAULT_VLAN_ID,
+                                       qos=qos)
         return port_binding
 
     def delete_port(self, tenant_id, net_id, port_id, **kwargs):