GithubHelp home page GithubHelp logo

opendcim / opendcim Goto Github PK

View Code? Open in Web Editor NEW
291.0 60.0 203.0 100.94 MB

An open source (GPL v3) Data Center Inventory Management (DCIM) application.

Home Page: http://opendcim.org

PHP 84.64% CSS 0.81% JavaScript 14.41% Hack 0.01% HTML 0.14%

opendcim's Introduction

openDCIM

An Open Source Software package for managing the infrastructure of a 
data center, no matter how small or large.  Initially developed 
in-house at Vanderbilt University Information Technology Services by 
Scott Milliken.  

After leaving Vanderbilt for Oak Ridge National Laboratory, Vanderbilt 
granted permission for the package to be open sourced under GPLv3.  
Scott continues as the primary contributor to the package and is 
actively recruiting assistance from others.

    This program is free software:  you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published
    by the Free Software Foundation, version 3.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    For further details on the license, see http://www.gnu.org/licenses

THE CURRENT RELEASE IN GITHUB IS FOR DEVELOPMENT ONLY

Github issues are not for asking questions - use the mailing list for that.

Official Website

Installation

Supposing you are using apache, php and apache-php-module firstly clone openDCIM in a directory which is accessible by apache user (e.g. /srv/http/) and then configure apache to load required modules and have access to project directory (you can define virtual host too).

If you're gonna create Dockerized development environment, you should enable apache's fast-cgi to connect to php-fpm's container

Database (PDO, PDODRIVERS, DB.INC)

Install and Configure Mysql and PHP-Mysql

Follow the guide

Create Database and Configuration File

Create the database and user

	mysql -uroot -p -e "CREATE DATABASE dcim;CREATE USER 'dcim'@'localhost' IDENTIFIED BY 'dcim';GRANT ALL ON dcim.* TO 'dcim'@'localhost';"

Make db.inc.php from db.inc.php-dist

	cp db.inc.php-dist db.inc.php

PHP SNMP Module

Install php-snmp and enable it in /etc/php/php.ini by uncomment or adding the line containing: extension=snmp.so

Apache User Authentication (AUTHENTICATION, REMOTE USER)

Enbale below apache modules:

  • mod_authn_file.so
  • mod_authn_core.so
  • mod_authz_user.so
  • mod_authz_core.so
  • mod_auth_basic.so

