early failures would prevent cleanup

because we are using finally: to do cleanup, we are cleaning
up variables which may never have been allocated, thus throwing
and additional exception and leaving state around after our
shutdown.

Discovered by bug #1087298 however this is not a fix for that
bug

Change-Id: I395301e619cc290367aa0ab8fb02d729343f1432
diff --git a/tempest/tests/compute/security_groups/test_security_group_rules.py b/tempest/tests/compute/security_groups/test_security_group_rules.py
index fd56dc3..ea23cf5 100644
--- a/tempest/tests/compute/security_groups/test_security_group_rules.py
+++ b/tempest/tests/compute/security_groups/test_security_group_rules.py
@@ -65,40 +65,46 @@
         with optional arguments
         should be successfull
         """
+        rule_id = None
+        secgroup1 = None
+        secgroup2 = None
         try:
             #Creating a Security Group to add rules to it
             s_name = rand_name('securitygroup-')
             s_description = rand_name('description-')
             resp, securitygroup =\
             self.client.create_security_group(s_name, s_description)
-            securitygroup_id1 = securitygroup['id']
+            secgroup1 = securitygroup['id']
             #Creating a Security Group so as to assign group_id to the rule
             s_name2 = rand_name('securitygroup-')
             s_description2 = rand_name('description-')
             resp, securitygroup =\
             self.client.create_security_group(s_name2, s_description2)
-            securitygroup_id2 = securitygroup['id']
+            secgroup2 = securitygroup['id']
             #Adding rules to the created Security Group with optional arguments
-            parent_group_id = securitygroup_id1
+            parent_group_id = secgroup1
             ip_protocol = 'tcp'
             from_port = 22
             to_port = 22
             cidr = '10.2.3.124/24'
-            group_id = securitygroup_id2
+            group_id = secgroup2
             resp, rule =\
             self.client.create_security_group_rule(parent_group_id,
                                                    ip_protocol,
                                                    from_port, to_port,
                                                    cidr=cidr,
                                                    group_id=group_id)
+            rule_id = rule['id']
             self.assertEqual(200, resp.status)
         finally:
             #Deleting the Security Group rule, created in this method
-            group_rule_id = rule['id']
-            self.client.delete_security_group_rule(group_rule_id)
+            if rule_id:
+                self.client.delete_security_group_rule(rule_id)
             #Deleting the Security Groups created in this method
-            resp, _ = self.client.delete_security_group(securitygroup_id1)
-            resp, _ = self.client.delete_security_group(securitygroup_id2)
+            if secgroup1:
+                self.client.delete_security_group(secgroup1)
+            if secgroup2:
+                self.client.delete_security_group(secgroup2)
 
     @attr(type='positive')
     def test_security_group_rules_create_delete(self):