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

* add ability to add multiple ip addresses to objects using pattern x… #187

Open
wants to merge 139 commits into
base: maintenance-0.20.x
Choose a base branch
from
Open

Conversation

mdpuma
Copy link

@mdpuma mdpuma commented Nov 9, 2016

No description provided.

@infrastation
Copy link
Member

Please mind the code style.

@mdpuma
Copy link
Author

mdpuma commented Nov 28, 2016

Done.

@infrastation
Copy link
Member

Thank you, this is better. It seems to me genericAssertion() and setFuncMessages() don't need to be called in each iteration. Also have you tested that ip2long(), pack() and the iteration itself work well for IPv4 addresses beyond 127.255.255.255 (INT32_MAX) in 32-bit environment? That used to be a problem when similar code was implemented in RackTables.

@mdpuma
Copy link
Author

mdpuma commented Dec 1, 2016

I do not have any issues with this, on php 5.6.26

@mdpuma
Copy link
Author

mdpuma commented Dec 9, 2016

Can you accept pull request ?

@infrastation
Copy link
Member

This should be one of the next pull requests resolved.

@letnab
Copy link

letnab commented Mar 27, 2017

Add the date of expiration of ip addresses

infrastation and others added 22 commits May 18, 2017 10:05
This optional means of debugging can provide a feedback loop when the
strict SQL mode is not enabled.

* collectMySQLWarnings(): new function to buffer the warnings
* usePreparedInsertBlade(): amend to call the above
* usePreparedDeleteBlade(): idem
* usePreparedUpdateBlade(): idem
* showMySQLWarnings(): new function to display the buffer
* index.php: call the above in the "redirect" case
Amend respective test to fail the right way.

* usePreparedDeleteBlade()
* usePreparedUpdateBlade()
This is how it was originally intended (also update the sample dataset).

* commitAddPortReal(): use nullIfEmptyStr()
* commitUpdatePortReal(): idem
* upgrade.php: queue an UPDATE for 0.21.0
* lastInsertID(): use PDOStatement::fetchColumn()
* getIPv4Stats(): idem
* getIPv6Stats(): idem
* getRackspaceStats(): idem
* sortPortList(): use array_fetch()
Convert a repeated code block to a function, fixup a TD alignment,
simplify portlet rendering, do not show the multiport form if
permissions would not allow to submit.
Address a long-standing glitch: when a port on the currently displayed
object was (or was suggested to be) linked to a port of an object that
had no name, the displayed remote object name would be an empty string.
This change makes the interface display a standard substitute instead,
which among other things makes the remote object hyperlink clickable.

* fetchPortList(): add remote object type ID to the result columns
* renderObjectPortRow(): make use of formatObjectDisplayedName()
* renderPortsForObject(): idem
* findSparePorts(): all of the above
For simpler maintenance the RackTables-specific CSS modifications now
reside in css/codemirror/rackcode.css. Do not include the CSS, HTML,
JavaScript, PHP and SQL CodeMirror tokenizers anymore as they had not
proved to be useful.
This completes the changes done in commit cf5da67.

* renderRackCodeEditor()
* renderTextEditor()
Reimplement the RackCode language mode in rackcode.js using simpler
JavaScript code and define a standalone "rackcode" theme in rackcode.css
instead of overriding the default theme. In renderRackCodeEditor() pass
more properties to CodeMirror constructor and make minor HTML fixups.
In renderRackCodeViewer() rewrite the code to use CodeMirror in read-only
mode and to scroll to requested line on request. Amend the URL format in
refRCLineno() respectively.
There is no reason to specify a default value for $input_name in
printTagsPickerInput() and printTagsPickerUl() so long as
printTagsPicker() is the only function that calls those functions.
A read-only RackTables instance would display an error image instead of
the thumbnail image for any rack that has invalidated thumbnail cache.
This change makes it deliver the thumbnail even if the attempted cache
update failed because of insufficient database permissions.

* RTDBTableAccessDenied: a new exception class
* convertPDOException(): add a respective case block for the error code
* dispatchMiniRackThumbRequest(): use the above for its REPLACE and
  update the comment
infrastation and others added 30 commits August 8, 2017 12:36
The conceptual purpose of usePreparedDeleteBlade() is to delete a
specific, well-defined set of rows from a table. However, Maik Ehinger in
his tag colour code had pointed it out that a hack allowed to delete all
rows from a table like this:

usePreparedDeleteBlade ('TableName', array ('1' => '1'));

Enforce the originally intended semantics in usePreparedDeleteBlade() and
update the other two SQL helper functions for consistency. Update
existing tests and add new tests.

* assertListOfColumnNames(): new function to test if the list items look
  reasonably similar to SQL column names
* makeSetSQL(): replace the previously existing test, which produced a
  generic message, with the new function; escape SQL columns names and
	add some spacing for readability
* makeWhereSQL(): idem
* usePreparedInsertBlade(): escape the table name and switch to
  INSERT ... SET syntax to reuse the code in makeSetSQL()
* usePreparedDeleteBlade(): leave the previously existing test, which
  produces a specific message, before the new test; escape the table name
* usePreparedUpdateBlade(): idem
This provides a temporary means for some users to hide the TD that
contains the tag selector in their RackTables installation. See the
discussion on racktables-users by Gerardo Ferreyra and Helen Browne.