Then follow this link To create apache authentication database (such as htpasswd) and enable apache auth in openDCIM directory (e.g. using .htaccess in root). As an example you can follow this instruction (Don't forget to change paths and names to correct onse):

sudo htpasswd -c /etc/httpd/users pouyan
echo 'AuthName "restricted stuff"\nAuthType Basic\nAuthUserFile /etc/httpd/users\nrequire valid-user' > /srv/http/openDCIM

Apache Rewrite (MOD_REWRITE)

Install Apache Rewrite Module and enable it

Run the application

Execute application by openning it in browser and do the installation

Contribution

Contributions are always welcome, please follow these steps to submit your changes:

  1. Install git from http://git-scm.com/

  2. Create a github account on https://github.com

  3. Set up your git ssh key using these instructions http://help.github.com/set-up-git-redirect

  4. Open the openDCIM project home page on github on https://github.com/samilliken/openDCIM/

  5. Click the "Fork" button, this will get you to a new page: your own copy of the code.

  6. Copy the SSH URL at the top of the page and clone the repository on your local machine

    git clone [email protected]:your-username/openDCIM.git my-opendcim-repo
  7. Create a branch and switch to it

    cd my-opendcim-repo
    git branch mynewfeature-patch
    git checkout mynewfeature-patch
  8. Apply your changes, then commit using a meaningful comment, that's the comment everybody will see!

    git add .
    git commit -m "Fixing issue 157, blablabla"
  9. Push the changes back to github (under a different branch, here myfeature-patch)

    git push origin mynewfeature-patch
  10. Open your forked repository on github at https://github.com/your-username/openDCIM

  11. Click "Switch Branches" and select your branch (mynewfeature-patch)

  12. Click "Pull Request"

  13. Submit your pull request to the openDCIM Developers

Translation - i18n

We do not accept any po files directly. Please use the very simple, user friendly web interface at POEditor.

https://poeditor.com/join/project?hash=zBX5TaqBhv

opendcim's People

Contributors

andham89 avatar brimstone avatar btravouillon avatar dmbanke avatar dominikborkowski avatar duhow avatar ericgeldmacher avatar gusenichka avatar hawson avatar jangliss avatar jaroslawp avatar jomigom avatar krishnachaitanya7 avatar m0zes avatar marios-zindilis avatar mattbathje avatar morinpierre avatar mullaneywt avatar pawsey-kbuckley avatar pouyanh avatar samilliken avatar schuups avatar spezialist1 avatar tafthorne avatar themicp avatar timlegge avatar unonu avatar waseem-shaukat avatar wilpig avatar womec avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

opendcim's Issues

Rack request won't complete with empty email

If a contact is not assigned an email address the rack request will not continue. The error is:

PHP Fatal error: Uncaught exception 'Swift_RfcComplianceException' with message 'Address in mailbox given [] does not comply with RFC 2822, 3.6.2.'

Create report to show conflicts in switch/power connection constraints

Will be adding in constraints to prevent duplicate combinations in the switch and power connections, but need to produce a report of conflicts for any users already in the install base.

Also need to add in error checking to display why an insert failed any time that you are setting connections.

Language mapping ability

Currently we edit the following files to change the headings and field titles so it is easier for our staff to read in their native language. It would be wonderfull if we could have a table or xml file or text file which we could edit once to establish the mappings for these field names and title names so we do not need to edit the files every time you release a new version of the PHP files. Below is a list of files we change. I can send you samples if you would like to see our changes (just send me your email address). Thanks.

sidebar.inc.php
cabinets.php
contacts.php
datacenter.php
departments.php
device_classes.php
manufacturers.php
panelmgr.php
powersource.php
reports.php
usermgr.php
storageroom.php
rackrequest.php
timeperiods.php
escalations.php

Allow for site customized voltages

Figure out the best way to allow for multiple voltages (especially internationalization). Not sure if it will be a voltage setting on the panel, or some other customization.

Make color of reserved devices choosable

Add a configuration item and a color picker to the configuration screen for the background color to use when displaying devices that have the reservation box checked.

Undefined offset: 0 in power.inc.php on line 406

Need error checking for anytime an snmp poll or other external command is used to avoid these types of errors.

example: exec( $pollCommand, $namesOutput );

./assets.inc.php
./power.inc.php
./vmware.inc.php

Create master script for calling other periodic functions from CRON

Rather than having CRON entries for multiple scripts, a master script should be created and configured through the web interface that will allow the site admins to select which child scripts to run, and when. The setup instructions would then simply include the step for adding the master script to the crontab to run on the smallest time period allowed (most likely 15 minutes).

Create a setup wizard for first-time setup

Create a setup.php script that will guide the user through the initial setup of a system. It should call the original files and pass a parameter that is checked in PHP and disable the inclusion of the style portions of the header, sidebar, and page definitions. It should cycle through the following entry screens, in this order:

Configuration
Departments
Data Centers
Cabinets

At the end, we'll link to the main page of the wiki, and state that only the bar minimum components have been set up. Consult the wiki for more information about additional features.

Add a version number display somewhere

There is no way to tell what version you are currently running. It should be a field updated in the database whenever an upgrade script is run and is display only on the configuration page, perhaps.

Position picker reversed, shows at top of page

First, the picker shows numbers in ascending order, while the cabinets show items in descending order. This results in incorrect placement.

If you've scrolled down so that the "Position" field is near the top, you'll never see the blade picker, since it's off the visible portion. The popup for the picker should be positioned either near the "Position" field, or at the cursor.

Additional template fields

Allow for templates to include more default values, such as # ports, # power supplies, etc. The ability to override these on a per device basis should also be allowed for.

Add in way to track chassis devices

Perhaps a subtable, similar to the VM's, to track the individual devices. This would need to work not only for blades, but for individual cards in a router chassis, so the subdevices need to have the same capabilities as standalone. Maybe a parent/child relationship.

changepatch.php with auto-populating combo boxes to prevent duplicate connections

When an endpoint device is selected, the "Port on Device" dropdown is automatically populated with a list of ports on that device (based on the number of ports given in the "Physical Infrastructure" portion of the Data Center Device Detail page). If a device port has already been assigned to a network patch connection, it is listed but it is grayed out and it is not selectable.

<?php
    require_once( 'db.inc.php' );
    require_once( 'facilities.inc.php' );

    $user=new User();

    $user->UserID=$_SERVER['REMOTE_USER'];
    $user->GetUserRights( $facDB );

    if(!$user->WriteAccess || ((!isset($_REQUEST['switchid']) && !isset($_REQUEST['portid'])))){
        // No soup for you.
        header('Location: '.redirect());
        exit;
    }

    $switchDev=new Device();
    $switchDev->DeviceID=$_REQUEST['switchid'];
    $switchDev->GetDevice($facDB);

    $connect=new SwitchConnection();
    $connect->SwitchDeviceID=$switchDev->DeviceID;
    $connect->SwitchPortNumber=$_REQUEST['portid'];
        $connect->GetSwitchPortConnector($facDB);

        $endpointDev=new Device();
    if (isset($_REQUEST['endpointdeviceid'])) {
            $endpointDev->DeviceID=$_REQUEST['endpointdeviceid'];
    }else{
        $endpointDev->DeviceID=$connect->EndpointDeviceID;
    }
        $endpointDev->GetDevice($facDB);

    if(isset($_REQUEST['action'])){
        if($_REQUEST['action']=="Save"){
            $connect->SwitchDeviceID=$_REQUEST['switchid'];
            $connect->SwitchPortNumber=$_REQUEST['portid'];
            $connect->EndpointDeviceID=$_REQUEST['endpointdeviceid'];
            $connect->EndpointPort=$_REQUEST['endpointport'];
            $connect->Notes=$_REQUEST['notes'];

            if( $_REQUEST['state']=="new" ){
                $connect->CreateConnection($facDB);
            }else{
                $connect->UpdateConnection($facDB);
            }
        }elseif($_REQUEST['action']=="Delete"){
            $connect->RemoveConnection($facDB);
        }
        header('Location: '.redirect("devices.php?deviceid=$connect->SwitchDeviceID"));
        exit;
    }

    $patchCandidates=$switchDev->CreatePatchCandidateList($facDB);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title>openDCIM Network Patch</title>
  <link rel="stylesheet" href="css/inventory.css" type="text/css">
  <link rel="stylesheet" href="css/jquery-ui-1.8.18.custom.css" type="text/css">
  <!-- <link rel="stylesheet" href="http://code.jquery.com/mobile/1.1.1/jquery.mobile-1.1.1.min.css" /> -->
  <link rel="stylesheet" href="css/validationEngine.jquery.css" type="text/css">
  <!--[if lt IE 9]>
  <link rel="stylesheet"  href="css/ie.css" type="text/css" />
  <![endif]-->
  <script type="text/javascript" src="scripts/jquery.min.js"></script>
  <script type="text/javascript" src="scripts/jquery-ui-1.8.18.custom.min.js"></script>
  <!-- <script src="http://code.jquery.com/mobile/1.1.1/jquery.mobile-1.1.1.min.js"></script> -->
  <script type="text/javascript" src="scripts/jquery.validationEngine-en.js"></script>
  <script type="text/javascript" src="scripts/jquery.validationEngine.js"></script>
  <script type="text/javascript">
    $(function(){
        $('#patchform').validationEngine({});
    });
  </script>

  <script type="text/javascript">

    // Case-insensitive "contains" function
    jQuery.expr[':'].nocasecontains = function(a,i,m){
      return (a.textContent || a.innerText || "").toUpperCase().indexOf(m[3].toUpperCase())>=0;
    };

    $(document).ready(function(){
      //$("#statusline").html("Choose a device to see available ports on that device");
      //$("#endpointport").hide();

      $("#endpointdeviceid").change( function() {
        $("#endpointport").hide();
        $("#statusline").html('Getting ports...');
        $.ajax({
           type: "POST",
           data: "endpointdeviceid=" + $(this).val() + "&endpointport=" + <?php echo ( $connect->EndpointPort?$connect->EndpointPort:(-1) ); ?>,
           url: "./populate_endpointports_dropdown.php",
           success: function(msg){
             if (msg != ""){
               $("#endpointport").html(msg).show();
               $("#statusline").html('');
             }
             else{
               $("#statusline").html("Choose a device to see available ports on that device");
             }
           }
        });
     });

     $("#devicefilter").keyup( function() {
       filter = $(this).val();
       if (filter) {
         $("#endpointdeviceid").find("option:not(:nocasecontains(" + filter + "))").hide();
         $("#endpointdeviceid").find("option:nocasecontains(" + filter + ")").show();
       } else {
         $("#endpointdeviceid").find("option").show();
       }
     });

     $("#endpointdeviceid").trigger("change");

    });    

  </script>

</head>
<body>
<div id="header"></div>
<div class="page">
<?php
    include( 'sidebar.inc.php' );
?>
<div class="main">
<h2><?php echo $config->ParameterArray['OrgName']; ?></h2>
<h3>Network Patch Connection</h3>
<p align="center" id="statusline"></p>
<div class="center"><div>
<form id="patchform" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<input type="hidden" name="switchid" value="<?php echo $connect->SwitchDeviceID; ?>">
<input type="hidden" name="portid" value="<?php echo $connect->SwitchPortNumber; ?>">

<?php
    if(($connect->EndpointDeviceID==0) OR ($connect->EndpointPort==0)){
        echo '<input type="hidden" name="state" value="new">';
    }
?>

<div class="table">
    <div>
        <div>Filter by Device Name</div>
        <div><input type="text" name="devicefilter" id="devicefilter" value=""></div>
    </div>
    <div>
        <div><label for="endpointdeviceid">Device Attached</label></div>
        <div><select name="endpointdeviceid" id="endpointdeviceid" multiple size="5"><option value=-1>No Connection</option>
<?php
        foreach($patchCandidates as $key=>$devRow){
            print "     <option value=$devRow->DeviceID";
            if($connect->EndpointDeviceID==$devRow->DeviceID){
                echo ' selected="selected"';
            }
            print ">$devRow->Label</option>\n";
        }
?>
        </select></div>
    </div>
    <div>

        <div><label for="endpointport">Endpoint Device Port</label></div>
        <div>
        <select name="endpointport" id="endpointport"><option value=-1>No Connection</option>
        </select>
        </div>
    </div>
    <div>
        <div><label for="notes">Notes</label></div>
        <div><textarea name="notes" id="notes" rows="5"><?php echo $connect->Notes; ?></textarea></div>
    </div>
    <div class="caption">
        <input type="submit" name="action" value="Save">
        <button type="button" onClick="location='<?php print redirect();?>'" value="Cancel">Cancel</button>
        <button type="submit" name="action" value="Delete">Delete</button>
    </div>
</div><!-- END div.table -->
</form>
</div></div>
<?php print "<br>\n   <a href=\"".redirect()."\">[Return to Device]</a>";?>
</div><!-- END div.main -->
</div><!-- END div.page -->



</body>
</html>

This enhancement requires populate_endpoints_dropdown.php:

<?php
    require_once( 'db.inc.php' );
    require_once( 'facilities.inc.php' );

        $endpointDev=new Device();

    if (isset($_POST["endpointdeviceid"]) ){
            $endpointDev->DeviceID=$_POST["endpointdeviceid"];
    }

        $endpointDev->GetDevice($facDB);

    $portCandidates=$endpointDev->GetDevicePorts($facDB);
        foreach($portCandidates as $key=>$devRow){
                        echo '<option value="'.$devRow->EndpointPort.'"';

            if (isset($_POST["endpointport"]) && ($devRow->EndpointPort==$_POST["endpointport"])){
                    echo ' selected';
            }

            if ($devRow->SwitchDeviceID <> "") {
                echo ' disabled';
            }

                    echo '>'.$devRow->EndpointPort ;
            if ($devRow->SwitchDeviceID <> "") {
                echo ' (assigned)';
            }
            echo '</option>';
                }
?>

Colorize equipment by owner

It would be very nice to have a device pick up a color assigned to a department and the all devices assigned to that department can pick up that color.

RackRequests not inserting into db table

When creating a new RackRequest the "Label" field displays a list of entries if double clicked on when using firefox for one user. But for other users which have full access (all boxes ticked) the Label field does not display anything when double clicked. In RackRequests when a label is manually keyed in and the remaining details entered, an email is sent when the "create" button is clicked, but no entry appears in the mysql table rackrequests. Also when you click on the link in the email it takes you to the rackrequest page with rackrequestid=0 but no detail is displayed. No errors show up in the apache or mysql error log either when set to debug.
Is the "Label" field supposed to show a drop down list of selectable items when double clicked ?
What can I try to debug this further ?

Enhanced devices.php using jQuery accordion attribute

Using jQuery's accordion layout for easier viewing on small screens

<?php
    require_once( 'db.inc.php' );
    require_once( 'facilities.inc.php' );

    $dev=new Device();
    $cab=new Cabinet();
    $user=new User();
    $contact=new Contact();

    $user->UserID=$_SERVER['REMOTE_USER'];
    $user->GetUserRights( $facDB );

    if(!$user->ReadAccess){
        // No soup for you.
        header('Location: '.redirect());
        exit;
    }

    // These objects are used no matter what operation we're performing
    $templ=new DeviceTemplate();
    $mfg=new Manufacturer();
    $esc=new Escalations();
    $escTime=new EscalationTimes();
    $contactList=$contact->GetContactList($facDB);
    $Dept=new Department();
    $pwrCords=null;

    // This page was called from somewhere so let's do stuff.
    // If this page wasn't called then present a blank record for device creation.
    if(isset($_REQUEST['action'])||isset($_REQUEST['deviceid'])){
        if(isset($_REQUEST['action'])&&$_REQUEST['action']=='new'){
            // Some fields are pre-populated when you click "Add device to this cabinet"
            if(isset($_REQUEST['cabinet'])){
                $dev->Cabinet = $_REQUEST['cabinet'];
            }
        }
        // if no device id requested then we must be making a new device so skip all data lookups.
        if(isset($_REQUEST['deviceid'])){
            $dev->DeviceID=$_REQUEST['deviceid'];
            // If no action is requested then we must be just querying a device info.
            // Skip all modification checks
            if(isset($_REQUEST['action'])){
                if($user->WriteAccess&&(($dev->DeviceID >0)&&($_REQUEST['action']=='Update'))){
                    $dev->Label=$_REQUEST['label'];
                    $dev->SerialNo=$_REQUEST['serialno'];
                    $dev->AssetTag=$_REQUEST['assettag'];
                    $dev->PrimaryIP=$_REQUEST['primaryip'];
                    $dev->SNMPCommunity=$_REQUEST['snmpcommunity'];
                    $dev->ESX=$_REQUEST['esx'];
                    $dev->Owner=$_REQUEST['owner'];
                    $dev->EscalationTimeID=$_REQUEST['escalationtimeid'];
                    $dev->EscalationID=$_REQUEST['escalationid'];
                    $dev->PrimaryContact=$_REQUEST['primarycontact'];
                    $dev->Cabinet=$_REQUEST['cabinetid'];
                    $dev->Position=$_REQUEST['position'];
                    $dev->Height=$_REQUEST['height'];
                    $dev->Ports=$_REQUEST['ports'];
                    $dev->TemplateID=$_REQUEST['templateid'];
                    $dev->PowerSupplyCount=$_REQUEST['powersupplycount'];
                    $dev->DeviceType=$_REQUEST['devicetype'];
                    $dev->MfgDate=date('Y-m-d',strtotime($_REQUEST['mfgdate']));
                    $dev->InstallDate=date('Y-m-d',strtotime($_REQUEST['installdate']));
                    $dev->Notes=$_REQUEST['notes'];
                    $dev->Reservation = ( $_REQUEST['reservation'] == "on" ) ? 1 : 0;
                    $dev->NominalWatts=$_REQUEST['nominalwatts'];

                    if (( $dev->TemplateID > 0 ) && ( intval( $dev->NominalWatts == 0 )))
                        $dev->UpdateWattageFromTemplate($facDB);

                    if($dev->Cabinet <0){
                        $dev->MoveToStorage($facDB);
                    }else{
                        $dev->UpdateDevice($facDB);
                    }
                }elseif($user->WriteAccess&&($_REQUEST['action']=='Create')){
                    $dev->Label=$_REQUEST['label'];
                    $dev->SerialNo=$_REQUEST['serialno'];
                    $dev->AssetTag=$_REQUEST['assettag'];
                    $dev->PrimaryIP=$_REQUEST['primaryip'];
                    $dev->SNMPCommunity=$_REQUEST['snmpcommunity'];
                    $dev->ESX=$_REQUEST['esx'];
                    $dev->Owner=$_REQUEST['owner'];
                    $dev->EscalationTimeID=$_REQUEST['escalationtimeid'];
                    $dev->EscalationID=$_REQUEST['escalationid'];
                    $dev->PrimaryContact=$_REQUEST['primarycontact'];
                    $dev->Cabinet=$_REQUEST['cabinetid'];
                    $dev->Position=$_REQUEST['position'];
                    $dev->Height=$_REQUEST['height'];
                    $dev->Ports=$_REQUEST['ports'];
                    $dev->TemplateID=$_REQUEST['templateid'];
                    $dev->PowerSupplyCount=$_REQUEST['powersupplycount'];
                    $dev->DeviceType=$_REQUEST['devicetype'];
                    $dev->MfgDate=date('Y-m-d',strtotime($_REQUEST['mfgdate']));
                    $dev->InstallDate=date('Y-m-d',strtotime($_REQUEST['installdate']));
                    $dev->Notes=$_REQUEST['notes'];
                    $dev->Reservation = ( $_REQUEST['reservation'] == "on" ) ? 1 : 0;
                    $dev->CreateDevice($facDB);
                }elseif($user->DeleteAccess&&($_REQUEST['action']=='Delete')){
                    $dev->GetDevice($facDB);
                    $dev->DeleteDevice($facDB);
                    header('Location: '.redirect("cabnavigator.php?cabinetid=$dev->Cabinet"));
                    exit;
                }
            }

            // Finished updating devices or creating them.  Refresh the object with data from the DB
            $dev->GetDevice($facDB);

            // Since a device exists we're gonna need some additional info
            $pwrConnection = new PowerConnection();
            $pdu = new PowerDistribution();
            $panel = new PowerPanel();
            $networkPatches = new SwitchConnection();

            $pwrConnection->DeviceID=$dev->DeviceID;
            $pwrCords=$pwrConnection->GetConnectionsByDevice($facDB);

            if($dev->DeviceType=='Switch'){
                $networkPatches->SwitchDeviceID=$dev->DeviceID;
                $patchList=$networkPatches->GetSwitchConnections($facDB);
            }else{
                $networkPatches->EndpointDeviceID=$dev->DeviceID;
                $patchList=$networkPatches->GetEndpointConnections($facDB);
            }
        }
        $cab->CabinetID=$dev->Cabinet;
    }

    $templateList=$templ->GetTemplateList($facDB);
    $escTimeList=$escTime->GetEscalationTimeList($facDB);
    $escList=$esc->GetEscalationList($facDB);
    $deptList=$Dept->GetDepartmentList($facDB); 

    // We have a slight issue with width if we get a really long escalation name
    $widthfix=0;
    foreach($escList as $tmp){
        if(strlen($tmp->Details)>30){
            if(strlen($tmp->Details)>$widthfix){
                $widthfix=strlen($tmp->Details);
            }
        }
    }
    foreach($deptList as $tmp){
        if(strlen($tmp->Name)>30){
            if(strlen($tmp->Name)>$widthfix){
                $widthfix=strlen($tmp->Name);
            }
        }
    }
    // 1150 default width 
    // add 10px per character over 30
    // 10px with a base font of 12px is 0.833em
    if($widthfix>0){$widthfix2=(($widthfix)*0.75);
    $widthfix=(($widthfix2*2)+18);
    $css="<style type=\"text/css\">div.page.device {min-width:{$widthfix}em;}.device div.left, .device div.right {max-width:{$widthfix2}em;}</style>\n";}else{$css="";}

?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title>openDCIM Device Maintenance</title>
  <link rel="stylesheet" href="css/inventory.css" type="text/css">
  <link rel="stylesheet" href="css/jquery-ui-1.8.18.custom.css" type="text/css">
  <!-- <link rel="stylesheet" href="css/jquery.mobile-1.1.1.min.css"  type="text/css" > -->
  <link rel="stylesheet" href="css/validationEngine.jquery.css" type="text/css">
  <!--[if lt IE 9]>
  <link rel="stylesheet"  href="css/ie.css" type="text/css" />
  <![endif]-->
  <?php echo $css; ?>
  <script type="text/javascript" src="scripts/jquery.min.js"></script>
  <script type="text/javascript" src="scripts/jquery-ui-1.8.18.custom.min.js"></script>
  <!-- <script type="text/javascript" src="scripts/jquery.mobile-1.1.1.min.js"></script> -->
  <script type="text/javascript" src="scripts/jquery.timepicker.js"></script>
  <script type="text/javascript" src="scripts/jquery.validationEngine-en.js"></script>
  <script type="text/javascript" src="scripts/jquery.validationEngine.js"></script>

<script type="text/javascript">
function showDeptContacts(formname) {
    alert ("showDeptContacts");
    var deptid=formname.elements['owner'];
    var popurl="contactpopup.php?deptid="+deptid.value;
    window.open( popurl, "window", "width=800, height=700, resizable=no, toolbar=no" );
}

function updateFromTemplate(formname) {
    var tmplHeight=new Array();

    var sel=formname.elements['templateid'];

    var xmlhttp;
    var template;
    if (window.XMLHttpRequest) {
        // code for IE7+, Firefox, Chrome, Opera, Safari
        xmlhttp=new XMLHttpRequest();
    } else {
        // code for IE6, IE5
        xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    }

    xmlhttp.onreadystatechange=function() {
        if (xmlhttp.readyState==4 && xmlhttp.status==200) {
            template=eval("("+xmlhttp.responseText+")");
            formname.elements['height'].value=template.Height;
            formname.elements['nominalwatts'].value=template.Wattage;
            formname.elements['powersupplycount'].value=template.PSCount;
            formname.elements['ports'].value=template.NumPorts;

            switch ( template.DeviceType ) {
                case "Server":
                    formname.elements['devicetype'].selectedIndex = 1;
                    break;
                case "Appliance":
                    formname.elements['devicetype'].selectedIndex = 2;
                    break;
                case "Storage Array":
                    formname.elements['devicetype'].selectedIndex = 3;
                    break;
                case "Switch":
                    formname.elements['devicetype'].selectedIndex = 4;
                    break;
                case "Routing Chassis":
                    formname.elements['devicetype'].selectedIndex = 5;
                    break;
                case "Patch Panel":
                    formname.elements['devicetype'].selectedIndex = 6;
                    break;
                default:
                    formname.elements['devicetype'].selectedIndex = 7;
            }
        }
    }

    xmlhttp.open("GET","scripts/ajax_template.php?q="+sel.options[sel.selectedIndex].value,true);
    xmlhttp.send();

}

$(function(){
    $('#deviceform').validationEngine({});
    $('#mfgdate').datepicker({});
    $('#installdate').datepicker({});
});

}
</script>

