Skip to content
This repository has been archived by the owner on Sep 23, 2020. It is now read-only.

Commit

Permalink
Change EPU references to Domain
Browse files Browse the repository at this point in the history
  • Loading branch information
priteau authored and labisso committed May 3, 2012
1 parent a47dc5b commit 3dc53ed
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 44 deletions.
14 changes: 7 additions & 7 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -59,20 +59,20 @@ To terminate all nodes and shut down the provisioner:
EPU Manager
-----------

To control the EPU manager, use the ``epu`` service name.
To control the EPU manager, use the ``domain`` service name.

To list all EPUs:
To list all domains:

``ceictl epu list``
``ceictl domain list``

To describe the EPU named `epu1`:
To describe the domain named `domain1`:

``ceictl epu describe epu1``
``ceictl domain describe domain1``

To reconfigure the EPU named `epu1` and change its engine configuration
To reconfigure the domain named `domain1` and change its engine configuration
parameter `preserve_n` to the integer value 2:

``ceictl epu reconfigure --int engine_conf.preserve_n=2 epu1``
``ceictl domain reconfigure --int engine_conf.preserve_n=2 domain1``

Boolean and string values can also be provided with the ``--bool`` and
``--string`` options.
Expand Down
22 changes: 11 additions & 11 deletions ceiclient/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,28 +110,28 @@ def update_credentials(self, caller, site_name, site_credentials):
class EPUMClient(CeiClient):

dashi_name = 'epu_management_service'
name = 'epu'
name = 'domain'
help = 'Control the EPU Management Service'

def __init__(self, connection, dashi_name=None):
if dashi_name:
self.dashi_name = dashi_name
self._connection = connection

def describe_epu(self, name, caller=None):
return self._connection.call(self.dashi_name, 'describe_epu', epu_name=name, caller=caller)
def describe_domain(self, name, caller=None):
return self._connection.call(self.dashi_name, 'describe_domain', domain_id=name, caller=caller)

def list_epus(self, caller=None):
return self._connection.call(self.dashi_name, 'list_epus', caller=caller)
def list_domains(self, caller=None):
return self._connection.call(self.dashi_name, 'list_domains', caller=caller)

def reconfigure_epu(self, name, config, caller=None):
return self._connection.call(self.dashi_name, 'reconfigure_epu', epu_name=name, epu_config=config, caller=caller)
def reconfigure_domain(self, name, config, caller=None):
return self._connection.call(self.dashi_name, 'reconfigure_domain', domain_id=name, config=config, caller=caller)

def add_epu(self, name, config, caller=None):
return self._connection.call(self.dashi_name, 'add_epu', epu_name=name, epu_config=config, caller=caller)
def add_domain(self, name, config, caller=None):
return self._connection.call(self.dashi_name, 'add_domain', domain_id=name, config=config, caller=caller)

def remove_epu(self, name, caller=None):
return self._connection.call(self.dashi_name, 'remove_epu', epu_name=name, caller=caller)
def remove_domain(self, name, caller=None):
return self._connection.call(self.dashi_name, 'remove_domain', domain_id=name, caller=caller)

commands = {}
for command in [EPUMDescribe, EPUMList, EPUMReconfigure, EPUMAdd, EPUMRemove]:
Expand Down
28 changes: 14 additions & 14 deletions ceiclient/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,27 +239,27 @@ class EPUMAdd(CeiCommand):

def __init__(self, subparsers):
parser = subparsers.add_parser(self.name)
parser.add_argument('epu_name', action='store', help='The name of the EPU to be added.')
parser.add_argument('domain_id', action='store', help='The name of the domain to be added.')
parser.add_argument('--conf', dest='de_conf', action='store', help='Set the type of decision engine to use.')

@staticmethod
def execute(client, opts):
stream = open(opts.de_conf, 'r')
conf = yaml.load(stream)
stream.close()
return client.add_epu(opts.epu_name, conf, caller=opts.caller)
return client.add_domain(opts.domain_id, conf, caller=opts.caller)

class EPUMRemove(CeiCommand):

name = 'remove'

def __init__(self, subparsers):
parser = subparsers.add_parser(self.name)
parser.add_argument('epu_name', action='store', help='The EPU to remove')
parser.add_argument('domain_id', action='store', help='The domain to remove')

@staticmethod
def execute(client, opts):
return client.remove_epu(opts.epu_name, caller=opts.caller)
return client.remove_domain(opts.domain_id, caller=opts.caller)


class EPUMDescribe(CeiCommand):
Expand All @@ -273,11 +273,11 @@ class EPUMDescribe(CeiCommand):

def __init__(self, subparsers):
parser = subparsers.add_parser(self.name)
parser.add_argument('epu_name', action='store', help='The EPU to describe')
parser.add_argument('domain_id', action='store', help='The domain to describe')

@staticmethod
def execute(client, opts):
return client.describe_epu(opts.epu_name, caller=opts.caller)
return client.describe_domain(opts.domain_id, caller=opts.caller)

@staticmethod
def output(result):
Expand All @@ -293,23 +293,23 @@ def __init__(self, subparsers):

@staticmethod
def execute(client, opts):
return client.list_epus(caller=opts.caller)
return client.list_domains(caller=opts.caller)

@staticmethod
def output(result):
for epu_name in result:
print epu_name
for domain_id in result:
print domain_id

