Skip to content
Snippets Groups Projects
Commit fcacc203 authored by drupal_dev Dev's avatar drupal_dev Dev
Browse files

Issue #1412860 by drupal.hobby: Updating the Schema API for upgrade to D7.

parent 5586d353
No related branches found
No related tags found
No related merge requests found
Showing
with 6714 additions and 0 deletions
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Lesser General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
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; either version 2 of the License, or
(at your option) any later version.
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.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License.
BASIC INFO
==========
- Provides usage estimate table based on user's activities.
- Works with Cloud module.
KNOWN ISSUES
============
- "Usage Estimate" includes some bugs.
HOW TO USE
==========
1) Enable Billing module
2) Update cloud information (by clicking '- Refresh Page -' link) or
take any action (e.g. launch an instance, create a server template, etc.)
3) Go to the menu: Report | Usage Estimate
DIRECTORY STRUCTURE
===================
cloud
+-modules (depends on Cloud module) (Cloud is a core module for Cloud package)
+-cloud_activity_audit
+-cloud_alerts
x-cloud_auto_scaling
o-cloud_billing
+-cloud_cluster
+-cloud_dashboard
+-cloud_failover
+-cloud_inputs
+-cloud_metering
+-cloud_monitoring
+-cloud_pricing
+-cloud_resource_allocator
x-cloud_scaling_manager
+-cloud_scripting
+-cloud_server_templates
x... Not released yet.
CHANGE HISTORY
==============
2011/12/21 ver.1.2 released 6.x-1.2
2011/07/02 ver.1.1 released 6.x-1.1
2011/06/13 ver.1.01 released 6.x-1.01
2011/06/10 ver.1.0 released 6.x-1.0
2011/06/02 ver.0.92 released 6.x-1.x-dev
2011/04/05 ver.0.91 released to reviewing process of drupal.org
2011/03/24 ver.0.9 released to reviewing process of drupal.org
2011/01/29 ver.0.82 released to reviewing process of drupal.org
2010/12/26 ver.0.81 released to reviewing process of drupal.org
2010/12/15 ver.0.8 released to reviewing process of drupal.org
2010/11/09 ver.0.7 released to reviewing process of drupal.org
Copyright
=========
Copyright (c) 2010-2011 DOCOMO Innovations, Inc.
End of README.txt
\ No newline at end of file
<?php
/**
* @file
* *.inc file: Billing
* Provides usage estimate table based on user's activities.
* Works with Cloud module.
*
* Copyright (c) 2010-2011 DOCOMO Innovations, Inc.
*
*/
define('CLOUD_BILLING_PATH', 'design/billing');
function _cloud_billing_usage_estimate($cloud_context = '' ) {
return @drupal_get_form('cloud_billing_report', $cloud_context);
}
/**
* Returns a form with listing of usage estimate
* Build a form including table header and table body
* @param $form_submit
* This is the form-submit submitted by billing form
* @param $cloud_context
* This is the sub-cloud who's billing details is being displayed
* @return return a form
*/
function cloud_billing_report($form, $form_submit = '', $cloud_context = '') {
global $user;
if (empty($cloud_context)) {
$cloud_context = '';
$cloud_name = 'all';
}
else {
$cloud_name = $cloud_context;
}
$column = 'name';
$total = 0;
$lumsum = 0;
$form['header'] = array(
'#type' => 'value',
'#value' => array(
array('data' => t('Date' )),
array('data' => t('Total')),
),
);
$month_range_list = _cloud_billing_get_month_range_array();
foreach ($month_range_list as $start => $end ) {
$query = _cloud_billing_generate_report($start, $end, $cloud_context, $instance_type);
//print $query;die;
$result = db_query( $query );
$total = 0;
foreach ($result as $billing_obj) {
$total_instance_type_charge = 0;
$unit_price = $billing_obj->linux_or_unix_usage;
$total_hours = _cloud_billing_instance_total_hours($start, $end, $billing_obj->launch_time, $billing_obj->terminated_date);
$total_instance_type_charge = ($total_hours > 0 )
? ($total_hours * $unit_price)
: 0;
$total += $total_instance_type_charge;
}
//die;
$form['date' ][$start] = array(
array(
'#markup' => l($start . ' to ' . $end,
'reports/usage_estimate/' . $start . '/' . $end . '/details/' . $cloud_name,
array('query' => array('start' => $start, 'end' => $end))),
),
); // array(), 'start=' . $start . '&end=' . $end , NULL, FALSE, TRUE ) ) ); //t( $start . ' to ' . $end ) ) );
$form['totals'][$start] = array(array('#markup' => t( '$' . number_format($total, 2))));
$lumsum += $total;
}
$form['cloud_context' ] = array(
'#type' => 'hidden',
'#value' => ($cloud_context),
);
$form['Total'] = array('#value' => '$' . number_format($lumsum, 2));
// print 'passed 1';die;
return $form;
}
function theme_cloud_billing_report($form) {
if (isset($form['form'])) {
$form = $form['form'];
}
$rows = array();
foreach (element_children($form['date']) as $key) {
$rows[] = array(
drupal_render($form['date' ][$key]),
drupal_render($form['totals'][$key]),
// drupal_render($form['Updated'][$key]),
// $action_data ;
);
}
$rows[] = array(
'',
drupal_render($form['Total']),
);
$output = drupal_render( $form['options']);
$output .= theme('table', array('header' => $form['header']['#value'], 'rows' => $rows));
$reload_link = l(t('- Refresh Page -'), 'reports/usage_estimate/' . $form['cloud_context']['#value']);
$ref_link = array(
'#type' => 'item',
'#prefix' => '<div id="link_reload" align="right">',
'#suffix' => '</div>',
'#markup' => $reload_link,
);
$output .= drupal_render($ref_link);
$output .= drupal_render_children($form);
return $output;
}
function cloud_billing_report_submit($form_id, $form_values) {
global $user;
$form_values = $form_values['values'];
return;
}
/**
* Returns a form with listing of usage estimate
* Build a form including table header and table body
* @param $form_submit
* This is the form-submit submitted by billing form
* @param $start
* This is start date of billing report
* @param $end
* This is end date of billing report
* @param $cloud_context
* This is the sub-cloud who's billing details is being displayed
* @return return a form
*/
function cloud_billing_report_details($form, $form_submit = '', $start = '', $end = '', $cloud_context = '') {
if ($cloud_context == 'all') {
$cloud_context = '';
}
$column = 'name';
$filter = cloud_get_filter_value( $form_submit, 'filter' );
$filter_col = cloud_get_filter_value( $form_submit, 'operation' );
$query_args = array();
$form['header'] = array(
'#type' => 'value',
'#value' => array(
array(
'data' => t('Rate (per Hour)' ),
'field' => 'linux_or_unix_usage',
'sort' => 'asc',
),
array(
'data' => t('Instance Type ID'),
'field' => 'instance_type',
),
array(
'data' => t('Description' ),
'field' => 'description',
),
array('data' => t('Instance(s)' )),
array('data' => t('Usage (in Hours)')),
array('data' => t('Totals' )),
array('data' => t('Start Date' )),
array('data' => t('End Date' )),
),
);
$query = _cloud_billing_get_instance_types($cloud_context);
$order = isset($_REQUEST['order']) ? $_REQUEST['order'] : FALSE;
$sort = isset($_REQUEST['sort']) ? $_REQUEST['sort'] : FALSE;
if (empty($order) === FALSE) {
if (strpos($order, 'Description') === 0) {
$query .= ' order by description ';
}
elseif (strpos($order, 'Rate') === 0) {
$query .= ' order by linux_or_unix_usage ';
}
elseif (strpos($order, 'Instance') === 0) {
$query .= ' order by instance_type ';
}
$query .= $sort . ' ';
}
else { // default
$query .= ' order by linux_or_unix_usage asc ';
}
$result = db_query($query);
$total = 0;
$t_usage = 0;
$t_instances = 0;
foreach ($result as $billing_obj) {
$instance_type = $billing_obj->instance_type;
$query_types = _cloud_billing_generate_report($start, $end, $cloud_context, $instance_type);
$result_types = db_query($query_types);
$total_instances = 0;
$total_hours_calc = 0;
foreach ($result_types as $types) {
$total_hours = _cloud_billing_instance_total_hours($start, $end, $types->launch_time, $types->terminated_date);
if ($instance_type == $types->instance_type and $total_hours > 0) {
$total_hours_calc = $total_hours + $total_hours_calc;
$total_instances++;
}
}
$unit_price = $billing_obj->linux_or_unix_usage;
//print $unit_price;die;
$date_created = '';
$date_updated = '';
$start_date = ($start) ? date_format(date_create($start), 'm/d/Y')
: '-';
$end_date = ($end) ? date_format(date_create($end > date('Y-m-d')
? date('Y-m-d')
: $end), 'm/d/Y')
: '-';
$total_instance_type_charge = ($total_hours_calc > 0 )
? ($total_hours_calc * $unit_price )
: 0;
$st_usage = $total_hours_calc;
$st_instances = $billing_obj->tinstances ;
$form['rate' ][$billing_obj->id] = array(array('#markup' => t( '$' . number_format($unit_price, 3))));
$form['instance_type'][$billing_obj->id] = array(array('#markup' => t( $billing_obj->instance_type )));
$form['description' ][$billing_obj->id] = array(array('#markup' => t( $billing_obj->description . ' instance ' )));
$form['stinstnaces' ][$billing_obj->id] = array(array('#markup' => t(($total_instances > 0)
? $total_instances
: 0 )));
$form['usage' ][$billing_obj->id] = array(array('#markup' => t(($total_hours_calc > 0)
? $total_hours_calc
: 0 )));
$form['totals' ][$billing_obj->id] = array(array('#markup' => t( '$' . number_format($total_instance_type_charge, 2))));
$form['start' ][$billing_obj->id] = array('#markup' => $start_date);
$form['end' ][$billing_obj->id] = array('#markup' => $end_date);
//$form['Updated' ][$billing_obj->id] = array('#value' => date_format($date_updated, 'm/d/Y') ) ;
$total += $total_instance_type_charge;
$t_usage += $st_usage ;
$t_instances += $st_instances ;
}
$form['Total' ] = array('#markup' => '$' . number_format($total, 2));
$form['tUsage' ] = array('#markup' => $t_usage);
$form['tInstances'] = array('#markup' => $t_instances);
$form['cloud_context'] = array(
'#type' => 'hidden',
'#value' => $cloud_context,
);
//print 'here1';die;
return $form;
}
function theme_cloud_billing_report_details($form) {
if (isset($form['form'])) {
$form = $form['form'];
}
$output = drupal_render($form['options']);
$action_data = '';
$rows = array();
$form['rate'] = !empty($form['rate']) ? $form['rate'] : '';
$form['pager']['#value'] = !empty($form['pager']['#value']) ? $form['pager']['#value'] : '';
$rows = array();
foreach (element_children($form['rate']) as $key) {
$rows[] = array(
drupal_render($form['rate' ][$key]),
drupal_render($form['instance_type'][$key]),
drupal_render($form['description' ][$key]),
drupal_render($form['stinstnaces' ][$key]),
drupal_render($form['usage' ][$key]),
drupal_render($form['totals' ][$key]),
drupal_render($form['start' ][$key]),
drupal_render($form['end' ][$key]),
$action_data,
);
}
$rows[] = array(
$row = array(
'',
drupal_render($form['tInstances']),
drupal_render($form['tUsage' ]),
drupal_render($form['Total' ]),
),
);
$output .= theme('table', array('header' => $form['header']['#value'], 'rows' => $rows));
if ($form['pager']['#value']) {
$output .= drupal_render($form['pager']);
}
$cloud_context = $form['cloud_context']['#value'];
$reload_link = l(t('- Back to Report Page -'), 'reports/usage_estimate/' . $cloud_context );
$ref_link = array(
'#type' => 'item',
'#prefix' => '<div id="link_reload" align="right">',
'#suffix' => '</div>',
'#markup' => $reload_link,
);
$output .= drupal_render($ref_link);
$output .= drupal_render_children($form);
return $output;
}
function _cloud_billing_get_month_range_array() {
$month_range_list = array();
for ($i = 0; $i < 12; $i++ ) { //for last 1 year
_cloud_billing_get_month_range($start, $end, $i);
$month_range_list[$start] = $end;
}
return $month_range_list;
}
function _cloud_billing_get_month_range(&$start_date, &$end_date, $offset = 0) {
$start_date = '';
$end_date = '';
$date = date('Y-m-d');
list($yr, $mo, $da) = explode('-', $date);
$start_date = date('Y-m-d', mktime(0, 0, 0, $mo - $offset, 1, $yr));
$i = 2;
list($yr, $mo, $da) = explode('-', $start_date);
while (date('d', mktime(0, 0, 0, $mo, $i, $yr)) > 1) {
$end_date = date('Y-m-d', mktime(0, 0, 0, $mo, $i, $yr));
$i++;
}
}
/**
* Function to syc the Cloud Instances details with Billing Instances table
*/
function _cloud_billing_syncronize_records() {
$filter_params = array();
$all_instances_list = array();
$get_all_instances = array();
$get_duplicate_instances = array();
$cloud_list = cloud_get_all_clouds();
foreach ($cloud_list as $cloud_context) {
$instances_list = cloud_get_instances($cloud_context, $filter_params );
$all_instances_list = array_merge($all_instances_list , $instances_list );
}
//drupal_set_message('<pre>'. print_r($all_instances_list, 1) . '</pre>');
foreach ($all_instances_list as $instances) {
if (is_array($instances)) {
$query_args = array();
$all_instances[] = $instances['instance_id'];
$instance_cloud = $instances['cloud_context'];
$query_args[] = 'instance_nickname';
$query_args[] = $instances['name'];
$query_args[] = 'dns_name';
$query_args[] = $instances['hostname'];
$query_args[] = 'instance_state_name';
$query_args[] = $instances['state'];
$query_args[] = 'launch_time';
$query_args[] = $instances['runtime'];
if (strtolower($instances['state']) == 'running') {
_cloud_billing_update_running($instances['instance_id'], $instance_cloud);
}
//Update Billing Instance Detials
$update_instance = _cloud_billing_syncronize_instances($instances['cloud_context'], $instances['instance_id'], $query_args);
}
}
//Check for duplicate Instance ID for a cloud type and remove the duplicates for orphaned instances
$cloud_list = cloud_get_all_clouds();
foreach ($cloud_list as $cloud_context) {
$get_duplicate_instances = _cloud_billing_check_duplicate($cloud_context);
if (!empty($get_duplicate_instances)) {
//Delete the duplicate Instances for a particular Cloud Type
foreach ($get_duplicate_instances as $key => $cloud_context) {
_cloud_billing_remove_instances($key, $cloud_context);
}
}
}
//Update the Instances table if the Instance Id is not found
$get_all_instances = _cloud_billing_get_all_instances();
foreach ($get_all_instances as $instances) {
$query_args = array();
$instance_id = $instances['instance_id'];
$launch_date = $instances['launch_time'];
if (!array_key_exists($instance_id, $all_instances_list)) {
$query_args[] = 'instance_state_name';
$query_args[] = 'terminated';
$query_args[] = 'terminated_date';
$query_args[] = $launch_date;
//Update Billing Instance Detials
$update_instance = _cloud_billing_update_instances($instance_id, $query_args);
}
}
}
/**
* Function get the Total hours between two different dates
* @param $launch_time
* This is Start Date
* @param $curr_time
* This is End Date, which can be also empty
* @return returns total number of hours
*/
function _cloud_billing_get_runtime($launch_time, $curr_time = '') {
if (empty($launch_time)) {
return 0;
}
$launch_tmp_time = date_parse($launch_time);
$gm_launch_time = gmmktime( $launch_tmp_time['hour'], $launch_tmp_time['minute'], $launch_tmp_time['second'], $launch_tmp_time['month'], $launch_tmp_time['day'], $launch_tmp_time['year'] );
if (!empty($curr_time)) {
$curr_tmp_time = date_parse($curr_time);
$gm_current_time = gmmktime( $curr_tmp_time['hour'], $curr_tmp_time['minute'], $curr_tmp_time['second'], $curr_tmp_time['month'], $curr_tmp_time['day'], $curr_tmp_time['year'] );
}
else {
$gm_current_time = gmmktime();
}
$diff = $gm_current_time - $gm_launch_time;
$days = $diff / (86400);
$hr = $diff / (3600);
$min = $diff / (60);
$sec = $diff;
$hours = 0;
if ( round( $days) > 0 ) {
$hours = $days * 24;
}
elseif ( round( $hr ) > 0 ) {
$hours = $hr;
}
elseif ( round( $min ) > 0 ) {
$hours = $min / 60;
}
elseif ( round( $sec ) > 0 ) {
$hours = $sec / 3600;
}
return round($hours);
}
/**
* Function to calculate the total number of Hours an Instance is running.
*
* @param $start
* This is Instance start date
* @param $end
* This is current date
* @param $runtime
* This is Instance launched date
* @param $terminated
* This is Instance terminated date
* @return returns hour values
*/
function _cloud_billing_instance_total_hours($start, $end, $runtime, $terminated) {
$return_data = array();
$start_date = gmdate('c', strtotime($start));
$end_date = gmdate('c', strtotime($end . ' 23:59:59'));
$instance_launch_date = gmdate('c', strtotime($runtime));
if (!empty($terminated)) {
$instance_terminated_date = gmdate('c', strtotime($terminated));
}
if (strtotime($start_date) < strtotime($instance_launch_date)) {
$start_date = $instance_launch_date;
}
if (strtotime($end_date) > strtotime(gmdate('c'))) {
$end_date = gmdate('c');
}
if (!empty($terminated) && strtotime($end_date) >= strtotime($instance_terminated_date)) {
$end_date = $instance_terminated_date;
}
$total_hours = _cloud_dashboard_get_runtime($start_date, $end_date);
return $total_hours;
}
name = Billing
description = Get a pricing details of instances.
package = Cloud
dependencies[] = cloud_pricing
core = 7.x
; Information added by drupal.org packaging script on 2011-12-22
version = "7.x-1.x-dev"
core = "7.x"
project = "cloud"
datestamp = "1324555586"
<?php
/**
* @file
* Provides usage estimate table based on user's activities.
* Works with Cloud module.
*
* Copyright (c) 2010-2011 DOCOMO Innovations, Inc.
*
*/
module_load_include('inc', 'cloud' , 'cloud_constants' );
module_load_include('inc', 'cloud_billing', 'cloud_billing_constants');
/**
* Implementation of hook_install().
*/
function cloud_billing_install() {
// Create tables.
}
/**
* Implementation of hook_uninstall().
*/
function cloud_billing_uninstall() {
// Remove tables.
}
/**
* Implementation of hook_schema().
*/
function cloud_billing_schema() {
$schema = array();
///To add more schema just add one more $schema['newtable'] array.
$schema[CLOUD_BILLING_INSTANCES_DETAILS_TABLE] = array(
'description' => 'Instances Details table',
'fields' => array(
'instance_id' => array(
'type' => 'varchar',
'length' => 64,
),
'cloud_type' => array(
'type' => 'varchar',
'length' => 64,
),
'instance_nickname' => array(
'type' => 'varchar',
'length' => 64,
),
'image_id' => array(
'type' => 'varchar',
'length' => 16,
),
'kernel_id' => array(
'type' => 'varchar',
'length' => 16,
),
'ramdisk_id' => array(
'type' => 'varchar',
'length' => 16,
),
'owner_id' => array(
'type' => 'varchar',
'length' => 64,
),
'group_id' => array(
'type' => 'varchar',
'length' => 64,
),
'reservation_id' => array(
'type' => 'varchar',
'length' => 64,
),
'platform' => array(
'type' => 'varchar',
'length' => 64,
),
'placement' => array(
'type' => 'varchar',
'length' => 64,
),
'instance_type' => array(
'type' => 'varchar',
'length' => 16,
),
'private_dns_name' => array(
'type' => 'varchar',
'length' => 64,
),
'dns_name' => array(
'type' => 'varchar',
'length' => 64,
),
'key_name' => array(
'type' => 'varchar',
'length' => 64,
),
'instance_state_name' => array(
'type' => 'varchar',
'length' => 64,
),
'instance_state_code' => array(
'type' => 'varchar',
'length' => 64,
),
'ami_launch_index' => array(
'type' => 'varchar',
'length' => 64,
),
'reason' => array(
'type' => 'varchar',
'length' => 64,
),
'product_codes' => array(
'type' => 'varchar',
'length' => 64,
),
'monitoring' => array(
'type' => 'varchar',
'length' => 64,
),
'launch_time' => array(
'type' => 'varchar',
'length' => 64,
),
'terminated_date' => array(
'type' => 'varchar',
'length' => 64,
),
),
);
return $schema;
}
<?php
/**
* @file
* Provides usage estimate table based on user's activities.
* Works with Cloud module.
*
* Copyright (c) 2010-2011 DOCOMO Innovations, Inc.
*
*/
module_load_include('inc', 'cloud' , 'cloud_constants' );
module_load_include('inc', 'cloud_billing', 'cloud_billing_constants');
module_load_include('inc', 'cloud_billing', 'cloud_billing' );
module_load_include('inc', 'cloud_billing', 'cloud_billing_db' );
/**
* Implementation of hook_help().
*/
function cloud_billing_help($section) {
switch ($section) {
case 'admin/help#':
$output = '<p>' . t('The cloud module creates a user interface for users to manage clouds. Users can Create Instances, Describe Instances etc..') . '</p>';
return $output;
case 'admin/content/comment':
case 'admin/content/comment/create':
return '<p>' . t("Below is a list of the latest comments posted to your site. Click on a subject to see the comment, the author's name to edit the author's user information , 'edit' to modify the text, and 'delete' to remove their submission.") . '</p>';
case 'admin/content/comment/approval':
return '<p>' . t("Below is a list of the comments posted to your site that need approval. To approve a comment, click on 'edit' and then change its 'moderation status' to Approved. Click on a subject to see the comment, the author's name to edit the author's user information, 'edit' to modify the text, and 'delete' to remove their submission.") . '</p>';
case 'admin/content/comment/settings':
return '<p>' . t("Comments can be attached to any node, and their settings are below. The display comes in two types: a 'flat list' where everything is flush to the left side, and comments come in chronological order, and a 'threaded list' where replies to other comments are placed immediately below and slightly indented, forming an outline. They also come in two styles: 'expanded', where you see both the title and the contents, and 'collapsed' where you only see the title. Preview comment forces a user to look at their comment by clicking on a 'Preview' button before they can actually add the comment.") . '</p>';
}
}
function cloud_billing_user_validate($op, &$edit, &$account, $category = NULL) {
switch ($op) {
case 'load':
break;
}
}
/**
* Implementation of hook_menu().
*/
function cloud_billing_menu() {
$items = array();
$cloud_list = cloud_get_all_clouds();
$cloud_name_list = cloud_get_all_clouds_display_name();
$new_cloud_list = '';
$i = 0;
foreach ($cloud_list as $cloud_context) {
if ($i == 0) {
$new_cloud_list = $cloud_context;
break;
}
}
$items['reports'] = array(
'title' => 'Report',
'description' => 'Usage Estimate Reports',
// NOTE: THERE ARE both cloud_billing_usage_estimate and _cloud_billing_usage_estimate
'page callback' => '_cloud_billing_usage_estimate',
//'page arguments' => array($new_cloud_list),
'access arguments' => array('access report'),
'weight' => -1,
'file' => '',
);
$items['reports/usage_estimate'] = array(
'title' => 'Usage Estimate',
'description' => 'Usage Estimate Reports',
// NOTE: THERE ARE both cloud_billing_usage_estimate and _cloud_billing_usage_estimate
'page callback' => '_cloud_billing_usage_estimate',
//'page arguments' => array($new_cloud_list),
'access arguments' => array('access report'),
'weight' => 0,
'file' => '',
);
$items['reports/usage_estimate/%/%/details/all'] = array(
//'path' => 'clouds/reports/usage_estimate/details',
'title' => 'Usage Estimate Details',
'description' => 'Usage Estimate Reports',
'page callback' => 'drupal_get_form',
'page arguments' => array('cloud_billing_report_details', 2, 3, 'all'),
'access arguments' => array('access usage estimate'),
'type' => MENU_CALLBACK,
'file' => '',
);
$i = 0;
foreach ($cloud_list as $cloud_context) {
$items['reports/usage_estimate/' . $cloud_context] = array(
'title' => $cloud_name_list[$cloud_context],
'description' => $cloud_name_list[$cloud_context],
// NOTE: THERE ARE both cloud_billing_usage_estimate and _cloud_billing_usage_estimate
'page callback' => '_cloud_billing_usage_estimate',
'page arguments' => array($cloud_context),
'access arguments' => array($cloud_context . ' access report'),
'weight' => 2,
'file' => '',
);
$items['reports/usage_estimate/%/%/details/' . $cloud_context] = array(
//'path' => 'clouds/reports/usage_estimate/details',
'title' => 'Usage Estimate Details',
'description' => 'Usage Estimate Reports',
'page callback' => 'drupal_get_form',
'page arguments' => array('cloud_billing_report_details', 2, 3, $cloud_context),
'access arguments' => array('access usage estimate'),
'type' => MENU_CALLBACK,
'file' => '',
);
$i++;
}
// End of billing Menu
return $items;
}
/**
* Implementation of hook_permission().
*/
function cloud_billing_permission() {
return array(
'access usage estimate',
'access report' ,
);
}
function cloud_billing_theme() {
return array(
'cloud_billing_report' => array(
'render element' => 'form',
'file' => 'cloud_billing.inc',
),
'cloud_billing_report_details' => array(
'render element' => 'form',
'file' => 'cloud_billing.inc',
),
);
}
/**
* Implementation of hook_cloud_delete()
*/
function cloud_billing_cloud_delete($cloud_name) {
_cloud_billing_delete_data($cloud_name);
}
/**
* Implementing of hook_cron()
*/
function cloud_billing_cron() {
_cloud_billing_syncronize_records();
}
<?php
/**
* @file
* Provides billing functionality
* Works with Cloud module.
*
* Copyright (c) 2010-2011 DOCOMO Innovations, Inc.
*
*/
define('CLOUD_BILLING_PREFIX' , 'cloud_' );
define('CLOUD_BILLING_INSTANCES_DETAILS_TABLE', CLOUD_BILLING_PREFIX . 'instances_details');
define('CLOUD_BILLING_PAGER_LIMIT' , 50 );
<?php
/**
* @file
* Provides usage estimate table based on user's activities.
* Works with Cloud module.
*
* Copyright (c) 2010-2011 DOCOMO Innovations, Inc.
*
*/
// scripting functions
//start
function _cloud_billing_generate_report($start, $end, $cloud_context = '', $instance_type = '') {
$clouds = array();
$cloud_list = cloud_get_all_clouds();
foreach ($cloud_list as $cloud) {
$clouds[] = $cloud;
}
$search_where = '';
if ($cloud_context) {
$search_where = " and b.cloud_type='" . $cloud_context . "' ";
}
$search_instance_type = '';
if ($instance_type) {
$search_instance_type = " and a.instance_type='" . $instance_type . "' ";
}
if ($start && $end) {
if ($end) {
list($yr, $mo, $da) = explode('-', $end);
$end = date('c', mktime(0, 0, 0, $mo, $da + 1, $yr)); //changed it to start of next month
$now = date('c'); //date('Y-m-dcH:i:s');
$end = ($end < $now) ? $end : $now;
}
$start_search = "if (launch_time < '" . $start . "', '" . $start . "', launch_time) ";
$end_search = "if (instance_state_name != 'terminated', '" . $end . "', if (terminated_date < '" . $end . "' and terminated_date > '" . $start . "', terminated_date, '" . $end . "')) ";
$search_where_sub = " and launch_time < " . $end_search . " and (terminated_date > '" . $start . "' or terminated_date = '0000-00-00 00:00:00' or terminated_date IS null) and instance_state_name != 'pending' ";
}
$query = "SELECT a.instance_id, a.instance_type, a.instance_nickname, a.instance_state_name, a.cloud_type,
a.launch_time, a.terminated_date, b.linux_or_unix_usage, b.windows_usage
FROM {" . CLOUD_BILLING_INSTANCES_DETAILS_TABLE . "} a
LEFT JOIN {" . CLOUD_PRICING_INSTANCES_TABLE . "} b
ON a.instance_type = b.instance_type where a.launch_time " . $search_instance_type . " IS NOT NULL
AND a.launch_time != '0000-00-00 00:00:00'
AND a.launch_time != '' AND (a.instance_state_name = 'running'
OR a.instance_state_name = 'terminated')
AND a.cloud_type = b.cloud_type " . $search_where;
return $query;
}
//end
/**
* Query all the Instance Types details
*/
function _cloud_billing_get_instance_types($cloud_context = '') {
$search_where = '';
if ($cloud_context) {
$search_where = " and a.cloud_type='" . $cloud_context . "' ";
}
$query = "SELECT a.instance_type, b.id, b.description, b.linux_or_unix_usage, b.windows_usage, " .
"(select count(instance_id) from {" . CLOUD_BILLING_INSTANCES_DETAILS_TABLE . "} e where a.instance_type=e.instance_type " . $search_where . " group by e.instance_type) as tInstances, " .
"(select min(launch_time) from {" . CLOUD_BILLING_INSTANCES_DETAILS_TABLE . "} d where a.instance_type=d.instance_type " . $search_where . " group by d.instance_type) as start_date FROM {" . CLOUD_INSTANCE_TYPE_TABLE . "} a " .
"left join {" . CLOUD_PRICING_INSTANCES_TABLE . "} b on a.instance_type=b.instance_type " . $search_where .
" WHERE 1 " . $search_where . " group by a.instance_type ";
return $query;
}
/**
* Update the Cloud Billing details
* @param $cloud_context
* This is cloud name
* @return returns a sql-query
*/
function _cloud_billing_update_instance_query($cloud_context, $instance_id, $nickname) {
$billing_instances_table = CLOUD_BILLING_INSTANCES_DETAILS_TABLE;
$num_updated = db_update($billing_instances_table)
->fields(array(
'instance_nickname' => $nickname,
))
->condition('instance_id', $instance_id, '=')
->condition('cloud_type', $cloud_context, '=')
->execute();
return $num_updated;
}
/**
* Delete the Cloud Billing details on Cloud Delete
* @param $cloud_context
* This is cloud name
* @return returs and sql-query
*/
function _cloud_billing_delete_data($cloud_context) {
$billing_instances_table = CLOUD_BILLING_INSTANCES_DETAILS_TABLE;
$billing_instance_delete = "DELETE FROM {" . $billing_instances_table . "} where and cloud_type = '$cloud_context'";
return $billing_instance_delete;
}
/**
* Function to get the details of Individual Instances of Cloud
*/
function _cloud_billing_get_all_instances() {
$billing_instances_table = CLOUD_BILLING_INSTANCES_DETAILS_TABLE;
$billing_instance_select = "SELECT * FROM {" . $billing_instances_table . "} ";
$query_result = cloud_get_db_results($billing_instance_select);
$instances_details = array();
foreach ($query_result as $values) {
$instances_details[$values['instance_id']] = $values;
}
return $instances_details;
}
/**
* Function to check count of Instances
* @param string $instance_id
* @param string $cloud_context
* @return returns a number
*/
function _cloud_billing_check_for_instance($instance_id, $cloud_context = '') {
$check_query = "SELECT count(*) as tCount FROM {"
. CLOUD_BILLING_INSTANCES_DETAILS_TABLE
. "} where instance_id='" . $instance_id . "' and cloud_type='" . $cloud_context . "' ";
$check_result = db_query( $check_query );
if ($check_result) {
$count = $check_result->fetchField();
return $count;
}
return 0;
}
/**
*
* Function to update the Instances details where Cloud Instances are fetched.
* @param $cloud_context
* This is cloud name
* @param $instance_id
* This is instance id
* @param $instance_state
* This is instance status
* @param $launch_time
* This is instance launched date
* @param $instance_type
* This is instance type
*
*/
function _cloud_billing_update( $cloud_context, $instance_id = '', $instance_state = '', $launch_time = '', $instance_type = '') {
if (empty($instance_id)) {
return;
}
if ( _cloud_billing_check_for_instance($instance_id, $cloud_context) == 0) {
$id = db_insert(CLOUD_BILLING_INSTANCES_DETAILS_TABLE)
->fields(array(
'instance_id' => $instance_id,
'instance_state_name' => $instance_state,
'launch_time' => $launch_time,
'instance_type' => $instance_type,
'cloud_type' => $cloud_context,
))
->execute();
}
$update_query = "update {" . CLOUD_BILLING_INSTANCES_DETAILS_TABLE
. "} set instance_state_name='"
. $instance_state
. "' where instance_id='"
. $instance_id . "' ";
$update_result = db_query( $update_query );
$update_query = "update {"
. CLOUD_BILLING_INSTANCES_DETAILS_TABLE
. "} set terminated_date='" . date('c')
. "' where instance_state_name='terminated' and terminated_date IS NULL";
$update_result = db_query( $update_query );
return;
}
/**
* Function to update Cloud Instance Details table on cron run for Mapped Instances
*/
function _cloud_billing_syncronize_instances($cloud_context, $instance_id, $query_args) {
$count_args = count($query_args);
for ($i = 0; $i < $count_args; ) {
$field_name = $query_args[$i];
$field_value = $query_args[$i + 1];
$billing_instance_update = "update {" . CLOUD_BILLING_INSTANCES_DETAILS_TABLE . "} set $field_name='$field_value' where instance_id= '$instance_id' and cloud_type = '$cloud_context'";
//Update the Instances details table
$update_query = db_query($billing_instance_update);
$i = $i + 2;
}
}
/**
* Function to update Cloud Instance Details table on cron run for Oprhaned Instances
*/
function _cloud_billing_update_instances($instance_id, $query_args) {
$billing_instances_table = CLOUD_BILLING_INSTANCES_DETAILS_TABLE;
$billing_status_update = "update {" . $billing_instances_table . "} set instance_state_name='terminated' where terminated_date !=''";
$billing_nickname_update = "update {" . $billing_instances_table . "} set instance_nickname='$instance_id' where instance_nickname IS NULL AND instance_id= '$instance_id'";
$count_args = count($query_args);
for ($i = 0; $i < $count_args; ) {
$field_name = $query_args[$i];
$field_value = $query_args[$i + 1];
$billing_instance_update = "update {" . $billing_instances_table . "} set $field_name='$field_value' where terminated_date IS NULL AND instance_id= '$instance_id'";
//Update the Instances details table
$update_query = db_query($billing_instance_update);
$update_status = db_query($billing_status_update);
$i = $i + 2;
}
$update_nickname = db_query($billing_nickname_update);
}
/**
* Function to check for Duplicate Instance for same Cloud Type
*/
function _cloud_billing_check_duplicate($cloud_context) {
$billing_instances_table = CLOUD_BILLING_INSTANCES_DETAILS_TABLE;
$billing_instance_query = "SELECT instance_id, cloud_type, COUNT( instance_id ) AS numberCount FROM {" . $billing_instances_table . "} WHERE cloud_type = '$cloud_context' GROUP BY instance_id HAVING (COUNT( instance_id ) >1) ";
$query_result = db_query($billing_instance_query);
$instances_details = array();
//while ($rows = db_fetch_array($query_result)) {
foreach (query_result as $rows) {
$instances_details[$rows['instance_id']] = $rows['cloud_type'];
}
return $instances_details;
}
/**
* Function to remove duplicate Cloud Instance Details on cron run
*/
function _cloud_billing_remove_instances($instance_id, $cloud_context) {
$billing_instances_table = CLOUD_BILLING_INSTANCES_DETAILS_TABLE;
$billing_instance_delete = "delete from {" . $billing_instances_table . "} where instance_id= '$instance_id' and cloud_type = '$cloud_context'";
$update_query = db_query($billing_instance_delete);
}
function _cloud_billing_update_running($instance_id, $cloud_context) {
$billing_instances_table = CLOUD_BILLING_INSTANCES_DETAILS_TABLE;
$billing_instance_update = "update {" . $billing_instances_table . "} set terminated_date=NULL WHERE instance_id= '$instance_id' AND cloud_type = '$cloud_context'";
$query_result = db_query($billing_instance_update);
}
BASIC INFO
==========
- Provides cluster feature which enables to bundle server templates.
- Works with Cloud and Server Templates module.
HOW TO USE
==========
1) Enable Cluster module
2) Create server template(s)
3) Go to the menu: Design | Cluster | Create
4) Input Nickname and Description (and click 'Save' button)
5) Select a cluster item
6) Click 'Add Server' button
7) Select a server template
8) Enter nickname, select SSH Key, Security Group and Availability Zone
9) Click 'Add' button
DIRECTORY STRUCTURE
===================
cloud
+-modules (depends on Cloud module) (Cloud is a core module for Cloud package)
+-cloud_activity_audit
+-cloud_alerts
x-cloud_auto_scaling
+-cloud_billing
o-cloud_cluster
+-cloud_dashboard
+-cloud_failover
+-cloud_inputs
+-cloud_metering
+-cloud_monitoring
+-cloud_pricing
+-cloud_resource_allocator
x-cloud_scaling_manager
+-cloud_scripting
+-cloud_server_templates
x... Not released yet.
CHANGE HISTORY
==============
2011/12/21 ver.1.2 released 6.x-1.2
2011/07/02 ver.1.1 released 6.x-1.1
2011/06/13 ver.1.01 released 6.x-1.01
2011/06/10 ver.1.0 released 6.x-1.0
2011/06/02 ver.0.92 released 6.x-1.x-dev
2011/04/05 ver.0.91 released to reviewing process of drupal.org
2011/03/24 ver.0.9 released to reviewing process of drupal.org
2011/01/29 ver.0.82 released to reviewing process of drupal.org
2010/12/26 ver.0.81 released to reviewing process of drupal.org
2010/12/15 ver.0.8 released to reviewing process of drupal.org
Copyright
=========
Copyright (c) 2010-2011 DOCOMO Innovations, Inc.
End of README.txt
\ No newline at end of file
This diff is collapsed.
name = Cluster
description = A cluster consists of a group of servers that work together
package = Cloud
dependencies[] = cloud
dependencies[] = cloud_server_templates
core = 7.x
; Information added by drupal.org packaging script on 2011-12-22
version = "7.x-1.x-dev"
core = "7.x"
project = "cloud"
datestamp = "1324555586"
<?php
/**
* @file
* Provides cluster feature which enables to bundle server templates.
* Works with Cloud and Server Templates module.
*
* Copyright (c) 2010-2011 DOCOMO Innovations, Inc.
*
*/
module_load_include('inc', 'cloud' , 'cloud_constants' );
module_load_include('inc', 'cloud_cluster', 'cloud_cluster_constants' );
drupal_load('module', 'cloud');
/**
* Implementation of hook_install().
*/
function cloud_cluster_install() {
// Create tables.
}
/**
* Implementation of hook_uninstall().
*/
function cloud_cluster_uninstall() {
// Remove tables.
}
/**
* Implementation of hook_schema().
*/
function cloud_cluster_schema() {
$schema = array();
$schema[CLOUD_CLUSTER_TABLE] = array(
'description' => 'Cluster of VMs',
'fields' => array(
'cluster_id' => array(
'type' => 'serial' ,
'length' => 11,
),
'cluster_nickname' => array(
'type' => 'varchar',
'length' => 64,
),
'description' => array(
'type' => 'text' ,
'length' => 255,
),
'creator' => array(
'type' => 'varchar',
'length' => 64,
),
),
'primary key' => array('cluster_id'),
);
$schema[CLOUD_CLUSTER_SERVER_TABLE] = array(
'description' => 'Cluster and template table',
'fields' => array(
'server_id' => array(
'type' => 'serial' ,
'length' => 11,
),
'cluster_id' => array(
'type' => 'int' ,
'length' => 11,
),
'template_id' => array(
'type' => 'int' ,
'length' => 11,
),
'instance_id' => array(
'type' => 'varchar',
'length' => 64,
),
'server_nickname' => array(
'type' => 'varchar',
'length' => 64,
),
'server_sshkey' => array(
'type' => 'varchar',
'length' => 64,
),
'server_security_group' => array(
'type' => 'varchar',
'length' => 64,
),
'server_zone' => array(
'type' => 'varchar',
'length' => 64,
),
'elastic_ip' => array(
'type' => 'varchar',
'length' => 16,
),
'failover_flag' => array(
'type' => 'int' ,
'length' => 3 ,
'default' => 0,
),
'failover_check_duration' => array(
'type' => 'int' ,
'length' => 3 ,
'default' => 3,
),
'failover_status' => array(
'type' => 'int' ,
'length' => 3 ,
'default' => 0,
),
'last_failover_check_time' => array('type' => 'text'),
),
'primary key' => array('server_id'),
);
return $schema;
}
<?php
/**
* @file
* Provides cluster feature which enables to bundle server templates.
* Works with Cloud and Server Templates module.
*
* Copyright (c) 2010-2011 DOCOMO Innovations, Inc.
*
*/
/**
*
* @file Enables users to access clusters.
*/
module_load_include('inc', 'cloud' , 'cloud_constants' );
module_load_include('inc', 'cloud_cluster', 'cloud_cluster_constants');
module_load_include('inc', 'cloud_cluster' );
module_load_include('inc', 'cloud_cluster', 'cloud_cluster_db' );
module_load_include('inc', 'cloud_cluster', 'cloud_cluster_server_db');
/**
* Implementation of hook_help().
*/
function cloud_cluster_help($section) {
switch ($section) {
case 'admin/help#cluster':
$output = '<p>' . t('A cluster consists of a group of servers that work together.') . '</p>';
return $output;
}
}
/**
* Implementation of hook_menu().
*/
function cloud_cluster_menu() {
$items = array();
$items[CLOUD_CLUSTER_PATH] = array(
'title' => CLOUD_CLUSTER_DISPLAY_NAME,
'description' => CLOUD_CLUSTER_DISPLAY_NAME,
'page callback' => 'drupal_get_form',
'page arguments' => array('cloud_cluster_display_list'),
'weight' => 10,
'access arguments' => array('list clusters'),
'file' => '',
);
$items[CLOUD_CLUSTER_PATH . '/get_data/%'] = array(
'title' => 'Get data',
'page callback' => '_cloud_cluster_get_data',
'page arguments' => array(3),
'access arguments' => array('list clusters'),
'file' => '',
'type' => MENU_CALLBACK,
);
$items[CLOUD_CLUSTER_PATH . '/callback_get_cluster_servers_list'] = array(
'page callback' => '_cloud_cluster_callback_get_cluster_servers_list',
'type' => MENU_CALLBACK,
'access arguments' => array('list clusters'),
);
$items[CLOUD_CLUSTER_PATH . '/describe'] = array(
'page callback' => '_cloud_cluster_describe',
'access arguments' => array('list clusters'),
'file' => '',
'type' => MENU_CALLBACK,
);
$items[CLOUD_CLUSTER_PATH . '/create'] = array(
'title' => 'New Cluster',
'page callback' => 'drupal_get_form',
'page arguments' => array('cloud_cluster_create_new_cluster'),
'access arguments' => array('create cluster'),
'file' => '',
'type' => MENU_CALLBACK,
);
$items[CLOUD_CLUSTER_PATH . '/delete/%'] = array(
'title' => 'Delete Cluster',
'page callback' => 'drupal_get_form',
'page arguments' => array('_cloud_cluster_delete_cluster', 3),
'access arguments' => array('delete cluster'),
'file' => '',
'type' => MENU_CALLBACK,
);
$items[CLOUD_CLUSTER_PATH . '/describe/info/%'] = array(
'title' => 'Info',
'description' => 'Cluster Details',
'page callback' => 'drupal_get_form',
'page arguments' => array('cloud_cluster_display_detail_info', 4),
'access arguments' => array('list clusters'),
'file' => '',
'weight' => 1,
'type' => MENU_LOCAL_TASK,
);
$items[CLOUD_CLUSTER_PATH . '/describe/cluster_templates/%'] = array(
'title' => 'Design',
'description' => 'Cluster Design by adding Templates',
'page callback' => 'drupal_get_form',
'page arguments' => array('cloud_cluster_display_templates_list', 4),
'access arguments' => array('list clusters'),
'file' => '',
'weight' => 2,
'type' => MENU_LOCAL_TASK,
);
$items[CLOUD_CLUSTER_PATH . '/describe/servers/%'] = array(
'title' => 'Instances',
'description' => 'Instances',
'page callback' => 'drupal_get_form',
'page arguments' => array('cloud_cluster_display_server_list', 4),
'access arguments' => array('list clusters'),
'file' => '',
'weight' => 3,
'type' => MENU_LOCAL_TASK,
);
$items[CLOUD_CLUSTER_PATH . '/describe/servers/add_server'] = array(
'title' => 'Add Server to Cluster',
'description' => 'Add Server to Cluster',
'access arguments' => array('update cluster'),
'file' => '',
'type' => MENU_CALLBACK,
);
//$enabled_cloud_list = cloud_get_clouds() ;
$cloud_list = cloud_get_all_clouds();
$row_counter = 0;
$cloud_name_list = cloud_get_all_clouds_display_name();
foreach ($cloud_list as $cloud_context) {
//$cloud_name = $enabled_cloud_list[$row_counter]["cloud_name"] ;
//$cloud_display_name = $enabled_cloud_list[$row_counter]["cloud_display_name"] ;
$items[CLOUD_CLUSTER_PATH . '/describe/servers/add_server/' . $cloud_context . '/%'] = array(
'title' => $cloud_name_list[$cloud_context],
'description' => $cloud_name_list[$cloud_context],
'page callback' => '_cloud_cluster_add_server',
'page arguments' => array($cloud_context, 6),
'access arguments' => array('update cluster'),
'file' => '',
'weight' => $row_counter,
'type' => MENU_LOCAL_TASK,
);
$row_counter++;
}
$items[CLOUD_CLUSTER_PATH . '/describe/servers/delete_server/%/%'] = array(
'page callback' => 'drupal_get_form',
'page arguments' => array('_cloud_cluster_delete_server' , 5, 6),
'access arguments' => array('update cluster'),
'file' => '',
'type' => MENU_CALLBACK,
);
$items[CLOUD_CLUSTER_PATH . '/describe/servers/launch_server/%/%'] = array(
'page callback' => 'drupal_get_form',
'page arguments' => array('_cloud_cluster_launch_server' , 5, 6),
'access arguments' => array('update cluster'),
'file' => '',
'type' => MENU_CALLBACK,
);
$items[CLOUD_CLUSTER_PATH . '/describe/servers/start_all_servers/%'] = array(
'page callback' => 'drupal_get_form',
'page arguments' => array('_cloud_cluster_launch_server_all', 5),
'access arguments' => array('update cluster'),
'file' => '',
'type' => MENU_CALLBACK,
);
return $items;
}
function cloud_cluster_theme() {
return array(
'cloud_cluster_display_list' => array(
'render element' => 'form',
'file' => 'cloud_cluster.inc',
),
'cloud_cluster_create_new_cluster' => array(
'render element' => 'form',
'file' => 'cloud_cluster.inc',
),
'cloud_cluster_display_detail_info' => array(
'render element' => 'form',
'file' => 'cloud_cluster.inc',
),
'cloud_cluster_display_server_list' => array(
'render element' => 'form',
'file' => 'cloud_cluster.inc',
),
'cloud_cluster_display_templates_list' => array(
'render element' => 'form',
'file' => 'cloud_cluster.inc',
),
);
}
/**
* Implementation of hook_permission().
*/
function cloud_cluster_permission() {
return array(
'create cluster',
'list clusters' ,
'update cluster',
'delete cluster',
);
}
/**
* hook_cron
*/
function cloud_cluster_cron() { }
/*
* This will be called when the respective Cloud submits the Cluster form
* e.g. When Amazon EC2 Cluster form submit's the following function will be called to save the Cluster
*/
function cloud_cluster_add_server_submit($form_id, $form_values) {
$cluster_id = $form_values['cluster_id'] ;
if ( $form_values['op'] == t('List Servers') ) {
drupal_goto( CLOUD_CLUSTER_PATH . '/describe/cluster_templates/' . $cluster_id );
return;
}
elseif ($form_values['op'] == t('Save')) {
_cloud_cluster_save_cluster_server_db($form_values);
drupal_set_message(t('Server @server_name added to Cluster.', array('@server_name' => $form_values['nickname_text']) ));
drupal_goto( CLOUD_CLUSTER_PATH . '/describe/cluster_templates/' . $cluster_id );
}
elseif ($form_values['op'] == t('Add More')) {
_cloud_cluster_save_cluster_server_db($form_values);
drupal_set_message(t('Server @server_name added to Cluster.', array('@server_name' => $form_values['nickname_text']) ));
return;
}
return;
}
<?php
/**
* @file
* Test Cases for Cluster Module
*
* Copyright (c) 2010-2011 DOCOMO Innovations, Inc.
*
*/
/**
* Updated by yas 2011/02/03
* Updated by yas 2010/12/14
* Updated by yas 2010/12/09
* Updated by jamir 2010/12/03
* Updated by yas 2010/12/02
* Created by yas 2010/12/01
*/
module_load_include('test', 'aws_cloud') ;
define('CLOUD_CLUSTER_REPEAT_COUNT', 3);
class ClusterTestCase extends AwsCloudTestCase {
public static function getInfo() {
return array(
'name' => 'Cluster' ,
'description' => 'Cluster Test Cases',
'group' => 'Cloud' ,
);
}
public function testCluster() {
// Access to Design | Cluster
$this->drupalGet('design/cluster');
$this->assertResponse(200, t('HTTP 200: Design | Cluster'));
$this->assertText( t('- Refresh Page -'), t('Found: - Refresh Page -'));
$this->assertNoText(t('Notice' ), t('Make sure w/o Notice' ));
$this->assertNoText(t('warning'), t('Make sure w/o Warnings'));
$clusterName = array();
$clusterDesc = array();
for ($i = 0; $i < CLOUD_CLUSTER_REPEAT_COUNT; $i++) { // 3 times
// Input Fields
$clusterName[] = t('#@number: @date - SimpleTest Cluster Name' , array(
'@number' => $i + 1,
'@date' => date('D M j G:i T Y')));
$clusterDesc[] = t('#@number: @date - SimpleTest Cluster Description', array(
'@number' => $i + 1,
'@date' => date('D M j G:i T Y')));
$edit = array(
'nickname_text' => $clusterName[$i],
'description_text' => $clusterDesc[$i],
);
$this->drupalPost('design/cluster/create', $edit, t('Next'));
$this->assertResponse(200, t('HTTP 200: New Cluster Form | Add'));
$this->assertText(t('Cluster successfully created.'),
t('Confirm Message:') . t('Cluster successfully created.'));
$this->assertText($clusterName[$i], t('Confirm Item on Listing Page: @cluster_name', array('@cluster_name' => $clusterName[$i])));
$this->assertNoText(t('Notice'), t('Make sure w/o Notice'));
for ( $j = 0; $j < $i + 1; $j++) {
$cluster_id = $j + 1 ;
$this->drupalGet('design/cluster/describe/info/' . $cluster_id );
$this->assertResponse(200, t('HTTP 200: Display Cluster Detail Page: @number', array('@number' => $cluster_id)));
$this->assertText($clusterDesc[$j], t('Confirm Cluster Description on Infor Page: @cluster_desc', array('@cluster_desc' => $clusterDesc[$j])));
$this->assertNoText(t('Notice' ), t('Make sure w/o Notice' ));
$this->assertNoText(t('warning'), t('Make sure w/o Warnings'));
}
}
//filtering cluster item
$filter = array(
'filter' => 'Test',
'operation' => 0,
);
$this->drupalPost('design/cluster', $filter, t('Apply'));
$this->assertResponse(200, t('HTTP 200: Search Listings | Filter'));
$cluster_id = CLOUD_CLUSTER_REPEAT_COUNT - 1 ;
$this->assertText($clusterName[$cluster_id], t('Confirm Item:') . $clusterName[$cluster_id ]);
$this->assertNoText(t('Notice' ), t('Make sure w/o Notice' ));
$this->assertNoText(t('warning'), t('Make sure w/o Warnings'));
///////end
}
public function testClusterListServers() {
$edit = array(
'nickname_text' => 'Cluster_List_Servers',
'description_text' => 'Cluster_description' ,
);
$this->drupalPost('design/cluster/create', $edit, t('Next'));
$this->assertResponse(200, t('HTTP 200: New Cluster Form | Add'));
$this->assertText(t('Cluster successfully created.'), t('Confirm Message:') . t('Cluster successfully created.'));
$this->assertNoText(t('Notice' ), t('Make sure w/o Notice' ));
$this->assertNoText(t('warning'), t('Make sure w/o Warnings'));
// Access to Cluster | Servers
$this->drupalGet('design/cluster/describe/servers/1');
$this->assertResponse(200, t('HTTP 200: Cluster | Servers'));
$this->assertText(t('Instances'), t('Found: Instances'));
$this->assertNoText(t('Notice' ), t('Make sure w/o Notice' ));
$this->assertNoText(t('warning'), t('Make sure w/o Warnings'));
}
public function testClusterModify() {
$edit = array(
'nickname_text' => 'Name testClusterModify' ,
'description_text' => 'description_ClusterModify ',
);
$this->drupalPost('design/cluster/create', $edit, t('Next'));
$this->assertResponse(200, t('HTTP 200: New Cluster Form | Add'));
$this->assertText( t('Cluster successfully created.'), t('Confirm Message:') . t('Cluster successfully created.'));
$this->assertNoText(t('Notice' ), t('Make sure w/o Notice' ));
$this->assertNoText(t('warning'), t('Make sure w/o Warnings'));
// Cluster | Update
$this->drupalGet('design/cluster/describe/servers/1');
$this->assertResponse(200, t('HTTP 200: Cluster | Instances'));
$this->assertText( t('Instances'), t('Found: Instances'));
$this->assertNoText(t('Notice' ), t('Make sure w/o Notice' ));
$this->assertNoText(t('warning'), t('Make sure w/o Warnings'));
$this->drupalGet('design/cluster/describe/info/1' );
$this->assertResponse(200, t('HTTP 200: Cluster | Servers'));
$this->assertText( t('Nickname'), t('Found: Nickname'));
$this->assertNoText(t('Notice'), t('Make sure w/o Notice'));
$modify_params = array(
'nickname_text' => 'New_Nickname' ,
'description_text' => 'New_Description',
'cluster_id' => '1' ,
);
$this->drupalPost('design/cluster/describe/info/1', $modify_params, t('Update'));
$this->assertResponse(200, t('HTTP 200: Cluster | Update'));
$this->assertText(t('Cluster has been updated'), t('Cluster has been updated'));
$this->assertNoText(t('Notice' ), t('Make sure w/o Notice' ));
$this->assertNoText(t('warning'), t('Make sure w/o Warnings'));
}
public function testClusterDelete() {
// Cluster | Create
$edit = array(
'nickname_text' => 'Name testClusterDelete',
'description_text' => 'description_ClusterDelete',
);
$this->drupalPost('design/cluster/create', $edit, t('Next'));
$this->assertResponse(200, t('HTTP 200: New Cluster Form | Add'));
$this->assertText(t('Cluster successfully created.'), t('Confirm Message:') . t('Cluster successfully created.'));
$this->assertNoText(t('Notice' ), t('Make sure w/o Notice' ));
$this->assertNoText(t('warning'), t('Make sure w/o Warnings'));
// Cluster | Delete
$this->drupalGet('design/cluster/delete/1' );
$this->assertResponse(200, t('HTTP 200: Cluster | Delete'));
$this->assertText(t('Cluster deleted successfully'), t('Found: Servers'));
$this->assertNoText(t('Notice' ), t('Make sure w/o Notice' ));
$this->assertNoText(t('warning'), t('Make sure w/o Warnings'));
}
}
\ No newline at end of file
<?php
/**
* @file
* Provides cluster feature which enables to bundle server templates.
* Works with Cloud and Server Templates module.
*
* Copyright (c) 2010-2011 DOCOMO Innovations, Inc.
*
*/
define('CLOUD_CLUSTER_PREFIX' , 'cloud_' );
define('CLOUD_CLUSTER_PATH' , 'design/cluster' );
define('CLOUD_CLUSTER_DISPLAY_NAME', 'Cluster' );
define('CLOUD_CLUSTER_TABLE' , CLOUD_CLUSTER_PREFIX . 'cluster' );
define('CLOUD_CLUSTER_SERVER_TABLE', CLOUD_CLUSTER_PREFIX . 'cluster_servers');
define('CLOUD_CLUSTER_PAGER_LIMIT', 50 );
<?php
/**
* @file
* Provides cluster feature which enables to bundle server templates.
* Works with Cloud and Server Templates module.
*
* Copyright (c) 2010-2011 DOCOMO Innovations, Inc.
*
*/
function _cloud_cluster_get_clusters_query() {
return db_select(CLOUD_CLUSTER_TABLE, 'a');
}
function _cloud_cluster_get_count_db() {
$cluster_count = 0;
$query = 'SELECT count(*) as cluster_count FROM {' . CLOUD_CLUSTER_TABLE . '} c ';
$result = db_query( $query);
foreach ($result as $cluster) {
$cluster_count = $cluster->cluster_count;
}
return $cluster_count;
}
function _cloud_cluster_get_cluster_by_id_query() {
return $query = 'SELECT c.cluster_id , c.cluster_nickname, c.description, c.creator FROM {' . CLOUD_CLUSTER_TABLE . '} c WHERE cluster_id= :cluster_id ';
}
function _cloud_cluster_get_cluster_by_filter_query() {
return $query = 'SELECT c.cluster_id , c.cluster_nickname, c.description, c.creator FROM {' . CLOUD_CLUSTER_TABLE . '} c WHERE cluster_nickname = :cluster_nickname ';
}
/**
* Insert a cluster in database
* This function insert entry in database and audit logs as well.
*
* @param $form_values
* This is the form-values submitted by new cluster form
* @return return a last inserted cluster-id
*/
function _cloud_cluster_save_cluster_db($form_values, $creator) {
$nid = db_insert(CLOUD_CLUSTER_TABLE)
->fields(array(
'cluster_nickname' => $form_values['nickname_text' ],
'description' => $form_values['description_text'],
'creator' => $creator,
))
->execute();
// User Activity Log
cloud_audit_user_activity( array(
'type' => 'user_activity',
'message' => t('Cluster has been added: @cluster_name', array('@cluster_name' => $form_values['nickname_text'])),
'link' => '',
)
);
// Get the id of newly inserted cluster
$cluster_id = NULL;
$result = db_select(CLOUD_CLUSTER_TABLE, 'n')
->fields('n')
->condition('cluster_nickname', $form_values['nickname_text' ], '=')
->condition('description', $form_values['description_text'], '=')
->condition('creator', $creator, '=')
->execute();
foreach ($result as $res_obj) {
$cluster_id = $res_obj->cluster_id;
}
return $cluster_id;
}
function _cloud_cluster_update_cluster_db($form_values, $cluster_id) {
$num_updated = db_update(CLOUD_CLUSTER_TABLE)
->fields(array(
'cluster_nickname' => $form_values['nickname_text'],
'description' => $form_values['description_text'],
))
->condition('cluster_id', $cluster_id, '=')
->execute();
// User Activity Log
cloud_audit_user_activity( array(
'type' => 'user_activity',
'message' => t('Cluster has been modified: @cluster_nickname', array('@cluster_nickname' => $form_values['nickname_text'])),
'link' => '',
)
);
return;
}
/**
* Delete a Cluster using Cluster Id
*
* @param $cluster_id
* @return
*/
function _cloud_cluster_delete_by_id($cluster_id) {
$num_deleted = db_delete(CLOUD_CLUSTER_SERVER_TABLE)
->condition('cluster_id', $cluster_id)
->execute();
$num_deleted = db_delete(CLOUD_CLUSTER_TABLE)
->condition('cluster_id', $cluster_id)
->execute();
// User Activity Log
cloud_audit_user_activity(array(
'type' => 'user_activity',
'message' => t('Cluster has been deleted: @cluster_id', array('@cluster_id' => $cluster_id)),
'link' => '',
)
);
return TRUE;
}
/**
* Return all cluster list
*
* @param $cloud
* @return
*/
function _cloud_cluster_get_all_clusters_query($cloud) {
return ' select * from {' . CLOUD_CLUSTER_TABLE . '} ';
}
// End : DB functions Related to Cluster
This diff is collapsed.
BASIC INFO
==========
- Cloud Dashboard module for displaying Cloud Instances details.
- Works with Cloud module.
KNOWN ISSUES
============
- "Usage Estimate" includes some bugs.
HOW TO USE
==========
1) Enable Dashboard module
2) Update cloud information (by clicking '- Refresh Page -' link) or
take any action (e.g. launch an instance, create a server template, etc.)
3) Go to the menu: Clouds | Dashboard
4) The Graphs in the Dashboard are generated using the JavaScript libraries Raphael and Ico.
The files "raphael-min.js" and "ico-min.js" must be present in the "js" directory of the core cloud module.
Please see the section titled "JS Dependencies" for the details of these JavaScript files.
For generating PDF Report:
===========================
This module is using Third Party PDF generating tool TCPDF.
TCPDF package from http://www.tcpdf.org is needed to generate the PDF Report.
You need to download the TCPDF package from htt://www.tcpdf.org and extract it in a directory.
e.g. Extract the TCPDF package inside /site/all/includes/tcpdf'.
Path to the file 'tcpdf.php' is '/site/all/includes/tcpdf/tcpdf.php'
Go to 'Site Administration -> Cloud Dashboard Settings.
In the 'Path for TCPDF Library Folder' textfield, provide the complete folder path where tcpdf.php file is located.
---------
You can also provide an Logo image path if you want to include at the top right section of the PDF Report.
Go to 'Site Administration -> Cloud Dashboard Settings.
In the 'Path of the Logo Image' textfield, provide the complete path of the image file.
Only JPG and GIF image format type are supported.
Date Time Formating
===================
Go to the Dashboard Setting page under Drupal Administration Settings and edit the Date and Time formating you want to display in the Dashboard PopUp Display.
Default Format for the Date is "Y, F j" and Time is "H:i:s". See http://php.net/manual/function.date.php for more Date and Time Formating Options.
Calender PopUp
==================
"Date" and "Date PopUp" module needs to be installed for enabling Calendar PopUp in Date inputs for fields "Start Date" and "End Date".
"jQuery UI" module also required for the Date PopUp to work. "Date PopUp" module have dependencies on "jQuery UI" module.
JS Dependencies
===============
For generating the graphs, the Dashboard module uses the JavaScript libraries - Raphael and Ico.
Raphael (http://raphaeljs.com/) allows the generation of vector graphics in the browser. Raphael is distributed under the MIT license.
Ico (http://alexyoung.github.com/ico/, http://alexyoung.org/2009/01/21/ico-svg-graphs-with-prototype-and-raphael/) allows
generation of simple graphs and charts using the Raphael API. Ico is distributed under the MIT license.
DIRECTORY STRUCTURE
===================
cloud
+-modules (depends on Cloud module) (Cloud is a core module for Cloud package)
+-cloud_activity_audit
+-cloud_alerts
x-cloud_auto_scaling
+-cloud_billing
+-cloud_cluster
o-cloud_dashboard
+-cloud_failover
+-cloud_inputs
+-cloud_metering
+-cloud_monitoring
+-cloud_pricing
+-cloud_resource_allocator
x-cloud_scaling_manager
+-cloud_scripting
+-cloud_server_templates
x... Not released yet.
Copyright
=========
Copyright (c) 2011 DOCOMO Innovations, Inc.
End of README.txt
\ No newline at end of file
This diff is collapsed.
name = Dashboard
description = Provides a Dashboard of Cloud Instances
package = Cloud
dependencies[] = cloud
dependencies[] = cloud_pricing
dependencies[] = cloud_metering
dependencies[] = cloud_server_templates
core = 7.x
; Information added by drupal.org packaging script on 2011-12-22
version = "7.x-1.x-dev"
core = "7.x"
project = "cloud"
datestamp = "1324555586"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment