Need help while setting paging file

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

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 guptasachin1112mrt@gmail.com
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

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 dey.ranjib@gmail.com 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 <guptasachin1112mrt@gmail.com

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

the error looks like windows specific, i dont have windows system around :frowning:

check wmic man pages, (InitialSize=3072.0 should that be int? like
InitialSize=3072 )

Yes Ranjib, this was the only mistake. now I have converted 3072.0 to 3072
using .to_i.
Now this function is working fine as expected.

Thanks for your help!!.

Thanks & Regards,
Sachin Gupta

On Wed, Feb 4, 2015 at 1:39 PM, Ranjib Dey dey.ranjib@gmail.com wrote:

the error looks like windows specific, i dont have windows system around
:frowning:

check wmic man pages, (InitialSize=3072.0 should that be int? like
InitialSize=3072 )