Ejemplo n.º 1
0
        /// <summary>
        /// Deploys all assets (i.e., external systems, entity types, and feeds)
        /// represented by types denoted with the appropriate attributes from all currently
        /// loaded assemblies.
        /// </summary>
        /// <param name="context">
        /// The <see cref="IDeploymentContext" /> instance to use.
        /// </param>
        public void Execute(IDeploymentContext context)
        {
            AssetSuite assetSuite = this.assetAssembler.AssembleAssets();

            this.DeployExternalSystems(context, assetSuite.ExternalSystems);
            this.DeployFeeds(context, assetSuite.Feeds);
        }
Ejemplo n.º 2
0
        public AdvancedViewModel(ILumiaSettingsService lumiaSettingsService, IFileSystemOperations fileSystemOperations,
                                 UIServices uiServices, IDeploymentContext context, IOperationContext operationContext, IOperationProgress progress,
                                 IList <Meta <IDiskLayoutPreparer> > diskPreparers,
                                 ILogCollector logCollector)
        {
            this.lumiaSettingsService = lumiaSettingsService;
            this.uiServices           = uiServices;
            this.context      = context;
            this.logCollector = logCollector;

            DiskPreparers = diskPreparers;

            DeleteDownloadedWrapper = new ProgressViewModel(ReactiveCommand.CreateFromTask(() => DeleteDownloaded(fileSystemOperations)), progress, this, uiServices.ContextDialog, operationContext);

            ForceDualBootWrapper = new ProgressViewModel(ReactiveCommand.CreateFromTask(ForceDualBoot), progress, this, uiServices.ContextDialog, operationContext);

            ForceSingleBootWrapper = new ProgressViewModel(ReactiveCommand.CreateFromTask(ForceDisableDualBoot), progress, this, uiServices.ContextDialog, operationContext);

            CollectLogsCommmandWrapper = new ProgressViewModel(ReactiveCommand.CreateFromTask(CollectLogs), progress, this, uiServices.ContextDialog, operationContext);

            IsBusyObservable = Observable.Merge(DeleteDownloadedWrapper.Command.IsExecuting,
                                                ForceDualBootWrapper.Command.IsExecuting, ForceSingleBootWrapper.Command.IsExecuting,
                                                CollectLogsCommmandWrapper.Command.IsExecuting);

            preparerUpdater = this.WhenAnyValue(x => x.SelectedPreparer)
                              .Where(x => x != null)
                              .Subscribe(x =>
            {
                context.DiskLayoutPreparer        = x.Value;
                lumiaSettingsService.DiskPreparer = (string)x.Metadata["Name"];
            });

            SelectedPreparer = GetInitialDiskPreparer();
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Entry point for execution of the step.
 /// </summary>
 /// <param name="context">The step context that can be used to access project related CKSProperties.</param>
 /// <remarks>
 /// This method is executed in a background thread.
 /// </remarks>
 public void Execute(IDeploymentContext context)
 {
     if (context.IsDeploying)
     {
         new ProcessUtilities().RestartIIS(context.Project);
     }
 }
Ejemplo n.º 4
0
 public FetchGitHubBranch(string repositoryUrl, string branchName,
                          IZipExtractor zipExtractor, IDownloader downloader, IGitHubClient gitHubClient,
                          IOperationProgress progressObserver, IDeploymentContext deploymentContext,
                          IFileSystemOperations fileSystemOperations, IOperationContext operationContext) :
     base(repositoryUrl, branchName, zipExtractor, downloader, gitHubClient, progressObserver, deploymentContext, fileSystemOperations, operationContext)
 {
 }
Ejemplo n.º 5
0
 public DeployWindows(IDeploymentContext deploymentContext, IWindowsDeployer deployer, IOperationProgress progressObserver,
                      IFileSystemOperations fileSystemOperations, IOperationContext operationContext) : base(deploymentContext, fileSystemOperations, operationContext)
 {
     this.deploymentContext = deploymentContext;
     this.deployer          = deployer;
     this.progressObserver  = progressObserver;
 }
Ejemplo n.º 6
0
 public RunScript(string scriptPath, IFileSystemOperations fileSystemOperations,
                  IDeploymentContext deploymentContext, IOperationContext operationContext, IScriptRunner scriptRunner, IScriptParser scriptParser) : base(deploymentContext, fileSystemOperations, operationContext)
 {
     this.scriptPath   = scriptPath;
     this.scriptRunner = scriptRunner;
     this.scriptParser = scriptParser;
 }
Ejemplo n.º 7
0
 protected DeploymentTask(IDeploymentContext deploymentContext, IFileSystemOperations fileSystemOperations,
                          IOperationContext operationContext)
 {
     DeploymentContext    = deploymentContext;
     FileSystemOperations = fileSystemOperations;
     OperationContext     = operationContext;
 }
Ejemplo n.º 8
0
 public CopyDirectory(string origin, string destination, IFileSystemOperations fileSystemOperations,
                      IDeploymentContext deploymentContext, IOperationContext operationContext) : base(deploymentContext, fileSystemOperations, operationContext)
 {
     this.origin               = origin;
     this.destination          = destination;
     this.fileSystemOperations = fileSystemOperations;
 }
Ejemplo n.º 9
0
        // Implements IDeploymentStep.CanExecute. Specifies whether the solution can be upgraded.
        public bool CanExecute(IDeploymentContext context)
        {
            // SharePoint returns all the installed solutions names in lower case.
            solutionName     = (context.Project.Package.Model.Name + ".wsp").ToLower();
            solutionFullPath = context.Project.Package.OutputPath;
            bool solutionExists = context.Project.SharePointConnection.ExecuteCommand <string, bool>(
                "Contoso.Commands.IsSolutionDeployed", solutionName);

            // Throw exceptions in error cases because deployment cannot proceed.
            if (context.Project.IsSandboxedSolution)
            {
                string sandboxMessage = "Cannot upgrade the solution. The upgrade deployment configuration " +
                                        "does not support Sandboxed solutions.";
                context.Logger.WriteLine(sandboxMessage, LogCategory.Error);
                throw new InvalidOperationException(sandboxMessage);
            }
            else if (!solutionExists)
            {
                string notDeployedMessage = string.Format("Cannot upgrade the solution. The IsSolutionDeployed " +
                                                          "command cannot find the following solution: {0}.", solutionName);
                context.Logger.WriteLine(notDeployedMessage, LogCategory.Error);
                throw new InvalidOperationException(notDeployedMessage);
            }

            // Execute step and continue with deployment.
            return(true);
        }
Ejemplo n.º 10
0
        public DeploymentViewModel(
            IDeploymentContext context,
            IOperationContext operationContext,
            IWoaDeployer deployer, UIServices uiServices, AdvancedViewModel advancedViewModel,
            WimPickViewModel wimPickViewModel, IFileSystemOperations fileSystemOperations, IRaspberryPiSettingsService raspberryPiSettingsService,
            IDiskRoot diskRoot)
        {
            this.context                    = context;
            this.deployer                   = deployer;
            this.uiServices                 = uiServices;
            this.advancedViewModel          = advancedViewModel;
            this.wimPickViewModel           = wimPickViewModel;
            this.fileSystemOperations       = fileSystemOperations;
            this.raspberryPiSettingsService = raspberryPiSettingsService;

            var isSelectedWim = wimPickViewModel.WhenAnyObservable(x => x.WimMetadata.SelectedImageObs)
                                .Select(metadata => metadata != null);

            FullInstallWrapper = new CommandWrapper <Unit, Unit>(this,
                                                                 ReactiveCommand.CreateFromTask(Deploy, isSelectedWim), uiServices.ContextDialog, operationContext);
            IsBusyObservable = FullInstallWrapper.Command.IsExecuting;
            isBusyHelper     = IsBusyObservable.ToProperty(this, model => model.IsBusy);

            RefreshDisksCommandWrapper = new CommandWrapper <Unit, IList <IDisk> >(this,
                                                                                   ReactiveCommand.CreateFromTask(diskRoot.GetDisks), uiServices.ContextDialog, operationContext);
            disks = RefreshDisksCommandWrapper.Command
                    .Select(x => x.Select(disk => new DiskViewModel(disk)))
                    .ToProperty(this, x => x.Disks);

            this.WhenAnyValue(x => x.SelectedDisk).Where(x => x != null).Subscribe(x => context.Device = new RaspberryPi(x.IDisk));
        }
 /// <summary>
 /// Executes the deployment step.
 /// </summary>
 /// <param name="context">An object that provides information you can use to determine the context in which the deployment step is executing.</param>
 public void Execute(IDeploymentContext context)
 {
     if (context.IsDeploying)
     {
         SharePointPackageArtefact item = new SharePointPackageArtefact(context.Project);
         item.QuickCopy(item, false);
     }
 }
Ejemplo n.º 12
0
 public Flash(string imagePath, IImageFlasher flasher, IDeploymentContext deploymentContext,
              IOperationContext operationContext, IFileSystemOperations fileSystemOperations, IOperationProgress progress) : base(deploymentContext,
                                                                                                                                  fileSystemOperations, operationContext)
 {
     this.imagePath = imagePath;
     this.flasher   = flasher;
     this.progress  = progress;
 }
Ejemplo n.º 13
0
        /// <summary>
        /// Executes the deployment step.
        /// </summary>
        /// <param name="context">An object that provides information you can use to determine the context in which the deployment step is executing.</param>
        public void Execute(IDeploymentContext context)
        {
            Uri        url     = context.Project.SiteUrl;
            WebRequest request = HttpWebRequest.Create(url);

            request.BeginGetResponse(
                a => request.EndGetResponse(a), null);
        }
 /// <summary>
 /// Executes the deployment step.
 /// </summary>
 /// <param name="context">An object that provides information you can use to determine the context in which the deployment step is executing.</param>
 public void Execute(IDeploymentContext context)
 {
     foreach (ISharePointProjectFeature feature in context.Project.Package.Features)
     {
         string relativePath = Path.Combine(feature.UnTokenize(feature.Model.DeploymentPath), "Feature.xml");
         context.Project.SharePointConnection.ExecuteCommand <string>(DeploymentSharePointCommandIds.InstallFeature, relativePath);
     }
 }
Ejemplo n.º 15
0
 public InjectDrivers(string origin, IDeploymentContext context, IWindowsImageService imageService,
                      IDeploymentContext deploymentContext, IFileSystemOperations fileSystemOperations,
                      IOperationContext operationContext) : base(deploymentContext, fileSystemOperations, operationContext)
 {
     this.origin               = origin;
     this.context              = context;
     this.imageService         = imageService;
     this.fileSystemOperations = fileSystemOperations;
 }
Ejemplo n.º 16
0
 /// <summary>
 /// Elevate all commands to the Superuser.
 /// </summary>
 /// <param name="context">Deployment context.</param>
 /// <param name="administratorPassword">Superuser (Admin) password.</param>
 public Sudo(IDeploymentContext context, SecureString administratorPassword)
     : base(context)
 {
     throw new NotImplementedException(); // TODO Figure out how to give password to sudo
     administratorPassword.MakeReadOnly();
     _administratorPassword = administratorPassword;
     _previousValue = Context.RemoteEnv.IsElevated;
     Context.RemoteEnv.IsElevated = true;
 }
        public void Apply(IDeploymentContext deploymentContext)
        {
            var pathToWinApp = deploymentContext.CustomData[this] as string;

            if (pathToWinApp != null)
            {
                _winApp = Process.Start(pathToWinApp);
            }
        }
        /// <summary>
        /// Determines whether the deployment step can be executed in the current context.
        /// </summary>
        /// <param name="context">An object that provides information you can use to determine the context in which the deployment step is executing.</param>
        /// <returns>
        /// true if the deployment step can be executed; otherwise, false.
        /// </returns>
        public bool CanExecute(IDeploymentContext context)
        {
            bool canExecute = false;

            ProjectProperties.ProjectProperties properties = context.Project.Annotations.GetValue <ProjectProperties.ProjectProperties>();
            bool hasScript = properties != null && String.IsNullOrEmpty(properties.ScriptName) == false;

            if (hasScript)
            {
                string powershellKeyPath = @"SOFTWARE\Microsoft\PowerShell\1";
                try
                {
                    RegistryKey powerShellKey = Registry.LocalMachine.OpenSubKey(powershellKeyPath);
                    if (powerShellKey != null)
                    {
                        object installValueObject = powerShellKey.GetValue("Install");
                        try
                        {
                            int installValue = Convert.ToInt32(installValueObject);
                            canExecute = installValue == 1;
                        }
                        catch (FormatException)
                        {
                            context.Logger.WriteLine(
                                @"Unexpected data in PowerShell registry subkey.",
                                LogCategory.Error);
                        }
                    }
                    else
                    {
                        context.Logger.WriteLine(
                            @"PowerShell not installed.",
                            LogCategory.Warning);
                    }
                }
                catch (SecurityException)
                {
                    context.Logger.WriteLine(
                        @"Access to registry key denied: HKLM\" + powershellKeyPath,
                        LogCategory.Error);
                }
            }
            else
            {
                context.Logger.WriteLine(
                    @"No PowerShell script configured for execution.",
                    LogCategory.Warning);
            }
            if (canExecute == false)
            {
                context.Logger.WriteLine(
                    "Skipping PowerShell script deployment step.",
                    LogCategory.Warning);
            }
            return(canExecute);
        }
Ejemplo n.º 19
0
 public WoaDeployer(IScriptRunner scriptRunner, IScriptParser parser, ITooling tooling,
                    IDeploymentContext context,
                    IFileSystemOperations fileSystemOperations)
 {
     this.scriptRunner         = scriptRunner;
     this.parser               = parser;
     this.tooling              = tooling;
     this.context              = context;
     this.fileSystemOperations = fileSystemOperations;
 }
        /// <summary>
        /// Determines whether the deployment step can be executed in the current context.
        /// </summary>
        /// <param name="context">An object that provides information you can use to determine the context in which the deployment step is executing.</param>
        /// <returns>
        /// true if the deployment step can be executed; otherwise, false.
        /// </returns>
        public bool CanExecute(IDeploymentContext context)
        {
            bool canExecute = context.Project.IsSandboxedSolution == false;

            if (canExecute == false)
            {
                context.Logger.WriteLine("Skipping step because the project is configured to deploy into the solution sandbox.", LogCategory.Status);
            }
            return(canExecute);
        }
Ejemplo n.º 21
0
 private void DeployExternalSystems(
     IDeploymentContext context, IEnumerable <ExternalSystemAsset> externalSystems)
 {
     foreach (ExternalSystemAsset externalSystem in externalSystems)
     {
         context.ExternalSystem(externalSystem.Id, externalSystem.Name);
         this.SetExternalSystemParameters(context, externalSystem);
         this.DeployExternalSystemEntityTypes(context, externalSystem);
     }
 }
Ejemplo n.º 22
0
 public Fetch(string url, string destination, IZipExtractor extractor,
              IDownloader downloader, IOperationProgress progressObserver, IDeploymentContext deploymentContext,
              IFileSystemOperations fileSystemOperations, IOperationContext operationContext) : base(deploymentContext, fileSystemOperations, operationContext)
 {
     this.url                  = url;
     this.destination          = destination;
     this.extractor            = extractor;
     this.fileSystemOperations = fileSystemOperations;
     this.downloader           = downloader;
     this.progressObserver     = progressObserver;
 }
Ejemplo n.º 23
0
        public async Task Deploy(IDeploymentContext deploymentContext)
        {
            context = deploymentContext;
            await EnsureFullyUnlocked();

            await DownloadDeploymentScripts();
            await RunDeploymentScript();
            await PatchBootManagerIfNeeded();
            await MoveMetadataToPhone();
            await PreparePhoneDiskForSafeRemoval();
        }
Ejemplo n.º 24
0
 /// <summary>
 /// Executes the deployment step.
 /// </summary>
 /// <param name="context">An object that provides information you can use to determine the context in which the deployment step is executing.</param>
 public void Execute(IDeploymentContext context)
 {
     context.Project.SharePointConnection.ExecuteCommand <SolutionInfo>(
         DeploymentSharePointCommandIds.UpgradeSolution,
         new SolutionInfo()
     {
         IsSandboxedSolution = context.Project.IsSandboxedSolution,
         LocalPath           = context.Project.Package.OutputPath,
         Name = context.Project.Package.Model.Name + ".wsp"
     });
 }
Ejemplo n.º 25
0
        /// <summary>
        /// Determines if the step can be executed in the current context.
        /// </summary>
        /// <param name="context">The step context that can be used to access project related CKSProperties.</param>
        /// <returns></returns>
        /// <exception cref="System.InvalidOperationException"></exception>
        /// <remarks>
        /// This method is executed in a background thread.
        /// </remarks>
        public bool CanExecute(IDeploymentContext context)
        {
            if (context.IsRetracting)
            {
                string sandboxMessage = "Restart IIS cannot Retract.";
                context.Logger.WriteLine(sandboxMessage, LogCategory.Error);
                throw new InvalidOperationException(sandboxMessage);
            }

            return(true);
        }
Ejemplo n.º 26
0
 private void DeployFeeds(IDeploymentContext context, IEnumerable <FeedAsset> feeds)
 {
     foreach (FeedAsset feed in feeds)
     {
         context.Feed(
             feed.EntityType.Id,
             feed.SourceSystem.Id,
             feed.FeedType);
         this.SetEntityTypeSourceSystemParameters(context, feed);
     }
 }
Ejemplo n.º 27
0
 private void SetEntityTypeSharedSourceSystemIdentifiers(
     IDeploymentContext context, EntityTypeAsset entityType)
 {
     foreach (IEnumerable <ExternalSystemAsset> sourceSystems
              in entityType.SharedIdentifierSourceSystems)
     {
         context.SharedSourceSystemIdentifiers(
             entityType.Id,
             sourceSystems.Select(ss => ss.Id).ToArray());
     }
 }
        /// <summary>
        /// Executes the deployment step.
        /// </summary>
        /// <param name="context">An object that provides information you can use to determine the context in which the deployment step is executing.</param>
        public void Execute(IDeploymentContext context)
        {
            ProjectProperties.ProjectProperties properties = context.Project.Annotations.GetValue <ProjectProperties.ProjectProperties>();
            string script = properties.ScriptName;

            context.Logger.WriteLine("Executing script " + script, LogCategory.Status);
            //    Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell");
            //powershell c:\pathtoscript\SingFile.ps1

            //TODO: complete this code as it appears to be missing
        }
 public FetchGitHubLatestReleaseAssetFile(string repoUrl, string assetName,
                                          IGitHubClient gitHubClient, IDownloader downloader, IOperationProgress progressObserver,
                                          IDeploymentContext deploymentContext, IFileSystemOperations fileSystemOperations,
                                          IOperationContext operationContext) : base(deploymentContext,
                                                                                     fileSystemOperations, operationContext)
 {
     this.repoUrl          = repoUrl ?? throw new ArgumentNullException(nameof(repoUrl));
     this.assetName        = assetName ?? throw new ArgumentNullException(nameof(assetName));
     this.gitHubClient     = gitHubClient ?? throw new ArgumentNullException(nameof(gitHubClient));
     this.downloader       = downloader ?? throw new ArgumentNullException(nameof(downloader));
     this.progressObserver = progressObserver ?? throw new ArgumentNullException(nameof(progressObserver));
 }
Ejemplo n.º 30
0
        public async Task DeployAsync(IDeploymentContext context,
                                      IEnumerable <IDeploymentResource> resources,
                                      CancellationToken cancellationToken)
        {
            //
            // Create a map between resources and activities, so we can easily
            // map dependencies later on
            //
            var order = 0;
            var map   = new Dictionary <IDeploymentResource, IDeploymentActivity>();

            foreach (var resource in resources)
            {
                order++;
                var t        = typeof(IDeploymentResourceProvider <>);
                var x        = t.MakeGenericType(resource.GetType());
                var provider = context.DeploymentServices.GetService(x);
                var adaptor  = new DeploymentResourceProviderAdaptor(provider);
                Expression <Func <Task> > expression = () => adaptor.SetAsync(context, resource, cancellationToken);
                var activity = new DeploymentActivity(resource.Key, expression, order);
                map.Add(resource, activity);
            }

            //
            // Add all the acitivies to the graph
            //
            var activityGraph = new Graph <IDeploymentActivity>();

            foreach (var value in map.Values)
            {
                activityGraph.Add(value);
            }

            //
            // Create dependencies between activities
            //
            foreach (var pair in map)
            {
                var resource = pair.Key;
                var activity = pair.Value;

                foreach (var antecedent in resource.Antecedents)
                {
                    var antecedentActivity = map[antecedent];
                    activityGraph.SetAntecedent(activity, antecedentActivity);
                }
            }

            //
            // Execute the activities
            //
            await activityGraph.Walk(activity => activity.ExecuteAsync(), context.Parallel);
        }
Ejemplo n.º 31
0
 /// <summary>
 /// Sets the orphan mapping behavior for the specified entity type.
 /// </summary>
 /// <param name="context">The deployment context.</param>
 /// <param name="entityTypeId">The ID of the entity type.</param>
 /// <param name="behavior">The orphan mapping behavior.</param>
 public static void EntityTypeOrphanMappingBehavior(
     this IDeploymentContext context,
     Guid entityTypeId,
     OrphanMappingBehavior behavior)
 {
     ArgumentValidator.EnsureArgumentNotNull(context, nameof(context));
     ArgumentValidator.EnsureArgumentNotEmpty(entityTypeId, nameof(entityTypeId));
     ValidateOrphanMappingBehavior(behavior);
     context.EntityTypeParameter(
         entityTypeId,
         OrphanMappingBehaviorParameterName,
         behavior.ToString());
 }
Ejemplo n.º 32
0
        internal BasicRemoteOperations(IDeploymentContext context, IHost host)
        {
            Context = context;

            Sftp = new SftpClient(host.Hostname, host.Username, host.Password)
                {
                    OperationTimeout = TimeSpan.FromMinutes(2),
                    ConnectionInfo = {Timeout = TimeSpan.FromMinutes(2)},
                    BufferSize = 1024*16
                };
            Sftp.Connect();

            Shell = new SshClient(host.Hostname, host.Username, host.Password);
            Shell.Connect();
            ShellStream = Shell.CreateShellStream(
                String.Format("{0}@{1}", host.Username, host.Hostname), 0, 0, 0, 0, 1024);
        }
Ejemplo n.º 33
0
 /// <summary>
 /// Create a ContextManager with the current
 /// DeploymentContext setup and teardown should apply
 /// to the given context only.
 /// </summary>
 /// <param name="context"></param>
 protected ContextManager(IDeploymentContext context)
 {
     Context = context;
 }
Ejemplo n.º 34
0
 /// <summary>
 /// Add a new prefix to all commands.
 /// </summary>
 /// <param name="context">Deployment context.</param>
 /// <param name="prefix">Prefix content.</param>
 public Prefix(IDeploymentContext context, string prefix)
     : base(context)
 {
     Context.RemoteEnv.PushPrefix(prefix);
 }
Ejemplo n.º 35
0
 public ConsoleSessionUserInfo(IDeploymentContext context)
 {
     AutoRespondYN = AutoResponse.AlwaysAsk;
 }
Ejemplo n.º 36
0
 internal LoopbackRemoteOperations(IDeploymentContext context, ILocalOperations localOperations)
 {
     Context = context;
     LocalOps = localOperations;
 }
Ejemplo n.º 37
0
 internal LoopbackRemoteOperations(IDeploymentContext context)
     : this(context, new BasicLocalOperations(context))
 {
 }
Ejemplo n.º 38
0
 internal BasicLocalOperations(IDeploymentContext context)
 {
     Context = context;
     _lock = new object();
 }
Ejemplo n.º 39
0
Archivo: Cd.cs Proyecto: nemec/Blossom
 /// <summary>
 /// Change to the given directory on the remote machine.
 /// </summary>
 /// <param name="context">Deployment context.</param>
 /// <param name="path">New current directory.</param>
 public Cd(IDeploymentContext context, IPurePath path)
     : base(context)
 {
     Context.RemoteEnv.Pushd(
         Context.RemoteEnv.CurrentDirectory.Join(path));
 }
Ejemplo n.º 40
0
 public static void Task2(IDeploymentContext context)
 {
 }
Ejemplo n.º 41
0
 public void InitializeDeployment(IDeploymentContext context, NullConfig config)
 {
     Config = config;
     Context = context;
 }