-
Notifications
You must be signed in to change notification settings - Fork 27
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
Development for new feature types and providers #18
Conversation
map = { | ||
:'always-send' => :alwaysSend, | ||
:'cookie-encryption' => :cookieEncryption, | ||
:'cookie-name' => :cookieName, |
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.
indentation
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.
updated
|
||
message = strip_nil_values(message) | ||
message = convert_underscores(message) | ||
#message = gen_sflow(message) |
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.
Delete line
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.
updated
:'match-across-virtuals' => :matchAcrossVirtuals, | ||
:'hash-algorithm' => :hashAlgorithm, | ||
:'hash-offset' => :hashOffset, | ||
:'hash-length' => :hashLength, |
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.
Indentation.
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.
Updated
end | ||
|
||
def destroy | ||
full_path_uri = resource[:name].gsub('/','~') |
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.
There's a lot of repetition. Could the full_path_uri
code be moved to the parent provider and shared?
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.
It's possible, but let's take it separately as it applies changes to ALL modules. @abrader
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.
yeah, I guess. With each new type added, the duplicated code becomes more of an issue though.
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.
@alexjfisher good point, discussed this with @ericzji and best suited as a PR of it's own. Will keep you posted.
return [] if profiles.nil? | ||
|
||
profiles.each do |profile| | ||
full_path_uri = profile['fullPath'].gsub('/','~') |
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.
What's this used for?
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.
@alexjfisher Not sure about the question, can you elaborate it?
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.
It's a variable local to instances and is not used. If you were to run rubocop, it would say...
Useless assignment to variable -
full_path_uri
.
message = object.to_hash | ||
|
||
# Map for conversion in the message. | ||
map = { |
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.
map
isn't used?
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.
Not used now, but leave it there for possible future use
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 disagree. Leaving dead unused code everywhere is not helpful.
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 have to agree with @alexjfisher here. If you need to reference the mapping model for there are plenty of providers where you can copy that code at the time of need @ericzji. Unused code in general should be removed. Furthermore we should get you running your code through rubocop.
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.
Removed.
end | ||
|
||
def exists? | ||
@property_hash[:ensure] == :present |
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.
If you don't implement instances
, @property_hash
will never be set.
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.
You are right. In this case, it does not need to. @property_hash[:ensure] not being set, will trigger "create". @abrader
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.
on every single run...
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.
@ericzji @alexjfisher absolutely agreed.
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.
Modified " @property_hash[:ensure] == :present" to "false", and it's tested
lib/puppet/type/f5_sslkey.rb
Outdated
@doc = ' Import SSL Keys' | ||
|
||
apply_to_device | ||
ensurable |
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.
It looks like this type shouldn't use ensurable
.
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.
@ericzji let's review this one more closely today.
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.
updated
def create | ||
result = Puppet::Provider::F5.post("/mgmt/tm/sys/crypto/key", message(resource)) | ||
# We clear the hash here to stop flush from triggering. | ||
@property_hash.clear |
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.
@property_hash
isn't set, so doesn't need clearing.
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 am leaving it to @abrader for comment
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.
@ericzji let's review today
|
||
newproperty(:method) do | ||
desc "Fail Safe Action. Valid values are 'reboot' or 'restart-all'." | ||
newvalues(:'insert', :'passive', 'rewrite') |
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.
Are these strings or symbols?
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.
strings
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 agree with @alexjfisher in that you @ericzji should make all of these symbols (i.e., turn 'rewrite' into :rewrite)
end | ||
|
||
newproperty(:httponly, :parent => Puppet::Property::F5truthy) do | ||
truthy_property("Valid values are 'enabled' or 'disabled'.") |
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.
Having looked at truthy_property
and its use in other types, proper booleans true
and false
should also work. I think the string passed in should describe the property not just say Valid values are 'enabled' or 'disabled'
each time.
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.
only 'enabled' or 'disabled' allowed
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.
No, the whole purpose of truthy_property is to allow true/false to be used. truthy_property munges boolean-like values into enabled/disabled.
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.
@ericzji this is true. @alexjfisher is correct in that you should let the f5_truthy property accept lazy values of what is effectively true or false. This gives user flexibility which is helpful.
|
||
newproperty(:hash_algorithm) do | ||
desc "hash_algorithm." | ||
newvalues(:default, :'carp') |
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.
Why the quotes around the symbol :carp
?
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.
it's string
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.
@ericzji change 'carp' to :carp
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.
updated.
end | ||
|
||
newproperty(:hash_algorithm) do | ||
desc "hash_algorithm." |
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.
If the property name is self explanatory, maybe just omit the desc
.
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.
Will consider, but leave it now
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.
@ericzji we can review this one.
|
||
newproperty(:proxy_ssl, :parent => Puppet::Property::F5truthy) do | ||
desc "Valid values are 'enabled' or 'disabled'." | ||
truthy_property('Fail Safe') |
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.
Is Fail Safe
a good description?
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.
Updated
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.
@ericzji should get all description fields from iControl documentation since it is provided.
|
||
newproperty(:proxy_ssl_passthrough, :parent => Puppet::Property::F5truthy) do | ||
desc "Valid values are 'enabled' or 'disabled'." | ||
truthy_property('Fail Safe') |
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.
ditto
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.
@ericzji same as above.
|
||
newproperty(:peer_cert_mode) do | ||
desc "peer_cert_mode." | ||
newvalues(:'ignore', :'require') |
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.
Quoting rubobop...
Do not use strings for word-like symbol literals
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.
@ericzji please change 'ignore' and 'require' to :ignore and :require accordingly.
ensurable | ||
|
||
newparam(:name) do | ||
def self.postinit |
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've not come across postinit
before. I'd like to understand better what this actually does. @hunner ?
require File.expand_path(File.join(File.dirname(__FILE__),'..','..','puppet/property/f5_description.rb')) | ||
require File.expand_path(File.join(File.dirname(__FILE__),'..','..','puppet/property/f5_health_monitors.rb')) | ||
require File.expand_path(File.join(File.dirname(__FILE__),'..','..','puppet/property/f5_ratio.rb')) | ||
require File.expand_path(File.join(File.dirname(__FILE__),'..','..','puppet/property/f5_state.rb')) |
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.
Are all these requires actually doing anything?
I can see why you need f5_name
and f5_description
. Not sure about the rest though.
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.
@ericzji let's review
lib/puppet/type/f5_sslcertificate.rb
Outdated
require File.expand_path(File.join(File.dirname(__FILE__),'..','..','puppet/property/f5_state.rb')) | ||
|
||
Puppet::Type.newtype(:f5_sslcertificate) do | ||
@doc = ' Import SSL Certificates' |
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.
stray 'space' before Import
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.
Updated
match_across_virtuals => 'enabled', | ||
hash_algorithm => 'carp', | ||
mask => '255.255.0.0', | ||
timeout => '180', |
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.
It'd be good to test the type works with actual integers too.
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.
Would you be more specific? Which one to use integers?
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.
Just in general it'd be nice to confirm in the tests that integer properties do actually work with integers. Same with booleans. It'd be nice to check that you can use either 'enabled' or true.
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.
@ericzji what @alexjfisher is suggesting is that the acceptance tests should confirm valid inputs should be tested. In this case, where values can be a word or an integer. Both should be tested in fairness.
EOS | ||
make_site_pp(pp) | ||
run_device(:allow_changes => true) | ||
|
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.
Need check for idempotency.
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.
Update for both f5_profileclientssl and f5_profileserverssl
run_device(:allow_changes => true) | ||
|
||
# pp2=<<-EOS | ||
# f5_persistencedestaddr { '/Common/dest_addr1': |
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.
Best not to commit large amounts of unrelated commented out code.
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.
@ericzji agreed. Let's get it into a good state or remove it.
For the sake of the project's commit history, it would be nice to at least squash all the README commits. |
|
||
Puppet::Type.type(:f5_sslcertificate).provide(:rest, parent: Puppet::Provider::F5) do | ||
|
||
def create_message(basename, hash) |
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.
create_message
is a method from the parent provider that you're overriding. But why?? It's not used anywhere.
def message(object) | ||
# Allows us to pass in resources and get all the attributes out | ||
# in the form of a hash. | ||
message = object.to_hash |
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.
This seems to be used in a lot of providers. I've no idea why though. object
is already a hash, isn't it?
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.
@ericzji offline please confirm value of object passed in is already hash. Nice find @alexjfisher.
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.
the class for object is Puppet::Type::F5_sslcertificate. Not very clear the structure, but different from hash? @alexjfisher @abrader
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.
Approval granted on the condition that only small, iterative changes and therefore PRs are submitted in the future.
The new types and providers added: