Skip to content
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

Merged
merged 56 commits into from
Dec 15, 2017
Merged

Conversation

ericzji
Copy link
Collaborator

@ericzji ericzji commented Nov 21, 2017

The new types and providers added:

  • f5_persistencecookie
  • f5_persistencedestaddr
  • f5_persistencehash
  • f5_persistencesourceaddr
  • f5_persistencessl
  • f5_persistenceuniversal
  • f5_profilehttp
  • f5_profileclientssl
  • f5_profileserverssl
  • f5_sslkey
  • f5_sslcertificate
  • f5_snat
  • f5_snatpool
  • f5_datagroup
  • f5_datagroupexternal

map = {
:'always-send' => :alwaysSend,
:'cookie-encryption' => :cookieEncryption,
:'cookie-name' => :cookieName,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indentation

Copy link
Collaborator Author

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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Delete line

Copy link
Collaborator Author

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,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indentation.

Copy link
Collaborator Author

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('/','~')
Copy link
Contributor

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?

Copy link
Collaborator Author

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

Copy link
Contributor

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.

Copy link
Contributor

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('/','~')
Copy link
Contributor

@alexjfisher alexjfisher Nov 22, 2017

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?

Copy link
Collaborator Author

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?

Copy link
Contributor

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 = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

map isn't used?

Copy link
Collaborator Author

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

Copy link
Contributor

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.

Copy link
Contributor

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.

Copy link
Collaborator Author

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
Copy link
Contributor

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.

Copy link
Collaborator Author

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

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

on every single run...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ericzji @alexjfisher absolutely agreed.

Copy link
Collaborator Author

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

@doc = ' Import SSL Keys'

apply_to_device
ensurable
Copy link
Contributor

@alexjfisher alexjfisher Nov 22, 2017

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.

Copy link
Contributor

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.

Copy link
Collaborator Author

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
Copy link
Contributor

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.

Copy link
Collaborator Author

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

Copy link
Contributor

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')
Copy link
Contributor

@alexjfisher alexjfisher Nov 22, 2017

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?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

strings

Copy link
Contributor

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'.")
Copy link
Contributor

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.

Copy link
Collaborator Author

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

Copy link
Contributor

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.

Copy link
Contributor

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')
Copy link
Contributor

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?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's string

Copy link
Contributor

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

Copy link
Collaborator Author

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."
Copy link
Contributor

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.

Copy link
Collaborator Author

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

Copy link
Contributor

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')
Copy link
Contributor

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?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

Copy link
Contributor

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')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

Copy link
Contributor

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')
Copy link
Contributor

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

Copy link
Contributor

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
Copy link
Contributor

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'))
Copy link
Contributor

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ericzji let's review

require File.expand_path(File.join(File.dirname(__FILE__),'..','..','puppet/property/f5_state.rb'))

Puppet::Type.newtype(:f5_sslcertificate) do
@doc = ' Import SSL Certificates'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stray 'space' before Import

Copy link
Collaborator Author

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',
Copy link
Contributor

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.

Copy link
Collaborator Author

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?

Copy link
Contributor

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.

Copy link
Contributor

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)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need check for idempotency.

Copy link
Collaborator Author

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':
Copy link
Contributor

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.

Copy link
Contributor

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.

@alexjfisher
Copy link
Contributor

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)
Copy link
Contributor

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
Copy link
Contributor

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?

Copy link
Contributor

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.

Copy link
Collaborator Author

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

Copy link
Contributor

@abrader abrader left a 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.

@abrader abrader merged commit 02cdc9c into master Dec 15, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants