Пример #1
0
class QconfConvert(QconfCli):
    """ Qconf upgrade command. """
    def __init__(self):
        QconfCli.__init__(self)
        self.api = QconfApi()
        self.add_option(
            '',
            '--input-file',
            dest='input_file',
            help='Input file containing object\'s JSON representation.')
        self.add_option('',
                        '--to-uge',
                        dest='target_uge_version',
                        default=self.api.get_uge_version(),
                        help='Target UGE version (default: %s).' %
                        self.api.get_uge_version())
        self.add_option(
            '',
            '--output-format',
            dest='output_format',
            default='json',
            help='Output format, either json or uge (default: json).')

    def check_input_args(self):
        if not self.options.input_file:
            raise InvalidRequest('Missing input file.')
        if self.options.output_format not in ['json', 'uge']:
            raise InvalidRequest('Output format may be either json or uge.')

    def run_command(self):
        self.parse_args("""
    qconf-convert --input-file=INPUT_FILE
        [--to-uge=TARGET_UGE_VERSION]
        [--output-format=OUTPUT_FORMAT]

Description:
    Converts Qconf object with a given JSON representation to equivalent object corresponding to the specified target UGE version. 
""")
        input_file = self.options.input_file
        target_uge_version = self.options.target_uge_version
        json_string = open(input_file).read()
        qconf_object = self.api.generate_object(json_string,
                                                target_uge_version)
        if self.options.output_format == 'json':
            print qconf_object.to_json()
        else:
            print qconf_object.to_uge()
Пример #2
0
 def __init__(self):
     QconfCli.__init__(self)
     self.api = QconfApi()
     self.add_option(
         '',
         '--input-file',
         dest='input_file',
         help='Input file containing object\'s JSON representation.')
     self.add_option('',
                     '--to-uge',
                     dest='target_uge_version',
                     default=self.api.get_uge_version(),
                     help='Target UGE version (default: %s).' %
                     self.api.get_uge_version())
     self.add_option(
         '',
         '--output-format',
         dest='output_format',
         default='json',
         help='Output format, either json or uge (default: json).')
Пример #3
0
import types
from nose import SkipTest

from .utils import needs_uge
from .utils import generate_random_string
from .utils import create_config_file
from .utils import load_values

from uge.api.qconf_api import QconfApi
from uge.config.config_manager import ConfigManager
from uge.log.log_manager import LogManager
from uge.exceptions.object_not_found import ObjectNotFound
from uge.exceptions.object_already_exists import ObjectAlreadyExists

create_config_file()
API = QconfApi()
HOST_GROUP_NAME = '@%s' % generate_random_string(6)
CONFIG_MANAGER = ConfigManager.get_instance()
HOST_NAME = CONFIG_MANAGER['host']
LOG_MANAGER = LogManager.get_instance()
VALUES_DICT = load_values('test_values.json')
print(VALUES_DICT)


@needs_uge
def test_generate_hgrp():
    hgrp = API.generate_hgrp(HOST_GROUP_NAME)
    assert (hgrp.data['group_name'] == HOST_GROUP_NAME)


def test_list_hgrps():
Пример #4
0
###########################################################################
#___INFO__MARK_END__
#
import types
from utils import needs_uge
from utils import generate_random_string
from utils import create_config_file

from uge.api.qconf_api import QconfApi
from uge.config.config_manager import ConfigManager
from uge.log.log_manager import LogManager
from uge.exceptions.object_not_found import ObjectNotFound
from uge.exceptions.object_already_exists import ObjectAlreadyExists

create_config_file()
API = QconfApi()
PE_NAME = '%s.q' % generate_random_string(6)
CONFIG_MANAGER = ConfigManager.get_instance()
LOG_MANAGER = LogManager.get_instance()


@needs_uge
def test_object_not_found():
    try:
        pe = API.get_pe('__non_existent_pe__')
        assert (False)
    except ObjectNotFound, ex:
        # ok
        pass

Пример #5
0
########################################################################### 
#___INFO__MARK_END__ 
# 
import types
from utils import needs_uge
from utils import generate_random_string
from utils import create_config_file

from uge.api.qconf_api import QconfApi
from uge.config.config_manager import ConfigManager
from uge.log.log_manager import LogManager
from uge.exceptions.object_not_found import ObjectNotFound
from uge.exceptions.object_already_exists import ObjectAlreadyExists

create_config_file()
API = QconfApi()
USER_NAME = '%s' % generate_random_string(6)
CONFIG_MANAGER = ConfigManager.get_instance()
LOG_MANAGER = LogManager.get_instance()

@needs_uge
def test_object_not_found():
    try:
        user = API.get_user('__non_existent_user__')
        assert(False)
    except ObjectNotFound, ex:
        # ok
        pass

def test_generate_user():
    user = API.generate_user(USER_NAME)
Пример #6
0
###########################################################################
#___INFO__MARK_END__
#
from utils import needs_uge
from utils import generate_random_string
from utils import generate_random_string_list
from utils import create_config_file

