try: guest_status = models.GuestStatus().create(instance_id=db_instance['id'], state='building') except Exception, e: LOG.exception("Error creating GuestStatus instance %s" % db_instance.data()['id']) self.fail("Unable to create GuestStatus entry") file_dict = { '/home/nova/agent.config': rd_utils.create_boot_config(config.Config, None, None, 'test') } instance = { 'id' : instance_id, 'remote_uuid' : None, 'remote_hostname' : remote_hostname, 'tenant_id' : TENANT_ID } # Invoke worker to ensure instance gets created worker_api.API().ensure_create_instance(None, instance, rd_utils.file_dict_as_userdata(file_dict)) # Test getting a specific db instance. # ------------------------------------ LOG.info("* Getting instance %s" % instance_id) resp, content = req.request(API_URL + "instances/" + instance_id, "GET", "", AUTH_HEADER) self.assertEqual(200, resp.status, ("Expecting 200 as response status of show instance but received %s" % resp.status)) # Check to see if the instance created is # in the 'running' state # wait a max of 15 minutes for instance to come up max_wait_for_instance = 960 wait_so_far = 0 LOG.debug("Content: %s" % content)
return wsgi.Result(errors.wrap(errors.Instance.REDDWARF_CREATE, "Floating ip fetch/attachment Failure"), 500) else: try: instance.update(address=floating_ip['ip']) except Exception as e: LOG.error("Error updating DBass Instance table for floating ip") # Attempt to attach a volume try: self._try_attach_volume(context, body, credential, region_az, volume_size, instance) except exception.ReddwarfError, e: LOG.exception("Error creating DBaaS instance - volume attachment failed") return wsgi.Result(errors.wrap(errors.Instance.REDDWARF_CREATE, "Volume Attachment failure"), 500) # Invoke worker to ensure instance gets created worker_api.API().ensure_create_instance(None, instance, file_dict_as_userdata(file_dict)) return wsgi.Result(views.DBInstanceView(instance, guest_status, [db_secgroup], req, tenant_id, flavor['flavor_id']).create('dbas', password), 201) def restart(self, req, tenant_id, id): """Restart an instance.""" LOG.debug("Called restart() with %s, %s" % (tenant_id, id)) context = rd_context.ReddwarfContext( auth_tok=req.headers["X-Auth-Token"], tenant=tenant_id) # Sanitize id if not Sanitizer.whitelist_uuid(id): return wsgi.Result(errors.wrap(errors.Input.NONALLOWED_CHARACTERS_ID))