* renderRackspace()
* renderDepot()
* renderIPSpace()
* renderCellList()
The call to usePreparedDeleteBlade() in destroyTag() [expectedly] started
to trigger an exception. However, that call didn't do any useful work
in the first place because a foreign key does not allow to delete a row
from TagTree if there are any dependent rows in TagStorage, this way if a
tag can be deleted it means it is not assigned to any rack or object and
hence its colour does not make any difference to any rack thumbnail.

Without the call that truncates RackThumbnail destroyTag() has no purpose
anymore so delete it and leave the $opspec_list declaration to do the job
through tableHandler() as before.
Conflicts:
wwwroot/inc/config.php
RackTables used to require PHP 5.2.10 or later for several years. As soon
as PHP versions 7.x are the default now it is wrong to claim support for
something that the upstream itself does not support anymore (5.5 is the
oldest supported version on php.net). This upcoming change was announced
on racktables-users on 2017-07-21 and nobody has objected so let's go
ahead.

From now on it is OK to _improve_ RackTables PHP code in ways that break
it on PHP versions 5.2/5.3/5.4 only.
Out of 47 heredoc strings only 11 actually involved PHP variable
interpolation. To make it easier to see what to expect from a random
long literal, denote genuine 11 heredoc instances with double quotes and
convert the other 36 instances to nowdoc.

This syntax was introduced in PHP 5.3.0.
After the testing environment upgrade PHP "7.0" is no longer 7.0.16 or
newer (with PHPUnit 6), it is 7.0.7 with PHPUnit 5, for whatever reason,
so do not run two PHP 7.0 jobs. PHP 7.1 job has PHPUnit 6 and RackTables
PHPUnit tests can sort themselves out whichever PHPUnit version it is.
* renderObject8021QSyncPreview(): move the custom JavaScript code here
This fixes the "802.1Q sync" tab, which was broken; see commit 37095aa.
Make the L2 address regexps strictly uppercase because they are used to
match all-uppercase strings.

In l2addressForDatabase() add handling of IP-over-InfiniBand L2 addresses
(20 bytes long). Change the SunOS-specific notation to apply to MAC
addresses only. It used to apply to WWN addresses too, most likely due to
a copy-and-paste change, and can be restored if there is a genuine use
case for it.

Resize the text inputs in renderPortsForObject() for IPoIB L2 addresses.

Change l2addressFromDatabase() to reject addresses that it would be
impossible to have in the database by normal means.

Rearrange some code for readability and update comments. Add and update
tests as necessary.
In renderDataIntegrityReport() add another check to look for L2 addresses
that have invalid length (there is already an existing check for invalid
characters). Declare and reuse table columns definitions.
Implement RTTestCase::myString() and update the tests to use it instead
of copying code around.
getObjectClass() used to do three different jobs and to accept two to
three arguments, of which the first was always a constant. Split its code
into three smaller and better focused functions with less arguments and
replace a global with a static. Also in the gradient definition convert
the percentage from float to integer to avoid potential issues in future
(see commit c3fe089).

* getObjectClass(): unary or binary function
* getTagClass(): unary function
* getCachedCSSClassForStyle(): binary function
* renderTagRowForEditor(): update as necessary
* getColorSelect(): ditto
* getTagClassName(): ditto
* enableTagsPicker(): ditto
* setEntityColors(): ditto
* printObjectDetailsForRenderRack(): ditto
* renderRack(): ditto
* renderDepot(): ditto
* renderIPSpaceRecords(): ditto
When the worker function outputs its contents normally, the calling
function needs the contents only, the buffer itself is removed, which
is right. When the worker function throws, don't just discard the
contents, remove the buffer too.
Test that renderDepot() has not returned an empty string, it is not much
but more than the mere fact the function managed to return without an
exception. Leave output buffer management to getOutputOf() and exception
handling -- to PHPUnit.

This change makes it possible to see that this test failure on PHP 7.1 is
actually an error (as much as PHPUnit distinguishes "failures" and
"errors") and it occurs the same way on both PHPUnit 5 and PHPUnit 6:

There was 1 error:

1) RenderDepotTest::testRenderDepot
session_start(): Cannot send session cookie - headers already sent by
(output started at /usr/share/php/PHPUnit6/Util/Printer.php:112)
This removes interference with RackTables code trying to send HTTP
headers (with session_start() at least) and should fix RenderDepotTest
on PHP 7.1.
This is one of the changes required for compatibility with PHP 7.1, it
reduces the number of test cases errored due to the warning below and
should fix RenderDepotTest, which was still erroring because of the
output started by the non-numeric warnings.

PHP Warning:  A non-numeric value encountered in .../functions.php
on line 5414
* renderNewRackForm()
* renderEditRSList()
* renderNewVSForm()
In renderVLANDomainListEditor() $dominfo['group_id'] is either NULL or a
string representation of an unsigned integer. Both kinds of values will
evaluate without the conversion as expected in printNiftySelect() and its
worker functions.

In renderEmptyResults() and getPageNumOfIPv6() the value originates from
getConfigVar(), which makes the conversion because the configuration
variable is declared "uint", hence the call is a no-op.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

10 participants