Commit 32a292da authored by Romain Courteaud's avatar Romain Courteaud

revert slapos changes

parent c6e4fbe5
......@@ -69,17 +69,17 @@ Examples
>>> # Request instance
>>> request(product.kvm, "myuniquekvm")
>>> # Request instance on specific compute_node
>>> # Request instance on specific computer
>>> request(product.kvm, "myotheruniquekvm",
filter_kw={ "compute_node_guid": "COMP-12345" })
filter_kw={ "computer_guid": "COMP-12345" })
>>> # Request instance, specifying parameters (here nbd_ip and nbd_port)
>>> request(product.kvm, "mythirduniquekvm",
partition_parameter_kw={"nbd_ip":"2a01:e35:2e27:460:e2cb:4eff:fed9:48dc",
"nbd_port":"1024"})
>>> # Request software installation on owned compute_node
>>> supply(product.kvm, "mycompute_node")
>>> # Request software installation on owned computer
>>> supply(product.kvm, "mycomputer")
>>> # Fetch existing instance status
>>> request(product.kvm, "myuniquekvm").getState()
......
......@@ -11,7 +11,7 @@ It "formats" the machine by:
- creating needed directories with proper ownership and permissions
- (optional-manager) creating cgroup resource tree for slapos
It reads configuration from /etc/opt/slapos/slapos.cfg and formats compute_node
It reads configuration from /etc/opt/slapos/slapos.cfg and formats computer
accordingly. The variables are number of partitions, IP addresses, storages
and network interfaces.
......
......@@ -15,7 +15,7 @@ For more informations about SLAP and SlapOS, please see the SLAP documentation.
Requirements
------------
A working SLAP server with informations about your compute_node, in order to
A working SLAP server with informations about your computer, in order to
retrieve them.
As Vifib servers use IPv6 only, we strongly recommend an IPv6 enabled UNIX
......@@ -33,20 +33,20 @@ Concepts
Here are the fundamental concepts of slapgrid :
A Software Release (SR) is just a software.
A Compute Partition (CP) is an instance of a Software Release.
A Computer Partition (CP) is an instance of a Software Release.
Imagine you want to install with slapgrid some software and run it. You will
have to install the software as a Software Release, and then instantiate it,
i.e configuring it for your needs, as a Compute Partition.
i.e configuring it for your needs, as a Computer Partition.
How it works
------------
When run, slapgrid will authenticate to the SLAP library with a compute_node_id and
fetch the list of Software Releases to install or remove and ComputeNode
When run, slapgrid will authenticate to the SLAP library with a computer_id and
fetch the list of Software Releases to install or remove and Computer
Partitions to start or stop.
Then, it will process each Software Release, and each Compute Partition.
It will also periodically send to SLAP the usage report of each ComputeNode
Then, it will process each Software Release, and each Computer Partition.
It will also periodically send to SLAP the usage report of each Computer
Partition.
......@@ -59,9 +59,9 @@ With easy_install::
slapgrid needs several directories to be created and configured before being
able to run : a software releases directory, and an instances directory with
configured compute partition directory(ies).
You should create for each Compute Partition directory created a specific user
and associate it with its Compute Partition directory. Each Compute Partition
configured computer partition directory(ies).
You should create for each Computer Partition directory created a specific user
and associate it with its Computer Partition directory. Each Computer Partition
directory should belongs to this specific user, with permissions of 0750.
......@@ -71,7 +71,7 @@ Usage
slapgrid needs several informations in order to run. You can specify them by
adding arguments to the slapgrid command line, or by putting then in a
configuration file.
Beware : you need a valid compute_node resource on server side.
Beware : you need a valid computer resource on server side.
Examples
......@@ -82,7 +82,7 @@ Just run slapgrid:
$ slapgrid --instance-root /path/to/instance/root --software-root
/path/to/software_root --master-url https://some.server/some.resource
--compute-node-id my.compute_node.id
--computer-id my.computer.id
configuration file example::
......@@ -91,7 +91,7 @@ configuration file example::
instance_root = /path/to/instance/root
software_root = /path/to/software/root
master_url = https://slapos.server/slap_service
compute_node_id = my.compute_node.id
computer_id = my.computer.id
then run slapgrid::
......
......@@ -2,7 +2,7 @@ proxy
=====
Implement minimalist SlapOS Master server without any security, designed to work
only from localhost with one SlapOS Node (a.k.a ComputeNode).
only from localhost with one SlapOS Node (a.k.a Computer).
It implements (or should implement) the SLAP API, as currently implemented in
the SlapOS Master (see slaptool.py in Master).
......
......@@ -6,16 +6,16 @@ Simple Language for Accounting and Provisioning python library.
How it works
------------
The SLAP main server which is in charge of service coordination receives from participating servers the number of compute_node paritions which are available, the type of resource which a party is ready provide, and request from parties for resources which are needed.
The SLAP main server which is in charge of service coordination receives from participating servers the number of computer paritions which are available, the type of resource which a party is ready provide, and request from parties for resources which are needed.
Each participating server is identified by a unique ID and runs a slap-server daemon. This daemon collects from the main server the installation tasks and does the installation of resources, then notifies the main server of completion whenever a resource is configured, installed and available.
The data structure on the main server is the following:
* A - Action: an action which can happen to provide a resource or account its usage
* CP - Compute Partition: provides a URL to Access a Cloud Resource
* CP - Computer Partition: provides a URL to Access a Cloud Resource
* RI - Resource Item: describes a resource
* CI - Contract Item: describes the contract to attach the DL to (This is unclear still)
* R - Resource: describes a type of cloud resource (ex. MySQL Table) is published on slapgrid.org
* DL - Delivery Line: Describes an action happening on a resource item on a compute partition
* DL - Delivery Line: Describes an action happening on a resource item on a computer partition
* D - Delivery: groups multiple Delivery Lines
\ No newline at end of file
......@@ -32,7 +32,7 @@ import slapos.slap.slap
def do_bang(configp, message):
compute_node_id = configp.get('slapos', 'compute_node_id')
computer_id = configp.get('slapos', 'computer_id')
master_url = configp.get('slapos', 'master_url')
if configp.has_option('slapos', 'key_file'):
key_file = configp.get('slapos', 'key_file')
......@@ -44,7 +44,7 @@ def do_bang(configp, message):
cert_file = None
slap = slapos.slap.slap()
slap.initializeConnection(master_url, key_file=key_file, cert_file=cert_file)
compute_node = slap.registerComputeNode(compute_node_id)
computer = slap.registerComputer(computer_id)
print('Banging to %r' % master_url)
compute_node.bang(message)
computer.bang(message)
print('Bang with message %r' % message)
......@@ -121,7 +121,7 @@ end
subcommands_descriptions.setdefault('cache', 'Manage cache')
subcommands_descriptions.setdefault('configure', 'Manage configuration')
subcommands_descriptions.setdefault('compute_node', 'Manage compute_node')
subcommands_descriptions.setdefault('computer', 'Manage computer')
subcommands_descriptions.setdefault('node', 'Manage node')
subcommands_descriptions.setdefault('proxy', 'Manage proxy')
subcommands_descriptions.setdefault('service', 'Manage services')
......
......@@ -37,13 +37,13 @@ from slapos.slap import ResourceNotReady, NotFoundError
class InfoCommand(ClientConfigCommand):
"""get information of an compute_node"""
"""get information of an computer"""
def get_parser(self, prog_name):
ap = super(InfoCommand, self).get_parser(prog_name)
ap.add_argument('reference',
help='Your compute_node reference')
help='Your computer reference')
return ap
......@@ -60,14 +60,14 @@ class InfoCommand(ClientConfigCommand):
def do_info(logger, conf, local):
resetLogger(logger)
try:
compute_node = local['slap'].registerComputeNode(conf.reference).getInformation()
computer = local['slap'].registerComputer(conf.reference).getInformation()
except ResourceNotReady:
logger.warning('Compute Node does not exist or is not ready yet.')
logger.warning('Computer does not exist or is not ready yet.')
return(2)
except NotFoundError:
logger.warning('Compute Node %s does not exist.', conf.reference)
logger.warning('Computer %s does not exist.', conf.reference)
return(2)
logger.info('Compute Node Reference: %s', compute_node._reference)
logger.info('Compute Node Title : %s', compute_node._title)
logger.info('Computer Reference: %s', computer._reference)
logger.info('Computer Title : %s', computer._title)
......@@ -52,10 +52,10 @@ class ListCommand(ClientConfigCommand):
def do_list(logger, conf, local):
resetLogger(logger)
compute_node_dict = local['slap'].getComputeNodeDict()
if compute_node_dict == {}:
logger.info('No existing compute_node.')
computer_dict = local['slap'].getComputerDict()
if computer_dict == {}:
logger.info('No existing computer.')
return
logger.info('List of ComputeNodes:')
for title, compute_node in six.iteritems(compute_node_dict):
logger.info('%s %s', compute_node._reference, title)
logger.info('List of Computers:')
for title, computer in six.iteritems(computer_dict):
logger.info('%s %s', computer._reference, title)
......@@ -37,7 +37,7 @@ from slapos.slap import ResourceNotReady, NotFoundError
class TokenCommand(ClientConfigCommand):
"""get token for setup a compute_node"""
"""get token for setup a computer"""
def get_parser(self, prog_name):
ap = super(TokenCommand, self).get_parser(prog_name)
......@@ -58,11 +58,11 @@ def do_token(logger, conf, local):
try:
token = local['slap'].registerToken().request()
except ResourceNotReady:
logger.warning('Compute Node does not exist or is not ready yet.')
logger.warning('Computer does not exist or is not ready yet.')
return(2)
except NotFoundError:
logger.warning('Compute Node %s does not exist.', conf.reference)
logger.warning('Computer %s does not exist.', conf.reference)
return(2)
logger.info('Compute Node token: %s', token)
logger.info('Computer token: %s', token)
......@@ -41,7 +41,7 @@ from slapos.grid.utils import updateFile, createPrivateDirectory
from slapos.grid.svcbackend import launchSupervisord
from slapos.util import bytes2str
DEFAULT_COMPUTE_NODE_ID = 'local_compute_node'
DEFAULT_COMPUTER_ID = 'local_computer'
class ConfigureLocalCommand(ConfigCommand):
......@@ -132,14 +132,14 @@ def _generateSlaposNodeConfigurationFile(slapos_node_config_path, args):
master_url = 'http://%s:%s' % (args.daemon_listen_ip, args.daemon_listen_port)
slapos_home = args.slapos_buildout_directory
to_replace = [
('compute_node_id', DEFAULT_COMPUTE_NODE_ID),
('computer_id', DEFAULT_COMPUTER_ID),
('master_url', master_url),
('interface_name', args.interface_name),
('ipv4_local_network', args.ipv4_local_network),
('partition_amount', args.partition_number),
('instance_root', args.slapos_instance_root),
('software_root', args.slapos_software_root),
('compute_node_xml', '%s/slapos.xml' % slapos_home),
('computer_xml', '%s/slapos.xml' % slapos_home),
('log_file', '%s/log/slapos-node-format.log' % slapos_home),
('use_unique_local_address_block', 'false')
]
......@@ -164,7 +164,7 @@ def _generateSlaposProxyConfigurationFile(conf):
('host', listening_ip),
('port', listening_port),
('master_url', 'http://%s:%s/' % (listening_ip, listening_port)),
('compute_node_id', DEFAULT_COMPUTE_NODE_ID),
('computer_id', DEFAULT_COMPUTER_ID),
('instance_root', conf.instance_root),
('software_root', conf.software_root)
]
......
......@@ -49,8 +49,8 @@ class ConsoleCommand(ClientConfigCommand):
examples :
>>> # Request instance
>>> request(kvm, "myuniquekvm")
>>> # Request software installation on owned compute_node
>>> supply(kvm, "mycompute_node")
>>> # Request software installation on owned computer
>>> supply(kvm, "mycomputer")
>>> # Fetch instance informations on already launched instance
>>> request(kvm, "myuniquekvm").getConnectionParameter("url")
"""
......@@ -122,8 +122,8 @@ slapos console allows you interact with slap API. You can play with the global
examples :
>>> # Request instance
>>> request(kvm, "myuniquekvm")
>>> # Request software installation on owned compute_node
>>> supply(kvm, "mycompute_node")
>>> # Request software installation on owned computer
>>> supply(kvm, "mycomputer")
>>> # Fetch instance informations on already launched instance
>>> request(kvm, "myuniquekvm").getConnectionParameter("url")
"""
......
......@@ -45,24 +45,24 @@ class FormatCommand(ConfigCommand):
def get_parser(self, prog_name):
ap = super(FormatCommand, self).get_parser(prog_name)
ap.add_argument('-x', '--compute_node_xml',
ap.add_argument('-x', '--computer_xml',
default=argparse.SUPPRESS, #can't use default here because it would overwrite .cfg
help="Path to file with compute_node's XML. If does not exists, will be created")
help="Path to file with computer's XML. If does not exists, will be created")
ap.add_argument('--compute_node_json',
ap.add_argument('--computer_json',
default=argparse.SUPPRESS, #can't use default here because it would overwrite .cfg
help="Path to a JSON version of the compute_node's XML (for development only)")
help="Path to a JSON version of the computer's XML (for development only)")
ap.add_argument('-i', '--input_definition_file',
default=argparse.SUPPRESS, #can't use default here because it would overwrite .cfg
help="Path to file to read definition of compute_node instead of "
help="Path to file to read definition of computer instead of "
"declaration. Using definition file allows to disable "
"'discovery' of machine services and allows to define compute_node "
"'discovery' of machine services and allows to define computer "
"configuration in fully controlled manner.")
ap.add_argument('-o', '--output_definition_file',
default=argparse.SUPPRESS, #can't use default here because it would overwrite .cfg
help="Path to file to write definition of compute_node from "
help="Path to file to write definition of computer from "
"declaration.")
ap.add_argument('--alter_user',
......
......@@ -65,8 +65,8 @@ class ProxyShowCommand(ConfigCommand):
ap.add_argument('-u', '--database-uri',
help='URI for sqlite database')
ap.add_argument('--compute-nodes',
help='view compute_node information',
ap.add_argument('--computers',
help='view computer information',
action='store_true')
ap.add_argument('--software',
......@@ -167,11 +167,11 @@ def log_params(logger, conn):
logger.info(' %s = %s', name, text)
def log_compute_node_table(logger, conn):
tbl_compute_node = 'compute_node' + DB_VERSION
def log_computer_table(logger, conn):
tbl_computer = 'computer' + DB_VERSION
cur = conn.cursor()
qry = cur.execute("SELECT * FROM %s" % tbl_compute_node)
log_table(logger, qry, tbl_compute_node)
qry = cur.execute("SELECT * FROM %s" % tbl_computer)
log_table(logger, qry, tbl_computer)
def log_software_table(logger, conn):
......@@ -236,7 +236,7 @@ def do_show(conf):
lambda s: hashlib.md5(str2bytes(s)).hexdigest())
call_table = [
(conf.compute_nodes, log_compute_node_table),
(conf.computers, log_computer_table),
(conf.software, log_software_table),
(conf.partitions, log_partition_table),
(conf.slaves, log_slave_table),
......
......@@ -43,7 +43,7 @@ from slapos.cli.command import Command, must_be_root
class RegisterCommand(Command):
"""
Register a new compute_node on SlapOS Master.
Register a new computer on SlapOS Master.
This command will generate everything you need for run your slapos node,
The files at /etc/opt/slapos (by default):
......@@ -106,7 +106,7 @@ class RegisterCommand(Command):
'should be avoided for security reasons.')
ap.add_argument('--token',
help="SlapOS 'compute node security' authentication token")
help="SlapOS 'computer security' authentication token")
ap.add_argument('--create-tap', '-t',
action='store_true',
......@@ -148,16 +148,16 @@ def get_certificate_key_pair(logger, master_url_web, node_name, token=None, logi
"""Download certificates from SlapOS Master"""
if token:
req = requests.post('/'.join([master_url_web, 'Person_requestComputeNode']),
req = requests.post('/'.join([master_url_web, 'Person_requestComputer']),
data={'title': node_name},
headers={'X-Access-Token': token},
verify=False)
else:
register_server_url = '/'.join([master_url_web, ("Person_requestComputeNode?title={}".format(node_name))])
register_server_url = '/'.join([master_url_web, ("Person_requestComputer?title={}".format(node_name))])
req = requests.get(register_server_url, auth=(login, password), verify=False)
if not req.ok and 'Certificate still active.' in req.text:
# raise a readable exception if the compute_node name is already used,
# raise a readable exception if the computer name is already used,
# instead of an opaque 500 Internal Error.
# this will not work with the new API.
logger.error('The node name "%s" is already in use. '
......@@ -182,8 +182,8 @@ def get_certificate_key_pair(logger, master_url_web, node_name, token=None, logi
json_dict = json.loads(req.text)
return json_dict["certificate"], json_dict["key"]
def get_compute_node_name(certificate):
"""Parse certificate to get compute_node name and return it"""
def get_computer_name(certificate):
"""Parse certificate to get computer name and return it"""
k = certificate.find("COMP-")
i = certificate.find("/email", k)
return certificate[k:i]
......@@ -265,7 +265,7 @@ def slapconfig(conf):
cfg = fetch_configuration_template()
to_replace = [
('compute_node_id', conf.compute_node_id),
('computer_id', conf.computer_id),
('master_url', conf.master_url),
('key_file', key_file),
('cert_file', cert_file),
......@@ -304,14 +304,14 @@ class RegisterConfig(object):
for option, value in options.__dict__.items():
setattr(self, option, value)
def COMPConfig(self, slapos_configuration, compute_node_id, certificate, key):
def COMPConfig(self, slapos_configuration, computer_id, certificate, key):
self.slapos_configuration = slapos_configuration
self.compute_node_id = compute_node_id
self.computer_id = computer_id
self.certificate = certificate
self.key = key
def displayUserConfig(self):
self.logger.debug('Compute Node Name: %s', self.node_name)
self.logger.debug('Computer Name: %s', self.node_name)
self.logger.debug('Master URL: %s', self.master_url)
self.logger.debug('Number of partition: %s', self.partition_number)
self.logger.info('Using Interface %s', self.interface_name)
......@@ -332,7 +332,7 @@ def gen_auth(conf):
def do_register(conf):
"""Register new compute_node on SlapOS Master and generate slapos.cfg"""
"""Register new computer on SlapOS Master and generate slapos.cfg"""
if conf.login or conf.login_auth:
for login, password in gen_auth(conf):
......@@ -349,19 +349,19 @@ def do_register(conf):
password=password)
else:
while not conf.token:
conf.token = input('Compute Node security token: ').strip()
conf.token = input('Computer security token: ').strip()
certificate, key = get_certificate_key_pair(conf.logger,
conf.master_url_web,
conf.node_name,
token=conf.token)
# get compute_node id
COMP = get_compute_node_name(certificate)
# get computer id
COMP = get_computer_name(certificate)
# Getting configuration parameters
conf.COMPConfig(slapos_configuration='/etc/opt/slapos/',
compute_node_id=COMP,
computer_id=COMP,
certificate=certificate,
key=key)
......
......@@ -54,10 +54,10 @@ class RemoveCommand(ClientConfigCommand):
do_remove(self.app.log, args.software_url, args.node, local)
def do_remove(logger, software_url, compute_node_id, local):
def do_remove(logger, software_url, computer_id, local):
"""
Request deletion of Software Release
'software_url' from compute_node 'compute_node_id'.
'software_url' from computer 'computer_id'.
"""
logger.info('Requesting deletion of %s Software Release...', software_url)
......@@ -65,7 +65,7 @@ def do_remove(logger, software_url, compute_node_id, local):
software_url = local[software_url]
local['slap'].registerSupply().supply(
software_release=software_url,
compute_node_guid=compute_node_id,
computer_guid=computer_id,
state='destroyed'
)
logger.info('Done.')
......@@ -66,7 +66,7 @@ class RequestCommand(ClientConfigCommand):
ap.add_argument('--node',
nargs='+',
help="Node request option 'option1=value1 option2=value2' (i.e. compute_node_guid=COMP-1234)")
help="Node request option 'option1=value1 option2=value2' (i.e. computer_guid=COMP-1234)")
ap.add_argument('--type',
help='Software type to be requested')
......
......@@ -54,8 +54,8 @@ class SlapgridCommand(ConfigCommand):
help='The software_root directory location.')
ap.add_argument('--master-url',
help='The master server URL. Mandatory.')
ap.add_argument('--compute-node-id',
help='The compute_node id defined in the server.')
ap.add_argument('--computer-id',
help='The computer id defined in the server.')
ap.add_argument('--supervisord-socket',
help='The socket supervisor will use.')
ap.add_argument('--supervisord-configuration-path',
......@@ -147,7 +147,7 @@ class SoftwareCommand(SlapgridCommand):
class InstanceCommand(SlapgridCommand):
"""run instance deployment"""
method_name = 'processComputePartitionList'
method_name = 'processComputerPartitionList'
default_pidfile = '/opt/slapos/slapgrid-cp.pid'
pidfile_option_name = 'pidfile_instance'
......@@ -162,11 +162,11 @@ class InstanceCommand(SlapgridCommand):
help='Stop the services even for instances requested as started')
only = ap.add_mutually_exclusive_group()
only.add_argument('--all', action='store_true',
help='Process all Compute Partitions.')
help='Process all Computer Partitions.')
only.add_argument('--only-cp', '--only',
help='Update a single or a list of compute partitions '
help='Update a single or a list of computer partitions '
'(ie.:slappartX, slappartY), '
'this option will make all other compute partitions be ignored.')
'this option will make all other computer partitions be ignored.')
return ap
......
......@@ -53,10 +53,10 @@ class SupplyCommand(ClientConfigCommand):
do_supply(self.app.log, args.software_url, args.node, local)
def do_supply(logger, software_release, compute_node_id, local):
def do_supply(logger, software_release, computer_id, local):
"""
Request installation of Software Release
'software_release' on compute_node 'compute_node_id'.
'software_release' on computer 'computer_id'.
"""
logger.info('Requesting software installation of %s...',
software_release)
......@@ -66,7 +66,7 @@ def do_supply(logger, software_release, compute_node_id, local):
local['supply'](
software_release=software_release,
compute_node_guid=compute_node_id,
computer_guid=computer_id,
state='available'
)
logger.info('Done.')
......@@ -98,7 +98,7 @@ def init(conf, logger):
def shorthandRequest(*args, **kwargs):
return slap.registerOpenOrder().request(*args, **kwargs)
def shorthandSupply(*args, **kwargs):
# XXX-Cedric Implement compute_node_group support
# XXX-Cedric Implement computer_group support
return slap.registerSupply().supply(*args, **kwargs)
local['request'] = shorthandRequest
local['supply'] = shorthandSupply
......
......@@ -3,13 +3,13 @@
Collecting Data
================
The "slapos node collect" command collects data from a compute_node taking a
The "slapos node collect" command collects data from a computer taking a
few snapshot on different scopes and storing it (currently on sqllite3).
Scopes of Snapshots are:
- User Processes: Collects data from all user's process related to SlapOS (ie.: slapuser*)
- System Information: Collects data from the System Usage and Compute Node Hardware.
- System Information: Collects data from the System Usage and Computer Hardware.
So on every slapos node collect calls (perfomed by cron on every minute), the
slapos stores the all snapshots for future analizes.
......@@ -34,16 +34,16 @@ System Information Snapshot
============================
Those snapshots has 2 different goals, first is collect current load from existing
compute_node (cpu, memory, disk, network...) and the second goal is collect the
available resources the compute_node has installed [4].
computer (cpu, memory, disk, network...) and the second goal is collect the
available resources the computer has installed [4].
We use 3 types of snapshots for determinate the load and the available resources
(all mostly use psutils to collect data):
- System Snapshot [5]: It collects general compute_node usage like CPU, Memory
- System Snapshot [5]: It collects general computer usage like CPU, Memory
and Network IO usage.
- Compute Node Snapshot [6]: It collects for now number of CPU cores and available
- Computer Snapshot [6]: It collects for now number of CPU cores and available
memory, however we wish to collect more details.
- Disk Snapshot [7]: It collects information related to the a disk
......@@ -72,7 +72,7 @@ plot easily with dygraph, so there will be few files available like this:
- system_net_out_dropped.csv
- system_net_out_errors.csv
All contains only information from compute_node usage, for global usage (for now). It
All contains only information from computer usage, for global usage (for now). It
is perfectly acceptable keep a realtime copy in csv of the most recently data.
Logrotate
......@@ -108,7 +108,7 @@ easily described like below [11]:
time (text)
reported (integer)
- compute_node
- computer
cpu_num_core (real)
cpu_frequency (real
cpu_type (text)
......
......@@ -37,14 +37,14 @@ from slapos.util import mkdir_p
import os
import stat
from slapos.collect.snapshot import ProcessSnapshot, ComputeNodeSnapshot
from slapos.collect.snapshot import ProcessSnapshot, ComputerSnapshot
from slapos.collect.reporter import RawCSVDumper, \
SystemCSVReporterDumper, \
compressLogFolder, \
ConsumptionReport, \
PartitionReport
from .entity import get_user_list, ComputeNode
from .entity import get_user_list, Computer
def _get_time():
return strftime("%Y-%m-%d -- %H:%M:%S", gmtime()).split(" -- ")
......@@ -106,7 +106,7 @@ def do_collect(logger, conf):
xml_report_directory = "%s/var/xml_report/%s" % \
(conf.get("slapos", "instance_root"),
conf.get("slapos", "compute_node_id"))
conf.get("slapos", "computer_id"))
mkdir_p(xml_report_directory, 0o755)
logger.debug("XML report directory: %s", xml_report_directory)
......@@ -120,7 +120,7 @@ def do_collect(logger, conf):
"computer_model_id")
else:
computer_model_id = "no_model"
logger.debug("Compute Node model id: %s", computer_model_id)
logger.debug("Computer model id: %s", computer_model_id)
uptime = _get_uptime()
......@@ -138,13 +138,13 @@ def do_collect(logger, conf):
test_heating = False
logger.debug("Heating sensor id: %s", heating_sensor_id)
logger.info("Inserting compute_node information into database...")
compute_node = ComputeNode(ComputeNodeSnapshot(model_id=computer_model_id,
logger.info("Inserting computer information into database...")
computer = Computer(ComputerSnapshot(model_id=computer_model_id,
sensor_id = heating_sensor_id,
test_heating=test_heating))
# Insert compute_node's data
compute_node.save(database, collected_date, collected_time)
# Insert computer's data
computer.save(database, collected_date, collected_time)
logger.info("Done.")
logger.info("Inserting user information into database...")
......@@ -161,7 +161,7 @@ def do_collect(logger, conf):
# Write xml files
consumption_report = ConsumptionReport(
compute_node_id=conf.get("slapos", "compute_node_id"),
computer_id=conf.get("slapos", "computer_id"),
user_list=user_dict,
database=database,
location=consumption_report_directory)
......
......@@ -59,7 +59,7 @@ class Database:
"(partition text, disk_used real, date text, " \
" time text, reported integer NULL DEFAULT 0)"
CREATE_COMPUTE_NODE_TABLE = "create table if not exists compute_node "\
CREATE_COMPUTER_TABLE = "create table if not exists computer "\
"(cpu_num_core real, cpu_frequency real, cpu_type text," \
" memory_size real, memory_type text, partition_list text," \
" date text, time text, reported integer NULL DEFAULT 0)"
......@@ -96,7 +96,7 @@ class Database:
"partition, disk_used, date, time) values " \
"('%s', %s, '%s', '%s' )"
INSERT_COMPUTE_NODE_TEMPLATE = "insert into compute_node("\
INSERT_COMPUTER_TEMPLATE = "insert into computer("\
" cpu_num_core, cpu_frequency, cpu_type," \
"memory_size, memory_type, partition_list," \
"date, time) values "\
......@@ -164,7 +164,7 @@ class Database:
self._execute(self.CREATE_USER_TABLE)
self._execute(self.CREATE_USER_PARTITION_DATE_TIME_INDEX)
self._execute(self.CREATE_FOLDER_TABLE)
self._execute(self.CREATE_COMPUTE_NODE_TABLE)
self._execute(self.CREATE_COMPUTER_TABLE)
self._execute(self.CREATE_SYSTEM_TABLE)
self._execute(self.CREATE_DISK_PARTITION)
self._execute(self.CREATE_TEMPERATURE_TABLE)
......@@ -208,12 +208,12 @@ class Database:
self._execute(insertion_sql)
return insertion_sql
def insertComputeNodeSnapshot(self, cpu_num_core, cpu_frequency, cpu_type,
def insertComputerSnapshot(self, cpu_num_core, cpu_frequency, cpu_type,
memory_size, memory_type, partition_list, insertion_date, insertion_time):
"""Insert Compute Node general informations snapshots informations on
"""Insert Computer general informations snapshots informations on
the database
"""
insertion_sql = self.INSERT_COMPUTE_NODE_TEMPLATE % \
insertion_sql = self.INSERT_COMPUTER_TEMPLATE % \
( cpu_num_core, cpu_frequency, cpu_type,
memory_size, memory_type,
partition_list, insertion_date,
......
......@@ -137,14 +137,14 @@ class User(object):
self._insertDiskSnapShot(database, collected_date, collected_time)
class ComputeNode(dict):
class Computer(dict):
def __init__(self, compute_node_snapshot):
self.compute_node_snapshot = compute_node_snapshot
def __init__(self, computer_snapshot):
self.computer_snapshot = computer_snapshot
def save(self, database, collected_date, collected_time):
database.connect()
self._save_compute_node_snapshot(database, collected_date, collected_time)
self._save_computer_snapshot(database, collected_date, collected_time)
self._save_system_snapshot(database, collected_date, collected_time)
self._save_disk_partition_snapshot(database, collected_date, collected_time)
self._save_temperature_snapshot(database, collected_date, collected_time)
......@@ -152,21 +152,21 @@ class ComputeNode(dict):
database.commit()
database.close()
def _save_compute_node_snapshot(self, database, collected_date, collected_time):
def _save_computer_snapshot(self, database, collected_date, collected_time):
partition_list = ";".join(["%s=%s" % (x,y) for x,y in \
self.compute_node_snapshot.get("partition_list")])
database.insertComputeNodeSnapshot(
cpu_num_core=self.compute_node_snapshot.get("cpu_num_core"),
cpu_frequency=self.compute_node_snapshot.get("cpu_frequency"),
cpu_type=self.compute_node_snapshot.get("cpu_type"),
memory_size=self.compute_node_snapshot.get("memory_size"),
memory_type=self.compute_node_snapshot.get("memory_type"),
self.computer_snapshot.get("partition_list")])
database.insertComputerSnapshot(
cpu_num_core=self.computer_snapshot.get("cpu_num_core"),
cpu_frequency=self.computer_snapshot.get("cpu_frequency"),
cpu_type=self.computer_snapshot.get("cpu_type"),
memory_size=self.computer_snapshot.get("memory_size"),
memory_type=self.computer_snapshot.get("memory_type"),
partition_list=partition_list,
insertion_date=collected_date,
insertion_time=collected_time)
def _save_system_snapshot(self, database, collected_date, collected_time):
snapshot = self.compute_node_snapshot.get("system_snapshot")
snapshot = self.computer_snapshot.get("system_snapshot")
database.insertSystemSnapshot(
loadavg=snapshot.get("load"),
cpu_percent=snapshot.get("cpu_percent"),
......@@ -182,7 +182,7 @@ class ComputeNode(dict):
insertion_time=collected_time)
def _save_disk_partition_snapshot(self, database, collected_date, collected_time):
for disk_partition in self.compute_node_snapshot.get("disk_snapshot_list"):
for disk_partition in self.computer_snapshot.get("disk_snapshot_list"):
database.insertDiskPartitionSnapshot(
partition=disk_partition.partition,
used=disk_partition.disk_size_used,
......@@ -192,7 +192,7 @@ class ComputeNode(dict):
insertion_time=collected_time)
def _save_temperature_snapshot(self, database, collected_date, collected_time):
for temperature_snapshot in self.compute_node_snapshot.get("temperature_snapshot_list"):
for temperature_snapshot in self.computer_snapshot.get("temperature_snapshot_list"):
database.insertTemperatureSnapshot(
sensor_id=temperature_snapshot.sensor_id,
temperature=temperature_snapshot.temperature,
......@@ -201,7 +201,7 @@ class ComputeNode(dict):
insertion_time=collected_time)
def _save_heating_snapshot(self, database, collected_date, collected_time):
heating_snapshot = self.compute_node_snapshot.get("heating_contribution_snapshot")
heating_snapshot = self.computer_snapshot.get("heating_contribution_snapshot")
if heating_snapshot is not None and \
heating_snapshot.initial_temperature is not None:
database.insertHeatingSnapshot(
......
......@@ -377,8 +377,8 @@ class PartitionReport(ConsumptionReportBase):
class ConsumptionReport(ConsumptionReportBase):
def __init__(self, database, compute_node_id, location, user_list):
self.compute_node_id = compute_node_id
def __init__(self, database, computer_id, location, user_list):
self.computer_id = computer_id
self.user_list = user_list
self.location = location
ConsumptionReportBase.__init__(self, database)
......@@ -396,7 +396,7 @@ class ConsumptionReport(ConsumptionReportBase):
transaction = journal.newTransaction()
journal.setProperty(transaction, "title", "Eco Information for %s " % self.compute_node_id)
journal.setProperty(transaction, "title", "Eco Information for %s " % self.computer_id)
journal.setProperty(transaction, "start_date", "%s 00:00:00" % date_scope)
journal.setProperty(transaction, "stop_date", "%s 23:59:59" % date_scope)
......@@ -416,7 +416,7 @@ class ConsumptionReport(ConsumptionReportBase):
resource="service_module/cpu_load_percent",
title="CPU Load Percent Average",
quantity=str(cpu_load_percent),
reference=self.compute_node_id,
reference=self.computer_id,
category="")
memory_used = self._getMemoryAverageConsumption(date_scope)
......@@ -426,7 +426,7 @@ class ConsumptionReport(ConsumptionReportBase):
resource="service_module/memory_used",
title="Used Memory",
quantity=str(memory_used),
reference=self.compute_node_id,
reference=self.computer_id,
category="")
......@@ -435,7 +435,7 @@ class ConsumptionReport(ConsumptionReportBase):
resource="service_module/zero_emission_ratio",
title="Zero Emission Ratio",
quantity=str(self._getZeroEmissionContribution()),
reference=self.compute_node_id,
reference=self.computer_id,
category="")
for user in self.user_list:
......
......@@ -32,7 +32,7 @@ import psutil
import os
import subprocess
import logging
from .temperature import collectComputeNodeTemperature, launchTemperatureTest
from .temperature import collectComputerTemperature, launchTemperatureTest
from .temperature.heating import get_contribution_ratio
......@@ -81,7 +81,7 @@ class FolderSizeSnapshot(_Snapshot):
"""Calculate partition folder size.
"""
def __init__(self, folder_path, pid_file=None, use_quota=False):
# slapos compute partition size
# slapos computer partition size
self.folder_path = folder_path
self.pid_file = pid_file
self.disk_usage = 0
......@@ -207,8 +207,8 @@ class DiskPartitionSnapshot(_Snapshot):
self.disk_size_free = disk.free
self.disk_size_percent = disk.percent
class ComputeNodeSnapshot(_Snapshot):
""" Take a snapshot from compute_node informations
class ComputerSnapshot(_Snapshot):
""" Take a snapshot from computer informations
"""
def __init__(self, model_id=None, sensor_id=None, test_heating=False):
self.cpu_num_core = psutil.cpu_count()
......@@ -219,7 +219,7 @@ class ComputeNodeSnapshot(_Snapshot):
#
# Include a SystemSnapshot and a list DiskPartitionSnapshot
# on a Compute Node Snapshot
# on a Computer Snapshot
#
self.system_snapshot = SystemSnapshot()
self.temperature_snapshot_list = self._get_temperature_snapshot_list()
......@@ -231,7 +231,7 @@ class ComputeNodeSnapshot(_Snapshot):
def _get_temperature_snapshot_list(self):
temperature_snapshot_list = []
for sensor_entry in collectComputeNodeTemperature():
for sensor_entry in collectComputerTemperature():
sensor_id, temperature, maximal, critical, alarm = sensor_entry
temperature_snapshot_list.append(
TemperatureSnapshot(sensor_id, temperature, alarm))
......
......@@ -17,7 +17,7 @@ try:
except NotImplementedError:
DEFAULT_CPU = 1
def collectComputeNodeTemperature(sensor_bin="sensors"):
def collectComputerTemperature(sensor_bin="sensors"):
result = subprocess.run((sensor_bin, '-u'),
universal_newlines=True,
stdout=subprocess.PIPE,
......@@ -95,7 +95,7 @@ def launchTemperatureTest(sensor_id, sensor_bin="sensors", timeout=600, interval
signal.signal(signal.SIGINT, sigint_handler)
def getTemperatureForSensor(s_id):
for collected_temperature in collectComputeNodeTemperature(sensor_bin):
for collected_temperature in collectComputerTemperature(sensor_bin):
if collected_temperature[0] == sensor_id:
return collected_temperature[1], collected_temperature[4]
......
This diff is collapsed.
......@@ -58,7 +58,7 @@ from slapos.util import bytes2str, rmtree
WATCHDOG_MARK = '-on-watch'
REQUIRED_COMPUTE_PARTITION_PERMISSION = 0o750
REQUIRED_COMPUTER_PARTITION_PERMISSION = 0o750
CP_STORAGE_FOLDER_NAME = 'DATA'
......@@ -411,8 +411,8 @@ class Partition(object):
instance_path,
supervisord_partition_configuration_path,
supervisord_socket,
compute_partition,
compute_node_id,
computer_partition,
computer_id,
partition_id,
server_url,
software_release_url,
......@@ -437,8 +437,8 @@ class Partition(object):
self.supervisord_partition_configuration_path = \
supervisord_partition_configuration_path
self.supervisord_socket = supervisord_socket
self.compute_partition = compute_partition
self.compute_node_id = compute_node_id
self.computer_partition = computer_partition
self.computer_id = computer_id
self.partition_id = partition_id
self.server_url = server_url
self.software_release_url = software_release_url
......@@ -486,7 +486,7 @@ class Partition(object):
def _updateCertificate(self):
try:
partition_certificate = self.compute_partition.getCertificate()
partition_certificate = self.computer_partition.getCertificate()
except NotFoundError:
raise NotFoundError('Partition %s is not known by SlapOS Master.' %
self.partition_id)
......@@ -577,8 +577,8 @@ class Partition(object):
""" Creates configuration file from template in software_path, then
installs the software partition with the help of buildout
"""
self.logger.info("Installing Compute Partition %s..."
% self.compute_partition.getId())
self.logger.info("Installing Computer Partition %s..."
% self.computer_partition.getId())
self.check_free_space()
......@@ -593,11 +593,11 @@ class Partition(object):
instance_stat_info = os.stat(self.instance_path)
permission = stat.S_IMODE(instance_stat_info.st_mode)
if permission != REQUIRED_COMPUTE_PARTITION_PERMISSION:
if permission != REQUIRED_COMPUTER_PARTITION_PERMISSION:
raise WrongPermissionError('Wrong permissions in %s: actual '
'permissions are: 0%o, wanted are 0%o' %
(self.instance_path, permission,
REQUIRED_COMPUTE_PARTITION_PERMISSION))
REQUIRED_COMPUTER_PARTITION_PERMISSION))
os.environ = getCleanEnvironment(logger=self.logger,
home_path=pwd.getpwuid(instance_stat_info.st_uid).pw_dir)
......@@ -627,7 +627,7 @@ class Partition(object):
buildout_text = f.read()
buildout_text += '\n\n' + bytes2str(pkg_resources.resource_string(__name__,
'templates/buildout-tail.cfg.in')) % {
'compute_node_id': self.compute_node_id,
'computer_id': self.computer_id,
'partition_id': self.partition_id,
'server_url': self.server_url,
'software_release_url': self.software_release_url,
......@@ -728,7 +728,7 @@ class Partition(object):
if os.path.exists(self.supervisord_partition_configuration_path):
os.unlink(self.supervisord_partition_configuration_path)
else:
partition_id = self.compute_partition.getId()
partition_id = self.computer_partition.getId()
group_partition_template = bytes2str(pkg_resources.resource_string(__name__,
'templates/group_partition_supervisord.conf.in'))
self.supervisor_configuration_group = group_partition_template % {
......@@ -763,22 +763,22 @@ class Partition(object):
"""Asks supervisord to start the instance. If this instance is not
installed, we install it.
"""
partition_id = self.compute_partition.getId()
partition_id = self.computer_partition.getId()
try:
with self.getSupervisorRPC() as supervisor:
supervisor.startProcessGroup(partition_id, False)
except xmlrpclib.Fault as exc:
if exc.faultString.startswith('BAD_NAME:'):
self.logger.info("Nothing to start on %s..." %
self.compute_partition.getId())
self.computer_partition.getId())
else:
raise
else:
self.logger.info("Requested start of %s..." % self.compute_partition.getId())
self.logger.info("Requested start of %s..." % self.computer_partition.getId())
def stop(self):
"""Asks supervisord to stop the instance."""
partition_id = self.compute_partition.getId()
partition_id = self.computer_partition.getId()
try:
with self.getSupervisorRPC() as supervisor:
supervisor.stopProcessGroup(partition_id, False)
......@@ -788,13 +788,13 @@ class Partition(object):
else:
raise
else:
self.logger.info("Requested stop of %s..." % self.compute_partition.getId())
self.logger.info("Requested stop of %s..." % self.computer_partition.getId())
def destroy(self):
"""Destroys the partition and makes it available for subsequent use."
"""
self.logger.info("Destroying Compute Partition %s..."
% self.compute_partition.getId())
self.logger.info("Destroying Computer Partition %s..."
% self.computer_partition.getId())
self.createRetentionLockDate()
if not self.checkRetentionIsAuthorized():
......@@ -815,7 +815,7 @@ class Partition(object):
stderr=subprocess.STDOUT,
logger=self.logger)
if process_handler.returncode is None or process_handler.returncode != 0:
message = 'Failed to destroy Compute Partition in %r.' % \
message = 'Failed to destroy Computer Partition in %r.' % \
self.instance_path
self.logger.error(message)
raise subprocess.CalledProcessError(message, process_handler.output)
......
......@@ -273,13 +273,13 @@ class PromiseLauncher(object):
master-url
SlapOS Master service URL
partition-cert
Compute Partition Certificate file
Computer Partition Certificate file
partition-key
Compute Partition key file
Computer Partition key file
partition-id
Compute Partition ID, ex: slappart13
compute-node-id
Compute Node ID, ex: COMP-1234
Computer Partition ID, ex: slappart13
computer-id
Computer ID, ex: COMP-1234
uid
User UID
gid
......@@ -305,7 +305,7 @@ class PromiseLauncher(object):
'partition-cert': None,
'partition-key': None,
'partition-id': None,
'compute-node-id': None,
'computer-id': None,
'check-anomaly': False,
'force': False,
'run-only-promise-list': None
......@@ -414,7 +414,7 @@ class PromiseLauncher(object):
'memory_resource': 'monitor_resource_memory.data',
'io_resource': 'monitor_resource_io.data',
'monitor_process_state': 'monitor_resource.status'},
aggregate_reference=config.get('compute-node-id'),
aggregate_reference=config.get('computer-id'),
partition_id=config.get('partition-id')
)
......@@ -724,7 +724,7 @@ class PromiseLauncher(object):
'partition-cert': self.partition_cert,
'partition-key': self.partition_key,
'partition-id': self.partition_id,
'compute-node-id': self.compute_node_id,
'computer-id': self.computer_id,
'queue': self.queue_result,
'slapgrid-version': version,
}
......
......@@ -261,7 +261,7 @@ class GenericPromise(with_metaclass(ABCMeta, object)):
"""
if 'master-url' in self.__config and \
'partition-id' in self.__config and \
'compute-node-id' in self.__config:
'computer-id' in self.__config:
slap = slapos.slap.slap()
slap.initializeConnection(
......@@ -269,11 +269,11 @@ class GenericPromise(with_metaclass(ABCMeta, object)):
self.__config.get('partition-key'),
self.__config.get('partition-cert'),
)
compute_partition = slap.registerComputePartition(
self.__config['compute-node-id'],
computer_partition = slap.registerComputerPartition(
self.__config['computer-id'],
self.__config['partition-id'],
)
compute_partition.bang(message)
computer_partition.bang(message)
self.logger.info("Bang with message %r." % message)
def __getResultFromString(self, result_string, only_failure=False):
......
This diff is collapsed.
......@@ -7,7 +7,7 @@ bin-directory = ${buildout:directory}/sbin
offline = true
[slap-connection]
compute-node-id = %(compute_node_id)s
computer-id = %(computer_id)s
partition-id = %(partition_id)s
server-url = %(server_url)s
software-release-url = %(software_release_url)s
......@@ -16,7 +16,7 @@ cert-file = %(cert_file)s
[slap_connection]
# Kept for backward compatiblity
compute_node_id = %(compute_node_id)s
computer_id = %(computer_id)s
partition_id = %(partition_id)s
server_url = %(server_url)s
software_release_url = %(software_release_url)s
......
......@@ -33,8 +33,8 @@ import sys
import six
import slapos.slap.slap
from slapos.grid.slapgrid import COMPUTE_PARTITION_TIMESTAMP_FILENAME, \
COMPUTE_PARTITION_LATEST_BANG_TIMESTAMP_FILENAME
from slapos.grid.slapgrid import COMPUTER_PARTITION_TIMESTAMP_FILENAME, \
COMPUTER_PARTITION_LATEST_BANG_TIMESTAMP_FILENAME
from slapos.grid.SlapObject import WATCHDOG_MARK
......@@ -44,8 +44,8 @@ def parseArgumentTuple():
parser.add_argument("--master-url",
help="The master server URL. Mandatory.",
required=True)
parser.add_argument("--compute-node-id",
help="The compute_node id defined in the server.",
parser.add_argument("--computer-id",
help="The computer id defined in the server.",
required=True)
parser.add_argument("--certificate-repository-path",
help="Path to partition certificates.",
......@@ -67,10 +67,10 @@ class Watchdog(object):
process_state_events = ['PROCESS_STATE_EXITED', 'PROCESS_STATE_FATAL']
def __init__(self, master_url, compute_node_id,
def __init__(self, master_url, computer_id,
certificate_repository_path=None, instance_root_path=None):
self.master_url = master_url
self.compute_node_id = compute_node_id
self.computer_id = computer_id
self.certificate_repository_path = certificate_repository_path
self.instance_root_path = instance_root_path
......@@ -128,11 +128,11 @@ class Watchdog(object):
)
partition_timestamp_file_path = os.path.join(
partition_home_path,
COMPUTE_PARTITION_TIMESTAMP_FILENAME
COMPUTER_PARTITION_TIMESTAMP_FILENAME
)
slapos_last_bang_timestamp_file_path = os.path.join(
partition_home_path,
COMPUTE_PARTITION_LATEST_BANG_TIMESTAMP_FILENAME
COMPUTER_PARTITION_LATEST_BANG_TIMESTAMP_FILENAME
)
if not os.path.exists(slapos_last_bang_timestamp_file_path):
......@@ -170,11 +170,11 @@ class Watchdog(object):
)
partition_timestamp_file_path = os.path.join(
partition_home_path,
COMPUTE_PARTITION_TIMESTAMP_FILENAME
COMPUTER_PARTITION_TIMESTAMP_FILENAME
)
slapos_last_bang_timestamp_file_path = os.path.join(
partition_home_path,
COMPUTE_PARTITION_LATEST_BANG_TIMESTAMP_FILENAME
COMPUTER_PARTITION_LATEST_BANG_TIMESTAMP_FILENAME
)
if os.path.exists(partition_timestamp_file_path):
with open(partition_timestamp_file_path, 'r') as f:
......@@ -187,8 +187,8 @@ class Watchdog(object):
def handle_process_state_change_event(self, headers, payload_dict):
partition_id = payload_dict['groupname']
self.initialize_connection(partition_id)
partition = slapos.slap.ComputePartition(
compute_node_id=self.compute_node_id,
partition = slapos.slap.ComputerPartition(
computer_id=self.computer_id,
connection_helper=self.slap._connection_helper,
partition_id=partition_id)
partition.bang("%s process in partition %s encountered a problem"
......
......@@ -38,13 +38,13 @@ class Manager(object):
"""We don't need to mingle with software."""
pass
def format(self, compute_node):
def format(self, computer):
"""Create cgroup folder per-CPU with exclusive access to the CPU.
- Those folders are "/sys/fs/cgroup/cpuset/cpu<N>".
"""
if not os.path.exists(os.path.join(self.cpuset_path, "cpuset.cpus")):
logger.warning("CPUSet Manager cannot format compute_node because cgroups do not exist.")
logger.warning("CPUSet Manager cannot format computer because cgroups do not exist.")
return
for cpu in self._cpu_id_list():
......@@ -57,15 +57,15 @@ class Manager(object):
with open(cpu_path + "/cpuset.mems", "wt") as fx:
fx.write("0") # it doesn't work without that
def formatTearDown(self, compute_node):
def formatTearDown(self, computer):
pass
def instance(self, partition):
"""Control runtime state of the compute_node."""
"""Control runtime state of the computer."""
if not os.path.exists(os.path.join(self.cpuset_path, "cpu0")):
# check whether the compute_node was formatted
logger.warning("CGROUP's CPUSET Manager cannot update compute_node because it is not cpuset-formatted.")
# check whether the computer was formatted
logger.warning("CGROUP's CPUSET Manager cannot update computer because it is not cpuset-formatted.")
return
request_file = os.path.join(partition.instance_path, self.cpu_exclusive_file)
......
......@@ -30,16 +30,16 @@ class Manager(object):
if line:
self.allowed_disk_for_vm.append(line)
def format(self, compute_node):
def format(self, computer):
"""Method called at `slapos node format` phase.
:param compute_node: slapos.format.ComputeNode, currently formatted compute_node
:param computer: slapos.format.Computer, currently formatted computer
"""
def formatTearDown(self, compute_node):
def formatTearDown(self, computer):
"""Method called after `slapos node format` phase.
:param compute_node: slapos.format.ComputeNode, formatted compute_node
:param computer: slapos.format.Computer, formatted computer
"""
def software(self, software):
......@@ -51,7 +51,7 @@ class Manager(object):
def softwareTearDown(self, software):
"""Method called after `slapos node software` phase.
:param compute_node: slapos.grid.SlapObject.Software, processed software
:param computer: slapos.grid.SlapObject.Software, processed software
"""
def instance(self, partition):
......
......@@ -3,7 +3,7 @@ from zope.interface import Interface
class IManager(Interface):
"""Manager is called in every step of preparation of the compute_node."""
"""Manager is called in every step of preparation of the computer."""
def __init__(config):
"""Manager needs to know config for its functioning.
......@@ -11,16 +11,16 @@ class IManager(Interface):
:param conf: dictionary-like object with full access to [slapos] section of the config file
"""
def format(compute_node):
def format(computer):
"""Method called at `slapos node format` phase.
:param compute_node: slapos.format.ComputeNode, currently formatted compute_node
:param computer: slapos.format.Computer, currently formatted computer
"""
def formatTearDown(compute_node):
def formatTearDown(computer):
"""Method called after `slapos node format` phase.
:param compute_node: slapos.format.ComputeNode, formatted compute_node
:param computer: slapos.format.Computer, formatted computer
"""
def software(software):
......@@ -32,7 +32,7 @@ class IManager(Interface):
def softwareTearDown(software):
"""Method called after `slapos node software` phase.
:param compute_node: slapos.grid.SlapObject.Software, processed software
:param computer: slapos.grid.SlapObject.Software, processed software
"""
def instance(partition):
......
......@@ -32,16 +32,16 @@ class Manager(object):
"""
self.config = config
def format(self, compute_node):
def format(self, computer):
"""Method called at `slapos node format` phase.
:param compute_node: slapos.format.ComputeNode, currently formatted compute_node
:param computer: slapos.format.Computer, currently formatted computer
"""
def formatTearDown(self, compute_node):
def formatTearDown(self, computer):
"""Method called after `slapos node format` phase.
:param compute_node: slapos.format.ComputeNode, formatted compute_node
:param computer: slapos.format.Computer, formatted computer
"""
def software(self, software):
......@@ -53,7 +53,7 @@ class Manager(object):
def softwareTearDown(self, software):
"""Method called after `slapos node software` phase.
:param compute_node: slapos.grid.SlapObject.Software, processed software
:param computer: slapos.grid.SlapObject.Software, processed software
"""
def instance(self, partition):
......@@ -81,8 +81,8 @@ class Manager(object):
return
# Get partitions IPv6 address
compute_partition = partition.compute_partition
parameter_dict = compute_partition.getInstanceParameterDict()
computer_partition = partition.computer_partition
parameter_dict = computer_partition.getInstanceParameterDict()
partition_ip_list = parameter_dict['ip_list'] + parameter_dict.get(
'full_ip_list', [])
......
......@@ -6,28 +6,28 @@ import subprocess
from zope.interface import implementer
from slapos.manager import interface
from slapos.grid.slapgrid import COMPUTE_PARTITION_WAIT_LIST_FILENAME
from slapos.grid.slapgrid import COMPUTER_PARTITION_WAIT_LIST_FILENAME
logger = logging.getLogger(__name__)
@implementer(interface.IManager)
class Manager(object):
"""Manager is called in every step of preparation of the compute_node."""
"""Manager is called in every step of preparation of the computer."""
def __init__(self, config):
"""Manager needs to know config for its functioning.
"""
pass
def format(self, compute_node):
def format(self, computer):
"""Method called at `slapos node format` phase.
"""
pass
def formatTearDown(self, compute_node):
def formatTearDown(self, computer):
"""Method called after `slapos node format` phase.
:param compute_node: slapos.format.ComputeNode, formatted compute_node
:param computer: slapos.format.Computer, formatted computer
"""
pass
......@@ -39,7 +39,7 @@ class Manager(object):
def softwareTearDown(self, software):
"""Method called after `slapos node software` phase.
:param compute_node: slapos.grid.SlapObject.Software, processed software
:param computer: slapos.grid.SlapObject.Software, processed software
"""
pass
......@@ -63,7 +63,7 @@ class Manager(object):
return
wait_filepath = os.path.join(partition.instance_path,
COMPUTE_PARTITION_WAIT_LIST_FILENAME)
COMPUTER_PARTITION_WAIT_LIST_FILENAME)
if not os.path.exists(partition.prerm_path):
return
partition_id = partition.partition_id
......
......@@ -61,16 +61,16 @@ class Manager(object):
"""
self.config = 'firewall' in config and config['firewall'] or None
def format(self, compute_node):
def format(self, computer):
"""Method called at `slapos node format` phase.
:param compute_node: slapos.format.ComputeNode, currently formatted compute_node
:param computer: slapos.format.Computer, currently formatted computer
"""
def formatTearDown(self, compute_node):
def formatTearDown(self, computer):
"""Method called after `slapos node format` phase.
:param compute_node: slapos.format.ComputeNode, formatted compute_node
:param computer: slapos.format.Computer, formatted computer
"""
def software(self, software):
......@@ -83,7 +83,7 @@ class Manager(object):
def softwareTearDown(self, software):
"""Method called after `slapos node software` phase.
:param compute_node: slapos.grid.SlapObject.Software, processed software
:param computer: slapos.grid.SlapObject.Software, processed software
"""
def instance(self, partition):
......
......@@ -89,7 +89,7 @@ class ProxyConfig(object):
def setupFlaskConfiguration(conf):
app.config['compute_node_id'] = conf.compute_node_id
app.config['computer_id'] = conf.computer_id
app.config['DATABASE_URI'] = conf.database_uri
app.config['software_product_list'] = conf.software_product_list
app.config['multimaster'] = conf.multimaster
......
......@@ -6,13 +6,13 @@ INSERT INTO local_software_release_root%(version)s VALUES(NULL);
CREATE TABLE IF NOT EXISTS software%(version)s (
url VARCHAR(255),
compute_node_reference VARCHAR(255) DEFAULT '%(compute_node)s',
computer_reference VARCHAR(255) DEFAULT '%(computer)s',
requested_state VARCHAR(255) DEFAULT 'available',
CONSTRAINT uniq PRIMARY KEY (url, compute_node_reference)
CONSTRAINT uniq PRIMARY KEY (url, computer_reference)
);
CREATE TABLE IF NOT EXISTS compute_node%(version)s (
reference VARCHAR(255) DEFAULT '%(compute_node)s',
CREATE TABLE IF NOT EXISTS computer%(version)s (
reference VARCHAR(255) DEFAULT '%(computer)s',
address VARCHAR(255),
netmask VARCHAR(255),
CONSTRAINT uniq PRIMARY KEY (reference)
......@@ -20,7 +20,7 @@ CREATE TABLE IF NOT EXISTS compute_node%(version)s (
CREATE TABLE IF NOT EXISTS partition%(version)s (
reference VARCHAR(255),
compute_node_reference VARCHAR(255) DEFAULT '%(compute_node)s',
computer_reference VARCHAR(255) DEFAULT '%(computer)s',
slap_state VARCHAR(255) DEFAULT 'free',
software_release VARCHAR(255),
xml TEXT,
......@@ -32,12 +32,12 @@ CREATE TABLE IF NOT EXISTS partition%(version)s (
-- slapproxy does not support proper scope
requested_state VARCHAR(255) NOT NULL DEFAULT 'started',
timestamp REAL,
CONSTRAINT uniq PRIMARY KEY (reference, compute_node_reference)
CONSTRAINT uniq PRIMARY KEY (reference, computer_reference)
);
CREATE TABLE IF NOT EXISTS slave%(version)s (
reference VARCHAR(255), -- unique slave reference
compute_node_reference VARCHAR(255) DEFAULT '%(compute_node)s',
computer_reference VARCHAR(255) DEFAULT '%(computer)s',
connection_xml TEXT,
hosted_by VARCHAR(255),
asked_by VARCHAR(255) -- only used for debugging,
......@@ -46,7 +46,7 @@ CREATE TABLE IF NOT EXISTS slave%(version)s (
CREATE TABLE IF NOT EXISTS partition_network%(version)s (
partition_reference VARCHAR(255),
compute_node_reference VARCHAR(255) DEFAULT '%(compute_node)s',
computer_reference VARCHAR(255) DEFAULT '%(computer)s',
reference VARCHAR(255),
address VARCHAR(255),
netmask VARCHAR(255)
......
This diff is collapsed.
......@@ -146,7 +146,7 @@ class ConnectionHelper:
# we don't know how or don't want to handle these (including Unauthorized)
req.raise_for_status()
except requests.exceptions.SSLError as exc:
raise AuthenticationError("%s\nCouldn't authenticate compute_node. Please "
raise AuthenticationError("%s\nCouldn't authenticate computer. Please "
"check that certificate and key exist and are valid." % exc)
# XXX TODO parse server messages for client configure and node register
......@@ -336,7 +336,7 @@ class HateoasNavigator(object):
self.getRootDocument()['_links']['me']['href'])
def getMeDocument(self):
# User can be a Person, Software Instance or ComputeNode
# User can be a Person, Software Instance or Computer
return self.jio_get(self._getMeUrl())
class SlapHateoasNavigator(HateoasNavigator):
......@@ -354,8 +354,8 @@ class SlapHateoasNavigator(HateoasNavigator):
return result['data']['rows']
def _getComputeNodeList(self, title=None, reference=None, select_list=["title", "reference"]):
query_str = 'portal_type:"Compute Node" AND validation_state:validated'
def _getComputerList(self, title=None, reference=None, select_list=["title", "reference"]):
query_str = 'portal_type:"Computer" AND validation_state:validated'
if title is not None:
query_str += ' AND title:="%s"' % title
......@@ -392,24 +392,24 @@ class SlapHateoasNavigator(HateoasNavigator):
return instance_tree_dict
def getComputeNodeDict(self):
compute_node_list = self._getComputeNodeList()
compute_node_dict = {}
for compute_node_json in compute_node_list:
compute_node = TempDocument()
for key, value in six.iteritems(compute_node_json):
def getComputerDict(self):
computer_list = self._getComputerList()
computer_dict = {}
for computer_json in computer_list:
computer = TempDocument()
for key, value in six.iteritems(computer_json):
if key in ['_links']:
continue
setattr(compute_node, '_%s' % key, value)
compute_node_dict[compute_node._title] = compute_node
setattr(computer, '_%s' % key, value)
computer_dict[computer._title] = computer
return compute_node_dict
return computer_dict
def getToken(self):
root_document = self.getRootDocument()
hateoas_url = root_document['_links']['self']['href']
token_json = self.jio_getAttachment(
"compute_node_module", hateoas_url + "/compute_node_module/Base_getComputeNodeToken", {})
"computer_module", hateoas_url + "/computer_module/Base_getComputerToken", {})
return token_json["access_token"]
......@@ -431,29 +431,29 @@ class SlapHateoasNavigator(HateoasNavigator):
return self.jio_get(instance_tree_jio_key)
def _getComputeNode(self, reference):
compute_node_list = self._getComputeNodeList(reference=reference,
def _getComputer(self, reference):
computer_list = self._getComputerList(reference=reference,
select_list=["reference", "relative_url"])
assert len(compute_node_list) <= 1, \
"There are more them one Compute Node for this reference"
assert len(computer_list) <= 1, \
"There are more them one Computer for this reference"
compute_node_jio_key = None
for compute_node_candidate in compute_node_list:
if compute_node_candidate.get("reference") == reference:
compute_node_jio_key = compute_node_candidate['relative_url']
computer_jio_key = None
for computer_candidate in computer_list:
if computer_candidate.get("reference") == reference:
computer_jio_key = computer_candidate['relative_url']
break
if compute_node_jio_key is None:
raise NotFoundError('This compute_node does not exist.')
if computer_jio_key is None:
raise NotFoundError('This computer does not exist.')
return self.jio_get(compute_node_jio_key)
return self.jio_get(computer_jio_key)
def getSoftwareInstallationList(self, compute_node_guid=None,
def getSoftwareInstallationList(self, computer_guid=None,
select_list=['uid', 'relative_url', 'url_string', 'SoftwareInstallation_getNewsDict']):
query_str = 'portal_type:"Software Installation" AND validation_state:validated'
if compute_node_guid is not None:
query_str += ' AND default_aggregate_reference:="%s"' % compute_node_guid
if computer_guid is not None:
query_str += ' AND default_aggregate_reference:="%s"' % computer_guid
result = self.jio_allDocs(
query={"query" : query_str, "select_list": select_list})
......@@ -463,18 +463,18 @@ class SlapHateoasNavigator(HateoasNavigator):
def getInstanceNews(self, url):
return self.jio_get(url)['news']
def getSoftwareInstallationNews(self, compute_node_guid=None, url=None):
for si in self.getSoftwareInstallationList(compute_node_guid):
def getSoftwareInstallationNews(self, computer_guid=None, url=None):
for si in self.getSoftwareInstallationList(computer_guid):
if si["url_string"] == url:
return si['SoftwareInstallation_getNewsDict']['text']
return "#error no data found"
def getComputeNodeNews(self, compute_node_guid):
return self._getComputeNode(reference=compute_node_guid)['data']['news']['compute_node']['text']
def getComputerNews(self, computer_guid):
return self._getComputer(reference=computer_guid)['data']['news']['computer']['text']
def getComputePartitionNews(self, compute_node_guid, partition_id):
def getComputerPartitionNews(self, computer_guid, partition_id):
try:
return self._getComputeNode(reference=compute_node_guid)['data']['news']['partition'][partition_id]['text']
return self._getComputer(reference=computer_guid)['data']['news']['partition'][partition_id]['text']
except KeyError:
return "#error no data found"
......
This diff is collapsed.
This diff is collapsed.
......@@ -179,7 +179,7 @@ class SlapOSConfigWriter(ConfigWriter):
config += 'key = {pfc.key}\n'.format(pfc=pfc)
config += 'software_release_list =\n {}\n'.format('\n '.join(pfc.software_release_list))
if isinstance(pfc, PartitionForwardAsPartitionConfiguration):
config += "compute_node = {pfc.compute_node}\n".format(pfc=pfc)
config += "computer = {pfc.computer}\n".format(pfc=pfc)
config += "partition = {pfc.partition}\n".format(pfc=pfc)
yield config
......@@ -201,7 +201,7 @@ class SlapOSConfigWriter(ConfigWriter):
{standalone_slapos._shared_part_root}
master_url = {standalone_slapos._master_url}
master_rest_url = {standalone_slapos._master_url}/hateoas
compute_node_id = {standalone_slapos._compute_node_id}
computer_id = {standalone_slapos._computer_id}
root_check = False
pidfile_software = {standalone_slapos._instance_pid}
pidfile_instance = {standalone_slapos._software_pid}
......@@ -215,7 +215,7 @@ class SlapOSConfigWriter(ConfigWriter):
alter_network = false
create_tap = false
create_tun = false
compute_node_xml = {standalone_slapos._slapos_xml}
computer_xml = {standalone_slapos._slapos_xml}
[slapproxy]
host = {standalone_slapos._server_ip}
......@@ -280,7 +280,7 @@ class SlapformatDefinitionWriter(ConfigWriter):
f.write(
textwrap.dedent(
"""
[compute_node]
[computer]
address = {ipv4_cidr}\n
""").format(**locals()))
for i in range(self._standalone_slapos._partition_count):
......@@ -318,7 +318,7 @@ class PartitionForwardAsPartitionConfiguration(PartitionForwardConfiguration):
def __init__(
self,
master_url,
compute_node,
computer,
partition,
cert=None,
key=None,
......@@ -331,7 +331,7 @@ class PartitionForwardAsPartitionConfiguration(PartitionForwardConfiguration):
key,
software_release_list,
)
self.compute_node = compute_node
self.computer = computer
self.partition = partition
......@@ -339,12 +339,12 @@ class PartitionForwardAsPartitionConfiguration(PartitionForwardConfiguration):
class StandaloneSlapOS(object):
"""A SlapOS that can be embedded in other applications, also useful for testing.
This plays the role of an `IComputeNode` where users of classes implementing this
This plays the role of an `IComputer` where users of classes implementing this
interface can install software, create partitions and access parameters of the
running partitions.
Extends the existing `IRequester` and `ISupply`, with the special behavior that
`IRequester.request` and `ISupply.supply` will only use the embedded compute_node.
`IRequester.request` and `ISupply.supply` will only use the embedded computer.
"""
# an "hidden" flag to run slapos node instance and software with --all, for
# test suites for softwares with missing promises.
......@@ -355,7 +355,7 @@ class StandaloneSlapOS(object):
base_directory,
server_ip,
server_port,
compute_node_id='local',
computer_id='local',
shared_part_list=(),
software_root=None,
instance_root=None,
......@@ -370,7 +370,7 @@ class StandaloneSlapOS(object):
Arguments:
* `base_directory` -- the directory which will contain softwares and instances.
* `server_ip`, `server_port` -- the address this SlapOS proxy will listen to.
* `compute_node_id` -- the id of this compute_node.
* `computer_id` -- the id of this computer.
* `shared_part_list` -- list of extra paths to use as read-only ${buildout:shared-part-list}.
* `software_root` -- directory to install software, default to "soft" in `base_directory`
* `instance_root` -- directory to create instances, default to "inst" in `base_directory`
......@@ -448,7 +448,7 @@ class StandaloneSlapOS(object):
'{self._log_directory}/slapos-node-auto.log',
}
}
self._compute_node_id = compute_node_id
self._computer_id = computer_id
self._slap = slap()
self._slap.initializeConnection(self._master_url)
......@@ -523,10 +523,10 @@ class StandaloneSlapOS(object):
self.start()
@property
def compute_node(self):
"""Access the compute_node.
def computer(self):
"""Access the computer.
"""
return self._slap.registerComputeNode(self._compute_node_id)
return self._slap.registerComputer(self._computer_id)
@property
def software_directory(self):
......@@ -602,7 +602,7 @@ class StandaloneSlapOS(object):
if os.path.isdir(path) and os.path.basename(path) not in ('var', 'etc'):
unknown_partition_set.add(path)
# create partitions and configure compute_node
# create partitions and configure computer
partition_list = []
for i in range(partition_count):
partition_reference = '%s%s' % (partition_base_name, i)
......@@ -632,26 +632,26 @@ class StandaloneSlapOS(object):
if unknown_partition_set:
# sanity check that we are not removing partitions in use
compute_partition_dict = {
compute_node_part.getId(): compute_node_part
for compute_node_part in self.compute_node.getComputePartitionList()
computer_partition_dict = {
computer_part.getId(): computer_part
for computer_part in self.computer.getComputerPartitionList()
}
for part in unknown_partition_set:
# used in format(**locals()) below
part_id = os.path.basename(part) # pylint: disable=unused-variable
compute_partition = compute_partition_dict.get(os.path.basename(part))
if compute_partition is not None \
and compute_partition.getState() != "destroyed":
computer_partition = computer_partition_dict.get(os.path.basename(part))
if computer_partition is not None \
and computer_partition.getState() != "destroyed":
raise ValueError(
"Cannot reformat to remove busy partition at {part_id}".format(
**locals()))
self.compute_node.updateConfiguration(
self.computer.updateConfiguration(
dumps({
'address': ipv4_address,
'netmask': '255.255.255.255',
'partition_list': partition_list,
'reference': self._compute_node_id,
'reference': self._computer_id,
'instance_root': self._instance_root,
'software_root': self._software_root
}))
......@@ -683,16 +683,16 @@ class StandaloneSlapOS(object):
SlapOSConfigWriter(self).writeConfig(self._slapos_config)
SlapformatDefinitionWriter(self).writeConfig(self._slapformat_definition)
def supply(self, software_url, compute_node_guid=None, state="available"):
def supply(self, software_url, computer_guid=None, state="available"):
"""Supply a software, see ISupply.supply
Software can only be supplied on this embedded compute_node.
Software can only be supplied on this embedded computer.
"""
if compute_node_guid not in (None, self._compute_node_id):
raise ValueError("Can only supply on embedded compute_node")
if computer_guid not in (None, self._computer_id):
raise ValueError("Can only supply on embedded computer")
self._slap.registerSupply().supply(
software_url,
self._compute_node_id,
self._computer_id,
state=state,
)
......@@ -707,10 +707,10 @@ class StandaloneSlapOS(object):
state=None):
"""Request an instance, see IRequester.request
Instance can only be requested on this embedded compute_node.
Instance can only be requested on this embedded computer.
"""
if filter_kw is not None:
raise ValueError("Can only request on embedded compute_node")
raise ValueError("Can only request on embedded computer")
return self._slap.registerOpenOrder().request(
software_release,
software_type=software_type,
......
......@@ -43,7 +43,7 @@ from ..slap.standalone import StandaloneSlapOS
from ..slap.standalone import SlapOSNodeCommandError
from ..slap.standalone import PathTooDeepError
from ..util import mkdir_p
from ..slap import ComputePartition
from ..slap import ComputerPartition
from .check_software import checkSoftware
try:
......@@ -245,10 +245,10 @@ class SlapOSInstanceTestCase(unittest.TestCase):
The following class attributes are available:
* `compute_partition`: the `slapos.slap.slap.ComputePartition`
compute partition instance.
* `computer_partition`: the `slapos.slap.slap.ComputerPartition`
computer partition instance.
* `compute_partition_root_path`: the path of the instance root
* `computer_partition_root_path`: the path of the instance root
directory.
This class is not supposed to be imported directly, but needs to be setup by
......@@ -277,8 +277,8 @@ class SlapOSInstanceTestCase(unittest.TestCase):
_resources = {} # type: Dict[str, ManagedResource]
_instance_parameter_dict = None # type: Dict
compute_partition = None # type: ComputePartition
compute_partition_root_path = None # type: str
computer_partition = None # type: ComputerPartition
computer_partition_root_path = None # type: str
# a short name of that software URL.
# eg. helloworld instead of
......@@ -390,12 +390,12 @@ class SlapOSInstanceTestCase(unittest.TestCase):
max_retry=cls.instance_max_retry, debug=cls._debug)
# expose some class attributes so that tests can use them:
# the main ComputePartition instance, to use getInstanceParameterDict
cls.compute_partition = cls.requestDefaultInstance()
# the main ComputerPartition instance, to use getInstanceParameterDict
cls.computer_partition = cls.requestDefaultInstance()
# the path of the instance on the filesystem, for low level inspection
cls.compute_partition_root_path = os.path.join(
cls.slap._instance_root, cls.compute_partition.getId())
cls.computer_partition_root_path = os.path.join(
cls.slap._instance_root, cls.computer_partition.getId())
cls.logger.debug("setUpClass done")
except BaseException:
cls.logger.exception("Error during setUpClass")
......@@ -541,7 +541,7 @@ class SlapOSInstanceTestCase(unittest.TestCase):
cls._storeSystemSnapshot(
"{}._cleanup waitForReport".format(snapshot_name))
leaked_partitions = [
cp for cp in cls.slap.compute_node.getComputePartitionList()
cp for cp in cls.slap.computer.getComputerPartitionList()
if cp.getState() != 'destroyed'
]
if leaked_partitions:
......
......@@ -201,7 +201,7 @@ class CrontabMixin(object):
"""
with open(
os.path.join(
self.compute_partition_root_path,
self.computer_partition_root_path,
'etc',
'cron.d',
crontab_name,
......
This diff is collapsed.
......@@ -45,9 +45,9 @@ import slapos.cli.console
import slapos.cli.entry
import slapos.cli.info
import slapos.cli.list
import slapos.cli.compute_node_info
import slapos.cli.compute_node_list
import slapos.cli.compute_node_token
import slapos.cli.computer_info
import slapos.cli.computer_list
import slapos.cli.computer_token
import slapos.cli.supervisorctl
from slapos.cli.proxy_show import do_show, StringIO
from slapos.cli.cache import do_lookup as cache_do_lookup
......@@ -206,7 +206,7 @@ class TestCliProxyShow(CliMixin):
db.commit()
# by default we simulate being invoked with "show all" arguments
self.conf.compute_nodes = True
self.conf.computers = True
self.conf.software = True
self.conf.partitions = True
self.conf.slaves = True
......@@ -392,8 +392,8 @@ class TestCliNode(CliMixin):
software_release.getURI = mock.Mock(return_value='http://example.org/software.cfg')
software_release.building = mock.Mock()
compute_node = mock.MagicMock()
compute_node.getSoftwareReleaseList = mock.Mock(return_value=[software_release])
computer = mock.MagicMock()
computer.getSoftwareReleaseList = mock.Mock(return_value=[software_release])
software = mock.MagicMock()
from slapos.grid.slapgrid import Slapgrid
......@@ -401,7 +401,7 @@ class TestCliNode(CliMixin):
with patch('slapos.cli.slapgrid.check_root_user', return_value=True) as checked_root_user, \
patch('slapos.cli.slapgrid.setRunning') as write_pid_file, \
patch.object(Slapgrid, 'checkEnvironmentAndCreateStructure') as checkEnvironmentAndCreateStructure, \
patch.object(slap, 'registerComputeNode', return_value=compute_node) as registerComputeNode, \
patch.object(slap, 'registerComputer', return_value=computer) as registerComputer, \
patch('slapos.grid.slapgrid.Software', return_value=software) as Software, \
patch('slapos.grid.slapgrid.open') as _open:
......@@ -412,7 +412,7 @@ class TestCliNode(CliMixin):
logger=mock.ANY,
pidfile='/opt/slapos/slapgrid-sr.pid')
checkEnvironmentAndCreateStructure.assert_called_once()
registerComputeNode.assert_called_once()
registerComputer.assert_called_once()
software_constructor_call, = Software.call_args_list
self.assertEqual('http://example.org/software.cfg', software_constructor_call[1]['url'])
......@@ -429,7 +429,7 @@ class TestCliNode(CliMixin):
from slapos.grid.slapgrid import Slapgrid
with patch('slapos.cli.slapgrid.check_root_user', return_value=True) as checked_root_user, \
patch('slapos.cli.slapgrid.setRunning') as write_pid_file, \
patch.object(Slapgrid, 'processComputePartitionList') as processComputePartitionList:
patch.object(Slapgrid, 'processComputerPartitionList') as processComputerPartitionList:
app.run(('node', 'instance'))
......@@ -437,7 +437,7 @@ class TestCliNode(CliMixin):
write_pid_file.assert_called_once_with(
logger=mock.ANY,
pidfile='/opt/slapos/slapgrid-cp.pid')
processComputePartitionList.assert_called_once()
processComputerPartitionList.assert_called_once()
def test_node_prune(self):
"""slapos node prune command
......@@ -516,65 +516,65 @@ class TestCliInfo(CliMixin):
self.logger.warning.assert_called_once_with('Instance %s does not exist.', self.conf.reference)
class TestCliComputeNodeList(CliMixin):
def test_compute_node_list(self):
class TestCliComputerList(CliMixin):
def test_computer_list(self):
"""
Test "slapos compute_node list" command output.
Test "slapos computer list" command output.
"""
return_value = {
'compute_node1': slapos.slap.hateoas.TempDocument(title='compute_node1', _reference='COMP-1'),
'compute_node2': slapos.slap.hateoas.TempDocument(title='compute_node2', _reference='COMP-0'),
'computer1': slapos.slap.hateoas.TempDocument(title='computer1', _reference='COMP-1'),
'computer2': slapos.slap.hateoas.TempDocument(title='computer2', _reference='COMP-0'),
}
with patch.object(slapos.slap.slap, 'getComputeNodeDict', return_value=return_value) as _:
slapos.cli.compute_node_list.do_list(self.logger, None, self.local)
with patch.object(slapos.slap.slap, 'getComputerDict', return_value=return_value) as _:
slapos.cli.computer_list.do_list(self.logger, None, self.local)
self.logger.info.assert_any_call('%s %s', 'COMP-1', 'compute_node1')
self.logger.info.assert_any_call('%s %s', 'COMP-0', 'compute_node2')
self.logger.info.assert_any_call('%s %s', 'COMP-1', 'computer1')
self.logger.info.assert_any_call('%s %s', 'COMP-0', 'computer2')
def test_compute_node_emptyList(self):
with patch.object(slapos.slap.slap, 'getComputeNodeDict', return_value={}) as _:
slapos.cli.compute_node_list.do_list(self.logger, None, self.local)
def test_computer_emptyList(self):
with patch.object(slapos.slap.slap, 'getComputerDict', return_value={}) as _:
slapos.cli.computer_list.do_list(self.logger, None, self.local)
self.logger.info.assert_called_once_with('No existing compute_node.')
self.logger.info.assert_called_once_with('No existing computer.')
@patch.object(slapos.slap.slap, 'registerComputeNode', return_value=slapos.slap.ComputeNode("COMP-1"))
class TestComputeNodeCliInfo(CliMixin):
def test_compute_node_info(self, _):
@patch.object(slapos.slap.slap, 'registerComputer', return_value=slapos.slap.Computer("COMP-1"))
class TestComputerCliInfo(CliMixin):
def test_computer_info(self, _):
"""
Test "slapos compute_node info" command output.
Test "slapos computer info" command output.
"""
setattr(self.conf, 'reference', 'COMP-1')
compute_node = slapos.slap.ComputeNode("COMP-1")
compute_node._reference = "COMP-1"
compute_node._title = "compute_node1"
with patch.object(slapos.slap.ComputeNode, 'getInformation', return_value=compute_node):
slapos.cli.compute_node_info.do_info(self.logger, self.conf, self.local)
computer = slapos.slap.Computer("COMP-1")
computer._reference = "COMP-1"
computer._title = "computer1"
with patch.object(slapos.slap.Computer, 'getInformation', return_value=computer):
slapos.cli.computer_info.do_info(self.logger, self.conf, self.local)
self.logger.info.assert_any_call('Compute Node Reference: %s', compute_node._reference)
self.logger.info.assert_any_call('Compute Node Title : %s', compute_node._title)
self.logger.info.assert_any_call('Computer Reference: %s', computer._reference)
self.logger.info.assert_any_call('Computer Title : %s', computer._title)
def test_compute_node_unknownReference(self, _):
def test_computer_unknownReference(self, _):
"""
Test "slapos compute_node info" command output in case reference
of compute_node is not known.
Test "slapos computer info" command output in case reference
of computer is not known.
"""
setattr(self.conf, 'reference', 'COMP-0')
with patch.object(slapos.slap.ComputeNode, 'getInformation', side_effect=raiseNotFoundError):
slapos.cli.compute_node_info.do_info(self.logger, self.conf, self.local)
with patch.object(slapos.slap.Computer, 'getInformation', side_effect=raiseNotFoundError):
slapos.cli.computer_info.do_info(self.logger, self.conf, self.local)
self.logger.warning.assert_called_once_with('Compute Node %s does not exist.', self.conf.reference)
self.logger.warning.assert_called_once_with('Computer %s does not exist.', self.conf.reference)
@patch.object(slapos.slap.slap, 'registerToken', return_value=slapos.slap.Token())
class TestComputeNodeCliToken(CliMixin):
def test_compute_node_token(self, _):
class TestComputerCliToken(CliMixin):
def test_computer_token(self, _):
"""
Test "slapos compute_node token" command output.
Test "slapos computer token" command output.
"""
token = "1234567-90"
with patch.object(slapos.slap.Token, 'request', return_value=token):
slapos.cli.compute_node_token.do_token(self.logger, self.conf, self.local)
slapos.cli.computer_token.do_token(self.logger, self.conf, self.local)
self.logger.info.assert_any_call('Compute Node token: %s', "1234567-90")
self.logger.info.assert_any_call('Computer token: %s', "1234567-90")
@patch.object(supervisor.supervisorctl, 'main')
class TestCliSupervisorctl(CliMixin):
......@@ -605,7 +605,7 @@ print(request('software_release', 'instance').getInstanceParameterDict()['parame
@contextmanager
def _test_console(self):
cp = slapos.slap.ComputePartition('compute_node_%s' % self.id(), 'partition_%s' % self.id())
cp = slapos.slap.ComputerPartition('computer_%s' % self.id(), 'partition_%s' % self.id())
cp._parameter_dict = {'parameter_name': 'parameter_value'}
with patch.object(slapos.slap.OpenOrder, 'request',
return_value = cp) as mock_request, \
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment