[chef] Re: Need help while setting paging file


Chronological Thread 
  • From: Sachin Gupta < >
  • To: Ranjib Dey < >
  • Cc: " " < >
  • Subject: [chef] Re: Need help while setting paging file
  • Date: Wed, 4 Feb 2015 13:12:40 +0530

Hi Ranjib,

Now I am trying to set the initilalSize and MaximumSize  through a batch resource like

   
batch "SetPageFileSize" do
      code <<-EOH
            wmic pagefileset where SettingID="pagefile.sys @ p:" set InitialSize=#{node[:WinTest][:PagingFileSizeMBP]},MaximumSize=#{node[:WinTest][:PagingFileSizeMBP]}')
          EOH
    end
 end

still getting the error of type mismatch, through the values of InitialSize and MaximumSize are correct

C:\>wmic pagefileset where SettingID="pagefile.sys @ p:" set InitialSize=3072.0,
MaximumSize=3072.0')
Updating property(s) of '\\OCIDEVOPS\ROOT\CIMV2:Win32_PageFileSetting.Name
="p:\\pagefile.sys"'
STDERR: ERROR:
Description = Type mismatch.

On Tue, Feb 3, 2015 at 9:57 PM, Ranjib Dey < " target="_blank"> > wrote:
you;ll need to define two attributes for two of those value. convert the mixlib::shellout call to an execute resource.

if node,attribute?(attr1) and node['attr1'].attribute?(attr2)
  command  = "something #{node[attr1][max]}   and #{node[attr1][min]}"
  execute command do
      action :run
  end
end

On Tue, Feb 3, 2015 at 4:29 AM, Sachin Gupta < " target="_blank"> > wrote:
Hi All,

I am running this function through chef recipe to create a paging file. This will check if the paging file is present else will create a paging file in p:\

def CreatingPagingFileP?
 if defined?(node[:WinTest][:CurrentInitialPagingFileSizeMBP]) && (node[:WinTest][:CurrentInitialPagingFileSizeMBP] != '')
 puts "paging file is already present. Nothing to set"
 else
 puts "Need to create the paging file"
    cmd=Mixlib::ShellOut.new('wmic pagefileset create name="p:\pagefile.sys"')
    cmd.run_command
    puts cmd.stdout
    check_for_errors(cmd.stderr)
    puts "max=#{node[:WinTest][:PagingFileSizeMBP]}"
       
    com=Mixlib::ShellOut.new('wmic pagefileset where  SettingID="pagefile.sys @ p:" set InitialSize=2048,MaximumSize=%max%')
    com.run_command
    puts com.stdout
    check_for_errors(com.stderr)
 end

 I would like to parametrize InitialSize and MaximumSize, so that they can be set to values from attribute file.
 I tried setting MaximumSize with options like #{node[:WinTest][:PagingFileSizeMBP]}, %max%, max but nothing is working.
 Can anyone help me in setting these values through a variable.

Thanks & Regards,
Sachin Gupta





Archive powered by MHonArc 2.6.16.

§