<script type="text/javascript">
/* 
IE work around
http://stackoverflow.com/questions/5227088/creating-style-node-adding-innerhtml-add-to-dom-and-ie-headaches
*/

function setCookie(c_name, value) {
    var exdate=new Date();
    exdate.setDate(exdate.getDate() + 365);
    var c_value=escape(value) + ";expires="+exdate.toUTCString();
    document.cookie=c_name + "=" + c_value;
}

function swaplayout(){
    var sheet = document.createElement('style');
    sheet.type = 'text/css';
    if (sheet.styleSheet) { // IE
        sheet.styleSheet.cssText = ".device div.left { display: block; }";
        document.getElementById('layout').innerHTML = "Landscape";
    } else {
        sheet.innerHTML = ".device div.left { display: block; }";
        document.getElementById('layout').innerHTML = "Landscape";
    }
    var s = document.getElementsByTagName('style')[0];
    if (s.innerHTML == sheet.innerHTML){
        if (sheet.styleSheet){ //IE
            document.getElementsByTagName('style')[0].styleSheet.cssText = "";
            document.getElementById('layout').innerHTML = "Portrait";
        }else{
            document.getElementsByTagName('style')[0].innerHTML = "";
            document.getElementById('layout').innerHTML = "Portrait";
        }
        setCookie("layout","Landscape");
    }else{
        s.parentNode.insertBefore(sheet, s);
        setCookie("layout","Portrait");
    }
}

