-
Notifications
You must be signed in to change notification settings - Fork 30
Accept path parameter in LogicalVolume initialization #64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
lib/linux_admin/logical_volume.rb
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is getting closer but the DEFAULT_PATH should really be defined by the volume group name. Please correct me if I'm wrong... cc/ @brandondunne
If @vg is 'volume_group'
-
LV.create 'lv', @vg, 256.gigabytes
lv.name => 'lv'
lv.path => '/dev/volume_group/lv' -
LV.create '/dev/volume_group/lv', @vg, 256.gigabytes
lv.name => 'lv',
lv.path => '/dev/volume_group/lv'
If @vg is 'vg'
@jrafanie updated |
lib/linux_admin/logical_volume.rb
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry @movitto, I wasn't clear in my description. Is it reasonable to create a LogicalVolume without a @volume_group? I don't think DEFAULT_PATH is needed. I think this else condition is not needed. We should always use the DEVICE_PATH and @volume_group.name to build the build.
@jrafanie updated |
@movitto Looks good other than what I put above... Although I don't know that I like my example that much. I"m sure you can make it better than mine ;-) |
lib/linux_admin/logical_volume.rb
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use parens around method calls.
@Fryguy updated |
lib/linux_admin/logical_volume.rb
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@movitto I have another idea.
You see how you have to check whether a path or name was provided here and also at line 82 below? I think all of this complexity can go away and you can just do LogicalVolume.new :name => name_or_path_value... so the .create method below should be unchanged, I think.
How about something like this:
def initialize(args = {})
@volume_group = args[:volume_group]
@sectors = args[:sectors]
self.path = args[:name] # pass whatever was provided name or path, let the setter method handle it
self.name = args[:name]
...
end
def path=(value)
@path = value.include?(File::SEPARATOR) ? value : DEVICE_PATH.join(@volume_group.name, value)
end
def name=(value)
@name = value.include?(File::SEPARATOR) ? value.split(File::SEPARATOR).last : value
end
@jrafanie good idea, updated |
lib/linux_admin/logical_volume.rb
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe id isn't the right variable name. I think of an numeric value when I think of id. Maybe name (the original) is best. Name can be the name of the lv or the path of the lv.
I think this is ready to merge once updated based on my last comments. |
Other than style differences, it looks good. 👍 |
Accept path parameter in LogicalVolume initialization
No description provided.