コード例 #1
0
        /// <summary>
        /// Set value for specified registry key with provied Name and Data
        /// </summary>
        /// <param name="nIn">Contains information on path which values need to be changed
        /// as well as Name and Data of value for change (or set if not exists)
        /// If this node does not contain required parameters for execution - ArgumentException is thrown</param>
        /// <returns>DDnode containing result of matching actual and expected results
        /// as well as exception, if there was any</returns>
        public static DDNode SetValue(DDNode nIn)
        {
            var nOut = DrTestActionExt.GetStubActionResultNode();

            try
            {
                nIn.Attributes.ContainsAttributesOtherwiseThrow(SchemaVKRegistry.ATTRIBYTE_NAME_PATH_TO_KEY,
                                                                SchemaVKRegistry.ATTRIBUTE_NAME_VALUE_NAME,
                                                                SchemaVKRegistry.ATTRIBUTE_NAME_VALUE_VALUE);
                WrapperVKRegistry.setValue(nIn.Attributes[SchemaVKRegistry.ATTRIBYTE_NAME_PATH_TO_KEY],
                                           nIn.Attributes[SchemaVKRegistry.ATTRIBUTE_NAME_VALUE_NAME],
                                           nIn.Attributes[SchemaVKRegistry.ATTRIBUTE_NAME_VALUE_VALUE]);


                return(nOut.SetActionResultStatusOK(String.Format(Msg.REGISTRY_SUCCESS_SET_VALUE, nIn.Attributes[SchemaVKRegistry.ATTRIBUTE_NAME_VALUE_NAME],
                                                                  nIn.Attributes[SchemaVKRegistry.ATTRIBUTE_NAME_VALUE_VALUE],
                                                                  nIn.Attributes[SchemaVKRegistry.ATTRIBYTE_NAME_PATH_TO_KEY])));
            }
            catch (Exception e)
            {
                return(nOut.SetActionResultStatusFailed(String.Format(Msg.REGISTRY_FAIL_SET_VALUE, nIn.Attributes[SchemaVKRegistry.ATTRIBUTE_NAME_VALUE_NAME],
                                                                      nIn.Attributes[SchemaVKRegistry.ATTRIBUTE_NAME_VALUE_VALUE],
                                                                      nIn.Attributes[SchemaVKRegistry.ATTRIBYTE_NAME_PATH_TO_KEY]), e));
            }
            finally
            {
                nOut.SetActionResultNodeEndTime();
            }
        }
コード例 #2
0
        private DDNode VMPowerAction(DDNode nIn, WrapperDrVM.vmPowerAction vmPA)
        {
            var nOut = DrTestActionExt.GetStubActionResultNode();

            try
            {
                nIn.Attributes.ContainsAttributesOtherwiseThrow(SchemaDrTestActionVM.ATTRIBUTE_NAME_SERVER_NAME,
                                                                SchemaDrTestActionVM.ATTRIBUTE_NAME_USER_NAME,
                                                                SchemaDrTestActionVM.ATTRIBUTE_NAME_USER_PWD,
                                                                SchemaDrTestActionVM.ATTRIBUTE_NAME_VM_NAME);

                var vm = new WrapperDrVM(nIn.Attributes[SchemaDrTestActionVM.ATTRIBUTE_NAME_SERVER_NAME]);

                vm.LogIn(nIn.Attributes[SchemaDrTestActionVM.ATTRIBUTE_NAME_USER_NAME], nIn.Attributes[SchemaDrTestActionVM.ATTRIBUTE_NAME_USER_PWD]);
                vm.VMChangePowerState(nIn.Attributes[SchemaDrTestActionVM.ATTRIBUTE_NAME_VM_NAME], vmPA);
                vm.Logout();

                return(nOut.SetActionResultStatusOK(string.Format(Msg.VM_SUCCESS_CHANGE_POWER_STATUS, Msg.VM_POWER_STATUS_ON, nIn.Attributes[SchemaDrTestActionVM.ATTRIBUTE_NAME_VM_NAME])));
            }
            catch (Exception e) // should be set Failed status because it's global exception of this action
            {
                return(nOut.SetActionResultStatusFailed(string.Format(Msg.VM_CANNOT_CHANGE_POWER_STATUS, WrapperDrVM.GetVMPowerActionDescription()[vmPA], nIn.Attributes[SchemaDrTestActionVM.ATTRIBUTE_NAME_VM_NAME]), e));
            }
            finally
            {
                nOut.SetActionResultNodeEndTime(); // sets EndTime attribute at the end
            }
        }
コード例 #3
0
        /// <summary>
        /// Creates registry key under specified path
        /// </summary>
        /// <param name="nIn">Contains information on new key path and excepted result of entire operation.
        /// If key under specified path already exists it considers as a failure
        /// If this node does not contain required parameters for execution - ArgumentException is thrown</param>
        /// <returns>DDnode containing result of matching actual and expected results
        /// as well as exception, if there was any</returns>
        public static DDNode CreateKey(DDNode nIn)
        {
            var nOut = DrTestActionExt.GetStubActionResultNode();

            try
            {
                nIn.Attributes.ContainsAttributesOtherwiseThrow(SchemaVKRegistry.ATTRIBYTE_NAME_PATH_TO_KEY);

                WrapperVKRegistry.createKey(nIn.Attributes[SchemaVKRegistry.ATTRIBYTE_NAME_PATH_TO_KEY]);

                return(nOut.SetActionResultStatusOK(String.Format(Msg.REGISTRY_SUCCEESS_CREATE_KEY, nIn.Attributes[SchemaVKRegistry.ATTRIBYTE_NAME_PATH_TO_KEY])));
            }
            catch (Exception e)
            {
                return(nOut.SetActionResultStatusFailed(String.Format(Msg.REGISTRY_FAIL_CREATE_KEY, nIn.Attributes[SchemaVKRegistry.ATTRIBYTE_NAME_PATH_TO_KEY]), e));
            }
            finally
            {
                nOut.SetActionResultNodeEndTime();
            }
        }