function setPreferredLayout() {<?php if(isset($_COOKIE["layout"]) && strtolower($_COOKIE["layout"])==="portrait"){echo 'swaplayout();setCookie("layout","Portrait");';}else{echo 'setCookie("layout","Landscape");';} ?>}

$(function() {
    $( "#accordion" ).accordion( {
            autoHeight: false
        });
});

$(document).bind('pageinit',function(event){
    $("#serialno").taphold( function() {
        alert("Ow!");
        var scanCode = function() {
            window.plugins.barcodeScanner.scan(
                function(result) { alert ("Scanned Code: " + result.text + " Format: " + result.format + " Cancelled: " + result.cancelled); $("#serialno").val(result.text) }, 
                function(error) { alert ("Scan failed: " + error); }
            )};
    });

    $("#showdepartmentcontacts").click(function() {
        alert ("showDeptContacts");
        var deptid=formname.elements['owner'];
        var popurl="contactpopup.php?deptid="+deptid.value;
        window.open( popurl, "window", "width=800, height=700, resizable=no, toolbar=no" );
    });

});


function getScanCode() {
    var scanCode = function() {
            window.plugins.barcodeScanner.scan(
                function(result) { alert ("Scanned Code: " + result.text + " Format: " + result.format + " Cancelled: " + result.cancelled); $("#serialno").text(result.text) }, 
                function(error) { alert ("Scan failed: " + error); }
            );
        }
}

</script>

</head>
<body onLoad="setPreferredLayout()">
    <div class="page device">
<?php
    include( 'sidebar.inc.php' );
?>
        <div class="main">
            <button id="layout" onClick="swaplayout()">Portrait</button>
            <h2><?php echo $config->ParameterArray['OrgName']; ?></h2>
            <h3>Data Center Device Detail</h3>
                <form name="deviceform" id="deviceform" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST">
                    <div id="accordion">

                        <h3><a href="#">Asset Tracking</a></h3>
                        <fieldset>
                            <div class="table">
                                <div>
                                    <div>Device ID</div>
                                    <div><input type="text" name="deviceid" value="<?php echo $dev->DeviceID; ?>" size="6" readonly></div>
                                </div>
                                <div>
                                    <div><label for="reservation">Reservation?</label></div>
                                    <div><input type="checkbox" name="reservation" id="reservation"<?php if($dev->Reservation){echo " checked";}?>></div>
                                </div>
                                <div>
                                    <div><label for="label">Label</label></div>
                                    <div><input type="text" class="validate[required,minSize[3],maxSize[50]]" name="label" id="label" size="40" value="<?php echo $dev->Label; ?>"></div>
                                </div>
                                <div>
                                    <div><label for="serialno">Serial Number</label></div>
                                    <div><input type="text" name="serialno" id="serialno" size="40" value="<?php echo $dev->SerialNo; ?>" onClick="getScanCode();"></div>
                                </div>
                                <div>
                                    <div><label for="assettag">Asset Tag</label></div>
                                    <div><input type="text" name="assettag" id="assettag" size="20" value="<?php echo $dev->AssetTag; ?>"></div>
                                </div>
                                <div>
                                    <div><label for="mfgdate">Manufacture Date</label></div>
                                    <div><input type="date" class="validate[optional,custom[date]] datepicker" name="mfgdate" id="mfgdate" value="<?php if ( $dev->MfgDate > '0000-00-00 00:00:00' ) echo date( 'm/d/Y', strtotime( $dev->MfgDate ) ); ?>"></div>
                                </div>
                                <div>
                                    <div><label for="installdate">Install Date</label></div>
                                    <div><input type="date" class="validate[required,custom[date]] datepicker" name="installdate" id="installdate" value="<?php if ( $dev->InstallDate > '0000-00-00 00:00:00' ) echo date( 'm/d/Y', strtotime( $dev->InstallDate ) ); ?>"></div>
                                </div>
                                <div>
                                    <div><label for="owner">Departmental Owner</label></div>
                                    <div>
                                        <select name="owner" id="owner">
                                        <option value=0>Unassigned</option>