from uge.api.qconf_api import QconfApi
from uge.config.config_manager import ConfigManager
from uge.log.log_manager import LogManager
from uge.exceptions.object_not_found import ObjectNotFound
from uge.exceptions.object_already_exists import ObjectAlreadyExists

create_config_file()
API = QconfApi()
ACL_NAME = 'acl.%s' % generate_random_string(6)
USER1_NAME = 'user.%s' % generate_random_string(6)
USER2_NAME = 'user.%s' % generate_random_string(6)
CONFIG_MANAGER = ConfigManager.get_instance()
LOG_MANAGER = LogManager.get_instance()


@needs_uge
def test_object_not_found():
    try:
        acl = API.get_acl('__non_existent_acl__')
        assert (False)
    except ObjectNotFound, ex:
        # ok
        pass
Пример #7
0
# limitations under the License.
###########################################################################
#___INFO__MARK_END__
#
from utils import needs_uge
from utils import create_config_file
from utils import generate_random_string

from uge.api.qconf_api import QconfApi
from uge.config.config_manager import ConfigManager
from uge.log.log_manager import LogManager
from uge.exceptions.object_not_found import ObjectNotFound
from uge.exceptions.object_already_exists import ObjectAlreadyExists

create_config_file()
API = QconfApi()
MANAGER_NAME = '%s' % generate_random_string(6)
CONFIG_MANAGER = ConfigManager.get_instance()
LOG_MANAGER = LogManager.get_instance()


@needs_uge
def test_list_managers():
    ol = API.list_managers()
    assert (ol is not None)


def test_add_manager():
    ol = API.list_managers()
    ol2 = API.add_managers([MANAGER_NAME])
    assert (len(ol2) == len(ol) + 1)
Пример #8
0
# limitations under the License.
###########################################################################
#___INFO__MARK_END__
#
from utils import needs_uge
from utils import generate_random_string
from utils import create_config_file

from uge.api.qconf_api import QconfApi
from uge.config.config_manager import ConfigManager
from uge.log.log_manager import LogManager
from uge.exceptions.object_not_found import ObjectNotFound
from uge.exceptions.object_already_exists import ObjectAlreadyExists

create_config_file()
API = QconfApi()
CKPT_NAME = '%s.q' % generate_random_string(6)
CONFIG_MANAGER = ConfigManager.get_instance()
LOG_MANAGER = LogManager.get_instance()


@needs_uge
def test_object_not_found():
    try:
        pe = API.get_ckpt('__non_existent_ckpt__')
        assert (False)
    except ObjectNotFound, ex:
        # ok
        pass

Пример #9
0
###########################################################################
#___INFO__MARK_END__
#
import types
from utils import needs_uge
from utils import generate_random_string
from utils import create_config_file

from uge.api.qconf_api import QconfApi
from uge.config.config_manager import ConfigManager
from uge.log.log_manager import LogManager
from uge.exceptions.object_not_found import ObjectNotFound
from uge.exceptions.object_already_exists import ObjectAlreadyExists

create_config_file()
API = QconfApi()
PROJECT_NAME = '%s' % generate_random_string(6)
CONFIG_MANAGER = ConfigManager.get_instance()
LOG_MANAGER = LogManager.get_instance()


@needs_uge
def test_object_not_found():
    try:
        project = API.get_prj('__non_existent_project__')
        assert (False)
    except ObjectNotFound, ex:
        # ok
        pass

Пример #10
0
# limitations under the License. 
########################################################################### 
#___INFO__MARK_END__ 
# 
from utils import needs_uge
from utils import create_config_file
from utils import generate_random_string

from uge.api.qconf_api import QconfApi
from uge.config.config_manager import ConfigManager
from uge.log.log_manager import LogManager
from uge.exceptions.object_not_found import ObjectNotFound
from uge.exceptions.object_already_exists import ObjectAlreadyExists

create_config_file()
API = QconfApi()
OPERATOR_NAME = '%s' % generate_random_string(6)
CONFIG_MANAGER = ConfigManager.get_instance()
LOG_MANAGER = LogManager.get_instance()

@needs_uge
def test_list_operators():
    ol = API.list_operators()
    assert(ol is not None)

def test_add_operator():
    ol = API.list_operators()
    ol2 = API.add_operators([OPERATOR_NAME])
    assert(len(ol2) == len(ol)+1)
    assert(ol2.count(OPERATOR_NAME) == 1)
Пример #11
0
# limitations under the License.
###########################################################################
#___INFO__MARK_END__
#
from utils import needs_uge
from utils import generate_random_string
from utils import create_config_file

from uge.api.qconf_api import QconfApi
from uge.config.config_manager import ConfigManager
from uge.log.log_manager import LogManager
from uge.exceptions.object_not_found import ObjectNotFound
from uge.exceptions.object_already_exists import ObjectAlreadyExists

create_config_file()
API = QconfApi()
CALENDAR_NAME = '%s' % generate_random_string(6)
CONFIG_MANAGER = ConfigManager.get_instance()
LOG_MANAGER = LogManager.get_instance()


@needs_uge
def test_object_not_found():
    try:
        calendar = API.get_cal('__non_existent_calendar__')
        assert (False)
    except ObjectNotFound, ex:
        # ok
        pass