-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
62fc261
commit f67dba7
Showing
96 changed files
with
10,142 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>maestro</name> | ||
<comment></comment> | ||
<projects> | ||
<project>salt</project> | ||
<project>salt-states</project> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>org.python.pydev.PyDevBuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>org.python.pydev.pythonNature</nature> | ||
</natures> | ||
</projectDescription> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="no"?> | ||
<?eclipse-pydev version="1.0"?><pydev_project> | ||
<pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">Default</pydev_property> | ||
<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python 2.7</pydev_property> | ||
<pydev_pathproperty name="org.python.pydev.PROJECT_SOURCE_PATH"> | ||
<path>/maestro/src</path> | ||
<path>/maestro/tests</path> | ||
<path>/maestro/client/python</path> | ||
<path>/maestro/taskmanager</path> | ||
</pydev_pathproperty> | ||
</pydev_project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
Building maestro is straightforward. | ||
|
||
- Install a python compiler. 32 or 64bit should work. Testing was done with 2.7 so I havent verified Python3 will work. | ||
|
||
- Install the dependencies in dependencies.txt | ||
|
||
- Run setup.py. It will generate a set of executables. | ||
|
||
- Install NSISETUP. cd to the PKG directory and run it on the NSI file there to generate the installer. | ||
|
||
Thats all there is to it. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<? | ||
include('inworldz_api.php'); | ||
|
||
$url = "https://10.0.0.1"; | ||
$login = "root"; /* login/user */ | ||
$password = "password"; /* password for the user */ | ||
|
||
/* Establish session with Xenserver */ | ||
$iwapi = new inworldz_api($url, $login, $password); | ||
|
||
/* Once sucessfully logged in - any method (valid or not) is passed to the XenServer. | ||
Replace the first period (.) of the method with a underscore (_) - because PHP doesnt like | ||
periods in the function names. | ||
All the methods (other then logging in) require passing the session_id as the first parameter, | ||
however this is done automatically - so you do not need to pass it. | ||
For example, to do VM.get_all(session_id) and get all the vms as an array, then get/print the details of each | ||
using VM.get_record(session_id, self) (self = VM object): | ||
*/ | ||
|
||
$vms_array = $iwapi->Console_get_all(); | ||
|
||
foreach ($vms_array as $vm) { | ||
$record = $iwpai->VM_get_record($vm); | ||
print_r($record); | ||
} | ||
|
||
/* | ||
To see how parametes are returned, print_r() is your friend :) | ||
*/ | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
<? | ||
/* | ||
* PHP IW API v1.0 | ||
* a class for InWorldz Remote API calls | ||
*/ | ||
|
||
class inworldz_api | ||
{ | ||
private $_url; | ||
|
||
private $_session_id; | ||
private $_user; | ||
private $_password; | ||
|
||
function __construct ($url, $user, $password) | ||
{ | ||
$r = $this->iwrpc_request($url, $this->iwrpc_method('session.login_with_password', array($user, $password, '1.3'))); | ||
if (is_array($r) && $r['Status'] == 'Success') | ||
{ | ||
$this->_session_id = $r['Value']; | ||
$this->_url = $url; | ||
$this->_user = $user; | ||
$this->_password = $password; | ||
} | ||
else | ||
{ | ||
echo "API failure. (" . implode(' ', $r['ErrorDescription']) . ")\n"; exit; | ||
} | ||
} | ||
|
||
function __call($name, $args) | ||
{ | ||
if (!is_array($args)) | ||
{ | ||
$args = array(); | ||
} | ||
list($mod, $method) = explode('_', $name, 2); | ||
$ret = $this->iwrpc_parseresponse( | ||
$this->iwrpc_request($this->_url, | ||
$this->iwrpc_method($mod . '.' . $method, array_merge(array($this->_session_id), $args)))); | ||
return $ret; | ||
} | ||
|
||
function iwrpc_parseresponse($response) | ||
{ | ||
if (!@is_array($response) && !@$response['Status']) | ||
{ | ||
echo "API failure. (500)\n"; exit; | ||
} | ||
else | ||
{ | ||
if ($response['Status'] == 'Success') | ||
{ | ||
$ret = $response['Value']; | ||
} | ||
else | ||
{ | ||
if ($response['ErrorDescription'][0] == 'SESSION_INVALID') | ||
{ | ||
$r = $this->iwrpc_request( | ||
$url, $this->iwrpc_method('session.login_with_password', | ||
array($this->_user, $this->_password, '1.3'))); | ||
if (!is_array($r) && $r['Status'] == 'Success') | ||
{ | ||
$this->_session_id = $r['Value']; | ||
} | ||
else | ||
{ | ||
echo "API failure. (session)\n"; exit; | ||
} | ||
} | ||
else | ||
{ | ||
echo "API failure. (" . implode(' ', $response['ErrorDescription']) . ")\n"; exit; | ||
} | ||
} | ||
} | ||
return $ret; | ||
} | ||
|
||
function iwrpc_method($name, $params) | ||
{ | ||
$ret = xmlrpc_encode_request($name, $params); | ||
return $ret; | ||
} | ||
|
||
function iwrpc_request($url, $req) | ||
{ | ||
$headers = array('Content-type: text/xml', 'Content-length: ' . strlen($req)); | ||
$ch = curl_init($url); | ||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST'); | ||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5); | ||
curl_setopt($ch, CURLOPT_TIMEOUT, 60); | ||
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); | ||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); | ||
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE); | ||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | ||
curl_setopt($ch, CURLOPT_POSTFIELDS, $req); | ||
$resp = curl_exec($ch); | ||
curl_close($ch); | ||
|
||
$ret = xmlrpc_decode($resp); | ||
return $ret; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
import os | ||
import sys | ||
import time | ||
import logging | ||
import pprint | ||
|
||
from maestro.rpcclient import Session | ||
from optparse import OptionParser | ||
|
||
__all__ = [] | ||
__version__ = 0.1 | ||
__date__ = '2012-11-14' | ||
__updated__ = '2012-11-14' | ||
|
||
DEBUG = 0 | ||
TESTRUN = 0 | ||
PROFILE = 0 | ||
|
||
def main(argv=None): | ||
'''Command line options.''' | ||
program_name = os.path.basename(sys.argv[0]) | ||
program_version = "v0.1" | ||
program_build_date = "%s" % __updated__ | ||
|
||
program_version_string = '%%prog %s (%s)' % (program_version, program_build_date) | ||
#program_usage = '''usage: spam two eggs''' # optional - will be autogenerated by optparse | ||
program_longdesc = '''''' # optional - give further explanation about what the program does | ||
program_license = "Copyright (c) 2015 InWorldz Inc. All Rights Reserved. Released under the Apache 2.0 License" | ||
|
||
if argv is None: | ||
argv = sys.argv[1:] | ||
try: | ||
# setup option parser | ||
parser = OptionParser(version=program_version_string, epilog=program_longdesc, description=program_license) | ||
|
||
parser.add_option("-p", "--password", dest="password", help="The password to use when connecting to the remote agent [default: %default]") | ||
parser.add_option("-u", "--username", dest="username", help="The username to use when connecting [default: %default]") | ||
parser.add_option("-v", "--verbose", dest="verbose", action="count", help="set verbosity level [default: %default]") | ||
# set defaults | ||
parser.set_defaults(password="", username="", verbose=1) | ||
|
||
# process options | ||
(opts, args) = parser.parse_args(argv) | ||
|
||
if opts.verbose > 0: | ||
print("verbosity level = %d" % opts.verbose) | ||
|
||
# Set up logging | ||
logging.basicConfig(level=logging.DEBUG) | ||
|
||
# session = Session('http://127.0.0.1:9000/xmlrpc/RemoteAdmin/') | ||
# sessionid = session.api.login_with_password(opts.username, opts.password) | ||
# session.api.Region.Shutdown("1fcbcb04-c56c-4baa-babb-92666faa4a5a", 30) | ||
|
||
session = Session('http://127.0.0.1:8006/xmlrpc/RemoteAdmin/') | ||
sessionid = session.api.login_with_password(opts.username, opts.password) | ||
session.api.MessagingServer.Shutdown(30) | ||
|
||
session = Session('http://127.0.0.1:8002/xmlrpc/RemoteAdmin/') | ||
sessionid = session.api.login_with_password(opts.username, opts.password) | ||
session.api.UserServer.Shutdown(30) | ||
|
||
session = Session('http://127.0.0.1:8009/xmlrpc/RemoteAdmin/') | ||
sessionid = session.api.login_with_password(opts.username, opts.password) | ||
session.api.GridServer.Shutdown(30) | ||
|
||
except Exception, e: | ||
indent = len(program_name) * " " | ||
sys.stderr.write(program_name + ": " + repr(e) + "\n") | ||
sys.stderr.write(indent + " for help use --help") | ||
return 2 | ||
|
||
if __name__ == "__main__": | ||
if DEBUG: | ||
sys.argv.append("-h") | ||
|
||
if TESTRUN: | ||
import doctest | ||
doctest.testmod() | ||
|
||
if PROFILE: | ||
import cProfile | ||
import pstats | ||
profile_filename = '_profile.txt' | ||
cProfile.run('main()', profile_filename) | ||
statsfile = open("profile_stats.txt", "wb") | ||
p = pstats.Stats(profile_filename, stream=statsfile) | ||
stats = p.strip_dirs().sort_stats('cumulative') | ||
stats.print_stats() | ||
statsfile.close() | ||
sys.exit(0) | ||
|
||
sys.exit(main()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
import os | ||
import sys | ||
import time | ||
import logging | ||
import pprint | ||
|
||
from maestro.rpcclient import Session | ||
from optparse import OptionParser | ||
|
||
__all__ = [] | ||
__version__ = 0.1 | ||
__date__ = '2012-11-14' | ||
__updated__ = '2012-11-14' | ||
|
||
DEBUG = 0 | ||
TESTRUN = 0 | ||
PROFILE = 0 | ||
|
||
def main(argv=None): | ||
'''Command line options.''' | ||
program_name = os.path.basename(sys.argv[0]) | ||
program_version = "v0.1" | ||
program_build_date = "%s" % __updated__ | ||
|
||
program_version_string = '%%prog %s (%s)' % (program_version, program_build_date) | ||
#program_usage = '''usage: spam two eggs''' # optional - will be autogenerated by optparse | ||
program_longdesc = '''''' # optional - give further explanation about what the program does | ||
program_license = "Copyright (c) 2015 InWorldz Inc. All Rights Reserved. Released under the Apache 2.0 License" | ||
|
||
if argv is None: | ||
argv = sys.argv[1:] | ||
try: | ||
# setup option parser | ||
parser = OptionParser(version=program_version_string, epilog=program_longdesc, description=program_license) | ||
|
||
parser.add_option("-p", "--password", dest="password", help="The password to use when connecting to the remote agent [default: %default]") | ||
parser.add_option("-u", "--username", dest="username", help="The username to use when connecting [default: %default]") | ||
parser.add_option("-v", "--verbose", dest="verbose", action="count", help="set verbosity level [default: %default]") | ||
# set defaults | ||
parser.set_defaults(password="", username="", verbose=1) | ||
|
||
# process options | ||
(opts, args) = parser.parse_args(argv) | ||
|
||
if opts.verbose > 0: | ||
print("verbosity level = %d" % opts.verbose) | ||
|
||
# Set up logging | ||
logging.basicConfig(level=logging.DEBUG) | ||
|
||
session = Session('http://127.0.0.1:12089/') | ||
sessionid = session.api.login_with_password(opts.username, opts.password) | ||
|
||
hosts = session.api.RegionHost.get_all() | ||
pprint.pprint(hosts) | ||
|
||
host = hosts[0] | ||
|
||
print "shutting down regions" | ||
regions = session.api.Region.get_all() | ||
|
||
for region in regions: | ||
print session.api.Region.Shutdown(region, 60) | ||
|
||
print "shutting down grid services" | ||
user_servers = session.api.UserServer.get_all() | ||
for user_server in user_servers: | ||
print session.api.UserServer.Shutdown(user_server, 60) | ||
|
||
msg_servers = session.api.MessagingServer.get_all() | ||
for msg_server in msg_servers: | ||
print session.api.MessagingServer.Shutdown(msg_server, 60) | ||
|
||
grid_servers = session.api.GridServer.get_all() | ||
for grid_server in grid_servers: | ||
print session.api.GridServer.Shutdown(grid_server, 60) | ||
|
||
print "Completed" | ||
|
||
session.api.session.logout() | ||
|
||
except Exception, e: | ||
indent = len(program_name) * " " | ||
sys.stderr.write(program_name + ": " + repr(e) + "\n") | ||
sys.stderr.write(indent + " for help use --help") | ||
return 2 | ||
|
||
if __name__ == "__main__": | ||
if DEBUG: | ||
sys.argv.append("-h") | ||
|
||
if TESTRUN: | ||
import doctest | ||
doctest.testmod() | ||
|
||
if PROFILE: | ||
import cProfile | ||
import pstats | ||
profile_filename = '_profile.txt' | ||
cProfile.run('main()', profile_filename) | ||
statsfile = open("profile_stats.txt", "wb") | ||
p = pstats.Stats(profile_filename, stream=statsfile) | ||
stats = p.strip_dirs().sort_stats('cumulative') | ||
stats.print_stats() | ||
statsfile.close() | ||
sys.exit(0) | ||
|
||
sys.exit(main()) | ||
|
||
|
Empty file.
Oops, something went wrong.