class EPUMReconfigure(CeiCommand):

name = 'reconfigure'

def __init__(self, subparsers):
parser = subparsers.add_parser(self.name)
parser.add_argument('epu_name', action='store', help='The EPU to reconfigure')
parser.add_argument('--bool', dest='updated_kv_bool', action='append', help='Key to modify in the EPU configuration with a boolean value')
parser.add_argument('--int', dest='updated_kv_int', action='append', help='Key to modify in the EPU configuration with a integer value')
parser.add_argument('--string', dest='updated_kv_string', action='append', help='Key to modify in the EPU configuration with a string value')
parser.add_argument('domain_id', action='store', help='The domain to reconfigure')
parser.add_argument('--bool', dest='updated_kv_bool', action='append', help='Key to modify in the domain configuration with a boolean value')
parser.add_argument('--int', dest='updated_kv_int', action='append', help='Key to modify in the domain configuration with a integer value')
parser.add_argument('--string', dest='updated_kv_string', action='append', help='Key to modify in the domain configuration with a string value')

@staticmethod
def format_reconfigure(bool_reconfs=[], int_reconfs=[], string_reconfs=[]):
Expand Down Expand Up @@ -359,7 +359,7 @@ def format_reconfigure(bool_reconfs=[], int_reconfs=[], string_reconfs=[]):
@staticmethod
def execute(client, opts):
updated_kvs = EPUMReconfigure.format_reconfigure(bool_reconfs=opts.updated_kv_bool, int_reconfs=opts.updated_kv_int, string_reconfs=opts.updated_kv_string)
return client.reconfigure_epu(opts.epu_name, updated_kvs, caller=opts.caller)
return client.reconfigure_domain(opts.domain_id, updated_kvs, caller=opts.caller)

class PDDispatch(CeiCommand):

Expand Down
24 changes: 12 additions & 12 deletions ceiclient/tests/test_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,26 @@ def setUp(self):

def test_command_parsing_epum_describe_ok(self):
EPUMDescribe(self.subparsers)
opts = self.parser.parse_args(['describe', 'epu1'])
opts = self.parser.parse_args(['describe', 'domain1'])
assert opts.command == 'describe'
assert opts.epu_name == 'epu1'
assert opts.domain_id == 'domain1'

def test_command_parsing_epum_add_ok(self):
EPUMAdd(self.subparsers)
de_conf = "XXX"
opts = self.parser.parse_args(['add', 'epu2', "--conf", de_conf])
opts = self.parser.parse_args(['add', 'domain2', "--conf", de_conf])
assert opts.de_conf == "XXX"
assert opts.epu_name == 'epu2'
assert opts.domain_id == 'domain2'

def test_command_parsing_epum_remove_ok(self):
EPUMRemove(self.subparsers)
opts = self.parser.parse_args(['remove', 'epu2'])
assert opts.epu_name == 'epu2'
opts = self.parser.parse_args(['remove', 'domain2'])
assert opts.domain_id == 'domain2'

@raises(SystemExit)
def test_command_parsing_epum_describe_failing_wrong_command(self):
EPUMDescribe(self.subparsers)
opts = self.parser.parse_args(['list', 'epu1'])
opts = self.parser.parse_args(['list', 'domain1'])

@raises(SystemExit)
def test_command_parsing_epum_describe_failing_missing_argument(self):
Expand All @@ -58,13 +58,13 @@ def test_command_parsing_epum_reconfigure_ok(self):
intkvpair2 = 'another.key=24'
stringkvpair1 = 'a.string=a_string'
stringkvpair2 = 'a.string_again=another_string'
opts = self.parser.parse_args(['reconfigure', 'epu1', '--bool',
opts = self.parser.parse_args(['reconfigure', 'domain1', '--bool',
boolkvpair1, '--int', intkvpair1, '--bool', boolkvpair2,
'--string', stringkvpair1, '--string', stringkvpair2, '--int',
intkvpair2])

assert opts.command == 'reconfigure'
assert opts.epu_name == 'epu1'
assert opts.domain_id == 'domain1'
assert opts.updated_kv_bool == [boolkvpair1, boolkvpair2]
assert opts.updated_kv_int == [intkvpair1, intkvpair2]
assert opts.updated_kv_string == [stringkvpair1, stringkvpair2]
Expand Down Expand Up @@ -93,14 +93,14 @@ def test_command_parsing_epum_reconfigure_ok(self):
@raises(SystemExit)
def test_command_parsing_epum_reconfigure_failing_wrong_command(self):
EPUMReconfigure(self.subparsers)
opts = self.parser.parse_args(['describe', 'epu1', '42'])
opts = self.parser.parse_args(['describe', 'domain1', '42'])

@raises(SystemExit)
def test_command_parsing_epum_reconfigure_failing_not_enough_arguments(self):
EPUMReconfigure(self.subparsers)
opts = self.parser.parse_args(['describe', 'epu1'])
opts = self.parser.parse_args(['describe', 'domain1'])

@raises(SystemExit)
def test_command_parsing_epum_reconfigure_failing_wrong_arguments(self):
EPUMReconfigure(self.subparsers)
opts = self.parser.parse_args(['describe', 'epu1', 'notanumber'])
opts = self.parser.parse_args(['describe', 'domain1', 'notanumber'])

0 comments on commit 3dc53ed

Please sign in to comment.