Skip to content
Permalink
Browse files

Merge branch 'master' of github.com:opensvc/opensvc

  • Loading branch information...
cvaroqui committed Jul 22, 2019
2 parents 859eccf + 063d9d3 commit fc780667b67aca7cf8b00d4268aea19b2c1eb550
Showing with 82 additions and 79 deletions.
  1. +5 −1 lib/keywords.py
  2. +10 −15 lib/nodedict.py
  3. +1 −46 lib/resTask.py
  4. +58 −0 lib/resTaskHost.py
  5. +5 −5 lib/svcBuilder.py
  6. +3 −12 lib/svcdict.py
@@ -162,6 +162,10 @@ def template_rst(self, section=None):
fill="node."
if "template.cluster" in self.top.template_prefix:
fill="cluster."
if "template.secret" in self.top.template_prefix:
fill="secret."
if "template.cfg" in self.top.template_prefix:
fill="cfg."
s += ".. _%s%s.%s:\n\n" % (fill, section, self.keyword)

s += ':kw:`%s`\n' % self.keyword
@@ -268,7 +272,7 @@ def _template_rst(self, rtype, section, write=False):
fpath = os.path.join(dpath, self.top.template_prefix+section+".rst")
s = section + "\n"
s += "*" * len(section) + "\n\n"
if self.top.template_prefix != "template.node." and len(section.split('.')) > 1:
if self.top.template_prefix != "template.node." and self.top.template_prefix != "template.cluster." and len(section.split('.')) > 1:
s += ".. include:: template.service." + section + ".example\n\n"
for keyword in sorted(self.getkeys(rtype)):
s += keyword.template(fmt="rst", section=section)
@@ -60,8 +60,7 @@
"section": "node",
"keyword": "connect_to",
"example": "1.2.3.4",
"default_text": "On GCE instances, defaults to the instance ip address.",
"text": "An asset information to push to the collector on pushasset, overriding the currently stored value."
"text": "An asset information to push to the collector on pushasset, overriding the currently discovered value. On GCE instances, defaults to the instance ip address."
},
{
"section": "node",
@@ -171,12 +170,6 @@
"example": "+0200",
"text": "Override for the corresponding pushasset discovery probe."
},
{
"section": "node",
"keyword": "connect_to",
"example": "1.2.3.4",
"text": "Override for the corresponding pushasset discovery probe."
},
{
"section": "node",
"keyword": "manufacturer",
@@ -412,7 +405,9 @@
"keyword": "repo",
"example": "http://opensvc.repo.corp",
"text": """Set the uri of the opensvc agent package repository and compliance modules gzipped tarball repository. This parameter is used by the 'nodemgr updatepkg' and 'nodemgr updatecomp' commands.
Expected repository structure::
ROOT
+- compliance
+- compliance-100.tar.gz
@@ -430,14 +425,17 @@
+- opensvc-1.9-49.rpm
+- opensvc-1.9-50.rpm
+- tbz
"""
},
{
"section": "node",
"keyword": "repopkg",
"example": "http://repo.opensvc.com",
"text": """Set the uri of the opensvc agent package repository. This parameter is used by the 'nodemgr updatepkg' command.
Expected repository structure::
ROOT
+- deb
+- depot
@@ -450,18 +448,22 @@
+- opensvc-1.9-49.rpm
+- opensvc-1.9-50.rpm
+- tbz
"""
},
{
"section": "node",
"keyword": "repocomp",
"example": "http://compliance.repo.corp",
"text": """Set the uri of the opensvc compliance modules gzipped tarball repository. This parameter is used by the 'nodemgr updatecomp' command.
Expected repository structure::
ROOT
+- compliance-100.tar.gz
+- compliance-101.tar.gz
+- current -> compliance-101.tar.gz
"""
},
{
@@ -1145,13 +1147,6 @@
"example": "/path/to/key",
"text": "The path to the private key to use to log in the switch."
},
{
"section": "switch",
"rtype": "brocade",
"keyword": "password",
"example": "admin",
"text": "The password to use to log in the switch. Either username or key must be specified."
},
{
"section": "array",
"keyword": "type",
@@ -10,34 +10,6 @@
from rcUtilities import lcall
from six.moves import input

def run_as_popen_kwargs(user):
if rcEnv.sysname == "Windows":
return {}
if user is None:
return {}
cwd = rcEnv.paths.pathtmp
import pwd
try:
pw_record = pwd.getpwnam(user)
except Exception as exc:
raise ex.excError("user lookup failure: %s" % str(exc))
user_name = pw_record.pw_name
user_home_dir = pw_record.pw_dir
user_uid = pw_record.pw_uid
user_gid = pw_record.pw_gid
env = os.environ.copy()
env['HOME'] = user_home_dir
env['LOGNAME'] = user_name
env['PWD'] = cwd
env['USER'] = user_name
return {'preexec_fn': demote(user_uid, user_gid), 'cwd': cwd, 'env': env}

def demote(user_uid, user_gid):
def result():
os.setgid(user_gid)
os.setuid(user_uid)
return result

class Task(Res.Resource):
default_optional = True
def __init__(self,
@@ -154,27 +126,10 @@ def _run(self):


def _run_call(self):
kwargs = {
'timeout': self.timeout,
'blocking': True,
}
kwargs.update(run_as_popen_kwargs(self.user))
if self.configs_environment or self.secrets_environment:
if "env" not in kwargs:
kwargs["env"] = {}
kwargs["env"].update(self.kind_environment_env("cfg", self.configs_environment))
kwargs["env"].update(self.kind_environment_env("sec", self.secrets_environment))
try:
self.action_triggers("", "command", **kwargs)
except ex.excError:
if self.on_error:
kwargs["blocking"] = False
self.action_triggers("", "on_error", **kwargs)
raise
pass

def _status(self, verbose=False):
return rcStatus.NA

def is_provisioned(self, refresh=False):
return True

@@ -0,0 +1,58 @@
import resTask
import rcExceptions as ex
import os

from rcGlobalEnv import rcEnv

def run_as_popen_kwargs(user):
if rcEnv.sysname == "Windows":
return {}
if user is None:
return {}
cwd = rcEnv.paths.pathtmp
import pwd
try:
pw_record = pwd.getpwnam(user)
except Exception as exc:
raise ex.excError("user lookup failure: %s" % str(exc))
user_name = pw_record.pw_name
user_home_dir = pw_record.pw_dir
user_uid = pw_record.pw_uid
user_gid = pw_record.pw_gid
env = os.environ.copy()
env['HOME'] = user_home_dir
env['LOGNAME'] = user_name
env['PWD'] = cwd
env['USER'] = user_name
return {'preexec_fn': demote(user_uid, user_gid), 'cwd': cwd, 'env': env}

def demote(user_uid, user_gid):
def result():
os.setgid(user_gid)
os.setuid(user_uid)
return result

class Task(resTask.Task):
def __init__(self, *args, **kwargs):
kwargs["type"] = "task.host"
resTask.Task.__init__(self, *args, **kwargs)


def _run_call(self):
kwargs = {
'timeout': self.timeout,
'blocking': True,
}
kwargs.update(run_as_popen_kwargs(self.user))
if self.configs_environment or self.secrets_environment:
if "env" not in kwargs:
kwargs["env"] = {}
kwargs["env"].update(self.kind_environment_env("cfg", self.configs_environment))
kwargs["env"].update(self.kind_environment_env("sec", self.secrets_environment))
try:
self.action_triggers("", "command", **kwargs)
except ex.excError:
if self.on_error:
kwargs["blocking"] = False
self.action_triggers("", "on_error", **kwargs)
raise
@@ -1490,8 +1490,8 @@ def add_task(svc, s):
add_task_docker(svc, s)
elif rtype == "podman":
add_task_podman(svc, s)
else:
add_task_default(svc, s)
elif rtype == "host":
add_task_host(svc, s)

def add_task_podman(svc, s):
kwargs = init_kwargs(svc, s)
@@ -1557,7 +1557,7 @@ def add_task_docker(svc, s):
r = resTaskDocker.Task(**kwargs)
svc += r

def add_task_default(svc, s):
def add_task_host(svc, s):
kwargs = init_kwargs(svc, s)
kwargs["command"] = svc.oget(s, "command")
kwargs["on_error"] = svc.oget(s, "on_error")
@@ -1568,8 +1568,8 @@ def add_task_default(svc, s):
kwargs["confirmation"] = svc.oget(s, "confirmation")
kwargs["secrets_environment"] = svc.oget(s, "secrets_environment")
kwargs["configs_environment"] = svc.oget(s, "configs_environment")
import resTask
r = resTask.Task(**kwargs)
import resTaskHost
r = resTaskHost.Task(**kwargs)
svc += r

def add_app_winservice(svc, s):
@@ -621,7 +621,7 @@
"section": "container",
"keyword": "name",
"at": True,
"rtype": rcEnv.vt_supported,
"rtype": list(set(rcEnv.vt_supported)-set(["docker", "podman"])),
"default_text": "the service name",
"text": "Set if the container hostname is different from the container name."
},
@@ -2050,16 +2050,6 @@
"text": "The wwn of the disk.",
"example": "6589cfc00000097484f0728d8b2118a6"
},
{
"section": "disk",
"rtype": "disk",
"keyword": "size",
"convert": "size",
"at": True,
"provisioning": True,
"text": "The size of the disk to provision.",
"example": "15g"
},
{
"section": "disk",
"rtype": "disk",
@@ -2944,7 +2934,8 @@
{
"section": "task",
"keyword": "type",
"candidates": [None, "docker", "podman"],
"candidates": ["host", "docker", "podman"],
"default": "host",
"text": "The type of task. Default tasks run on the host, their use is limited to the cluster admin population. Containerized tasks are safe for unprivileged population."
},
{

0 comments on commit fc78066

Please sign in to comment.
You can’t perform that action at this time.