<?php
            foreach($deptList as $deptRow){
                echo "          <option value=\"$deptRow->DeptID\"";
                if($dev->Owner == $deptRow->DeptID){echo ' selected="selected"';}
                echo ">$deptRow->Name</option>\n";
            }
?>
                                        </select>
                                        <button type="button" id="showdepartmentcontacts" onclick="showDeptContacts(this.form);">Show Contacts</button>
                                    </div>
                                </div>
                                <div>
                                    <div>
                                        <fieldset>
                                            <legend>Escalation Information</legend>
                                            <div class="table">
                                                <div>
                                                    <div><label for="escaltationtimeid">Time Period</label></div>
                                                    <div>
                                                        <select name="escalationtimeid" id="escalationtimeid">
                                                            <option value="">Select...</option>
<?php
                foreach($escTimeList as $escTime){
                    print "             <option value=\"$escTime->EscalationTimeID\"";
                    if($escTime->EscalationTimeID==$dev->EscalationTimeID){ echo ' selected="selected"';}
                    print ">$escTime->TimePeriod</option>\n";
                }
?>
                                                        </select>
                                                    </div>
                                                </div>
                                                <div>
                                                    <div><label for="escalationid">Details</label></div>
                                                    <div>
                                                        <select name="escalationid" id="escalationid">
                                                            <option value="">Select...</option>
<?php
                foreach($escList as $esc){                  print "             <option value=\"$esc->EscalationID\"";
                    if($esc->EscalationID==$dev->EscalationID){ echo ' selected="selected"';}
                    print ">$esc->Details</option>\n";
                }
?>
                                                        </select>
                                                    </div>
                                                </div>
                                            </div>
                                        </fieldset>
                                    </div>
                                    </div>
                                <div>
                                    <div><label for="primarycontact">Primary Contact</label></div>
                                    <div>
                                        <select name="primarycontact" id="primarycontact">
                                            <option value=0>Unassigned</option>
<?php
            foreach($contactList as $contactRow){
                print "         <option value=\"$contactRow->ContactID\"";
                if($contactRow->ContactID==$dev->PrimaryContact){$contactUserID=$contactRow->UserID;echo ' selected="selected"';}
                print ">$contactRow->LastName, $contactRow->FirstName</option>\n";
            }
?>          
                                        </select>
<?php
            if(isset($config->ParameterArray['UserLookupURL']) && eregi($urlregex, $config->ParameterArray['UserLookupURL']) && isset($contactUserID)){
                echo "<input type=\"button\" value=\"Contact Lookup\" onclick=\"window.open( '".$config->ParameterArray["UserLookupURL"]."$contactUserID', 'UserLookup')\">\n";
            }
?>
                                    </div>
                                </div>  
                            </div>
                        </fieldset> 

                        <h3><a href="#">Notes</a></h3>
                        <div>
                            <textarea name="notes" id="notes" cols="40" rows="8"><?php echo $dev->Notes; ?></textarea>
                        </div>

                        <h3><a href="#">Physical Infrastructure</a></h3>
                        <fieldset>
                            <div class="table">
                                <div>
                                    <div><label for="cabinet">Cabinet</label></div>
                                    <div><?php echo $cab->GetCabinetSelectList($facDB);?></div>
                                </div>
                                <div>
                                    <div><label for="templateid">Device Class</label></div>
                                    <div>
                                        <select name="templateid" id="templateid" onchange="updateFromTemplate(deviceform)">
                                            <option value=0>Select a template...</option>
<?php
            foreach($templateList as $tempRow){
                print "         <option value=\"$tempRow->TemplateID\"";
                if($dev->TemplateID==$tempRow->TemplateID){echo ' selected="selected"';}
                $mfg->ManufacturerID=$tempRow->ManufacturerID;
                $mfg->GetManufacturerByID( $facDB );
                print ">$mfg->Name - $tempRow->Model</option>";
            }
?>
                                        </select>
                                    </div>
                                </div>
                                <div>
                                    <div><label for="position">Position</label></div>
                                    <div><input type="number" class="required,validate[custom[onlyNumberSp]]" name="position" id="position" size="4" value="<?php echo $dev->Position; ?>"></div>
                                </div>
                                <div>
                                    <div><label for="height">Height</label></div>
                                    <div><input type="number" class="required,validate[custom[onlyNumberSp]]" name="height" id="height" size="4" value="<?php echo $dev->Height; ?>"></div>
                                </div>
                                <div>
                                    <div><label for="ports">Number of Data Ports</label></div>
                                    <div><input type="number" class="optional,validate[custom[onlyNumberSp]]" name="ports" id="ports" size="4" value="<?php echo $dev->Ports; ?>"></div>
                                </div>
                                <div>
                                    <div><label for="nominalwatts">Nominal Draw (Watts)</label></div>
                                    <div><input type="text" class="optional,validate[custom[onlyNumberSp]]" name="nominalwatts" id="nominalwatts" size=6 value="<?php echo $dev->NominalWatts; ?>"></div>
                                </div>
                                <div>
                                    <div><label for="powersupplycount">Number of Power Supplies</label></div>
                                    <div><input type="number" class="optional,validate[custom[onlyNumberSp]]" name="powersupplycount" id="powersupplycount" size=4 value="<?php echo $dev->PowerSupplyCount; ?>"></div>
                                </div>
                                <div>
                                    <div>Device Type</div>
                                    <div>
                                        <select name="devicetype">
                                            <option value=0>Select...</option>
<?php

        foreach(array('Server','Appliance','Storage Array','Switch','Routing Chassis','Patch Panel','Physical Infrastructure') as $devType){
            echo "          <option value=\"$devType\"";
            if($devType==$dev->DeviceType){
                echo ' selected="selected"';
            }
            echo ">$devType</option>\n";  
        }
?>
                                        </select>
                                    </div>
                                </div>
                            </div> <!-- END div.table -->
                        </fieldset>

                        <h3><a href='#'>VMWare ESX Server Information</a></h3>
<?php
    // Do not display ESX block if device isn't a virtual server and the user doesn't have write access
    if($user->WriteAccess || $dev->ESX){
        echo "<div>";
    // If the user doesn't have write access display the list of VMs but not the configuration information.
        if($user->WriteAccess){
?>
                        <div class="table">
                            <div>
                                <div><label for="esx">ESX Server?</label></div>
                                <div>
                                    <select name="esx" id="esx">
                                        <option value="1"<?php if($dev->ESX==1){echo' selected="selected"';}?>>True</option>
                                        <option value="0" <?php if($dev->ESX==0){echo' selected="selected"';}?>>False</option>
                                    </select>
                                </div>
                            </div>
                            <div>
                              <div><label for="primaryip">Primary IP</label></div>
                              <div><input type="text" name="primaryip" id="primaryip" size="20" value="<?php echo $dev->PrimaryIP; ?>"></div>
                            </div>
                            <div>
                            <div><label for="snmpcommunity">SNMP Read Only Community</label></div>
                              <div><input type="text" name="snmpcommunity" id="snmpcommunity" size="40" value="<?php echo $dev->SNMPCommunity; ?>"></div>
                            </div>
                        </div><!-- END div.table -->
                        <div>&nbsp;</div>
<?php
        }
        if($dev->ESX){
            $esx=new ESX();
            $esx->DeviceID=$dev->DeviceID;
            $vmList=$esx->GetDeviceInventory($facDB);

            echo "\n<div class=\"table border\"><div><div>VM Name</div><div>Status</div><div>Owner</div><div>Last Updated</div></div>\n";
            foreach($vmList as $vmRow){
                if($vmRow->vmState=='poweredOff'){
                    $statColor='red';
                }else{
                    $statColor='green';
                }
                $Dept->DeptID=$vmRow->Owner;
                if($Dept->DeptID >0){
                    $Dept->GetDeptByID($facDB);
                }else{
                    $Dept->Name='Unknown';
                }
                echo "<div><div>$vmRow->vmName</div><div><font color=$statColor>$vmRow->vmState</font></div><div><a href=\"updatevmowner.php?vmindex=$vmRow->VMIndex\">$Dept->Name</a></div><div>$vmRow->LastUpdated</div></div>\n";
            }
            echo '</div> <!-- END div.table -->';
        }
    }
        echo "</div>";
?>
                        <h3><a href="#">Power Connections</a></h3>
                        <div>
<?php
    include( 'power_connections.inc.php' );
?>
                        </div>

                        <h3><a href="#">Network Connections</a></h3>
                        <div>
<?php
    include( 'network_connections.inc.php' );
?>
                        </div>
                    </div> <!-- END div accordion -->

                    <div class="center">
                        <div class="table">
                            <div class="caption">
<?php
    if($user->WriteAccess){
        if($dev->DeviceID >0){
            echo "        <div><input type=\"submit\" name=\"action\" value=\"Update\" default></div>\n";
        }else{
            echo '        <div><input type="submit" name="action" value="Create"></div>';
        }
    }
    // Delete rights are seperate from write rights
    if($user->DeleteAccess && $dev->DeviceID >0){
        echo "        <div><input type=\"submit\" name=\"action\" value=\"Delete\"></div>\n";
    }
?>
                            </div>
                        </div>
                    </div>

                </form>

<?php
    if($dev->Cabinet >0){
        echo "   <a href=\"cabnavigator.php?cabinetid=$cab->CabinetID\">[Return to Navigator]</a>";
    }else{
        echo '   <div><a href="storageroom.php">[Return to Navigator]</a></div>';
    }
?>
            </div><!-- END div.main -->
        </div><!-- END div.page -->
    </body>
</html>

Better sanity checks on devices input

The devices.php page will still allow you to enter a device at position 0. At a minimum, that needs to be checked to ensure that it is greater than 0, and less than (CabinetHeight - DeviceHeight + 1). Ideally, it would make an AJAX call for a sanity check on the position to ensure that it doesn't overlap another device. Possibly even show a help text with valid choices.

Add report for audit log

Need at least one report that shows the audit log for cabinets. Should be able to select format as either by data center, by age since last audit, or both.

Replace Rmail library with one still supported

The Rmail library originally used for the openDCIM product is no longer under development and the developer website is no longer online. Documentation for the original library is no longer available.

Wattage on Devices Screen

The template value for wattage no longer displays on the devices.php screen, and the ability to override seems to have been broken.

Missing / Broken Reports

Broken: vm_by_department_report.php
Missing: assets_by_department.php

If we are going to keep the vm report and I assume we would then it needs to be updated to use the logo from the config and correct any other errors it has.

Assets by department is just gone, not sure when it was removed but the link to it still exists on the reports page. So either we need to find that missing file or remove the link.

Rack slot picker not working

The slot picker was erroring out on a console.log request when a console wasn't available to display under IE.

Blade tracking

Add in the ability to specify if a blade is in the front of back of a chassis and adjust displays to distinguish front from back. It would probably be a good idea to take a better look at the height property as well to do half slot designations as well as multislot devices.

Contact Assignment Screen Formatting

The formatting for the Assign Contacts iframe within the departments.php page is not using all of the available space, and is showing up with scroll bars.

This is consistent in Google Chrome and Internet Explorer 9. Mozilla Firefox does not display the same issue.

Voltage and phases

Not every country has 208VAC for voltage
This should not be static and is part of the reason why I included a country option in the configuration page

Support barcode scanning (iPhone & Android)

Thanks to Martin's devices.php modifications, I noticed that he was using a barcode scanning API. I hadn't gotten un-lazy enough to find one, but now that we know about ZXing, we're going to implement it.

Should be able to scan a cabinet barcode - perhaps from the sidebar - let's discuss first
Should be able to scan a device barcode - definitely from the cabnavigator, possibly from sidebar - let's discuss first
Need to add scan for asset tag to the devices.php page

Since the code for this seems fairly trivial, now that we've got examples in hand, I'm adding to the 1.5 Milestone.

We'll also need to remember to check for iPhone v. Android to make sure that we encode the scanning URLs correctly.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.