fix AttributeError
[sfa.git] / sfa / openstack / osaggregate.py
index fa8410e..a40abc0 100644 (file)
@@ -257,3 +257,28 @@ class OSAggregate:
                                           user_data=pubkeys, 
                                           group_name=group_name)
 
+
+    def delete_instances(self, project_name):
+        project = self.driver.shell.get_project(project_name)
+        if not project:
+            return 1
+        instances = self.driver.shell.db.instance_get_all_by_project(project_name)
+        security_group_manager = SecurityGroup(self)
+        for instance in instances:
+            # deleate this instance's security groups
+            for security_group in instance.security_groups:
+                # dont delete the default security group
+                if security_group.name != 'default': 
+                    security_group_manager.delete_security_group(security_group.name)
+            # destroy instance
+            self.driver.shell.db.instance_destroy(instance.instance_id)
+        return 1
+
+    def stop_instances(self, project_name):
+        instances = self.driver.shell.db.instance_get_all_by_project(project_name)
+        for instance in instances:
+            self.driver.shell.db.instance_stop(instance.instance_id)
+        return 1
+
+    def update_instances(self, project_name):
+        pass