Exemplo n.º 1
0
        public async Task <IActionResult> IndexAsync()
        {
            List <Makerspace> makerspaces = await _httpHelper.Get <List <Makerspace> >(endpoint);

            List <Event> events = await _httpHelper.Get <List <Event> >("event");

            feedData.makerSpaces = makerspaces;
            feedData.events      = events;

            return(View(feedData));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> IndexAsync()
        {
            List <Makerspace> makerspaces = await _httpHelper.Get <List <Makerspace> >("makerspace");

            List <Event> events = await _httpHelper.Get <List <Event> >("event");

            exploreData.events      = events;
            exploreData.makerSpaces = makerspaces;

            foreach (var item in events)
            {
                item.makerspace = makerspaces.Find(x => x.id == item.makerSpaceId);
            }

            return(View(exploreData));
        }
Exemplo n.º 3
0
        protected override void Run()
        {
            host.Status = HostStatus.compiling;

            string hostname = Helpers.GetName(host.Host);

            hostname = ZipStatusReportAction.SanitizeTarPathMember(hostname);
            // Workaround for excessively long filenames: trim the hostname we use
            if (hostname.Length > 20)
            {
                hostname = hostname.Truncate(20);
            }
            string filename = string.Format("{1}\\{2}-bugtool-{0}.tar", hostname, filepath, timestring);

            string entries_string = String.Join(",", entries);

            log.DebugFormat("Getting system status for {0} on {1}", entries_string, hostname);

            try
            {
                host.Status = HostStatus.compiling;
                if (Session == null)
                {
                    throw new Exception(Messages.CONNECTION_IO_EXCEPTION);
                }

                HTTPHelper.Get(this, false, dataRxDelegate, filename, host.Host.address,
                               (HTTP_actions.get_ssss)HTTP_actions.get_system_status,
                               Session.opaque_ref, entries_string, "tar");

                log.DebugFormat("Getting system status from {0} successful", hostname);

                host.Status          = HostStatus.succeeded;
                base.PercentComplete = 100;
            }
            catch (CancelledException ce)
            {
                log.Info("Getting system status cancelled");

                Description = Messages.ACTION_SYSTEM_STATUS_CANCELLED;
                host.Status = HostStatus.failed;
                host.error  = ce;

                throw;
            }
            catch (Exception e)
            {
                log.Warn(string.Format("Getting system status from {0} failed", hostname), e);

                host.Status = HostStatus.failed;
                host.error  = e;

                Description =
                    Win32.GetHResult(e) == Win32.ERROR_DISK_FULL ?
                    Messages.ACTION_SYSTEM_STATUS_DISK_FULL :
                    Messages.ACTION_SYSTEM_STATUS_FAILED;
            }
        }
Exemplo n.º 4
0
        protected XenRef <Pool_patch> BringPatchToPoolForHost(Host host, Pool_patch patch)
        {
            // Check the patch exists on the pool this host is connected to
            XenRef <Pool_patch> patch_ref = host.Connection.Cache.FindRef(patch);

            if (patch_ref != null)
            {
                return(patch_ref);
            }

            Description = String.Format(Messages.DOWNLOADING_PATCH_FROM, patch.Connection.Hostname);

            // 1st download patch from the pool that has it (the connection on the xenobject)

            string filename = Path.GetTempFileName();

            try
            {
                Connection = patch.Connection;
                Session    = patch.Connection.DuplicateSession();

                try
                {
                    HTTPHelper.Get(this, true, filename, patch.Connection.Hostname,
                                   (HTTP_actions.get_sss)HTTP_actions.get_pool_patch_download,
                                   Session.uuid, patch.uuid);
                }
                finally
                {
                    Connection = null;
                    Session    = null;
                }

                // Then, put it on the pool that doesn't have it

                Description = String.Format(Messages.UPLOADING_PATCH_TO, host.Name);

                Connection = host.Connection;
                Session    = host.Connection.DuplicateSession();

                try
                {
                    string result = HTTPHelper.Put(this, true, filename, host.Connection.Hostname,
                                                   (HTTP_actions.put_ss)HTTP_actions.put_pool_patch_upload, Session.uuid);

                    return(new XenRef <Pool_patch>(result));
                }
                finally
                {
                    Connection = null;
                    Session    = null;
                }
            }
            finally
            {
                File.Delete(filename);
            }
        }
Exemplo n.º 5
0
        public async Task <IActionResult> IndexAsync()
        {
            List <Event> events = await _httpHelper.Get <List <Event> >(endpoint);

            foreach (var item in events)
            {
                item.makerspace = await _httpHelper.GetWithID <Makerspace>("makerspace", item.makerSpaceId);
            }

            return(View(events));
        }
        public override object[] Connect(params object[] Parameters)
        {
            //return base.Connect(Parameters);

            HTTPHelper helper = new HTTPHelper();

            string operationName = Parameters[0] != null ? Parameters[0].ToString() : null;

            Operation operation = !String.IsNullOrEmpty(operationName) ? this.GetOperation(operationName) : this.GetOperation(0);

            string message = Parameters[1] != null ? Parameters[1].ToString() : operation.Message;

            helper.EnableTracing   = ((!String.IsNullOrEmpty(operation.GetArgumentValue("EnableTracing"))) && (operation.GetArgumentValue("EnableTracing").ToLower() == "true"));
            helper.TraceSourceName = operation.GetArgumentValue("TraceSourceName");

            Dictionary <string, string> headers = null;

            IDictionary <string, object> headerArgs = operation.GetArguments("HttpHeader");

            if (headerArgs != null)
            {
                headers = new Dictionary <string, string>();

                foreach (string headerName in headerArgs.Keys)
                {
                    if ((!headers.ContainsKey(headerName)) && (headerArgs[headerName] != null))
                    {
                        headers.Add(headerName, headerArgs[headerName].ToString());
                    }
                }
            }

            if (operation.Method == OperationMethod.Retrieve)
            {
                return(new object[] { helper.Get(this.Address, this.Authentication, headers) });
            }
            else
            {
                return(new object[] { helper.Post(this.Address, message, this.Authentication, headers) });
            }
        }
        protected override void Run()
        {
            try
            {
                switch (type)
                {
                case HostBackupRestoreType.backup:
                    this.Description = String.Format(Messages.BACKINGUP_HOST_WITH_DATA, Host.Name, Util.MemorySizeStringSuitableUnits(0, false));

                    LogDescriptionChanges = false;
                    try
                    {
                        HTTPHelper.Get(this, true, DataReceived, filename, Host.address,
                                       (HTTP_actions.get_ss)HTTP_actions.get_host_backup, Session.uuid);
                    }
                    finally
                    {
                        LogDescriptionChanges = true;
                    }

                    this.Description = String.Format(Messages.HOST_BACKEDUP, Host.Name);
                    break;

                case HostBackupRestoreType.restore:
                    this.Description = String.Format(Messages.RESTORING_HOST, Host.Name);

                    HTTPHelper.Put(this, true, filename, Host.address,
                                   (HTTP_actions.put_ss)HTTP_actions.put_host_restore, Session.uuid);

                    this.Description = String.Format(Messages.HOST_RESTORED, Host.Name);
                    break;
                }
            }
            catch (HTTP.CancelledException)
            {
                Description = Messages.CANCELLED_BY_USER;
                throw new CancelledException();
            }
        }
Exemplo n.º 8
0
        protected override void Run()
        {
            Status = ReportStatus.compiling;

            string hostname = Helpers.GetName(host);

            hostname = ZipStatusReportAction.SanitizeTarPathMember(hostname);
            if (hostname.Length > 20)
            {
                hostname = hostname.Truncate(20);
            }

            string filename = string.Format("{1}\\{2}-bugtool-{0}.tar", hostname, filePath, timeString);

            string entries_string = string.Join(",", capabilityKeys);

            log.DebugFormat("Getting system status for {0} on {1}", entries_string, hostname);

            try
            {
                if (Session == null)
                {
                    throw new Exception(Messages.CONNECTION_IO_EXCEPTION);
                }

                HTTPHelper.Get(this, false, dataRxDelegate, filename, host.address,
                               (HTTP_actions.get_ssss)HTTP_actions.get_system_status,
                               Session.opaque_ref, entries_string, "tar");

                log.DebugFormat("Getting system status from {0} successful", hostname);

                Status          = ReportStatus.succeeded;
                Description     = Messages.COMPLETED;
                PercentComplete = 100;
            }
            catch (HTTP.CancelledException)
            {
                throw new CancelledException();
            }
            catch (CancelledException ce)
            {
                log.Info("Getting system status cancelled");
                Status      = ReportStatus.cancelled;
                Error       = ce;
                Description = Messages.ACTION_SYSTEM_STATUS_CANCELLED;
                throw;
            }
            catch (Exception e)
            {
                log.Error(string.Format("Getting system status from {0} failed", hostname), e);

                Status = ReportStatus.failed;
                Error  = e;

                if (Win32.GetHResult(e) == Win32.ERROR_DISK_FULL)
                {
                    Description = Messages.ACTION_SYSTEM_STATUS_DISK_FULL;
                    return;
                }

                if (!string.IsNullOrEmpty(Error.Message) && RBAC_FAIL_STRINGS.All(s => Error.Message.Contains(s)))
                {
                    var roles = Host.Connection.Session.Roles;
                    roles.Sort();
                    Description = string.Format(Messages.BUGTOOL_RBAC_FAILURE, roles[0].FriendlyName());
                    return;
                }

                Description = Messages.BUGTOOL_REPORTSTATUS_FAILED;
            }
        }