def setUp(self): models.client.GanetiRapiClient = RapiProxy # Cluster cluster = Cluster(hostname='test.cluster.gwm', slug='test', username='******', password='******') #cluster.info = INFO cluster.save() # Template template_data = dict( template_name='new.vm.template', description='A new template.', cluster=cluster.id, start=True, name_check=True, disk_template='plain', disk_count=0, memory=256, vcpus=2, root_path='/', kernel_path='', cdrom_image_path='', serial_console=False, nic_type='paravirtual', disk_type='paravirtual', nic_count=0, boot_order='disk', os='image+ubuntu-lucid', ) data = template_data.copy() data['cluster'] = cluster del data['disk_count'] del data['nic_count'] template = VirtualMachineTemplate(**data) template.save() # Template Fields fields = vars(template).keys() # Users self.create_users([ ('superuser', { 'is_superuser': True }), 'cluster_admin', ]) self.cluster_admin.grant('admin', cluster) self.users = [self.superuser, self.cluster_admin] self.template = template self.cluster = cluster self.template_data = template_data self.template_fields = fields
def setUp(self): self.tearDown() models.client.GanetiRapiClient = RapiProxy cluster = Cluster(hostname='test.cluster', slug='test', username='******', password='******') cluster.id = 23 # XXX MySQL DB does not reset auto-increment IDs when an object is removed cluster.save() cluster.sync_nodes() template = VirtualMachineTemplate(template_name="Template1", cluster=cluster) template.disks = [{'size': 500}] template.nics = [{'mode': 'bridged', 'link': ''}] template.save() instance = VirtualMachine(hostname='new.vm.hostname', cluster=cluster) instance.info = INSTANCE instance.disks = [] instance.nics = [] instance.save() # Users self.create_users([ ('superuser', { 'is_superuser': True }), 'cluster_admin', 'create_vm', 'unauthorized', ]) self.cluster_admin.grant('admin', cluster) self.create_vm.grant('create_vm', cluster) self.create_template_data = dict( cluster=cluster.pk, template_name='foo_bar', memory=512, disk_template='plain', disk_count=0, nic_count=0, ) self.cluster = cluster self.template = template self.instance = instance self.c = Client()